/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/type-insurance@1.2.10/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __assign=this&&this.__assign||function(){return __assign=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},__assign.apply(this,arguments)},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});var isEmpty_1=__importDefault(require("lodash/isEmpty")),has_own_prop_1=__importDefault(require("has-own-prop")),hash_sum_1=__importDefault(require("hash-sum")),convert_hex_1=__importDefault(require("./utils/convert-hex"));function castString(t,e){void 0===e&&(e=!1);var r=t?""+t:"";return"boolean"==typeof t?r=e?t?"true":"false":t?"1":"0":"object"==typeof t?r=isEmpty_1.default(t)?"":JSON.stringify(t):0===t&&(r="0"),r}function castNumber(t,e){void 0===e&&(e=!1);var r=/\d+/.exec(t),s=!!r&&r[0]===t,i=Array.isArray(t),n=convert_hex_1.default(hash_sum_1.default(t));return"string"==typeof t&&!s&&t?n:t&&"object"==typeof t?e?n:i?t.reduce((function(t,e){return castNumber(t)+castNumber(e)}),0):castNumber(Object.values(t)):t?+t:0}function castBoolean(t){return("object"!=typeof t||!isEmpty_1.default(t))&&!!t}function castArray(t){if(Array.isArray(t))return t;if("object"==typeof t&&t)return Object.values(t);if("string"==typeof t&&t){for(var e=[],r=0,s=t;r<s.length;r++){var i=s[r];e.push(i)}return e}return"number"==typeof t&&t?t.toString().split("").map(Number):t||"boolean"==typeof t||0===t?[t]:[]}function castObject(t,e){var r,s=Array.isArray(t);return t||"boolean"==typeof t||0===t?"object"!=typeof t||s?s?__assign({},t):((r={})[e]=t,r):t:{}}var TypeInsurance=function(){function t(t,e){this.input=t,this.defaultKey="key",this.hashObjects=!1,this.stringifyBoolsVerbatim=!1,e&&(has_own_prop_1.default(e,"defaultKey")&&(this.defaultKey=castString(e.defaultKey)),has_own_prop_1.default(e,"hashObjects")&&(this.hashObjects=e.hashObjects),has_own_prop_1.default(e,"stringifyBoolsVerbatim")&&(this.stringifyBoolsVerbatim=e.stringifyBoolsVerbatim)),this.string=this.__string__(),this.number=this.__number__(),this.boolean=this.__boolean__(),this.array=this.__array__(),this.object=this.__object__()}return t.prototype.__string__=function(){return castString(this.input,this.stringifyBoolsVerbatim)},t.prototype.__number__=function(){return castNumber(this.input,this.hashObjects)},t.prototype.__boolean__=function(){return castBoolean(this.input)},t.prototype.__array__=function(){return castArray(this.input)},t.prototype.__object__=function(){return castObject(this.input,this.defaultKey)},t}();exports.default=TypeInsurance;
//# sourceMappingURL=/sm/b0f9c4911b35c41aede368f4f21e2df09ff0916d88f845ca62dc7f3a36e69c88.map