UNPKG

@detector-js/core

Version:
3 lines (2 loc) 8.14 kB
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function t(e,t,r,n){Object.defineProperty(e,t,{get:r,set:n,enumerable:!0,configurable:!0})}window.Reflect=window.Reflect||{},String.prototype.includes||Object.defineProperty(String.prototype,"includes",{enumerable:!1,configurable:!0,writable:!0,value(e,t){return!((t="number"!=typeof t?0:t)+e.length>this.length)&&-1!==this.indexOf(e,t)}}),String.prototype.startsWith||Object.defineProperty(String.prototype,"startsWith",{value(e,t){let r=t>0?0|t:0;return this.substring(r,r+e.length)===e}}),String.prototype.toCamelCase||Object.defineProperty(String.prototype,"toCamelCase",{enumerable:!1,configurable:!0,writable:!0,value(){let e=this&&this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(e=>e.slice(0,1).toUpperCase()+e.slice(1).toLowerCase()).join("");return e.slice(0,1).toLowerCase()+e.slice(1)}}),Array.prototype.map||Object.defineProperty(Array.prototype,"map",{enumerable:!1,configurable:!0,writable:!0,value(e,t){let r=[];for(let n=0;n<e.length;n+=1)r.push(t(e[n]));return r}}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{enumerable:!1,configurable:!0,writable:!0,value(e,t){if(this==null)throw TypeError('"this" is null or not defined');let r=Object(this),n=r.length>>>0;if(0===n)return!1;let o=0|t,i=Math.max(o>=0?o:n-Math.abs(o),0);for(;i<n;){var s;if((s=r[i])===e||"number"==typeof s&&"number"==typeof e&&isNaN(s)&&isNaN(e))return!0;i++}return!1}}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value(e,t){if(null==e)throw TypeError("Cannot convert first argument to object");let r=Object(e);for(let e=1;e<arguments.length;e++){let t=arguments[e];if(null==t)continue;t=Object(t);let n=Object.keys(Object(t));for(let e=0,o=n.length;e<o;e++){let o=n[e],i=Object.getOwnPropertyDescriptor(t,o);void 0!==i&&i.enumerable&&(r[o]=t[o])}}return r}}),function(t,r){"use strict";if(!(r in t)){var n,o=typeof e==typeof o?window:e,i=0,s=String(Math.random()),a="__\x01symbol:",l=a.length,c="__\x01symbol@@"+s,u="defineProperty",f="defineProperties",g="getOwnPropertyNames",p="getOwnPropertyDescriptor",b="propertyIsEnumerable",h=t[g],y=t[p],O=t.create,m=t.keys,d=t.freeze||t,v=t[u],w=t[f],P=y(t,g),j=t.prototype,S=j.hasOwnProperty,C=j[b],F=j.toString,A=function(e,t,r){S.call(e,c)||v(e,c,{enumerable:!1,configurable:!1,writable:!1,value:{}}),e[c]["@@"+t]=r},N=function(e,t){var r=O(e);return h(t).forEach(function(e){E.call(t,e)&&W(r,e,t[e])}),r},x=function(e){var t=O(e);return t.enumerable=!1,t},$=function(){},D=function(e){return e!=c&&!S.call(_,e)},k=function(e){return e!=c&&S.call(_,e)},E=function(e){var t=String(e);return k(t)?S.call(this,t)&&this[c]["@@"+t]:C.call(this,e)},T=function(e){return v(j,e,{enumerable:!1,configurable:!0,get:$,set:function(t){n(this,e,{enumerable:!1,configurable:!0,writable:!0,value:t}),A(this,e,!0)}}),_[e]=v(t(e),"constructor",R),d(_[e])},V=function e(t){if(this instanceof e)throw TypeError("Symbol is not a constructor");return T(a.concat(t||"",s,++i))},_=O(null),R={value:V},L=function(e){return _[e]},W=function(e,t,r){var o=String(t);return k(o)?(n(e,o,r.enumerable?x(r):r),A(e,o,!!r.enumerable)):v(e,t,r),e},Z=function(e){return h(e).filter(k).map(L)};P.value=W,v(t,u,P),P.value=Z,v(t,r,P),P.value=function(e){return h(e).filter(D)},v(t,g,P),P.value=function(e,t){var r=Z(t);return r.length?m(t).concat(r).forEach(function(r){E.call(t,r)&&W(e,r,t[r])}):w(e,t),e},v(t,f,P),P.value=E,v(j,b,P),P.value=V,v(o,"Symbol",P),P.value=function(e){var t=a.concat(a,e,s);return t in j?_[t]:T(t)},v(V,"for",P),P.value=function(e){if(D(e))throw TypeError(e+" is not a symbol");if(S.call(_,e)){var t=e.slice(l);if(t.slice(0,l)===a&&(t=t.slice(l))!==s)return(t=t.slice(0,t.length-s.length)).length>0?t:void 0}},v(V,"keyFor",P),P.value=function(e,t){var r=y(e,t);return r&&k(t)&&(r.enumerable=E.call(e,t)),r},v(t,p,P),P.value=function(e,t){return 1==arguments.length||void 0===t?O(e):N(e,t)},v(t,"create",P),P.value=function(){var e=F.call(this);return"[object String]"===e&&k(this)?"[object Symbol]":e},v(j,"toString",P);try{if(!0===O(v({},a,{get:function(){return v(this,a,{value:!0})[a]}}))[a])n=v;else throw"IE11"}catch(e){n=function(e,t,r){var n=y(j,t);delete j[t],v(e,t,r),v(j,t,n)}}}}(Object,"getOwnPropertySymbols"),function(e,t){"use strict";var r,n=e.defineProperty,o=e.prototype,i=o.toString,s="toStringTag";["iterator","match","replace","search","split","hasInstance","isConcatSpreadable","unscopables","species","toPrimitive",s].forEach(function(a){a in t||(n(t,a,{value:t(a)}),a===s&&((r=e.getOwnPropertyDescriptor(o,"toString")).value=function(){var e=i.call(this),r=this==null?this:this[t.toStringTag];return null==r?e:"[object "+r+"]"},n(o,"toString",r)))})}(Object,Symbol),function(e,t,r){function n(){return this}t[e]||(t[e]=function(){var t=0,r=this,o={next:function(){var e=r.length<=t;return e?{done:e}:{done:e,value:r[t++]}}};return o[e]=n,o}),r[e]||(r[e]=function(){var t=String.fromCodePoint,r=this,o=0,i=r.length,s={next:function(){var e=i<=o,n=e?"":t(r.codePointAt(o));return o+=n.length,e?{done:e}:{done:e,value:n}}};return s[e]=n,s})}(Symbol.iterator,Array.prototype,String.prototype),Object.hasOwnProperty("getOwnPropertyDescriptors")||Object.defineProperty(Object,"getOwnPropertyDescriptors",{configurable:!0,enumerable:!0,writable:!0,value(e){let t=Reflect&&Reflect.ownKeys?Reflect.ownKeys(e):Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));return t.reduce((t,r)=>Object.defineProperty(t,r,{configurable:!0,enumerable:!0,writable:!0,value:Object.getOwnPropertyDescriptor(e,r)}),{})}}),Object.prototype.merge||Object.defineProperty(Object.prototype,"merge",{enumerable:!1,configurable:!0,writable:!0,value(...e){let t=[this,...e].reduce((e,t)=>Object.keys(t).reduce((r,n)=>(e.hasOwnProperty(n)?e[n]instanceof Array?e[n]=[].concat(e[n],t[n]):e[n]instanceof Object&&Object.keys(e[n]).length>0&&t[n]instanceof Object&&Object.keys(t[n]).length>0?e[n].merge(t[n]):e[n]=t[n]:e[n]=t[n],e),{}),{});return Object.assign(this,t)}}),t({},"Asserts",()=>r);class r{static checkAssert(e,t=!1){return!!e&&(e instanceof Function?e():e)}static all(e=[],t=!1){return e.every(e=>r.checkAssert(e,t))}static one(e=[],t=!1){return e.some(e=>r.checkAssert(e,t))}}t({},"FlagsClass",()=>n);class n{#e;get booleanFlagsValuePropertyName(){return this.#e}set booleanFlagsValuePropertyName(e){this.#e=e}#t;get root(){return this.#t}#r;get process(){return this.#r}#n;get navigator(){return this.#n}#o;get document(){return this.#o}#i;get ua(){return this.#i}constructor(t=null){this.#e="name",this.#t=self||window||e||{},this.#r=this.#t.process||{},this.#n=this.#t.navigator||{},this.#o=this.#t.document||null,this.#i=t||this.#n.userAgent||"n/a"}toValues(){let e=Object.getPrototypeOf(this),t=(this.#e||this.constructor.name).toLowerCase(),r=Object.getOwnPropertyNames(e).filter(t=>!!Object.getOwnPropertyDescriptors(e)[t].get).concat(Object.getOwnPropertyNames(this).filter(e=>!e.startsWith("_")&&!Object.getOwnPropertyDescriptor(this,e)?.get)),n=r.reduce((e,r)=>(this[r]&&("boolean"==typeof this[r]?e[t]=r:e[r]=this[r]),e),{});return n}toFlags(){let e=Object.getPrototypeOf(this);return Object.getOwnPropertyNames(e).filter(t=>!!Object.getOwnPropertyDescriptors(e)[t].get).reduce((e,t)=>(e[t]=this[t],e),{}).merge(Object.getOwnPropertyNames(this).filter(e=>!e.startsWith("_")&&!Object.getOwnPropertyDescriptor(this,e)?.get).reduce((e,t)=>(e[t]=this[t],e),{}))}}t({},"CssFlagsClass",()=>o);class o extends n{#s;get flags(){return this.#s}#a;get cssFlagsPrefix(){return this.#a}constructor(e=null,t={},r="flags"){super(e),this.#s=t,this.#s[1]=!0,this.#a=r}toCssFlags(){let e=Object.getPrototypeOf(this);return Object.getOwnPropertyNames(e).filter(t=>!!Object.getOwnPropertyDescriptors(e)[t].get).reduce((e,t)=>(this[t]&&e.push(`${this.#a}--${t}--${"boolean"!=typeof this[t]?"--"+this[t]:""}`.toLowerCase()),e),[])}}"use strict";export{r as Asserts,n as FlagsClass,o as CssFlagsClass}; //# sourceMappingURL=core.mjs.map