PageSourceSearch

https://www.travelxp.com/_next/static/chunks/b6ea53d40bbc73e7.js?dpl=ee70e9d6bf591bd607a68954f2091ca94d580cc5

js travelxp.com collected 2026-10-01 12:22:03 UTC 230,774 bytes, 4 lines download raw bytes

1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="b0ea99eb-0143-441a-744a-f01de6db8dff")}catch(e){}}();
2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,436872,e=>{"use strict";var t=e.i(112414);let i={trending:"/labels/trending_text_v1.svg","top 10":"/labels/top10_text_v1.svg","new episode":"/labels/newepisode_text_v1.svg","new season":"/labels/newepisode_text_v1.svg","new show":"/labels/newepisode_text_v1.svg",upcoming:"/labels/upcoming_text_v1.svg"},r={trending:"/labels/trending_icon_v1.svg","top 10":"/labels/top10_icon_v1.svg","new episode":"/labels/newepisode_icon_v1.svg","new season":"/labels/newepisode_icon_v1.svg","new show":"/labels/newepisode_icon_v1.svg",upcoming:"/labels/upcoming_icon_v1.svg"};function a(e,s="text"){let n=("icon"===s?r:i)[e.trim().toLowerCase()];return n?`${t.CDN.watch}${n}`:""}e.s(["getLabelImage",()=>a])},606648,e=>{"use strict";var t=e.i(247167);class i{constructor(e){if(!e||"object"!=typeof e)throw Error("Configuration must be an object");if(!e.customerId)throw Error("Customer ID is required");if(!e.appId)throw Error("App ID is required");if(!e.appName)throw Error("App Name is required");if(!e.appVersion)throw Error("App Version is required");this._config={customerId:e.customerId,appId:e.appId,appName:e.appName,appVersion:e.appVersion,sdkVersion:"1.0.0",platform:"web",dataSrc:"Application",sessionId:this._generateUUID(),...e},this._serverTimeOffset=0,this.__configSourceTag="core/mm-app-analytics-sdk-config.js",this.__hasTimestampSync=!0,this._initializeStaticMetadata()}_initializeStaticMetadata(){let e=void 0!==t.default&&t.default.versions&&t.default.versions.node,i="u">typeof window&&"u">typeof document,r=i&&"u">typeof navigator&&navigator.userAgent?navigator.userAgent:"Node.js/Server",a=i&&window.screen?window.screen:{width:0,height:0,colorDepth:24};i&&/iPad|Android|Tablet/i.test(r)?this.setDeviceType("tablet"):i&&/Mobile|Android|iPhone|iPod/i.test(r)?this.setDeviceType("mobile"):this.setDeviceType("desktop"),i&&/Chrome/i.test(r)?(this.setBrowser("Chrome"),this.setBrowserVersion(r.match(/Chrome\/(\d+\.\d+\.\d+\.\d+)/)?.[1])):i&&/Firefox/i.test(r)?(this.setBrowser("Firefox"),this.setBrowserVersion(r.match(/Firefox\/(\d+\.\d+)/)?.[1])):i&&/Safari/i.test(r)&&!/Chrome/i.test(r)?(this.setBrowser("Safari"),this.setBrowserVersion(r.match(/Version\/(\d+\.\d+\.\d+)/)?.[1])):i&&/Edge/i.test(r)?(this.setBrowser("Edge"),this.setBrowserVersion(r.match(/Edge\/(\d+\.\d+\.\d+\.\d+)/)?.[1])):(this.setBrowser(e?"Node.js":"Unknown"),this.setBrowserVersion(e?t.default.version:"Unknown")),i&&/Windows/i.test(r)?(this.setOS("Windows"),this.setOSVersion(r.match(/Windows NT (\d+\.\d+)/)?.[1])):i&&/Mac OS X/i.test(r)?(this.setOS("MacOS"),this.setOSVersion(r.match(/Mac OS X (\d+[._]\d+)/)?.[1]?.replace("_","."))):i&&/Linux/i.test(r)?(this.setOS("Linux"),this.setOSVersion("Unknown")):i&&/Android/i.test(r)?(this.setOS("Android"),this.setOSVersion(r.match(/Android (\d+\.\d+)/)?.[1])):i&&/iOS|iPhone|iPad|iPod/i.test(r)?(this.setOS("iOS"),this.setOSVersion(r.match(/OS (\d+[._]\d+)/)?.[1]?.replace("_","."))):(this.setOS(e?t.default.platform:"Unknown"),this.setOSVersion(e?t.default.version:"Unknown")),this.setScreenRes(`${a.width}x${a.height}`),this.setScreenWidth(a.width),this.setScreenHeight(a.height),this.setColorDepth(a.colorDepth);let s=i&&window.devicePixelRatio?window.devicePixelRatio:1;this.setPixelRatio(s);let n=i&&window.innerWidth?window.innerWidth:0,o=i&&window.innerHeight?window.innerHeight:0;this.setViewportWidth(n),this.setViewportHeight(o);let d=i&&"u">typeof navigator&&navigator.language?navigator.language:"en-US";this.setLanguage(d);let l=i?Intl.DateTimeFormat().resolvedOptions().timeZone:"UTC";this.setTimezone(l),this.setDeviceId(this._generateUUID());let u=i&&"u">typeof navigator&&navigator.userAgent?navigator.userAgent:`Node.js/${e?t.default.version:"Unknown"} (${e?t.default.platform:"Server"})`;this.setUserAgent(u);try{if("u">typeof window){let e=Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(e=>"function"==typeof this[e]);console.log("[CONFIG BUILD]",{source:"src/core/mm-app-analytics-sdk-config.js",buildTime:(new Date).toISOString()}),console.log("[CONFIG METHODS]",e),console.log("[CONFIG TAG]",{sourceTag:this.__configSourceTag,hasTimestampSync:this.__hasTimestampSync})}}catch(e){}}setDeviceType(e){this._config.deviceType=e}setBrowser(e){this._config.browser=e}setBrowserVersion(e){this._config.browserVersion=e}setOS(e){this._config.os=e}setOSVersion(e){this._config.osVersion=e}setScreenRes(e){this._config.screenRes=e}setScreenWidth(e){this._config.screenWidth=e}setScreenHeight(e){this._config.screenHeight=e}setColorDepth(e){this._config.colorDepth=e}setPixelRatio(e){this._config.pixelRatio=e}setViewportWidth(e){this._config.viewportWidth=e}
2setViewportHeight(e){this._config.viewportHeight=e}setLanguage(e){this._config.language=e}setTimezone(e){this._config.timezone=e}setDeviceId(e){this._config.deviceId=e}setUserAgent(e){this._config.userAgent=e}_generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})}getEventMetadata(){return{deviceType:this._config.deviceType,browser:this._config.browser,browserVersion:this._config.browserVersion,os:this._config.os,osVersion:this._config.osVersion,screenRes:this._config.screenRes,screenWidth:this._config.screenWidth,screenHeight:this._config.screenHeight,colorDepth:this._config.colorDepth,pixelRatio:this._config.pixelRatio,viewportWidth:this._config.viewportWidth,viewportHeight:this._config.viewportHeight,language:this._config.language,timezone:this._config.timezone,deviceId:this._config.deviceId,userAgent:this._config.userAgent,timestamp:Date.now(),platform:this._config.platform,sdkVersion:this._config.sdkVersion,dataSrc:this._config.dataSrc}}get(e){return this._config[e]}set(e,t){this._config[e]=t}getConfig(){return{...this._config}}getDeviceInfo(){return{deviceType:this._config.deviceType,browser:this._config.browser,browserVersion:this._config.browserVersion,os:this._config.os,osVersion:this._config.osVersion,screenRes:this._config.screenRes,screenWidth:this._config.screenWidth,screenHeight:this._config.screenHeight,colorDepth:this._config.colorDepth,pixelRatio:this._config.pixelRatio,viewportWidth:this._config.viewportWidth,viewportHeight:this._config.viewportHeight,language:this._config.language,timezone:this._config.timezone,deviceId:this._config.deviceId,userAgent:this._config.userAgent}}getAppInfo(){return{customerId:this._config.customerId,appId:this._config.appId,appName:this._config.appName,appVersion:this._config.appVersion,platform:this._config.platform,sdkVersion:this._config.sdkVersion,dataSrc:this._config.dataSrc}}getSessionId(){return this._config.sessionId}updateSessionId(e){this._config.sessionId=e}getActivityTimeout(){return this._config.activityTimeout||3e5}getSessionTimeout(){return this._config.sessionTimeout||18e5}setActivityTimeout(e){this._config.activityTimeout=e}setSessionTimeout(e){if("number"!=typeof e||e<0)throw Error("Session timeout must be a non-negative number");this._config.sessionTimeout=e}setServerTimeOffset(e){if("number"!=typeof e)throw Error("Server timestamp must be a number");let t=Date.now();this._serverTimeOffset=e-t,console.log(`[CONFIG] Server time offset set: ${this._serverTimeOffset}ms (server: ${e}, local: ${t})`)}getServerTimeOffset(){return this._serverTimeOffset}getSynchronizedTimestamp(){return Date.now()+this._serverTimeOffset}isTimeSynchronized(){return 0!==this._serverTimeOffset}static getSynchronizedTimestamp(e){return"number"!=typeof serverTimestamp?Date.now():Date.now()+e}}class r{constructor(){this._states={app:{current:{state:"foreground",timestamp:Date.now()},previous:null,history:[]},video:{current:{state:"idle",timestamp:Date.now()},previous:null,history:[]},screen:{current:null,previous:null,history:[]},user:{current:null,previous:null,history:[]},payment:{current:null,previous:null,history:[]},subscription:{current:null,previous:null,history:[]}},this._states.app.history.push(this._states.app.current),this._states.video.history.push(this._states.video.current),this._maxHistoryLength=10,this._stateChangeCallbacks=new Map}getAppState(){return this._states.app.current?.state||"foreground"}getVideoState(){return this._states.video.current?.state||"idle"}getScreenState(){return this._states.screen.current?.state||null}getVideoData(){return this._states.video.current?.metadata||null}getScreenData(){return this._states.screen.current?.metadata||null}getVideoStateHistory(){return this._states.video.history}getAppStateHistory(){return this._states.app.history}getScreenStateHistory(){return this._states.screen.history}updateAppState(e,t={}){return this._updateState("app",e,t)}updateVideoState(e,t={}){return this._updateState("video",e,t)}updateScreenState(e,t={}){return this._updateState("screen",e,t)}updateUserState(e){return this._updateState("user","identified",e)}getUserState(){return this._states.user.current}getUserStateHistory(){return this._states.user.history}getCurrentState(e){return this._states[e]?.current||null}getPreviousState(e){return this._states[e]?.previous||null}getStateHistory(e){return[...this._states[e]?.history||[]]}onStateChange(e,t){this._stateChangeCallbacks.has(e)||this._stateChangeCallbacks.set(e,new Set),this._stateChangeCallbacks.get(e).add(t)}offStateChange(e,t){let i=this._stateChangeCallbacks.get(e);i&&i.delete(t)}clearStates(){this._states={app:{current:{state:"foreground",timestamp:Date.now()},previous:null,history:[]},video:{current:{state:"idle",timestamp:Date.now()},previous:null,history:[]},screen:{current:null,previous:null,history:[]},user:{current:null,previous:null,history:[]},payment:{current:null,previous:null,history:[]},subscription:{current:null,previous:null,history:[]}}}_updateState(e,t,i){try{if(!this._states[e])throw Error(`Invalid state type: ${e}`);if(!this._isValidStateTransition(e,t))return!1;let r={state:t,timestamp:Date.now(),metadata:i};return this._states[e].previous=this._states[e].current,this._states[e].current=r,this._states[e].history.push(r),this._states[e].history.length>this._maxHistoryLength&&this._states[e].history.shift(),this._notifyStateChange(e,r),!0}catch(t){return console.error(`State update failed for ${e}:`,t),!1}}_isValidStateTransition(e,t){let i=this._states[e].current?.state||null,r={app:{null:["foreground","background"],foreground:["background"],background:["foreground"]},video:{null:["idle","loading","playing"],idle:["loading","playing"],loading:["playing","error"],playing:["paused","ended","error"],paused:["playing","ended"],ended:["idle","loading"],error:["idle"]},screen:{null:["active"],active:["inactive"],inactive:["active"]},payment:{null:["initiated","processing"],initiated:["processing","failed"],processing:["success","failed","refunded"],success:["refunded"],failed:["initiated"],refunded:["initiated"]},subscription:{null:["trial","active"],trial:["active","expired"],active:["cancelled","expired","upgraded","downgraded"],cancelled:["active","expired"],expired:["active"],upgraded:["active"],downgraded:["active"]}}[e];return!!r&&(r[i]||[]).includes(t)}_notifyStateChange(e,t){let i=this._stateChangeCallbacks.get(e);
2i&&i.forEach(i=>{try{i(t,this._states[e].previous)}catch(t){console.error(`Error in state change callback for ${e}:`,t)}})}updatePaymentState(e,t={}){return this._updateState("payment",e,t)}getPaymentState(){return this._states.payment.current}getPaymentStateHistory(){return this._states.payment.history}updateSubscriptionState(e,t={}){return this._updateState("subscription",e,t)}getSubscriptionState(){return this._states.subscription.current}getSubscriptionStateHistory(){return this._states.subscription.history}}let a={getItem(e){try{return localStorage.getItem(e)}catch(e){return console.error("Failed to get item from storage:",e),null}},setItem(e,t){try{return localStorage.setItem(e,t),!0}catch(e){return console.error("Failed to set item in storage:",e),!1}},removeItem(e){try{return localStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove item from storage:",e),!1}}};class s{constructor(e={}){this._config={batchSize:e.batchSize||10,flushInterval:e.flushInterval||5e3,maxRetries:e.maxRetries||3,retryDelay:e.retryDelay||1e3,getConfig:()=>({batchSize:this._config.batchSize,flushInterval:this._config.flushInterval,maxRetries:this._config.maxRetries,retryDelay:this._config.retryDelay})},this.events=[],this._flushTimer=null,this._producerURL="https://streamproducer-lcrr.mediamelon.com",this._processingQueue=[],this._retryTimeouts=new Map,this._isProcessing=!1,this._stats={successfulEvents:0,failedEvents:0,totalProcessed:0,lastProcessTime:0},this._loadStoredEvents(),this._startFlushTimer(),console.log("EventQueue initialized with config:",this._config.getConfig())}setProducerURL(e){if(!e||"string"!=typeof e)throw Error("Valid producer URL is required");this._producerURL=e}getProducerURL(){return this._producerURL}updateConfig(e){this._config={...e,getConfig:()=>e},this._flushTimer&&clearInterval(this._flushTimer),this._startFlushTimer()}_loadStoredEvents(){let e=a.getItem("mm_analytics_event_queue");if(e)try{this.events=JSON.parse(e)}catch(e){console.error("Failed to parse stored events:",e),this.events=[]}}addEvent(e){if(!e||"object"!=typeof e)throw Error("Invalid event");e.eventId||(e.eventId=this._generateUUID()),console.log("Adding event to queue:",e.type),this.events.push(e),this._persistEvents(),this.events.length>=this._config.batchSize&&(console.log("Batch size reached, triggering immediate flush"),this._flush())}getNextEvent(){return this.events.length>0?this.events[0]:null}removeEvent(){this.events.length>0&&(this.events.shift(),this._persistEvents())}clear(){if(this.events=[],this._config){for(let e of(this._processingQueue=[],this._stats={successfulEvents:0,failedEvents:0,totalProcessed:0,lastProcessTime:0},this._flushTimer&&(clearInterval(this._flushTimer),this._flushTimer=null),this._retryTimeouts.values()))clearTimeout(e);this._retryTimeouts.clear()}a.removeItem("mm_analytics_event_queue")}isEmpty(){return 0===this.events.length}getSize(){return this.events.length}getStatus(){if(!this._config)return{queueLength:this.events.length,processingLength:0,retryCount:0,successfulEvents:0,failedEvents:0,totalProcessed:0,processingTime:0,isProcessing:!1};for(let[e,t]of this._retryTimeouts.entries())(t._destroyed||t._called)&&this._retryTimeouts.delete(e);return{queueLength:this.events.length,processingLength:this._processingQueue.length,retryCount:this._retryTimeouts.size,successfulEvents:this._stats.successfulEvents,failedEvents:this._stats.failedEvents,totalProcessed:this._stats.totalProcessed,processingTime:this._stats.lastProcessTime,isProcessing:this._isProcessing}}_startFlushTimer(){this._flushTimer&&clearInterval(this._flushTimer);let e=this._config.flushInterval;console.log("Starting flush timer with interval:",e),this._flushTimer=setInterval(()=>{this.events.length>0&&(console.log("Flush timer triggered, queue size:",this.events.length),this._flush())},e)}_persistEvents(){a.setItem("mm_analytics_event_queue",JSON.stringify(this.events))}async _flush(){if(this._isProcessing)return void console.log("Already processing events, skipping flush");if(0===this.events.length)return void console.log("No events to flush");console.log("Starting flush of",this.events.length,"events"),console.log("[EVENT QUEUE] Events in queue:",this.events.map(e=>({type:e.type,timestamp:e.timestamp})));let e=this._config.batchSize,t=this.events.splice(0,e);console.log("Prepared batch of",t.length,"events for processing");try{await this._sendBatch(t),console.log("Successfully processed batch of",t.length,"events")}catch(e){console.error("Error during flush:",e),t&&t.length>0&&(console.log("Putting failed events back in queue"),this.events.unshift(...t))}}async _sendBatch(e){if(e&&0!==e.length)if(this._isProcessing)console.log("Already processing events, skipping batch");else{this._isProcessing=!0,console.log("Starting batch processing of",e.length,"events");try{for(let t of e)try{let e;if(!t){console.error("Invalid event: null or undefined");continue}if(t.qubitData)e={timestamp:t.timestamp,qubitData:t.qubitData};else{console.log("Formatting event without qubitData:",t.type);let i=t.data?.currentPayload||{};(e={timestamp:t.timestamp||Date.now(),qubitData:[{streamID:{custId:i.customerId||i.custId||t.data?.customerId||t.data?.custId||"",subscriberId:i.subscriberId||t.data?.subscriberId||"",subscriberType:i.subscriberType||t.data?.subscriberType||"",subscriberTag:i.subscriberTag||t.data?.subscriberTag||"",sessionId:i.sessionId||t.data?.sessionId||t.sessionId||this._config?.getSessionId?.()||"",pId:i.profileId||t.data?.profileId||"",dataSrc:"Application"},sdkInfo:{sdkVersion:i.sdkVersion||t.data?.sdkVersion||"JSSDK1.0.0"},appEventInfo:{eventName:this._getEventName(t),eventType:this._getEventType(t),currentScreen:i.
2currentScreen||t.data?.currentScreen||"",isGraceful:i.isGraceful||t.data?.isGraceful||!1,eventData:i.eventData||t.data?.eventData||{}},userInfo:{profileId:i.profileId||t.data?.profileId||"",userData:i.userData||t.data?.userData||{},referralId:i.referralId||t.data?.referralId||"",referralData:i.referralData||t.data?.referralData||{}},clientInfo:{appName:i.appName||t.data?.appName||"",appVersion:i.appVersion||t.data?.appVersion||"",scrnRes:i.screenRes||i.scrnRes||t.data?.screenRes||t.data?.scrnRes||this._getScreenResolution(),deviceId:i.deviceId||t.data?.deviceId||"",deviceType:i.deviceType||t.data?.deviceType||"",deviceBrand:i.deviceBrand||t.data?.deviceBrand||"",deviceModel:i.deviceModel||t.data?.deviceModel||"",deviceMarketingName:i.deviceMarketingName||t.data?.deviceMarketingName||"",osVersion:i.osVersion||t.data?.osVersion||"",platform:i.platform||t.data?.platform||"",ua:i.userAgent||t.data?.userAgent||t.data?.clientInfo?.ua||""},customTags:i.customTags||t.data?.customTags||{}}]}).qubitData[0].clientInfo.ua?console.log("[DEBUG] ua found in clientInfo:",e.qubitData[0].clientInfo.ua):(console.warn("[DEBUG] ua missing from clientInfo!"),console.warn("currentPayload:",JSON.stringify(i,null,2)),console.warn("event.data:",JSON.stringify(t.data,null,2)))}if(this._removeEmptyFields(e),!t.qubitData&&!e.qubitData?.[0]?.streamID?.custId){console.error("Missing required field: custId");continue}console.log("About to make network call to:",this._producerURL),console.log("Event payload:",JSON.stringify(e,null,2)),console.log("Making fetch request...");let i=await fetch(this._producerURL,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(console.log("Fetch request completed"),console.log("Response status:",i.status,i.statusText),!i.ok){let e=await i.text();throw console.error("Server response:",e),Error(`HTTP error! status: ${i.status}, message: ${e}`)}let r=await i.text(),a=null;if(r&&r.trim())try{a=JSON.parse(r),console.log("Server response data:",a)}catch(e){console.warn("Failed to parse response as JSON:",r),console.warn("Parse error:",e),a={success:!0,message:"Response received but not JSON"}}else console.log("Empty response received from server"),a={success:!0,message:"Empty response received"};this.removeEvent(),this._stats.successfulEvents++,this._stats.totalProcessed++,console.log("Event successfully processed and removed from queue")}catch(e){if(console.error("Error sending event:",e),this._stats.failedEvents++,this._stats.totalProcessed++,t.retryCount=(t.retryCount||0)+1,t.retryCount<this._config.maxRetries){console.log("Scheduling retry for event, attempt:",t.retryCount),this._scheduleRetry(t);continue}console.log("Max retries reached for event, removing from queue")}console.log("Successfully processed batch of",e.length,"events")}catch(e){console.error("Error processing batch:",e)}finally{console.log("Resetting processing state"),this._isProcessing=!1,this.events.length>0&&(console.log("More events in queue, scheduling next batch"),this._scheduleNextBatch())}}else console.log("Empty batch, skipping processing")}_removeEmptyFields(e){for(let t in e)null===e[t]||void 0===e[t]||""===e[t]?delete e[t]:"object"==typeof e[t]&&(this._removeEmptyFields(e[t]),0===Object.keys(e[t]).length&&delete e[t])}_getEventName(e){if(e.eventName)return e.eventName;switch(e.type){case"APP_STATE":return"foreground"===e.state?"APP_FOREGROUND":"APP_BACKGROUND";case"USER_IDENTIFICATION":return"USER_IDENTIFICATION";case"SESSION_START":return"SESSION_START";case"HEART_BEAT":return"STATS";case"USER_SIGN_UP":return"USER_SIGN_UP";case"USER_SIGN_IN":return"USER_SIGN_IN";case"USER_SIGN_OUT":return"USER_SIGN_OUT";case"USER_PROFILE_UPDATE":return"USER_PROFILE_UPDATE";case"USER_PREFERENCE_UPDATE":return"USER_PREFERENCE_UPDATE";case"USER_SESSION_END":return"USER_SESSION_END";case"USER_INFO":return"USER_INFO";case"APP_PERFORMANCE":return"APP_PERFORMANCE";case"SUBSCRIPTION_VIEWED":return"SUBSCRIPTION_VIEWED";case"FEATURE_USAGE":return"FEATURE_USAGE";case"VIDEO_BUFFERING":return"VIDEO_BUFFERING";default:return e.type||""}}_getEventType(e){if(e.eventType)return e.eventType;switch(e.type){case"APP_STATE":return"APP_STATE";case"USER_IDENTIFICATION":return"USER_IDENTIFICATION";case"SESSION_START":return"SESSION_START";case"HEART_BEAT":return"HEART_BEAT";case"USER_SIGN_UP":return"USER_SIGN_UP";case"USER_SIGN_IN":return"USER_SIGN_IN";case"USER_SIGN_OUT":return"USER_SIGN_OUT";case"USER_PROFILE_UPDATE":return"USER_PROFILE_UPDATE";case"USER_PREFERENCE_UPDATE":return"USER_PREFERENCE_UPDATE";case"USER_SESSION_END":return"USER_SESSION_END";case"USER_INFO":return"USER_INFO";case"APP_PERFORMANCE":return"APP_PERFORMANCE";case"SUBSCRIPTION_VIEWED":return"SUBSCRIPTION_VIEWED";case"FEATURE_USAGE":return"FEATURE_USAGE";case"VIDEO_BUFFERING":return"VIDEO_BUFFERING";default:return e.type||""}}_getEventData(e){let t={type:e.type||e.eventType||"",timestamp:e.timestamp||Date.now(),payloadId:e.payloadId||this._generateUUID(),dataSrc:"Application",sessionId:e.sessionId||""};switch(e.type||e.eventType){case"APP_STATE":return{...t,state:e.state,appId:e.appId};case"USER_IDENTIFICATION":return{...t,userId:e.userId,email:e.email,demographics:e.demographics};case"SESSION_START":return{...t,sessionId:e.sessionId};case"HEART_BEAT":return{...t,eventName:"STATS"};default:return t}}_generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}_getScreenResolution(){return"u">typeof window&&window.screen?`${window.screen.width}x${window.screen.height}`:""}_scheduleRetry(e){let t=setTimeout(()=>{this.events.push(e),this._retryTimeouts.delete(e.eventId),this.events.length>=this._config.getConfig().batchSize&&this._flush()},this._config.getConfig().retryDelay*Math.pow(2,(e.retryCount||0)-1));this._retryTimeouts.set(e.eventId,t)}
2async destroy(){if(this._config){for(let e of(this._flushTimer&&(clearInterval(this._flushTimer),this._flushTimer=null),this.events.length>0&&await this._flush(),this._retryTimeouts.values()))clearTimeout(e);this._retryTimeouts.clear(),a.removeItem("mm_analytics_event_queue")}}_shouldProcessBatch(){return!!this._config&&this.events.length>=this._getBatchSize()}_getBatchSize(){return this._config.getConfig().batchSize}_getRetryDelay(){return this._config.getConfig().retryDelay}_getEndpoint(){return this._producerURL}async _processBatch(){try{let e=this._getBatchSize(),t=this.events.splice(0,e),i=Date.now();await this._sendBatch(t),this._stats.lastProcessTime=Date.now()-i}catch(e){this._handleError(e,"_processBatch")}}async _retryFailedEvents(){try{this._config.getConfig().retryDelay}catch(e){this._handleError(e,"_retryFailedEvents")}}_scheduleNextBatch(){this._isProcessing?console.log("Already processing events, skipping next batch"):(console.log("Scheduling next batch processing"),setTimeout(()=>{this.events.length>0&&(console.log("Processing next batch of",this.events.length,"events"),this._flush())},this._config.getConfig().flushInterval))}_handleError(e,t){console.error(`Error in EventQueue (${t}):`,e)}}class n{constructor(e,t){if(!e)throw Error("Event queue is required");this._eventQueue=e,this._config=t,this._producerURL="https://streamproducer-lcrr.mediamelon.com",this._statsInterval=-1,this._heartbeatIntervalId=null,this._isHeartbeatRunning=!1,this._currentPayload=null,this._eventPayloadKeys={streamID:{fields:["customerId","subscriberId","subscriberType","subscriberTag","sessionId","payloadId","dataSrc"],mappings:{customerId:"custId",payloadId:"pId"}},sdkInfo:{fields:["sdkVersion"]},appEventInfo:{fields:["eventName","eventType","eventData","currentScreen","isGraceful"]},userInfo:{fields:["profileId","userData","referralId","referralData"]},clientInfo:{fields:["appName","appVersion","deviceId","deviceType","deviceBrand","deviceModel","deviceMarketingName","osVersion","platform","screenRes","userAgent"],mappings:{screenRes:"scrnRes",userAgent:"ua"}},customTags:{fields:["customTags"]}}}setProducerURL(e){if(!e||"string"!=typeof e)throw Error("Valid producer URL is required");this._producerURL=e,this._eventQueue.setProducerURL(e)}setStatsInterval(e){if("number"!=typeof e)throw Error("Stats interval must be a number");this._statsInterval=e}startSendingHeartBeatPayload(){}stopSendingHeartBeatPayload(){this._isHeartbeatRunning=!1,this._heartbeatIntervalId&&(clearInterval(this._heartbeatIntervalId),this._heartbeatIntervalId=null)}updateCurrentPayload(e){if(!e)return void console.warn("MM SDK: Attempting to update current payload with null/undefined value");let t=["customerId","appName","appVersion"].filter(t=>!e[t]);t.length>0&&console.warn(`MM SDK: Missing required fields in payload: ${t.join(", ")}`),this._currentPayload={...this._currentPayload,...e,customerId:e.customerId||this._currentPayload?.customerId||"",appName:e.appName||this._currentPayload?.appName||"",appVersion:e.appVersion||this._currentPayload?.appVersion||"",sdkVersion:e.sdkVersion||this._currentPayload?.sdkVersion||"JSSDK1.0.0",sessionId:e.sessionId||this._currentPayload?.sessionId||"",screenRes:e.screenRes||this._currentPayload?.screenRes||this._getScreenResolution(),custId:e.customerId||e.custId||this._currentPayload?.custId||"",subscriberId:e.subscriberId||this._currentPayload?.subscriberId||"",subscriberType:e.subscriberType||this._currentPayload?.subscriberType||"",subscriberTag:e.subscriberTag||this._currentPayload?.subscriberTag||"",clientInfo:{appName:e.appName||this._currentPayload?.clientInfo?.appName||"",appVersion:e.appVersion||this._currentPayload?.clientInfo?.appVersion||"",scrnRes:e.screenRes||e.scrnRes||this._currentPayload?.clientInfo?.scrnRes||this._getScreenResolution(),ua:e.userAgent||this._currentPayload?.clientInfo?.ua||""},userInfo:{profileId:e.profileId||this._currentPayload?.userInfo?.profileId||"",userData:e.userData||this._currentPayload?.userInfo?.userData||{},referralId:e.referralId||this._currentPayload?.userInfo?.referralId||"",referralData:e.referralData||this._currentPayload?.userInfo?.referralData||{}},customTags:e.customTags||this._currentPayload?.customTags||{}}}publishEvent(e,t){if(!this._currentPayload)return void console.warn("MM SDK: Cannot publish event - current payload is not set");console.log(`[DEBUG] Publishing event: ${e}`),console.log(`[DEBUG] Current payload sessionId: ${this._currentPayload.sessionId}`),console.log(`[DEBUG] Event data sessionId: ${t?.sessionId}`);let i={...this._currentPayload,...t,eventType:e,timestamp:this._config.getSynchronizedTimestamp(),payloadId:this._generateUUID(),pId:this._generateUUID(),dataSrc:"Application"};if(this._currentPayload.customerId&&(i.customerId=this._currentPayload.customerId),console.log(`[DEBUG] Final payload sessionId: ${i.sessionId}`),!i.sessionId){let e=this._config?.getSessionId?.();e?(i.sessionId=e,console.log(`[DEBUG] Using session ID from config: ${e}`)):console.warn("[DEBUG] No session ID available from config or payload")}let r={timestamp:i.timestamp,qubitData:[{streamID:{custId:i.customerId||i.custId||"",subscriberId:t.subscriberId||i.subscriberId||"",subscriberType:t.subscriberType||i.subscriberType||"",subscriberTag:t.subscriberTag||i.subscriberTag||"",sessionId:i.sessionId||"",pId:i.pId||"",dataSrc:"Application"},sdkInfo:{sdkVersion:i.sdkVersion||"JSSDK1.0.0"},appEventInfo:{eventName:this._getEventName(e,t),eventType:this._getEventType(e,t),currentScreen:i.
2currentScreen||"",isGraceful:i.isGraceful||!1,eventData:this._getEventSpecificData({...i,type:e,customerId:t.customerId},this._getEventType(e,t))},userInfo:{profileId:t.profileId||i.profileId||"",referralId:t.referralId||i.referralId||"",userData:t.userData||i.userData||{},referralData:t.referralData||i.referralData||{}},clientInfo:{appName:i.appName||"",appVersion:i.appVersion||"",deviceId:t.deviceId||i.deviceId||"",deviceType:t.deviceType||i.deviceType||"",deviceBrand:t.deviceBrand||i.deviceBrand||"",deviceModel:t.deviceModel||i.deviceModel||"",deviceMarketingName:t.deviceMarketingName||i.deviceMarketingName||"",osVersion:t.osVersion||i.osVersion||"",platform:t.platform||i.platform||"",scrnRes:i.screenRes||i.scrnRes||this._getScreenResolution(),ua:i.userAgent||i.ua||""},customTags:i.customTags||{}}]};console.log("[DEBUG] Before _removeEmptyFields:",JSON.stringify(r,null,2)),this._removeEmptyFields(r),console.log("[DEBUG] After _removeEmptyFields:",JSON.stringify(r,null,2)),this._eventQueue.addEvent({type:e,qubitData:r.qubitData,timestamp:i.timestamp})}_getEventName(e,t){if(t.eventName)return t.eventName;let i={app_state:e=>"foreground"===e.state?"APP_FOREGROUND":"APP_BACKGROUND",APP_STATE:e=>"foreground"===e.state?"APP_FOREGROUND":"APP_BACKGROUND",user_identification:()=>"USER_IDENTIFICATION",user_preference_change:()=>"USER_PREFERENCE_CHANGE",session_start:()=>"SESSION_START",screen_view:()=>"SCREEN_VIEW",screen_exit:()=>"SCREEN_EXIT",HEART_BEAT:()=>"STATS",user_sign_up:()=>"USER_SIGN_UP",user_sign_in:()=>"USER_SIGN_IN",user_sign_out:()=>"USER_SIGN_OUT",user_profile_update:()=>"USER_PROFILE_UPDATE",user_preference_update:()=>"USER_PREFERENCE_UPDATE",user_session_start:()=>"USER_SESSION_START",user_session_end:()=>"USER_SESSION_END",user_info:()=>"USER_INFO",app_performance:()=>"APP_PERFORMANCE",subscription_viewed:()=>"SUBSCRIPTION_VIEWED",subscription_start:()=>"SUBSCRIPTION_START",subscription_renewal:()=>"SUBSCRIPTION_RENEWAL",subscription_cancellation:()=>"SUBSCRIPTION_CANCELLATION",subscription_upgrade:()=>"SUBSCRIPTION_UPGRADE",subscription_downgrade:()=>"SUBSCRIPTION_DOWNGRADE",payment_initiation:()=>"PAYMENT_INITIATION",payment_success:()=>"PAYMENT_SUCCESS",payment_failure:()=>"PAYMENT_FAILURE",payment_refund:()=>"PAYMENT_REFUND",ad_impression:()=>"AD_IMPRESSION",ad_click:()=>"AD_CLICK",ad_start:()=>"AD_START",ad_complete:()=>"AD_COMPLETE",ad_skip:()=>"AD_SKIP",ad_error:()=>"AD_ERROR",experiment_exposure:()=>"EXPERIMENT_EXPOSURE",experiment_activation:()=>"EXPERIMENT_ACTIVATION",feature_flag_evaluation:()=>"FEATURE_FLAG_EVALUATION",experiment_results:()=>"EXPERIMENT_RESULTS",feature_usage:()=>"FEATURE_USAGE",video_start:()=>"VIDEO_START",video_play:()=>"VIDEO_PLAY",video_pause:()=>"VIDEO_PAUSE",video_resume:()=>"VIDEO_RESUME",video_stop:()=>"VIDEO_STOP",video_complete:()=>"VIDEO_COMPLETE",video_seek:()=>"VIDEO_SEEK",video_buffering:()=>"VIDEO_BUFFERING",video_error:()=>"VIDEO_ERROR",video_quality_change:()=>"VIDEO_QUALITY_CHANGE",video_fullscreen:()=>"VIDEO_FULLSCREEN",video_exit_fullscreen:()=>"VIDEO_EXIT_FULLSCREEN",video_end:()=>"VIDEO_END",video_skip:()=>"VIDEO_SKIP",video_shared:()=>"VIDEO_SHARED",video_bookmarked:()=>"VIDEO_BOOKMARKED",video_liked:()=>"VIDEO_LIKED",video_commented:()=>"VIDEO_COMMENTED",video_rated:()=>"VIDEO_RATED",video_playback_speed_changed:()=>"VIDEO_PLAYBACK_SPEED_CHANGED",user_click:()=>"USER_CLICK",user_scroll:()=>"USER_SCROLL"}[e];return"function"==typeof i?i(t):i||e.toUpperCase()}_getEventType(e,t){if(t.eventType)return t.eventType;if("app_state"===e)return"APP_STATE";let i={app_error:"APP_ERROR",user_identification:"USER_IDENTIFICATION",user_preference_change:"USER_PREFERENCE_CHANGE",session_start:"SESSION_START",screen_view:"SCREEN_VIEW",screen_exit:"SCREEN_EXIT",HEART_BEAT:"HEART_BEAT",user_sign_up:"USER_SIGN_UP",user_sign_in:"USER_SIGN_IN",user_sign_out:"USER_SIGN_OUT",user_profile_update:"USER_PROFILE_UPDATE",user_preference_update:"USER_PREFERENCE_UPDATE",user_session_start:"USER_SESSION_START",user_session_end:"USER_SESSION_END",user_info:"USER_INFO",app_performance:"APP_PERFORMANCE",subscription_viewed:"SUBSCRIPTION_VIEWED",subscription_start:"SUBSCRIPTION_START",subscription_renewal:"SUBSCRIPTION_RENEWAL",subscription_cancellation:"SUBSCRIPTION_CANCELLATION",subscription_upgrade:"SUBSCRIPTION_UPGRADE",subscription_downgrade:"SUBSCRIPTION_DOWNGRADE",payment_initiation:"PAYMENT_INITIATION",payment_success:"PAYMENT_SUCCESS",payment_failure:"PAYMENT_FAILURE",payment_refund:"PAYMENT_REFUND",ad_impression:"AD_IMPRESSION",ad_click:"AD_CLICK",ad_start:"AD_START",ad_complete:"AD_COMPLETE",ad_skip:"AD_SKIP",ad_error:"AD_ERROR",experiment_exposure:"EXPERIMENT_EXPOSURE",experiment_activation:"EXPERIMENT_ACTIVATION",feature_flag_evaluation:"FEATURE_FLAG_EVALUATION",experiment_results:"EXPERIMENT_RESULTS",feature_usage:"FEATURE_USAGE",video_start:"VIDEO_START",video_play:"VIDEO_PLAY",video_pause:"VIDEO_PAUSE",video_resume:"VIDEO_RESUME",video_stop:"VIDEO_STOP",video_complete:"VIDEO_COMPLETE",video_seek:"VIDEO_SEEK",video_buffering:"VIDEO_BUFFERING",video_error:"VIDEO_ERROR",video_quality_change:"VIDEO_QUALITY_CHANGE",video_fullscreen:"VIDEO_FULLSCREEN",video_exit_fullscreen:"VIDEO_EXIT_FULLSCREEN",video_end:"VIDEO_END",video_skip:"VIDEO_SKIP",video_shared:"VIDEO_SHARED",video_bookmarked:"VIDEO_BOOKMARKED",video_liked:"VIDEO_LIKED",video_commented:"VIDEO_COMMENTED",video_rated:"VIDEO_RATED",video_playback_speed_changed:"VIDEO_PLAYBACK_SPEED_CHANGED",user_click:"USER_CLICK",user_scroll:"USER_SCROLL"}[e];return"function"==typeof i?i(t):i||e.toUpperCase()}_getEventSpecificData(e,t){console.log(`[DEBUG] _getEventSpecificData called with eventType: ${t}`);let i={SESSION_START:{sessionId:e.sessionId,startTime:e.startTime||e.timestamp,source:e.source,deviceInfo:e.deviceInfo,appInfo:e.appInfo},SESSION_END:{sessionId:e.sessionId,endTime:e.endTime||e.timestamp,sessionDuration:e.sessionDuration,source:e.source},APP_STATE:{state:e.state,timestamp:e.timestamp,metadata:e.metadata||{},trigger:e.trigger,sessionId:e.sessionId},NAVIGATION:{fromUrl:e.fromUrl,toUrl:e.toUrl,navigationType:e.navigationType,referrer:e.referrer,pageUrl:e.pageUrl},CLICK:{elementId:e.elementId,elementType:e.elementType,pageUrl:e.pageUrl,position:e.position,elementText:e.elementText,elementClass:e.elementClass},SCROLL_DEPTH:{scrollDepth:e.scrollDepth,scrollPercentage:e.scrollPercentage,pageUrl:e.pageUrl,scrollDirection:e.scrollDirection,scrollDistance:e.scrollDistance},PAYMENT_INITIATION:{paymentId:e.paymentId,amount:e.amount,currency:e.currency,method:e.method||e.paymentMethod,status:e.status||"initiated",transactionId:e.transactionId,orderId:e.orderId,customerId:e.customerId},PAYMENT_SUCCESS:{paymentId:e.paymentId,amount:e.amount,currency:e.currency,method:e.method||e.paymentMethod,status:e.status||"completed",transactionId:e.transactionId,receiptUrl:e.receiptUrl},PAYMENT_FAILURE:{paymentId:e.paymentId,amount:e.amount,currency:e.currency,method:e.method||e.paymentMethod,status:e.status||"failed",errorType:e.errorType,message:e.message,metadata:e.metadata||{}},PAYMENT_REFUND:{paymentId:e.paymentId,amount:e.amount,currency:e.currency,method:e.method||e.paymentMethod,status:e.status||"refunded",transactionId:e.transactionId,refundReason:e.refundReason,metadata:e.metadata||{}},SUBSCRIPTION_START:{subscriptionId:e.subscriptionId,planId:e.planId,planName:e.planName,amount:e.amount,currency:e.currency,duration:e.duration,measure:e.measure,status:e.status||"active"},SUBSCRIPTION_RENEWAL:{subscriptionId:e.subscriptionId,planId:e.planId,planName:e.planName,amount:e.amount,currency:e.currency,renewalDate:e.renewalDate,nextRenewalDate:e.nextRenewalDate},SUBSCRIPTION_CANCELLATION:{subscriptionId:e.subscriptionId,planId:e.planId,planName:e.planName,cancellationReason:e.cancellationReason,
2cancellationDate:e.cancellationDate,endDate:e.endDate},SUBSCRIPTION_EXPIRATION:{subscriptionId:e.subscriptionId,planId:e.planId,planName:e.planName,expirationDate:e.expirationDate,reason:e.reason},SUBSCRIPTION_UPGRADE:{subscriptionId:e.subscriptionId,oldPlanId:e.oldPlanId,oldPlanName:e.oldPlanName,newPlanId:e.newPlanId,newPlanName:e.newPlanName,upgradeReason:e.upgradeReason},SUBSCRIPTION_DOWNGRADE:{subscriptionId:e.subscriptionId,oldPlanId:e.oldPlanId,oldPlanName:e.oldPlanName,newPlanId:e.newPlanId,newPlanName:e.newPlanName,downgradeReason:e.downgradeReason},SUBSCRIPTION_VIEWED:{subscriptionId:e.subscriptionId,planId:e.planId,planName:e.planName,viewSource:e.viewSource,pageUrl:e.pageUrl},AD_IMPRESSION:{adId:e.adId,adType:e.adType,duration:e.duration},AD_CLICK:{adId:e.adId,adType:e.adType},AD_START:{adId:e.adId,adType:e.adType,duration:e.duration},AD_COMPLETE:{adId:e.adId,adType:e.adType,duration:e.duration,completionPercentage:e.completionPercentage},AD_SKIP:{adId:e.adId,adType:e.adType,skipTime:e.skipTime,skipReason:e.skipReason},AD_ERROR:{adId:e.adId,adType:e.adType,errorType:e.errorType,errorMessage:e.errorMessage},EXPERIMENT_EXPOSURE:{experimentId:e.experimentId,experimentName:e.experimentName,variantId:e.variantId,variantName:e.variantName,exposureType:e.exposureType,source:e.source,context:e.context},FEATURE_FLAG_EVALUATION:{experimentId:e.experimentId,experimentName:e.experimentName,variantId:e.variantId,variantName:e.variantName,evaluationType:e.evaluationType,source:e.source,context:e.context},EXPERIMENT_ACTIVATION:{experimentId:e.experimentId,experimentName:e.experimentName,variantId:e.variantId,variantName:e.variantName,activationType:e.activationType,source:e.source,context:e.context},EXPERIMENT_RESULTS:{experimentId:e.experimentId,experimentName:e.experimentName,variantId:e.variantId,variantName:e.variantName,resultType:e.resultType,resultValue:e.resultValue},FEATURE_USAGE:{featureId:e.featureId,featureName:e.featureName,action:e.action,usageType:e.usageType,source:e.source},APP_PERFORMANCE:{loadTime:e.loadTime,renderTime:e.renderTime,memoryUsage:e.memoryUsage,timestamp:e.timestamp,metadata:e.metadata},APP_FOREGROUND:{state:e.state,appId:e.appId,isGraceful:e.isGraceful||!1,timestamp:e.timestamp,metadata:e.metadata},APP_BACKGROUND:{state:e.state,appId:e.appId,isGraceful:e.isGraceful||!1,timestamp:e.timestamp,metadata:e.metadata},APP_ERROR:{errorCode:e.errorCode,errorMessage:e.errorMessage,stackTrace:e.stackTrace,timestamp:e.timestamp,metadata:e.metadata},APP_INTERRUPTION:{interruptionType:e.interruptionType,reason:e.reason,timestamp:e.timestamp,sessionId:e.sessionId,metadata:e.metadata||{}},VIDEO_START:{assetId:e.assetId,assetName:e.assetName,duration:e.duration,position:e.position,quality:e.quality,reason:e.reason},VIDEO_PLAY:{assetId:e.assetId,assetName:e.assetName,position:e.position,quality:e.quality},VIDEO_PAUSE:{assetId:e.assetId,assetName:e.assetName,position:e.position,reason:e.reason},VIDEO_RESUME:{assetId:e.assetId,assetName:e.assetName,position:e.position,quality:e.quality},VIDEO_STOP:{assetId:e.assetId,assetName:e.assetName,position:e.position,reason:e.reason},VIDEO_COMPLETE:{assetId:e.assetId,assetName:e.assetName,duration:e.duration,position:e.position,quality:e.quality},VIDEO_SEEK:{assetId:e.assetId,assetName:e.assetName,fromPosition:e.fromPosition,toPosition:e.toPosition,reason:e.reason},VIDEO_BUFFERING:{assetId:e.assetId,assetName:e.assetName,position:e.position,bufferTime:e.bufferTime,reason:e.reason},VIDEO_ERROR:{assetId:e.assetId,assetName:e.assetName,position:e.position,errorType:e.errorType,errorMessage:e.errorMessage},VIDEO_QUALITY_CHANGE:{assetId:e.assetId,assetName:e.assetName,position:e.position,fromQuality:e.fromQuality,toQuality:e.toQuality,reason:e.reason},VIDEO_QUALITY_CHANGED:{assetId:e.assetId,assetName:e.assetName,position:e.position,fromQuality:e.fromQuality,toQuality:e.toQuality,reason:e.reason},VIDEO_FULLSCREEN:{assetId:e.assetId,assetName:e.assetName,position:e.position,isFullscreen:e.isFullscreen},VIDEO_EXIT_FULLSCREEN:{assetId:e.assetId,assetName:e.assetName,position:e.position,isFullscreen:e.isFullscreen},VIDEO_END:{assetId:e.assetId,assetName:e.assetName,duration:e.duration,position:e.position,reason:e.reason},VIDEO_STATE:{assetId:e.assetId,assetName:e.assetName,state:e.state,position:e.position,qual
2ity:e.quality,reason:e.reason,metadata:e.metadata||{}},VIDEO_SKIP:{assetId:e.assetId,assetName:e.assetName,position:e.position,reason:e.reason},VIDEO_SHARED:{assetId:e.assetId,assetName:e.assetName,position:e.position,platform:e.platform,method:e.method},VIDEO_BOOKMARKED:{assetId:e.assetId,assetName:e.assetName,position:e.position,action:e.action},VIDEO_LIKED:{assetId:e.assetId,assetName:e.assetName,position:e.position,action:e.action},VIDEO_COMMENTED:{assetId:e.assetId,assetName:e.assetName,position:e.position,commentLength:e.commentLength,hasAttachment:e.hasAttachment},VIDEO_RATED:{assetId:e.assetId,assetName:e.assetName,position:e.position,rating:e.rating,maxRating:e.maxRating},VIDEO_PLAYBACK_SPEED_CHANGED:{assetId:e.assetId,assetName:e.assetName,position:e.position,fromSpeed:e.fromSpeed,toSpeed:e.toSpeed,reason:e.reason},USER_IDENTIFICATION:{userId:e.userId,email:e.email,name:e.name,age:e.age,location:e.location,userData:e.userData},USER_INFO:{userId:e.userId,email:e.email,name:e.name,age:e.age,location:e.location,userData:e.userData},SUBSCRIBER_INFO:{subscriberId:e.subscriberId,subscriberType:e.subscriberType,subscriberTag:e.subscriberTag,profileId:e.profileId,userData:e.userData},REFERRAL_INFO:{referralId:e.referralId,referralData:e.referralData,source:e.source,campaign:e.campaign,userData:e.userData},USER_SIGN_UP:{userId:e.userId,email:e.email,signUpMethod:e.signUpMethod,source:e.source,userData:e.userData},USER_SIGN_IN:{userId:e.userId,email:e.email,signInMethod:e.signInMethod,source:e.source,userData:e.userData},USER_SIGN_OUT:{userId:e.userId,signOutMethod:e.signOutMethod,sessionDuration:e.sessionDuration,userData:e.userData},USER_SESSION_START:{userId:e.userId,sessionId:e.sessionId,startTime:e.startTime,source:e.source,userData:e.userData},USER_SESSION_END:{userId:e.userId,sessionId:e.sessionId,endTime:e.endTime,sessionDuration:e.sessionDuration,userData:e.userData},USER_PREFERENCE_UPDATE:{userId:e.userId,preferenceType:e.preferenceType,oldValue:e.oldValue,newValue:e.newValue,userData:e.userData},USER_PROFILE_UPDATE:{userId:e.userId,updatedFields:e.updatedFields,oldValues:e.oldValues,newValues:e.newValues,userData:e.userData},USER_CLICK:{userId:e.userId,elementId:e.elementId,elementType:e.elementType,pageUrl:e.pageUrl,userData:e.userData},USER_SCROLL:{userId:e.userId,scrollDirection:e.scrollDirection,scrollDistance:e.scrollDistance,pageUrl:e.pageUrl,userData:e.userData},USER_PREFERENCE_CHANGE:{userId:e.userId,preferenceType:e.preferenceType,oldValue:e.oldValue,newValue:e.newValue,userData:e.userData},USER_INTERACTION:{userId:e.userId,interactionType:e.interactionType,elementId:e.elementId,elementType:e.elementType,pageUrl:e.pageUrl,userData:e.userData},USER_PREFERENCE:{userId:e.userId,preferenceType:e.preferenceType,preferenceValue:e.preferenceValue,pageUrl:e.pageUrl,userData:e.userData},USER_FEEDBACK:{userId:e.userId,feedbackType:e.feedbackType,feedbackValue:e.feedbackValue,feedbackText:e.feedbackText,pageUrl:e.pageUrl,userData:e.userData},SCREEN_VIEW:{screenName:e.screenName||e.currentScreen,screenId:e.screenId,previousScreen:e.previousScreen,screenType:e.screenType,timestamp:e.timestamp,metadata:e.metadata},SCREEN_EXIT:{screenName:e.screenName,screenId:e.screenId,duration:e.duration,timestamp:e.timestamp,metadata:e.metadata},SDK_SHUTDOWN:{timestamp:e.timestamp,sessionId:e.sessionId,reason:e.reason||"normal"},SDK_ERROR:{errorCode:e.errorCode,errorMessage:e.errorMessage,stackTrace:e.stackTrace,timestamp:e.timestamp,sessionId:e.sessionId,metadata:e.metadata||{}},STATS:{timestamp:e.timestamp,sessionId:e.sessionId,statsType:e.statsType||"heartbeat",metadata:e.metadata||{}}};console.log(`[DEBUG] Looking up eventType: '${t}' in eventDataMap`),console.log("[DEBUG] Available keys in eventDataMap:",Object.keys(i));let r=i[t]||{};return console.log(`[DEBUG] _getEventSpecificData returning eventData for ${t}:`,r),this._convertEventDataToStrings(r)}_convertEventDataToStrings(e){console.log("[DEBUG] _convertEventDataToStrings input:",e);let t={};for(let[i,r]of Object.entries(e))"metadata"!==i?null==r?(t[i]="",console.log(`[DEBUG] Convert
2ing ${i}: null/undefined -> ''`)):"object"!=typeof r||Array.isArray(r)?Array.isArray(r)?(t[i]=JSON.stringify(r),console.log(`[DEBUG] Converting ${i}: array -> '${JSON.stringify(r)}'`)):(t[i]=String(r),console.log(`[DEBUG] Converting ${i}: ${typeof r} -> '${String(r)}'`)):(t[i]=JSON.stringify(r),console.log(`[DEBUG] Converting ${i}: object -> '${JSON.stringify(r)}'`)):console.log(`[DEBUG] Skipping metadata field: ${i}`);return console.log("[DEBUG] _convertEventDataToStrings output:",t),t}_removeEmptyFields(e){for(let t in e)null===e[t]||void 0===e[t]||""===e[t]?delete e[t]:"object"!=typeof e[t]||Array.isArray(e[t])||(this._removeEmptyFields(e[t]),0===Object.keys(e[t]).length&&delete e[t])}_generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}_getScreenResolution(){return"u">typeof window&&window.screen?`${window.screen.width}x${window.screen.height}`:""}}class o{constructor(e){this._config=e,this._errorCallbacks=new Map,this._recoveryStrategies=new Map,this._errorHistory=[],this._maxHistorySize=100}handleError(e,t,i={}){let r=this._categorizeError(e,t,i);return this._addToHistory(r),this._recoveryStrategies.has(r.category)&&this._recoveryStrategies.get(r.category)(r),this._notifyErrorCallbacks(r),this._shouldReportError(e)&&this._reportError(r),!0}onError(e,t){this._errorCallbacks.has(e)||this._errorCallbacks.set(e,new Set),this._errorCallbacks.get(e).add(t)}registerRecoveryStrategy(e,t){this._recoveryStrategies.set(e,t)}getErrorHistory(){return[...this._errorHistory]}clearErrorHistory(){this._errorHistory=[]}_categorizeError(e,t,i){let r="unknown",a="error";return"NetworkError"===e.name||e.message.includes("network")?r="network":"ValidationError"===e.name||e.message.includes("validation")?r="validation":"StateError"===e.name||e.message.includes("state")?r="state":"ConfigurationError"===e.name||e.message.includes("config")?r="configuration":("StorageError"===e.name||e.message.includes("storage"))&&(r="storage"),e.critical||e.message.includes("critical")?a="critical":e.warning||e.message.includes("warning")?a="warning":(e.info||e.message.includes("info"))&&(a="info"),{timestamp:Date.now(),category:r,severity:a,context:t,message:e.message,stack:e.stack,...i}}_addToHistory(e){this._errorHistory.unshift(e),this._errorHistory.length>this._maxHistorySize&&this._errorHistory.pop()}_notifyErrorCallbacks(e){this._errorCallbacks.has(e.category)&&this._errorCallbacks.get(e.category).forEach(t=>{try{t(e)}catch(e){console.error("Error in error callback:",e)}}),this._errorCallbacks.has("*")&&this._errorCallbacks.get("*").forEach(t=>{try{t(e)}catch(e){console.error("Error in global error callback:",e)}})}async _reportError(e){try{let t=this._getErrorEndpoint(),i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({error:e,metadata:this._config.getEventMetadata()})});if(!i.ok)throw Error(`Failed to report error: ${i.status}`)}catch(e){console.error("Error reporting to backend:",e)}}_shouldReportError(e){return this._config.getConfig().errorReporting}_getErrorEndpoint(){return this._config.getConfig().errorEndpoint}_createErrorEvent(e,t,i){return{error:e.message,context:t,timestamp:Date.now(),stack:e.stack,metadata:this._config.getEventMetadata()}}}let d={DEBUG:"debug",INFO:"info",WARN:"warn",ERROR:"error"},l={[d.DEBUG]:0,[d.INFO]:1,[d.WARN]:2,[d.ERROR]:3};class u{constructor(e={}){this._config=e,this._logHistory=[],this._logCallbacks=new Map,this._maxHistorySize=e.maxLogHistorySize||1e3,this._enabled=!0,this._currentLevel=d.INFO,this._userId=null}updateConfig(e){this._config=e,this._maxHistorySize=e.maxLogHistorySize||1e3}setUserId(e){this._userId=e}debug(e,t={}){this._log(d.DEBUG,e,t)}info(e,t={}){this._log(d.INFO,e,t)}warn(e,t={}){this._log(d.WARN,e,t)}error(e,t={}){this._log(d.ERROR,e,t)}setLogLevel(e){d[e.toUpperCase()]&&(this._currentLevel=e.toLowerCase())}setEnabled(e){this._enabled=e}onLog(e,t){this._logCallbacks.has(e)||this._logCallbacks.set(e,new Set),this._logCallbacks.get(e).add(t)}_log(e,t,i){if(!this._enabled||l[e]<l[this._currentLevel])return;let r={timestamp:Date.now(),level:e,message:t,data:i,userId:this._userId,context:this._getContext()};this._notifyCallbacks(r),this._consoleOutput(r)}_getContext(){return{sdkVersion:this._config.getAppInfo().sdkVersion,environment:this._config.getConfig().environment,appVersion:this._config.getAppInfo().appVersion,timestamp:Date.now()}}_notifyCallbacks(e){this._logCallbacks.has(e.level)&&this._logCallbacks.get(e.level).forEach(t=>{try{t(e)}catch(e){console.error("Error in log callback:",e)}}),this._logCallbacks.has("*")&&this._logCallbacks.get("*").forEach(t=>{try{t(e)}catch(e){console.error("Error in global log callback:",e)}})}_consoleOutput(e){let t=new Date(e.timestamp).toISOString(),i=e.userId?`[User: ${e.userId}]`:"",r=`[${t}] [${e.level.toUpperCase()}] ${i} ${e.message}`;switch(e.level){case d.DEBUG:console.debug(r,e.data);break;case d.INFO:console.info(r,e.data);break;case d.WARN:console.warn(r,e.data);break;case d.ERROR:console.error(r,e.data)}}_createLogEntry(e,t,i){return{level:e,message:t,data:i,timestamp:Date.now(),sdkVersion:this._config.getAppInfo().sdkVersion,environment:this._config.getConfig().environment,appVersion:this._config.getAppInfo().appVersion}}}let h="type",c="format",_="range",p="state",m={video:{states:["idle","loading","playing","paused","ended","error"],transitions:{null:["idle","loading","playing"],idle:["loading","playing"],loading:["playing","error"],playing:["paused","ended","error"],paused:["playing","ended"],ended:["idle","loading"],error:["idle"]}},app:{states:["foreground","background"],transitions:{null:["foreground","background"],foreground:["background"],background:["foreground"]}},screen:{states:["active","inactive"],transitions:{null:["active"],active:["inactive"],inactive:["active"]}}};class f{constructor(e={}){if(!e)throw Error("Config is required for Validator");this._config=e}updateConfig(e){this._config=e}validateInitParams(e){if(!e||"object"!=typeof e)throw this._createError(h,"Initialization parameters must be an object");let{customerId:t,appId:i,appName:r,appVersion:a}=e;
2this._validateRequired({customerId:t,appId:i,appName:r,appVersion:a}),this._validateType({customerId:{value:t,type:"string"},appId:{value:i,type:"string"},appName:{value:r,type:"string"},appVersion:{value:a,type:"string"}}),this._validateFormat({appVersion:{value:a,pattern:/^\d+\.\d+\.\d+$/}})}validateEventData(e,t){if(!e||"string"!=typeof e)throw this._createError(h,"eventName must be a string");if(!t||"object"!=typeof t)throw this._createError(h,"eventData must be an object");switch(e){case"VIDEO_START":case"VIDEO_PAUSE":case"VIDEO_RESUME":case"VIDEO_SKIP":case"VIDEO_STOP":case"VIDEO_END":case"VIDEO_BUFFERING":this._validateVideoEvent(e,t);break;case"VIDEO_STATE":break;case"VIDEO_QUALITY_CHANGE":this._validateVideoQualityChange(t);break;case"SCREEN_VIEW":this._validateScreenView(t);break;case"SCREEN_EXIT":this._validateScreenExit(t);break;case"APP_STATE":this._validateAppState(t);break;case"APP_ERROR":case"ERROR":this._validateAppError(t);break;case"APP_PERFORMANCE":case"PERFORMANCE_METRICS":this._validatePerformanceMetrics(t);break;case"SUBSCRIPTION_START":case"SUBSCRIPTION_RENEWAL":case"SUBSCRIPTION_CANCELLATION":case"SUBSCRIPTION":let{type:i,...r}=t;this._validateSubscriptionEvent(e,r);break;case"EXPERIMENT_EXPOSURE":case"EXPERIMENT_ACTIVATION":this._validateExperimentEvent(e,t);break;case"FEATURE_FLAG_EVALUATION":this._validateFeatureFlagEvaluation(t);break;case"EXPERIMENT_RESULTS":this._validateExperimentResults(t);break;case"USER_INFO":this._validateUserInfo(t);break;case"USER_SIGN_UP":case"USER_SIGN_IN":case"USER_SIGN_OUT":this._validateUserAuth(t);break;case"USER_SESSION_START":case"USER_PREFERENCE_CHANGE":this._validateUserEvent(t);break;case"PAYMENT_SUCCESS":case"PAYMENT_INITIATION":case"PAYMENT_FAILURE":case"PAYMENT_REFUND":this._validatePaymentEvent(t);break;case"AD_IMPRESSION":case"AD_CLICK":case"AD_START":case"AD_COMPLETE":case"AD_SKIP":case"AD_ERROR":this._val
2idateAdEvent(t);break;case"USER_CLICK":this._validateUserClick(t);break;case"USER_SCROLL":this._validateUserScroll(t);break;case"USER_SESSION_END":this._validateUserSessionEnd(t);break;case"FEATURE_USAGE":this._validateFeatureUsage(t);break;case"custom":this._validateCustomEvent(t);break;default:t.type&&this._validateType({type:{value:t.type,type:"string"}})}}validateStateTransition(e,t,i){if(!i||"string"!=typeof i)throw this._createError(h,"stateType must be a string");if(!t||"string"!=typeof t)throw this._createError(h,"newState must be a string");let r=m[i];if(!r)throw this._createError(p,`Invalid state type: ${i}`);if(!r.states.includes(t))throw this._createError(p,`Invalid state: ${t}. Must be one of: ${r.states.join(", ")}`);let a=r.transitions[e||"null"];if(!a||!a.includes(t))throw this._createError(p,`Invalid transition from ${e||"null"} to ${t} for ${i}`)}validateConfig(e){if(!e||"object"!=typeof e)throw this._createError(h,"Configuration must be an object");this._validateRequired({endpoint:e.endpoint,batchSize:e.batchSize,flushInterval:e.flushInterval}),this._validateType({endpoint:{value:e.endpoint,type:"string"},batchSize:{value:e.batchSize,type:"number"},flushInterval:{value:e.flushInterval,type:"number"},maxRetries:{value:e.maxRetries,type:"number"},retryDelay:{value:e.retryDelay,type:"number"}}),this._validateRange({batchSize:{value:e.batchSize,min:1,max:1e3},flushInterval:{value:e.flushInterval,min:1e3,max:6e4},maxRetries:{value:e.maxRetries,min:0,max:10},retryDelay:{value:e.retryDelay,min:1e3,max:3e4}})}_validateRequired(e){Object.entries(e).forEach(([e,t])=>{if(null==t||""===t)throw this._createError("required",`${e} is required`)})}_validateType(e){Object.entries(e).forEach(([e,{value:t,type:i}])=>{if(null!=t){let r=typeof t;if(r!==i)throw this._createError(h,`${e} must be of type ${i}, got ${r}`)}})}_validateFormat(e){Object.entries(e).forEach(([e,{value:t,pattern:i}])=>{if(null!=t&&!i.test(t))throw this._createError(c,`${e} has invalid format`)})}_validateRange(e){Object.entries(e).forEach(([e,{value:t,min:i,max:r}])=>{if(null!=t&&(t<i||t>r))throw this._createError(_,`${e} must be between ${i} and ${r}`)})}_validateEnum(e){Object.entries(e).forEach(([e,{value:t,values:i}])=>{if(null!=t&&!i.includes(t))throw this._createError("enum",`${e} must be one of: ${i.join(", ")}`)})}_validateVideoState(e){this._validateRequired({state:e.state}),this._validateEnum({state:{value:e.state,values:m.video.states}}),void 0!==e.duration&&(this._validateType({duration:{value:e.duration,type:"number"}}),this._validateRange({duration:{value:e.duration,min:0,max:Number.MAX_SAFE_INTEGER}})),void 0!==e.currentTime&&(this._validateType({currentTime:{value:e.currentTime,type:"number"}}),this._validateRange({currentTime:{value:e.currentTime,min:0,max:e.duration||Number.MAX_SAFE_INTEGER}}))}_validateScreenView(e){this._validateRequired({screenName:e.screenName}),this._validateType({screenName:{value:e.screenName,type:"string"},screenId:{value:e.screenId,type:"string"},previousScreen:{value:e.previousScreen,type:"string"}})}_validateScreenExit(e){if(this._validateRequired({screenName:e.screenName,screenId:e.screenId,duration:e.duration}),this._validateType({screenName:{value:e.screenName,type:"string"},screenId:{value:e.screenId,type:"string"},duration:{value:e.duration,type:"number"},timestamp:{value:e.timestamp,type:"number"}}),e.duration<0)throw this._createError(_,`duration must be non-negative, got: ${e.duration}`);e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}})}_validateAppState(e){this._validateRequired({state:e.state}),this._validateEnum({state:{value:e.state,values:m.app.states}}),void 0!==e.timestamp&&this._validateType({timestamp:{value:e.timestamp,type:"number"}})}_validateAppError(e){this._validateRequired({errorCode:e.errorCode,errorMessage:e.errorMessage}),this._validateType({errorCode:{value:e.errorCode,type:"string"},errorMessage:{value:e.errorMessage,type:"string"},stackTrace:{value:e.stackTrace,type:"string"},timestamp:{value:e.timestamp,type:"number"}}),e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}})}
2_validateUserInfo(e){this._validateRequired({userId:e.userId}),this._validateType({userId:{value:e.userId,type:"string"},userType:{value:e.userType,type:"string"},deviceId:{value:e.deviceId,type:"string"}})}_validateUserAuth(e){if(this._validateRequired({userId:e.userId,email:e.email}),this._validateType({userId:{value:e.userId,type:"string"},email:{value:e.email,type:"string"},timestamp:{value:e.timestamp,type:"number"}}),!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email))throw this._createError(c,`Invalid email format: ${e.email}`);e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}})}_validateUserEvent(e){this._validateRequired({userId:e.userId}),this._validateType({userId:{value:e.userId,type:"string"},timestamp:{value:e.timestamp,type:"number"}}),e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}})}_validatePaymentEvent(e){this._validateRequired({paymentId:e.paymentId,amount:e.amount,currency:e.currency}),this._validateType({paymentId:{value:e.paymentId,type:"string"},amount:{value:e.amount,type:"number"},currency:{value:e.currency,type:"string"},timestamp:{value:e.timestamp,type:"number"}}),e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}})}_validateAdEvent(e){this._validateRequired({adId:e.adId,adType:e.adType}),this._validateType({adId:{value:e.adId,type:"string"},adType:{value:e.adType,type:"string"},adUnit:{value:e.adUnit,type:"string"},adNetwork:{value:e.adNetwork,type:"string"},duration:{value:e.duration,type:"number"},timestamp:{value:e.timestamp,type:"number"}}),e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}}),e.clickPosition&&this._validateType({"clickPosition.x":{value:e.clickPosition.x,type:"number"},"clickPosition.y":{value:e.clickPosition.y,type:"number"}}),e.errorType&&this._validateType({errorType:{value:e.errorType,type:"string"},message:{value:e.message,type:"string"}})}_validateCustomEvent(e){this._validateRequired({eventName:e.eventName}),this._validateType({eventName:{value:e.eventName,type:"string"}}),void 0!==e.eventData&&this._validateType({eventData:{value:e.eventData,type:"object"}})}_validateVideoEvent(e,t){if(this._validateRequired({assetId:t.assetId,assetName:t.assetName,duration:t.duration,position:t.position,quality:t.quality,reason:t.reason}),this._validateType({assetId:{value:t.assetId,type:"string"},assetName:{value:t.assetName,type:"string"},duration:{value:t.duration,type:"number"},position:{value:t.position,type:"number"},quality:{value:t.quality,type:"string"},reason:{value:t.reason,type:"string"}}),this._validateRange({duration:{value:t.duration,min:0,max:Number.MAX_SAFE_INTEGER},position:{value:t.position,min:0,max:t.duration||Number.MAX_SAFE_INTEGER}}),t.metadata){this._validateType({metadata:{value:t.metadata,type:"object"}});let e=["playbackSpeed","bufferingTime","bitrate","resolution","playerVersion","playerType","category","language","subtitles","reason"];Object.keys(t.metadata).forEach(t=>{if(!e.includes(t))throw this._createError(c,`Invalid metadata field: ${t}. Must be one of: ${e.join(", ")}`)}),void 0!==t.metadata.playbackSpeed&&this._validateType({"metadata.playbackSpeed":{value:t.metadata.playbackSpeed,type:"number"}}),void 0!==t.metadata.bufferingTime&&this._validateType({"metadata.bufferingTime":{value:t.metadata.bufferingTime,type:"number"}}),void 0!==t.metadata.bitrate&&this._validateType({"metadata.bitrate":{value:t.metadata.bitrate,type:"number"}}),void 0!==t.metadata.resolution&&this._validateType({"metadata.resolution":{value:t.metadata.resolution,type:"string"}}),void 0!==t.metadata.playerVersion&&this._validateType({"metadata.playerVersion":{value:t.metadata.playerVersion,type:"string"}}),void 0!==t.metadata.playerType&&this._validateType({"metadata.playerType":{value:t.metadata.playerType,type:"string"}})}}_validateVideoQualityChange(e){if(this._validateRequired({assetId:e.assetId,assetName:e.assetName,quality:e.quality,reason:e.reason}),this._validateType({assetId:{value:e.assetId,type:"string"},assetName:{value:e.assetName,type:"string"},quality:{value:e.quality,type:"string"},reason:{value:e.reason,type:"string"}}
2),e.metadata){this._validateType({metadata:{value:e.metadata,type:"object"}});let t=["playbackSpeed","bufferingTime","bitrate","resolution","playerVersion","playerType","previousQuality"];Object.keys(e.metadata).forEach(e=>{if(!t.includes(e))throw this._createError(c,`Invalid metadata field: ${e}. Must be one of: ${t.join(", ")}`)}),void 0!==e.metadata.previousQuality&&this._validateType({"metadata.previousQuality":{value:e.metadata.previousQuality,type:"string"}})}}_validatePerformanceMetrics(e){this._validateRequired({timestamp:e.timestamp,metrics:e.metrics}),this._validateType({timestamp:{value:e.timestamp,type:"number"},metrics:{value:e.metrics,type:"object"}});let t=["memoryUsage","cpuUsage","networkLatency","frameRate","loadTime","renderTime","jsHeapSize","jsHeapSizeLimit"];Object.keys(e.metrics).forEach(i=>{if(!t.includes(i))throw this._createError(c,`Invalid metric field: ${i}. Must be one of: ${t.join(", ")}`);this._validateType({[`metrics.${i}`]:{value:e.metrics[i],type:"number"}})}),e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}})}_validateSubscriptionEvent(e,t){if(this._validateRequired({subscriptionId:t.subscriptionId,planId:t.planId,planName:t.planName,amount:t.amount,currency:t.currency,duration:t.duration,measure:t.measure,status:t.status}),this._validateType({subscriptionId:{value:t.subscriptionId,type:"string"},planId:{value:t.planId,type:"string"},planName:{value:t.planName,type:"string"},amount:{value:t.amount,type:"number"},currency:{value:t.currency,type:"string"},duration:{value:t.duration,type:"number"},measure:{value:t.measure,type:"string"},status:{value:t.status,type:"string"}}),t.metadata){this._validateType({metadata:{value:t.metadata,type:"object"}});let e=["paymentMethod","autoRenew","trialPeriod","startDate","endDate","cancellationReason","source"];Object.keys(t.metadata).forEach(t=>{if(!e.includes(t))throw this._createError(c,`Invalid metadata field: ${t}. Must be one of: ${e.join(", ")}`)})}}_validateExperimentEvent(e,t){if(this._validateRequired({experimentId:t.experimentId,experimentName:t.experimentName,variantId:t.variantId,variantName:t.variantName,timestamp:t.timestamp}),this._validateType({experimentId:{value:t.experimentId,type:"string"},experimentName:{value:t.experimentName,type:"string"},variantId:{value:t.variantId,type:"string"},variantName:{value:t.variantName,type:"string"},timestamp:{value:t.timestamp,type:"number"}}),t.metadata){this._validateType({metadata:{value:t.metadata,type:"object"}});let e=["exposureType","source","context","activationType","activationTrigger","sessionId","evaluationTime","sessionDuration"];Object.keys(t.metadata).forEach(t=>{if(!e.includes(t))throw this._createError(c,`Invalid metadata field: ${t}. Must be one of: ${e.join(", ")}`)}),t.metadata.context&&this._validateType({"metadata.context":{value:t.metadata.context,type:"object"}})}}_validateExperimentResults(e){if(this._validateRequired({experimentId:e.experimentId,experimentName:e.experimentName,variantId:e.variantId,variantName:e.variantName,results:e.results}),this._validateType({experimentId:{value:e.experimentId,type:"string"},experimentName:{value:e.experimentName,type:"string"},variantId:{value:e.variantId,type:"string"},variantName:{value:e.variantName,type:"string"},results:{value:e.results,type:"object"}}),e.results&&this._validateType({results:{value:e.results,type:"object"}}),e.metadata){this._validateType({metadata:{value:e.metadata,type:"object"}});let t=["resultType","metrics","context","sessionDuration","source"];Object.keys(e.metadata).forEach(e=>{if(!t.includes(e))throw this._createError(c,`Invalid metadata field: ${e}. Must be one of: ${t.join(", ")}`)})}}_validateFeatureFlagEvaluation(e){this._validateRequired({featureId:e.featureId,featureName:e.featureName,enabled:e.enabled,timestamp:e.timestamp}),this._validateType({featureId:{value:e.featureId,type:"string"},featureName:{value:e.featureName,type:"string"},enabled:{value:e.enabled,type:"boolean"},timestamp:{value:e.timestamp,type:"number"}}),e.evaluationContext&&this._validateType({evaluationContext:{value:e.evaluationContext,type:"object"}}
2),e.source&&this._validateType({source:{value:e.source,type:"string"}}),e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}})}_validateUserClick(e){this._validateRequired({elementId:e.elementId,elementType:e.elementType}),this._validateType({elementId:{value:e.elementId,type:"string"},elementType:{value:e.elementType,type:"string"},pageUrl:{value:e.pageUrl,type:"string"},position:{value:e.position,type:"object"},timestamp:{value:e.timestamp,type:"number"}}),e.position&&this._validateType({"position.x":{value:e.position.x,type:"number"},"position.y":{value:e.position.y,type:"number"}})}_validateUserScroll(e){this._validateRequired({scrollDepth:e.scrollDepth}),this._validateType({scrollDepth:{value:e.scrollDepth,type:"number"},scrollPercentage:{value:e.scrollPercentage,type:"number"},pageUrl:{value:e.pageUrl,type:"string"},timestamp:{value:e.timestamp,type:"number"}}),void 0!==e.scrollPercentage&&this._validateRange({scrollPercentage:{value:e.scrollPercentage,min:0,max:100}})}_validateUserSessionEnd(e){this._validateRequired({userId:e.userId,sessionId:e.sessionId,timestamp:e.timestamp}),this._validateType({userId:{value:e.userId,type:"string"},sessionId:{value:e.sessionId,type:"string"},timestamp:{value:e.timestamp,type:"number"}}),e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}})}_validateFeatureUsage(e){this._validateRequired({featureId:e.featureId,featureName:e.featureName,action:e.action}),this._validateType({featureId:{value:e.featureId,type:"string"},featureName:{value:e.featureName,type:"string"},action:{value:e.action,type:"string"},timestamp:{value:e.timestamp,type:"number"}}),e.metadata&&this._validateType({metadata:{value:e.metadata,type:"object"}})}_createError(e,t){let i=Error(t);return i.type=e,i}}class I{constructor(e){if(!e)throw Error("Dependencies are required for tracker initialization");const{config:t,eventPublisher:i,logger:r,validator:a,errorHandler:s,stateManager:n}=e;if(!t)throw Error("Config is required");if(!i)throw Error("Event publisher is required");if(!r)throw Error("Logger is required");if(!a)throw Error("Validator is required");if(!s)throw Error("Error handler is required");this._config=t,this._eventPublisher=i,this._logger=r,this._validator=a,this._errorHandler=s,this._stateManager=n}updateConfig(e){this._config=e}_createEventData(e){let t=this._config.getDeviceInfo(),i=this._config.getAppInfo();return{...e,timestamp:this._getTimestamp(),sessionId:this._config.getSessionId(),deviceInfo:t,appInfo:i,deviceId:t?.deviceId||"",deviceType:t?.deviceType||"",deviceBrand:t?.deviceBrand||"",deviceModel:t?.deviceModel||"",deviceMarketingName:t?.deviceMarketingName||"",osVersion:t?.osVersion||"",platform:t?.platform||"",profileId:this._config.get&&this._config.get("profileId")||"",userData:this._config.get&&this._config.get("userData")||{},referralId:this._config.get&&this._config.get("referralId")||"",referralData:this._config.get&&this._config.get("referralData")||{},subscriberId:this._config.get&&this._config.get("subscriberId")||"",subscriberType:this._config.get&&this._config.get("subscriberType")||"",subscriberTag:this._config.get&&this._config.get("subscriberTag")||"",pId:this._config.get&&this._config.get("pId")||this._config.get&&this._config.get("profileId")||""}}_publishEvent(e,t){try{this._eventPublisher.publishEvent(e,t),this._logger.debug(`Event published: ${e}`,t)}catch(t){this._handleError(t,"_publishEvent",`${e}_error`)}}_handleError(e,t,i="tracker_error"){this._logger.error(`Error in ${t}:`,e),this._errorHandler.handleError(e,t,{eventType:i,tracker:this.constructor.name})}_getTimestamp(){return this._config.getSynchronizedTimestamp()}}class v extends I{constructor(e){super({...e,stateManager:e.stateManager||new r})}reportVideoStart(e){try{this._validator.validateEventData("VIDEO_START",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_START",t),this._logger.debug("Video start reported",t)}catch(e){this._handleError(e,"reportVideoStart","video_error")}}reportVideoPause(e){try{this._validator.validateEventData("VIDEO_PAUSE",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_PAUSE",t),this._logger.debug("Video pause reported",t)}catch(e){this._handleError(e,"reportVideoPause","video_error")}}
2reportVideoResume(e){try{this._validator.validateEventData("VIDEO_RESUME",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_RESUME",t),this._logger.debug("Video resume reported",t)}catch(e){this._handleError(e,"reportVideoResume","video_error")}}reportVideoSkip(e){try{this._validator.validateEventData("VIDEO_SKIP",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_SKIP",t),this._logger.debug("Video skip reported",t)}catch(e){this._handleError(e,"reportVideoSkip","video_error")}}reportVideoStop(e){try{this._validator.validateEventData("VIDEO_STOP",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_STOP",t),this._logger.debug("Video stop reported",t)}catch(e){this._handleError(e,"reportVideoStop","video_error")}}reportVideoEnd(e){try{this._validator.validateEventData("VIDEO_END",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_END",t),this._logger.debug("Video end reported",t)}catch(e){this._handleError(e,"reportVideoEnd","video_error")}}reportVideoQualityChange(e){try{this._validator.validateEventData("VIDEO_QUALITY_CHANGE",e);let t=this._createEventData(e);this._publishEvent("VIDEO_QUALITY_CHANGE",t),this._logger.debug("Video quality change reported",t)}catch(e){throw this._handleError(e,"reportVideoQualityChange","video_error"),e}}reportVideoBuffering(e){try{this._validator.validateEventData("VIDEO_BUFFERING",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_BUFFERING",t),this._logger.debug("Video buffering reported",t)}catch(e){throw this._handleError(e,"reportVideoBuffering","video_error"),e}}reportVideoSeek(e){try{this._validator.validateEventData("VIDEO_SEEK",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_SEEK",t),this._logger.debug("Video seek reported",t)}catch(e){this._handleError(e,"reportVideoSeek","video_error")}}reportVideoFullscreen(e){try{this._validator.validateEventData("VIDEO_FULLSCREEN",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_FULLSCREEN",t),this._logger.debug("Video fullscreen reported",t)}catch(e){this._handleError(e,"reportVideoFullscreen","video_error")}}reportVideoExitFullscreen(e){try{this._validator.validateEventData("VIDEO_EXIT_FULLSCREEN",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_EXIT_FULLSCREEN",t),this._logger.debug("Video exit fullscreen reported",t)}catch(e){this._handleError(e,"reportVideoExitFullscreen","video_error")}}reportVideoState(e){try{this._validator.validateEventData("VIDEO_STATE",e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent("VIDEO_STATE",t),this._logger.debug("Video state reported",t)}catch(e){throw this._handleError(e,"reportVideoState","video_error"),e}}getVideoState(){return this._stateManager.getVideoState()}}class E extends I{constructor(e){super(e)}reportScreenView(e){try{this._validator.validateEventData("SCREEN_VIEW",e);let t=this._createEventData(e);this._publishEvent("SCREEN_VIEW",t),this._logger.debug("Screen view reported",t)}catch(e){throw this._handleError(e,"reportScreenView","screen_error"),e}}reportScreenExit(e){try{this._validator.validateEventData("screen_exit",e);let t=this._createEventData(e);this._publishEvent("screen_exit",t),this._logger.debug("Screen exit reported",t)}catch(e){throw this._handleError(e,"reportScreenExit","screen_error"),e}}getScreenState(){return this._stateManager.getScreenState()}}let S="VIDEO_SHARED",g="VIDEO_BOOKMARKED",T="VIDEO_LIKED",b="VIDEO_COMMENTED",y="VIDEO_RATED",D="VIDEO_QUALITY_CHANGED",R="VIDEO_PLAYBACK_SPEED_CHANGED",A="APP_STATE",P="APP_ERROR",N="APP_PERFORMANCE",C="USER_SIGN_UP",O="USER_SESSION_START",U="USER_SESSION_END",M="USER_PREFERENCE_UPDATE",x="USER_PROFILE_UPDATE",w="SUBSCRIPTION_START",k="SUBSCRIPTION_RENEWAL",L="SUBSCRIPTION_CANCELLATION",V="SUBSCRIPTION_UPGRADE",B="SUBSCRIPTION_DOWNGRADE",F="SUBSCRIPTION_EXPIRATION",q="PAYMENT_SUCCESS",G="PAYMENT_INITIATION",H="PAYMENT_FAILURE",z="PAYMENT_REFUND",W="AD_START",K="AD_COMPLETE",j="AD_ERROR",Q="AD_IMPRESSION",Y="AD_CLICK",$="AD_SKIP",X="EXPERIMENT_EXPOSURE",J="EXPERIMENT_ACTIVATION",Z="FEATURE_FLAG_EVALUATION",ee="EXPERIMENT_RESULTS";class et extends I{constructor(e){super(e)}
2reportAppState(e){try{this._validator.validateEventData(A,e);let t=this._createEventData(e);this._publishEvent(A,t),this._logger.debug("Application state reported",t)}catch(e){this._handleError(e,"reportAppState","app_error")}}reportAppError(e){try{this._validator.validateEventData(P,e);let t=this._createEventData(e);this._publishEvent(P,t),this._logger.debug("Application error reported",t)}catch(e){this._handleError(e,"reportAppError","app_error")}}reportPerformanceMetrics(e){try{this._validator.validateEventData(N,e);let t=this._createEventData(e);this._publishEvent(N,t),this._logger.debug("Application performance metrics reported",t)}catch(e){this._handleError(e,"reportPerformanceMetrics","app_error")}}getAppState(){return this._stateManager.getAppState()}_validateAppData(e,t){if(!e||"object"!=typeof e)throw Error("Invalid application data");this._validator.validateEventData(t,e)}}class ei extends I{constructor(e){super(e)}reportUserIdentification(e){try{this._validator.validateEventData(C,e);let t=this._createEventData(e);this._publishEvent(C,t)}catch(e){this._handleError(e,"reportUserIdentification","user_error")}}reportUserProfileUpdate(e){try{this._validator.validateEventData(x,e);let t=this._createEventData(e);this._publishEvent(x,t)}catch(e){this._handleError(e,"reportUserProfileUpdate","user_error")}}reportUserPreferenceUpdate(e){try{this._validator.validateEventData(M,e);let t=this._createEventData(e);this._publishEvent(M,t)}catch(e){this._handleError(e,"reportUserPreferenceUpdate","user_error")}}reportUserSessionEnd(e){try{this._validator.validateEventData(U,e);let t=this._createEventData(e);this._publishEvent(U,t)}catch(e){this._handleError(e,"reportUserSessionEnd","user_error")}}reportUserSessionStart(e){try{this._validator.validateEventData(O,e);let t=this._createEventData(e);this._publishEvent(O,t)}catch(e){this._handleError(e,"reportUserSessionStart","user_error")}}reportUserPreferenceChange(e){try{this._validator.validateEventData(M,e);let t=this._createEventData(e);this._publishEvent(M,t)}catch(e){this._handleError(e,"reportUserPreferenceChange","user_error")}}}class er{constructor(e){this.sdk=e}reportSubscriberInfo(e){if(!e||"object"!=typeof e)throw Error("data must be an object");if(!e.subscriberId||"string"!=typeof e.subscriberId)throw Error("data.subscriberId must be a string");if(!e.planType||"string"!=typeof e.planType)throw Error("data.planType must be a string");if(!e.segment||"string"!=typeof e.segment)throw Error("data.segment must be a string");if(!e.profileId||"string"!=typeof e.profileId)throw Error("data.profileId must be a string");this.sdk._eventPublisher.publishEvent("SUBSCRIBER_INFO",{...e,timestamp:Date.now()})}reportReferralInfo(e){if(!e||"object"!=typeof e)throw Error("data must be an object");if(!e.referralId||"string"!=typeof e.referralId)throw Error("data.referralId must be a string");if(!e.source||"string"!=typeof e.source)throw Error("data.source must be a string");if(!e.medium||"string"!=typeof e.medium)throw Error("data.medium must be a string");if(!e.campaign||"string"!=typeof e.campaign)throw Error("data.campaign must be a string");this.sdk._eventPublisher.publishEvent("REFERRAL_INFO",{...e,timestamp:Date.now()})}}class ea{constructor(e){const{config:t,eventPublisher:i,logger:r,validator:a,errorHandler:s,stateManager:n}=e;if(!t)throw Error("Config is required");if(!i)throw Error("Event publisher is required");if(!r)throw Error("Logger is required");if(!a)throw Error("Validator is required");if(!s)throw Error("Error handler is required");if(!n)throw Error("State manager is required");this._config=t,this._eventPublisher=i,this._logger=r,this._validator=a,this._errorHandler=s,this._stateManager=n,this._enabled=!1,this._isTracking=!1,this._lastActivity=Date.now(),this._activityTimeout=null,this._sessionTimeout=null,this._sessionStartTime=null,this._lastActivityTime=null,this._currentPath=null,this._previousPath=null,this._navigationStartTime=null,this._clickCount=0,this._lastClickTime=null,this._scrollDepth=0,this._maxScrollDepth=0,this._scrollStartTime=null,this._boundHandleSessionStart=this._handleSessionStart.bind(this),this._boundHandleSessionEnd=this._handleSessionEnd.bind(this),this._boundHandleNavigation=this._handleNavigation.bind(this),this._boundHandleClick=this._handleClick.bind(this),this._boundHandleScroll=this._handleScroll.bind(this)}_initializeEventListeners(){if("u">typeof window){if(window.addEventListener("load",this._boundHandleSessionStart),window.addEventListener("beforeunload",this._boundHandleSessionEnd),window.addEventListener("popstate",this._boundHandleNavigation),"u">typeof history){let e=history.pushState;history.pushState=(...t)=>{e.apply(history,t),this._boundHandleNavigation()}}document.addEventListener("click",this._boundHandleClick),window.addEventListener("scroll",this._boundHandleScroll)}}
2_handleSessionStart(){if(console.log("[AUTO-COLLECTION] _handleSessionStart called, _enabled:",this._enabled),this._enabled&&!this._isTracking){this._isTracking=!0,this._lastActivity=Date.now(),this._resetTimers();try{this._sessionStartTime=Date.now(),this._lastActivityTime=this._sessionStartTime;let e=this._createEventData("session_start",{sessionId:this._config.getSessionId(),deviceInfo:this._config.getDeviceInfo(),appInfo:this._config.getAppInfo()});this._eventPublisher.publishEvent("session_start",e),this._logger.debug("Session started",{sessionId:this._config.getSessionId()})}catch(e){this._handleError(e,"session_start")}}}_handleSessionEnd(){if(this._enabled&&this._isTracking)try{let e=Date.now()-this._sessionStartTime,t=this._createEventData("session_end",{sessionId:this._config.getSessionId(),deviceInfo:this._config.getDeviceInfo(),appInfo:this._config.getAppInfo(),duration:e});this._eventPublisher.publishEvent("session_end",t),this._logger.debug("Session ended",{sessionId:this._config.getSessionId()}),this._isTracking=!1,this._clearTimers()}catch(e){this._handleError(e,"session_end")}}_handleNavigation(){if(this._enabled)try{let e=window.location.pathname;if(e===this._currentPath)return;this._previousPath=this._currentPath,this._currentPath=e,this._navigationStartTime=Date.now();let t=this._createEventData("navigation",{currentPath:this._currentPath,previousPath:this._previousPath,referrer:document.referrer});this._eventPublisher.publishEvent("navigation",t),this._logger.debug("Navigation tracked",{path:this._currentPath})}catch(e){this._handleError(e,"navigation")}}_handleClick(e){if(console.log("[AUTO-COLLECTION] _handleClick called, _enabled:",this._enabled),this._enabled)try{this._clickCount++,this._lastClickTime=Date.now(),this._lastActivityTime=this._lastClickTime;let t=e.target,i=this._createEventData("click",{position:{x:e.clientX,y:e.clientY},target:{tagName:t.tagName,id:t.id,className:t.className,text:t.textContent?.trim().substring(0,100),href:t.href,type:t.type}});this._eventPublisher.publishEvent("click",i),this._logger.debug("Click tracked",{position:{x:e.clientX,y:e.clientY}})}catch(e){this._handleError(e,"click")}}_handleScroll(){if(this._enabled)if(this._config&&this._logger&&this._eventPublisher)try{let e=window.pageYOffset||document.documentElement.scrollTop,t=document.documentElement.scrollHeight||document.body.scrollHeight,i=document.documentElement.clientHeight;if(t<=0||i<=0)return;let r=(e+i)/t*100;if(r>this._maxScrollDepth){this._maxScrollDepth=r,this._scrollStartTime=this._scrollStartTime||Date.now(),this._lastActivityTime=Date.now();let a=this._createEventData("scroll_depth",{depth:r,scrollTop:e,scrollHeight:t,clientHeight:i});this._eventPublisher.publishEvent("scroll_depth",a),this._logger.debug("Scroll tracked",{depth:r})}}catch(e){this._handleError(e,"scroll")}else console.warn("AutoCollectionManager not fully initialized")}_handleError(e,t){try{let i=e instanceof Error?e.message:String(e);this._logger&&this._logger.error(`Error in ${t}:`,e),this._eventPublisher&&this._eventPublisher.publishEvent("auto_collection_error",{error:i,context:t,timestamp:Date.now()})}catch(i){console.error("Error in error handler:",i),console.error("Original error:",e),console.error("Context:",t)}}getSessionInfo(){return{sessionId:this._config.getSessionId(),startTime:this._sessionStartTime,lastActivityTime:this._lastActivityTime,clickCount:this._clickCount,maxScrollDepth:this._maxScrollDepth}}getNavigationInfo(){return{currentPath:this._currentPath,previousPath:this._previousPath,navigationStartTime:this._navigationStartTime}}setEnabled(e){console.log("[AUTO-COLLECTION] setEnabled called with:",e),this._enabled=e,e?(console.log("[AUTO-COLLECTION] Initializing event listeners"),this._initializeEventListeners()):(console.log("[AUTO-COLLECTION] Removing event listeners"),this._removeEventListeners())}_removeEventListeners(){"u">typeof window&&(window.removeEventListener("load",this._boundHandleSessionStart),window.removeEventListener("beforeunload",this._boundHandleSessionEnd),window.removeEventListener("popstate",this._boundHandleNavigation),document.removeEventListener("click",this._boundHandleClick),window.removeEventListener("scroll",this._boundHandleScroll))}_resetTimers(){this._activityTimeout=setTimeout(()=>{this._endSession()},this._config.getActivityTimeout()),this._sessionTimeout=setTimeout(()=>{this._endSession()},this._config.getSessionTimeout())}_clearTimers(){clearTimeout(this._activityTimeout),clearTimeout(this._sessionTimeout)}_createEventData(e,t={}){return{timestamp:Date.now(),sessionId:this._config.getSessionId(),deviceInfo:this._config.getDeviceInfo(),appInfo:this._config.getAppInfo(),...t}}}class es extends I{constructor(e){super(e)}
2reportSubscriptionStart(e){try{this._validator.validateEventData(w,e);let t=this._createEventData(e);this._publishEvent(w,t)}catch(e){this._handleError(e,"reportSubscriptionStart","subscription_error")}}reportSubscriptionRenewal(e){try{let{metadata:t,...i}=e,r={paymentMethod:t?.paymentMethod,autoRenew:t?.autoRenew,trialPeriod:t?.trialPeriod,startDate:t?.renewalDate||t?.startDate,endDate:t?.nextRenewalDate||t?.endDate},a=this._createEventData({...i,metadata:r});this._validator.validateEventData(k,a),this._publishEvent(k,a)}catch(e){this._handleError(e,"reportSubscriptionRenewal","subscription_error")}}reportSubscriptionCancellation(e){try{let{metadata:t,...i}=e,r={paymentMethod:t?.paymentMethod,autoRenew:t?.autoRenew,trialPeriod:t?.trialPeriod,startDate:t?.startDate,endDate:t?.cancellationDate||t?.endDate,cancellationReason:t?.reason||t?.cancellationReason},a=this._createEventData({...i,metadata:r});this._validator.validateEventData(L,a),this._publishEvent(L,a)}catch(e){this._handleError(e,"reportSubscriptionCancellation","subscription_error")}}reportSubscriptionExpiration(e){try{this._validator.validateEventData(F,e);let t=this._createEventData(e);this._publishEvent(F,t)}catch(e){this._handleError(e,"reportSubscriptionExpiration","subscription_error")}}reportSubscriptionUpgrade(e){try{this._validator.validateEventData(V,e);let t=this._createEventData(e);this._publishEvent(V,t)}catch(e){this._handleError(e,"reportSubscriptionUpgrade","subscription_error")}}reportSubscriptionDowngrade(e){try{this._validator.validateEventData(B,e);let t=this._createEventData(e);this._publishEvent(B,t)}catch(e){this._handleError(e,"reportSubscriptionDowngrade","subscription_error")}}reportSubscriptionViewed(e){try{if(!e||"object"!=typeof e)throw Error("data must be an object");if(!e.planId||"string"!=typeof e.planId)throw Error("data.planId must be a string");let t=this._createEventData(e);this._validator.validateEventData("SUBSCRIPTION_VIEWED",t),this._publishEvent("SUBSCRIPTION_VIEWED",t)}catch(e){this._handleError(e,"reportSubscriptionViewed","subscription_error")}}getSubscriptionState(){return this._stateManager.getSubscriptionState()}_validateSubscriptionData(e){if(!e||"object"!=typeof e)throw Error("Invalid subscription data");for(let t of["subscriptionId","planId","planName","amount","currency","duration","measure","status"])if(!e[t])throw Error(`Missing required field: ${t}`);if(e.metadata){let t=["trialPeriod","renewalDate","cancellationDate","paymentMethod","billingCycle","discountCode","promotionId"];for(let i of Object.keys(e.metadata))if(!t.includes(i))throw Error(`Invalid metadata field: ${i}`)}}}class en extends I{constructor(e){super(e)}reportPaymentInitiation(e){try{this._validator.validateEventData(G,e);let t=this._createEventData(e);this._publishEvent(G,t),this._stateManager.updatePaymentState("initiated",e),this._logger.debug("Payment initiation reported",e)}catch(e){this._handleError(e,"reportPaymentInitiation","payment_error")}}reportPaymentSuccess(e){try{this._validator.validateEventData(q,e);let t=this._createEventData(e);this._publishEvent(q,t),this._stateManager.updatePaymentState("success",e),this._logger.debug("Payment success reported",e)}catch(e){this._handleError(e,"reportPaymentSuccess","payment_error")}}reportPaymentFailure(e){try{this._validator.validateEventData(H,e);let t=this._createEventData(e);this._publishEvent(H,t),this._stateManager.updatePaymentState("failed",e),this._logger.debug("Payment failure reported",e)}catch(e){this._handleError(e,"reportPaymentFailure","payment_error")}}reportPaymentRefund(e){try{this._validator.validateEventData(z,e);let t=this._createEventData(e);this._publishEvent(z,t),this._stateManager.updatePaymentState("refunded",e),this._logger.debug("Payment refund reported",e)}catch(e){this._handleError(e,"reportPaymentRefund","payment_error")}}getPaymentState(){try{return this._stateManager.getPaymentState()}catch(e){return this._handleError(e,"getPaymentState","payment_error"),null}}}class eo extends I{constructor(e){super(e)}reportAdStart(e){try{this._validator.validateEventData(W,e);let t=this._createEventData(e);this._publishEvent(W,t)}catch(e){this._handleError(e,"reportAdStart","ad_error")}}
2reportAdImpression(e){try{this._validator.validateEventData(Q,e);let t=this._createEventData(e);this._publishEvent(Q,t)}catch(e){this._handleError(e,"reportAdImpression","ad_error")}}reportAdClick(e){try{this._validator.validateEventData(Y,e);let t=this._createEventData(e);this._publishEvent(Y,t)}catch(e){this._handleError(e,"reportAdClick","ad_error")}}reportAdComplete(e){try{this._validator.validateEventData(K,e);let t=this._createEventData(e);this._publishEvent(K,t)}catch(e){this._handleError(e,"reportAdComplete","ad_error")}}reportAdSkip(e){try{this._validator.validateEventData($,e);let t=this._createEventData(e);this._publishEvent($,t)}catch(e){this._handleError(e,"reportAdSkip","ad_error")}}reportAdError(e){try{this._validator.validateEventData(j,e);let t=this._createEventData(e);this._publishEvent(j,t)}catch(e){this._handleError(e,"reportAdError","ad_error")}}getAdState(){return this._stateManager.getAdState()}}class ed extends I{constructor(e){super(e)}reportExperimentExposure(e){try{this._validator.validateEventData(X,e);let t=this._createEventData(e);this._publishEvent(X,t),this._logger.debug("Experiment exposure reported",t)}catch(e){this._handleError(e,"reportExperimentExposure")}}reportExperimentActivation(e){try{this._validator.validateEventData(J,e);let t=this._createEventData(e);this._publishEvent(J,t),this._logger.debug("Experiment activation reported",t)}catch(e){this._handleError(e,"reportExperimentActivation")}}reportFeatureFlagEvaluation(e){try{this._validator.validateEventData(Z,e);let t=this._createEventData(e);this._publishEvent(Z,t),this._logger.debug("Feature flag evaluation reported",t)}catch(e){this._handleError(e,"reportFeatureFlagEvaluation")}}reportExperimentResults(e){try{this._validator.validateEventData(ee,e);let t=this._createEventData(e);this._publishEvent(ee,t),this._logger.debug("Experiment results reported",t)}catch(e){this._handleError(e,"reportExperimentResults")}}_handleError(e,t,i){this._logger.error(`Error in ${t}: ${e.message}`);let r={error:e.message,context:t,timestamp:Date.now(),stack:e.stack};i&&this._publishEvent(i,r)}}class el extends I{constructor(e){super(e)}reportUserSignUp(e){this._validator.validateEventData("user_sign_up",e);let t=this._createEventData(e);this._publishEvent("user_sign_up",t),this._logger.debug("User sign up reported",t)}reportUserSignIn(e){this._validator.validateEventData("user_sign_in",e);let t=this._createEventData(e);this._publishEvent("user_sign_in",t),this._logger.debug("User sign in reported",t)}reportUserSignOut(e){this._validator.validateEventData("user_sign_out",e);let t=this._createEventData(e);this._publishEvent("user_sign_out",t),this._logger.debug("User sign out reported",t)}reportUserProfileUpdate(e){this._validator.validateEventData("user_profile_update",e);let t=this._createEventData(e);this._publishEvent("user_profile_update",t),this._logger.debug("User profile update reported",t)}}class eu extends I{constructor(e){super(e)}reportFeatureUsage(e){try{this._validator.validateEventData("feature_usage",e);let t=this._createEventData(e);this._publishEvent("feature_usage",t),this._logger.debug("Feature usage reported",t)}catch(e){this._handleError(e,"reportFeatureUsage","feature_usage_error")}}}class eh extends I{constructor(e){super(e)}reportUserInteraction(e){try{this._validator.validateEventData("user_interaction",e);let t=this._createEventData(e);this._publishEvent("user_interaction",t),this._logger.debug("User interaction reported",t)}catch(e){this._handleError(e,"reportUserInteraction","user_interaction_error")}}reportUserPreference(e){try{this._validator.validateEventData("user_preference",e);let t=this._createEventData(e);this._publishEvent("user_preference",t),this._logger.debug("User preference reported",t)}catch(e){this._handleError(e,"reportUserPreference","user_preference_error")}}reportUserFeedback(e){try{this._validator.validateEventData("user_feedback",e);let t=this._createEventData(e);this._publishEvent("user_feedback",t),this._logger.debug("User feedback reported",t)}catch(e){this._handleError(e,"reportUserFeedback","user_feedback_error")}}
2reportUserClick(e){try{this._validator.validateEventData("user_click",e);let t=this._createEventData(e);this._publishEvent("user_click",t),this._logger.debug("User click reported",t)}catch(e){throw this._handleError(e,"reportUserClick","user_click_error"),e}}reportUserScroll(e){try{this._validator.validateEventData("user_scroll",e);let t=this._createEventData(e);this._publishEvent("user_scroll",t),this._logger.debug("User scroll reported",t)}catch(e){throw this._handleError(e,"reportUserScroll","user_scroll_error"),e}}}class ec extends I{constructor(e){super(e)}reportVideoShared(e){try{if(!e||"object"!=typeof e)throw Error("data must be an object");if(!e.assetId||"string"!=typeof e.assetId)throw Error("data.assetId must be a string");let t=this._createEventData({type:S,...e,timestamp:Date.now()});this._validator.validateEventData(S,t),this._publishEvent(S,t),this._logger.debug("Video shared reported",t)}catch(e){this._handleError(e,"reportVideoShared","video_engagement_error")}}reportVideoBookmarked(e){try{this._validator.validateEventData(g,e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent(g,t),this._logger.debug("Video bookmarked reported",t)}catch(e){this._handleError(e,"reportVideoBookmarked","video_engagement_error")}}reportVideoLiked(e){try{this._validator.validateEventData(T,e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent(T,t),this._logger.debug("Video liked reported",t)}catch(e){this._handleError(e,"reportVideoLiked","video_engagement_error")}}reportVideoComment(e){try{this._validator.validateEventData(b,e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent(b,t),this._logger.debug("Video comment reported",t)}catch(e){this._handleError(e,"reportVideoComment","video_engagement_error")}}reportVideoRating(e){try{this._validator.validateEventData(y,e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent(y,t),this._logger.debug("Video rating reported",t)}catch(e){this._handleError(e,"reportVideoRating","video_engagement_error")}}reportVideoQualityChange(e){try{this._validator.validateEventData(D,e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent(D,t),this._logger.debug("Video quality change reported",t)}catch(e){this._handleError(e,"reportVideoQualityChange","video_engagement_error")}}reportVideoPlaybackSpeedChange(e){try{this._validator.validateEventData(R,e);let t=this._createEventData({...e,timestamp:Date.now()});this._publishEvent(R,t),this._logger.debug("Video playback speed change reported",t)}catch(e){this._handleError(e,"reportVideoPlaybackSpeedChange","video_engagement_error")}}reportCustomEngagement(e,t){try{this._validator.validateEventData(e,t);let i=this._createEventData(t);this._publishEvent(e,i),this._logger.debug(`Custom video engagement reported: ${e}`,i)}catch(e){this._handleError(e,"reportCustomEngagement","video_engagement_error")}}}class e_{constructor(){this._version="1.0.0",this._isInitialized=!1,this._initializationInProgress=!1,this._registrationRetryCount=2,this._config=null,this._stateManager=null,this._eventQueue=null,this._eventPublisher=null,this._errorHandler=null,this._logger=null,this._validator=null,this._videoTracker=null,this._screenTracker=null,this._appTracker=null,this._userTracker=null,this._autoCollection=null,this._subscriptionTracker=null,this._paymentTracker=null,this._adTracker=null,this._experimentTracker=null,this._userAuthTracker=null,this._featureUsageTracker=null,this._userInteractionTracker=null,this._videoEngagementTracker=null,this._userInfoTracker=null}async initialize(e,t,a,d,l={},h={}){try{if(console.log("[SDK INIT] initialize called with sdkConfig:",h),console.log("[SDK INIT] _isInitialized:",this._isInitialized),console.log("[SDK INIT] _initializationInProgress:",this._initializationInProgress),this._isInitialized)return console.log("[SDK INIT] SDK already initialized - skipping"),void this._logger?.warn("SDK already initialized");if(this._initializationInProgress)return console.log("[SDK INIT] SDK initialization in progress - skipping"),void this._logger?.warn("SDK initialization in progress");
2this._validateInitParams(e,t,a,d),this._initializationInProgress=!0,this._config=new i({customerId:e,appId:t,appName:a,appVersion:d,...h});try{console.log("[SDK DEBUG] Config instance created. typeof setServerTimeOffset:",typeof this._config?.setServerTimeOffset),console.log("[SDK DEBUG] Config prototype methods:",Object.getOwnPropertyNames(Object.getPrototypeOf(this._config)).filter(e=>"function"==typeof this._config[e])),console.log("[SDK DEBUG] Config trace:",{sourceTag:this._config.__configSourceTag,hasTimestampSync:this._config.__hasTimestampSync})}catch(e){}this._stateManager=new r,this._eventQueue=new s(this._config),!1===h.autoCollect&&(console.log("[SDK INIT] Clearing stored events for e2e testing"),this._eventQueue.clear()),this._eventPublisher=new n(this._eventQueue,this._config),this._errorHandler=new o(this._config),this._logger=new u(this._config),this._validator=new f(this._config);let c={customerId:e,appId:t,appName:a,appVersion:d,sdkVersion:this._config.sdkVersion,sessionId:this._config.sessionId,screenRes:this._getScreenResolution(),timestamp:Date.now(),custId:e,subscriberId:l.subscriberId||"",subscriberType:l.subscriberType||"",subscriberTag:l.subscriberTag||"",clientInfo:{appName:a,appVersion:d,scrnRes:this._getScreenResolution(),ua:this._config.get("userAgent")||""},userInfo:{profileId:l.profileId||"",userData:l.userData||{},referralId:l.referralId||"",referralData:l.referralData||{}},customTags:l.customTags||{}};this._eventPublisher.updateCurrentPayload(c);let _={config:this._config,eventPublisher:this._eventPublisher,logger:this._logger,validator:this._validator,errorHandler:this._errorHandler,stateManager:this._stateManager};this._videoTracker=new v(_),this._screenTracker=new E(_),this._appTracker=new et(_),this._userTracker=new ei(_),this._userInfoTracker=new er(this),this._userInteractionTracker=new eh(_),this._videoEngagementTracker=new ec(_),this._autoCollection=new ea({config:this._config,eventPublisher:this._eventPublisher,logger:this._logger,validator:this._validator,errorHandler:this._errorHandler,stateManager:this._stateManager}),this._autoCollection.setEnabled(h.autoCollect??!0),this._subscriptionTracker=new es(_),this._paymentTracker=new en(_),this._adTracker=new eo(_),this._experimentTracker=new ed(_),this._userAuthTracker=new el(_),this._featureUsageTracker=new eu(_);try{let t=await this._registerWithBackend(e);t.timestamp&&"number"==typeof t.timestamp&&(console.log("[SDK DEBUG] About to set server time offset. typeof setServerTimeOffset:",typeof this._config?.setServerTimeOffset),console.log("[SDK DEBUG] Config trace before set:",{sourceTag:this._config.__configSourceTag,hasTimestampSync:this._config.__hasTimestampSync}),this._config.setServerTimeOffset(t.timestamp),console.log(`[SDK] Server time offset set: ${this._config.getServerTimeOffset()}ms`)),this._eventPublisher.setProducerURL(t.producerURL||"https://streamproducer-lcrr.mediamelon.com"),this._eventPublisher.setStatsInterval(t.statsInterval)}catch(i){if(console.warn("Backend registration failed, continuing with default settings:",i.message),this._eventPublisher.setProducerURL("https://streamproducer-lcrr.mediamelon.com"),this._eventPublisher.setStatsInterval(30),this._registrationRetryCount>0&&!i.message.includes("422"))return this._registrationRetryCount--,this._initializationInProgress=!1,void await this.initialize(e,t,a,d,l,h)}this._isInitialized=!0,this._initializationInProgress=!1,this._logger.debug("SDK initialized successfully");let p=h.autoCollect??!0;if(console.log("[SDK DEBUG] autoCollect setting:",p),console.log("[SDK DEBUG] sdkConfig:",h),console.log("[SDK DEBUG] About to check autoCollect condition..."),p){console.log("[SDK DEBUG] autoCollect is TRUE - will send initial events");let i=[];i.push({type:"APP_STATE",data:{type:"APP_STATE",customerId:e,appId:t,appName:a,appVersion:d,state:"foreground",timestamp:Date.now(),sessionId:this._config.sessionId,sdkVersion:this._config.sdkVersion,screenRes:this._getScreenResolution(),custId:e,subscriberId:l.subscriberId||"",subscriberType:l.subscriberType||"",subscriberTag:l.subscriberTag||"",clientInfo:{appName:a,appVersion:d,scrnRes:this._getScreenResolution(),ua:this._config.get("userAgent")||""},userInfo:{profileId:l.profileId||"",userData:l.userData||{},referralId:l.referralId||"",referralData:l.referralData||{}},customTags:l.customTags||{}}}),l&&Object.keys(l).length>0&&i.push({type:"USER_IDENTIFICATION",data:{type:"USER_IDENTIFICATION",customerId:e,appId:t,appName:a,appVersion:d,timestamp:Date.now(),sessionId:this._config.sessionId,sdkVersion:this._config.sdkVersion,screenRes:this._getScreenResolution(),custId:e,subscriberId:l.subscriberId||"",subscriberType:l.subscriberType||"",subscriberTag:l.subscriberTag||"",clientInfo:{appName:a,appVersion:d,scrnRes:this._getScreenResolution(),ua:this._config.get("userAgent")||""},userInfo:{profileId:l.profileId||"",userData:l.userData||{},referralId:l.referralId||"",referralData:l.referralData||{}},customTags:l.customTags||{}}}),i.push({type:"SESSION_START",data:{type:"SESSION_START",customerId:e,appId:t,appName:a,appVersion:d,timestamp:Date.now(),sessionId:this._config.sessionId,sdkVersion:this._config.sdkVersion,screenRes:this._getScreenResolution(),custId:e,subscriberId:l.subscriberId||"",subscriberType:l.subscriberType||"",subscriberTag:l.subscriberTag||"",clientInfo:{appName:a,appVersion:d,scrnRes:this._getScreenResolution(),ua:this._config.get("userAgent")||""},userInfo:{profileId:l.profileId||"",userData:l.userData||{},referralId:l.referralId||"",referralData:l.referralData||{}},customTags:l.customTags||{}}}
2),console.log("[SDK INIT] User agent in config:",this._config.get("userAgent")),console.log("[SDK INIT] Sending initial events:",i.map(e=>e.type)),i.forEach(e=>{console.log("[SDK INIT] Publishing event:",e.type),this._eventPublisher.publishEvent(e.type,e.data)})}else console.log("[SDK DEBUG] autoCollect is FALSE - skipping initial events"),console.log("[SDK INIT] Auto-collection disabled - skipping initial events")}catch(e){throw this._initializationInProgress=!1,this._handleError(e,"initialize"),e}}isInitialized(){return!0===this._isInitialized}getSynchronizedTimestamp(){return this._isInitialized&&this._config?this._config.getSynchronizedTimestamp():Date.now()}isTimeSynchronized(){return!(!this._isInitialized||!this._config)&&this._config.isTimeSynchronized()}getServerTimeOffset(){return this._isInitialized&&this._config?this._config.getServerTimeOffset():0}destroy(){if(this._isInitialized)try{this._autoCollection&&this._autoCollection._enabled&&this._sendEvent("SESSION_END",{timestamp:Date.now(),sessionId:this._config?.sessionId,isGraceful:!0}),this._sendEvent("SDK_SHUTDOWN",{timestamp:Date.now()}),this._eventQueue&&this._eventQueue.destroy(),this._stateManager&&this._stateManager.clearStates(),this._logger&&this._logger.info("SDK destroyed"),this._isInitialized=!1,this._config=null,this._stateManager=null,this._eventQueue=null,this._errorHandler=null,this._logger=null,this._validator=null}catch(e){this._logger?this._logger.error("Error during SDK destruction:",e):console.error("Error during SDK destruction:",e)}}reportVideoState(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid video state data");this._videoTracker.reportVideoState(e)}catch(e){throw this._handleError(e,"reportVideoState"),e}}reportScreenView(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid screen view data");this._screenTracker.reportScreenView(e)}catch(e){throw this._handleError(e,"reportScreenView"),e}}reportAppState(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid app state data");this._appTracker.reportAppState(e)}catch(e){throw this._handleError(e,"reportAppState"),e}}reportAppError(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid error data");this._appTracker.reportAppError(e)}catch(e){throw this._handleError(e,"reportAppError"),e}}reportUserInfo(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid user info data");this._validator.validateEventData("USER_INFO",e),this._logger&&this._logger.setUserId(e.userId),this._sendEvent("USER_INFO",e)}catch(e){throw this._handleError(e,"reportUserInfo"),e}}reportEvent(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid event data");this._sendEvent(e.type||"custom",e)}catch(e){throw this._handleError(e,"reportEvent"),e}}getStatus(){return{version:this._version,isInitialized:this._isInitialized,config:this._config?.getConfig(),eventQueue:this._eventQueue?.getStatus()}}onError(e,t){this._validateInitialization(),this._errorHandler.onError(e,t)}getErrorHistory(){return this._validateInitialization(),this._errorHandler.getErrorHistory()}clearErrorHistory(){this._validateInitialization(),this._errorHandler.clearErrorHistory()}setLogLevel(e){this._validateInitialization(),this._logger.setLogLevel(e)}setLoggingEnabled(e){this._validateInitialization(),this._logger.setEnabled(e)}onLog(e,t){this._validateInitialization(),this._logger.onLog(e,t)}getLogHistory(){return this._validateInitialization(),this._logger.getLogHistory()}clearLogHistory(){this._validateInitialization(),this._logger.clearLogHistory()}getPerformanceMetrics(){return this._validateInitialization(),{eventQueue:this._eventQueue?this._eventQueue.getStatus():{queueLength:0,successfulEvents:0,failedEvents:0,processingTime:0},timestamp:Date.now()}}getSessionInfo(){return this._autoCollection.getSessionInfo()}getNavigationInfo(){return this._autoCollection.getNavigationInfo()}setAutoCollectionEnabled(e){this._autoCollection.setEnabled(e),this._logger.debug("Auto-collection "+(e?"enabled":"disabled"))}isAutoCollectionEnabled(){return!!this._autoCollection&&this._autoCollection._enabled}_validateInitialization(){if(!this._isInitialized)throw Error("SDK not initialized")}_generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}
2async _registerWithBackend(e){let t=`https://register.mediamelon.com/mm-apis/register/${e}?platform=Browser&component=HTML5JSSDK`;return new Promise((e,i)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.onload=function(){if(r.status>=200&&r.status<300)try{let t=JSON.parse(r.responseText);t.timestamp&&"number"==typeof t.timestamp&&(console.log(`[SDK] Server timestamp received: ${t.timestamp}`),console.log(`[SDK] Local timestamp: ${Date.now()}`)),e(t)}catch(e){i(Error("Invalid registration response"))}else i(Error(`Registration failed with status: ${r.status}`))},r.onerror=function(){i(Error("Registration request failed"))},r.send()})}_sendEvent(e,t){if(!this._eventQueue)throw Error("Event queue not initialized");this._eventPublisher.publishEvent(e,t)}_handleError(e,t,i={}){this._logger&&this._logger.error(`Error in ${t}:`,e),this._errorHandler&&this._errorHandler.handleError(e,t,i),this._eventQueue&&this._isInitialized&&this._sendEvent("SDK_ERROR",{context:t,error:{name:e.name,message:e.message,stack:e.stack},metadata:i})}_validateInitParams(e,t,i,r){if(!e||"string"!=typeof e)throw Error("Invalid customer ID");if(!t||"string"!=typeof t)throw Error("Invalid application ID");if(!i||"string"!=typeof i)throw Error("Invalid application name");if(!r||"string"!=typeof r)throw Error("Invalid application version")}reportVideoStart(e){this._validateInitialization();try{if(console.log("MMAppAnalyticsSDK.reportVideoStart received:",JSON.stringify(e)),!e||"object"!=typeof e)throw Error("Invalid video start data");this._videoTracker.reportVideoStart(e)}catch(e){throw this._handleError(e,"reportVideoStart"),e}}reportVideoPause(e){return this._videoTracker.reportVideoPause(e)}reportVideoResume(e){return this._videoTracker.reportVideoResume(e)}reportVideoSkip(e){return this._videoTracker.reportVideoSkip(e)}reportVideoStop(e){return this._videoTracker.reportVideoStop(e)}reportVideoEnd(e){return this._videoTracker.reportVideoEnd(e)}reportVideoQuality(e){return this._validateInitialization(),this._videoTracker.reportVideoQualityChange(e)}reportVideoQualityChange(e){return this._validateInitialization(),this._videoTracker.reportVideoQualityChange(e)}reportVideoBuffering(e){return this._videoTracker.reportVideoBuffering(e)}reportVideoSeek(e){return this._videoTracker.reportVideoSeek(e)}reportVideoFullscreen(e){return this._videoTracker.reportVideoFullscreen(e)}reportVideoExitFullscreen(e){return this._videoTracker.reportVideoExitFullscreen(e)}reportScreenExit(e){return this._screenTracker.reportScreenExit(e)}reportPerformanceMetrics(e){return this._appTracker.reportPerformanceMetrics(e)}reportUserIdentification(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid user identification data");this._userTracker.reportUserIdentification(e)}catch(e){throw this._handleError(e,"reportUserIdentification"),e}}reportUserSessionStart(e){return this._userTracker.reportUserSessionStart(e)}reportUserSessionEnd(e){return this._userTracker.reportUserSessionEnd(e)}reportUserPreferenceChange(e){return this._userTracker.reportUserPreferenceChange(e)}reportUserSignUp(e){this._validateInitialization();try{this._userAuthTracker.reportUserSignUp(e)}catch(e){throw this._handleError(e,"reportUserSignUp"),e}}reportUserSignIn(e){this._validateInitialization();try{this._userAuthTracker.reportUserSignIn(e)}catch(e){throw this._handleError(e,"reportUserSignIn"),e}}reportUserSignOut(e){this._validateInitialization();try{this._userAuthTracker.reportUserSignOut(e)}catch(e){throw this._handleError(e,"reportUserSignOut"),e}}getVideoState(){return this._videoTracker.getVideoState()}getScreenState(){return this._screenTracker.getScreenState()}getAppState(){return this._appTracker.getAppState()}getUserState(){return this._userTracker.getUserState()}reportSubscriptionStart(e){return this._subscriptionTracker.reportSubscriptionStart(e)}reportSubscriptionRenewal(e){return this._subscriptionTracker.reportSubscriptionRenewal(e)}reportSubscriptionCancellation(e){return this._subscriptionTracker.reportSubscriptionCancellation(e)}reportSubscriptionUpgrade(e){return this._subscriptionTracker.reportSubscriptionUpgrade(e)}reportSubscriptionDowngrade(e){return this._subscriptionTracker.reportSubscriptionDowngrade(e)}
2reportPaymentInitiation(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid payment initiation data");this._paymentTracker.reportPaymentInitiation(e)}catch(e){throw this._handleError(e,"reportPaymentInitiation"),e}}reportPaymentSuccess(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid payment success data");this._paymentTracker.reportPaymentSuccess(e)}catch(e){throw this._handleError(e,"reportPaymentSuccess"),e}}reportPaymentFailure(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid payment failure data");this._paymentTracker.reportPaymentFailure(e)}catch(e){throw this._handleError(e,"reportPaymentFailure"),e}}reportPaymentRefund(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid payment refund data");this._paymentTracker.reportPaymentRefund(e)}catch(e){throw this._handleError(e,"reportPaymentRefund"),e}}reportAdImpression(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid ad impression data");this._adTracker.reportAdImpression(e)}catch(e){throw this._handleError(e,"reportAdImpression"),e}}reportAdClick(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid ad click data");this._adTracker.reportAdClick(e)}catch(e){throw this._handleError(e,"reportAdClick"),e}}reportAdStart(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid ad start data");this._adTracker.reportAdStart(e)}catch(e){throw this._handleError(e,"reportAdStart"),e}}reportAdComplete(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid ad complete data");this._adTracker.reportAdComplete(e)}catch(e){throw this._handleError(e,"reportAdComplete"),e}}reportAdSkip(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid ad skip data");this._adTracker.reportAdSkip(e)}catch(e){throw this._handleError(e,"reportAdSkip"),e}}reportAdError(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid ad error data");this._adTracker.reportAdError(e)}catch(e){throw this._handleError(e,"reportAdError"),e}}getSubscriptionState(){return this._subscriptionTracker.getSubscriptionState()}getPaymentState(){return this._paymentTracker.getPaymentState()}getAdState(){return this._adTracker.getAdState()}reportExperimentExposure(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid experiment exposure data");this._experimentTracker.reportExperimentExposure(e)}catch(e){throw this._handleError(e,"reportExperimentExposure"),e}}reportExperimentActivation(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid experiment activation data");this._experimentTracker.reportExperimentActivation(e)}catch(e){throw this._handleError(e,"reportExperimentActivation"),e}}reportFeatureFlagEvaluation(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid feature flag evaluation data");this._experimentTracker.reportFeatureFlagEvaluation(e)}catch(e){throw this._handleError(e,"reportFeatureFlagEvaluation"),e}}reportExperimentResults(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid experiment results data");this._experimentTracker.reportExperimentResults(e)}catch(e){throw this._handleError(e,"reportExperimentResults"),e}}getExperimentState(e){return this._experimentTracker.getExperimentState(e)}getActiveExperiments(){return this._experimentTracker.getActiveExperiments()}reportUserProfileUpdate(e){this._validateInitialization();try{this._userTracker.reportUserProfileUpdate(e)}catch(e){throw this._handleError(e,"reportUserProfileUpdate"),e}}reportFeatureUsage(e){this._validateInitialization();try{this._featureUsageTracker.reportFeatureUsage(e)}catch(e){throw this._handleError(e,"reportFeatureUsage"),e}}reportSubscriptionViewed(e){this._subscriptionTracker.reportSubscriptionViewed(e)}reportSubscriberInfo(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid subscriber info data");if(!(e.subscriberId&&e.planType&&e.segment&&e.profileId))throw Error("Missing required fields: subscriberId, planType, segment, profileId");this._userInfoTracker.reportSubscriberInfo(e)}catch(e){throw this._handleError(e,"reportSubscriberInfo"),e}}
2reportReferralInfo(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid referral info data");if(!(e.referralId&&e.source&&e.medium&&e.campaign))throw Error("Missing required fields: referralId, source, medium, campaign");this._userInfoTracker.reportReferralInfo(e)}catch(e){throw this._handleError(e,"reportReferralInfo"),e}}reportUserClick(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid click metadata");this._userInteractionTracker.reportUserClick(e)}catch(e){throw this._handleError(e,"reportUserClick"),e}}reportUserScroll(e){this._validateInitialization();try{if(!e||"object"!=typeof e)throw Error("Invalid scroll metadata");this._userInteractionTracker.reportUserScroll(e)}catch(e){throw this._handleError(e,"reportUserScroll"),e}}reportVideoShared(e){return this._validateInitialization(),this._videoEngagementTracker.reportVideoShared(e)}reportVideoBookmarked(e){return this._validateInitialization(),this._videoEngagementTracker.reportVideoBookmarked(e)}reportVideoLiked(e){return this._validateInitialization(),this._videoEngagementTracker.reportVideoLiked(e)}reportVideoComment(e){return this._validateInitialization(),this._videoEngagementTracker.reportVideoComment(e)}reportVideoRating(e){return this._validateInitialization(),this._videoEngagementTracker.reportVideoRating(e)}reportVideoPlaybackSpeedChange(e){return this._validateInitialization(),this._videoEngagementTracker.reportVideoPlaybackSpeedChange(e)}_createEvent(e,t){return{type:e,data:t,timestamp:Date.now(),sessionId:this._config.getSessionId(),config:this._config.getConfig(),metadata:this._config.getEventMetadata()}}_initializeSession(){let e=this._config.getSessionId();return this._config.updateSessionId(e),e}_getScreenResolution(){return"u">typeof window&&window.screen?`${window.screen.width}x${window.screen.height}`:""}}let ep={version:"1.0.0",buildTime:(new Date).toISOString(),source:"src/sdk-entry.js"};try{"u">typeof window&&(window.__MM_SDK_BUILD_INFO__=ep,console.log("[SDK BUILD]",ep))}catch(e){}e.s(["ErrorHandler",()=>o,"EventPublisher",()=>n,"EventQueue",()=>s,"Logger",()=>u,"MMAppAnalyticsSDK",()=>e_,"MMAppAnalyticsSDKConfig",()=>i,"StateManager",()=>r,"Validator",()=>f,"__MM_BUILD_INFO__",()=>ep])},134152,(e,t,i)=>{"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t,i){var a;return(a=function(e,t){if("object"!=r(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=r(a))return a;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==r(a)?a:a+"")in e)?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(i,"__esModule",{value:!0}),i.SHAKAPlayerMMSSIntgr=void 0,function(){if("u">typeof document){var e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pako.min.js",document.head.appendChild(e)}}();var s,n,o,d,l=function(e,t,i,r,a,s,n,o){var d={};return d.trackIdx=void 0===e?-1:e,d.trackIdx=void 0===e?-1:e,d.bitrate=void 0===t?-1:t,d.sequence=void 0===i?-1:i,d.startTime=void 0===a?-1:a,d.startByte=void 0===n?-1:n,d.endByte=void 0===o?-1:o,d.duration=void 0===s?-1:s,d.initStartByte=-1,d.initEndByte=-1,d.resourceURL=r||null,d},u=function(e,t,i,r,a,s){var n={};return n.trackIdx=e||0,n.bitrate=t||0,n.width=i||0,n.height=r||0,n.codecIdentifier=a||{},n.segmentInfo=s||[],n},h=function(e,t,i,r){var a={};return 1===e&&(e=!0),a.isLive=e||!1,a.duration=t||-1,a.representationArray=i||[],a.contentType=r||"",a},c=Object.freeze({AD_BLOCKED:1,AD_IMPRESSION:2,AD_STARTED:3,AD_PLAYING:4,AD_CLICKED:5,AD_PAUSED:6,AD_RESUMED:7,AD_SKIPPED:8,AD_COMPLETED:9,AD_ERROR:10,AD_REQUEST:11,AD_PLAY:12,AD_BUFFERING:13,AD_MIDPOINT:14,AD_FIRST_QUARTILE:15,AD_THIRD_QUARTILE:16,AD_ENDED:17}),_=function(){return{adClient:void 0,adId:void 0,adDuration:0,adPosition:void 0,adIsLinear:!1,adCreativeType:void 0,adServer:void 0,adResolution:void 0,adPodIndex:void 0,adPositionInPod:void 0,adPodLength:void 0,isBumper:!1,adScheduledTime:-1,adCreativeId:void 0,adUrl:void 0,adTitle:void 0,adBitrate:void 0}},p=Object.freeze({PLAYING:1,PAUSED:2,STOPPED:3}),m=Object.freeze({SeekStarted:1,SeekCompleted:2,Playing:3}),f=Object.freeze({QBRModeDisabled:"QBRDisabled",QBRModeQuality:"QBRQuality",QBRModeBitsave:"QBRBitsave",QBRModeCostsave:"QBRCostsave"}),I=(Object.freeze({Cellular:"Cellular",Cellular_2G:"Cellular_2G",Cellular_3G:"Cellular_3G",Cellular_4G:"Cellular_4G",Cellular_LTE:"Cellular_LTE",Cellular_5G:"Cellular_5G",NotReachable:"WebNotReachable",Wifi:"Wifi",WiredNetwork:"WiredNetwork"}),a(a(a(a(a(a(a(a(a(a(d={timestamp:"t",pbTime:"pt",playDur:"pd",interval:"i",version:"v",qubitData:"qd",streamID:"sd",custId:"ci",dataSrc:"dsr",playerName:"pn",sessionId:"si",domainName:"dn",streamURL:"su",playerVersion:"pv",pb:"pb",pm:"pm",experimentName:"exn",subPropertyId:"spi",viewSessionId:"vsi",appSessionId:"asi",basePlayerName:"bpn",basePlayerVersion:"bpv",subscriberId:"sbi",subscriberType:"sbt",subscriberTag:"sg",assetId:"ai",assetName:"an",videoId:"vi",mode:"m",isLive:"il",pId:"pi",sst:"sst",sourceType:"sct",parentCustId:"pci",streamMode:"sm",mediaType:"mt",sourceHostName:"shn",streamInfo:"sif",totalDuration:"td",maxRes:"xr",minRes:"nr",maxFps:"xf",minFps:"nf",numOfProfile:"np",streamFormat:"sf",videoTrack:"vk",subtitleTrack:"sk",audioTrack:"ak",isVDSActive:"iv",isSubtitleActive:"is",contentMetadata:"cm",contentType:"ct",drmProtection:"dp",episodeNumber:"en",genre:"g",season:"se",seriesTitle:"st",videoType:"vt",segInfo:"sgi",res:"r",cbrBitrate:"cb",vCodec:"vc",aCodec:"ac",downloadRate:"dr",qbrBitrate:"qb",qbrQual:"qq",cbrQual:"cq",dur:"du",fps:"f",seqNum:"sn",startTime:"s",profileNum:"pfn",lastTS:"lts",cbrSize:"cz",qbrSize:"qz",cbrProfileNum:"cp",bufferLength:"bl",pbEventInfo:"pe",event:"e",desc:"dsc",id:"id",playbackStatus:"ps",pbInfo:"pif",bwInUse:"bu",progressMark:"gm",latency:"l",buffWait:"bw",buffWaitType:"bwt",sumBuffWait:"sb",sumBuffWaitCIRR:"sbc",sumBuffWaitVRT:"sbv",sumBuffWaitAAD:"sba",frameloss:"fl",upShiftCount:"us",downShiftCount:"ds",pauseDuration:"ud",seekDuration:"sd",bitrate:"b",prevBitrate:"pb",resWidth:"rw",resHeight:"rh",prevResWidth:"prw",prevResHeight:"prh",sdkInfo:"sdi",sdkVersion:"sv",hFileVersion:"hv",sdkType:"skt",clientInfo:"cif",appName:"apn",appVersion:"apv",deviceMarketingName:"dm",scrnRes:"sr",deviceId:"di",deviceCapabilities:"dc",cdn:"c",o
2perator:"op",nwType:"nt",wifissid:"ws",wifidatarate:"wd",signalstrength:"ss",platform:"p",location:"l",device:"d",brand:"br",model:"ml",videoQuality:"vq",userAgent:"ua",browserVersion:"bv",browser:"b"},"version","v"),"clientIP","cip"),"playerRes","pr"),"asn","asn"),"adInfo","aif"),"adId","id"),"adClient","cl"),"adCreative","c"),"adCreativeId","cid"),"adCreativeType","ct"),a(a(a(a(a(a(a(a(a(a(d,"adDuration","d"),"adInterval","i"),"adPosition","p"),"adLinear","al"),"adSystem","s"),"adPodIndex","pi"),"adPodPosition","pp"),"adPodLength","pl"),"adResolution","r"),"adBitrate","b"),a(a(a(a(a(a(a(a(a(a(d,"adTitle","t"),"adUrl","u"),"isBumper","ib"),"appEventInfo","aei"),"eventName","en"),"eventType","et"),"eventData","ed"),"currentScreen","cs"),"isGraceFul","ig"),"userInfo","ui"),a(a(a(a(a(a(a(a(d,"profileId","pid"),"userType","tp"),"userTag","tg"),"userData","d"),"referralId","rid"),"referralData","rd"),"diagnostics","di"),"customTags","ctg")),v=Object.freeze({Latency:"Latency",DurationWatched:"DurationWatched",streamURL:"streamURL",drmType:"drmType"}),E=Object.freeze({CDN:"CDN"}),S={sdkVersion:"JSSDKv4.7.0_",hintFileVersion:"2.0.0",EP_SCHEMA_VERSION:"2.0.0",platform:"Browser",qmetric:!0,statistics:!1,log_level:2},g=function(e){var t=function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},i=function(e,i,r,a,s,n){var o;return t((o=t(t(i,e),t(a,n)))<<s|o>>>32-s,r)},r=function(e,t,r,a,s,n,o){return i(t&r|~t&a,e,t,s,n,o)},a=function(e,t,r,a,s,n,o){return i(t&a|r&~a,e,t,s,n,o)},s=function(e,t,r,a,s,n,o){return i(t^r^a,e,t,s,n,o)},n=function(e,t,r,a,s,n,o){return i(r^(t|~a),e,t,s,n,o)},o=function(e){var i;return function(e){var t,i="",r=32*e.length;for(t=0;t<r;t+=8)i+=String.fromCharCode(e[t>>5]>>>t%32&255);return i}(function(e,i){e[i>>5]|=128<<i%32,e[14+(i+64>>>9<<4)]=i;var o,d,l,u,h,c=0x67452301,_=-0x10325477,p=-0x67452302,m=0x10325476;for(o=0;o<e.length;o+=16)d=c,l=_,u=p,h=m,c=r(c,_,p,m,e[o],7,-0x28955b88),m=r(m,c,_,p,e[o+1],12,-0x173848aa),p=r(p,m,c,_,e[o+2],17,0x242070db),_=r(_,p,m,c,e[o+3],22,-0x3e423112),c=r(c,_,p,m,e[o+4],7,-0xa83f051),m=r(m,c,_,p,e[o+5],12,0x4787c62a),p=r(p,m,c,_,e[o+6],17,-0x57cfb9ed),_=r(_,p,m,c,e[o+7],22,-0x2b96aff),c=r(c,_,p,m,e[o+8],7,0x698098d8),m=r(m,c,_,p,e[o+9],12,-0x74bb0851),p=r(p,m,c,_,e[o+10],17,-42063),_=r(_,p,m,c,e[o+11],22,-0x76a32842),c=r(c,_,p,m,e[o+12],7,0x6b901122),m=r(m,c,_,p,e[o+13],12,-0x2678e6d),p=r(p,m,c,_,e[o+14],17,-0x5986bc72),_=r(_,p,m,c,e[o+15],22,0x49b40821),c=a(c,_,p,m,e[o+1],5,-0x9e1da9e),m=a(m,c,_,p,e[o+6],9,-0x3fbf4cc0),p=a(p,m,c,_,e[o+11],14,0x265e5a51),_=a(_,p,m,c,e[o],20,-0x16493856),c=a(c,_,p,m,e[o+5],5,-0x29d0efa3),m=a(m,c,_,p,e[o+10],9,0x2441453),p=a(p,m,c,_,e[o+15],14,-0x275e197f),_=a(_,p,m,c,e[o+4],20,-0x182c0438),c=a(c,_,p,m,e[o+9],5,0x21e1cde6),m=a(m,c,_,p,e[o+14],9,-0x3cc8f82a),p=a(p,m,c,_,e[o+3],14,-0xb2af279),_=a(_,p,m,c,e[o+8],20,0x455a14ed),c=a(c,_,p,m,e[o+13],5,-0x561c16fb),m=a(m,c,_,p,e[o+2],9,-0x3105c08),p=a(p,m,c,_,e[o+7],14,0x676f02d9),_=a(_,p,m,c,e[o+12],20,-0x72d5b376),c=s(c,_,p,m,e[o+5],4,-378558),m=s(m,c,_,p,e[o+8],11,-0x788e097f),p=s(p,m,c,_,e[o+11],16,0x6d9d6122),_=s(_,p,m,c,e[o+14],23,-0x21ac7f4),c=s(c,_,p,m,e[o+1],4,-0x5b4115bc),m=s(m,c,_,p,e[o+4],11,0x4bdecfa9),p=s(p,m,c,_,e[o+7],16,-0x944b4a0),_=s(_,p,m,c,e[o+10],23,-0x41404390),c=s(c,_,p,m,e[o+13],4,0x289b7ec6),m=s(m,c,_,p,e[o],11,-0x155ed806),p=s(p,m,c,_,e[o+3],16,-0x2b10cf7b),_=s(_,p,m,c,e[o+6],23,0x4881d05),c=s(c,_,p,m,e[o+9],4,-0x262b2fc7),m=s(m,c,_,p,e[o+12],11,-0x1924661b),p=s(p,m,c,_,e[o+15],16,0x1fa27cf8),_=s(_,p,m,c,e[o+2],23,-0x3b53a99b),c=n(c,_,p,m,e[o],6,-0xbd6ddbc),m=n(m,c,_,p,e[o+7],10,0x432aff97),p=n(p,m,c,_,e[o+14],15,-0x546bdc59),_=n(_,p,m,c,e[o+5],21,-0x36c5fc7),c=n(c,_,p,m,e[o+12],6,0x655b59c3),m=n(m,c,_,p,e[o+3],10,-0x70f3336e),p=n(p,m,c,_,e[o+10],15,-1051523),_=n(_,p,m,c,e[o+1],21,-0x7a7ba22f),c=n(c,_,p,m,e[o+8],6,0x6fa87e4f),m=n(m,c,_,p,e[o+15],10,-0x1d31920),p=n(p,m,c,_,e[o+6],15,-0x5cfebcec),_=n(_,p,m,c,e[o+13],21,0x4e0811a1),c=n(c,_,p,m,e[o+4],6,-0x8ac817e),m=n(m,c,_,p,e[o+11],10,-0x42c50dcb),p=n(p,m,c,_,e[o+2],15,0x2ad7d2bb),_=n(_,p,m,c,e[o+9],21,-0x14792c6f),c=t(c,d),_=t(_,l),p=t(p,u),m=t(m,h);return[c,_,p,m]}(function(e){var t,i=[];for(i[(e.length>>2)-1]=void 0,t=0;t<i.length;t+=1)i[t]=0;var r=8*e.length;for(t=0;t<r;t+=8)i[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return i}(i=unescape(encodeURIComponent(e))),8*i.length))},d=function(e){return function(e){var t,i,r="0123456789abcdef",a="";for(i=0;i<e.length;i+=1)a+=r.charAt((t=e.charCodeAt(i))>>>4&15)+r.charAt(15&t);return a}(o(e))};return{mm_md5:function(e){return d(e)},hexMD5:d,rawMD5:o}};function T(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function b(e){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var y={_adClient:void 0,_adId:void 0,_adPosition:void 0,_adDuration:void 0,_adResolution:void 0,_adLinear:void 0,_adCreativeType:void 0,_adServer:void 0,_prevAdState:void 0,_playSent:!1,_adCreativeId:void 0,_adTitle:void 0,_adBitrate:void 0,_adUrl:void 0,_adPlaybackStartWallClockTime:0,_adplaydur:0,_adPlaybackTime:0,_adLastPlayingEventTimeStamp:-1,_adLastAdEventTimeStamp:-1,_isBumper:!1,_adPodIndex:-2,_adPodLength:-1,_adPositionInPod:-1,_adScheduledTime:-1},D=Object.freeze({IDLE:0,INITIALIZED:1,ONLOAD_SENT:2,STARTED:3,STOPPED:4,ERROR:5}),R=function(){var e,t,i,s,n,o,d,l,u,h,_,R,P,C,O;return a(a(a(a(a(a(a(a(a(a(e={_httpUtil:void 0,_playerName:void 0,_customerID:void 0,_subscriberID:void 0,_hashSubscriberID:!1,_assetID:void 0,_assetName:void 0,_videoId:void 0,_contentMetadata:void 0,_domainName:void 0,_component:void 0,_inProgress:!1,_simulatedEndedSent:!1,_mode:null,_modeFromResponse:null,_timerObj:null,_timerObj2:null,_timerTimestampSynchro:null,_regStatus:"",_enableVideoQoE:!0,_enableAdQoE:!0,_sdkVersion:"",_hintFileVersion:"",_playDur:0,_latencyStartTime:0,_enableEP:!1,_KAdKeepAliveInterval:5e3,_adInformation:Object.create(y),_flagStartLatencyViaPlayer:!1,_statsMetric:{version:"1.0.0",qubitData:[]},_recordIndex:0,_upshiftCount:0,_downshiftCount:0,_pbTime:0,_progressMark:0,_totalDuration:0,_buffWait:0,_sumBuffWait:0,_sumBuffWaitCIRR:0,_buffWaitType:"",_sumBuffWaitVRT:0,_sumBuffWaitAAD:0,_prevPlayerState:0,_isVideoPaused:!1,_seekState:void 0,_EPState:0,_pauseStartTime:0,_pauseDuration:0,_initLatency:0,_adPlaybackTime:0,_bufferLength:0,_downloadRate:0,_downloadRateCount:0,_avgDownloadRate:0,_networkType:"",adClient:"",adURL:"",adDuration:0,adPosition:0,adLinear:!1,_adServer:"",_adCreativeMime:"",_wifiDataRate:0,frameLoss:0,_wifiSignalStrenth:0,_wifiSSID:"",_presentationWidth:0,_presentationHeight:0,_videoQuality:"",_experimentName:void 0,_subPropertyId:void 0,_viewSessionId:void 0,_basePlayerName:void 0,_basePlayerVersion:void 0,_deviceCapabilities:void 0,_deviceID:void 0,_playbackStatus:void 0,_bufferStartTime:0,_adBufferStartTime:0,_seekStartTime:0,_seekDuration:0},"_bufferStartTime",0),"_isBufferingState",!1),"_streamFormat",void 0),"_mediaType",void 0),"_sourceType",void 0),"prevBitrate",0),"newBitrate",0),"_playerBrand",""),"_playerModel",""),"_playerVersion",""),a(a(a(a(a(a(a(a(a(a(e,"_appName",""),"_playerRes",""),"_appVersion",""),"_deviceType",""),"_deviceBrand",""),"_deviceModel",""),"_deviceOs",""),"_deviceOsVersion",""),"_deviceOperator",""),"_deviceMarketingName",""),a(a(a(a(a(a(a(a(a(a(e,"_timeShift",0),"_timeDeltaInMs",0),"_isFirstBatch",!0),"_eventToSend",[]),"_SESEventToSend",[]),"deviceIdStarz",""),"_statsToSend",[]),"_epocTime",0),"_setState",!1),"_qoeMetric",{}),a(a(a(a(a(a(a(a(a(a(e,"_bwExtSet",!1),"_prevSegInfo",{}),"_segINfoStatus",!1),"_prevAudioTrack","NA"),"_prevSubtitleTrack","OFF"),"_cfVal",0),"_maxSteps",0),"_maxStepUp",0),"_maxStepDown",0),"_maxEventsInQ",40),a(a(a(a(a(a(a(a(a(a(e,"_eventCount",0),"_onLoadSentAtTS",0),"_lastStatsPostedAtTS",0),"_statsMonitorStartedAtTS",0),"_bufferingCount",0),"_subscriberType",void 0),"_subscriberTag",void 0),"_adLoadTime",0),"_adStartEpocTime",0),"_adBuffWaitForInterval",0),a(a(a(a(a(a(a(a(a(a(e,"_adSumBuffWait",0),"_adSumBuffWaitCIRR",0),"_adSumBuffWaitVRT",0),"_adPauseStartTime",0),"_adPauseDuration",0),"_adPauseDurationToOffsetFromInterval",0),"_adLoadStartTime",0),"_segRepeatationCount",0),"_httpPostTimeout",9e4),"sessionId",""),a(a(a(a(a(a(a(a(a(a(e,"_eventMetric",{version:"1.0.0",qubitData:[]}),"attributes",{UPSHIFTCOUNT:"upShiftCount",DOWNSHIFTCOUNT:"downShiftCount",SDKBOOTTIME:"sdkBootuptime",STREAMFORMAT:"streamFormat",MEDIATYPE:"mediaType",SOURCETYPE:"sourceType",SDKVERSION:"sdkVersion",HFILEVERSION:"hFileVersion",ISLIVE:"isLive",DATASOURCE:"dataSrc",CUSTID:"custId",SESSIONID:"sessionId",SST:"sst",CDN:"cdn",ASN:"asn",HOSTNAME:"sourceHostName",PBTIME:"pbTime",OPERATOR:"operator",NETWORKTYPE:"nwType",WIFISSID:"wifissid",WIFIDATERATE:"wifidatarate",SIGNALSTRENGTH:"signalstrength",PLATFORM:"platform",LOCATION:"location",SCREENRES:"scrnRes",BANDWIDTH:"bwInUse",LATENCY:"latency",BUFFERING:"buffWait",BUFFERINGTYPE:"buffWaitType",SUMBUFFERING:"sumBuffWait",SUMBUFFERINGCIRR:"sumBuffWaitCIRR",SUMBUFFERINGVRT:"sumBuffWaitVRT",SUMBUFFERINGAAD:"sumBuffWaitAAD",SEEKDURATION:"seekDuration",PLAYDUR:"playDur",FRAMELOSS:"frameloss",ASSETID:"assetId",ASSETNAME:"assetName",VIDEOID:"videoId",STREAMURL:"streamURL",PLAYERVERSION:"playerVersion",PLAYERBRAND:"pb",PLAYERMODEL:"pm",MINRES:"minRes",MAXRES:"maxRes",MAXFPS:"maxFps",MINFPS:"minFps",NUMPROFILE:"numOfProfile",TOTALDURATION:"totalDuration",RESOLUTION:"res",QBRBITRATE:"qbrBitrate",CBRBITRATE:"cbrBitrate",QBRQUALITY:"qbrQual",CBRQUALITY:"cbrQual",DURATION:"dur",FPS:"fps",SEQNUM:"seqNum",STARTTIME:"startTime",PROFILENUM:"profileNum",LASTTS:"lastTS",CBRSIZE:"cbrSize",QBRSIZE:"qbrSize",PAUSEDURATION:"pauseDuration",SUBSCRIBERID:"subscriberId",DOMAINNAME:"domainName",PLAYERNAME:"playerName",QBRSDKMODE:"mode",DEVICETYPE:"device",DEVICEBRAND:"brand",DEVICEMODEL:"model",DEVICEMARKETINGNAME:"deviceMarketingName",OSVERSION:"version",SUBSCRIBERTYPE:"subscriberType",SUBSCRIBERTAG:"subscriberTag",CONTENTTYPE:"contentType",DRMPROTECTION:"drmProtection",EPISODENUMBER:"episodeNumber",GENRE:"genre",SEASON:"season",SERIESTITLE:"seriesTitle",VIDEOTYPE:"videoType",VIDEOTRACK:"videoTrack",SUBTITLETRACK:"subtitleTrack",AUDIOTRACK:"audioTrack",ISVDSACTIVE:"isVDSActive",ISSUBTITLEACTIVE:"isSubtitleActive",PROGRESSMARK:"progressMark",APPNAME:"appName",PLAYERRES:"playerRes",APPVERSION:"appVersion",VIDEOQUALITY:"videoQuality",DEVICECAPABILITIES:"deviceCapabilities",DEVICEID:"deviceId",PLAYBACKSTATUS:"playbackStatus",EXPERIMENTNAME:"experimentName",
2SUBPROPERTYID:"subPropertyId",VIEWSESSIONID:"viewSessionId",APPSESSIONID:"appSessionId",BASEPLAYERNAME:"basePlayerName",BASEPLAYERVERSION:"basePlayerVersion",BITRATE:"bitrate",PREV_BITRATE:"prevBitrate",RES_WIDTH:"resWidth",RES_HEIGHT:"resHeight",PREV_RES_WIDTH:"prevResWidth",PREV_RES_HEIGHT:"prevResHeight"}),"_producerURL",void 0),"_secondaryProducerList",[]),"_producerURLSES",void 0),"sesRequirements",void 0),"profiledIdSES",void 0),"index",0),"deviceIdStarz",""),"_postInterval",10),T(C=a(a(a(a(a(a(e,"_customTag",{}),"_baseServerTimeStampMS",0),"_prevBitrate",-1),"_streamUrl",""),"_initLatancy",0),"_prevCDN",""),"_adPauseStartTime",0),T(C,"_adEpocTime",0),T(C,"setEPState",function(e){this._EPState=e}),T(C,"getEPState",function(){return this._EPState}),T(C,"getQbrMode",function(){return this._mode}),T(C,"isValidStateTransition",function(e){return!0}),T(C,"setRegistrationStatus",function(e){this._regStatus=e}),T(C,"getRegistrationStatusWithBackend",function(){return this._regStatus}),(O={})[t="postInterval"]=O[t]||{},O[t].set=function(e){this._postInterval=e},O[i="postInterval"]=O[i]||{},O[i].get=function(){return this._postInterval},O[s="recordIndex"]=O[s]||{},O[s].set=function(e){this._recordIndex=e},O[n="recordIndex"]=O[n]||{},O[n].get=function(){return this._recordIndex},O[o="upShiftCount"]=O[o]||{},O[o].set=function(e){this._upshiftCount=e},O[d="upshiftCount"]=O[d]||{},O[d].get=function(){return this._upshiftCount},O[l="downShiftCount"]=O[l]||{},O[l].set=function(e){this._downshiftCount=e},O[u="downshiftCount"]=O[u]||{},O[u].get=function(){return this._downshiftCount},O[h="qoeMetric"]=O[h]||{},O[h].set=function(e){this._qoeMetric=e},O[_="qoeMetric"]=O[_]||{},O[_].get=function(){return this._qoeMetric},O[R="eventMetric"]=O[R]||{},O[R].set=function(e){this._eventMetric=e},O[P="eventMetric"]=O[P]||{},O[P].get=function(){return this._eventMetric},T(C,"registerMMSmartStreaming",function(e,t,i,r,a,s,n){this._playerName=e,this._customerID=t,this._subscriberID=i,this._domainName=r,this._subscriberType=a,this._subscriberTag=s,void 0!==n&&(this._hashSubscriberID=n)}),T(C,"updateSubscriberID",function(e){this._subscriberID=e}),T(C,"updateSubscriber",function(e,t,i){this._subscriberID=e,this._subscriberType=t,this._subscriberTag=i}),T(C,"initializeSession",function(e,t,i,r){return this._httpUtil&&(this._httpUtil.cleanUp(),this._httpUtil=void 0),this._producerURL=void 0,this._secondaryProducerList=[],this._producerURLSES=void 0,this.deviceIdStarz="",this.index=0,this.setRegistrationStatus("PENDING"),this._statsMetric.version=this._eventMetric.version=S.EP_SCHEMA_VERSION,this._streamUrl=t,this._assetID=r.assetId,this._assetName=r.assetName,this._videoId=r.videoId,this._contentMetadata=r,this.setSESURL("https://sdks.mediamelon.com/1185727140/files/endPoint.json"),this.initialize(),this.registerSdkWithBackend(e)}),T(C,"registerSdkWithBackend",function(e){var t="https://register.mediamelon.com/mm-apis/register/"+this._customerID;return S.component=this._component,S.mode=e,this._httpUtil=new A,this._httpUtil.doGet(t,S)}),T(C,"getProfiledIdforToolbox",function(){if(this.sesRequirements){var e=this.sesRequirements.JWT,t=new XMLHttpRequest;t.open("GET",this.sesRequirements.toolboxEndpoint_profiledId,!0),t.setRequestHeader("Access-Control-Allow-Origin","*"),t.setRequestHeader("Authorization","JWT "+e),t.onerror=function(){console.log("Error while getting  profiledId for Toolbox")};var i=this;t.onreadystatechange=function(){if(t.readyState===XMLHttpRequest.DONE){var e=t.status;if(0===e||e>=200&&e<400){var r=t.response;try{i.profiledId=JSON.parse(r).result[0].id}catch(e){console.log("JSON format incorrect for profiledId -Toolbox")}}else console.log("Error while getting  profiledId for Toolbox - HTTP error",e)}},t.send()}}),T(C,"sendHearbeatToStarz",function(){if(this.sesRequirements){var e=this.sesRequirements.sid,t=parseFloat(this._pbTime.toFixed(2)),i=this.sesRequirements.cid,r=new XMLHttpRequest;r.open("POST",this._producerURLSES+"PLAYBACK_UPDATE",!0),r.timeout=this._httpPostTimeout,r.setRequestHeader("Access-Control-Allow-Origin","*"),r.setRequestHeader("Content-type","application/json");var a=this.sesRequirements.starzEndpoint.split("track/")[1],s={apiKey:a.substring(0,a.length-1),eventType:"",deviceId:this.deviceIdStarz};s.eventType="PLAYBACK_UPDATE",s.properties={session_id:e,affiliate_name:"Dish_MX_SES",content_id:i,position_milliseconds:1e3*t};var n=JSON.stringify(s);r.onerror=function(){console.log("Error in sending heartbeat to starz")},r.send(n)}}),T(C,"sendHeartbeatToToolbox",function(){if(this._producerURLSES&&this.profiledId&&this.sesRequirements&&!this.sesRequirements.isStarz){var e={content:{id:this.sesRequirements.cid,drmType:"com.widevine.alpha",formatType:"application/d
2ash+xml"},events:[],playback:{position:parseFloat(this._pbTime.toFixed(2)),timeSpent:this.getPlayDur(),bitrate:this._prevSegInfo.cbrBitrate},user:{profiledId:this.profiledId},playerID:this.deviceIdStarz};e.events.push({name:"StreamingProgress"});var t=JSON.stringify(e),i=new XMLHttpRequest;i.open("POST",this._producerURLSES),i.setRequestHeader("Content-Type","application/json"),i.setRequestHeader("Access-Control-Allow-Origin","*"),i.setRequestHeader("Accept","application/json");var r=this.sesRequirements.JWT;i.setRequestHeader("Authorization","JWT "+r),i.onerror=function(){console.log("Error while sending heartbeat to Toolbox")},i.send(t)}}),T(C,"packageToolBoxEvent",function(e,t){if(this.sesRequirements&&!this.sesRequirements.isStarz&&(this.sesRequirements.isToolbox&&""==this.sesRequirements.toolboxEndpoint_profiledId&&this.getProfiledIdforToolbox(),"ONLOAD"!==e&&"COMPLETE"!==e&&"SEEKED"!==e&&"BUFFERING"!==e&&"VideoPlaybackQualityChanged"!==e&&"ERROR"!==e&&"SEEKING"!==e&&"BUFFERING_FINISHED"!==e)){var i="firstquartile"===e?25:"midpoint"===e?50:"thirdquartile"===e?75:"complete"===e?95:"ended"===e?99:"COMPLETE"===e?100:"progressmark"===e?10:void 0,r={content:{id:this.sesRequirements.cid,drmType:"com.widevine.alpha",formatType:"application/dash+xml"},events:[],playback:{position:parseFloat(this._pbTime.toFixed(2)),timeSpent:this.getPlayDur(),bitrate:this._prevSegInfo.cbrBitrate},user:{profiledId:this.profiledId},playerID:this.deviceIdStarz};if("START"===e||"PAUSE"===e||"RESUME"===e){var a={name:e.toLowerCase(),number:this.index+1};return r.events.push(a),this.index+=1,JSON.stringify(r)}if("SES_ERROR"===e){var s={name:"playbackError",value:{errorCode:t.code,errorMessage:t.name}};return r.events.push(s),JSON.stringify(r)}var n={name:e,value:i,number:this.index+1};return r.events.push(n),this.index+=1,JSON.stringify(r)}}),T(C,"sendEventToToolbox",function(){if(this.sesRequirements&&!this.sesRequirements.isStarz&&this._producerURLSES&&this.profiledId){this._SESEventToSend.length;for(var e=this.sesRequirements.JWT,t=0;t<this._SESEventToSend.length;t++){var i=new XMLHttpRequest;i.open("POST",this._producerURLSES,!0),i.timeout=this._httpPostTimeout,i.setRequestHeader("Access-Control-Allow-Origin","*"),i.setRequestHeader("Content-type","application/json"),i.setRequestHeader("Authorization","JWT "+e),i.setRequestHeader("Accept","application/json"),i.onerror=function(){console.log("Error while sending event to Toolbox")},i.send(this._SESEventToSend[t]),this._SESEventToSend[t]=null}this._SESEventToSend=[]}}),T(C,"GenerateDeviceIdStarz",function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,function(e){return(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)})}),T(C,"packageStarzEvent",function(e,t){if(this.sesRequirements&&!this.sesRequirements.isToolbox){var i=this.sesRequirements.sid,r=parseFloat(this._pbTime.toFixed(2)),a=this._playerBrand,s=this._playerVersion,n=this._deviceOs,o=this._deviceOsVersion,d=this._deviceBrand,l=this._deviceModel,u=this.sesRequirements.cid,h="Dish_MX",c=this.sesRequirements.starzEndpoint.split("track/")[1],_={apiKey:c.substring(0,c.length-1),eventType:"",deviceId:this.deviceIdStarz};return"VideoPlaybackQualityChanged"===e?(_.eventType="VIDEO_PLAYBACK_QUALITY_CHANGED",_.properties={session_id:i,target_quality_resolution:t.targetQuality.width+"X"+t.targetQuality.height,target_quality_bitrate:t.targetQuality.bitrate},JSON.stringify(_)):"PAUSE"===e||"RESUME"===e||"COMPLETE"===e||"SEEKING"===e||"SEEKED"===e||"ENDED"===e?("PAUSE"===e?(_.eventType="PLAYBACK_PAUSED",_.properties={session_id:i,paused_position_milliseconds:1e3*r}):"RESUME"===e?(_.eventType="PLAYBACK_RESUMED",_.properties={session_id:i,resumed_position_milliseconds:1e3*r}):"COMPLETE"===e||"ENDED"===e?(_.eventType="PLAYBACK_FINISHED",_.properties={session_id:i,end_time_milliseconds:1e3*r}):"SEEKING"===e?(_.eventType="SEEK_STARTED",_.properties={session_id:i,start_position_milliseconds:1e3*r}):"SEEKED"===e&&(_.eventType="SEEK_FINISHED",_.properties={session_id:i,end_position_milliseconds:1e3*r}),JSON.stringify(_)):"ONLOAD"===e?(_.eventType="PLAYER_READY",_.properties={session_id:i,player_name:a,player_version:s,os_name:n,os_version:o,platform_name:d,platform_version:l,device_type:"PC",content_id:u},JSON.stringify(_)):"downloadFinished"===e?(_.eventType="DOWNLOAD_FINISHED",_.properties={session_id:i,http_status:t.httpStatus,success:t.success,download_time:t.downloadTime,size:t.size,attempt:t.attempt,max_attempts:t.maxAttempts,download_Type:t.downloadType},JSON.stringify(_)):"SES_ERROR"===e?(_.eventType="ERROR",_.properties={session_id:i,error_details:{code:t.code,message:t.name,content_id:u,detail:t.data},user_residency_country:"NA",user_residency_region:"NA",catalog_partner:h},JSON.stringify(_)):"SES_WARNING"===e?(_.eventType="WARNING",_.properties={session_id:i,warning_details:{code:t.code,name:t.name,timestamp:t.timestamp,data:t.data,message:t.message}},JSON.stringify(_)):"BUFFERING_FINISHED"===e?(_.eventType="BUFFERING_FINISHED",_.properties={session_id:i},JSON.stringify(_)):"BUFFERING"===e?(_.eventType="BUFFERING_STARTED",_.properties={session_id:i},JSON.stringify(_)):"START"===e?(_.eventType="PLAYBACK_STARTED",_.properties={session_id:i,startup_time_milliseconds:this._initLatency,content_id:u,affiliate_name:"Dish_MX_SES",type:"Play Button",user_residency_country:"NA",user_residency_region:"NA",catalog_partner:h},JSON.stringify(_)):void 0}}),T(C,"sendEventToStarz",function(){if(this.sesRequirements&&!this.sesRequirements.isToolbox&&this._producerURLSES){this._SESEventToSend.length;for(var e=0;e<this._SESEventToSend.length;e++){var t=new XMLHttpRequest,i=JSON.parse(this._SESEventToSend[e]),r=this._producerURLSES+i.eventType;t.open("POST",r,!0),t.timeout=this._httpPostTimeout,t.setRequestHeader("Acce
2ss-Control-Allow-Origin","*"),t.setRequestHeader("Content-type","application/json"),t.onerror=function(){console.log("Error while sending payload to Starz")},t.send(this._SESEventToSend[e]),this._SESEventToSend[e]=null}return this._SESEventToSend=[],0}}),T(C,"reportRegistrationSuccess",function(e){var t,i;this.setRegistrationStatus("SUCCESS"),this._modeFromResponse=e.mode,this.setCfVal(e.cfVal),void 0!==e.maxStepsUp&&(isNaN(e.maxStepsUp)||(t=e.maxStepsUp)),void 0!==e.maxStepsDown&&(isNaN(e.maxStepsDown)||(i=e.maxStepsDown)),void 0===t&&void 0===i&&void 0!==e.maxSteps&&(isNaN(e.maxSteps)||(t=i=e.maxSteps)),void 0!==e.secProdList&&e.secProdList.length>0&&Array.isArray(e.secProdList)&&this.reportSecondaryProducerList(e.secProdList),this.setMaxSteps(t,i),this.reportServerTimeStamp(e.timestamp),this.reportProducer(e.producerURL,e.statsInterval),this.monitorRegistration(),this._inProgress=!0,this._simulatedEndedSent=!1}),T(C,"setSDKQoEConfig",function(e,t){void 0!==e&&(this._enableVideoQoE=e),void 0!==t&&(this._enableAdQoE=t)}),T(C,"reportRegistrationFailure",function(){this.setRegistrationStatus("FAILED"),this._producerURL=void 0,this._secondaryProducerList=[],this._modeFromResponse=null,this._postInterval=-1,this._eventToSend=[],this._SESEventToSend=[],this._statsToSend=[],this.stopMonitoring()}),T(C,"parseResolution",function(e){if("string"!=typeof e)return null;var t=e.split("x");if(2!==t.length)return null;var i=parseInt(t[0],10),r=parseInt(t[1],10);return isNaN(i)||isNaN(r)?null:{width:i,height:r}}),T(C,"reportRenditionChange",function(e,t){var i={},r=!1;if(t.cbrBitrate&&t.cbrBitrate!==e.cbrBitrate){e.cbrBitrate?t.cbrBitrate>e.cbrBitrate?this.upShift():this.downShift():e.cbrBitrate=0,this._qoeMetric[this.attributes.BITRATE]=t.cbrBitrate,this._qoeMetric[this.attributes.PREV_BITRATE]=e.cbrBitrate;var a=e.cbrBitrate+"@"+t.cbrBitrate;i.B=a,r=!0}if(t.res&&t.res!==e.res){e.res||(e.res="0x0");var s=this.parseResolution(t.res);s&&(this._qoeMetric[this.attributes.RES_WIDTH]=s.width,this._qoeMetric[this.attributes.RES_HEIGHT]=s.height);var n=this.parseResolution(e.res);n&&(this._qoeMetric[this.attributes.PREV_RES_WIDTH]=n.width,this._qoeMetric[this.attributes.PREV_RES_HEIGHT]=n.height);var o=e.res+"@"+t.res;i.R=o,r=!0}if(t.vCodec&&t.vCodec!==e.vCodec){e.vCodec||(e.vCodec="NA");var d=e.vCodec+"@"+t.vCodec;i.V=d,r=!0}if(t.aCodec&&t.aCodec!==e.aCodec){e.aCodec||(e.aCodec="NA");var l=e.aCodec+"@"+t.aCodec;i.A=l,r=!0}if(t.fps&&t.fps!==e.fps){e.fps||(e.fps="0.0");var u=e.fps+"@"+t.fps;i.F=u,r=!0}return r&&(i=JSON.stringify(i),this.notifyEvent("RENDITION_CHANGE",i,"RENDITION_CHANGE",this._pbTime)),r}),T(C,"addCustomSegInfo",function(e){this.reportRenditionChange(this._prevSegInfo,e)&&(e.timestamp=this.getCorrectedCurrentTimeinMs(),this._downloadRate>0&&(e.downloadRate=parseFloat((1024*this._downloadRate).toFixed(2))),this._statsMetric.qubitData[this._recordIndex].segInfo.push(e),this._prevSegInfo=e,this._segINfoStatus=!0)}),T(C,"addSegInfo",function(e){!(this._prevSegInfo&&(-1!=e.seqNum&&this._prevSegInfo.seqNum==e.seqNum&&this._prevSegInfo.startTime===e.startTime&&this._prevSegInfo.cbrBitrate===e.cbrBitrate&&this._segRepeatationCount++<10||this._prevSegInfo.cbrBitrate===e.cbrBitrate&&this._prevSegInfo.res===e.res))&&e.cbrBitrate&&(this._downloadRate>0&&(e.downloadRate=parseFloat((1024*this._downloadRate).toFixed(2))),this._bufferLength>=0&&(e.bufferLength=parseInt(this._bufferLength)),e.cbrSize?e.dur<0&&(e.cbrSize=e.qbrSize=0):e.dur>0?e.cbrSize=e.qbrSize=e.dur*e.cbrBitrate:e.cbrSize=e.qbrSize=0,e.timestamp=this.getCorrectedCurrentTimeinMs(),void 0!==e.qbrBitrate&&delete e.qbrBitrate,void 0!==e.qbrQual&&delete e.qbrQual,void 0!==e.cbrQual&&delete e.cbrQual,void 0!==e.dur&&delete e.dur,void 0!==e.seqNum&&delete e.seqNum,void 0!==e.startTime&&delete e.startTime,void 0!==e.fps&&delete e.fps,void 0!==e.profileNum&&delete e.profileNum,void 0!==e.cbrProfileNum&&delete e.cbrProfileNum,void 0!==e.qbrSize&&delete e.qbrSize,void 0!==e.bufferLength&&delete e.bufferLength,void 0!==e.cbrSize&&e.cbrSize<=0&&delete e.cbrSize,void 0!==e.vCodec&&""===e.vCodec&&delete e.vCodec,void 0!==e.aCodec&&""===e.aCodec&&delete e.aCodec,this.reportRenditionChange(this._prevSegInfo,e),this._statsMetric.qubitData[this._recordIndex].segInfo.push(e),this._prevSegInfo=e.constructor===Array?e[length-1]:e,this._segINfoStatus=!0,this._segRepeatationCount=0)}),T(C,"setBandwidth",function(e){void 0!==e&&e>0&&(this._downloadRate=e/1024,this._downloadRateCount=this._downloadRateCount+1,this._avgDownloadRate=this._downloadRate+this._avgDownloadRate)}),T(C,"reportBufferLength",function(e){e>=0&&(this._bufferLength=e)}),T(C,"clearAdInfo",function(){delete this._eventMetric.qubitData[this._recordIndex].adInfo}),T(C,"setCustomTag",function(e,t){void 0===this._eventMetric.qubitData[this._recordIndex].customTags&&(this._eventMetric.qubitData[this._recordIndex].customTags={}),void 0===this._statsMetric.qubitData[this._recordIndex].customTags&&(this._statsMetric.qubitData[this._recordIndex].customTags={});var i=this._eventMetric.qubitData[this._recordIndex].customTags;i[e]=t,this._eventMetric.qubitData[this._recordIndex].customTags=i,this._statsMetric.qubitData[this._recordIndex].customTags=i}),T(C,"reportContentMetadata",function(e){void 0!==e.assetId&&null!==e.assetId&&this.setContentMetadata(this.attributes.ASSETID,e.assetId),void 0!==e.assetName&&null!==e.assetName&&this.setContentMetadata(this.attributes.ASSETNAME,e.assetName),e.videoId&&this.setContentMetadata(this.attributes.VIDEOID,e.videoId),e.contentType&&this.setContentMetadata(this.attributes.CONTENTTYPE,e.contentType),e.drmProtection&&this.setContentMetadata(this.attributes.DRMPROTECTION,e.drmProtection),e.episodeNumber&&this.setContentMetadata(this.attributes.EPISODENUMBER,e.episodeNumber),e.genre&&this.setContentMetadata(this.attributes.GENRE,e.genre),e.season&&this.setContentMetadata(this.attributes.SEASON,e.season),e.seriesTitle&&this.setContentMetadata(this.attributes.SERIESTITLE,e.seriesTitle),e.videoType&&this.setContentMetadata(this.attributes.VIDEOTYPE,e.videoType)}),T(C,"setContentMetadata",function(e,t){null!=t&&(this._statsMetric.qubitData[this._recordIndex].contentMetadata[e]=t,this._eventMetric.qubitData[this._recordIndex].contentMetadata[e]=t)}),T(C,"reportNetworkType",function(e){e&&(this._networkType=e,this.setClientInfo(this.attributes.NETWORKTYPE,this._networkType))}),T(C,"reportDeviceType",function(e){this._deviceType=e}),T(C,"setCfVal",function(e){this._cfVal=e}),T(C,"getCfVal",function(){return this._cfVal}),T(C,"setMaxSteps",function(e,t){e>=0&&(this._maxStepUp=e),t>=0&&(this._maxStepDown=t)}),T(C,"getMaxStepsToSwitch",function(){return[this._maxStepUp,this._maxStepDown]}),T(C,"reportWifiSSID",function(e){e&&(this._wifiSSID=e,this.setClientInfo(this.attributes.WIFISSID,this._wifiSSID))}),T(C,"reportWifiSignalStrenthPercentage",function(e){e&&(this._wifiSignalStrenth=e,this.setClientInfo(this.attributes.SIGNALSTRENGTH,this._wifiSignalStrenth))}
2),T(C,"reportWifiDataRate",function(e){e&&(this._wifiDataRate=e,this.setClientInfo(this.attributes.WIFIDATERATE,this._wifiDataRate))}),T(C,"reportServerTimeStamp",function(e){this._baseServerTimeStampMS=e,this.setCurrentTimeDelta()}),T(C,"reportProducer",function(e,t){this._producerURL=e,this._postInterval=t}),T(C,"reportSecondaryProducerList",function(e){this._secondaryProducerList=e}),T(C,"reportProducerForSES",function(e){this._producerURLSES=e,this.deviceIdStarz=this.GenerateDeviceIdStarz()}),T(C,"reportMode",function(e){this._mode=e,this.setStreamID(this.attributes.QBRSDKMODE,this._mode),this.sendEventInfo()}),T(C,"reportAssetID",function(e,t,i){e&&(this._assetID=e),t&&(this._assetName=t),i&&(this._videoId=i)}),T(C,"reportPresentationSize",function(e,t){this._presentationWidth=e,this._presentationHeight=t}),T(C,"reportFrameLoss",function(e){this.frameloss=e,this.setPBStats(this.attributes.FRAMELOSS,this.frameloss)}),T(C,"reportABRSwitch",function(e,t){}),T(C,"monitorRegistration",function(){this.sendEventInfo(),this.sendQueuedStats(),this.startMonitoring()}),T(C,"sendQueuedStats",function(){if(void 0!==this._producerURL){for(var e=0;e<this._statsToSend.length;e++){var t=this._statsToSend[e],i=!1;if("u">typeof pako)try{t=pako.gzip(t),i=!0}catch(e){console.error("MMError: Error compressing event payload: ",e)}var r=new XMLHttpRequest;r.open("POST",this._producerURL,!0),r.timeout=this._httpPostTimeout,r.setRequestHeader("Content-type","application/json"),i&&r.setRequestHeader("Content-Encoding","gzip"),r.send(t),this._lastStatsPostedAtTS=this.getCurrentTimeinMs(),this._statsToSend[e]=null,this._secondaryProducerList&&this._secondaryProducerList.length>0&&this.sendDataToSecondaryProducerList(t,i)}this._statsToSend=[]}}),T(C,"reportPlayerInfo",function(e,t,i){this._playerBrand=e,this._playerModel=t,this._playerVersion=i}),T(C,"reportAppInfo",function(e,t){this._appName=e,this._appVersion=t}),T(C,"reportPlayerResolution",function(e){this._playerRes=e,this.setClientInfo(this.attributes.PLAYERRES,this._playerRes)}),T(C,"reportDeviceCapabilities",function(e){this._deviceCapabilities=e}),T(C,"reportVideoQuality",function(e){this._videoQuality=e}),T(C,"reportExperimentName",function(e){this._experimentName=e,this.setStreamID(this.attributes.EXPERIMENTNAME,this._experimentName)}),T(C,"reportSubPropertyId",function(e){this._subPropertyId=e,this.setStreamID(this.attributes.SUBPROPERTYID,this._subPropertyId)}),T(C,"reportViewSessionId",function(e){this._viewSessionId=e,this.setStreamID(this.attributes.VIEWSESSIONID,this._viewSessionId)}),T(C,"reportAppSessionId",function(e){this._appSessionId=e,this.setStreamID(this.attributes.APPSESSIONID,this._appSessionId)}),T(C,"reportBasePlayerInfo",function(e,t){this._basePlayerName=e,this._basePlayerVersion=t,this.setStreamID(this.attributes.BASEPLAYERNAME,this._basePlayerName),this.setStreamID(this.attributes.BASEPLAYERVERSION,this._basePlayerVersion)}),T(C,"reportManifestLoaded",function(e){this.notifyEvent("MANIFEST_LOADED","Manifest Load Complete","MANIFEST_LOADED",this._pbTime)}),T(C,"reportDeviceId",function(e){this._deviceID=e,this.setClientInfo(this.attributes.DEVICEID,this._deviceID)}),T(C,"reportDeviceInfo",function(e,t,i,r,a,s,n,o){e&&(this._deviceBrand=e),t&&(this._deviceModel=t),i&&(this._deviceOs=i),r&&(this._deviceOsVersion=r),a&&(this._deviceOperator=a),n&&(this._presentationWidth=n),o&&(this._presentationHeight=o),s&&(this._deviceMarketingName=s),this.setScreenRes()}),T(C,"reportMetricValue",function(e,t){e===v.Latency?(this._initLatency=parseFloat(t.toFixed(2)),this._flagStartLatencyViaPlayer=!0):e===v.DurationWatched||(e===v.streamURL?this.setStreamID(this.attributes.STREAMURL,t):e===v.drmType&&this.setContentMetadata(this.attributes.DRMPROTECTION,t))}),T(C,"reportStringDimension",function(e,t){if(null!=t&&""!==t&&e===E.CDN){if(this.setClientInfo(this.attributes.CDN,t),""!==this._prevCDN&&t!==this._prevCDN){var i="Prev: "+this._prevCDN+", New: "+t;this.notifyEvent("CDN_CHANGE",i,"CDN_CHANGE",this._pbTime)}this._prevCDN=t}}),T(C,"reportAdBufferingStarted",function(){if(this._adInformation&&this._adInformation._playSent&&!this._isBufferingState){this._isBufferingState=!0;var e=this.getCurrentTimeinMs();this.populateAdRelatedInfo(e),this._adBufferStartTime=e,this.notifyEvent("AD_BUFFERING_START","Ad Buffering started","AD_BUFFERING_START",null),this._adInformation._adLastAdEventTimeStamp=e}}),T(C,"reportAdBufferingCompleted",function(){this._adInformation&&this._adInformation._playSent&&0!=this._isBufferingState&&(this._playbackStatus="AD_BUFFERING_COMPLETE",this._isBufferingState=!1,this.setAdBuffering(),this.notifyEvent("AD_BUFFERING_COMPLETE","Ad Buffering completed","AD_BUFFERING_COMPLETE",null),this._adBufferStartTime=0)}
2),T(C,"reportBufferingStarted",function(){this.getEPState()!==D.STARTED||this._isBufferingState||(this._isBufferingState=!0,this._bufferingCount++,this.notifyEvent("BUFFERING_START","Playback Buffering Started","BUFFERING_START",this._pbTime),this._bufferStartTime=this.getCurrentTimeinMs())}),T(C,"reportBufferingCompleted",function(){this.getEPState()===D.STARTED&&(this.setBuffering(),this.notifyEvent("BUFFERING_COMPLETE","Playback Buffering Completed","BUFFERING_COMPLETE",this._pbTime),this._isBufferingState=!1,this._bufferStartTime=0)}),T(C,"reportEventWithValue",function(e,t){this.notifyEvent(e,t,e,this._pbTime)}),T(C,"reportUserInitiatedPlayback",function(){var e=this.getCurrentTimeinMs();this.getEPState()===D.INITIALIZED?(this._latencyStartTime=e,this.notifyEvent("ONLOAD","Player Initializing..","ONLOAD",0),this.notifyPackager("ONLOAD"),this.setEPState(D.ONLOAD_SENT)):console.log("Warn: State not valid")}),T(C,"reportPlayerState",function(e){var t=this.getEPState(),i=this.getCurrentTimeinMs(),r=!1;switch(e){case p.PLAYING:if(this._seekState=m.Playing,this._isVideoPaused=!1,this._prevPlayerState==p.PAUSED&&t===D.ONLOAD_SENT&&(this._pauseDuration=i-this._pauseStartTime,this.setBufPBEvent(this.attributes.PAUSEDURATION,this._pauseDuration),this.notifyEvent("RESUME","Playback resumed","RESUME",this._pbTime),this._pauseStartTime=0,this.startMonitoring(),r=!0),t===D.ONLOAD_SENT){if(!this._flagStartLatencyViaPlayer){var a=i-this._latencyStartTime;this._pauseDuration>0&&(a-=this._pauseDuration),this._initLatency=a,this._initLatency<0&&(this._initLatency=0)}this._epocTime=i,this.setPBStats(this.attributes.LATENCY,this._initLatency),this.setEPState(D.STARTED),this.notifyPackager("START"),this.notifyEvent("START","Playback Start","START",this._pbTime),this._latencyStartTime=0,this.startMonitoring(),r=!0}else if(t===D.STARTED&&this._prevPlayerState===p.PAUSED)this._pauseStartTime&&(this._pauseDuration=i-this._pauseStartTime,this.setBufPBEvent(this.attributes.PAUSEDURATION,this._pauseDuration),this._epocTime+=this._pauseDuration,this.notifyEvent("RESUME","Playback resumed","RESUME",this._pbTime),this.notifyPackager("RESUME"),this._pauseStartTime=0,this.startMonitoring(),r=!0);else if(t===D.STOPPED&&this._prevPlayerState===p.STOPPED){var s=this.getStreamInfo(),n=this.getStreamId(),o=this._mode;this.reset(),this.initialize(),this.reportMode(o),this.setPresentationStreamInfo(s.maxRes,s.minRes,s.maxFps,s.minFps,s.numOfProfile,s.streamFormat),this.setVideoDuration(s.totalDuration),this.setPresentationType(n.isLive),this.setEPState(D.INITIALIZED),this.reportUserInitiatedPlayback(),this.reportPlayerState(p.PLAYING),this.setEPState(D.STARTED),r=!0}break;case p.PAUSED:t!==D.STARTED&&t!==D.ONLOAD_SENT||(this.sendQBRStats(),this.notifyEvent("PAUSE","Playback Paused","PAUSE",this._pbTime),this.notifyPackager("PAUSE"),this._pauseStartTime=i,this._isVideoPaused=!0,r=!0);break;case p.STOPPED:if(!0===this._simulatedEndedSent||t===D.STOPPED||void 0===this._prevPlayerState||this._prevPlayerState===p.STOPPED)break;this._seekState==m.SeekStarted&&(this.setSeek(),this._seekState=m.SeekCompleted),void 0!==this._pauseStartTime&&this._pauseStartTime>0&&(this._pauseDuration=i-this._pauseStartTime,this.setBufPBEvent(this.attributes.PAUSEDURATION,this._pauseDuration)),void 0!==this._adPauseStartTime&&this._adPauseStartTime>0&&(this._adPauseDuration=i-this._adPauseStartTime,this.setBufPBEvent(this.attributes.PAUSEDURATION,this._adPauseDuration)),this._isBufferingState&&(this.setBuffering(),this._isBufferingState=!1),this.sendQBRStats(),this._totalDuration<=0||this._pbTime<.9*this._totalDuration?(this.notifyEvent("ENDED","Playback completion","ENDED",this._pbTime),this.notifyPackager("ENDED")):(this.notifyEvent("COMPLETE","Playback completion","COMPLETE",this._pbTime),this.notifyPackager("COMPLETE")),this._seekStartTime=0,this._pauseStartTime=0,this._bufferStartTime=0,this._adPauseStartTime=0,this.stopMonitoring(),this._inProgress=!1,this.setEPState(D.STOPPED),r=!0;break;default:return void N.log("INFO","Unknown State")}r&&(this._prevPlayerState=e)}),T(C,"reportError",function(e,t){this.setPlaybackPos(t),this.getEPState()>=D.ONLOAD_SENT&&this.notifyEvent("ERROR",e,"ERROR",this._pbTime)}),T(C,"isValid",function(e){return null!=e&&e.length}),T(C,"reportResolutionChange",function(e){}),T(C,"reportVolumeChange",function(e){this.notifyEvent("VOLUME_CHANGE",e,"VOLUME_CHANGE",this._pbTime)}),T(C,"reportPlaybackRateChange",function(){this.notifyEvent("RATE_CHANGE","Playback Rate Changed","RATE_CHANGE",this._pbTime)}),T(C,"reportDurationChange",function(){this.notifyEvent("DURATION_CHANGE","Playback Duration Changed","DURATION_CHANGE",this._pbTime)}),T(C,"reportPlayerSeekStarted",function(){this._seekState=m.SeekStarted,this.notifyEvent("SEEK_START","Playback Seek Started","SEEK_START",this._pbTime),this._seekStartTime=this.getCurrentTimeinMs()}),T(C,"reportPlayerSeekCompleted",function(e){this.getCurrentTimeinMs(),this.getEPState()!==D.ONLOAD_SENT&&this.getEPState()!==D.STARTED||(this.setSeek(),this.setPlaybackPos(e),this._seekState=m.SeekCompleted,this.notifyEvent("SEEK_COMPLETE","Playback Seek Completed","SEEK_COMPLETE",e/1e3),this.notifyPackager("SEEKED"),this._epocTime+=this._seekDuration,this._seekStartTime=0)}),T(C,"reset",function(){this._inProgress&&this.getEPState()===D.STARTED&&(this.reportPlayerState(p.STOPPED),this._inProgress=!1,this._simulatedEndedSent=!0),this._mode=null,this._bufferLength=0,this._downloadRate=0,this._downloadRateCount=0,this._avgDownloadRate=0,this._isFirstBatch=!0,this._eventCount=0,this._onLoadSentAtTS=0,this._lastStatsPostedAtTS=0,this._statsMonitorStartedAtTS=0,this._bufferingCount=0,this._recordIndex=0,this._prevBitrate=-1,this._upshiftCount=0,this._pbTime=0,this._progressMark=0,this._downshiftCount=0,this._playDur=0,this._baseServerTimeStampMS=0,this._totalDuration=0,this._buffWait=0,this._sumBuffWait=0,this._sumBuffWaitCIRR=0,this._buffWaitType="",this._sumBuffWaitVRT=0,this._sumBuffWaitAAD=0,this._seekDuration=0,this._seekStartTime=0,this._seekState=void 0,this._initLatency=0,this._latencyStartTime=0,this._enableEP=!1,this._flagStartLatencyViaPlayer=!1,this._prevPlayerState=void 0,this._isVideoPaused=!1,this._prevSegInfo={},this._prevAudioTrack="NA",this._prevSubtitleTrack="OFF",this._prevCDN="",this._pauseStartTime=0,this._pauseDuration=0,this._adPlaybackTime=0,this.adDuration=0,this.adPosition=0,this._bufferStartTime=0,this._adBufferStartTime=0,this._isBufferingState=!1,this.newBitrate=0,this._epocTime=0,this._qoeMetric={},this._statsMetric.qubitData=[],this._eventMetric.qubitData=[],this._statsMetric.qubitData.push(this.QBRMetricTemplate()),this._eventMetric.qubitData.push(this.EventMetricTemplate()),this._eventToSend=[],this._SESEventToSend=[],this.deviceIdStarz="",this._statsToSend=[],this.sessionId="",this._segRepeatationCount=0,this._maxSteps=0,this._maxStepUp=0,this._maxStepDown=0,this.index=0,this.setEPState(D.IDLE)}),T(C,"initialize",function(){this.setStreamID(this.attributes.CUSTID,parseInt(this._customerID)),this.setStreamID(this.attributes.DATASOURCE,"Player"),this.setStreamID(this.attributes.PLAYERNAME,this._playerName),this.sessionId=this.getSessionId(),this.deviceIdStarz=this.GenerateDeviceIdStarz(),this.setStreamID(this.attributes.SESSIONID,this.sessionId),this.setStreamID(this.attributes.DOMAINNAME,this.getDomainName()),this.setStreamID(this.attributes.STREAMURL,this._streamUrl),this.setStreamID(this.attributes.PLAYERVERSION,this._playerVersion),this.setStreamID(this.attributes.PLAYERBRAND,this._playerBrand),this.setStreamID(this.attributes.PLAYERMODEL,this._playerModel),this.setStreamID(this.attributes.SUBPROPERTYID,this._subPropertyId),this.setStreamID(this.attributes.EXPERIMENTNAME,this._experimentName),this.setStreamID(this.attributes.VIEWSESSIONID,this._viewSessionId),this.setStreamID(this.attributes.APPSESSIONID,this._appSessionId),this.setStreamID(this.attributes.BASEPLAYERNAME,this._basePlayerName),this.setStreamID(this.attributes.BASEPLAYERVERSION,this._basePlayerVersion),this.setSDKInfo(this.attributes.S
2DKVERSION,this._sdkVersion),this.setSDKInfo(this.attributes.HFILEVERSION,this._hintFileVersion),this.setClientInfo(this.attributes.DEVICETYPE,this._deviceType),this.setClientInfo(this.attributes.DEVICEBRAND,this._deviceBrand),this.setClientInfo(this.attributes.DEVICEMODEL,this._deviceModel),this.setClientInfo(this.attributes.OSVERSION,this._deviceOsVersion),this.setClientInfo(this.attributes.PLATFORM,this._deviceOs),this.setClientInfo(this.attributes.OPERATOR,this._deviceOperator),this.setClientInfo(this.attributes.NETWORKTYPE,this._networkType),this.setClientInfo(this.attributes.WIFISSID,this._wifiSSID),this.setClientInfo(this.attributes.WIFIDATERATE,this._wifiDataRate),this.setClientInfo(this.attributes.SIGNALSTRENGTH,this._wifiSignalStrenth),this.setClientInfo(this.attributes.APPNAME,this._appName),this.setClientInfo(this.attributes.APPVERSION,this._appVersion),this.setClientInfo(this.attributes.PLAYERRES,this._playerRes),this.setClientInfo(this.attributes.DEVICEMARKETINGNAME,this._deviceMarketingName),this.setStreamInfo(this.attributes.STREAMFORMAT,this._streamFormat),this.setStreamID(this.attributes.MEDIATYPE,this._mediaType),this.setStreamID(this.attributes.SOURCETYPE,this._sourceType),this.setSubscriberID(),this.setSubscriberType(),this.setSubscriberTag(),this.setAssetID(),this.reportContentMetadata(this._contentMetadata),this.setScreenRes(),this.setEPState(D.INITIALIZED)}),T(C,"getSessionId",function(){return(new Date).getTime(),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx-".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})+(new Date).getTime()}),T(C,"getDomainName",function(){return this.isValid(this._domainName)||(this._domainName=""),this._domainName}),T(C,"isEmpty",function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}),T(C,"getCustomTag",function(e){return this._customTag[e]}),T(C,"notifyPackager",function(e,t){var i;this.sesRequirements&&(this&&this.sesRequirements.isToolbox&&((i="SES_ERROR"===e||"SES_WARNING"===e?this.packageToolBoxEvent(e,t):this.packageToolBoxEvent(e,this._pbTime))&&this._SESEventToSend.push(i),this.sendEventToToolbox()),this&&this.sesRequirements.isStarz&&((i="VideoPlaybackQualityChanged"===e||"SES_ERROR"===e||"downloadFinished"===e||"SES_WARNING"===e?this.packageStarzEvent(e,t):this.packageStarzEvent(e,this._pbTime))&&this._SESEventToSend.push(i),this.sendEventToStarz()))}),T(C,"setSESRequirements",function(e){this.sesRequirements=e}),T(C,"setSESURL",function(e){if(this.sesRequirements){var t=new XMLHttpRequest;t.open("GET",e,!0);var i=this;t.onload=function(){if(200===t.status){var e=JSON.parse(t.response);i.sesRequirements.isToolbox?(i.reportProducerForSES(e.toolboxEndpoint_events),i.sesRequirements.toolboxEndpoint_events=e.toolboxEndpoint_events,i.sesRequirements.toolboxEndpoint_profiledId=e.toolboxEndpoint_profiledId,i.getProfiledIdforToolbox()):i.sesRequirements.isStarz&&(i.reportProducerForSES(e.starzEndpoint),i.sesRequirements.starzEndpoint=e.starzEndpoint)}else console.log("Error while fetching MM URL tracker file "+t.response)},t.send()}}),T(C,"notifyEvent",function(e,t,i,r){if("object"===b(t)&&(t="Unknown error took place: "+t),"FAILED"!==this._regStatus&&this&&this._eventMetric&&this._eventMetric.qubitData&&!(this._recordIndex<0)&&this._eventMetric.qubitData[this._recordIndex]&&this._eventMetric.qubitData[this._recordIndex].clientInfo&&this.attributes&&this.attributes.SCREENRES){this._eventMetric.playDur=this.getPlayDur();var a=this._eventMetric.qubitData[this._recordIndex].clientInfo[this.attributes.SCREENRES];0!==e.indexOf("AD_")?(this.clearAdInfo(),this.setBufPBEvent(this.attributes.SUMBUFFERING,this._sumBuffWait),this.setBufPBEvent(this.attributes.SUMBUFFERINGCIRR,this._sumBuffWaitCIRR),this.setBufPBEvent(this.attributes.SUMBUFFERINGVRT,this._sumBuffWaitVRT),this.setBufPBEvent(this.attributes.SUMBUFFERINGAAD,this._sumBuffWaitAAD)):(void 0!==this._adInformation._adResolution&&(this._eventMetric.qubitData[this._recordIndex].clientInfo[this.attributes.SCREENRES]=this._adInformation._adResolution),"AD_ENDED"!==e&&"AD_COMPLETE"!==e&&"AD_SKIPPED"
2!==e||(this.setBufPBEvent(this.attributes.SUMBUFFERING,this._adSumBuffWait),this.setBufPBEvent(this.attributes.SUMBUFFERINGCIRR,this._adSumBuffWaitCIRR),this.setBufPBEvent(this.attributes.SUMBUFFERINGVRT,this._adSumBuffWaitVRT)),this._eventMetric.playDur=parseInt(this.getAdPlayDur())),r=r?parseFloat(r):parseFloat(0),this._eventMetric.playDur||(this._eventMetric.playDur=0),this._eventMetric.qubitData[this._recordIndex].pbEventInfo.event=e,this._eventMetric.qubitData[this._recordIndex].pbEventInfo.desc=t,this._eventMetric.qubitData[this._recordIndex].pbEventInfo.id=i,this._eventMetric.qubitData[this._recordIndex].pbEventInfo.pbTime=parseFloat(r.toFixed(2)),this._qoeMetric.timestamp=this._eventMetric.timestamp=this.getCorrectedCurrentTimeinMs(),this._totalDuration>0&&(this._progressMark=this._pbTime/this._totalDuration*100,this._qoeMetric[this.attributes.PROGRESSMARK]=parseFloat(this._progressMark.toFixed(2))),this._eventMetric.interval=this._postInterval,this._eventMetric.pbTime=parseFloat(r.toFixed(2)),Object.keys(this._qoeMetric).length&&this._eventMetric.qubitData[this._recordIndex].pbInfo.push(this._qoeMetric),this._eventMetric.qubitData[this._recordIndex].pbInfo[0].hasOwnProperty(this.attributes.BUFFERING)&&delete this._eventMetric.qubitData[this._recordIndex].pbInfo[0][this.attributes.BUFFERING],this._eventMetric.qubitData[this._recordIndex].pbInfo[0].hasOwnProperty(this.attributes.UPSHIFTCOUNT)&&delete this._eventMetric.qubitData[this._recordIndex].pbInfo[0][this.attributes.UPSHIFTCOUNT],this._eventMetric.qubitData[this._recordIndex].pbInfo[0].hasOwnProperty(this.attributes.DOWNSHIFTCOUNT)&&delete this._eventMetric.qubitData[this._recordIndex].pbInfo[0][this.attributes.DOWNSHIFTCOUNT];var s=JSON.parse(JSON.stringify(this._eventMetric));this._eventToSend.push(s),this.sendEventInfo(),this._eventMetric.qubitData[this._recordIndex].clientInfo[this.attributes.SCREENRES]=a,this._eventMetric.qubitData[this._recordIndex].adInfo=void 0,this._eventMetric.qubitData[this._recordIndex].pbEventInfo={},this._eventMetric.qubitData[this._recordIndex].pbInfo=[],this._playbackStatus=e,this._qoeMetric={}}}),T(C,"downShift",function(){this._downshiftCount++}),T(C,"upShift",function(){this._upshiftCount++}),T(C,"getInitialDelay",function(){return this._initLatency}),T(C,"getBuffWait",function(){return this._sumBuffWait}),T(C,"getBufferingCount",function(){return this._bufferingCount}),T(C,"setStreamID",function(e,t){null!=t&&(this._statsMetric.qubitData[this._recordIndex].streamID[e]=t,this._eventMetric.qubitData[this._recordIndex].streamID[e]=t)}),T(C,"setMode",function(e){void 0!==e&&String(e).length>0&&(statsMetric.qubitData[this._recordIndex].streamID.mode=e,eventMetric.qubitData[this._recordIndex].streamID.mode=e)}),T(C,"setClientInfo",function(e,t){this._eventMetric.qubitData&&(void 0===this._eventMetric.qubitData[this._recordIndex].clientInfo&&(this._eventMetric.qubitData[this._recordIndex].clientInfo={}),void 0===this._statsMetric.qubitData[this._recordIndex].clientInfo&&(this._statsMetric.qubitData[this._recordIndex].clientInfo={}),t&&(this._statsMetric.qubitData[this._recordIndex].clientInfo[e]=t,this._eventMetric.qubitData[this._recordIndex].clientInfo[e]=t))}),T(C,"setPlaybackPos",function(e){this._pbTime=e/1e3}),T(C,"getPlaybackPos",function(){return this._pbTime}),T(C,"setPBStats",function(e,t){if(e!==this.attributes.LATENCY){var i={};i.timestamp=this.getCorrectedCurrentTimeinMs(),i[e]=parseFloat(t.toFixed(2)),i[this.attributes.PBTIME]=parseFloat(this._pbTime.toFixed(2)),this._totalDuration>0&&(this._progressMark=this._pbTime/this._totalDuration*100,i[this.attributes.PROGRESSMARK]=parseFloat(this._progressMark.toFixed(2))),e===this.attributes.BUFFERING&&(i[this.attributes.BUFFERINGTYPE]=this._buffWaitType),this._statsMetric.qubitData[this._recordIndex].pbInfo.push(i)}(t||e==this.attributes.LATENCY)&&(this._qoeMetric[e]=parseFloat(t.toFixed(2)))}),T(C,"setBufPBEvent",function(e,t){t&&t>0&&(e in this._qoeMetric&&e===this.attributes.BUFFERING?this._qoeMetric[e]=parseInt(t):this._qoeMetric[e]=t)}),T(C,"setSDKInfo",function(e,t){t&&(this._statsMetric.qubitData[this._recordIndex].sdkInfo[e]=t,this._eventMetric.qubitData[this._recordIndex].sdkInfo[e]=t)}),T(C,"getPBStats",function(e){return this._qoeMetric[e]}),T(C,"setDiagnostics",function(e,t){t&&(this._statsMetric.qubitData[this._recordIndex].diagnostics[e]=t)}),T(C,"setStreamInfo",function(e,t){void 0!==e&&void 0!==t&&(this._statsMetric.qubitData[this._recordIndex].streamInfo[e]=t,this._eventMetric.qubitData[this._recordIndex].streamInfo[e]=t)}),T(C,"getStreamInfo",function(){return this._statsMetric.qubitData[this._recordIndex].streamInfo}),T(C,"getStreamId",function(){return this._statsMetric.qubitData[this._recordIndex].streamID}),T(C,"setSegInfo",function(e,t){t&&(this._statsMetric.qubitData[this._recordIndex].segInfo[e]=t)}),T(C,"setScreenRes",function(){var e="";this.isValid(this._presentationHeight)&&this.isValid(this._presentationWidth)||this._presentationHeight>0&&this._presentationWidth>0?e=this._presentationWidth+"x"+this._presentationHeight:"u">typeof window&&window.innerWidth&&window.innerHeight&&(e=window.innerWidth+"x"+window.innerHeight),this.setClientInfo(this.attributes.SCREENRES,e),this.setClientInfo(this.attributes.VIDEOQUALITY,this._videoQuality),this.setClientInfo(this.attributes.DEVICEID,this._deviceID),this._deviceCapabilities?this.setClientInfo(this.attributes.DEVICECAPABILITIES,this._deviceCapabilities):"u">typeof window&&window.matchMedia("(dynamic-range: high)")&&window.matchMedia("(dynamic-range: high)").matches&&this.setClientInfo(this.attributes.DEVICECAPABILITIES,"HDR")}),T(C,"setAssetID",function(){void 0!==this._assetID&&null!==this._assetID&&this.setStreamID(this.attributes.ASSETID,this._assetID),void 0!==this._assetName&&null!==this._assetName&&this.setStreamID(this.attributes.ASSETNAME,this._assetName),this._videoId&&this.setStreamID(this.attributes.VIDEOID,this._videoId)}),T(C,"uuidv4_subscriberID",function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})}),T(C,"setSubscriberID",function(){this._subscriberID&&(this._hashSubscriberID?this.setStreamID(this.attributes.SUBSCRIBERID,g().mm_md5(this._subscriberID)):this.setStreamID(this.attributes.SUBSCRIBERID,this._subscriberID))}),T(C,"setSubscriberType",function(){this._subscriberType&&this.setStreamID(this.attributes.SUBSCRIBERTYPE,this._subscriberType)}),T(C,"setSubscriberTag",function(){this._subscriberTag&&this.setStreamID(this.attributes.SUBSCRIBERTAG,this._subscriberTag)}),T(C,"setVideoDuration",function(e){e&&(this._totalDuration=e,this.setStreamInfo(this.attributes.TOTALDURATION,parseFloat(e.toFixed(2))))}),T(C,"reportStreamInfo",function(e,t,i){e&&(this._streamFormat=e,this.setStreamInfo(this.attributes.STREAMFORMAT,e)),t&&(this._mediaType=t,this.setStreamID(this.attributes.MEDIATYPE,t)),i&&(this._sourceType=i,this.setStreamID(this.attributes.SOURCETYPE,i))}),T(C,"reportNetworkInfo",function(e,t,i,r){r&&(this._deviceOperator=r),i&&(this._networkType=i),this.setClientInfo(this.attributes.ASN,e),this.setClientInfo(this.attributes.HOSTNAME,t),this.setClientInfo(this.attributes.NETWORKTYPE,this._networkType),this.setClientInfo(this.attributes.OPERATOR,this._deviceOperator)}),T(C,"setPresentationType",function(e){this.setStreamID(this.attributes.ISLIVE,e)}),T(C,"setPresentationStreamInfo",function(e,t,i,r,a,s){this.setStreamInfo(this.getAttribute().MAXRES,e),this.setStreamInfo(this.getAttribute().MINRES,t),this.setStreamInfo(this.getAttribute().MAXFPS,parseFloat(i)),this.setStreamInfo(this.getAttribute().MINFPS,parseFloat(r)),this.setStreamInfo(this.getAttribute().NUMPROFILE,a),s&&this.setStreamInfo(this.getAttribute().STREAMFORMAT,s)}),T(C,"reportTrackinfo",function(e,t,i,r,a){var s=t;if(a||(s="OFF"),this.setStreamInfo(this.getAttribute().VIDEOTRACK,e),this.setStreamInfo(this.getAttribute().SUBTITLETRACK,s),this.setStreamInfo(this.getAttribute().AUDIOTRACK,i),this.setStreamInfo(this.getAttribute().ISVDSACTIVE,r),this.setStreamInfo(this.getAttribute().ISSUBTITLEACTIVE,a),s&&s!=this._prevSubtitleTrack){var n="Prev: "+this._prevSubtitleTrack+", New: "+s;this.notifyEvent("SUBTITLE_CHANGE",n,"SUBTITLE_CHANGE",this._pbTime),this._prevSubtitleTrack=s}i&&i.length>0&&i!=this._prevAudioTrack&&(n="Prev: "+this._prevAudioTrack+", New: "+i,this.notifyEvent("AUDIO_CHANGE",n,"AUDIO_CHANGE",this._pbTime),this._prevAudioTrack=i)}),T(C,"reportComponent",function(e){this._component=e}),T(C,"reportSDKVersion",function(e){this._sdkVersion=S.sdkVersion+e}),T(C,"getSDKVersion",function(){return this._sdkVersion}),T(C,"reportHintFileVersion",function(e){this._hintFileVersion=e}),T(C,"setBuffering",function(){var e=this.getCurrentTimeinMs();this._bufferStartTime&&(this._buffWait=e-this._bufferStartTime,this._sumBuffWait=this._sumBuffWait+this._buffWait,this._seekState===m.SeekStarted?(this._sumBuffWaitVRT=this._sumBuffWaitVRT+this._buffWait,this._buffWaitType="VRT"):(this._sumBuffWaitCIRR=this._sumBuffWaitCIRR+this._buffWait,this._buffWaitType="CIR
2R",this._epocTime+=this._buffWait),this.setPBStats(this.attributes.BUFFERING,this._buffWait),this.setBufPBEvent(this.attributes.SUMBUFFERING,this._sumBuffWait),this.setBufPBEvent(this.attributes.SUMBUFFERINGCIRR,this._sumBuffWaitCIRR),this.setBufPBEvent(this.attributes.SUMBUFFERINGVRT,this._sumBuffWaitVRT),this.setBufPBEvent(this.attributes.SUMBUFFERINGAAD,this._sumBuffWaitAAD))}),T(C,"setAdBuffering",function(){try{var e=this.getCurrentTimeinMs();e=this.getCurrentTimeinMs(),this._adBufferStartTime&&(this._adBuffWaitForInterval=e-this._adBufferStartTime,this._adSumBuffWait=this._adSumBuffWait+this._adBuffWaitForInterval,this._seekState===m.SeekStarted?this._adSumBuffWaitVRT=this._adSumBuffWaitVRT+this._adBuffWaitForInterval:this._adSumBuffWaitCIRR=this._adSumBuffWaitCIRR+this._adBuffWaitForInterval,this._adBufferStartTime=0)}catch(e){console.log("Exception in setting ad buffering")}}),T(C,"setSeek",function(){var e=this.getCurrentTimeinMs();void 0!==this._pauseStartTime&&this._pauseStartTime>0&&(this._pauseStartTime<this._seekStartTime?this._pauseStartTime+=e-this._seekStartTime:this._pauseStartTime=this.getCurrentTimeinMs()),void 0!==this._seekStartTime&&this._seekStartTime>0&&(this._seekDuration=e-this._seekStartTime,this.setBufPBEvent(this.attributes.SEEKDURATION,this._seekDuration))}),T(C,"setCurrentTimeDelta",function(){var e=(new Date).getTime();this._baseServerTimeStampMS&&(this._baseServerTimeStampMS>e?(this._timeShift=-1,this._timeDeltaInMs=this._baseServerTimeStampMS-e):(this._timeShift=1,this._timeDeltaInMs=e-this._baseServerTimeStampMS))}),T(C,"getCorrectedCurrentTimeinMs",function(){var e=(new Date).getTime();return this._timeShift>0?e-this._timeDeltaInMs:e+this._timeDeltaInMs}),T(C,"getCurrentTimeinMs",function(){return(new Date).getTime()}),T(C,"setPostInterval",function(e){this._postInterval=e}),T(C,"stopMonitoring",function(){this._enableEP=!1,this._lastStatsPostedAtTS=0,this._statsMonitorStartedAtTS=0,this._timerObj&&clearInterval(this._timerObj),this._timerObj2&&clearInterval(this._timerObj2),this._timerObj=null,this._timerObj2=null,this._timerTimestampSynchro&&clearInterval(this._timerTimestampSynchro),this._timerTimestampSynchro=null}),T(C,"startMonitoringForSES",function(){this.sesRequirements&&(this&&this.sesRequirements.isToolbox&&null===this._timerObj2&&this._producerURLSES&&(this._timerObj2=setInterval(this.sendHeartbeatToToolbox.bind(this),3e5)),this&&this.sesRequirements.isStarz&&null===this._timerObj2&&this._producerURLSES&&(this._timerObj2=setInterval(this.sendHearbeatToStarz.bind(this),6e4)))}),T(C,"startMonitoring",function(){if("SUCCESS"===this._regStatus){this._enableEP=!0,null===this._timerObj&&this.getEPState()===D.STARTED&&this._postInterval>0&&this._producerURL&&(this._timerObj=setInterval(this.sendQBRStats.bind(this),1e3*this._postInterval),this.sesRequirements&&this.sesRequirements.isToolbox&&null===this._timerObj2&&this._producerURLSES&&(this._timerObj2=setInterval(this.sendHeartbeatToToolbox.bind(this),3e5)),this.sesRequirements&&this.sesRequirements.isStarz&&null===this._timerObj2&&this._producerURLSES&&(this._timerObj2=setInterval(this.sendHearbeatToStarz.bind(this),6e4)));try{this._statsMetric&&this._statsMetric.qubitData&&this._statsMetric.qubitData.length>0&&this._statsMetric.qubitData[this._recordIndex]&&(this._statsMetric.qubitData[this._recordIndex].segInfo=[],this._prevSegInfo&&this._prevSegInfo.cbrBitrate&&(this._prevSegInfo.timestamp=this.getCorrectedCurrentTimeinMs(),this._statsMetric.qubitData[this._recordIndex].segInfo.push(this._prevSegInfo)))}catch(e){}this._lastStatsPostedAtTS=0,this._statsMonitorStartedAtTS=this.getCurrentTimeinMs()}}),T(C,"getChecksum",function(e,t,i){var r=g().mm_md5(e+t+i+this._eventCount);return this._eventCount++,r.substr(8,8)+r.substr(24,8)+r.substr(0,8)+r.substr(16,8)}),T(C,"cloneAndReplaceAttributes",function e(t){var i={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){var s=void 0!==I&&void 0!==I[a]?I[a]:a,n=t[a];Array.isArray(n)?i[s]=n.map(function(t){return"object"===r(t)&&null!==t?e(t):t}):"object"===r(n)&&null!==n?i[s]=e(n):i[s]=n}return i}),T(C,"sendEventInfo",function(){if(void 0!==this._producerURL){if("FAILED"!==this._regStatus){for(var e=0;e<this._eventToSend.length;e++){var t=this._eventToSend[e];if(t&&t.qubitData[this._recordIndex].streamID){if(!0===this._isFirstBatch?(t.timestamp=this.getCorrectedCurrentTimeinMs(),t.qubitData[this._recordIndex].pbInfo[0].timestamp=t.timestamp,t.qubitData[this._recordIndex].streamID.mode=this._mode,t.interval=this._postInterval):(isNaN(t.timestamp)||void 0===t.timestamp||null===t.timestamp)&&(t.timestamp=this.getCorrectedCurrentTimeinMs()),"ONLOAD"===t.qubitData[this._recordIndex].pbEventInfo.event)this._onLoadSentAtTS=t.timestamp,this._modeFromResponse&&(t.qubitData[this._recordIndex].streamID.mode=this._modeFromResponse);else if("BUFFERING"!==t.qubitData[this._recordIndex].pbEventInfo.event&&"SEEKED"!==t.qubitData[this._recordIndex].pbEventInfo.event)this._modeFromResponse&&(t.qubitData[this._recordIndex].streamID.mode=this._modeFromResponse);else{if(null===this._mode)return;t.qubitData[this._recordIndex].streamID.mode=this._mode}if(this._onLoadSentAtTS&&"START"===t.qubitData[this._recordIndex].pbEventInfo.event){if(null===this._mode||(this._modeFromResponse=this._mode,-1===this._totalDuration&&void 0===t.qubitData[this._recordIndex].streamID.isLive&&(t.qubitData[this._recordIndex].streamID.isLive=!0),void 0===t.qubitData[this._recordIndex].streamID.isLive&&this._totalDuration>=0&&(t.qubitData[this._recordIndex].streamID.isLive=!1),void 0===t.qubitData[this._recordIndex].streamID.isLive))return;t.qubitData[this._recordIndex].streamID.mode=this._mode}if(0===t.qubitData[this._recordIndex].pbEventInfo.event.indexOf("AD_")&&(t.qubitData[this._recordIndex].streamID.mode=void 0),0===t.qubitData[this._recordIndex].pbEventInfo.event.indexOf("AD_")){if(!this._enableAdQoE)return void(this._eventToSend[e]=null)}else if(!this._enableVideoQoE)return void(this._eventToSend[e]=null);console.log("EVENT == ",t.qubitData[this._recordIndex].pbEventInfo.event),t.qubitData[this._recordIndex].streamID.pId=this.getChecksum(this._customerID,this.sessionId,t.timestamp),this._onLoadSentAtTS>0&&(t.qubitData[this._recordIndex].streamID.sst=this._onLoadSentAtTS);var i=JSON.stringify(this.cloneAndReplaceAttributes(t)),r=!1;if("u">typeof pako)try{i=pako.gzip(i),r=!0}
2catch(e){console.error("MMError: Error compressing event payload: ",e)}var a=new XMLHttpRequest;a.open("POST",this._producerURL,!0),a.timeout=this._httpPostTimeout,a.setRequestHeader("Content-type","application/json"),r&&a.setRequestHeader("Content-Encoding","gzip"),a.send(i),this._eventToSend[e]=null,this._secondaryProducerList&&this._secondaryProducerList.length>0&&this.sendDataToSecondaryProducerList(i,r)}}this._isFirstBatch=!1,this._eventToSend=[]}}else this._eventToSend.length>this._maxEventsInQ&&this._eventToSend.splice(this._maxEventsInQ-4,2)}),T(C,"sendQBRStats",function(){if("FAILED"!==this._regStatus&&this._enableVideoQoE&&("PENDING"===this._regStatus||this._enableEP&&this.getEPState()===D.STARTED)){if(!1===this._bwExtSet){var e=this._avgDownloadRate/this._downloadRateCount;!isNaN(e)&&e>0&&this.setPBStats(this.attributes.BANDWIDTH,e),this._downloadRateCount=0,this._avgDownloadRate=0}if(this._totalDuration>0&&(this._progressMark=this._pbTime/this._totalDuration*100,this.setPBStats(this.attributes.PROGRESSMARK,parseFloat(this._progressMark.toFixed(2)))),!this._isVideoPaused){if(this._statsMetric&&this._statsMetric.pbTime>-1&&parseFloat(this._statsMetric.pbTime.toFixed(2))===parseFloat(this._pbTime.toFixed(2)))return;this._prevSegInfo&&this._prevSegInfo.cbrBitrate&&this._statsMetric.qubitData[this._recordIndex].segInfo&&this._statsMetric.qubitData[this._recordIndex].segInfo.length>1&&(this._prevSegInfo.timestamp=this.getCorrectedCurrentTimeinMs(),this._statsMetric.qubitData[this._recordIndex].segInfo.push(this._prevSegInfo))}this._segINfoStatus=!1,this._bwExtSet=!1,this._statsMetric.timestamp=this.getCorrectedCurrentTimeinMs(),this._statsMetric.pbTime=parseFloat(this._pbTime.toFixed(2)),this._isVideoPaused||(this._statsMetric.playDur=this.getPlayDur());var t=this._statsMonitorStartedAtTS?this.getCurrentTimeinMs()-this._statsMonitorStartedAtTS:0;if(t=this._lastStatsPostedAtTS?this.getCurrentTimeinMs()-this._lastStatsPostedAtTS:t,this._statsMetric.interval=parseInt(t?t/1e3:0),"PENDING"===this._regStatus||this._statsMetric.interval){this._upshiftCount>0&&this.setPBStats(this.attributes.UPSHIFTCOUNT,this._upshiftCount),this._downshiftCount>0&&this.setPBStats(this.attributes.DOWNSHIFTCOUNT,this._downshiftCount),this._statsMetric.qubitData[this._recordIndex].streamID.pId=this.getChecksum(this._customerID,this.sessionId,this._statsMetric.timestamp),this._onLoadSentAtTS>0&&(this._statsMetric.qubitData[this._recordIndex].streamID.sst=this._onLoadSentAtTS);var i=this._statsMetric;this._isVideoPaused&&(i=this.convertStatsToPingPayload(i));var r=JSON.stringify(this.cloneAndReplaceAttributes(i));if(this._statsMetric.qubitData[this._recordIndex].segInfo=[],this._statsMetric.qubitData[this._recordIndex].pbInfo=[],this._statsToSend.push(r),this._prevSegInfo&&this._prevSegInfo.cbrBitrate&&(this._prevSegInfo.timestamp=this.getCorrectedCurrentTimeinMs(),this._statsMetric.qubitData[this._recordIndex].segInfo.push(this._prevSegInfo)),void 0!==this._producerURL){for(var a=0;a<this._statsToSend.length;a++){var s=this._statsToSend[a],n=!1;if("u">typeof pako)try{s=pako.gzip(s),n=!0}catch(e){console.error("MMError: Error compressing event payload: ",e)}var o=new XMLHttpRequest;o.open("POST",this._producerURL,!0),o.timeout=this._httpPostTimeout,o.setRequestHeader("Content-type","application/json"),n&&o.setRequestHeader("Content-Encoding","gzip"),o.send(s),this._lastStatsPostedAtTS=this.getCurrentTimeinMs(),this._statsToSend[a]=null,this._secondaryProducerList&&this._secondaryProducerList.length>0&&this.sendDataToSecondaryProducerList(s,n)}this._statsToSend=[]}else this._statsToSend.length>this._maxEventsInQ&&this._statsToSend.splice(this._maxEventsInQ-4,2)}}}),T(C,"convertStatsToPingPayload",function(e){var t=e.qubitData[0].streamID,i={};t&&(t.custId&&(i[this.attributes.CUSTID]=t[this.attributes.CUSTID]),t.sessionId&&(i[this.attributes.SESSIONID]=t[this.attributes.SESSIONID]),t.pId&&(i.pId=t.pId),t.sst&&(i.sst=t.sst),t.subscriberId&&(i[this.attributes.SUBSCRIBERID]=t[this.attributes.SUBSCRIBERID]),i[this.attributes.DATASOURCE]="Player-ping");var r=JSON.parse(JSON.stringify(e));return r.qubitData=[{streamID:i}],r}),T(C,"sendDataToSecondaryProducerList",function(e,t){try{var i=this;this._secondaryProducerList.forEach(function(r){var a=new XMLHttpRequest;a.open("POST",r,!0),a.timeout=i._httpPostTimeout,a.setRequestHeader("Content-type","application/json"),t&&a.setRequestHeader("Content-Encoding","gzip"),a.send(e)})}catch(e){console.error("MMError: Error sending data to secondary producer list: ",e)}}),T(C,"getPlayDur",function(){var e=this.getCurrentTimeinMs();return this._pauseStartTime>0||this._seekStartTime>0||this._bufferStartTime>0||this._adPauseStartTime>0||(0!==this._epocTime?e>this._epocTime&&(this._playDur=parseInt((e-this._epocTime)/1e3)):this._playDur=0),this._playDur}),T(C,"getAdPlayDur",function(){var e=0;return this._adInformation&&(e=this._adInformation._adPlayDur),e}),T(C,"getAttribute",function(){return this.attributes}),T(C,"SegmentInfo",function(e,t,i,r,a,s,n,o,d,l,u,h,c,_,p){return{res:e,qbrBitrate:void 0!==t&&t>0?t:0,cbrBitrate:void 0!==i&&i>0?i:0,qbrQual:void 0!==r?parseFloat(r.toFixed(2)):0,cbrQual:void 0!==a?parseFloat(a.toFixed(2)):0,dur:void 0!==s?s:0,seqNum:void 0!==n?n:0,startTime:void 0!==o?o:0,fps:void 0!==d?d:0,cbrProfileNum:void 0!==u?u:0,profileNum:void 0!==l?l:0,cbrSize:void 0!==h?Math.floor(h):0,qbrSize:void 0!==c?Math.floor(c):0,v
2Codec:void 0!==_?_:"",aCodec:void 0!==p?p:""}}),T(C,"EventMetricTemplate",function(){return{streamID:{},pbEventInfo:{},streamInfo:{},contentMetadata:{},sdkInfo:{},pbInfo:[]}}),T(C,"QBRMetricTemplate",function(){return{streamID:{},streamInfo:{},contentMetadata:{},segInfo:[],pbInfo:[],sdkInfo:{}}}),T(C,"resetAdvertisementInfo",function(){this._adInformation._adResolution=void 0,this._adInformation._adClient=void 0,this._adInformation._adId=void 0,this._adInformation._adDuration=void 0,this._adInformation._adPosition=void 0,this._adInformation._adLinear=void 0,this._adInformation._adCreativeType=void 0,this._adInformation._adServer=void 0,this._adInformation._prevAdState=void 0,this._adInformation._adPlaybackTime=void 0,this._adInformation._adCreativeId=void 0,this._adInformation._adTitle=void 0,this._adInformation._adBitrate=void 0,this._adInformation._adUrl=void 0,this._adInformation._playSent=!1,this._adInformation._adPlaybackStartWallClockTime=void 0,this._adInformation._adPlayDur=0,this._adInformation._adLastPlayingEventTimeStamp=-1,this._adInformation._adLastAdEventTimeStamp=-1,this._adInformation._isBumper=!1,this._adInformation._adPodIndex=-2,this._adInformation._adPodLength=-1,this._adInformation._adPositionInPod=-1,this._adInformation._adScheduledTime=-1,this._adEpocTime=0,this._adPauseStartTime=0,this._adStartEpocTime=0,this._adLoadTime=0,this._adStartEpocTime=0,this._adBuffWaitForInterval=0,this._adSumBuffWait=0,this._adSumBuffWaitCIRR=0,this._adSumBuffWaitVRT=0,this._adPauseDuration=0,this._adPauseDurationToOffsetFromInterval=0,this._adLoadStartTime=0}),T(C,"resetForNewAd",function(){this._adInformation._prevAdState=null,this._adInformation._adPlaybackTime=-1,this._adInformation._playSent=!1,this._adInformation._adPlaybackStartWallClockTime=-1,this._adInformation._adLastPlayingEventTimeStamp=-1,this._adInformation._adLastAdEventTimeStamp=-1,this._adInformation._adPlayDur=0,this._adInformation._adPodIndex=-2,this._adInformation._adPodLength=-1,this._adInformation._adPositionInPod=-1,this._adInformation._adCreativeId=void 0,this._adInformation._adTitle=void 0,this._adInformation._adBitrate=void 0,this._adInformation._adUrl=void 0,this._adEpocTime=0,this._adPauseStartTime=0,this._adStartEpocTime=0,this._adLoadTime=0,this._adStartEpocTime=0,this._adBuffWaitForInterval=0,this._adSumBuffWait=0,this._adSumBuffWaitCIRR=0,this._adSumBuffWaitVRT=0,this._adPauseDuration=0,this._adPauseDurationToOffsetFromInterval=0,this._adLoadStartTime=0}),T(C,"sendAdPlayingEvent",function(e,t){if(null!=this._adInformation&&this._adInformation._playSent&&this._adInformation._prevAdState!=c.AD_PAUSED){var i=parseInt((e-this._adInformation._adPlaybackStartWallClockTime)/1e3);(t||i>0&&i%(this._KAdKeepAliveInterval/1e3)==0)&&(this._adInformation._adPlaybackStartWallClockTime=e,this.populateAdRelatedInfo(e),this.notifyEvent("AD_PLAYING","AD KEEP ALIVE","AD_PLAYING",this.millisecToSec(this._adInformation._adPlaybackTime)),this._adInformation._adLastPlayingEventTimeStamp=e,this._adInformation._adLastAdEventTimeStamp=this.getCurrentTimeinMs())}}),T(C,"resetAdInfoIfInitialState",function(e){null==this._adInformation&&(this._adInformation=new y),e==c.AD_REQUEST||null==this._adInformation._prevAdState?(this.resetAdvertisementInfo(),this._adLoadStartTime=this._adPauseStartTime=this._adPauseDuration=this._adLoadTime=0,this._adBuffWaitForInterval=this._adSumBuffWait=this._adSumBuffWaitCIRR=this._adSumBuffWaitVRT=0):e==c.AD_IMPRESSION&&this._adInformation._prevAdState!=c.AD_STARTED&&this._adInformation._prevAdState!=c.AD_REQUEST&&this._adInformation._prevAdState!=c.AD_IMPRESSION&&(this.resetForNewAd(),this._adLoadStartTime=this._adPauseStartTime=this._adPauseDuration=this._adLoadTime=0,this._adBuffWaitForInterval=this._adSumBuffWait=this._adSumBuffWaitCIRR=this._adSumBuffWaitVRT=0);var t=Math.ceil(this._pbTime+3);null!=this._adInformation._adPosition&&null!=this._adInformation._adPosition||(this.getEPState()==D.STARTED||this._pbTime<=1?this._adInformation._adPosition="pre":!this._adInformation.prevAdState&&this._adInformation.prevAdState!=p.STOPPED&&this._pbTime>0&&t<this._totalDuration?this._adInformation._adPosition="mid":(!this._adInformation.prevAdState&&this._adInformation.prevAdState==p.STOPPED||this._pbTime>0&&t>=this._totalDuration)&&(this._adInformation._adPosition="post")),this._adInformation._prevAdState=e}),T(C,"populateAdRelatedInfo",function(e){this._adInformation&&(void 0===this._eventMetric.qubitData[this._recordIndex].adInfo&&(this._eventMetric.qubitData[this._recordIndex].adInfo={}),void 0!==this._adInformation._adClient&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adClient=this._adInformation._adClient),void 0!==this._adInformation._adId&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adId=this._adInformation._adId),void 0!==this._adInformation._adDuration&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adDuration=parseFloat((this._adInformation._adDuration/1e3).toFixed(2))),void 0!==this._adInformation._adPosition&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adPosition=this._adInformation._adPosition),void 0!==this._adInformation._adLinear&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adLinear=this._adInformation._adLinear),void 0!==this._adInformation._adCreativeType&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adCreativeType=this._adInformation._adCreativeType),void 0!==this._adInformation._adServer&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adSystem=this._adInformation._adServer),void 0!==this._adInformation._adResolution&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adResolution=this._adInformation._adResolution),void 0!==this._adInformation._adTitle&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adTitle=this._adInformation._adTitle),void 0!==this._adInformation._adBitrate&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adBitrate=this._adInformation._adBitrate),void 0!==this._adInformation._adUrl&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adUrl=this._adInformation._adUrl),void 0!==this._adInformation._adCreativeId&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adCreativeId=this._adInformation._adCreativeId),this._adInformation._adPodLength>0&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adPodLength=this._adInformation._adPodLength),this._adInformation._adPodIndex>=-1&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adPodIndex=this._adInformation._adPodIndex),this._adInformation._adPositionInPod>0&&(this._eventMetric.qubitData[this._recordIndex].adInfo.adPodPosition=this._adInformation._adPositionInPod),this._eventMetric.qubitData[this._recordIndex].adInfo.isBumper=this._adInformation._isBumper,this._eventMetric.qubitData[this._recordIndex].adInfo.adInterval=this.getAdInterval(e))}),T(C,"getAdInterval",function(e){var t=0;return null!=this._adInformation&&this._adInformation._adLastAdEventTimeStamp>0&&(null!=this._adPauseStartTime&&this._adPauseStartTime>0&&(e=this._adPauseStartTime),t=(e-this._adInformation._adLastAdEventTimeStamp)/1e3),this._adPauseDurationToOffsetFromInterval>0&&(t-=this._adPauseDurationToOffsetFromInterval/1e3,this._adPauseDurationToOffsetFromInterval=0),this._adBuffWaitForInterval>0&&(t-=this._adBuffWaitForInterval/1e3,this._adInformation._adPlayDur+=this._adBuffWaitForInterval/1e3,this._adBuffWaitForInterval=0),t<0&&(t=0),this._adInformation._adPlayDur+=t,t}),T(C,"millisecToSec",function(e){return parseFloat(e/1e3).toFixed(2)}),T(C,"reportAdState",function(e){var t=this.getCurrentTimeinMs();switch(this.resetAdInfoIfInitialState(e),this.populateAdRelatedInfo(t),e){case c.AD_BLOCKED:this.notifyEvent("AD_BLOCK","Ad blocked","AD_BLOCK",0);break;case c.AD_IMPRESSION:this._adLoadStartTime=t,this._adPauseStartTime=-1,this.notifyEvent("AD_IMPRESSION","Ad impression has been made","AD_IMPRESSION",0);break;case c.AD_STARTED:case c.AD_PLAY:0==this._adInformation._playSent&&(this._adInformation._playSent=!0,this._adLoadStartTime>0&&(this.loadStartTime>0&&(this._adLoadStartTime,this.loadStartTime),this._adLoadTime=t-this._adLoadStartTime,this._adPauseDuration>0&&(this._adLoadTime-=this._adPauseDuration),this._adLoadTime<0&&(this._adLoadTime=0),this._adInformation._adPlayDur+=Math.ceil(this._adLoadTime/1e3)),this.populateAdRelatedInfo(t),this.setPBStats(this.attributes.LATENCY,this._adLoadTime),this.notifyEvent("AD_PLAY","Ad Playback started","AD_PLAY",0),this.adLoadStartTime=0,this._adInformation._adLastPlayingEventTimeStamp=this._adInformation._adPlaybackStartWallClockTime=this.getCurrentTimeinMs(),this._adInformation._adLastAdEventTimeStamp=this._adInformation._adLastPlayingEventTimeStamp);break;case c.AD_CLICKED:this.notifyEvent("AD_CLICK","Ad has been clicked","AD_CLICK",this.millisecToSec(this._adInformation._adPlaybackTime)),this._adInformation._adLastAdEventTimeStamp=t;break;case c.AD_PAUSED:this.sendQBRStats(),this._adPauseStartTime=this.getCurrentTimeinMs(),this.notifyEvent("AD_PAUSED","Ad has been paused","AD_PAUSED",this.millisecToSec(this._adInformation._adPlaybackTime)),this._adInformation._adLastAdEventTimeStamp=t,this._isVideoPaused=!0;break;case c.AD_RESUMED:this._adPauseStartTime>0&&(this._adPauseDuration=t-this._adPauseStartTime,this._adPauseDuration<0&&(this._adPauseDuration=0),this._adPauseDurationToOffsetFromInterval=this._adPauseDuration),this._isVideoPaused=!1,this.setPBStats(this.attributes.PAUSEDURATION,this._adPauseDuration),this.populateAdRelatedInfo(t),this.notifyEvent("AD_RESUMED","Ad has been resumed","AD_RESUMED",this.millisecToSec(this._adInformation._adPlaybackTime)),this.startMonitoring(),this._adInformation._adLastAdEventTimeStamp=t,this._adPauseStartTime=-1;break;case c.AD_SKIPPED:this.setAdBuffering(),this.notifyEvent("AD_SKIPPED","Ad has been skipped","AD_SKIPPED",this.millisecToSec(this._adInformation._adPlaybackTime)),this._adInformation._adLastAdEventTimeStamp=t;break;case c.AD_COMPLETED:this._adInformation._adDuration>0&&(this._adInformation._adPlaybackTime-90*this._adInformation._adDuration/100>=0||2>Math.abs(this._adInformation._adPlaybackTime-this._adInformation._adDuration))?(this.setAdBuffering(),this.notifyEvent("AD_COMPLETE","Ad completed playing","AD_COMPLETE",this.millisecToSec(this._adInformation._adPlaybackTime))):(this.setAdBuffering(),this.notifyEvent("AD_ENDED","Ad ended","AD_ENDED",this.millisecToSec(this._adInformation._adPlaybackTime))),this._adInformation._playSent=!1,this._adInformation._adLastAdEventTimeStamp=t;break;
2case c.AD_ENDED:this.setAdBuffering(),this.notifyEvent("AD_ENDED","Ad ended","AD_ENDED",this.millisecToSec(this._adInformation._adPlaybackTime)),this._adInformation._playSent=!1,this._adInformation._adLastAdEventTimeStamp=t;break;case c.AD_ERROR:this.notifyEvent("AD_ERROR",event.message,"AD_ERROR",this.millisecToSec(this._adInformation._adPlaybackTime)),this._adInformation._playSent=!1,this._adInformation._adLastAdEventTimeStamp=t;break;case c.AD_REQUEST:this.notifyEvent("AD_REQUEST","Ad has been requested","AD_REQUEST",0);break;case c.AD_PLAYING:this.sendAdPlayingEvent(t,!1);break;case c.AD_FIRST_QUARTILE:this.notifyEvent("AD_PLAYED_FIRST_QUARTILE","Ad reached first quartile","AD_PLAYED_FIRST_QUARTILE",this.millisecToSec(this._adInformation._adPlaybackTime)),this._adInformation._adLastAdEventTimeStamp=t;break;case c.AD_MIDPOINT:this.notifyEvent("AD_PLAYED_SECOND_QUARTILE","Ad reached midpoint","AD_PLAYED_SECOND_QUARTILE",this.millisecToSec(this._adInformation._adPlaybackTime)),this._adInformation._adLastAdEventTimeStamp=t;break;case c.AD_THIRD_QUARTILE:this.notifyEvent("AD_PLAYED_THIRD_QUARTILE","Ad reached third quartile","AD_PLAYED_THIRD_QUARTILE",this.millisecToSec(this._adInformation._adPlaybackTime)),this._adInformation._adLastAdEventTimeStamp=t}}),T(C,"reportAdError",function(e,t){this.populateAdRelatedInfo(),null==t&&(t=this._adInformation._adPlaybackTime),void 0===t&&(t=0),this.notifyEvent("AD_ERROR",e,"AD_ERROR",this.millisecToSec(t))}),T(C,"reportAdPlaybackTime",function(e){if(e>=0&&this._adInformation){var t=this.getCurrentTimeinMs();this._adInformation._adPlaybackTime=e,this.sendAdPlayingEvent(t,!1)}}),T(C,"reportAdInfo",function(e){this._adInformation||(this._adInformation=new y),e&&(void 0!==e.adClient&&(this._adInformation._adClient=e.adClient),void 0!==e.adId&&(this._adInformation._adId=e.adId),void 0!==e.adDuration&&(this._adInformation._adDuration=e.adDuration),void 0!==e.adPosition&&(this._adInformation._adPosition=e.adPosition),void 0!==e.adIsLinear&&(e.adIsLinear?this._adInformation._adLinear="linear":this._adInformation._adLinear="nonlinear"),void 0!==e.adCreativeType&&(this._adInformation._adCreativeType=e.adCreativeType),void 0!==e.adServer&&(this._adInformation._adServer=e.adServer),void 0!==e.adResolution&&(this._adInformation._adResolution=e.adResolution),this._adInformation._isBumper=e.isBumper,e.adPodIndex>=-1&&(this._adInformation._adPodIndex=e.adPodIndex),e.adPodLength>0&&(this._adInformation._adPodLength=e.adPodLength),e.adPositionInPod>0&&(this._adInformation._adPositionInPod=e.adPositionInPod),e.adScheduledTime>=0&&(this._adInformation._adScheduledTime=e.adScheduledTime),void 0!==e.adUrl&&(this._adInformation._adUrl=e.adUrl),void 0!==e.adCreativeId&&(this._adInformation._adCreativeId=e.adCreativeId),void 0!==e.adTitle&&(this._adInformation._adTitle=e.adTitle),void 0!==e.adBitrate&&(this._adInformation._adBitrate=e.adBitrate))}),T(C,"isQBRDisabled",function(){return null===this._mode||"QBRDisabled-NoMetafile"==this._mode||this._mode==f.QBRModeDisabled||"QBRDisabled-QMetric"==this._mode||"QBRDisabled-NoPresentationInfo"==this._mode||"QBRDisabled-NoABR"==this._mode||"QBRDisabled-LiveSessionNotSupported"==this._mode||"QBRDisabled-ContentNotSupportedForQBR"==this._mode}),function(e,t){for(var i in t)(s=t[i]).configurable=s.enumerable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,i,s);if(Object.getOwnPropertySymbols)for(var r=Object.getOwnPropertySymbols(t),a=0;a<r.length;a++){var s,n=r[a];(s=t[n]).configurable=s.enumerable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,n,s)}}(C,O),C},A=function(){var e=new XMLHttpRequest;return{doGet:function(t,i){return new Promise(function(r,a){void 0!==i&&(t+="?"+Object.keys(i).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(i[e])}).join("&")),e.open("GET",t),e.timeout=25e3,e.onload=function(){200==e.status?r(e.response):a(Error(e.statusText))},e.onerror=function(){a(Error("Network Error"))},e.abort=function(){a(Error("NetRequest Aborted"))},e.ontimeout=function(){a(Error("NetRequest timeout"))},e.send()})},cleanUp:function(){e&&4!=e.readyState&&e.abort()}}},P=function(){var e,t=[],i=[];function r(e,t){for(var r in i){var a=i[r];if(a.context===e&&a.name===t)return a.instance}return null}function a(t,i,r,a){var n=s(r)[t];if(n){var o=n.instance;if(!n.override)return o.apply({context:r,factory:e},a);for(var d in o=o.apply({context:r,factory:e,parent:i},a))i.hasOwnProperty(d)&&(i[d]=o[d])}return i}function s(e){var i;return t.forEach(function(t){t===e&&(i=t)}),i||(i=t.push(e)),i}return e={extend:function(e,t,i,r){var a=s(r);!a[e]&&t&&(a[e]={instance:t,override:i})},getSingletonInstance:r,setSingletonInstance:function(e,t,r){for(var a in i){var s=i[a];if(s.context===e&&s.name===t)return void(i[a].instance=r)}i.push({name:t,context:e,instance:r})},getSingletonFactory:function(e){return function(t){var s;return void 0===t&&(t={}),{getInstance:function(){return s||(s=r(t,e.__dashjs_factory_name)),s||(s=a(e.__dashjs_factory_name,e.apply({context:t},arguments),t,arguments),i.push({name:e.__dashjs_factory_name,context:t,instance:s})),s}}}},getClassFactory:function(e){return function(t){return void 0===t&&(t={}),{create:function(){return a(e.__dashjs_factory_name,e.apply({context:t},arguments),t,arguments)}}}}}}(),N=(s=isNaN(S.log_level)?2:S.log_level,n={VERBOSE:6,DEBUG:5,INFO:4,ANALYZE:3,WARN:2,ERROR:1,OFF:0},{setLogLevel:function(e){e<0&&(e=0),s=e},log:function(e,t){(function(e){for(var t in n)if(t===e)return n[t];return n.OFF})(e)<=s&&console.log("["+e+"] : "+t)}}),C=function(){var e=!1,t=new R,i=null,r=!1,a=function(e){r&&console.log("mmTrace:"+(new Date).getTime()+"::"+e)},s=function(r){if(null!=r&&(a(" setPresentationInformation In - live?"+r.isLive+" duration:"+r.duration+" repsCnt:"+r.representationArray.length),1===(i=r).isLive&&(i.isLive=!0),0===i.isLive&&(i.isLive=!1),e)){t.reportMode("QBRDisabled");var s=i.isLive?-1:i.duration/1e3;t.setVideoDuration(s),t.setPresentationType(i.isLive);var n="",o="",d=0,l=0,u=i.representationArray.length,h=i.contentType;if(u)for(var c=0;c<u;c++)i.representationArray[c].width&&i.representationArray[c].height&&i.representationArray[c].width>0&&i.representationArray[c].height>0&&((0===d||d>i.representationArray[c].width*i.representationArray[c].height)&&(o=i.representationArray[c].width+"x"+i.representationArray[c].height,d=i.representationArray[c].width*i.representationArray[c].height),(0===l||l<i.representationArray[c].width*i.representationArray[c].height)&&(n=i.representationArray[c].width+"x"+i.representationArray[c].height,l=i.representationArray[c].width*i.representationArray[c].height));t.setPresentationStreamInfo(n,o,0,0,u,h)}},n=function(e){var i=e.endByte>0?e.endByte-e.startByte:-1,r=void 0,a=void 0,s=e.duration>0?parseInt(e.duration/1e3):-1,n=e.startTime>0?e.startTime/1e3:-1;-1==e.trackIdx?-1!=e.bitrate&&(r=o(e.bitrate),a=d(e.bitrate)):(r=l(e.trackIdx),a=u(e.trackIdx));var h=void 0,c=void 0;return a&&a.video&&(c=a.video),a&&a.audio&&(h=a.audio),t.SegmentInfo(r,e.bitrate,e.bitrate,void 0,void 0,s,e.sequence,n,void 0,e.trackIdx,e.trackIdx,i,void 0,c,h)},o=function(e){var t=h(e),i=void 0;return void 0!==t&&void 0!==t.width&&void 0!==t.height&&t.width>0&&t.height>0&&(i=t.width+"x"+t.height),i},d=function(e){var t=h(e),i=void 0;return t&&(i=t.codecIdentifier),i},l=function(e){var t=c(e),i=void 0;return void 0!==t&&void 0!==t.width&&void 0!==t.height&&t.width>0&&t.height>0&&(i=t.width+"x"+t.height),i},u=function(e){var t=c(e),i=void 0;return t&&(i=t.codecIdentifier),i},h=function(e){var t=void 0;if(i){for(var r=0;r<i.representationArray.length;
2r++)if(i.representationArray[r].bitrate===e){t=i.representationArray[r];break}}return t},c=function(e){var t=void 0;if(i){for(var r=0;r<i.representationArray.length;r++)if(i.representationArray[r].trackIdx===e){t=i.representationArray[r];break}}return t};return{enableLogTrace:function(e){r=e},updateSubscriberID:function(e){t.updateSubscriberID(e)},updateSubscriber:function(e,i,r){t.updateSubscriber(e,i,r)},getRegistrationStatus:function(){return e},getRegistrationStatusWithBackend:function(){return t.getRegistrationStatusWithBackend()},registerMMSmartStreaming:function(i,r,s,n,o,d,l,u){a(" registerMMSmartStreaming In "+i+" "+r+" "+n+" "+o+" "+s),t.reset(),t.registerMMSmartStreaming(i,r,n,o,d,l,u),t.reportHintFileVersion(S.hintFileVersion),t.reportComponent(s),e=!0},initializeSession:function(e,r,n,o){return a(" initializeSession In mode: "+e+" url:"+r+" metaurl: "+n+" contentMetadata:"+o),i=null,t.reset(),t.initializeSession(e,r,n,o).then(function(e){var r=JSON.parse(e);return void 0!==r.producerURL?(t.reportRegistrationSuccess(r),t.reportAssetID(o.assetID,o.assetName,o.videoId),s(i),N.log("VERBOSE"," initializing QEngine"),new Promise(function(e,i){N.log("VERBOSE","InitializeSession Success"),e(r),r&&t.setSDKQoEConfig(r.mmVideo,r.mmAd)})):(t.reportRegistrationFailure(),t.reset(),new Promise(function(e,t){N.log("VERBOSE","Playback Registration Failed"),t("Playback Registration Failed.")}))}).catch(function(e){return"QBRSDK : QEngine cannot be initialized...."!=e?(e="Experience Probe Initialisation Failed.",t.reportRegistrationFailure(),t.reset()):e="MMSmartStreaming :  QBR component cannot be initialized...",s(i),new Promise(function(t,i){N.log("VERBOSE",e),i(e)})})},setPresentationInformation:s,reportStreamInfo:function(e,i,r){t.reportStreamInfo(e,i,r)},reportNetworkInfo:function(e,i,r,a){t.reportNetworkInfo(e,i,r,a)},reportChunkRequest:function(i){if(e){a("reportChunkRequest In");var r=n(i);t.addSegInfo(r)}},reportDownloadRate:function(i){e&&(a(" reportDownloadRate In :"+i),t.setBandwidth(i))},reportBufferLength:function(i){e&&(a(" reportBufferLength In :"+i),t.reportBufferLength(i))},reportCustomMetadata:function(i,r){e&&(a(" reportCustomMetadata In"),t.setCustomTag(i,r))},reportPlaybackPosition:function(i){e&&(a(" reportPlaybackPosition In :"+i),t.setPlaybackPos(i))},reportNetworkType:function(i){e&&(a(" reportNetworkType In"),t.reportNetworkType(i))},reportMetricValue:function(i,r){e&&(a(" reportMetricValue In"),t.reportMetricValue(i,r))},reportStringDimension:function(e,i){a(" reportStringDimension In "+e+" "+i),t.reportStringDimension(e,i)},reportDeviceInfo:function(e,i,r,s,n,o,d,l){a(" reportDeviceInfo In "),t.reportDeviceInfo(e,i,r,s,n,o,d,l),"CHROMECAST"===i?t.reportDeviceType("ChromeCast"):"SMARTTV"===i&&t.reportDeviceType("SmartTV")},reportPlayerInfo:function(e,i,r){a(" reportPlayerInfo In"),t.reportPlayerInfo(e,i,r)},reportAppInfo:function(e,i){a(" reportAppInfo In"),t.reportAppInfo(e,i)},reportPlayerResolution:function(e){a(" reportPlayerResolution In"),t.reportPlayerResolution(e)},reportDeviceCapabilities:function(e){a(" reportdeviceCapabilities In"),t.reportDeviceCapabilities(e)},reportVideoQuality:function(e){a(" reportVideoQuality In"),t.reportVideoQuality(e)},reportExperimentName:function(e){t.reportExperimentName(e)},reportSubPropertyId:function(e){t.reportSubPropertyId(e)},reportViewSessionId:function(e){t.reportViewSessionId(e)},reportAppSessionId:function(e){t.reportAppSessionId(e)},reportBasePlayerInfo:function(e,i){t.reportBasePlayerInfo(e,i)},reportManifestLoaded:function(){a(" reportManifestLoaded In"),t.reportManifestLoaded()},reportDeviceId:function(e){a(" reportDeviceId In"),t.reportDeviceId(e)},reportPlayerState:function(e){a(" reportPlayerState In "+e),t.reportPlayerState(e)},notifyPackager:function(e,i){t.notifyPackager(e,i)},setSESRequirements:function(e){t.setSESRequirements(e)},setSESURL:function(e){t.setSESURL(e)},reportTrackinfo:function(e,i,r,a,s){t.reportTrackinfo(e,i,r,a,s)},reportUserInitiatedPlayback:function(){a(" reportUserInitiatedPlayback In "),t.reportUserInitiatedPlayback()}
2,reportBufferingStarted:function(){a(" reportBufferingStarted In "),t.reportBufferingStarted()},reportBufferingCompleted:function(){a(" reportBufferingCompleted In "),t.reportBufferingCompleted()},reportEventWithValue:function(e,i){t.reportEventWithValue(e,i)},addCustomSegInfo:function(e){t.addCustomSegInfo(e)},reportABRSwitch:function(i,r){e&&t.isQBRDisabled()&&(a(" reportABRSwitch "+i+"->"+r),t.reportABRSwitch(i,r))},reportFrameLoss:function(i){e&&(a(" reportFrameLoss In "+i),t.reportFrameLoss(i))},reportPresentationSize:function(e,i){a("reportPresentationSize w:"+e+" h:"+i),t.reportPresentationSize(e,i)},reportError:function(i,r){e&&(a(" reportError In "+i),t.reportError(i,r))},reportPlayerSeekCompleted:function(i){e&&(a(" reportPlayerSeekCompleted In"),t.reportPlayerSeekCompleted(i))},reportPlayerSeekStarted:function(){e&&(a(" reportPlayerSeekStarted In"),t.reportPlayerSeekStarted())},reportResolutionChange:function(i){e&&(a(" reportResolutionChange In"),t.reportResolutionChange(i))},reportVolumeChange:function(i){e&&(a(" reportVolumeChange In"),t.reportVolumeChange(i))},reportPlaybackRateChange:function(){e&&(a(" reportPlaybackRateChange In"),t.reportPlaybackRateChange())},reportDurationChange:function(){e&&(a(" reportDurationChange In"),t.reportDurationChange())},reportSDKVersion:function(e){t.reportSDKVersion(e)},getSDKVersion:function(){return t.getSDKVersion()},reportWifiSSID:function(i){e&&(a(" reportWifiSSID In"),t.reportWifiSSID(i))},reportWifiSignalStrenthPercentage:function(i){e&&(a(" reportWifiSignalStrenthPercentage In"),t.reportWifiSignalStrenthPercentage(i))},reportWifiDataRate:function(i){e&&(a(" reportWifiDataRate In"),t.reportWifi
2DataRate(i))},reportAdInfo:function(i){e&&(a(" reportAdInfo "),i&&t.reportAdInfo(i))},reportAdError:function(e,i){a(" reportAdError "+e),t.reportAdError(e,i)},reportAdBufferingStarted:function(){a(" reportAdBufferingStarted In "),t.reportAdBufferingStarted()},reportAdBufferingCompleted:function(){a(" reportAdBufferingCompleted In "),t.reportAdBufferingCompleted()},reportAdPlaybackTime:function(i){e&&(a(" reportAdPlaybackTime "+i),t.reportAdPlaybackTime(i))},reportAdState:function(i){e&&(a(" reportAdState "+i),t.reportAdState(i))},reportComponent:function(i){e&&(a(" reportComponent "+i),t.reportComponent(i))},setRegistrationStatus:function(t){e=t},getSessionId:function(){if(e)return t.sessionId}}},O={createInstance:function(e){var t,i=Object.create((t=new C,{getSDKVersion:function(){return t.getSDKVersion()},getRegistrationStatus:function(){return t.getRegistrationStatus()},getRegistrationStatusWithBackend:function(){return t.getRegistrationStatusWithBackend()},registerMMSmartStreaming:function(e,i,r,a,s,n,o,d){return t.registerMMSmartStreaming(e,i,r,a,s,n,o,d)},updateSubscriberID:function(e){return t.updateSubscriberID(e)},reportDeviceInfo:function(e,i,r,a,s,n,o,d){t.reportDeviceInfo(e,i,r,a,s,n,o,d)},reportPlayerInfo:function(e,i,r){t.reportPlayerInfo(e,i,r)},reportDeviceCapabilities:function(e){t.reportDeviceCapabilities(e)},reportAppInfo:function(e,i){t.reportAppInfo(e,i)},reportPlayerResolution:function(e){t.reportPlayerResolution(e)},reportVideoQuality:function(e){t.reportVideoQuality(e)},reportExperimentName:function(e){t.reportExperimentName(e)},reportSubPropertyId:function(e){t.reportSubPropertyId(e)},reportViewSessionId:function(e){t.reportViewSessionId(e)},reportAppSessionId:function(e){t.reportAppSessionId(e)},reportBasePlayerInfo:function(e,i){t.reportBasePlayerInfo(e,i)},reportManifestLoaded:function(){t.reportManifestLoaded()},reportDeviceId:function(e){t.reportDeviceId(e)},initializeSession:function(e,i,r,a){return t.initializeSession(e,i,r,a)},setPresentationInformation:function(e){t.setPresentationInformation(e)},reportStreamInfo:function(e,i,r){t.reportStreamInfo(e,i,r)},reportNetworkInfo:function(e,i,r,a){t.reportNetworkInfo(e,i,r,a)},reportChunkRequest:function(e){t.reportChunkRequest(e)},reportDownloadRate:function(e){t.reportDownloadRate(e)},reportBufferLength:function(e){t.reportBufferLength(e)},reportCustomMetadata:function(e,i){t.reportCustomMetadata(e,i)},reportPlaybackPosition:function(e){t.reportPlaybackPosition(e)},reportNetworkType:function(e){t.reportNetworkType(e)},reportMetricValue:function(e,i){t.reportMetricValue(e,i)},reportStringDimension:function(e,i){t.reportStringDimension(e,i)},reportBufferingStarted:function(){t.reportBufferingStarted()},reportBufferingCompleted:function(){t.reportBufferingCompleted()},reportEventWithValue:function(e,i){t.reportEventWithValue(e,i)},addCustomSegInfo:function(e){t.addCustomSegInfo(e)},reportUserInitiatedPlayback:function(){t.reportUserInitiatedPlayback()},reportPlayerState:function(e){t.reportPlayerState(e)},notifyPackager:function(e,i){t.notifyPackager(e,i)},setSESRequirements:function(e){t.setSESRequirements(e)},setSESURL:function(e){t.setSESURL(e)},reportABRSwitch:function(e,i){t.reportABRSwitch(e,i)},reportFrameLoss:function(e){t.reportFrameLoss(e)},reportPresentationSize:function(e,i){t.reportPresentationSize(e,i)},reportError:function(e,i){t.reportError(e,i)},reportPlayerSeekCompleted:function(e){t.reportPlayerSeekCompleted(e)},reportPlayerSeekStarted:function(){t.reportPlayerSeekStarted()},reportResolutionChange:function(e){t.reportResolutionChange(e)},reportVolumeChange:function(e){t.reportVolumeChange(e)},reportPlaybackRateChange:function(){t.reportPlaybackRateChange()},reportDurationChange:function(){t.reportDurationChange()},reportSDKVersion:function(e){t.reportSDKVersion(e)},reportWifiSSID:function(e){t.reportWifiSSID(e)},reportWifiSignalStrengthPercentage:function(e){t.reportWifiSignalStrenthPercentage(e)}
2,reportWifiDataRate:function(e){t.reportWifiDataRate(e)},reportAdState:function(e){t.reportAdState(e)},reportAdInfo1:function(e,i,r,a,s,n,o,d){t.reportAdInfo(e,i,r,a,s,n,o,d)},reportAdInfo:function(e){t.reportAdInfo(e)},reportAdPlaybackTime:function(e){t.reportAdPlaybackTime(e)},reportAdError:function(e,i){t.reportAdError(e,i)},reportAdBufferingStarted:function(){t.reportAdBufferingStarted()},reportAdBufferingCompleted:function(){t.reportAdBufferingCompleted()},enableLogTrace:function(e){t.enableLogTrace(e)},updateSubscriber:function(e,i,r){return t.updateSubscriber(e,i,r)},setRegistrationStatus:function(e){t.setRegistrationStatus(e)},getSessionId:function(){return t.getSessionId()},reportTrackinfo:function(e,i,r,a,s){return t.reportTrackinfo(e,i,r,a,s)}}));return i.__dashjs_factory_name="MMSmartStreamingSdk",P.setSingletonInstance(e,"MMSmartStreamingSdk",i),i},getInstance:function(e){if(void 0===e)return o||(o=this.createInstance(this));var t=P.getSingletonInstance(e,"MMSmartStreamingSdk");return t||console.log("ERROR MMSDK Instance not created!"),t}};Object.freeze({DASH:"dash",HLS:"hls",MSS:"mss",MP4:"mp4"}),i.SHAKAPlayerMMSSIntgr=function(){var e=Object.freeze({READY:0,PLAYING:1,PAUSED:2,STOPPED:3}),t=Object.freeze({IDLE:1,BUFFERING_STARTED:2,BUFFERING_COMPLETED:3}),i=Object.freeze({IDLE:1,SEEK_STARTED:2,SEEK_COMPLETED:3}),a={1:"NETWORK",2:"TEXT",3:"MEDIA",4:"MANIFEST",5:"STREAMING",6:"DRM",7:"PLAYER",8:"CAST",9:"STORAGE",10:"ADS"},s="SHAKASDK",n=void 0,o=void 0,d=O.createInstance(this),m=void 0,I=void 0,S=t.IDLE,g=i.IDLE,T=!1,b="",y=!1,D=!1,R=void 0,A=!1,P=void 0,N=!1,C=!0,U=!1,M="None",x=!1,w="None",k="None",L=!1,V=void 0,B=function(){m=void 0,T=!1,I=void 0,A=!1,y=!1,S=t.IDLE,g=i.IDLE,D=!1,N=!1,b=""},F=function(e){U&&console.log("[MMLog] => "+e)},q=function(){if(n){var e=[],t=o.duration;if(null==A&&(A=n.isLive()),A||t===1/0||isNaN(t)?t=-1:t*=1e3,void 0!==n.getVariantTracks)for(var i=n.getVariantTracks(),r=0;r<i.length;r++){var a=i[r],s={video:a.videoCodec,audio:a.audioCodec},l=u(r,a.bandwidth,a.width,a.height,s);e.push(l)}var c=h(A,t,e);d.setPresentationInformation(c),y=!0}},G=function(){return o?1e3*o.currentTime:-1},H=function(e){F("initializeMMSDK Called With mmVideoAssetInfo: "+JSON.stringify(e));var t=function(e){var t=[],i={assetId:null,assetName:null,contentType:null,drmProtection:null,episodeNumber:null,genre:null,season:null,seriesTitle:null,videoId:null,videoType:null};if(null!=e&&(e.assetId&&(i.assetId=e.assetId),e.assetName&&(i.assetName=e.assetName),e.videoId&&(i.videoId=e.videoId),e.contentType&&(i.contentType=e.contentType),e.drmProtection&&(i.drmProtection=e.drmProtection),e.episodeNumber&&(i.episodeNumber=e.episodeNumber),e.genre&&(i.genre=e.genre),e.season&&(i.season=e.season),e.seriesTitle&&(i.seriesTitle=e.seriesTitle),e.title&&(i.title=e.title),e.videoType&&(i.videoType=e.videoType),e.customTags))for(var r in e.customTags)t.push({key:r,attributeValue:e.customTags[r]});return{customMeta:t,contentMetadata:i}}(e),i=t.contentMetadata;if(d.initializeSession(f.QBRModeDisabled,b,"",i).catch(function(e){console.log(e)}),t.customMeta&&t.customMeta.length)for(var r=0;r<t.customMeta.length;r++)d.reportCustomMetadata(t.customMeta[r].key,t.customMeta[r].attributeValue);T=!0},z=function(t){F("Load Event"),!1===N&&void 0===m&&(d.reportUserInitiatedPlayback(),m=e.READY,N=!0)},W=function(t){F("Unload Event"),null!=d&&void 0!==m&&m!==e.STOPPED&&(d.reportPlayerState(p.STOPPED),m=e.STOPPED)},K=function(t){if(t)switch(t.type){case"playing":y||q(),d.reportPlayerState(p.PLAYING),m=e.PLAYING;break;case"pause":m!==e.READY&&m!==e.PLAYING||(d.reportPlayerState(p.PAUSED),m=e.PAUSED);break;case"ended":et()}},j=function(){m!==e.PLAYING&&m!==e.PAUSED||S!==t.BUFFERING_STARTED&&(d.reportBufferingStarted(),S=t.BUFFERING_STARTED)},Q=function(){m!==e.PLAYING&&m!==e.PAUSED||g!==i.SEEK_STARTED&&(d.reportPlayerSeekStarted(),g=i.SEEK_STARTED)},Y=function(){S===t.BUFFERING_STARTED&&(d.reportBufferingCompleted(),S=t.BUFFERING_COMPLETED),g===i.SEEK_STARTED&&(d.reportPlayerSeekCompleted(G()),g=i.SEEK_COMPLETED)},$=function(){null!=n&&(V&&V.reportPlaybackPosition(G()),d.reportPlaybackPosition(G()),d.reportDownloadRate(I),d.reportDeviceInfo(void 0,void 0,void 0,void 0,void 0,R,o.clientWidth,o.clientHeight),void 0!==m&&m>e.READY&&G()>5e3&&(!1===y&&q(),!1===D&&ei()))},X=function(e){if(C&&null!=n)try{if(void 0!==e.detail){void 0===m&&d.reportUserInitiatedPlayback();var t=e.detail,i="";if(t.code&&(i+=t.code),t.category){var s=a[t.category]||"UNKNOWN_".concat(t.category);t.category&&(i+="_"+s)}
2t.severity===shaka.util.Error.Severity.CRITICAL?i+="@@FATAL@@":i+="@@WARNING@@";var o=t.data;o&&o.length>1&&"object"===r(o[1])&&(o[1].message&&(i+=o[1].message),o[1].stack&&(i+="_"+o[1].stack));var l=G();d.reportError(i,l>0?l:0)}}catch(e){console.log("MMError:"+e)}},J=function(e){ee(),Z()},Z=function(e){for(var t=n.getTextTracks(),i=0,r=0;r<t.length;r++)if("subtitle"==t[r].kind&&1==t[r].active){M=t[r].language,x=!0,i=1;break}0===i&&(x=!1,M="None"),d.reportTrackinfo(w,M,k,L,x)},ee=function(){for(var e=n.getVariantTracks(),t=0;t<e.length;t++){var i=e[t];if(i.active){k=i.language,L="commentary"===i.roles[0];break}}d.reportTrackinfo(w,M,k,L,x)},et=function(t){null!=n&&(m=e.STOPPED,d.reportPlayerState(p.STOPPED),B())},ei=function(){if(n&&!1===D&&(n.getTracks?P=n.getTracks():n.getVariantTracks&&(P=n.getVariantTracks()),P.active)){d.reportDownloadRate(P.bandwidth);var e=l(void 0,P.bandwidth,void 0,void 0,void 0,void 0,void 0,void 0);d.reportChunkRequest(e),D=!0}},er=function(e){if(n&&n.getStats())var t=n.getStats().streamBandwidth;if(void 0!==I&&t!=I&&d.reportABRSwitch(I,t),d.reportDownloadRate(t),void 0===I||t!=I){var i=l(void 0,t,void 0,void 0,void 0,void 0,void 0,void 0);d.reportChunkRequest(i),D=!0}I=t},ea=function(e){d.reportAdState(c.AD_REQUEST);var t=_();0==e.startTime?t.adPosition="pre":t.adPosition="mid",t.adId=e.id,t.adDuration=e.duration,t.adIsLinear=!0,t.adServer="Equativ",t.isSSAI=!0,t.adClient="Harmonic",d.reportAdInfo(t),d.reportAdState(c.AD_IMPRESSION)},es=function(e){var t=_();0==e.startTime?t.adPosition="pre":t.adPosition="mid",t.adId=e.id,t.adDuration=e.duration,t.adIsLinear=!0,t.adServer="Equative",t.isSSAI=!0,t.adClient="Harmonic",d.reportAdInfo(t),d.reportAdState(c.AD_STARTED)},en=function(){d.reportAdState(c.AD_FIRST_QUARTILE)},eo=function(){d.reportAdState(c.AD_MIDPOINT)},ed=function(){d.reportAdState(c.AD_THIRD_QUARTILE)},el=function(){d.reportAdState(c.AD_COMPLETED)};return{initialize:function(e,t,i,r,a){F("initialize Called with streamUrl: "+i+" isLive: "+a+" mmVideoAssetInfo: "+JSON.stringify(r)),d.reportSDKVersion("SHKP2.5.1"),console.log("MMSmartStreaming- "+d.getSDKVersion()),e&&(null!=n&&(n.removeEventListener("error",X),n.removeEventListener("adaptation",er),n.removeEventListener("loading",z),n.removeEventListener("unloading",W),n.removeEventListener("texttrackvisibility",J),n.removeEventListener("textchanged",Z),n.removeEventListener("variantchanged",ee),n.removeEventListener("complete",et)),null!=o&&(o.removeEventListener("play",K),o.removeEventListener("pause",K),o.removeEventListener("ended",K),o.removeEventListener("playing",K),o.removeEventListener("timeupdate",$),o.removeEventListener("seeking",Q),o.removeEventListener("waiting",j),o.removeEventListener("canplay",Y),o.removeEventListener("canplaythrough",Y)),B(),o=t,A=a,null!=(n=e)&&(n.addEventListener("error",X),n.addEventListener("adaptation",er),n.addEventListener("loading",z),n.addEventListener("unloading",W),n.addEventListener("texttrackvisibility",J),n.addEventListener("textchanged",Z),n.addEventListener("variantchanged",ee),n.addEventListener("complete",et)),null!=o&&(o.addEventListener("play",K),o.addEventListener("pause",K),o.addEventListener("ended",K),o.addEventListener("playing",K),o.addEventListener("timeupdate",$),o.addEventListener("seeking",Q),o.addEventListener("waiting",j),o.addEventListener("canplay",Y),o.addEventListener("canplaythrough",Y)),i&&(b=i)),T||H(r)},reportPlayerInfo:function(e,t,i){return d.reportPlayerInfo(e,t,i)},reportAppInfo:function(e,t){return d.reportAppInfo(e,t)},setDeviceInfo:function(e){R=e},reportVideoQuality:function(e){return d.reportVideoQuality(e)},updateSubscriber:function(e,t,i){d.updateSubscriber(e,t,i)},getRegistrationStatus:function(){return d.getRegistrationStatus()},registerMMSmartStreaming:function(e,t,i,r,a,n,o){return F("registerMMSmartStreaming Called with playerName: "+e+" customerID: "+t+" component: "+s+" subscriberID: "+i+" domainName: "+r+" subscriberType: "+a+" subscriberTag: "+n+" hashSubscriberId: "+o),d.registerMMSmartStreaming(e,t,s,i,r,a,n,o)},reportCustomMetadata:function(e,t){return F("reportCustomMetadata Called with key: "+e+" attributeValue: "+t),d.reportCustomMetadata(e,t)},enableLogTrace:function(e){U=e,d.enableLogTrace(e)},reportExperimentName:function(e){try{d.reportExperimentName(e)}catch(e){console.log("MMError:"+e)}},reportSubPropertyId:function(e){try{d.reportSubPropertyId(e)}catch(e){console.log("MMError:"+e)}},reportViewSessionId:function(e){try{d.reportViewSessionId(e)}catch(e){console.log("MMError:"+e)}},reportAppSessionId:function(e){try{d.reportAppSessionId(e)}catch(e){console.log("MMError:"+e)}},reportBasePlayerInfo:function(e,t){try{d.reportBasePlayerInfo(e,t)}catch(e){console.log("MMError:"+e)}},reportFallbackEvent:function(e,t){try{""!==e&&null!=e&&d.reportMetricValue(v.streamURL,e),t&&""!==t||(t="Unknown"),d.reportEventWithValue("FALLBACK_ATTEMPT",t)}catch(e){console.log("MMError:"+e)}},reportDeviceId:function(e){e&&d.reportDeviceId(e)},reportPlayerResolution:function(e,t){void 0!==e&&void 0!==t&&d.reportPlayerResolution(e+"x"+t)},reportError:function(e,t,i){try{t&&""!=t||(t="NA"),i&&""!=i||(i="NA");var r=e+"_"+t+"@@FATAL@@"+i,a=G();d.reportError(r,a>0?a:0)}catch(e){console.log("MMError:"+e)}},reportWarning:function(e,t,i){try{t&&""!=t||(t="NA"),i&&""!=i||(i="NA");var r=e+"_"+t+"@@WARNING@@"+i,a=G();d.reportError(r,a>0?a:0)}catch(e){console.log("MMError:"+e)}},disableAutoErrorCapture:function(){C=!1},reportCDN:function(e){F("reportCDN called with cdn: "+e),e&&""!==e&&d.reportStringDimension(E.CDN,e)},reportStreamInfo:function(e,t,i){F("reportStreamInfo called with streamFormat: "+e+", mediaType: "+t+", sourceType: "+i),d.reportStreamInfo(e,t,i)},updateAssetInfo:function(t){try{F("updateAssetInfo called with mmAssetInfo: "+t),F("updateAssetInfo _player: "+n),t&&n&&(et(),H(t),z(),q(),d.reportPlayerState(p.PLAYING),m=e.PLAYING)}catch(e){console.log("MMError:"+e.message)}},initializeHarmonicSSAIAdManager:function(e,t){try{e&&(V=e)&&(V.off("impression",ea),V.off("start",es),V.off("firstQuartile",en),V.off("midpoint",eo),V.off("thirdQuartile",ed),V.off("complete",el)),V&&(V.on("impression",ea),V.on("start",es),V.on("firstQuartile",en),V.on("midpoint",eo),V.on("thirdQuartile",ed),V.on("complete",el)),V.setup(t,A)}catch(e){console.log("MMError:"+e)}}}}},446410,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"MMAppAnalyticsSDK",{enumerable:!0,get:function(){return r.MMAppAnalyticsSDK}}),Object.defineProperty(i,"SHAKAPlayerMMSSIntgr",{enumerable:!0,get:function(){return a.SHAKAPlayerMMSSIntgr}});var r=e.r(606648),a=e.r(134152)},804730,e=>
2{e.v({name:"travelxp-b2c",version:"7.0.0",description:"Travelxp B2C — Travel media platform & booking service",private:!0,imports:{"#*":"./*"},scripts:{dev:"next dev -p 3001",build:"next build",start:"next start -p 3001","test:compare":"vitest run tests/comparison/","test:e2e":"playwright test","test:ui":"playwright test --ui",analyze:"ANALYZE=true next build","test:api":"playwright test playwright/tests/api"},dependencies:{"@formatjs/intl-localematcher":"^0.8.1","@rudderstack/analytics-js":"^3.28.1","@sentry/nextjs":"^10.39.0","@stripe/react-stripe-js":"^5.6.0","@stripe/stripe-js":"^8.7.0","baseline-browser-mapping":"^2.10.0","bwip-js":"^4.8.0",dayjs:"^1.11.19","js-cookie":"^3.0.5","lucide-react":"^0.563.0","mapbox-gl":"^3.18.1","mediamelon-js-shaka-sdk":"2.5.1",next:"16.1.6","otpless-headless-js":"^1.0.7",react:"^19.2.4","react-dom":"^19.2.4","shaka-player":"^4.16.17",shimmer:"^1.2.1",supercluster:"^8.0.1",swr:"^2.4.0"},devDependencies:{"@axe-core/playwright":"^4.11.1","@next/bundle-analyzer":"^16.1.6","@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@testing-library/dom":"10.4.0","@testing-library/react":"^16.3.2","@types/js-cookie":"^3.0.6","@types/mapbox-gl":"^3.5.0","@types/mapbox__point-geometry":"^1.0.87","@types/node":"^25.2.2","@types/react":"^19.2.13","@types/react-dom":"^19.2.3","@types/supercluster":"^7.1.3",autoprefixer:"^10.4.20","cross-env":"^10.1.0",dotenv:"^17.3.1",jsdom:"^29.1.1",postcss:"^8.5.6",tailwindcss:"^3.4.10",typescript:"5.9.3",vitest:"^4.0.18"}})},16492,e=>{"use strict";var t=e.i(446410),i=e.i(804730),r=e.i(911368);let a="shaka-player";function s(e,t={}){let{isTrailer:i=!1,drmProtection:r="None"}=t;return{assetName:e.title||e.name,assetId:e.id,videoId:e.id,contentType:i?"Trailer":"program"===e.type?"Program":"Episode",mediaType:i?"Trailer":"program"===e.type?"Show":"Episode",seriesTitle:e.program?.name||e.title||e.name,season:e.seasons,episodeNumber:e.episodes,videoType:"VOD",drmProtection:r,genre:e.label||e.program?.name||e.title||e.name||"-"}}function n({player:e,videoElement:s,mediaUrl:n,mmVideoAssetInfo:o,userId:d,planName:l,shakaVersion:u="4.16.17",experimentName:h="default"}){try{if(void 0===t.SHAKAPlayerMMSSIntgr)return;let r=new t.SHAKAPlayerMMSSIntgr;if(r?.getRegistrationStatus()===!1){let e,t,s,n;d?l?(e="Subscribed",t=l):(e="Unsubscribed",t="Logged In"):(e="Unsubscribed",t="Logged Out"),r.registerMMSmartStreaming(a,"476976526",d||"Guest","www.travelxp.com",e,t,!1),r.reportPlayerInfo(a,a,u),r.reportBasePlayerInfo(a,u),r.reportAppInfo("travelxpB2c",i.default.version),r.setDeviceInfo((s=navigator.userAgent,/iPhone/.test(s)?"iPhone":/iPad/.test(s)?"iPad":/Android.*Mobile/.test(s)?"Android Mobile":/Android/.test(s)?"Android Tablet":/Mac/.test(s)?"Mac Desktop":/Windows/.test(s)?"Windows Desktop":/Linux/.test(s)?"Linux Desktop":"Desktop"),(n=navigator.userAgent,/iPhone|iPad|Mac/.test(n)?"Apple":/Android/.test(n)?"Android":/Windows/.test(n)?"Microsoft":/Linux/.test(n)?"Linux":"Unknown"))}let c=n.includes(".mpd")?"DASH":n.includes(".m3u8")?"HLS":"";
2c&&r.reportStreamInfo(c,"VOD","CDN"),s.clientWidth&&s.clientHeight&&r.reportPlayerResolution(s.clientWidth,s.clientHeight);let _="u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`;return r.reportViewSessionId(_),r.reportExperimentName(h),r.initialize(e,s,n,o,!1),e.addEventListener("trackschanged",()=>{try{let t=e.getVariantTracks()?.find(e=>e.active);t?.videoCodec&&r.reportVideoCodec(t.videoCodec),t?.audioCodec&&r.reportAudioCodec(t.audioCodec),t?.width&&t?.height&&r.reportStreamResolution(t.width,t.height)}catch{}},{once:!0}),r}catch(e){return(0,r.logError)("Error initializing MediaMelon SDK",e,{tags:{feature:"watch"}}),null}}e.s(["buildMmVideoAssetInfo",()=>s,"initMediaMelon",()=>n])}]);
3
4//# debugId=b0ea99eb-0143-441a-744a-f01de6db8dff

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.