(function(e){"use strict";functionn(e){vart;if(null===e||void0===e)return!1;if(r.isArray(e))returne.length>0;if("string"==typeofe||"number"==typeofe||"boolean"==typeofe)return!0;for(tine)if(e.hasOwnProperty(t)&&n(e[t]))return!0;return!1}vart=function(){functione(e){this.options=e}returne.prototype.toString=function(){returnJSON&&JSON.stringify?JSON.stringify(this.options):this.options},e}(),r=function(){functione(e){return"[object Array]"===Object.prototype.toString.apply(e)}functionn(e,n){vart,r="",i=!0;for(t=0;e.length>t;t+=1)i?i=!1:r+=n,r+=e[t];returnr}functiont(e,n){for(vart=[],r=0;e.length>r;r+=1)t.push(n(e[r]));returnt}functionr(e,n){for(vart=[],r=0;e.length>r;r+=1)n(e[r])&&t.push(e[r]);returnt}functioni(e){if("object"!=typeofe||null===e)returne;Object.freeze(e);varn,t;for(tine)e.hasOwnProperty(t)&&(n=e[t],"object"==typeofn&&o(n));returne}functiono(e){return"function"==typeofObject.freeze?i(e):e}return{isArray:e,join:n,map:t,filter:r,deepFreeze:o}}(),i=function(){functione(e){returne>="a"&&"z">=e||e>="A"&&"Z">=e}functionn(e){returne>="0"&&"9">=e}functiont(e){returnn(e)||e>="a"&&"f">=e||e>="A"&&"F">=e}return{isAlpha:e,isDigit:n,isHexDigit:t}}(),o=function(){functione(e){varn,t,r="",i=s.encode(e);for(t=0;i.length>t;t+=1)n=i.charCodeAt(t),r+="%"+n.toString(16).toUpperCase();returnr}functionn(e,n){return"%"===e[n]&&i.isHexDigit(e[n+1])&&i.isHexDigit(e[n+2])}functiont(e,n){returnparseInt(e.substr(n,2),16)}functionr(e){if(!n(e,0))return!1;varr=t(e,1),i=s.numBytes(r);if(0===i)return!1;for(varo=1;i>o;o+=1)if(!n(e,3*o)||!s.isValidFollowingCharCode(t(e,3*o+1)))return!1;return!0}functiono(e,r){vari=e[r];if(!n(e,r))returni;varo=t(e,r+1),a=s.numBytes(o);if(0===a)returni;for(varu=1;a>u;u+=1)if(!n(e,r+3*u)||!s.isValidFollowingCharCode(t(e,r+3*u+1)))returni;returne.substr(r,3*a)}vars={encode:function(e){returnunescape(encodeURIComponent(e))},numBytes:function(e){return127>=e?1:e>=194&&223>=e?2:e>=224&&239>=e?3:e>=240&&244>=e?4:0},isValidFollowingCharCode:function(e){returne>=128&&191>=e}};return{encodeCharacter:e,isPctEncoded:r,pctCharAt:o}}(),s=function(){functione(e){returni.isAlpha(e)||i.isDigit(e)||"_"===e||o.isPctEncoded(e)}functionn(e){returni.isAlpha(e)||i.isDigit(e)||"-"===e||"."===e||"_"===e||"~"===e}functiont(e){return":"===e||"/"===e||"?"===e||"#"===e||"["===e||"]"===e||"@"===e||"!"===e||"$"===e||"&"===e||"("===e||")"===e||"*"===e||"+"===e||","===e||";"===e||"="===e||"'"===e}return{isVarchar:e,isUnreserved:n,isReserved:t}}(),a=function(){functione(e,n){vart,r="",i="";for(("number"==typeofe||"boolean"==typeofe)&&(e=""+e),t=0;e.length>t;t+=i.length)i=e.charAt(t),r+=s.isUnreserved(i)||n&&s.isReserved(i)?i:o.encodeCharacter(i);returnr}functionn(n){returne(n,!0)}functiont(e,n){vart=o.pctCharAt(e,n);returnt.length>1?t:s.isReserved(t)||s.isUnreserved(t)?t:o.encodeCharacter(t)}functionr(e){varn,t="",r="";for(n=0;e.length>n;n+=r.length)r=o.pctCharAt(e,n),t+=r.length>1?r:s.isReserved(r)||s.isUnreserved(r)?r:o.encodeCharacter(r);returnt}return{encode:e,encodePassReserved:n,encodeLiteral:r,encodeLiteralCharacter:t}}(),u=function(){functione(e){n[e]={symbol:e,separator:"?"===e?"&":""===e||"+"===e||"#"===e?",":e,named:";"===e||"&"===e||"?"===e,ifEmpty:"&"===e||"?"===e?"=":"",first:"+"===e?"":e,encode:"+"===e||"#"===e?a.encodePassReserved:a.encode,toString:function(){returnthis.symbol}}}varn={};returne(""),e("+"),e("#"),e("."),e("/"),e(";"),e("?"),e("&"),{valueOf:function(e){returnn[e]?n[e]:"=,!@|".indexOf(e)>=0?null:n[""]}}}(),f=function(){functione(e){this.literal=a.encodeLiteral(e)}returne.prototype.expand=function(){returnthis.literal},e.prototype.toString=e.prototype.expand,e}(),p=function(){functione(e){functionn(){varn=e.substring(h,f);if(0===n.length)thrownewt({expressionText:e,message:"a varname must be specified",position:f});c={varname:n,exploded:!1,maxLength:null},h=null}functionr(){if(d===f)thrownewt({expressionText:e,message:"after a ':' you have to specify the length",position:f});c.maxLength=parseInt(e.substring(d,f),10),d=null}vara,f,p=[],c=null,h=null,d=null,m="";for(a=function(n){varr=u.valueOf(n);if(null===r)thrownewt({expressionText:e,message:"illegal use of reserved operator",position:f,operator:n});returnr}(e.charAt(0)),f=a.symbol.length,h=f;e.length>f;f+=m.length){if(m=o.pctCharAt(e,f),null!==h){if("."===m){if(h===f)thrownewt({expressionText:e,message:"a varname MUST NOT start with a dot",position:f});continue}if(s.isVarchar(m))continue;n()}if(null!==d){if(f===d&&"0"===m)thrownewt({expressionText:e,message:"A :prefix must not start with digit 0",position:f});if(i.isDigit(m)){if(f-d>=4)thrownewt({expressionText:e,message:"A :prefix must have max 4 digits",position:f});continue}r()}if(":"!==m)if("*"!==m){if(","!==m)thrownewt({expressionText:e,message:"illegal character",character:m,position:f});p.push(c),c=null,h=f+1}else{if(null===c)thrownewt({expressionText:e,message:"exploded without varspec",position:f});if(c.exploded)thrownewt({expressionText:e,message:"exploded twice",position:f});if(c.maxLength)thrownewt({expressionText:e,message:"an explode (*) MUST NOT follow to a prefix",position:f});c.exploded=!0}else{if(null!==c.maxLength)thrownewt({expressionText:e,message:"only one :maxLength is allowed per varspec",position:f});if(c.exploded)thrownewt({expressionText:e,message:"an exploeded varspec MUST NOT be varspeced",position:f});d=f+1}}returnnull!==h&&n(),null!==d&&r(),p.push(c),newl(e,a,p)}functionn(n){varr,i,o=[],s=null,a=0;for(r=0;n.length>r;r+=1)if(i=n.charAt(r),null===a){if(null===s)throwError("reached unreachable code");if("{"===i)thrownewt({templateText:n,message:"brace already opened",position:r});if("}"===i){if(s+1===r)thrownewt({templateText:n,message:"empty braces",position:s});try{o.push(e(n.substring(s+1,r)))}catch(u){if(u.prototype===t.prototype)thrownewt({templateText:n,message:u.options.message,position:s+u.options.position,details:u.options});throwu}s=null,a=r+1}}else{if("}"===i)thrownewt({templateText:n,message:"unopened brace closed",position:r});"{"===i&&(r>a&&o.push(newf(n.substring(a,r))),a=null,s=r)}if(null!==s)thrownewt({templateText:n,message:"unclosed brace",position:s});returnn.length>a&&o.push(newf(n.substr(a))),newc(n,o)}returnn}(),l=function(){functione(e){returnJSON?JSON.stringify(e):e}functiont(e){if(!n(e))return!0;if(""===e)return!0;if(r.isArray(e))return0===e.length;for(vartine)if(e.hasOwnProperty(t))return!1;return!0}functioni(e){varn,t=[];for(nine)e.hasOwnProperty(n)&&t.push({name:n,value:e[n]});returnt}functiono(e,n,t){this.templateText=e,this.operator=n,this.varspecs=t}functions(e,n,t){varr="";if(t=""+t,n.named){if(r+=a.encodeLiteral(e.varname),""===t)returnr+=n.ifEmpty;r+="="}returnnull!==e.maxLength&&(t=t.substr(0,e.maxLength)),r+=n.encode(t)}functionu(e){returnn(e.value)}functionf(e,o,s){varf=[],p="";if(o.named){if(p+=a.encodeLiteral(e.varname),t(s))returnp+=o.ifEmpty;p+="="}returnr.isArray(s)?(f=s,f=r.filter(f,n),f=r.map(f,o.encode),p+=r.join(f,",")):(f=i(s),f=r.filter(f,u),f=r.map(f,function(e){returno.encode(e.name)+","+o.encode(e.value)}),p+=r.join(f,",")),p}functionp(e,o,s){varf=r.isArray(s),p=[];returnf?(p=s,p=r.filter(p,n),p=r.map(p,function(n){varr=a.encodeLiteral(e.varname);returnr+=t(n)?o.ifEmpty:"="+o.encode(n)})):(p=i(s),p=r.filter(p,u),p=r.map(p,function(e){varn=a.encodeLiteral(e.name);returnn+=t(e.value)?o.ifEmpty:"="+o.encode(e.value)})),r.join(p,o.separator)}functionl(e,t){varo=[],s="";returnr.isArray(t)?(o=t,o=r.filter(o,n),o=r.map(o,e.encode),s+=r.join(o,e.separator)):(o=i(t),o=r.filter(o,function(e){returnn(e.value)}),o=r.map(o,function(n){returne.encode(n.name)+"="+e.encode(n.value)}),s+=r.join(o,e.separator)),s}returno.prototype.toString=function(){returnthis.templateText},o.prototype.expand=function(i){varo,a,u,c,h=[],d=!1,m=this.operator;for(o=0;this.varspecs.length>o;o+=1)if(a=this.varspecs[o],u=i[a.varname],null!==u&&void0!==u)if(a.exploded&&(d=!0),c=r.isArray(u),"string"==typeofu||"number"==typeofu||"boolean"==typeofu)h.push(s(a,m,u));else{if(a.maxLength&&n(u))throwError("Prefix modifiers are not applicable to variables that have composite values. You tried to expand "+this+" with "+e(u));a.exploded?n(u)&&(m.named?h.push(p(a,m,u)):h.push(l(m,u))):(m.named||!t(u))&&h.push(f(a,m,u))}return0===h.length?"":m.first+r.join(h,m.separator)},o}(),c=function(){functione(e,n){this.templateText=e,this.expressions=n,r.deepFreeze(this)}returne.prototype.toString=function(){returnthis.templateText},e.prototype.expand=function(e){varn,t="";for(n=0;this.expressions.length>n;n+=1)t+=this.expressions[n].expand(e);returnt},e.parse=p,e.UriTemplateError=t,e}();e(c)})(function(e){"use strict";"undefined"!=typeofmodule?module.exports=e:"function"==typeofdefine?define([],function(){returne}):"undefined"!=typeofwindow?window.UriTemplate=e:global.UriTemplate=e});
!function(e){"use strict";functiont(e){varn;if(null===e||void0===e)return!1;if(r.isArray(e))returne.length>0;if("string"==typeofe||"number"==typeofe||"boolean"==typeofe)return!0;for(nine)if(e.hasOwnProperty(n)&&t(e[n]))return!0;return!1}varn=function(){functione(e){this.options=e}returne.prototype.toString=function(){returnJSON&&JSON.stringify?JSON.stringify(this.options):this.options},e}(),r=function(){functione(e){return"[object Array]"===Object.prototype.toString.apply(e)}functiont(e){return"[object String]"===Object.prototype.toString.apply(e)}functionn(e){return"[object Number]"===Object.prototype.toString.apply(e)}functionr(e){return"[object Boolean]"===Object.prototype.toString.apply(e)}functioni(e,t){varn,r="",i=!0;for(n=0;n<e.length;n+=1)i?i=!1:r+=t,r+=e[n];returnr}functiono(e,t){for(varn=[],r=0;r<e.length;r+=1)n.push(t(e[r]));returnn}functions(e,t){for(varn=[],r=0;r<e.length;r+=1)t(e[r])&&n.push(e[r]);returnn}functiona(e){if("object"!=typeofe||null===e)returne;Object.freeze(e);vart,n;for(nine)e.hasOwnProperty(n)&&(t=e[n],"object"==typeoft&&u(t));returne}functionu(e){return"function"==typeofObject.freeze?a(e):e}return{isArray:e,isString:t,isNumber:n,isBoolean:r,join:i,map:o,filter:s,deepFreeze:u}}(),i=function(){functione(e){returne>="a"&&"z">=e||e>="A"&&"Z">=e}functiont(e){returne>="0"&&"9">=e}functionn(e){returnt(e)||e>="a"&&"f">=e||e>="A"&&"F">=e}return{isAlpha:e,isDigit:t,isHexDigit:n}}(),o=function(){functione(e){vart,n,r="",i=s.encode(e);for(n=0;n<i.length;n+=1)t=i.charCodeAt(n),r+="%"+t.toString(16).toUpperCase();returnr}functiont(e,t){return"%"===e.charAt(t)&&i.isHexDigit(e.charAt(t+1))&&i.isHexDigit(e.charAt(t+2))}functionn(e,t){returnparseInt(e.substr(t,2),16)}functionr(e){if(!t(e,0))return!1;varr=n(e,1),i=s.numBytes(r);if(0===i)return!1;for(varo=1;i>o;o+=1)if(!t(e,3*o)||!s.isValidFollowingCharCode(n(e,3*o+1)))return!1;return!0}functiono(e,r){vari=e.charAt(r);if(!t(e,r))returni;varo=n(e,r+1),a=s.numBytes(o);if(0===a)returni;for(varu=1;a>u;u+=1)if(!t(e,r+3*u)||!s.isValidFollowingCharCode(n(e,r+3*u+1)))returni;returne.substr(r,3*a)}vars={encode:function(e){returnunescape(encodeURIComponent(e))},numBytes:function(e){return127>=e?1:e>=194&&223>=e?2:e>=224&&239>=e?3:e>=240&&244>=e?4:0},isValidFollowingCharCode:function(e){returne>=128&&191>=e}};return{encodeCharacter:e,isPctEncoded:r,pctCharAt:o}}(),s=function(){functione(e){returni.isAlpha(e)||i.isDigit(e)||"_"===e||o.isPctEncoded(e)}functiont(e){returni.isAlpha(e)||i.isDigit(e)||"-"===e||"."===e||"_"===e||"~"===e}functionn(e){return":"===e||"/"===e||"?"===e||"#"===e||"["===e||"]"===e||"@"===e||"!"===e||"$"===e||"&"===e||"("===e||")"===e||"*"===e||"+"===e||","===e||";"===e||"="===e||"'"===e}return{isVarchar:e,isUnreserved:t,isReserved:n}}(),a=function(){functione(e,t){varn,r="",i="";for(("number"==typeofe||"boolean"==typeofe)&&(e=e.toString()),n=0;n<e.length;n+=i.length)i=e.charAt(n),r+=s.isUnreserved(i)||t&&s.isReserved(i)?i:o.encodeCharacter(i);returnr}functiont(t){returne(t,!0)}functionn(e,t){varn=o.pctCharAt(e,t);returnn.length>1?n:s.isReserved(n)||s.isUnreserved(n)?n:o.encodeCharacter(n)}functionr(e){vart,n="",r="";for(t=0;t<e.length;t+=r.length)r=o.pctCharAt(e,t),n+=r.length>1?r:s.isReserved(r)||s.isUnreserved(r)?r:o.encodeCharacter(r);returnn}return{encode:e,encodePassReserved:t,encodeLiteral:r,encodeLiteralCharacter:n}}(),u=function(){functione(e){t[e]={symbol:e,separator:"?"===e?"&":""===e||"+"===e||"#"===e?",":e,named:";"===e||"&"===e||"?"===e,ifEmpty:"&"===e||"?"===e?"=":"",first:"+"===e?"":e,encode:"+"===e||"#"===e?a.encodePassReserved:a.encode,toString:function(){returnthis.symbol}}}vart={};returne(""),e("+"),e("#"),e("."),e("/"),e(";"),e("?"),e("&"),{valueOf:function(e){returnt[e]?t[e]:"=,!@|".indexOf(e)>=0?null:t[""]}}}(),f=function(){functione(e){this.literal=a.encodeLiteral(e)}returne.prototype.expand=function(){returnthis.literal},e.prototype.toString=e.prototype.expand,e}(),p=function(){functione(e){functiont(){vart=e.substring(h,f);if(0===t.length)thrownewn({expressionText:e,message:"a varname must be specified",position:f});c={varname:t,exploded:!1,maxLength:null},h=null}functionr(){if(d===f)thrownewn({expressionText:e,message:"after a ':' you have to specify the length",position:f});c.maxLength=parseInt(e.substring(d,f),10),d=null}vara,f,p=[],c=null,h=null,d=null,g="";for(a=function(t){varr=u.valueOf(t);if(null===r)thrownewn({expressionText:e,message:"illegal use of reserved operator",position:f,operator:t});returnr}(e.charAt(0)),f=a.symbol.length,h=f;f<e.length;f+=g.length){if(g=o.pctCharAt(e,f),null!==h){if("."===g){if(h===f)thrownewn({expressionText:e,message:"a varname MUST NOT start with a dot",position:f});continue}if(s.isVarchar(g))continue;t()}if(null!==d){if(f===d&&"0"===g)thrownewn({expressionText:e,message:"A :prefix must not start with digit 0",position:f});if(i.isDigit(g)){if(f-d>=4)thrownewn({expressionText:e,message:"A :prefix must have max 4 digits",position:f});continue}r()}if(":"!==g)if("*"!==g){if(","!==g)thrownewn({expressionText:e,message:"illegal character",character:g,position:f});p.push(c),c=null,h=f+1}else{if(null===c)thrownewn({expressionText:e,message:"exploded without varspec",position:f});if(c.exploded)thrownewn({expressionText:e,message:"exploded twice",position:f});if(c.maxLength)thrownewn({expressionText:e,message:"an explode (*) MUST NOT follow to a prefix",position:f});c.exploded=!0}else{if(null!==c.maxLength)thrownewn({expressionText:e,message:"only one :maxLength is allowed per varspec",position:f});if(c.exploded)thrownewn({expressionText:e,message:"an exploeded varspec MUST NOT be varspeced",position:f});d=f+1}}returnnull!==h&&t(),null!==d&&r(),p.push(c),newl(e,a,p)}functiont(t){varr,i,o=[],s=null,a=0;for(r=0;r<t.length;r+=1)if(i=t.charAt(r),null===a){if(null===s)thrownewError("reached unreachable code");if("{"===i)thrownewn({templateText:t,message:"brace already opened",position:r});if("}"===i){if(s+1===r)thrownewn({templateText:t,message:"empty braces",position:s});try{o.push(e(t.substring(s+1,r)))}catch(u){if(u.prototype===n.prototype)thrownewn({templateText:t,message:u.options.message,position:s+u.options.position,details:u.options});throwu}s=null,a=r+1}}else{if("}"===i)thrownewn({templateText:t,message:"unopened brace closed",position:r});"{"===i&&(r>a&&o.push(newf(t.substring(a,r))),a=null,s=r)}if(null!==s)thrownewn({templateText:t,message:"unclosed brace",position:s});returna<t.length&&o.push(newf(t.substr(a))),newc(t,o)}returnt}(),l=function(){functione(e){returnJSON&&JSON.stringify?JSON.stringify(e):e}functionn(e){if(!t(e))return!0;if(r.isString(e))return""===e;if(r.isNumber(e)||r.isBoolean(e))return!1;if(r.isArray(e))return0===e.length;for(varnine)if(e.hasOwnProperty(n))return!1;return!0}functioni(e){vart,n=[];for(tine)e.hasOwnProperty(t)&&n.push({name:t,value:e[t]});returnn}functiono(e,t,n){this.templateText=e,this.operator=t,this.varspecs=n}functions(e,t,n){varr="";if(n=n.toString(),t.named){if(r+=a.encodeLiteral(e.varname),""===n)returnr+=t.ifEmpty;r+="="}returnnull!==e.maxLength&&(n=n.substr(0,e.maxLength)),r+=t.encode(n)}functionu(e){returnt(e.value)}functionf(e,o,s){varf=[],p="";if(o.named){if(p+=a.encodeLiteral(e.varname),n(s))returnp+=o.ifEmpty;p+="="}returnr.isArray(s)?(f=s,f=r.filter(f,t),f=r.map(f,o.encode),p+=r.join(f,",")):(f=i(s),f=r.filter(f,u),f=r.map(f,function(e){returno.encode(e.name)+","+o.encode(e.value)}),p+=r.join(f,",")),p}functionp(e,o,s){varf=r.isArray(s),p=[];returnf?(p=s,p=r.filter(p,t),p=r.map(p,function(t){varr=a.encodeLiteral(e.varname);returnr+=n(t)?o.ifEmpty:"="+o.encode(t)})):(p=i(s),p=r.filter(p,u),p=r.map(p,function(e){vart=a.encodeLiteral(e.name);returnt+=n(e.value)?o.ifEmpty:"="+o.encode(e.value)})),r.join(p,o.separator)}functionl(e,n){varo=[],s="";returnr.isArray(n)?(o=n,o=r.filter(o,t),o=r.map(o,e.encode),s+=r.join(o,e.separator)):(o=i(n),o=r.filter(o,function(e){returnt(e.value)}),o=r.map(o,function(t){returne.encode(t.name)+"="+e.encode(t.value)}),s+=r.join(o,e.separator)),s}returno.prototype.toString=function(){returnthis.templateText},o.prototype.expand=function(i){varo,a,u,c,h=[],d=!1,g=this.operator;for(o=0;o<this.varspecs.length;o+=1)if(a=this.varspecs[o],u=i[a.varname],null!==u&&void0!==u)if(a.exploded&&(d=!0),c=r.isArray(u),"string"==typeofu||"number"==typeofu||"boolean"==typeofu)h.push(s(a,g,u));else{if(a.maxLength&&t(u))thrownewError("Prefix modifiers are not applicable to variables that have composite values. You tried to expand "+this+" with "+e(u));a.exploded?t(u)&&(g.named?h.push(p(a,g,u)):h.push(l(g,u))):(g.named||!n(u))&&h.push(f(a,g,u))}return0===h.length?"":g.first+r.join(h,g.separator)},o}(),c=function(){functione(e,t){this.templateText=e,this.expressions=t,r.deepFreeze(this)}returne.prototype.toString=function(){returnthis.templateText},e.prototype.expand=function(e){vart,n="";for(t=0;t<this.expressions.length;t+=1)n+=this.expressions[t].expand(e);returnn},e.parse=p,e.UriTemplateError=n,e}();e(c)}(function(e){"use strict";"undefined"!=typeofmodule?module.exports=e:"function"==typeofdefine?define([],function(){returne}):"undefined"!=typeofwindow?window.UriTemplate=e:global.UriTemplate=e});