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AK,IAI5B,QAAQ,MAAQ,MAIhB,QAAQ,oBAAsB,oBA8C9B,QAAQ,kBAAoB,kBAsE5B,QAAQ,WAAa","file":"/npm/@sesamecare-oss/async-rule-evaluator@1.2.0/build/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@sesamecare-oss/async-rule-evaluator@1.2.0/build/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.toFunction = exports.getObjectResolver = exports.resetObjectResolver = exports.parse = void 0;\nconst lodash_topath_1 = __importDefault(require(\"lodash.topath\"));\nconst lodash_uniq_1 = __importDefault(require(\"lodash.uniq\"));\nconst lodash_union_1 = __importDefault(require(\"lodash.union\"));\nconst lodash_intersection_1 = __importDefault(require(\"lodash.intersection\"));\nconst lodash_difference_1 = __importDefault(require(\"lodash.difference\"));\nconst parser_1 = require(\"./generated/parser\");\nconst AsyncFunction = Object.getPrototypeOf(async () => true).constructor;\nconst OBJECT_RESOLVER = Symbol('Property resolver assigned to filtered objects');\nconst std = {\n    numify(v) {\n        if (v !== null && typeof v === 'object') {\n            return 1;\n        }\n        return Number(v);\n    },\n    isfn(fns, funcName) {\n        return Object.hasOwnProperty.call(fns, funcName) && typeof fns[funcName] === 'function';\n    },\n    unknown(funcName) {\n        throw ReferenceError(`Unknown function: ${funcName}()`);\n    },\n    coerceArray(value) {\n        if (Array.isArray(value))\n            return value;\n        return [value];\n    },\n    coerceBoolean(value) {\n        if (typeof value === 'boolean')\n            return +value;\n        return value;\n    },\n    isSubset(a, b) {\n        const A = std.coerceArray(a);\n        const B = std.coerceArray(b);\n        return +A.every((val) => B.includes(val));\n    },\n    isSubsetInexact(a, b) {\n        const A = std.coerceArray(a);\n        const B = std.coerceArray(b);\n        return +A.every((val) => B.findIndex((v) => (String(v) === String(val))) >= 0);\n    },\n    buildString(inQuote, inLiteral) {\n        const quote = String(inQuote)[0];\n        const literal = String(inLiteral);\n        let built = '';\n        if (literal[0] !== quote || literal[literal.length - 1] !== quote)\n            throw new Error('Unexpected internal error: String literal doesn\\'t begin/end with the right quotation mark.');\n        for (let i = 1; i < literal.length - 1; i += 1) {\n            if (literal[i] === '\\\\') {\n                i += 1;\n                if (i >= literal.length - 1)\n                    throw new Error('Unexpected internal error: Unescaped backslash at the end of string literal.');\n                if (literal[i] === '\\\\')\n                    built += '\\\\';\n                else if (literal[i] === quote)\n                    built += quote;\n                else\n                    throw new Error(`Unexpected internal error: Invalid escaped character in string literal: ${literal[i]}`);\n            }\n            else if (literal[i] === quote) {\n                throw new Error('Unexpected internal error: String literal contains unescaped quotation mark.');\n            }\n            else {\n                built += literal[i];\n            }\n        }\n        return JSON.stringify(built);\n    },\n};\nparser_1.FiltrexParser.yy = std;\nfunction parse(input) {\n    return parser_1.FiltrexParser.parse(input);\n}\nexports.parse = parse;\nfunction resetObjectResolver(obj) {\n    delete obj[OBJECT_RESOLVER];\n}\nexports.resetObjectResolver = resetObjectResolver;\nfunction getObjectResolver(obj) {\n    if (!obj) {\n        return () => undefined;\n    }\n    if (obj[OBJECT_RESOLVER]) {\n        return obj[OBJECT_RESOLVER];\n    }\n    const cachedPromises = new WeakMap();\n    async function objectResolver(name) {\n        let current = obj;\n        const path = (0, lodash_topath_1.default)(name);\n        let index = 0;\n        const { length } = path;\n        // Walk the specified path, looking for functions and promises along the way.\n        // If we find a function, invoke it and cache the result (which is often a promise)\n        while (current != null && index < length) {\n            const key = String(path[index]);\n            let currentVal = Object.prototype.hasOwnProperty.call(current, key) ? current[key] : undefined;\n            if (typeof currentVal === 'function') {\n                let cacheEntry = cachedPromises.get(current);\n                if (cacheEntry && Object.hasOwnProperty.call(cacheEntry, key)) {\n                    currentVal = cacheEntry[key];\n                }\n                else {\n                    // By passing objectResolver to the fn, it can \"depend\" on other promises\n                    // and still get the cache benefits\n                    currentVal = currentVal(objectResolver, obj, current, name);\n                    // Need to get this again because someone else may have made it\n                    cacheEntry = cachedPromises.get(current);\n                    if (!cacheEntry) {\n                        cacheEntry = {};\n                        cachedPromises.set(current, cacheEntry);\n                    }\n                    cacheEntry[key] = currentVal;\n                }\n            }\n            // eslint-disable-next-line no-await-in-loop\n            current = await currentVal;\n            index += 1;\n        }\n        return (index && index === length) ? current : undefined;\n    }\n    Object.defineProperty(obj, OBJECT_RESOLVER, { value: objectResolver, enumerable: false, configurable: true });\n    return objectResolver;\n}\nexports.getObjectResolver = getObjectResolver;\nfunction toFunction(input, { functions, onParse, customResolver } = {}) {\n    const allFunctions = {\n        abs: Math.abs,\n        ceil: Math.ceil,\n        floor: Math.floor,\n        log: Math.log,\n        max: Math.max,\n        min: Math.min,\n        random: Math.random,\n        round: Math.round,\n        sqrt: Math.sqrt,\n        length(o) { return o?.length || 0; },\n        lower(a) {\n            if (a === null || a === undefined) {\n                return a;\n            }\n            return a.toString().toLocaleLowerCase();\n        },\n        substr(a, from, length) {\n            if (a === null || a === undefined) {\n                return a;\n            }\n            return a.toString().substr(from, length);\n        },\n        union(...sets) {\n            return (0, lodash_union_1.default)(...sets.map(std.coerceArray));\n        },\n        intersection(...sets) {\n            return (0, lodash_intersection_1.default)(...sets.map(std.coerceArray));\n        },\n        difference(...sets) {\n            const [first, ...rest] = sets.map(std.coerceArray);\n            return (0, lodash_difference_1.default)(first, ...rest);\n        },\n        unique(set) {\n            return (0, lodash_uniq_1.default)(std.coerceArray(set));\n        },\n        ...functions,\n    };\n    const tree = parser_1.FiltrexParser.parse(input);\n    const js = [];\n    const pathReferences = [];\n    js.push('return ');\n    function toJs(node) {\n        if (Array.isArray(node)) {\n            if (node[1] === 'await prop(') {\n                pathReferences.push(JSON.parse(node[2]));\n            }\n            node.forEach(toJs);\n        }\n        else {\n            js.push(node);\n        }\n    }\n    tree.forEach(toJs);\n    js.push(';');\n    const func = new AsyncFunction('fns', 'std', 'prop', js.join(''));\n    if (onParse) {\n        onParse({\n            input,\n            tree,\n            functionObject: func,\n            pathReferences,\n        });\n    }\n    return async function asyncRuleEvaluator(data) {\n        return func(allFunctions, std, customResolver || getObjectResolver(data));\n    };\n}\nexports.toFunction = toFunction;\n"]}