/**
 * Fingerprint BotD v2.0.0 - Copyright (c) FingerprintJS, Inc, 2025 (https://fingerprint.com)
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
 */
const e={Awesomium:"awesomium",Cef:"cef",CefSharp:"cefsharp",CoachJS:"coachjs",Electron:"electron",FMiner:"fminer",Geb:"geb",NightmareJS:"nightmarejs",Phantomas:"phantomas",PhantomJS:"phantomjs",Rhino:"rhino",Selenium:"selenium",Sequentum:"sequentum",SlimerJS:"slimerjs",WebDriverIO:"webdriverio",WebDriver:"webdriver",HeadlessChrome:"headless_chrome",Unknown:"unknown"};class n extends Error{constructor(e,t){super(t),this.state=e,this.name="BotdError",Object.setPrototypeOf(this,n.prototype)}}function t(n,t){const i={};let o={bot:!1};for(const r in t){const a=(0,t[r])(n);let s={bot:!1};"string"==typeof a?s={bot:!0,botKind:a}:a&&(s={bot:!0,botKind:e.Unknown}),i[r]=s,s.bot&&(o=s)}return[i,o]}async function i(e){const t={},i=Object.keys(e);return await Promise.all(i.map((async i=>{const o=e[i];try{t[i]={value:await o(),state:0}}catch(r){t[i]=r instanceof n?{state:r.state,error:`${r.name}: ${r.message}`}:{state:-3,error:r instanceof Error?`${r.name}: ${r.message}`:String(r)}}}))),t}function o(e,n){return-1!==e.indexOf(n)}function r(e,n){return-1!==e.indexOf(n)}function a(e,n){if("find"in e)return e.find(n);for(let t=0;t<e.length;t++)if(n(e[t],t,e))return e[t]}function s(e){return Object.getOwnPropertyNames(e)}function u(e,...n){for(const t of n)if("string"==typeof t){if(o(e,t))return!0}else{if(null!=a(e,(e=>t.test(e))))return!0}return!1}function c(e){return e.reduce(((e,n)=>e+(n?1:0)),0)}const d={detectAppVersion:function({appVersion:n}){return 0===n.state&&(/headless/i.test(n.value)?e.HeadlessChrome:/electron/i.test(n.value)?e.Electron:/slimerjs/i.test(n.value)?e.SlimerJS:void 0)},detectDocumentAttributes:function({documentElementKeys:n}){return 0===n.state&&(u(n.value,"selenium","webdriver","driver")?e.Selenium:void 0)},detectErrorTrace:function({errorTrace:n}){return 0===n.state&&(/PhantomJS/i.test(n.value)?e.PhantomJS:void 0)},detectEvalLengthInconsistency:function({evalLength:e,browserKind:n,browserEngineKind:t}){if(0!==e.state||0!==n.state||0!==t.state)return;const i=e.value;return"unknown"!==t.value&&(37===i&&!o(["webkit","gecko"],t.value)||39===i&&!o(["internet_explorer"],n.value)||33===i&&!o(["chromium"],t.value))},detectFunctionBind:function({functionBind:n}){if(-2===n.state)return e.PhantomJS},detectLanguagesLengthInconsistency:function({languages:n}){if(0===n.state&&0===n.value.length)return e.HeadlessChrome},detectNotificationPermissions:function({notificationPermissions:n,browserKind:t}){return 0===t.state&&"chrome"===t.value&&(0===n.state&&n.value?e.HeadlessChrome:void 0)},detectPluginsArray:function({pluginsArray:n}){if(0===n.state&&!n.value)return e.HeadlessChrome},detectPluginsLengthInconsistency:function({pluginsLength:n,android:t,browserKind:i,browserEngineKind:o}){if(0===n.state&&0===t.state&&0===i.state&&0===o.state&&"chrome"===i.value&&!t.value&&"chromium"===o.value)return 0===n.value?e.HeadlessChrome:void 0},detectProcess:function({process:n}){var t;return 0===n.state&&("renderer"===n.value.type||null!=(null===(t=n.value.versions)||void 0===t?void 0:t.electron)?e.Electron:void 0)},detectUserAgent:function({userAgent:n}){return 0===n.state&&(/PhantomJS/i.test(n.value)?e.PhantomJS:/Headless/i.test(n.value)?e.HeadlessChrome:/Electron/i.test(n.value)?e.Electron:/slimerjs/i.test(n.value)?e.SlimerJS:void 0)},detectWebDriver:function({webDriver:n}){if(0===n.state&&n.value)return e.HeadlessChrome},detectWebGL:function({webGL:n}){if(0===n.state){const{vendor:t,renderer:i}=n.value;if("Brian Paul"==t&&"Mesa OffScreen"==i)return e.HeadlessChrome}},detectWindowExternal:function({windowExternal:n}){return 0===n.state&&(/Sequentum/i.test(n.value)?e.Sequentum:void 0)},detectWindowSize:function({windowSize:n,documentFocus:t}){if(0!==n.state||0!==t.state)return!1;const{outerWidth:i,outerHeight:o}=n.value;return t.value&&0===i&&0===o?e.HeadlessChrome:void 0},detectMimeTypesConsistent:function({mimeTypesConsistent:n}){if(0===n.state&&!n.value)return e.Unknown},detectProductSub:function({productSub:n,browserKind:t}){return 0===n.state&&0===t.state&&("chrome"!==t.value&&"safari"!==t.value&&"opera"!==t.value&&"wechat"!==t.value||"20030107"===n.value?void 0:e.Unknown)},detectDistinctiveProperties:function({distinctiveProps:e}){if(0!==e.state)return!1;const n=e.value;let t;for(t in n)if(n[t])return t}};function l(){var e,n;const t=window,i=navigator;return c(["webkitPersistentStorage"in i,"webkitTemporaryStorage"in i,0===i.vendor.indexOf("Google"),"webkitResolveLocalFileSystemURL"in t,"BatteryManager"in t,"webkitMediaStream"in t,"webkitSpeechGrammar"in t])>=5?"chromium":c(["ApplePayError"in t,"CSSPrimitiveValue"in t,"Counter"in t,0===i.vendor.indexOf("Apple"),"getStorageUpdates"in i,"WebKitMediaKeys"in t])>=4?"webkit":c(["buildID"in navigator,"MozAppearance"in(null!==(n=null===(e=document.documentElement)||void 0===e?void 0:e.style)&&void 0!==n?n:{}),"onmozfullscreenchange"in t,"mozInnerScreenX"in t,"CSSMozDocumentRule"in t,"CanvasCaptureMediaStream"in t])>=4?"gecko":"unknown"}const w={android:function(){const e=l(),n="gecko"===e,t=window,i=navigator,o="connection";return"chromium"===e?c([!("SharedWorker"in t),i[o]&&"ontypechange"in i[o],!("sinkId"in new Audio)])>=2:!!n&&c(["onorientationchange"in t,"orientation"in t,/android/i.test(i.appVersion)])>=2},browserKind:function(){var e;const n=null===(e=navigator.userAgent)||void 0===e?void 0:e.toLowerCase();return r(n,"edg/")?"edge":r(n,"trident")||r(n,"msie")?"internet_explorer":r(n,"wechat")?"wechat":r(n,"firefox")?"firefox":r(n,"opera")||r(n,"opr")?"opera":r(n,"chrome")?"chrome":r(n,"safari")?"safari":"unknown"},browserEngineKind:l,documentFocus:function(){return void 0!==document.hasFocus&&document.hasFocus()},userAgent:function(){return navigator.userAgent},appVersion:function(){const e=navigator.appVersion;if(null==e)throw new n(-1,"navigator.appVersion is undefined");return e},rtt:function(){if(void 0===navigator.connection)throw new n(-1,"navigator.connection is undefined");if(void 0===navigator.connection.rtt)throw new n(-1,"navigator.connection.rtt is undefined");return navigator.connection.rtt},windowSize:function(){return{outerWidth:window.outerWidth,outerHeight:window.outerHeight,innerWidth:window.innerWidth,innerHeight:window.innerHeight}},pluginsLength:function(){if(void 0===navigator.plugins)throw new n(-1,"navigator.plugins is undefined");if(void 0===navigator.plugins.length)throw new n(-3,"navigator.plugins.length is undefined");return navigator.plugins.length},pluginsArray:function(){if(void 0===navigator.plugins)throw new n(-1,"navigator.plugins is undefined");if(void 0===window.PluginArray)throw new n(-1,"window.PluginArray is undefined");return navigator.plugins instanceof PluginArray},errorTrace:function(){try{null[0]()}catch(e){if(e instanceof Error&&null!=e.stack)return e.stack.toString()}throw new n(-3,"errorTrace signal unexpected behaviour")},productSub:function(){const{productSub:e}=navigator;if(void 0===e)throw new n(-1,"navigator.productSub is undefined");return e},windowExternal:function(){if(void 0===window.external)throw new n(-1,"window.external is undefined");const{external:e}=window;if("function"!=typeof e.toString)throw new n(-2,"window.external.toString is not a function");return e.toString()},mimeTypesConsistent:function(){if(void 0===navigator.mimeTypes)throw new n(-1,"navigator.mimeTypes is undefined");const{mimeTypes:e}=navigator;let t=Object.getPrototypeOf(e)===MimeTypeArray.prototype;for(let n=0;n<e.length;n++)t&&(t=Object.getPrototypeOf(e[n])===MimeType.prototype);return t},evalLength:function(){return eval.toString().length},webGL:function(){const e=document.createElement("canvas");if("function"!=typeof e.getContext)throw new n(-2,"HTMLCanvasElement.getContext is not a function");const t=e.getContext("webgl");if(null===t)throw new n(-4,"WebGLRenderingContext is null");if("function"!=typeof t.getParameter)throw new n(-2,"WebGLRenderingContext.getParameter is not a function");return{vendor:t.getParameter(t.VENDOR),renderer:t.getParameter(t.RENDERER)}},webDriver:function(){if(null==navigator.webdriver)throw new n(-1,"navigator.webdriver is undefined");return navigator.webdriver},languages:function(){const e=navigator,n=[],t=e.language||e.userLanguage||e.browserLanguage||e.systemLanguage;if(void 0!==t&&n.push([t]),Array.isArray(e.languages)){"chromium"===l()&&function(){const e=window;return c([!("MediaSettingsRange"in e),"RTCEncodedAudioFrame"in e,""+e.Intl=="[object Intl]",""+e.Reflect=="[object Reflect]"])>=3}()||n.push(e.languages)}else if("string"==typeof e.languages){const t=e.languages;t&&n.push(t.split(","))}return n},notificationPermissions:async function(){if(void 0===window.Notification)throw new n(-1,"window.Notification is undefined");if(void 0===navigator.permissions)throw new n(-1,"navigator.permissions is undefined");const{permissions:e}=navigator;if("function"!=typeof e.query)throw new n(-2,"navigator.permissions.query is not a function");try{const n=await e.query({name:"notifications"});return"denied"===window.Notification.permission&&"prompt"===n.state}catch(t){throw new n(-3,"notificationPermissions signal unexpected behaviour")}},documentElementKeys:function(){if(void 0===document.documentElement)throw new n(-1,"document.documentElement is undefined");const{documentElement:e}=document;if("function"!=typeof e.getAttributeNames)throw new n(-2,"document.documentElement.getAttributeNames is not a function");return e.getAttributeNames()},functionBind:function(){if(void 0===Function.prototype.bind)throw new n(-2,"Function.prototype.bind is undefined");return Function.prototype.bind.toString()},process:function(){const{process:e}=window,t="window.process is";if(void 0===e)throw new n(-1,`${t} undefined`);if(e&&"object"!=typeof e)throw new n(-3,`${t} not an object`);return e},distinctiveProps:function(){const n={[e.Awesomium]:{window:["awesomium"]},[e.Cef]:{window:["RunPerfTest"]},[e.CefSharp]:{window:["CefSharp"]},[e.CoachJS]:{window:["emit"]},[e.FMiner]:{window:["fmget_targets"]},[e.Geb]:{window:["geb"]},[e.NightmareJS]:{window:["__nightmare","nightmare"]},[e.Phantomas]:{window:["__phantomas"]},[e.PhantomJS]:{window:["callPhantom","_phantom"]},[e.Rhino]:{window:["spawn"]},[e.Selenium]:{window:["_Selenium_IDE_Recorder","_selenium","calledSelenium",/^([a-z]){3}_.*_(Array|Promise|Symbol)$/],document:["__selenium_evaluate","selenium-evaluate","__selenium_unwrapped"]},[e.WebDriverIO]:{window:["wdioElectron"]},[e.WebDriver]:{window:["webdriver","__webdriverFunc","__lastWatirAlert","__lastWatirConfirm","__lastWatirPrompt","_WEBDRIVER_ELEM_CACHE","ChromeDriverw"],document:["__webdriver_script_fn","__driver_evaluate","__webdriver_evaluate","__fxdriver_evaluate","__driver_unwrapped","__webdriver_unwrapped","__fxdriver_unwrapped","__webdriver_script_fn","__webdriver_script_func","__webdriver_script_function","$cdc_asdjflasutopfhvcZLmcf","$cdc_asdjflasutopfhvcZLmcfl_","$chrome_asyncScriptInfo","__$webdriverAsyncExecutor"]},[e.HeadlessChrome]:{window:["domAutomation","domAutomationController"]}};let t;const i={},o=s(window);let r=[];for(t in void 0!==window.document&&(r=s(window.document)),n){const e=n[t];if(void 0!==e){const n=void 0!==e.window&&u(o,...e.window),a=!(void 0===e.document||!r.length)&&u(r,...e.document);i[t]=n||a}}return i}};class f{constructor(){this.components=void 0,this.detections=void 0}getComponents(){return this.components}getDetections(){return this.detections}detect(){if(void 0===this.components)throw new Error("BotDetector.detect can't be called before BotDetector.collect");const[e,n]=t(this.components,d);return this.detections=e,n}async collect(){return this.components=await i(w),this.components}}async function m({monitoring:e=!0}={}){const n=new f;return await n.collect(),n}var v={load:m};export{e as BotKind,n as BotdError,i as collect,v as default,t as detect,d as detectors,m as load,w as sources};
