UNPKG

@2l/ewa-analytics-web-sdk

Version:
1 lines 96.1 kB
(function(q,ne){typeof exports=="object"&&typeof module<"u"?ne(exports):typeof define=="function"&&define.amd?define(["exports"],ne):(q=typeof globalThis<"u"?globalThis:q||self,ne(q.CentrifugoWebSDK={}))})(this,function(q){"use strict";function ne(n,e){return{...n,...e}}class Xt{baseURL;headers;constructor(e={}){const{baseURL:t="",headers:i={}}=e;this.baseURL=t,this.headers=i}buildUrl(e,t){const i=new URL(`${this.baseURL}${e}`);if(t){const s=new URLSearchParams(Object.entries(t));i.search=`?${s.toString()}`}return i.toString()}isValidUrl(e){try{return new URL(e),!0}catch{return!1}}buildRequestOptions(e,t){const i={method:e,headers:t.headers||this.headers};return t.body&&(i.body=t.body,i.headers["Content-Type"]="application/json"),i}async sendRequest(e,t){if(!this.isValidUrl(e))return Promise.reject(new Error("Invalid URL provided"));const i=await fetch(e,t);return i.ok?i.json():this.handleErrorResponse(i)}async handleErrorResponse(e){try{const t=await e.text(),{error:i}=JSON.parse(t);return Promise.reject(ne(e,i))}catch(t){return Promise.reject(ne(e,t))}}async fetch(e,t,i,s){const r=this.buildUrl(t,i.queryParameters),o=this.buildRequestOptions(e,i);return s&&(o.body=JSON.stringify(s),o.headers["Content-Type"]="application/json"),this.sendRequest(r,o)}setHeaders(e,t){this.headers=t?e:ne(this.headers||{},e)}async post(e,t,i={method:"POST"}){return this.fetch("POST",e,i,t)}}for(var O=[],Ve=0;Ve<256;++Ve)O.push((Ve+256).toString(16).slice(1));function Yt(n,e=0){return(O[n[e+0]]+O[n[e+1]]+O[n[e+2]]+O[n[e+3]]+"-"+O[n[e+4]]+O[n[e+5]]+"-"+O[n[e+6]]+O[n[e+7]]+"-"+O[n[e+8]]+O[n[e+9]]+"-"+O[n[e+10]]+O[n[e+11]]+O[n[e+12]]+O[n[e+13]]+O[n[e+14]]+O[n[e+15]]).toLowerCase()}var Pe,Zt=new Uint8Array(16);function Qt(){if(!Pe&&(Pe=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pe(Zt)}var ei=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const dt={randomUUID:ei};function ti(n,e,t){if(dt.randomUUID&&!n)return dt.randomUUID();n=n||{};var i=n.random||(n.rng||Qt)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Yt(i)}const $e=n=>{const e={};for(const t of Object.keys(n))n[t]&&(e[t]=n[t]);return e};class ft{random_user_id="";event_name="";app_id="";platform="";created_at_milli=Date.now();event_subtype;web_uuid;session_id;customer_user_id;app_version;web_hwid;country;event_value;language;timezone;os_version;os_name;device_name;device_type;constructor(e){this.country=e?.country?.toLowerCase(),this.event_subtype=e?.subtype||e?.event_subtype,this.random_user_id=e?.randomUserId,this.app_id=e?.appId||"web",this.app_version=e?.appVersion,this.platform=e?.platform,this.session_id=e?.sessionId,this.customer_user_id=e?.customer_user_id||e?.randomUserId,this.setUserAgentFields(e.userAgent)}setUserAgentFields(e){this.language=navigator.language.split("-")[0],this.timezone=e.getTimezone(),this.os_version=e.detectOSVersion(),this.os_name=e.detectOS(),this.device_name=e.detectDeviceName(),this.device_type=e.detectDeviceType()}}class ii extends ft{store;tracker;tracker_name;network_name;campaign_name;adgroup_name;creative_name;connection_type;adjust_tracker_id;user_agent;ip_address;environment;att_status;constructor(e){super(e);const t=Object.keys(this);for(const i of t)e[i]!==void 0&&!this[i]&&(this[i]=e[i]);this.adgroup_name=e.adgroup,this.campaign_name=e.campaign,this.creative_name=e.creative}}class ni extends ft{event_id="";event;event_type;native_language;learning_language;sdk_version;constructor(e){super(e);function t(s){const r=new Set(Object.keys({})),o=new Set(Object.keys({})),f=new Set(Object.keys({})),c={};for(const[v,x]of Object.entries(s))!r.has(v)&&!o.has(v)&&!f.has(v)&&(c[v]=x);const _=$e(c),m={browser:s.userAgent.getBrowserName().toLowerCase(),browser_version:s.userAgent.getBrowserVersion()};return JSON.stringify({..._,...m})}this.event_value=e.event_value||t(e),this.event_id=ti();const i=Object.keys(this);for(const s of i)e[s]!==void 0&&!this[s]&&(this[s]=e[s])}}async function si(n){const e=new ii(n);return $e(e)}async function ri(n){const e=new ni(n);return $e(e)}var bt=(n=>(n.SESSIONS="analytics:sessions",n.EVENTS="analytics:events",n))(bt||{}),_e=(n=>(n.INITIAL="initial",n.LOCATED="located",n.ATTRIBUTED="attributed",n))(_e||{});class oi{config;constructor(e){this.config=e}hasValidLocationData(e,t){return!!(e&&t)}logLocationWarning(e,t,i){console.warn("[EwaAnalytics SDK] Country or IP address is not set. Session located event not sent",{country:e,ip_address:t,context:i})}createSessionLocatedData(e,t){return{event_name:"session",event_subtype:_e.LOCATED,random_user_id:this.config.globalConfig.initData.randomUserId,app_id:this.config.globalConfig.initData.appId||"web",platform:this.config.globalConfig.initData.platform||"web",country:e,ip_address:t}}createSessionStartedData(){return{event_name:"session",event_subtype:_e.INITIAL,random_user_id:this.config.globalConfig.initData.randomUserId,platform:this.config.globalConfig.initData.platform||"web",app_id:this.config.globalConfig.initData.appId||"web"}}async sendSessionStarted(e){const t=this.createSessionStartedData();await this.config.eventTracker.trackEvent("session",t,e)}async sendSessionLocated(e,t,i){if(!this.hasValidLocationData(e,t)){this.logLocationWarning(e,t,i);return}const s=this.createSessionLocatedData(e,t);await this.config.eventTracker.trackEvent("session",s,i)}}var ai="2.0.2",Ke=500,_t="user-agent",oe="",pt="?",Ie="function",J="undefined",ae="object",Ge="string",L="browser",V="cpu",B="device",W="engine",N="os",ce="result",l="name",a="type",h="vendor",d="version",D="architecture",pe="major",u="model",ge="console",p="mobile",S="tablet",R="smarttv",F="wearable",Je="xr",me="embedded",we="inapp",Xe="brands",se="formFactors",Ye="fullVersionList",ue="platform",Ze="platformVersion",Ae="bitness",X="sec-ch-ua",ci=X+"-full-version-list",ui=X+"-arch",li=X+"-"+Ae,hi=X+"-form-factors",di=X+"-"+p,fi=X+"-"+u,gt=X+"-"+ue,bi=gt+"-version",mt=[Xe,Ye,p,u,ue,Ze,D,se,Ae],Le="Amazon",le="Apple",wt="ASUS",vt="BlackBerry",re="Google",yt="Huawei",St="Lenovo",kt="Honor",De="LG",Qe="Microsoft",et="Motorola",tt="Nvidia",Et="OnePlus",it="OPPO",ve="Samsung",Tt="Sharp",ye="Sony",nt="Xiaomi",st="Zebra",Ct="Chrome",xt="Chromium",Y="Chromecast",_i="Edge",Se="Firefox",ke="Opera",Rt="Facebook",Ot="Sogou",he="Mobile ",Ee=" Browser",rt="Windows",pi=typeof window!==J,U=pi&&window.navigator?window.navigator:void 0,Z=U&&U.userAgentData?U.userAgentData:void 0,gi=function(n,e){var t={},i=e;if(!je(e)){i={};for(var s in e)for(var r in e[s])i[r]=e[s][r].concat(i[r]?i[r]:[])}for(var o in n)t[o]=i[o]&&i[o].length%2===0?i[o].concat(n[o]):n[o];return t},Ue=function(n){for(var e={},t=0;t<n.length;t++)e[n[t].toUpperCase()]=n[t];return e},ot=function(n,e){if(typeof n===ae&&n.length>0){for(var t in n)if($(n[t])==$(e))return!0;return!1}return de(n)?$(e).indexOf($(n))!==-1:!1},je=function(n,e){for(var t in n)return/^(browser|cpu|device|engine|os)$/.test(t)||(e?je(n[t]):!1)},de=function(n){return typeof n===Ge},at=function(n){if(n){for(var e=[],t=fe(/\\?\"/g,n).split(","),i=0;i<t.length;i++)if(t[i].indexOf(";")>-1){var s=Ce(t[i]).split(";v=");e[i]={brand:s[0],version:s[1]}}else e[i]=Ce(t[i]);return e}},$=function(n){return de(n)?n.toLowerCase():n},ct=function(n){return de(n)?fe(/[^\d\.]/g,n).split(".")[0]:void 0},K=function(n){for(var e in n){var t=n[e];typeof t==ae&&t.length==2?this[t[0]]=t[1]:this[t]=void 0}return this},fe=function(n,e){return de(e)?e.replace(n,oe):e},Te=function(n){return fe(/\\?\"/g,n)},Ce=function(n,e){if(de(n))return n=fe(/^\s\s*/,n),typeof e===J?n:n.substring(0,Ke)},ut=function(n,e){if(!(!n||!e))for(var t=0,i,s,r,o,f,c;t<e.length&&!f;){var _=e[t],m=e[t+1];for(i=s=0;i<_.length&&!f&&_[i];)if(f=_[i++].exec(n),f)for(r=0;r<m.length;r++)c=f[++s],o=m[r],typeof o===ae&&o.length>0?o.length===2?typeof o[1]==Ie?this[o[0]]=o[1].call(this,c):this[o[0]]=o[1]:o.length===3?typeof o[1]===Ie&&!(o[1].exec&&o[1].test)?this[o[0]]=c?o[1].call(this,c,o[2]):void 0:this[o[0]]=c?c.replace(o[1],o[2]):void 0:o.length===4&&(this[o[0]]=c?o[3].call(this,c.replace(o[1],o[2])):void 0):this[o]=c||void 0;t+=2}},Q=function(n,e){for(var t in e)if(typeof e[t]===ae&&e[t].length>0){for(var i=0;i<e[t].length;i++)if(ot(e[t][i],n))return t===pt?void 0:t}else if(ot(e[t],n))return t===pt?void 0:t;return e.hasOwnProperty("*")?e["*"]:n},Pt={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2","8.1":"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},It={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},At={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[d,[l,he+"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[d,[l,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[l,d],[/opios[\/ ]+([\w\.]+)/i],[d,[l,ke+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[d,[l,ke+" GX"]],[/\bopr\/([\w\.]+)/i],[d,[l,ke]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[d,[l,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[d,[l,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[l,d],[/quark(?:pc)?\/([-\w\.]+)/i],[d,[l,"Quark"]],[/\bddg\/([\w\.]+)/i],[d,[l,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[d,[l,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[d,[l,"WeChat"]],[/konqueror\/([\w\.]+)/i],[d,[l,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[d,[l,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[d,[l,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[d,[l,"Smart "+St+Ee]],[/(avast|avg)\/([\w\.]+)/i],[[l,/(.+)/,"$1 Secure"+Ee],d],[/\bfocus\/([\w\.]+)/i],[d,[l,Se+" Focus"]],[/\bopt\/([\w\.]+)/i],[d,[l,ke+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[d,[l,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[d,[l,"Dolphin"]],[/coast\/([\w\.]+)/i],[d,[l,ke+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[d,[l,"MIUI"+Ee]],[/fxios\/([\w\.-]+)/i],[d,[l,he+Se]],[/\bqihoobrowser\/?([\w\.]*)/i],[d,[l,"360"]],[/\b(qq)\/([\w\.]+)/i],[[l,/(.+)/,"$1Browser"],d],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[l,/(.+)/,"$1"+Ee],d],[/samsungbrowser\/([\w\.]+)/i],[d,[l,ve+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[d,[l,Ot+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[l,Ot+" Mobile"],d],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[l,d],[/(lbbrowser|rekonq)/i],[l],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[d,l],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[l,Rt],d,[a,we]],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(instagram|snapchat)[\/ ]([-\w\.]+)/i],[l,d,[a,we]],[/\bgsa\/([\w\.]+) .*safari\//i],[d,[l,"GSA"],[a,we]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[d,[l,"TikTok"],[a,we]],[/\[(linkedin)app\]/i],[l,[a,we]],[/(chromium)[\/ ]([-\w\.]+)/i],[l,d],[/headlesschrome(?:\/([\w\.]+)| )/i],[d,[l,Ct+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[l,Ct+" WebView"],d],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[d,[l,"Android"+Ee]],[/chrome\/([\w\.]+) mobile/i],[d,[l,he+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[l,d],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[d,[l,he+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[l,he+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[d,l],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[l,[d,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[l,d],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[l,he+Se],d],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[l,"Netscape"],d],[/(wolvic|librewolf)\/([\w\.]+)/i],[l,d],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[d,[l,Se+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[l,[d,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[l,[d,/[^\d\.]+./,oe]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[D,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[D,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[D,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[D,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[D,"arm"]],[/((ppc|powerpc)(64)?)( mac|;|\))/i],[[D,/ower/,oe,$]],[/ sun4\w[;\)]/i],[[D,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i],[[D,$]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[u,[h,ve],[a,S]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[u,[h,ve],[a,p]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[u,[h,le],[a,p]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[u,[h,le],[a,S]],[/(macintosh);/i],[u,[h,le]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[u,[h,Tt],[a,p]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[u,[h,kt],[a,S]],[/honor([-\w ]+)[;\)]/i],[u,[h,kt],[a,p]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[u,[h,yt],[a,S]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[u,[h,yt],[a,p]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[u,/_/g," "],[h,nt],[a,S]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[u,/_/g," "],[h,nt],[a,p]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[u,[h,it],[a,p]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[u,[h,Q,{OnePlus:["304","403","203"],"*":it}],[a,S]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[u,[h,"Vivo"],[a,p]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[u,[h,"Realme"],[a,p]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto(?! 360)[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[u,[h,et],[a,p]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[u,[h,et],[a,S]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[u,[h,De],[a,S]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv|watch)\w+)/i,/\blg-?([\d\w]+) bui/i],[u,[h,De],[a,p]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[u,[h,St],[a,S]],[/(nokia) (t[12][01])/i],[h,u,[a,S]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*))/i],[[u,/_/g," "],[a,p],[h,"Nokia"]],[/(pixel (c|tablet))\b/i],[u,[h,re],[a,S]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[u,[h,re],[a,p]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[u,[h,ye],[a,p]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[u,"Xperia Tablet"],[h,ye],[a,S]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[u,[h,Et],[a,p]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[u,[h,Le],[a,S]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[u,/(.+)/g,"Fire Phone $1"],[h,Le],[a,p]],[/(playbook);[-\w\),; ]+(rim)/i],[u,h,[a,S]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[u,[h,vt],[a,p]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[u,[h,wt],[a,S]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[u,[h,wt],[a,p]],[/(nexus 9)/i],[u,[h,"HTC"],[a,S]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[u,/_/g," "],[a,p]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[u,[h,"TCL"],[a,S]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[u,[h,"TCL"],[a,p]],[/(itel) ((\w+))/i],[[h,$],u,[a,Q,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[u,[h,"Acer"],[a,S]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[u,[h,"Meizu"],[a,p]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[u,[h,"Ulefone"],[a,p]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[u,[h,"Energizer"],[a,p]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[u,[h,"Cat"],[a,p]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[u,[h,"Smartfren"],[a,p]],[/droid.+; (a(?:015|06[35]|142p?))/i],[u,[h,"Nothing"],[a,p]],[/(imo) (tab \w+)/i,/(infinix) (x1101b?)/i],[h,u,[a,S]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (hmd|imo) ([\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,/(oppo) ?([\w ]+) bui/i],[h,u,[a,p]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[h,u,[a,S]],[/(surface duo)/i],[u,[h,Qe],[a,S]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[u,[h,"Fairphone"],[a,p]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[u,[h,tt],[a,S]],[/(sprint) (\w+)/i],[h,u,[a,p]],[/(kin\.[onetw]{3})/i],[[u,/\./g," "],[h,Qe],[a,p]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[u,[h,st],[a,S]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[u,[h,st],[a,p]],[/smart-tv.+(samsung)/i],[h,[a,R]],[/hbbtv.+maple;(\d+)/i],[[u,/^/,"SmartTV"],[h,ve],[a,R]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,De],[a,R]],[/(apple) ?tv/i],[h,[u,le+" TV"],[a,R]],[/crkey.*devicetype\/chromecast/i],[[u,Y+" Third Generation"],[h,re],[a,R]],[/crkey.*devicetype\/([^/]*)/i],[[u,/^/,"Chromecast "],[h,re],[a,R]],[/fuchsia.*crkey/i],[[u,Y+" Nest Hub"],[h,re],[a,R]],[/crkey/i],[[u,Y],[h,re],[a,R]],[/droid.+aft(\w+)( bui|\))/i],[u,[h,Le],[a,R]],[/(shield \w+ tv)/i],[u,[h,tt],[a,R]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[u,[h,Tt],[a,R]],[/(bravia[\w ]+)( bui|\))/i],[u,[h,ye],[a,R]],[/(mi(tv|box)-?\w+) bui/i],[u,[h,nt],[a,R]],[/Hbbtv.*(technisat) (.*);/i],[h,u,[a,R]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,Ce],[u,Ce],[a,R]],[/droid.+; ([\w- ]+) (?:android tv|smart[- ]?tv)/i],[u,[a,R]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[a,R]],[/(ouya)/i,/(nintendo) (\w+)/i],[h,u,[a,ge]],[/droid.+; (shield)( bui|\))/i],[u,[h,tt],[a,ge]],[/(playstation \w+)/i],[u,[h,ye],[a,ge]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[u,[h,Qe],[a,ge]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[u,[h,ve],[a,F]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[h,u,[a,F]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[u,[h,it],[a,F]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[u,[h,le],[a,F]],[/(opwwe\d{3})/i],[u,[h,Et],[a,F]],[/(moto 360)/i],[u,[h,et],[a,F]],[/(smartwatch 3)/i],[u,[h,ye],[a,F]],[/(g watch r)/i],[u,[h,De],[a,F]],[/droid.+; (wt63?0{2,3})\)/i],[u,[h,st],[a,F]],[/droid.+; (glass) \d/i],[u,[h,re],[a,Je]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,u,[a,Je]],[/; (quest( \d| pro)?)/i],[u,[h,Rt],[a,Je]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[a,me]],[/(aeobc)\b/i],[u,[h,Le],[a,me]],[/(homepod).+mac os/i],[u,[h,le],[a,me]],[/windows iot/i],[[a,me]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+?(mobile|vr|\d) safari/i],[u,[a,Q,{mobile:"Mobile",xr:"VR","*":S}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[a,S]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[a,p]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[u,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[d,[l,_i+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[l,d],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[d,[l,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[l,d],[/ladybird\//i],[[l,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[d,l]],os:[[/microsoft (windows) (vista|xp)/i],[l,d],[/(windows (?:phone(?: os)?|mobile|iot))[\/ ]?([\d\.\w ]*)/i],[l,[d,Q,Pt]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[d,Q,Pt],[l,rt]],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[d,/_/g,"."],[l,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[l,"macOS"],[d,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[d,[l,Y+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[d,[l,Y+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[d,[l,Y+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[d,[l,Y+" Linux"]],[/crkey\/([\d\.]+)/i],[d,[l,Y]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[d,l],[/(ubuntu) ([\w\.]+) like android/i],[[l,/(.+)/,"$1 Touch"],d],[/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen|webos)\w*[-\/; ]?([\d\.]*)/i],[l,d],[/\(bb(10);/i],[d,[l,vt]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[d,[l,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[d,[l,Se+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[d,[l,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[d,[l,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[l,"Chrome OS"],d],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux)(?: arm\w*| x86\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[l,d],[/(sunos) ?([\w\.\d]*)/i],[[l,"Solaris"],d],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[l,d]]},ze=function(){var n={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return K.call(n.init,[[L,[l,d,pe,a]],[V,[D]],[B,[a,u,h]],[W,[l,d]],[N,[l,d]]]),K.call(n.isIgnore,[[L,[d,pe]],[W,[d]],[N,[d]]]),K.call(n.isIgnoreRgx,[[L,/ ?browser$/i],[N,/ ?os$/i]]),K.call(n.toString,[[L,[l,d]],[V,[D]],[B,[h,u]],[W,[l,d]],[N,[l,d]]]),n}(),mi=function(n,e){var t=ze.init[e],i=ze.isIgnore[e]||0,s=ze.isIgnoreRgx[e]||0,r=ze.toString[e]||0;function o(){K.call(this,t)}return o.prototype.getItem=function(){return n},o.prototype.withClientHints=function(){return Z?Z.getHighEntropyValues(mt).then(function(f){return n.setCH(new Lt(f,!1)).parseCH().get()}):n.parseCH().get()},o.prototype.withFeatureCheck=function(){return n.detectFeature().get()},e!=ce&&(o.prototype.is=function(f){var c=!1;for(var _ in this)if(this.hasOwnProperty(_)&&!ot(i,_)&&$(s?fe(s,this[_]):this[_])==$(s?fe(s,f):f)){if(c=!0,f!=J)break}else if(f==J&&c){c=!c;break}return c},o.prototype.toString=function(){var f=oe;for(var c in r)typeof this[r[c]]!==J&&(f+=(f?" ":oe)+this[r[c]]);return f||J}),Z||(o.prototype.then=function(f){var c=this,_=function(){for(var v in c)c.hasOwnProperty(v)&&(this[v]=c[v])};_.prototype={is:o.prototype.is,toString:o.prototype.toString};var m=new _;return f(m),m}),new o};function Lt(n,e){if(n=n||{},K.call(this,mt),e)K.call(this,[[Xe,at(n[X])],[Ye,at(n[ci])],[p,/\?1/.test(n[di])],[u,Te(n[fi])],[ue,Te(n[gt])],[Ze,Te(n[bi])],[D,Te(n[ui])],[se,at(n[hi])],[Ae,Te(n[li])]]);else for(var t in n)this.hasOwnProperty(t)&&typeof n[t]!==J&&(this[t]=n[t])}function Dt(n,e,t,i){return this.get=function(s){return s?this.data.hasOwnProperty(s)?this.data[s]:void 0:this.data},this.set=function(s,r){return this.data[s]=r,this},this.setCH=function(s){return this.uaCH=s,this},this.detectFeature=function(){if(U&&U.userAgent==this.ua)switch(this.itemType){case L:U.brave&&typeof U.brave.isBrave==Ie&&this.set(l,"Brave");break;case B:!this.get(a)&&Z&&Z[p]&&this.set(a,p),this.get(u)=="Macintosh"&&U&&typeof U.standalone!==J&&U.maxTouchPoints&&U.maxTouchPoints>2&&this.set(u,"iPad").set(a,S);break;case N:!this.get(l)&&Z&&Z[ue]&&this.set(l,Z[ue]);break;case ce:var s=this.data,r=function(o){return s[o].getItem().detectFeature().get()};this.set(L,r(L)).set(V,r(V)).set(B,r(B)).set(W,r(W)).set(N,r(N))}return this},this.parseUA=function(){return this.itemType!=ce&&ut.call(this.data,this.ua,this.rgxMap),this.itemType==L&&this.set(pe,ct(this.get(d))),this},this.parseCH=function(){var s=this.uaCH,r=this.rgxMap;switch(this.itemType){case L:case W:var o=s[Ye]||s[Xe],f;if(o)for(var c in o){var _=o[c].brand||o[c],m=o[c].version;this.itemType==L&&!/not.a.brand/i.test(_)&&(!f||/chrom/i.test(f)&&_!=xt)&&(_=Q(_,{Chrome:"Google Chrome",Edge:"Microsoft Edge","Chrome WebView":"Android WebView","Chrome Headless":"HeadlessChrome"}),this.set(l,_).set(d,m).set(pe,ct(m)),f=_),this.itemType==W&&_==xt&&this.set(d,m)}break;case V:var v=s[D];v&&(v&&s[Ae]=="64"&&(v+="64"),ut.call(this.data,v+";",r));break;case B:if(s[p]&&this.set(a,p),s[u]&&(this.set(u,s[u]),!this.get(a)||!this.get(h))){var x={};ut.call(x,"droid 9; "+s[u]+")",r),!this.get(a)&&x.type&&this.set(a,x.type),!this.get(h)&&x.vendor&&this.set(h,x.vendor)}if(s[se]){var w;if(typeof s[se]!="string")for(var P=0;!w&&P<s[se].length;)w=Q(s[se][P++],It);else w=Q(s[se],It);this.set(a,w)}break;case N:var T=s[ue];if(T){var k=s[Ze];T==rt&&(k=parseInt(ct(k),10)>=13?"11":"10"),this.set(l,T).set(d,k)}this.get(l)==rt&&s[u]=="Xbox"&&this.set(l,"Xbox").set(d,void 0);break;case ce:var M=this.data,ie=function(g){return M[g].getItem().setCH(s).parseCH().get()};this.set(L,ie(L)).set(V,ie(V)).set(B,ie(B)).set(W,ie(W)).set(N,ie(N))}return this},K.call(this,[["itemType",n],["ua",e],["uaCH",i],["rgxMap",t],["data",mi(this,n)]]),this}function H(n,e,t){if(typeof n===ae?(je(n,!0)?(typeof e===ae&&(t=e),e=n):(t=n,e=void 0),n=void 0):typeof n===Ge&&!je(e,!0)&&(t=e,e=void 0),t&&typeof t.append===Ie){var i={};t.forEach(function(c,_){i[_]=c}),t=i}if(!(this instanceof H))return new H(n,e,t).getResult();var s=typeof n===Ge?n:t&&t[_t]?t[_t]:U&&U.userAgent?U.userAgent:oe,r=new Lt(t,!0),o=e?gi(At,e):At,f=function(c){return c==ce?function(){return new Dt(c,s,o,r).set("ua",s).set(L,this.getBrowser()).set(V,this.getCPU()).set(B,this.getDevice()).set(W,this.getEngine()).set(N,this.getOS()).get()}:function(){return new Dt(c,s,o[c],r).parseUA().get()}};return K.call(this,[["getBrowser",f(L)],["getCPU",f(V)],["getDevice",f(B)],["getEngine",f(W)],["getOS",f(N)],["getResult",f(ce)],["getUA",function(){return s}],["setUA",function(c){return de(c)&&(s=c.length>Ke?Ce(c,Ke):c),this}]]).setUA(s),this}H.VERSION=ai,H.BROWSER=Ue([l,d,pe,a]),H.CPU=Ue([D]),H.DEVICE=Ue([u,h,a,ge,p,R,S,F,me]),H.ENGINE=H.OS=Ue([l,d]);var xe=(n=>(n.PHONE="phone",n.TABLET="tablet",n.DESKTOP="desktop",n))(xe||{}),ee=(n=>(n.ANDROID="android",n.IOS="ios",n.MAC="mac",n.WIN="win",n.LINUX="linux",n.UNKNOWN="unknown",n))(ee||{});function wi(n){const e=n.toLowerCase();return{detectOS(){return/android/.test(e)?ee.ANDROID:/iphone|ipad|ipod/.test(e)?ee.IOS:/macintosh|mac os x/.test(e)?ee.MAC:/windows/.test(e)?ee.WIN:/linux/.test(e)?ee.LINUX:ee.UNKNOWN},detectDeviceType(){const t=/iphone|ipod|android.*mobile|windows phone|blackberry|webos/.test(e),i=/ipad|android(?!.*mobile)|tablet/.test(e);return t?xe.PHONE:i?xe.TABLET:xe.DESKTOP},detectDeviceName(){const i=new H().getResult();return i.device&&i.device.model?`${i.device.vendor} ${i.device.model}`:i.os&&i.os.name?`${i.os.name} ${i.os.version}`:"Unknown Device"},getTimezone(){const i=new Date().toString().match(/GMT[+-]\d{4}/);return i?i[0]:""},getBrowserName(){return new H(n).getBrowser().name||""},getBrowserVersion(){return new H(n).getBrowser().version||""},detectOSVersion(){let t;return/android/.test(e)?t=e.match(/android\s([0-9_.]+)/):/iphone|ipad|ipod/.test(e)?t=e.match(/os\s([0-9_]+)/):/macintosh|mac os x/.test(e)?t=e.match(/mac os x\s([0-9_.]+)/):/windows/.test(e)?t=e.match(/windows nt\s([0-9_.]+)/):/linux/.test(e)&&(t=e.match(/linux\s?([0-9_.]*)/)),t?t[1].replace(/_/g,"."):"unknown"}}}function b(n,e,t){typeof console<"u"&&console.debug&&(t==="error"?console.error(`[EwaAnalytics SDK] ${n}`,e||""):console.debug(`[EwaAnalytics SDK] ${n}`,e||""))}class vi{config;userAgent;sessionLocated=!1;initialEventSent=!1;constructor(e){this.config=e,this.userAgent=wi(e.globalConfig.initData.userAgent)}createMergedPayload(e,t){return{...e,...this.config.globalConfig.initData,...t,userAgent:this.userAgent,session_id:this.config.sessionId,environment:this.config.globalConfig.initData.environment}}updateSessionState(e){switch(e){case"located":this.sessionLocated=!0,b("Session marked as located");break;case"initial":this.initialEventSent=!0,b("Initial session events marked as sent");break;case"attributed":this.sessionLocated=!0,this.initialEventSent=!0,b("Session marked as attributed and ready for analytics");break}}canTrackAnalyticsEvents(){return this.sessionLocated?this.initialEventSent?!0:(console.warn("[EwaAnalytics SDK] Initial session events not yet sent. Skipping analytics event tracking."),!1):(console.warn("[EwaAnalytics SDK] Session not yet located. Skipping analytics event tracking."),!1)}async trackEvent(e,t,i){try{this.validateEventType(e),this.validatePayload(t);const s=this.createMergedPayload(t,i);if(e==="session")await this.trackSession(s);else if(e==="event")await this.trackAnalyticsEvent(s);else throw new Error(`Invalid event type: ${e}. Must be 'session' or 'event'`)}catch(s){throw console.error(`[EwaAnalytics SDK] Error tracking ${e}:`,s),s}}async trackSession(e){try{const t=await si(e);b(`Tracking session ${e.event_subtype}:`,t),this.updateSessionState(e.event_subtype),await this.sendToTransport(t,"session")}catch(t){throw console.error("[EwaAnalytics SDK] Error tracking session:",t),t}}async trackAnalyticsEvent(e){try{if(!this.canTrackAnalyticsEvents())return;const t=await ri(e);b("Tracking event:",t),await this.sendToTransport(t,"event")}catch(t){throw console.error("[EwaAnalytics SDK] Error tracking event:",t),t}}async sendToTransport(e,t){const i=t==="session"?"analytics:sessions":"analytics:events";switch(this.config.globalConfig.transport){case"http":await this.postToHttp(e);break;case"websocket":await this.publishToWebSocket(i,e);break;default:throw new Error(`Unsupported transport: ${this.config.globalConfig.transport}`)}}async postToHttp(e){if(!this.config.apiInstance)throw new Error("HTTP API instance not available");try{await this.config.apiInstance.post("/events",e)}catch(t){throw console.error("[EwaAnalytics SDK] HTTP POST failed:",t),t}}async publishToWebSocket(e,t){if(!this.config.connection)throw new Error("WebSocket connection not available");try{this.config.connection.publish(e,t)}catch(i){throw console.error("[EwaAnalytics SDK] WebSocket publish failed:",i),i}}async trackSessionTyped(e,t){this.validatePayload(e);const i=t?{...t,...e}:e;return this.trackEvent("session",i)}async trackEventTyped(e,t){this.validatePayload(e);const i=t?{...t,...e}:e;return this.trackEvent("event",i)}getTransport(){return this.config.globalConfig.transport}getApiUrl(){return this.config.globalConfig.apiUrl}isWebSocketTransport(){return this.config.globalConfig.transport==="websocket"}isHttpTransport(){return this.config.globalConfig.transport==="http"}isSessionLocated(){return this.sessionLocated}areInitialEventsSent(){return this.initialEventSent}getSessionState(){return{located:this.sessionLocated,initialEventSent:this.initialEventSent}}setSessionLocated(e=!0){this.sessionLocated=e,b(`Session located state manually set to: ${e}`)}setInitialEventsSent(e=!0){this.initialEventSent=e,b(`Initial events sent state manually set to: ${e}`)}resetSessionState(){this.sessionLocated=!1,this.initialEventSent=!1,b("Session state reset")}validateEventType(e){if(!e||typeof e!="string")throw new Error("Event type is required and must be a string");if(!["session","event"].includes(e))throw new Error(`Invalid event type: ${e}. Must be 'session' or 'event'`)}validatePayload(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Payload is required and must be an object");if(!e.event_name)throw new Error("Payload must contain an event_name field")}}function Re(n,e,t,i){function s(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function f(m){try{_(i.next(m))}catch(v){o(v)}}function c(m){try{_(i.throw(m))}catch(v){o(v)}}function _(m){m.done?r(m.value):s(m.value).then(f,c)}_((i=i.apply(n,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;function yi(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var lt={exports:{}},be=typeof Reflect=="object"?Reflect:null,Ut=be&&typeof be.apply=="function"?be.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Ne;be&&typeof be.ownKeys=="function"?Ne=be.ownKeys:Object.getOwnPropertySymbols?Ne=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ne=function(e){return Object.getOwnPropertyNames(e)};function Si(n){console&&console.warn&&console.warn(n)}var jt=Number.isNaN||function(e){return e!==e};function y(){y.init.call(this)}lt.exports=y,lt.exports.once=Ci,y.EventEmitter=y,y.prototype._events=void 0,y.prototype._eventsCount=0,y.prototype._maxListeners=void 0;var zt=10;function Me(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(y,"defaultMaxListeners",{enumerable:!0,get:function(){return zt},set:function(n){if(typeof n!="number"||n<0||jt(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");zt=n}}),y.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},y.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||jt(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Nt(n){return n._maxListeners===void 0?y.defaultMaxListeners:n._maxListeners}y.prototype.getMaxListeners=function(){return Nt(this)},y.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var s=e==="error",r=this._events;if(r!==void 0)s=s&&r.error===void 0;else if(!s)return!1;if(s){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var f=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var c=r[e];if(c===void 0)return!1;if(typeof c=="function")Ut(c,this,t);else for(var _=c.length,m=Bt(c,_),i=0;i<_;++i)Ut(m[i],this,t);return!0};function Mt(n,e,t,i){var s,r,o;if(Me(t),r=n._events,r===void 0?(r=n._events=Object.create(null),n._eventsCount=0):(r.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),r=n._events),o=r[e]),o===void 0)o=r[e]=t,++n._eventsCount;else if(typeof o=="function"?o=r[e]=i?[t,o]:[o,t]:i?o.unshift(t):o.push(t),s=Nt(n),s>0&&o.length>s&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=n,f.type=e,f.count=o.length,Si(f)}return n}y.prototype.addListener=function(e,t){return Mt(this,e,t,!1)},y.prototype.on=y.prototype.addListener,y.prototype.prependListener=function(e,t){return Mt(this,e,t,!0)};function ki(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Wt(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},s=ki.bind(i);return s.listener=t,i.wrapFn=s,s}y.prototype.once=function(e,t){return Me(t),this.on(e,Wt(this,e,t)),this},y.prototype.prependOnceListener=function(e,t){return Me(t),this.prependListener(e,Wt(this,e,t)),this},y.prototype.removeListener=function(e,t){var i,s,r,o,f;if(Me(t),s=this._events,s===void 0)return this;if(i=s[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(r=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){f=i[o].listener,r=o;break}if(r<0)return this;r===0?i.shift():Ei(i,r),i.length===1&&(s[e]=i[0]),s.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this},y.prototype.off=y.prototype.removeListener,y.prototype.removeAllListeners=function(e){var t,i,s;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var r=Object.keys(i),o;for(s=0;s<r.length;++s)o=r[s],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this};function Ht(n,e,t){var i=n._events;if(i===void 0)return[];var s=i[e];return s===void 0?[]:typeof s=="function"?t?[s.listener||s]:[s]:t?Ti(s):Bt(s,s.length)}y.prototype.listeners=function(e){return Ht(this,e,!0)},y.prototype.rawListeners=function(e){return Ht(this,e,!1)},y.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):qt.call(n,e)},y.prototype.listenerCount=qt;function qt(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}y.prototype.eventNames=function(){return this._eventsCount>0?Ne(this._events):[]};function Bt(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function Ei(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Ti(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function Ci(n,e){return new Promise(function(t,i){function s(o){n.removeListener(e,r),i(o)}function r(){typeof n.removeListener=="function"&&n.removeListener("error",s),t([].slice.call(arguments))}Ft(n,e,r,{once:!0}),e!=="error"&&xi(n,s,{once:!0})})}function xi(n,e,t){typeof n.on=="function"&&Ft(n,"error",e,t)}function Ft(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function s(r){i.once&&n.removeEventListener(e,s),t(r)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var Ri=lt.exports,Vt=yi(Ri),E;(function(n){n[n.timeout=1]="timeout",n[n.transportClosed=2]="transportClosed",n[n.clientDisconnected=3]="clientDisconnected",n[n.clientClosed=4]="clientClosed",n[n.clientConnectToken=5]="clientConnectToken",n[n.clientRefreshToken=6]="clientRefreshToken",n[n.subscriptionUnsubscribed=7]="subscriptionUnsubscribed",n[n.subscriptionSubscribeToken=8]="subscriptionSubscribeToken",n[n.subscriptionRefreshToken=9]="subscriptionRefreshToken",n[n.transportWriteError=10]="transportWriteError",n[n.connectionClosed=11]="connectionClosed",n[n.badConfiguration=12]="badConfiguration"})(E||(E={}));var te;(function(n){n[n.connectCalled=0]="connectCalled",n[n.transportClosed=1]="transportClosed",n[n.noPing=2]="noPing",n[n.subscribeTimeout=3]="subscribeTimeout",n[n.unsubscribeError=4]="unsubscribeError"})(te||(te={}));var Oe;(function(n){n[n.disconnectCalled=0]="disconnectCalled",n[n.unauthorized=1]="unauthorized",n[n.badProtocol=2]="badProtocol",n[n.messageSizeLimit=3]="messageSizeLimit"})(Oe||(Oe={}));var We;(function(n){n[n.subscribeCalled=0]="subscribeCalled",n[n.transportClosed=1]="transportClosed"})(We||(We={}));var He;(function(n){n[n.unsubscribeCalled=0]="unsubscribeCalled",n[n.unauthorized=1]="unauthorized",n[n.clientClosed=2]="clientClosed"})(He||(He={}));var C;(function(n){n.Disconnected="disconnected",n.Connecting="connecting",n.Connected="connected"})(C||(C={}));var I;(function(n){n.Unsubscribed="unsubscribed",n.Subscribing="subscribing",n.Subscribed="subscribed"})(I||(I={}));function Oi(n,e){return n.lastIndexOf(e,0)===0}function $t(n){return n==null?!1:typeof n=="function"}function Pi(n,e){if(globalThis.console){const t=globalThis.console[n];$t(t)&&t.apply(globalThis.console,e)}}function Ii(n,e){return Math.floor(Math.random()*(e-n+1)+n)}function qe(n,e,t){n>31&&(n=31);const i=Ii(0,Math.min(t,e*Math.pow(2,n)));return Math.min(t,e+i)}function Ai(n){return"error"in n&&n.error!==null}function Be(n){return Math.min(n*1e3,2147483647)}class Li extends Vt{constructor(e,t,i){super(),this._resubscribeTimeout=null,this._refreshTimeout=null,this.channel=t,this.state=I.Unsubscribed,this._centrifuge=e,this._token="",this._getToken=null,this._data=null,this._getData=null,this._recover=!1,this._offset=null,this._epoch=null,this._recoverable=!1,this._positioned=!1,this._joinLeave=!1,this._minResubscribeDelay=500,this._maxResubscribeDelay=2e4,this._resubscribeTimeout=null,this._resubscribeAttempts=0,this._promises={},this._promiseId=0,this._inflight=!1,this._refreshTimeout=null,this._delta="",this._delta_negotiated=!1,this._prevValue=null,this._unsubPromise=Promise.resolve(),this._setOptions(i),this._centrifuge._debugEnabled?(this.on("state",s=>{this._debug("subscription state",t,s.oldState,"->",s.newState)}),this.on("error",s=>{this._debug("subscription error",t,s)})):this.on("error",function(){Function.prototype()})}ready(e){return this.state===I.Unsubscribed?Promise.reject({code:E.subscriptionUnsubscribed,message:this.state}):this.state===I.Subscribed?Promise.resolve():new Promise((t,i)=>{const s={resolve:t,reject:i};e&&(s.timeout=setTimeout(function(){i({code:E.timeout,message:"timeout"})},e)),this._promises[this._nextPromiseId()]=s})}subscribe(){this._isSubscribed()||(this._resubscribeAttempts=0,this._setSubscribing(We.subscribeCalled,"subscribe called"))}unsubscribe(){this._unsubPromise=this._setUnsubscribed(He.unsubscribeCalled,"unsubscribe called",!0)}publish(e){const t=this;return this._methodCall().then(function(){return t._centrifuge.publish(t.channel,e)})}presence(){const e=this;return this._methodCall().then(function(){return e._centrifuge.presence(e.channel)})}presenceStats(){const e=this;return this._methodCall().then(function(){return e._centrifuge.presenceStats(e.channel)})}history(e){const t=this;return this._methodCall().then(function(){return t._centrifuge.history(t.channel,e)})}_methodCall(){return this._isSubscribed()?Promise.resolve():this._isUnsubscribed()?Promise.reject({code:E.subscriptionUnsubscribed,message:this.state}):new Promise((e,t)=>{const i=setTimeout(function(){t({code:E.timeout,message:"timeout"})},this._centrifuge._config.timeout);this._promises[this._nextPromiseId()]={timeout:i,resolve:e,reject:t}})}_nextPromiseId(){return++this._promiseId}_needRecover(){return this._recover===!0}_isUnsubscribed(){return this.state===I.Unsubscribed}_isSubscribing(){return this.state===I.Subscribing}_isSubscribed(){return this.state===I.Subscribed}_setState(e){if(this.state!==e){const t=this.state;return this.state=e,this.emit("state",{newState:e,oldState:t,channel:this.channel}),!0}return!1}_usesToken(){return this._token!==""||this._getToken!==null}_clearSubscribingState(){this._resubscribeAttempts=0,this._clearResubscribeTimeout()}_clearSubscribedState(){this._clearRefreshTimeout()}_setSubscribed(e){if(!this._isSubscribing())return;this._clearSubscribingState(),e.recoverable&&(this._recover=!0,this._offset=e.offset||0,this._epoch=e.epoch||""),e.delta?this._delta_negotiated=!0:this._delta_negotiated=!1,this._setState(I.Subscribed);const t=this._centrifuge._getSubscribeContext(this.channel,e);this.emit("subscribed",t),this._resolvePromises();const i=e.publications;if(i&&i.length>0)for(const s in i)i.hasOwnProperty(s)&&this._handlePublication(i[s]);e.expires===!0&&(this._refreshTimeout=setTimeout(()=>this._refresh(),Be(e.ttl)))}_setSubscribing(e,t){return Re(this,void 0,void 0,function*(){this._isSubscribing()||(this._isSubscribed()&&this._clearSubscribedState(),this._setState(I.Subscribing)&&this.emit("subscribing",{channel:this.channel,code:e,reason:t}),this._centrifuge._transport&&this._centrifuge._transport.emulation()&&(yield this._unsubPromise),this._isSubscribing()&&this._subscribe())})}_subscribe(){return this._debug("subscribing on",this.channel),this._isTransportOpen()?this._inflight?null:(this._inflight=!0,this._canSubscribeWithoutGettingToken()?this._subscribeWithoutToken():(this._getSubscriptionToken().then(e=>this._handleTokenResponse(e)).catch(e=>this._handleTokenError(e)),null)):(this._debug("delay subscribe on",this.channel,"till connected"),null)}_isTransportOpen(){return this._centrifuge._transportIsOpen}_canSubscribeWithoutGettingToken(){return!this._usesToken()||!!this._token}_subscribeWithoutToken(){return this._getData?(this._getDataAndSubscribe(this._token),null):this._sendSubscribe(this._token)}_getDataAndSubscribe(e){if(!this._getData){this._inflight=!1;return}this._getData({channel:this.channel}).then(t=>{if(!this._isSubscribing()){this._inflight=!1;return}this._data=t,this._sendSubscribe(e)}).catch(t=>this._handleGetDataError(t))}_handleGetDataError(e){if(!this._isSubscribing()){this._inflight=!1;return}if(e instanceof G){this._inflight=!1,this._failUnauthorized();return}this.emit("error",{type:"subscribeData",channel:this.channel,error:{code:E.badConfiguration,message:e?.toString()||""}}),this._inflight=!1,this._scheduleResubscribe()}_handleTokenResponse(e){if(!this._isSubscribing()){this._inflight=!1;return}if(!e){this._inflight=!1,this._failUnauthorized();return}this._token=e,this._getData?this._getDataAndSubscribe(e):this._sendSubscribe(e)}_handleTokenError(e){if(!this._isSubscribing()){this._inflight=!1;return}if(e instanceof G){this._inflight=!1,this._failUnauthorized();return}this.emit("error",{type:"subscribeToken",channel:this.channel,error:{code:E.subscriptionSubscribeToken,message:e?.toString()||""}}),this._inflight=!1,this._scheduleResubscribe()}_sendSubscribe(e){if(!this._isTransportOpen())return this._inflight=!1,null;const t=this._buildSubscribeCommand(e);return this._centrifuge._call(t).then(i=>{this._inflight=!1;const s=i.reply.subscribe;this._handleSubscribeResponse(s),i.next&&i.next()},i=>{this._inflight=!1,this._handleSubscribeError(i.error),i.next&&i.next()}),t}_buildSubscribeCommand(e){const t={channel:this.channel};if(e&&(t.token=e),this._data&&(t.data=this._data),this._positioned&&(t.positioned=!0),this._recoverable&&(t.recoverable=!0),this._joinLeave&&(t.join_leave=!0),this._needRecover()){t.recover=!0;const i=this._getOffset();i&&(t.offset=i);const s=this._getEpoch();s&&(t.epoch=s)}return this._delta&&(t.delta=this._delta),{subscribe:t}}_debug(...e){this._centrifuge._debug(...e)}_handleSubscribeError(e){if(this._isSubscribing()){if(e.code===E.timeout){this._centrifuge._disconnect(te.subscribeTimeout,"subscribe timeout",!0);return}this._subscribeError(e)}}_handleSubscribeResponse(e){this._isSubscribing()&&this._setSubscribed(e)}_setUnsubscribed(e,t,i){if(this._isUnsubscribed())return Promise.resolve();let s=Promise.resolve();return this._isSubscribed()?(i&&(s=this._centrifuge._unsubscribe(this)),this._clearSubscribedState()):this._isSubscribing()&&(this._inflight&&i&&(s=this._centrifuge._unsubscribe(this)),this._clearSubscribingState()),this._inflight=!1,this._setState(I.Unsubscribed)&&this.emit("unsubscribed",{channel:this.channel,code:e,reason:t}),this._rejectPromises({code: