{"ast":null,"code":"import { extend, is, isString, pattern } from '../common';\nimport { UrlRules } from './urlRules';\nimport { UrlConfig } from './urlConfig';\nimport { TargetState } from '../state';\n/**\n * API for URL management\n */\n\nvar UrlService = function () {\n  /** @internal */\n  function UrlService(\n  /** @internal */\n  router) {\n    var _this = this;\n\n    this.router = router;\n    /** @internal */\n\n    this.interceptDeferred = false;\n    /**\n     * The nested [[UrlRules]] API for managing URL rules and rewrites\n     *\n     * See: [[UrlRules]] for details\n     */\n\n    this.rules = new UrlRules(this.router);\n    /**\n     * The nested [[UrlConfig]] API to configure the URL and retrieve URL information\n     *\n     * See: [[UrlConfig]] for details\n     */\n\n    this.config = new UrlConfig(this.router); // Delegate these calls to the current LocationServices implementation\n\n    /**\n     * Gets the current url, or updates the url\n     *\n     * ### Getting the current URL\n     *\n     * When no arguments are passed, returns the current URL.\n     * The URL is normalized using the internal [[path]]/[[search]]/[[hash]] values.\n     *\n     * For example, the URL may be stored in the hash ([[HashLocationServices]]) or\n     * have a base HREF prepended ([[PushStateLocationServices]]).\n     *\n     * The raw URL in the browser might be:\n     *\n     * ```\n     * http://mysite.com/somepath/index.html#/internal/path/123?param1=foo#anchor\n     * ```\n     *\n     * or\n     *\n     * ```\n     * http://mysite.com/basepath/internal/path/123?param1=foo#anchor\n     * ```\n     *\n     * then this method returns:\n     *\n     * ```\n     * /internal/path/123?param1=foo#anchor\n     * ```\n     *\n     *\n     * #### Example:\n     * ```js\n     * locationServices.url(); // \"/some/path?query=value#anchor\"\n     * ```\n     *\n     * ### Updating the URL\n     *\n     * When `newurl` arguments is provided, changes the URL to reflect `newurl`\n     *\n     * #### Example:\n     * ```js\n     * locationServices.url(\"/some/path?query=value#anchor\", true);\n     * ```\n     *\n     * @param newurl The new value for the URL.\n     *               This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.\n     *               It should not include the protocol, site, port, or base path of an absolute HREF.\n     * @param replace When true, replaces the current history entry (instead of appending it) with this new url\n     * @param state The history's state object, i.e., pushState (if the LocationServices implementation supports it)\n     *\n     * @return the url (after potentially being processed)\n     */\n\n    this.url = function (newurl, replace, state) {\n      return _this.router.locationService.url(newurl, replace, state);\n    };\n    /**\n     * Gets the path part of the current url\n     *\n     * If the current URL is `/some/path?query=value#anchor`, this returns `/some/path`\n     *\n     * @return the path portion of the url\n     */\n\n\n    this.path = function () {\n      return _this.router.locationService.path();\n    };\n    /**\n     * Gets the search part of the current url as an object\n     *\n     * If the current URL is `/some/path?query=value#anchor`, this returns `{ query: 'value' }`\n     *\n     * @return the search (query) portion of the url, as an object\n     */\n\n\n    this.search = function () {\n      return _this.router.locationService.search();\n    };\n    /**\n     * Gets the hash part of the current url\n     *\n     * If the current URL is `/some/path?query=value#anchor`, this returns `anchor`\n     *\n     * @return the hash (anchor) portion of the url\n     */\n\n\n    this.hash = function () {\n      return _this.router.locationService.hash();\n    };\n    /**\n     * @internal\n     *\n     * Registers a low level url change handler\n     *\n     * Note: Because this is a low level handler, it's not recommended for general use.\n     *\n     * #### Example:\n     * ```js\n     * let deregisterFn = locationServices.onChange((evt) => console.log(\"url change\", evt));\n     * ```\n     *\n     * @param callback a function that will be called when the url is changing\n     * @return a function that de-registers the callback\n     */\n\n\n    this.onChange = function (callback) {\n      return _this.router.locationService.onChange(callback);\n    };\n  }\n  /** @internal */\n\n\n  UrlService.prototype.dispose = function () {\n    this.listen(false);\n    this.rules.dispose();\n  };\n  /**\n   * Gets the current URL parts\n   *\n   * This method returns the different parts of the current URL (the [[path]], [[search]], and [[hash]]) as a [[UrlParts]] object.\n   */\n\n\n  UrlService.prototype.parts = function () {\n    return {\n      path: this.path(),\n      search: this.search(),\n      hash: this.hash()\n    };\n  };\n  /**\n   * Activates the best rule for the current URL\n   *\n   * Checks the current URL for a matching [[UrlRule]], then invokes that rule's handler.\n   * This method is called internally any time the URL has changed.\n   *\n   * This effectively activates the state (or redirect, etc) which matches the current URL.\n   *\n   * #### Example:\n   * ```js\n   * urlService.deferIntercept();\n   *\n   * fetch('/states.json').then(resp => resp.json()).then(data => {\n   *   data.forEach(state => $stateRegistry.register(state));\n   *   urlService.listen();\n   *   // Find the matching URL and invoke the handler.\n   *   urlService.sync();\n   * });\n   * ```\n   */\n\n\n  UrlService.prototype.sync = function (evt) {\n    if (evt && evt.defaultPrevented) return;\n    var _a = this.router,\n        urlService = _a.urlService,\n        stateService = _a.stateService;\n    var url = {\n      path: urlService.path(),\n      search: urlService.search(),\n      hash: urlService.hash()\n    };\n    var best = this.match(url);\n    var applyResult = pattern([[isString, function (newurl) {\n      return urlService.url(newurl, true);\n    }], [TargetState.isDef, function (def) {\n      return stateService.go(def.state, def.params, def.options);\n    }], [is(TargetState), function (target) {\n      return stateService.go(target.state(), target.params(), target.options());\n    }]]);\n    applyResult(best && best.rule.handler(best.match, url, this.router));\n  };\n  /**\n   * Starts or stops listening for URL changes\n   *\n   * Call this sometime after calling [[deferIntercept]] to start monitoring the url.\n   * This causes UI-Router to start listening for changes to the URL, if it wasn't already listening.\n   *\n   * If called with `false`, UI-Router will stop listening (call listen(true) to start listening again).\n   *\n   * #### Example:\n   * ```js\n   * urlService.deferIntercept();\n   *\n   * fetch('/states.json').then(resp => resp.json()).then(data => {\n   *   data.forEach(state => $stateRegistry.register(state));\n   *   // Start responding to URL changes\n   *   urlService.listen();\n   *   urlService.sync();\n   * });\n   * ```\n   *\n   * @param enabled `true` or `false` to start or stop listening to URL changes\n   */\n\n\n  UrlService.prototype.listen = function (enabled) {\n    var _this = this;\n\n    if (enabled === false) {\n      this._stopListeningFn && this._stopListeningFn();\n      delete this._stopListeningFn;\n    } else {\n      return this._stopListeningFn = this._stopListeningFn || this.router.urlService.onChange(function (evt) {\n        return _this.sync(evt);\n      });\n    }\n  };\n  /**\n   * Disables monitoring of the URL.\n   *\n   * Call this method before UI-Router has bootstrapped.\n   * It will stop UI-Router from performing the initial url sync.\n   *\n   * This can be useful to perform some asynchronous initialization before the router starts.\n   * Once the initialization is complete, call [[listen]] to tell UI-Router to start watching and synchronizing the URL.\n   *\n   * #### Example:\n   * ```js\n   * // Prevent UI-Router from automatically intercepting URL changes when it starts;\n   * urlService.deferIntercept();\n   *\n   * fetch('/states.json').then(resp => resp.json()).then(data => {\n   *   data.forEach(state => $stateRegistry.register(state));\n   *   urlService.listen();\n   *   urlService.sync();\n   * });\n   * ```\n   *\n   * @param defer Indicates whether to defer location change interception.\n   *        Passing no parameter is equivalent to `true`.\n   */\n\n\n  UrlService.prototype.deferIntercept = function (defer) {\n    if (defer === undefined) defer = true;\n    this.interceptDeferred = defer;\n  };\n  /**\n   * Matches a URL\n   *\n   * Given a URL (as a [[UrlParts]] object), check all rules and determine the best matching rule.\n   * Return the result as a [[MatchResult]].\n   */\n\n\n  UrlService.prototype.match = function (url) {\n    var _this = this;\n\n    url = extend({\n      path: '',\n      search: {},\n      hash: ''\n    }, url);\n    var rules = this.rules.rules(); // Checks a single rule. Returns { rule: rule, match: match, weight: weight } if it matched, or undefined\n\n    var checkRule = function (rule) {\n      var match = rule.match(url, _this.router);\n      return match && {\n        match: match,\n        rule: rule,\n        weight: rule.matchPriority(match)\n      };\n    }; // The rules are pre-sorted.\n    // - Find the first matching rule.\n    // - Find any other matching rule that sorted *exactly the same*, according to `.sort()`.\n    // - Choose the rule with the highest match weight.\n\n\n    var best;\n\n    for (var i = 0; i < rules.length; i++) {\n      // Stop when there is a 'best' rule and the next rule sorts differently than it.\n      if (best && best.rule._group !== rules[i]._group) break;\n      var current = checkRule(rules[i]); // Pick the best MatchResult\n\n      best = !best || current && current.weight > best.weight ? current : best;\n    }\n\n    return best;\n  };\n\n  return UrlService;\n}();\n\nexport { UrlService };","map":{"version":3,"sources":["D:/Development/Work/CENOS/cenos-ui/node_modules/@uirouter/core/__ivy_ngcc__/lib-esm/url/urlService.js"],"names":["extend","is","isString","pattern","UrlRules","UrlConfig","TargetState","UrlService","router","_this","interceptDeferred","rules","config","url","newurl","replace","state","locationService","path","search","hash","onChange","callback","prototype","dispose","listen","parts","sync","evt","defaultPrevented","_a","urlService","stateService","best","match","applyResult","isDef","def","go","params","options","target","rule","handler","enabled","_stopListeningFn","deferIntercept","defer","undefined","checkRule","weight","matchPriority","i","length","_group","current"],"mappings":"AAAA,SAASA,MAAT,EAAiBC,EAAjB,EAAqBC,QAArB,EAA+BC,OAA/B,QAA8C,WAA9C;AACA,SAASC,QAAT,QAAyB,YAAzB;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,WAAT,QAA4B,UAA5B;AACA;AACA;AACA;;AACA,IAAIC,UAAU,GAAkB,YAAY;AACxC;AACA,WAASA,UAAT;AAAoB;AAAiBC,EAAAA,MAArC,EAA6C;AACzC,QAAIC,KAAK,GAAG,IAAZ;;AACA,SAAKD,MAAL,GAAcA,MAAd;AACA;;AAAiB,SAAKE,iBAAL,GAAyB,KAAzB;AACjB;AACR;AACA;AACA;AACA;;AACQ,SAAKC,KAAL,GAAa,IAAIP,QAAJ,CAAa,KAAKI,MAAlB,CAAb;AACA;AACR;AACA;AACA;AACA;;AACQ,SAAKI,MAAL,GAAc,IAAIP,SAAJ,CAAc,KAAKG,MAAnB,CAAd,CAfyC,CAgBzC;;AACA;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACQ,SAAKK,GAAL,GAAW,UAAUC,MAAV,EAAkBC,OAAlB,EAA2BC,KAA3B,EAAkC;AACzC,aAAOP,KAAK,CAACD,MAAN,CAAaS,eAAb,CAA6BJ,GAA7B,CAAiCC,MAAjC,EAAyCC,OAAzC,EAAkDC,KAAlD,CAAP;AACH,KAFD;AAGA;AACR;AACA;AACA;AACA;AACA;AACA;;;AACQ,SAAKE,IAAL,GAAY,YAAY;AAAE,aAAOT,KAAK,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,IAAI,CAACR,KAAL,CAAWrB,GAAX,EAAgBJ,KAAK,CAACD,MAAtB,CAAZ;AACA,aAAO0B,KAAK,IAAI;AAAEA,QAAAA,KAAK,EAAEA,KAAT;AAAgBQ,QAAAA,IAAI,EAAEA,IAAtB;AAA4BQ,QAAAA,MAAM,EAAER,IAAI,CAACS,aAAL,CAAmBjB,KAAnB;AAApC,OAAhB;AACH,KAHD,CALwC,CASxC;AACA;AACA;AACA;;;AACA,QAAID,IAAJ;;AACA,SAAK,IAAImB,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGzC,KAAK,CAAC0C,MAA1B,EAAkCD,CAAC,EAAnC,EAAuC;AACnC;AACA,UAAInB,IAAI,IAAIA,IAAI,CAACS,IAAL,CAAUY,MAAV,KAAqB3C,KAAK,CAACyC,CAAD,CAAL,CAASE,MAA1C,EACI;AACJ,UAAIC,OAAO,GAAGN,SAAS,CAACtC,KAAK,CAACyC,CAAD,CAAN,CAAvB,CAJmC,CAKnC;;AACAnB,MAAAA,IAAI,GAAG,CAACA,IAAD,IAAUsB,OAAO,IAAIA,OAAO,CAACL,MAAR,GAAiBjB,IAAI,CAACiB,MAA3C,GAAqDK,OAArD,GAA+DtB,IAAtE;AACH;;AACD,WAAOA,IAAP;AACH,GAvBD;;AAwBA,SAAO1B,UAAP;AACH,CA9P+B,EAAhC;;AA+PA,SAASA,UAAT","sourcesContent":["import { extend, is, isString, pattern } from '../common';\nimport { UrlRules } from './urlRules';\nimport { UrlConfig } from './urlConfig';\nimport { TargetState } from '../state';\n/**\n * API for URL management\n */\nvar UrlService = /** @class */ (function () {\n    /** @internal */\n    function UrlService(/** @internal */ router) {\n        var _this = this;\n        this.router = router;\n        /** @internal */ this.interceptDeferred = false;\n        /**\n         * The nested [[UrlRules]] API for managing URL rules and rewrites\n         *\n         * See: [[UrlRules]] for details\n         */\n        this.rules = new UrlRules(this.router);\n        /**\n         * The nested [[UrlConfig]] API to configure the URL and retrieve URL information\n         *\n         * See: [[UrlConfig]] for details\n         */\n        this.config = new UrlConfig(this.router);\n        // Delegate these calls to the current LocationServices implementation\n        /**\n         * Gets the current url, or updates the url\n         *\n         * ### Getting the current URL\n         *\n         * When no arguments are passed, returns the current URL.\n         * The URL is normalized using the internal [[path]]/[[search]]/[[hash]] values.\n         *\n         * For example, the URL may be stored in the hash ([[HashLocationServices]]) or\n         * have a base HREF prepended ([[PushStateLocationServices]]).\n         *\n         * The raw URL in the browser might be:\n         *\n         * ```\n         * http://mysite.com/somepath/index.html#/internal/path/123?param1=foo#anchor\n         * ```\n         *\n         * or\n         *\n         * ```\n         * http://mysite.com/basepath/internal/path/123?param1=foo#anchor\n         * ```\n         *\n         * then this method returns:\n         *\n         * ```\n         * /internal/path/123?param1=foo#anchor\n         * ```\n         *\n         *\n         * #### Example:\n         * ```js\n         * locationServices.url(); // \"/some/path?query=value#anchor\"\n         * ```\n         *\n         * ### Updating the URL\n         *\n         * When `newurl` arguments is provided, changes the URL to reflect `newurl`\n         *\n         * #### Example:\n         * ```js\n         * locationServices.url(\"/some/path?query=value#anchor\", true);\n         * ```\n         *\n         * @param newurl The new value for the URL.\n         *               This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.\n         *               It should not include the protocol, site, port, or base path of an absolute HREF.\n         * @param replace When true, replaces the current history entry (instead of appending it) with this new url\n         * @param state The history's state object, i.e., pushState (if the LocationServices implementation supports it)\n         *\n         * @return the url (after potentially being processed)\n         */\n        this.url = function (newurl, replace, state) {\n            return _this.router.locationService.url(newurl, replace, state);\n        };\n        /**\n         * Gets the path part of the current url\n         *\n         * If the current URL is `/some/path?query=value#anchor`, this returns `/some/path`\n         *\n         * @return the path portion of the url\n         */\n        this.path = function () { return _this.router.locationService.path(); };\n        /**\n         * Gets the search part of the current url as an object\n         *\n         * If the current URL is `/some/path?query=value#anchor`, this returns `{ query: 'value' }`\n         *\n         * @return the search (query) portion of the url, as an object\n         */\n        this.search = function () { return _this.router.locationService.search(); };\n        /**\n         * Gets the hash part of the current url\n         *\n         * If the current URL is `/some/path?query=value#anchor`, this returns `anchor`\n         *\n         * @return the hash (anchor) portion of the url\n         */\n        this.hash = function () { return _this.router.locationService.hash(); };\n        /**\n         * @internal\n         *\n         * Registers a low level url change handler\n         *\n         * Note: Because this is a low level handler, it's not recommended for general use.\n         *\n         * #### Example:\n         * ```js\n         * let deregisterFn = locationServices.onChange((evt) => console.log(\"url change\", evt));\n         * ```\n         *\n         * @param callback a function that will be called when the url is changing\n         * @return a function that de-registers the callback\n         */\n        this.onChange = function (callback) { return _this.router.locationService.onChange(callback); };\n    }\n    /** @internal */\n    UrlService.prototype.dispose = function () {\n        this.listen(false);\n        this.rules.dispose();\n    };\n    /**\n     * Gets the current URL parts\n     *\n     * This method returns the different parts of the current URL (the [[path]], [[search]], and [[hash]]) as a [[UrlParts]] object.\n     */\n    UrlService.prototype.parts = function () {\n        return { path: this.path(), search: this.search(), hash: this.hash() };\n    };\n    /**\n     * Activates the best rule for the current URL\n     *\n     * Checks the current URL for a matching [[UrlRule]], then invokes that rule's handler.\n     * This method is called internally any time the URL has changed.\n     *\n     * This effectively activates the state (or redirect, etc) which matches the current URL.\n     *\n     * #### Example:\n     * ```js\n     * urlService.deferIntercept();\n     *\n     * fetch('/states.json').then(resp => resp.json()).then(data => {\n     *   data.forEach(state => $stateRegistry.register(state));\n     *   urlService.listen();\n     *   // Find the matching URL and invoke the handler.\n     *   urlService.sync();\n     * });\n     * ```\n     */\n    UrlService.prototype.sync = function (evt) {\n        if (evt && evt.defaultPrevented)\n            return;\n        var _a = this.router, urlService = _a.urlService, stateService = _a.stateService;\n        var url = { path: urlService.path(), search: urlService.search(), hash: urlService.hash() };\n        var best = this.match(url);\n        var applyResult = pattern([\n            [isString, function (newurl) { return urlService.url(newurl, true); }],\n            [TargetState.isDef, function (def) { return stateService.go(def.state, def.params, def.options); }],\n            [is(TargetState), function (target) { return stateService.go(target.state(), target.params(), target.options()); }],\n        ]);\n        applyResult(best && best.rule.handler(best.match, url, this.router));\n    };\n    /**\n     * Starts or stops listening for URL changes\n     *\n     * Call this sometime after calling [[deferIntercept]] to start monitoring the url.\n     * This causes UI-Router to start listening for changes to the URL, if it wasn't already listening.\n     *\n     * If called with `false`, UI-Router will stop listening (call listen(true) to start listening again).\n     *\n     * #### Example:\n     * ```js\n     * urlService.deferIntercept();\n     *\n     * fetch('/states.json').then(resp => resp.json()).then(data => {\n     *   data.forEach(state => $stateRegistry.register(state));\n     *   // Start responding to URL changes\n     *   urlService.listen();\n     *   urlService.sync();\n     * });\n     * ```\n     *\n     * @param enabled `true` or `false` to start or stop listening to URL changes\n     */\n    UrlService.prototype.listen = function (enabled) {\n        var _this = this;\n        if (enabled === false) {\n            this._stopListeningFn && this._stopListeningFn();\n            delete this._stopListeningFn;\n        }\n        else {\n            return (this._stopListeningFn =\n                this._stopListeningFn || this.router.urlService.onChange(function (evt) { return _this.sync(evt); }));\n        }\n    };\n    /**\n     * Disables monitoring of the URL.\n     *\n     * Call this method before UI-Router has bootstrapped.\n     * It will stop UI-Router from performing the initial url sync.\n     *\n     * This can be useful to perform some asynchronous initialization before the router starts.\n     * Once the initialization is complete, call [[listen]] to tell UI-Router to start watching and synchronizing the URL.\n     *\n     * #### Example:\n     * ```js\n     * // Prevent UI-Router from automatically intercepting URL changes when it starts;\n     * urlService.deferIntercept();\n     *\n     * fetch('/states.json').then(resp => resp.json()).then(data => {\n     *   data.forEach(state => $stateRegistry.register(state));\n     *   urlService.listen();\n     *   urlService.sync();\n     * });\n     * ```\n     *\n     * @param defer Indicates whether to defer location change interception.\n     *        Passing no parameter is equivalent to `true`.\n     */\n    UrlService.prototype.deferIntercept = function (defer) {\n        if (defer === undefined)\n            defer = true;\n        this.interceptDeferred = defer;\n    };\n    /**\n     * Matches a URL\n     *\n     * Given a URL (as a [[UrlParts]] object), check all rules and determine the best matching rule.\n     * Return the result as a [[MatchResult]].\n     */\n    UrlService.prototype.match = function (url) {\n        var _this = this;\n        url = extend({ path: '', search: {}, hash: '' }, url);\n        var rules = this.rules.rules();\n        // Checks a single rule. Returns { rule: rule, match: match, weight: weight } if it matched, or undefined\n        var checkRule = function (rule) {\n            var match = rule.match(url, _this.router);\n            return match && { match: match, rule: rule, weight: rule.matchPriority(match) };\n        };\n        // The rules are pre-sorted.\n        // - Find the first matching rule.\n        // - Find any other matching rule that sorted *exactly the same*, according to `.sort()`.\n        // - Choose the rule with the highest match weight.\n        var best;\n        for (var i = 0; i < rules.length; i++) {\n            // Stop when there is a 'best' rule and the next rule sorts differently than it.\n            if (best && best.rule._group !== rules[i]._group)\n                break;\n            var current = checkRule(rules[i]);\n            // Pick the best MatchResult\n            best = !best || (current && current.weight > best.weight) ? current : best;\n        }\n        return best;\n    };\n    return UrlService;\n}());\nexport { UrlService };\n"]},"metadata":{},"sourceType":"module"}