{"ast":null,"code":"import { extend, identity } from '../common/common';\nimport { services } from '../common/coreservices';\nimport { trace } from '../common/trace';\nimport { stringify } from '../common/strings';\nimport { isFunction, isObject } from '../common/predicates';\nimport { isNullOrUndefined } from '../common/predicates'; // TODO: explicitly make this user configurable\n\nexport var defaultResolvePolicy = {\n  when: 'LAZY',\n  async: 'WAIT'\n};\n/**\n * The basic building block for the resolve system.\n *\n * Resolvables encapsulate a state's resolve's resolveFn, the resolveFn's declared dependencies, the wrapped (.promise),\n * and the unwrapped-when-complete (.data) result of the resolveFn.\n *\n * Resolvable.get() either retrieves the Resolvable's existing promise, or else invokes resolve() (which invokes the\n * resolveFn) and returns the resulting promise.\n *\n * Resolvable.get() and Resolvable.resolve() both execute within a context path, which is passed as the first\n * parameter to those fns.\n */\n\nvar Resolvable = function () {\n  function Resolvable(arg1, resolveFn, deps, policy, data) {\n    this.resolved = false;\n    this.promise = undefined;\n\n    if (arg1 instanceof Resolvable) {\n      extend(this, arg1);\n    } else if (isFunction(resolveFn)) {\n      if (isNullOrUndefined(arg1)) throw new Error('new Resolvable(): token argument is required');\n      if (!isFunction(resolveFn)) throw new Error('new Resolvable(): resolveFn argument must be a function');\n      this.token = arg1;\n      this.policy = policy;\n      this.resolveFn = resolveFn;\n      this.deps = deps || [];\n      this.data = data;\n      this.resolved = data !== undefined;\n      this.promise = this.resolved ? services.$q.when(this.data) : undefined;\n    } else if (isObject(arg1) && arg1.token && (arg1.hasOwnProperty('resolveFn') || arg1.hasOwnProperty('data'))) {\n      var literal = arg1;\n      return new Resolvable(literal.token, literal.resolveFn, literal.deps, literal.policy, literal.data);\n    }\n  }\n\n  Resolvable.prototype.getPolicy = function (state) {\n    var thisPolicy = this.policy || {};\n    var statePolicy = state && state.resolvePolicy || {};\n    return {\n      when: thisPolicy.when || statePolicy.when || defaultResolvePolicy.when,\n      async: thisPolicy.async || statePolicy.async || defaultResolvePolicy.async\n    };\n  };\n  /**\n   * Asynchronously resolve this Resolvable's data\n   *\n   * Given a ResolveContext that this Resolvable is found in:\n   * Wait for this Resolvable's dependencies, then invoke this Resolvable's function\n   * and update the Resolvable's state\n   */\n\n\n  Resolvable.prototype.resolve = function (resolveContext, trans) {\n    var _this = this;\n\n    var $q = services.$q; // Gets all dependencies from ResolveContext and wait for them to be resolved\n\n    var getResolvableDependencies = function () {\n      return $q.all(resolveContext.getDependencies(_this).map(function (resolvable) {\n        return resolvable.get(resolveContext, trans);\n      }));\n    }; // Invokes the resolve function passing the resolved dependencies as arguments\n\n\n    var invokeResolveFn = function (resolvedDeps) {\n      return _this.resolveFn.apply(null, resolvedDeps);\n    };\n\n    var node = resolveContext.findNode(this);\n    var state = node && node.state;\n    var asyncPolicy = this.getPolicy(state).async;\n    var customAsyncPolicy = isFunction(asyncPolicy) ? asyncPolicy : identity; // After the final value has been resolved, update the state of the Resolvable\n\n    var applyResolvedValue = function (resolvedValue) {\n      _this.data = resolvedValue;\n      _this.resolved = true;\n      _this.resolveFn = null;\n      trace.traceResolvableResolved(_this, trans);\n      return _this.data;\n    }; // Sets the promise property first, then getsResolvableDependencies in the context of the promise chain. Always waits one tick.\n\n\n    return this.promise = $q.when().then(getResolvableDependencies).then(invokeResolveFn).then(customAsyncPolicy).then(applyResolvedValue);\n  };\n  /**\n   * Gets a promise for this Resolvable's data.\n   *\n   * Fetches the data and returns a promise.\n   * Returns the existing promise if it has already been fetched once.\n   */\n\n\n  Resolvable.prototype.get = function (resolveContext, trans) {\n    return this.promise || this.resolve(resolveContext, trans);\n  };\n\n  Resolvable.prototype.toString = function () {\n    return \"Resolvable(token: \" + stringify(this.token) + \", requires: [\" + this.deps.map(stringify) + \"])\";\n  };\n\n  Resolvable.prototype.clone = function () {\n    return new Resolvable(this);\n  };\n\n  Resolvable.fromData = function (token, data) {\n    return new Resolvable(token, function () {\n      return data;\n    }, null, null, data);\n  };\n\n  return Resolvable;\n}();\n\nexport { Resolvable };","map":{"version":3,"sources":["D:/Development/Work/CENOS/cenos-ui/node_modules/@uirouter/core/__ivy_ngcc__/lib-esm/resolve/resolvable.js"],"names":["extend","identity","services","trace","stringify","isFunction","isObject","isNullOrUndefined","defaultResolvePolicy","when","async","Resolvable","arg1","resolveFn","deps","policy","data","resolved","promise","undefined","Error","token","$q","hasOwnProperty","literal","prototype","getPolicy","state","thisPolicy","statePolicy","resolvePolicy","resolve","resolveContext","trans","_this","getResolvableDependencies","all","getDependencies","map","resolvable","get","invokeResolveFn","resolvedDeps","apply","node","findNode","asyncPolicy","customAsyncPolicy","applyResolvedValue","resolvedValue","traceResolvableResolved","then","toString","clone","fromData"],"mappings":"AAAA,SAASA,MAAT,EAAiBC,QAAjB,QAAiC,kBAAjC;AACA,SAASC,QAAT,QAAyB,wBAAzB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,SAAT,QAA0B,mBAA1B;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAqC,sBAArC;AACA,SAASC,iBAAT,QAAkC,sBAAlC,C,CACA;;AACA,OAAO,IAAIC,oBAAoB,GAAG;AAC9BC,EAAAA,IAAI,EAAE,MADwB;AAE9BC,EAAAA,KAAK,EAAE;AAFuB,CAA3B;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAIC,UAAU,GAAkB,YAAY;AACxC,WAASA,UAAT,CAAoBC,IAApB,EAA0BC,SAA1B,EAAqCC,IAArC,EAA2CC,MAA3C,EAAmDC,IAAnD,EAAyD;AACrD,SAAKC,QAAL,GAAgB,KAAhB;AACA,SAAKC,OAAL,GAAeC,SAAf;;AACA,QAAIP,IAAI,YAAYD,UAApB,EAAgC;AAC5BX,MAAAA,MAAM,CAAC,IAAD,EAAOY,IAAP,CAAN;AACH,KAFD,MAGK,IAAIP,UAAU,CAACQ,SAAD,CAAd,EAA2B;AAC5B,UAAIN,iBAAiB,CAACK,IAAD,CAArB,EACI,MAAM,IAAIQ,KAAJ,CAAU,8CAAV,CAAN;AACJ,UAAI,CAACf,UAAU,CAACQ,S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Ab;AACH,KAND,CAd4D,CAqB5D;;;AACA,WAAQ,KAAKE,OAAL,GAAeI,EAAE,CACpBb,IADkB,GAElB0C,IAFkB,CAEbhB,yBAFa,EAGlBgB,IAHkB,CAGbV,eAHa,EAIlBU,IAJkB,CAIbJ,iBAJa,EAKlBI,IALkB,CAKbH,kBALa,CAAvB;AAMH,GA5BD;AA6BA;AACJ;AACA;AACA;AACA;AACA;;;AACIrC,EAAAA,UAAU,CAACc,SAAX,CAAqBe,GAArB,GAA2B,UAAUR,cAAV,EAA0BC,KAA1B,EAAiC;AACxD,WAAO,KAAKf,OAAL,IAAgB,KAAKa,OAAL,CAAaC,cAAb,EAA6BC,KAA7B,CAAvB;AACH,GAFD;;AAGAtB,EAAAA,UAAU,CAACc,SAAX,CAAqB2B,QAArB,GAAgC,YAAY;AACxC,WAAO,uBAAuBhD,SAAS,CAAC,KAAKiB,KAAN,CAAhC,GAA+C,eAA/C,GAAiE,KAAKP,IAAL,CAAUwB,GAAV,CAAclC,SAAd,CAAjE,GAA4F,IAAnG;AACH,GAFD;;AAGAO,EAAAA,UAAU,CAACc,SAAX,CAAqB4B,KAArB,GAA6B,YAAY;AACrC,WAAO,IAAI1C,UAAJ,CAAe,IAAf,CAAP;AACH,GAFD;;AAGAA,EAAAA,UAAU,CAAC2C,QAAX,GAAsB,UAAUjC,KAAV,EAAiBL,IAAjB,EAAuB;AAAE,WAAO,IAAIL,UAAJ,CAAeU,KAAf,EAAsB,YAAY;AAAE,aAAOL,IAAP;AAAc,KAAlD,EAAoD,IAApD,EAA0D,IAA1D,EAAgEA,IAAhE,CAAP;AAA+E,GAA9H;;AACA,SAAOL,UAAP;AACH,CAtF+B,EAAhC;;AAuFA,SAASA,UAAT","sourcesContent":["import { extend, identity } from '../common/common';\nimport { services } from '../common/coreservices';\nimport { trace } from '../common/trace';\nimport { stringify } from '../common/strings';\nimport { isFunction, isObject } from '../common/predicates';\nimport { isNullOrUndefined } from '../common/predicates';\n// TODO: explicitly make this user configurable\nexport var defaultResolvePolicy = {\n    when: 'LAZY',\n    async: 'WAIT',\n};\n/**\n * The basic building block for the resolve system.\n *\n * Resolvables encapsulate a state's resolve's resolveFn, the resolveFn's declared dependencies, the wrapped (.promise),\n * and the unwrapped-when-complete (.data) result of the resolveFn.\n *\n * Resolvable.get() either retrieves the Resolvable's existing promise, or else invokes resolve() (which invokes the\n * resolveFn) and returns the resulting promise.\n *\n * Resolvable.get() and Resolvable.resolve() both execute within a context path, which is passed as the first\n * parameter to those fns.\n */\nvar Resolvable = /** @class */ (function () {\n    function Resolvable(arg1, resolveFn, deps, policy, data) {\n        this.resolved = false;\n        this.promise = undefined;\n        if (arg1 instanceof Resolvable) {\n            extend(this, arg1);\n        }\n        else if (isFunction(resolveFn)) {\n            if (isNullOrUndefined(arg1))\n                throw new Error('new Resolvable(): token argument is required');\n            if (!isFunction(resolveFn))\n                throw new Error('new Resolvable(): resolveFn argument must be a function');\n            this.token = arg1;\n            this.policy = policy;\n            this.resolveFn = resolveFn;\n            this.deps = deps || [];\n            this.data = data;\n            this.resolved = data !== undefined;\n            this.promise = this.resolved ? services.$q.when(this.data) : undefined;\n        }\n        else if (isObject(arg1) && arg1.token && (arg1.hasOwnProperty('resolveFn') || arg1.hasOwnProperty('data'))) {\n            var literal = arg1;\n            return new Resolvable(literal.token, literal.resolveFn, literal.deps, literal.policy, literal.data);\n        }\n    }\n    Resolvable.prototype.getPolicy = function (state) {\n        var thisPolicy = this.policy || {};\n        var statePolicy = (state && state.resolvePolicy) || {};\n        return {\n            when: thisPolicy.when || statePolicy.when || defaultResolvePolicy.when,\n            async: thisPolicy.async || statePolicy.async || defaultResolvePolicy.async,\n        };\n    };\n    /**\n     * Asynchronously resolve this Resolvable's data\n     *\n     * Given a ResolveContext that this Resolvable is found in:\n     * Wait for this Resolvable's dependencies, then invoke this Resolvable's function\n     * and update the Resolvable's state\n     */\n    Resolvable.prototype.resolve = function (resolveContext, trans) {\n        var _this = this;\n        var $q = services.$q;\n        // Gets all dependencies from ResolveContext and wait for them to be resolved\n        var getResolvableDependencies = function () {\n            return $q.all(resolveContext.getDependencies(_this).map(function (resolvable) { return resolvable.get(resolveContext, trans); }));\n        };\n        // Invokes the resolve function passing the resolved dependencies as arguments\n        var invokeResolveFn = function (resolvedDeps) { return _this.resolveFn.apply(null, resolvedDeps); };\n        var node = resolveContext.findNode(this);\n        var state = node && node.state;\n        var asyncPolicy = this.getPolicy(state).async;\n        var customAsyncPolicy = isFunction(asyncPolicy) ? asyncPolicy : identity;\n        // After the final value has been resolved, update the state of the Resolvable\n        var applyResolvedValue = function (resolvedValue) {\n            _this.data = resolvedValue;\n            _this.resolved = true;\n            _this.resolveFn = null;\n            trace.traceResolvableResolved(_this, trans);\n            return _this.data;\n        };\n        // Sets the promise property first, then getsResolvableDependencies in the context of the promise chain. Always waits one tick.\n        return (this.promise = $q\n            .when()\n            .then(getResolvableDependencies)\n            .then(invokeResolveFn)\n            .then(customAsyncPolicy)\n            .then(applyResolvedValue));\n    };\n    /**\n     * Gets a promise for this Resolvable's data.\n     *\n     * Fetches the data and returns a promise.\n     * Returns the existing promise if it has already been fetched once.\n     */\n    Resolvable.prototype.get = function (resolveContext, trans) {\n        return this.promise || this.resolve(resolveContext, trans);\n    };\n    Resolvable.prototype.toString = function () {\n        return \"Resolvable(token: \" + stringify(this.token) + \", requires: [\" + this.deps.map(stringify) + \"])\";\n    };\n    Resolvable.prototype.clone = function () {\n        return new Resolvable(this);\n    };\n    Resolvable.fromData = function (token, data) { return new Resolvable(token, function () { return data; }, null, null, data); };\n    return Resolvable;\n}());\nexport { Resolvable };\n"]},"metadata":{},"sourceType":"module"}