Loading
function(e,t,n){var i=n(271434);e.exports=function e(t,n,r){if(i(n)||(r=n||r,n=[]),r=r||{},t instanceof RegExp){var a,o,l=n,c=t.source.match(/\((?!\?)/g);if(c)for(var _=0;_<c.length;_++)l.push({name:_,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return t.keys=l,t}if(i(t)){for(var h,f=n,E=r,p=[],m=0;m<t.length;m++)p.push(e(t[m],f,E).source);return(h=RegExp("(?:"+p.join("|")+")",u(E))).keys=f,h}return a=n,d(s(t,o=r),a,o)},e.exports.parse=s,e.exports.compile=function(e,t){return o(s(e,t))},e.exports.tokensToFunction=o,e.exports.tokensToRegExp=d;var r=RegExp("(\\\\.)|([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))","g");function s(e,t){for(var n,i=[],s=0,a=0,o="",u=t&&t.delimiter||"/";null!=(n=r.exec(e));){var d=n[0],c=n[1],_=n.index;if(o+=e.slice(a,_),a=_+d.length,c){o+=c[1];continue}var h=e[a],f=n[2],E=n[3],p=n[4],m=n[5],g=n[6],A=n[7];o&&(i.push(o),o="");var I=null!=f&&null!=h&&h!==f,T="+"===g||"*"===g,S="?"===g||"*"===g,N=n[2]||u,C=p||m;i.push({name:E||s++,prefix:f||"",delimiter:N,optional:S,repeat:T,partial:I,asterisk:!!A,pattern:C?C.replace(/([=!:$\/()])/g,"\\$1"):A?".*":"[^"+l(N)+"]+?"})}return a<e.length&&(o+=e.substr(a)),o&&i.push(o),i}function a(e){return encodeURI(e).replace(/[\/?#]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}function o(e){for(var t=Array(e.length),n=0;n<e.length;n++)"object"==typeof e[n]&&(t[n]=RegExp("^(?:"+e[n].pattern+")$"));return function(n,r){for(var s="",o=n||{},l=(r||{}).pretty?a:encodeURIComponent,u=0;u<e.length;u++){var d,c=e[u];if("string"==typeof c){s+=c;continue}var _=o[c.name];if(null==_)if(c.optional){c.partial&&(s+=c.prefix);continue}else throw TypeError('Expected "'+c.name+'" to be defined');if(i(_)){if(!c.repeat)throw TypeError('Expected "'+c.name+'" to not repeat, but received `'+JSON.stringify(_)+"`");if(0===_.length)if(c.optional)continue;else throw TypeError('Expected "'+c.name+'" to not be empty');for(var h=0;h<_.length;h++){if(d=l(_[h]),!t[u].test(d))throw TypeError('Expected all "'+c.name+'" to match "'+c.pattern+'", but received `'+JSON.stringify(d)+"`");s+=(0===h?c.prefix:c.delimiter)+d}continue}if(d=c.asterisk?encodeURI(_).replace(/[?#]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}):l(_),!t[u].test(d))throw TypeError('Expected "'+c.name+'" to match "'+c.pattern+'", but received "'+d+'"');s+=c.prefix+d}return s}}function l(e){return e.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function u(e){return e.sensitive?"":"i"}function d(e,t,n){i(t)||(n=t||n,t=[]);for(var r,s=(n=n||{}).strict,a=!1!==n.end,o="",d=0;d<e.length;d++){var c=e[d];if("string"==typeof c)o+=l(c);else{var _=l(c.prefix),h="(?:"+c.pattern+")";t.push(c),c.repeat&&(h+="(?:"+_+h+")*"),o+=h=c.optional?c.partial?_+"("+h+")?":"(?:"+_+"("+h+"))?":_+"("+h+")"}}var f=l(n.delimiter||"/"),E=o.slice(-f.length)===f;return s||(o=(E?o.slice(0,-f.length):o)+"(?:"+f+"(?=$))?"),a?o+="$":o+=s&&E?"":"(?="+f+"|$)",(r=RegExp("^"+o,u(n))).keys=t,r}}