"use strict";function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function n(){n=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof h?t:h,a=Object.create(i.prototype),c=new x(n||[]);return o(a,"_invoke",{value:O(e,r,c)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=f;var p={};function h(){}function d(){}function v(){}var y={};s(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(j([])));g&&g!==t&&r.call(g,a)&&(y=g);var w=v.prototype=h.prototype=Object.create(y);function b(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(o,i,a,c){var u=l(e[o],e,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(f).then((function(e){s.value=e,a(s)}),(function(e){return n("throw",e,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function O(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return A()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=S(a,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function S(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=l(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,p;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function j(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:A}}function A(){return{value:void 0,done:!0}}return d.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:d,configurable:!0}),d.displayName=s(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,s(e,u,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},b(E.prototype),s(E.prototype,c,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new E(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(w),s(w,u,"Generator"),s(w,a,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=j,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){i(a,n,o,c,u,"next",e)}function u(e){i(a,n,o,c,u,"throw",e)}c(void 0)}))}}function c(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var f,l;!function(e){e.DOM_NOT_FOUND="UAParser is not running in the browser context (no DOM available), you must pass header map as a parameter to do the explicit device detection.",e.REQUIRED_RESOURCE_KEY="Resource key required. Configure one at https://configure.51degrees.com/S6fGMDKw",e.EMPTY_RESOURCE_KEY="Empty resource key provided. Configure one at https://configure.51degrees.com/S6fGMDKw",e.INCOMPLETE_HEADER_MAP="Incomplete header map. Must include either User-Agent or Sec-CH-UA header.",e.ATTEMPT_TO_USE_USER_AGENT="You are trying to use the legacy UAParser and pass User-Agent string as a parameter, please refer to the new API: await UAParser([resource-key][, header-map]).  Configure a resource key at https://configure.51degrees.com",e.INVALID_RESOURCE_KEY="Invalid resource key. Configure one at https://configure.51degrees.com/S6fGMDKw",e.HEADERS_NOT_HASHMAP="Invalid header map. Header map object must be a valid hash map.",e.INVALID_HEADERS_VALUE="Invalid header map. Header values must be of type string.",e.PROMISE_MISUSE="You are likely using a legacy API. The new UAParser call returns a promise that must be awaited."}(f||(f={})),function(e){e.USING_DEFAULT_KEY="Resource key not provided. Using default resource key"}(l||(l={}));var p={get:function(e,t){if("then"===t||"catch"===t)return e[t].bind(e);if(e instanceof Promise)throw new Error(f.PROMISE_MISUSE);return Reflect.get(e,t)}},h=["getUA","setUA"],d={get:function(e,t){if(h.includes(t))throw new Error("".concat(t," is a UAParser result deprecated method, consider using `result.device` that contains comprehensive device data."));return Reflect.get(e,t)}},v={Console:"console",Desktop:"desktop",EReader:"embedded",IoT:"embedded",MediaHub:"smarttv",Mobile:"mobile",NotMobile:null,Router:"embedded",SmallScreen:"embedded",SmartPhone:"mobile",SmartSpeaker:"embedded",SmartWatch:"wearable",Tablet:"tablet",Tv:"smarttv"},y={browser:{name:"browsername",version:"browservendor"},cpu:{architecture:void 0},device:{model:"hardwaremodel",type:"devicetype",vendor:"hardwarevendor"},engine:{name:"layoutengine",version:void 0},os:{name:"platformname",version:"platformversion"}},m={getBrowser:function(){return y.browser},getCPU:function(){return y.cpu},getDevice:function(){return y.device},getEngine:function(){return y.engine},getOS:function(){return y.os},getResult:function(){return{os:m.getOS(),browser:m.getBrowser(),cpu:m.getCPU(),device:m.getDevice(),engine:m.getEngine()}}},g=function(e){for(var t=r({},e),n=0,o=Object.entries(y);n<o.length;n++){var i=u(o[n],2),a=i[0],c=i[1];t[a]||(t[a]={}),t[a]=Object.assign(t[a],w(t,c))}for(var s=0,f=Object.entries(m);s<f.length;s++){var l=u(f[s],2),p=l[0],h=l[1];t[p]=b(t,h)}return t},w=function(e,t){for(var n,o=r({},e.device),i={},a=0,c=Object.entries(t);a<c.length;a++){var s=u(c[a],2),f=s[0],l=s[1];i[f]||(i[f]=""),void 0===l&&(i[f]=void 0),l&&o[l]&&"unknown"===o[l].toLowerCase()?i[f]=void 0:i[f]="devicetype"!==l?o[l]:(n=o[l],v[n])}return i},b=function(e,t){var r=t();if(r.browser){for(var n={},o=0,i=Object.entries(r);o<i.length;o++){var a=u(i[o],2),c=a[0],s=a[1];n[c]||(n[c]={}),n[c]=w(e,s)}return function(){return n}}return function(){return w(e,r)}},E=function(){var e=a(n().mark((function e(t){var r;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,(r=document.createElement("script")).type="text/javascript",r.async=!0,r.src="https://cloud.51degrees.com/api/v4/".concat(t,".js?cloud.client.product=ua-parser"),document.head.appendChild(r),e.abrupt("return",new Promise((function(e,t){r.onload=function(){fod.complete((function(t){var r=g(t),n=new Proxy(r,d);e(n)}))},r.onerror=function(){t("UAParser-51D device detection failed to load javascript resource")}})));case 9:throw e.prev=9,e.t0=e.catch(0),new Error("Injection request failed: ".concat(e.t0));case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t){return e.apply(this,arguments)}}(),O=function(e,t){return S(new URL("https://cloud.51degrees.com/api/v4/".concat(e,".json?cloud.client.product=ua-parser")),t)},S=function(){var t=a(n().mark((function t(r,o){var i,a,c,u,s,f,l;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i="&"+new URLSearchParams(o).toString(),!("undefined"!=typeof window&&Object.keys(window).length>0)){t.next=17;break}return t.prev=2,t.next=5,fetch(r+i);case 5:return a=t.sent,t.next=8,a.json();case 8:return c=t.sent,t.abrupt("return",{status:a.status,response:c});case 12:throw t.prev=12,t.t0=t.catch(2),new Error("Request failed: ".concat(t.t0));case 15:t.next=36;break;case 17:if(!process.mainModule){t.next=21;break}t.t1=require("http"),t.next=24;break;case 21:return t.next=23,Promise.resolve().then((function(){return e(require("http"))}));case 23:t.t1=t.sent;case 24:if(u=t.t1,!process.mainModule){t.next=29;break}t.t2=require("https"),t.next=32;break;case 29:return t.next=31,Promise.resolve().then((function(){return e(require("https"))}));case 31:t.t2=t.sent;case 32:return s=t.t2,f="http:"===r.protocol?u:s,l={hostname:r.hostname,port:r.port,path:r.pathname+r.search+i},t.abrupt("return",new Promise((function(e,t){f.get(l,(function(t){var r="";t.on("data",(function(e){r+=e})),t.on("end",(function(){e({status:t.statusCode,response:JSON.parse(r)})}))})).on("error",(function(e){t(new Error("Request failed: ".concat(e)))}))})));case 36:case"end":return t.stop()}}),t,null,[[2,12]])})));return function(e,r){return t.apply(this,arguments)}}(),P=function(){var e=a(n().mark((function e(t,r){var o,i,a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,O(t,r);case 3:if(o=e.sent,i=o.status,a=o.response,200!==i){e.next=11;break}return c=g(a),e.abrupt("return",new Proxy(c,d));case 11:throw new Error(a.errors.at(0));case 12:e.next=17;break;case 14:throw e.prev=14,e.t0=e.catch(0),e.t0;case 17:case"end":return e.stop()}}),e,null,[[0,14]])})));return function(t,r){return e.apply(this,arguments)}}(),_=function(e,t){if(!e)throw Error(f.REQUIRED_RESOURCE_KEY);if(e.length<=0)throw Error(f.EMPTY_RESOURCE_KEY);if(/\s/g.test(e))throw Error(f.ATTEMPT_TO_USE_USER_AGENT);if(e.length<4)throw Error(f.INVALID_RESOURCE_KEY);if("undefined"!=typeof window){if(!t)return new Proxy(E(e),p)}else if(!t)throw new Error(f.DOM_NOT_FOUND);if(Object.keys(t).length<=0)throw Error(f.INCOMPLETE_HEADER_MAP);if(Object.keys(t).length<=0)throw Error(f.HEADERS_NOT_HASHMAP);if(Object.keys(t).some((function(e){return"string"!=typeof t[e]})))throw Error(f.INVALID_HEADERS_VALUE);if(!Object.keys(t).some((function(e){return"user-agent"===e.toLowerCase()||e.toLowerCase().includes("sec-ch")})))throw Error(f.INCOMPLETE_HEADER_MAP);return new Proxy(P(e,t),p)};!function(e,t){"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=_),exports.UAParser=_):"function"==typeof define&&define.amd?define((function(){return _})):void 0!==e&&(e.UAParser=_)}("object"===("undefined"==typeof window?"undefined":o(window))&&window);
