!function(){"use strict";window.LiveScoreApp=window.LiveScoreApp||{},window.LiveScoreApp.Monitoring=window.LiveScoreApp.Monitoring||{};const e={cacheWrites:[],cacheWriteFailures:[],maxBufferSize:500};window.LiveScoreApp.Monitoring.trackCacheWrite=function(t){try{e.cacheWrites.push({...t,timestamp:(new Date).toISOString()}),e.cacheWrites.length>e.maxBufferSize&&e.cacheWrites.shift(),e.cacheWrites.length>=100&&i("success",e.cacheWrites)}catch(e){}},window.LiveScoreApp.Monitoring.trackCacheWriteFailure=function(t){try{e.cacheWriteFailures.push({...t,timestamp:(new Date).toISOString()}),e.cacheWriteFailures.length>e.maxBufferSize&&e.cacheWriteFailures.shift(),e.cacheWriteFailures.length>=50&&i("failure",e.cacheWriteFailures)}catch(e){}},window.LiveScoreApp.Monitoring.trackResponseTime=function(t){try{e.responseTimes=e.responseTimes||[],e.responseTimes.push({...t,timestamp:(new Date).toISOString()}),e.responseTimes.length>e.maxBufferSize&&e.responseTimes.shift(),e.responseTimes.length>=100&&i("response_times",e.responseTimes)}catch(e){}},window.LiveScoreApp.Monitoring.getBuffers=function(){return{cacheWrites:e.cacheWrites.length,cacheWriteFailures:e.cacheWriteFailures.length,responseTimes:(e.responseTimes||[]).length}},window.LiveScoreApp.Monitoring.reset=function(){e.cacheWrites.length=0,e.cacheWriteFailures.length=0,e.responseTimes&&(e.responseTimes.length=0),window.LiveScoreApp.Monitoring._resetInProgress=!0};const t={},n=1e4;function i(e,i){if(0!==i.length){var a=Date.now();if(!(t[e]&&a-t[e]<n)){t[e]=a;var s=i.slice(),r=window.LiveScoresAjax&&window.LiveScoresAjax.ajax_url||"/wp-admin/admin-ajax.php",o=window.LiveScoresAjax&&window.LiveScoresAjax.monitoring_nonce||"",c="response_times"===e?e:"cache_"+e;if(navigator.sendBeacon)try{var l=new FormData;l.append("action","send_monitoring_metrics"),l.append("nonce",o),l.append("type",c),l.append("data",JSON.stringify(s)),navigator.sendBeacon(r,l),i.length=0}catch(e){}}}}setInterval(function(){e.cacheWrites.length>0&&i("success",e.cacheWrites),e.cacheWriteFailures.length>0&&i("failure",e.cacheWriteFailures),e.responseTimes&&e.responseTimes.length>0&&i("response_times",e.responseTimes)},6e4),window.addEventListener("beforeunload",()=>{if(!(window.LiveScoreApp&&window.LiveScoreApp.Monitoring&&window.LiveScoreApp.Monitoring._resetInProgress)){var t=window.LiveScoresAjax&&window.LiveScoresAjax.ajax_url||"/wp-admin/admin-ajax.php",n=window.LiveScoresAjax&&window.LiveScoresAjax.monitoring_nonce||"";if(e.cacheWrites.length>0){var i=new FormData;i.append("action","send_monitoring_metrics"),i.append("nonce",n),i.append("type","cache_success"),i.append("data",JSON.stringify(e.cacheWrites)),navigator.sendBeacon(t,i)}if(e.cacheWriteFailures.length>0){var a=new FormData;a.append("action","send_monitoring_metrics"),a.append("nonce",n),a.append("type","cache_failure"),a.append("data",JSON.stringify(e.cacheWriteFailures)),navigator.sendBeacon(t,a)}if(e.responseTimes&&e.responseTimes.length>0){var s=new FormData;s.append("action","send_monitoring_metrics"),s.append("nonce",n),s.append("type","response_times"),s.append("data",JSON.stringify(e.responseTimes)),navigator.sendBeacon(t,s)}}})}(),window.LiveScoreApp=window.LiveScoreApp||{},window.LiveScoreApp.Monitoring=window.LiveScoreApp.Monitoring||{},window.APIMonitor=function(){"use strict";let e=null;try{const t=parseInt(localStorage.getItem("monitoringResetAt")||"0",10),n=localStorage.getItem("apiMonitorMetrics");if(n){const i=JSON.parse(n);i.startTime&&i.startTime>=t&&(e=i)}}catch(e){}const t={apiRequests:e?.apiRequests||[],cacheHits:e?.cacheHits||0,cacheMisses:e?.cacheMisses||0,requestsByType:e?.requestsByType||{},requestsByMinute:e?.requestsByMinute||{},ttlUsageByType:e?.ttlUsageByType||{},errors:e?.errors||[],startTime:e?.startTime||Date.now(),lastReportTime:Date.now()},n=window.fetch;if(window.fetch=function(...e){const i=e[0];if("string"==typeof i){if(-1!==i.indexOf("monitoring-api"))return n.apply(window,e);if(e[1]&&e[1].body instanceof FormData&&"send_monitoring_metrics"===e[1].body.get("action"))return n.apply(window,e);if(0===i.indexOf("http")&&-1===i.indexOf(location.hostname)&&-1===i.indexOf("admin-ajax.php")&&-1===i.indexOf("proxy.php"))return n.apply(window,e)}const a=Date.now(),s=Math.floor(a/6e4);let r=function(e,t){if(t&&t.body)try{if(t.body instanceof FormData){var n=t.body.get("action");if(n){var i=l(n);if(i)return i}}const e=JSON.parse(t.body);if(e&&e.dataType)return e.dataType;if(e&&e.action){var a=l(e.action);if(a)return a}}catch(e){if("string"==typeof t.body){var s=t.body.match(/(?:^|&)action=([^&]+)/);if(s){var r=l(s[1]);if(r)return r}}}const o=e.toLowerCase();if(o.includes("admin-ajax.php")){var c=e.match(/[?&]action=([^&]+)/);if(c){var p=l(c[1]);if(p)return p}}if(o.includes("proxy.php")){var d=e.match(/[?&]action=([^&]+)/);if(d){var u=d[1].toLowerCase();if(u.includes("jersey"))return"JERSEY";if(u.includes("player"))return"PLAYER_DATA";if(u.includes("lineup"))return"LINEUPS";if(u.includes("statistic"))return"STATISTICS";if(u.includes("incident"))return"MATCH_INCIDENTS";if(u.includes("momentum"))return"ATTACK_MOMENTUM";if(u.includes("match_details"))return"LIVE_SCORES"}}return o.includes("livescore")||o.includes("match")?"LIVE_SCORES":o.includes("incident")?"MATCH_INCIDENTS":o.includes("lineup")?"LINEUPS":o.includes("statistics")||o.includes("stats")?"STATISTICS":o.includes("standing")||o.includes("table")?"STANDINGS":o.includes("h2h")||o.includes("head")?"H2H":o.includes("player")?"PLAYER_DATA":o.includes("monitoring-api")?"MONITORING_API":o.includes(".json")?"LOCAL_CACHE":"OTHER"}(i,e[1]);t.apiRequests.push({url:i,type:r,timestamp:a,minute:s}),t.requestsByType[r]=(t.requestsByType[r]||0)+1,t.requestsByMinute[s]=(t.requestsByMinute[s]||0)+1;const o=Date.now();return n.apply(window,e).then(t=>{const n=Date.now()-o;let a="unknown";if("string"==typeof i)if(i.includes("?action="))a=i.match(/action=([^&]+)/)[1];else if(i.includes("wp-admin/admin-ajax.php")||i.includes("admin-ajax.php")){a="ajax_generic";try{if(e[1]&&e[1].body instanceof FormData){var s=e[1].body.get("action");s&&(a=s)}else if(e[1]&&e[1].body&&"undefined"!=typeof URLSearchParams&&e[1].body instanceof URLSearchParams){var r=e[1].body.get("action");r&&(a=r)}else if(e[1]&&"string"==typeof e[1].body){var c=e[1].body.match(/(?:^|&)action=([^&]+)/);if(c&&(a=c[1]),"ajax_generic"===a&&"{"===e[1].body.charAt(0))try{var l=JSON.parse(e[1].body);l.action&&(a=l.action)}catch(e){}}}catch(e){}if("ajax_generic"===a){var p=i.match(/[?&]action=([^&]+)/);p&&(a=p[1])}}return window.LiveScoreApp&&window.LiveScoreApp.Monitoring&&n>0&&window.LiveScoreApp.Monitoring.trackResponseTime({endpoint:a,duration_ms:n,url:i,status:t.status}),t}).catch(e=>{throw t.errors.push({type:"FETCH_ERROR",message:e.message,timestamp:Date.now()}),t.errors.length>50&&(t.errors=t.errors.slice(-50)),e})},"undefined"!=typeof jQuery&&(jQuery(document).ajaxSend(function(e,n,i){if(!i.data||"string"!=typeof i.data||-1===i.data.indexOf("action=send_monitoring_metrics")){var a=i.url||"",s="OTHER";if(i.data&&"string"==typeof i.data){var r=i.data.match(/(?:^|&)action=([^&]+)/);r&&(s=l(r[1])||"OTHER")}else i.data&&"object"==typeof i.data&&i.data.action&&(s=l(i.data.action)||"OTHER");if("DEDUP_POLL"!==s&&"MONITORING_API"!==s&&"WP_SYSTEM"!==s){var o=Date.now(),c=Math.floor(o/6e4);t.apiRequests.push({url:a,type:s,timestamp:o,minute:c,transport:"jquery"}),t.requestsByType[s]=(t.requestsByType[s]||0)+1,t.requestsByMinute[c]=(t.requestsByMinute[c]||0)+1,n._monitorStartTime=o,n._monitorType=s}}}),jQuery(document).ajaxComplete(function(e,t,n){if(t._monitorStartTime){var i=Date.now()-t._monitorStartTime,a="ajax_generic";if(n.data&&"string"==typeof n.data){var s=n.data.match(/(?:^|&)action=([^&]+)/);s&&(a=s[1])}else n.data&&"object"==typeof n.data&&n.data.action&&(a=n.data.action);if("ajax_generic"===a&&n.url){var r=n.url.match(/[?&]action=([^&]+)/);r&&(a=r[1])}window.LiveScoreApp&&window.LiveScoreApp.Monitoring&&i>0&&window.LiveScoreApp.Monitoring.trackResponseTime({endpoint:a,duration_ms:i,url:n.url||"",status:t.status,transport:"jquery"})}})),window.LiveScoreApp.Utils&&window.LiveScoreApp.Utils.Cache){const e=window.LiveScoreApp.Utils.Cache.getFromCache;window.LiveScoreApp.Utils.Cache.getFromCache=function(n,i){if(e){const a=e.call(this,n,i);if(a&&void 0!==a.data&&null!==a.data){t.cacheHits++;const e=c(n);e&&(t.ttlUsageByType[e]||(t.ttlUsageByType[e]={hits:0,misses:0}),t.ttlUsageByType[e].hits++)}else{t.cacheMisses++;const e=c(n);e&&(t.ttlUsageByType[e]||(t.ttlUsageByType[e]={hits:0,misses:0}),t.ttlUsageByType[e].misses++)}return a}}}let i=0;function a(){if(!window.LiveScoreApp||!window.LiveScoreApp.Utils||!window.LiveScoreApp.Utils.Cache)return i++,void(i<50?setTimeout(a,200):"function"==typeof window.getCache&&o());i=0;const e=window.LiveScoreApp.Utils.Cache.getFromCacheByType;e&&"function"==typeof e&&(window.LiveScoreApp.Utils.Cache.getFromCacheByType=function(n,i){try{const s=e.call(this,n,i),r="string"!=typeof(a=i||"")?null:a.includes("liveScore")?"LIVE_SCORES":a.includes("incident")?"MATCH_INCIDENTS":a.includes("matchDetail")?"MATCH_DETAILS":a.includes("attack")||a.includes("momentum")?"ATTACK_MOMENTUM":a.includes("lineup")?"LINEUPS":a.includes("statistic")?"STATISTICS":a.includes("h2h")?"H2H":a.includes("standing")?"STANDINGS":a.includes("liveMinute")||a.includes("LIVE_TEXT")?"LIVE_TEXT":a.includes("player")?"PLAYER_DATA":null;return r&&(null!=s?(t.cacheHits++,t.ttlUsageByType[r]||(t.ttlUsageByType[r]={hits:0,misses:0}),t.ttlUsageByType[r].hits++):(t.cacheMisses++,t.ttlUsageByType[r]||(t.ttlUsageByType[r]={hits:0,misses:0}),t.ttlUsageByType[r].misses++)),s}catch(t){return e.call(this,n,i)}var a})}let s=0;function r(){if(!window.getCache||"function"!=typeof window.getCache)return s++,void(s<30&&setTimeout(r,300));o()}function o(){if(!window.getCache||"function"!=typeof window.getCache)return;const e=window.getCache;window.getCache=function(n){try{const i=e.apply(this,arguments);if(null!=i){t.cacheHits++;const e=c(n);e&&(t.ttlUsageByType[e]||(t.ttlUsageByType[e]={hits:0,misses:0}),t.ttlUsageByType[e].hits++)}else{t.cacheMisses++;const e=c(n);e&&(t.ttlUsageByType[e]||(t.ttlUsageByType[e]={hits:0,misses:0}),t.ttlUsageByType[e].misses++)}return i}catch(t){return e.apply(this,arguments)}}}function c(e){return e.includes("liveScore")||e.includes("LIVE_SCORES")?"LIVE_SCORES":e.includes("incident")?"MATCH_INCIDENTS":e.includes("matchDetail")?"MATCH_DETAILS":e.includes("attack")||e.includes("momentum")?"ATTACK_MOMENTUM":e.includes("lineup")?"LINEUPS":e.includes("statistic")?"STATISTICS":e.includes("h2h")?"H2H":e.includes("standing")?"STANDINGS":e.includes("LIVE_MINUTE")||e.includes("minute")?"LIVE_TEXT":e.includes("player")?"PLAYER_DATA":null}function l(e){return{get_live_scores:"LIVE_SCORES",get_match_details:"LIVE_SCORES",get_match_incidents:"MATCH_INCIDENTS",get_match_lineups:"LINEUPS",get_match_statistics:"STATISTICS",get_standings_data:"STANDINGS",get_cached_standings:"STANDINGS",get_h2h_data:"H2H",get_streaks_data:"H2H",get_team_performance:"STATISTICS",get_attack_momentum:"ATTACK_MOMENTUM",get_super_lig_next_matches:"SEO",check_dedup_cache:"DEDUP_POLL",send_monitoring_metrics:"MONITORING_API",sync_memcached_cleanup:"SYSTEM",heartbeat:"WP_SYSTEM",wp_ajax_heartbeat:"WP_SYSTEM",validate_cache_ttls:"SYSTEM"}[e]||null}function p(){const e=Date.now(),n=Math.round((e-t.startTime)/1e3),i=Math.round(n/60);let a=0;for(const e of Object.values(t.requestsByType))a+=e;0===a&&(a=t.apiRequests.length);const s=Math.floor(e/6e4)-1,r=t.requestsByMinute[s]||0;let o=i>0?+(a/i).toFixed(1):a;const c=t.ttlUsageByType.LIVE_SCORES||{hits:0,misses:0},l=t.cacheHits-c.hits,p=t.cacheMisses-c.misses,d=l+p,u=d>0?Math.round(l/d*100):0,m={};for(const[e,n]of Object.entries(t.requestsByType))m[e]={count:n,percentage:a>0?Math.round(n/a*100):0};const h={};for(const[e,n]of Object.entries(t.ttlUsageByType)){const t=n.hits+n.misses;h[e]={hits:n.hits,misses:n.misses,total:t,hitRate:t>0?Math.round(n.hits/t*100):0}}return{timestamp:new Date(e).toISOString(),uptime:{seconds:n,minutes:i},apiMetrics:{totalRequests:a,requestsPerMinute:o,lastMinuteRequests:r,targetRange:"8-12 req/min",status:o<=12?"✅ OK":"⚠️ HIGH"},cacheMetrics:{totalOperations:d,hits:l,misses:p,hitRate:u+"%",liveScoresExcluded:c.hits+c.misses,targetRange:"70-80%",status:u>=70&&u<=80?"✅ OK":u<70?"⚠️ LOW":"⚠️ HIGH"},requestsByType:m,ttlUsageByType:h,errors:{count:t.errors.length,recent:t.errors.slice(-5)}}}r(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function(){a()}):a(),window.addEventListener("load",function(){t.cacheHits||t.cacheMisses||(a(),r())});let d=!1;function u(){try{if(d)return;if(-1!==window.location.pathname.indexOf("monitoring-dashboard"))return;!function(){t.apiRequests.length>100&&(t.apiRequests=t.apiRequests.slice(-100)),t.errors.length>50&&(t.errors=t.errors.slice(-50));const e=Math.floor(Date.now()/6e4)-60;for(const n of Object.keys(t.requestsByMinute))parseInt(n)<e&&delete t.requestsByMinute[n]}(),function(){if(!d)try{localStorage.setItem("apiMonitorMetrics",JSON.stringify({apiRequests:t.apiRequests,cacheHits:t.cacheHits,cacheMisses:t.cacheMisses,requestsByType:t.requestsByType,requestsByMinute:t.requestsByMinute,ttlUsageByType:t.ttlUsageByType,errors:t.errors,startTime:t.startTime,lastReportTime:t.lastReportTime}))}catch(e){}}();const s=p();var e=window.LiveScoresAjax&&window.LiveScoresAjax.ajax_url||"/wp-admin/admin-ajax.php",i=window.LiveScoresAjax&&window.LiveScoresAjax.monitoring_nonce||"",a=new FormData;a.append("action","send_monitoring_metrics"),a.append("nonce",i),a.append("type","api"),a.append("data",JSON.stringify(s)),n(e,{method:"POST",body:a}).catch(function(){})}catch(e){}}return setTimeout(u,3e3),setInterval(function(){try{u()}catch(e){}},6e4),{getReport:p,reset:function(){d=!0,t.apiRequests=[],t.cacheHits=0,t.cacheMisses=0,t.requestsByType={},t.requestsByMinute={},t.ttlUsageByType={},t.errors=[],t.startTime=Date.now(),t.lastReportTime=Date.now();try{localStorage.removeItem("apiMonitorMetrics"),localStorage.setItem("monitoringResetAt",String(Date.now()))}catch(e){}},getMetrics:function(){return t}}}();try{window.APIMonitor&&window.APIMonitor.getReport}catch(e){}window.LiveScoreApp=window.LiveScoreApp||{},window.LiveScoreApp.Monitoring=window.LiveScoreApp.Monitoring||{},window.ConsoleMonitor=function(){"use strict";let e=null;try{const t=parseInt(localStorage.getItem("monitoringResetAt")||"0",10),n=localStorage.getItem("consoleMonitorMetrics");if(n){const i=JSON.parse(n);i.startTime&&i.startTime>=t&&(e=i)}}catch(e){}const t={errors:e?.errors||[],warnings:e?.warnings||[],logs:e?.logs||[],jsErrors:e?.jsErrors||[],startTime:e?.startTime||Date.now(),performanceMetrics:e?.performanceMetrics||{documentReady:null,dataLoaded:null,firstPaint:null}},n=200;t.errors.length>n&&(t.errors=t.errors.slice(-200)),t.warnings.length>n&&(t.warnings=t.warnings.slice(-200)),t.logs.length>n&&(t.logs=t.logs.slice(-200)),t.jsErrors.length>n&&(t.jsErrors=t.jsErrors.slice(-200));const i=console.error,a=console.warn,s=console.log;console.error=function(...e){const n=Date.now();t.errors.push({timestamp:n,time:new Date(n).toLocaleTimeString(),message:e.join(" "),stack:(new Error).stack}),i.apply(console,e)},console.warn=function(...e){const n=Date.now();t.warnings.push({timestamp:n,time:new Date(n).toLocaleTimeString(),message:e.join(" ")}),a.apply(console,e)};const r=["API Monitor","Console Monitor","Cache"];function o(){"complete"!==document.readyState||t.performanceMetrics.documentReady||(t.performanceMetrics.documentReady=Date.now()),window.LiveScoreApp&&window.LiveScoreApp.Events&&window.LiveScoreApp.Events.DataLoaded&&!t.performanceMetrics.dataLoaded&&(t.performanceMetrics.dataLoaded=Date.now())}function c(){const e=Date.now(),n=Math.round((e-t.startTime)/1e3),i=t.errors.length+t.warnings.length+t.jsErrors.length;return{timestamp:new Date(e).toISOString(),uptime:{seconds:n,minutes:Math.round(n/60)},summary:{totalErrors:t.errors.length,totalWarnings:t.warnings.length,totalJSErrors:t.jsErrors.length,totalIssues:i,status:0===t.errors.length&&0===t.jsErrors.length?"✅ OK":"❌ ISSUES"},errors:t.errors,warnings:t.warnings,jsErrors:t.jsErrors,recentLogs:t.logs.slice(-10),performance:t.performanceMetrics}}console.log=function(...e){const n=e.join(" ");if(r.some(e=>n.includes(e))){const e=Date.now();t.logs.push({timestamp:e,time:new Date(e).toLocaleTimeString(),message:n})}s.apply(console,e)},window.addEventListener("error",function(e){const n=Date.now();t.jsErrors.push({timestamp:n,time:new Date(n).toLocaleTimeString(),type:"JavaScript Error",message:e.message,filename:e.filename,lineno:e.lineno,colno:e.colno,stack:e.error?e.error.stack:"No stack trace"})}),window.addEventListener("unhandledrejection",function(e){const n=Date.now();t.jsErrors.push({timestamp:n,time:new Date(n).toLocaleTimeString(),type:"Unhandled Promise Rejection",message:e.reason?e.reason.toString():"Unknown",stack:e.reason&&e.reason.stack?e.reason.stack:"No stack trace"})}),document.addEventListener("DOMContentLoaded",o),window.addEventListener("load",o),setInterval(o,6e4);let l=!1;function p(){try{if(l)return;if(-1!==window.location.pathname.indexOf("monitoring-dashboard"))return;!function(){try{localStorage.setItem("consoleMonitorMetrics",JSON.stringify({errors:t.errors.slice(-200),warnings:t.warnings.slice(-200),logs:t.logs.slice(-50),jsErrors:t.jsErrors.slice(-200),startTime:t.startTime,performanceMetrics:t.performanceMetrics}))}catch(e){}}();const a=c();var e=window.LiveScoresAjax&&window.LiveScoresAjax.ajax_url||"/wp-admin/admin-ajax.php",n=window.LiveScoresAjax&&window.LiveScoresAjax.monitoring_nonce||"",i=new FormData;i.append("action","send_monitoring_metrics"),i.append("nonce",n),i.append("type","console"),i.append("data",JSON.stringify(a)),fetch(e,{method:"POST",body:i}).catch(function(){})}catch(e){}}return setTimeout(p,3e3),setInterval(function(){try{p()}catch(e){}},6e4),{getReport:c,reset:function(){l=!0,t.errors=[],t.warnings=[],t.logs=[],t.jsErrors=[],t.startTime=Date.now(),t.performanceMetrics={documentReady:null,dataLoaded:null,firstPaint:null};try{localStorage.removeItem("consoleMonitorMetrics"),localStorage.setItem("monitoringResetAt",String(Date.now()))}catch(e){}},getMetrics:function(){return t}}}();try{window.ConsoleMonitor&&window.ConsoleMonitor.getReport}catch(e){}window.LiveScoreApp=window.LiveScoreApp||{},window.LiveScoreApp.Monitoring=window.LiveScoreApp.Monitoring||{},window.UserInteractionMonitor=function(){"use strict";const e={interactions:{matchCardsClicked:0,matchDetailsOpened:0,matchDetailsClosed:0,tabSwitches:{details:0,lineups:0,statistics:0,standings:0,h2h:0,incidents:0,history:0},totalTabSwitches:0},performance:{apiCallTimes:[],apiCallsByType:{},apiCallDetails:[],maxResponseTime:0,minResponseTime:1/0},cache:{writeAttempts:0,writeSuccesses:0,writeFailures:0,readAttempts:0,successRate:0},sessionStart:Date.now(),lastUpdated:Date.now(),webVitals:{ttfb:null,fcp:null,lcp:null,domReady:null,windowLoad:null,lazySectionLoad:null}};var t=!1;function n(){if(t)return!0;var n=window.LiveScoreApp&&window.LiveScoreApp.Modules&&window.LiveScoreApp.Modules.MatchDetails;if(!n)return!1;if(n.updateMatchDetails&&!n._uimOpenHooked){var i=n.updateMatchDetails;n.updateMatchDetails=function(t){return e.interactions.matchDetailsOpened++,l("DETAILS_OPENED",{matchId:t}),i.apply(this,arguments)},n._uimOpenHooked=!0}if(n.closeMatchDetails&&!n._uimCloseHooked){var a=n.closeMatchDetails;n.closeMatchDetails=function(){return e.interactions.matchDetailsClosed++,l("DETAILS_CLOSED"),a.apply(this,arguments)},n._uimCloseHooked=!0}return n._uimOpenHooked&&(t=!0),t}function i(e){return e?e.replace(/^tab-/,"").toLowerCase().trim():""}var a=0,s="";function r(t,n){if(t){var r=i(t);if(r){var o=Date.now();r===s&&o-a<200||(s=r,a=o,e.interactions.tabSwitches.hasOwnProperty(r)||(e.interactions.tabSwitches[r]=0),e.interactions.tabSwitches[r]++,e.interactions.totalTabSwitches++)}}}function o(e){return e&&{get_live_scores:"LIVE_SCORES",get_match_details:"LIVE_SCORES",get_match_incidents:"INCIDENTS",get_match_lineups:"LINEUPS",get_match_statistics:"STATISTICS",get_standings_data:"STANDINGS",get_cached_standings:"STANDINGS",get_h2h_data:"H2H",get_streaks_data:"H2H",get_team_performance:"STATISTICS",get_attack_momentum:"ATTACK_MOMENTUM",get_super_lig_next_matches:"SEO",check_dedup_cache:"DEDUP_POLL",send_monitoring_metrics:"MONITORING_API"}[e]||null}function c(){const t=e.performance.apiCallTimes.map(e=>e.duration);t.length>0&&(e.performance.avgResponseTime=Math.round(t.reduce((e,t)=>e+t)/t.length),e.performance.maxResponseTime=Math.round(Math.max(...t)),e.performance.minResponseTime=Math.round(Math.min(...t)))}function l(e,t={}){window.APIMonitor&&window.APIMonitor.recordEvent&&window.APIMonitor.recordEvent(e,t)}function p(){return e.cache.successRate=e.cache.writeAttempts>0?Math.round(e.cache.writeSuccesses/e.cache.writeAttempts*100):0,{...e,sessionDuration:Date.now()-e.sessionStart}}function d(){const t=p();return{title:"👥 User Interaction Report",summary:{sessionDuration:Math.round((Date.now()-e.sessionStart)/1e3)+"s",matchCardsClicked:t.interactions.matchCardsClicked,matchDetailsOpened:t.interactions.matchDetailsOpened,totalTabSwitches:t.interactions.totalTabSwitches,totalAPIcalls:t.performance.apiCallTimes.length,avgResponseTime:t.performance.avgResponseTime+"ms",cacheWriteSuccessRate:t.cache.successRate+"%"},tabBreakdown:t.interactions.tabSwitches,apiByType:t.performance.apiCallsByType,performanceMetrics:{avgResponseTime:t.performance.avgResponseTime,maxResponseTime:t.performance.maxResponseTime,minResponseTime:t.performance.minResponseTime}}}function u(t=null){const n=e.performance.apiCallDetails;return t?n.filter(e=>e.type===t||e.type.includes(t)):n}function m(){try{if(-1!==window.location.pathname.indexOf("monitoring-dashboard"))return;d();const t=e.performance.apiCallDetails.slice(0,20),n={type:"user_interactions",metrics:{interactions:e.interactions,performance:{avgResponseTime:e.performance.avgResponseTime,minResponseTime:e.performance.minResponseTime,maxResponseTime:e.performance.maxResponseTime,callCount:e.performance.apiCallTimes.length,callsByType:e.performance.apiCallsByType,recentCalls:t.map(e=>({type:e.type,method:e.method,duration:Math.round(e.duration),status:e.status||null,timestamp:e.timestamp,url:e.url,error:e.error||null}))},cache:{writeSuccessRate:e.cache.writeSuccessRate,writeAttempts:e.cache.writeAttempts,writeSuccesses:e.cache.writeSuccesses},session:{duration:Date.now()-e.sessionStart,startTime:e.sessionStart},webVitals:e.webVitals}},i=window.LiveScoresAjax&&window.LiveScoresAjax.ajax_url||"/wp-admin/admin-ajax.php",a=window.LiveScoresAjax&&window.LiveScoresAjax.monitoring_nonce||"",s=new FormData;s.append("action","send_monitoring_metrics"),s.append("nonce",a),s.append("type","user_interactions"),s.append("data",JSON.stringify(n.metrics)),fetch(i,{method:"POST",body:s,keepalive:!0}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);const t=e.headers.get("content-type");if(t&&t.includes("text/html"))throw new Error("Server returned HTML instead of JSON (Cloudflare error page)");return e.json()}).then(e=>{}).catch(e=>{})}catch(e){}}function h(){try{document.querySelectorAll('.live-scores-match, [data-match-id], .match-card, .match-item, [class*="match"]').length,document.addEventListener("click",function(t){let n=t.target.closest(".live-scores-match");n||(n=t.target.closest("[data-match-id]")),n||(n=t.target.closest(".match-card")),n||(n=t.target.closest(".match-item")),n||(n=t.target.closest('[class*="match"]')),n&&!t.target.closest("button")&&(e.interactions.matchCardsClicked++,l("MATCH_CARD_CLICKED"))})}catch(t){}try{n()||(setTimeout(n,1e3),setTimeout(n,3e3),setTimeout(n,5e3),setTimeout(n,1e4))}catch(a){}try{!function(){const e=window.switchTab||window.switchTabTo||function(){};window.switchTab=function(t,n){return n&&(r(n),l("TAB_SWITCHED",{from:t,to:n})),e.apply(this,arguments)},document.addEventListener("click",function(e){var t=e.target.closest('[data-tab], .match-details-tab, [role="tab"], .tab-button');if(t){var n=t.getAttribute("data-tab")||t.getAttribute("data-tab-id")||t.id||t.textContent.toLowerCase().trim();n&&(r(n),l("TAB_CLICKED",{tab:i(n)}))}})}()}catch(s){}try{!function(){const t=window.fetch;window.fetch=function(...n){const i=n[0],a=n[1]||{},s=a&&a.method||"GET",r=performance.now();let p=function(e,t){if(!e)return"UNKNOWN";t=t||{};const n=e.toString();if(n.includes("live_scores")||n.includes("matches"))return"LIVE_SCORES";if(n.includes("incidents")||n.includes("events"))return"INCIDENTS";if(n.includes("lineups")||n.includes("formation"))return"LINEUPS";if(n.includes("statistics")||n.includes("stats"))return"STATISTICS";if(n.includes("standings")||n.includes("table"))return"STANDINGS";if(n.includes("h2h")||n.includes("head"))return"H2H";if(n.includes("streak"))return"STREAKS";if(n.includes("admin-ajax.php")){if(t.body)try{if("undefined"!=typeof FormData&&t.body instanceof FormData){var i=t.body.get("action");if(i){var a=o(i);if(a)return a}}if("string"==typeof t.body&&"{"===t.body.charAt(0)){var s=JSON.parse(t.body);if(s.action){var r=o(s.action);if(r)return r}}if("string"==typeof t.body&&-1!==t.body.indexOf("action=")){var c=t.body.match(/(?:^|&)action=([^&]+)/);if(c){var l=o(c[1]);if(l)return l}}}catch(e){}try{const e=new URL(n,window.location.origin).searchParams.get("action");if(e)return o(e)||(e.includes("live_score")?"LIVE_SCORES":e.includes("incident")?"INCIDENTS":e.includes("statistic")?"STATISTICS":e.includes("lineup")?"LINEUPS":e.includes("standing")?"STANDINGS":e.includes("h2h")?"H2H":e.includes("monitoring")||e.includes("metric")?"MONITORING_API":"AJAX_"+e.toUpperCase())}catch(e){}return"AJAX_UNKNOWN"}if(n.includes("monitoring-api.php")){try{let e=t.body;if("string"==typeof e&&(e=JSON.parse(e)),e&&e.type)return"MONITORING_"+e.type.toUpperCase()}catch(e){}return"MONITORING_API"}if(n.includes("rapidapi.com")||n.includes("api.example.com")||n.includes("api.football")||n.includes("api.sports")){try{const e=new URL(n).hostname;if(e.includes("rapidapi"))return"RAPIDAPI_EXTERNAL";if(e.includes("football")||e.includes("sports"))return"SPORTS_API"}catch(e){}return"EXTERNAL_API"}if(n.includes("/wp-json/")||n.includes("/rest/"))return"WP_REST_API";if(n.match(/\.(js|css|jpg|jpeg|png|gif|svg|woff|woff2|ttf|eot)(\?|$)/i))return"STATIC_ASSET";try{const e=new URL(n,window.location.origin).pathname.toLowerCase();if(e.includes("/api/"))return"API_"+(e.split("/api/")[1]?.split("/")[0]?.toUpperCase()||"API");if(e.includes("/wp-content/"))return"PLUGIN_RESOURCE";if(e.includes("/wp-includes/"))return"WP_CORE_RESOURCE"}catch(e){}return n.length>100?"EXTERNAL_REQUEST":"LOCAL_REQUEST"}(i,a);if("MONITORING_API"===p||"string"==typeof p&&0===p.indexOf("MONITORING_"))return t.apply(this,n);const d=i.toString(),u=d.length>80?d.substring(0,77)+"...":d;return t.apply(this,n).then(t=>{const n=performance.now()-r,i={type:p,url:u,fullUrl:d,duration:n,status:t.status,timestamp:Date.now(),method:s};return e.performance.apiCallTimes.push({type:p,duration:n,status:t.status,timestamp:Date.now(),method:s}),e.performance.apiCallsByType[p]=(e.performance.apiCallsByType[p]||0)+1,e.performance.apiCallDetails.unshift(i),e.performance.apiCallDetails.length>50&&e.performance.apiCallDetails.pop(),c(),l("API_CALL",{type:p,duration:Math.round(n),status:t.status}),t}).catch(t=>{const n=performance.now()-r;throw e.performance.apiCallTimes.push({type:p,duration:n,error:t.message,timestamp:Date.now()}),e.performance.apiCallDetails.unshift({type:p,url:u,fullUrl:d,duration:n,error:t.message,timestamp:Date.now(),method:s}),e.performance.apiCallDetails.length>50&&e.performance.apiCallDetails.pop(),l("API_ERROR",{type:p,error:t.message}),t})},"undefined"!=typeof jQuery&&(jQuery(document).ajaxSend(function(e,t,n){if(!n.data||"string"!=typeof n.data||-1===n.data.indexOf("action=send_monitoring_metrics")){var i="OTHER";if(n.data&&"string"==typeof n.data){var a=n.data.match(/(?:^|&)action=([^&]+)/);a&&(i=o(a[1])||"OTHER")}else n.data&&"object"==typeof n.data&&n.data.action&&(i=o(n.data.action)||"OTHER");if("DEDUP_POLL"!==i&&"MONITORING_API"!==i){var s=n.url||"",r=s.length>80?s.substring(0,77)+"...":s;t._uimStartTime=performance.now(),t._uimType=i,t._uimDisplayUrl=r,t._uimFullUrl=s}}}),jQuery(document).ajaxComplete(function(t,n,i){if(n._uimStartTime){var a=performance.now()-n._uimStartTime,s=n._uimType||"OTHER",r={type:s,url:n._uimDisplayUrl||"",fullUrl:n._uimFullUrl||"",duration:a,status:n.status,timestamp:Date.now(),method:"POST",transport:"jquery"};e.performance.apiCallTimes.push({type:s,duration:a,status:n.status,timestamp:Date.now(),method:"POST",transport:"jquery"}),e.performance.apiCallsByType[s]=(e.performance.apiCallsByType[s]||0)+1,e.performance.apiCallDetails.unshift(r),e.performance.apiCallDetails.length>50&&e.performance.apiCallDetails.pop(),c(),l("API_CALL",{type:s,duration:Math.round(a),status:n.status,transport:"jquery"})}}))}()}catch(p){}try{!function(){const t=window.setCache||function(){},n=window.getCache||function(){};window.setCache=function(n,i,a){e.cache.writeAttempts++;try{const i=t.apply(this,arguments);return e.cache.writeSuccesses++,l("CACHE_WRITE_SUCCESS",{key:n}),i}catch(t){throw e.cache.writeFailures++,l("CACHE_WRITE_FAIL",{key:n,error:t.message}),t}},window.getCache=function(t,i){return e.cache.readAttempts++,l("CACHE_READ",{key:t}),n.apply(this,arguments)}}()}catch(d){}try{!function(){function t(){var t=performance.getEntriesByType&&performance.getEntriesByType("navigation"),n=t&&t.length>0?t[0]:null;if(n&&n.responseStart)e.webVitals.ttfb=Math.round(n.responseStart-n.requestStart),n.domContentLoadedEventEnd&&(e.webVitals.domReady=Math.round(n.domContentLoadedEventEnd-n.startTime)),n.loadEventEnd>0&&(e.webVitals.windowLoad=Math.round(n.loadEventEnd-n.startTime));else if(performance.timing&&performance.timing.responseStart){var i=performance.timing;e.webVitals.ttfb=i.responseStart-i.navigationStart,i.domContentLoadedEventEnd&&(e.webVitals.domReady=i.domContentLoadedEventEnd-i.navigationStart),i.loadEventEnd>0&&(e.webVitals.windowLoad=i.loadEventEnd-i.navigationStart)}}function n(){var t=performance.getEntriesByType&&performance.getEntriesByType("paint");if(t)for(var n=0;n<t.length;n++)"first-contentful-paint"===t[n].name&&(e.webVitals.fcp=Math.round(t[n].startTime))}if("undefined"!=typeof PerformanceObserver)try{new PerformanceObserver(function(t){var n=t.getEntries();n.length>0&&(e.webVitals.lcp=Math.round(n[n.length-1].startTime))}).observe({type:"largest-contentful-paint",buffered:!0})}catch(e){}"complete"===document.readyState?(t(),n()):window.addEventListener("load",function(){setTimeout(function(){t(),n()},100)})}()}catch(u){}try{function h(){setTimeout(m,2e3),window.UserInteractionMonitorInterval=setInterval(m,6e4)}"complete"===document.readyState?h():window.addEventListener("load",h)}catch(f){}try{window.addEventListener("beforeunload",function(){window.LiveScoreApp&&window.LiveScoreApp.Monitoring&&window.LiveScoreApp.Monitoring._resetInProgress||m()})}catch(w){}window.UserInteractionMonitorReady=!0}try{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function(){h()}):h()}catch(e){}return{getMetrics:p,getReport:d,printReport:function(){d()},getAPICallDetails:u,printAPICallDetails:function(e=null){u(e).length},reset:function(){e.interactions.matchCardsClicked=0,e.interactions.matchDetailsOpened=0,e.interactions.matchDetailsClosed=0,Object.keys(e.interactions.tabSwitches).forEach(t=>{e.interactions.tabSwitches[t]=0}),e.interactions.totalTabSwitches=0,e.performance.apiCallTimes=[],e.performance.apiCallsByType={},e.performance.apiCallDetails=[],e.cache.writeAttempts=0,e.cache.writeSuccesses=0,e.cache.writeFailures=0,e.cache.readAttempts=0,e.webVitals.ttfb=null,e.webVitals.fcp=null,e.webVitals.lcp=null,e.webVitals.domReady=null,e.webVitals.windowLoad=null,e.webVitals.lazySectionLoad=null,e.sessionStart=Date.now()},init:h,sendMetrics:m,debugElementSelectors:function(){[".live-scores-match","[data-match-id]",".match-card",".match-item",'[class*="match"]'].forEach(e=>{document.querySelectorAll(e)}),["[data-tab]",".match-details-tab",'[role="tab"]',".tab-button",'[class*="tab"]'].forEach(e=>{document.querySelectorAll(e)})}}}();try{window.UserInteractionMonitor}catch(e){};