//XRegExp 3.0.0 MIT License var XRegExp=function(a){"use strict";function u(a,d,e,f,g){var h;if(a[c]={captureNames:d},g)return a;if(a.__proto__)a.__proto__=b.prototype;else for(h in b.prototype)a[h]=b.prototype[h];return a[c].source=e,a[c].flags=f?f.split("").sort().join(""):f,a}function v(a){return e.replace.call(a,/([\s\S])(?=[\s\S]*\1)/g,"")}function w(d,f){if(!b.isRegExp(d))throw new TypeError("Type RegExp expected");var g=d[c]||{},h=y(d),i="",j="",k=null,l=null;return f=f||{},f.removeG&&(j+="g"),f.removeY&&(j+="y"),j&&(h=e.replace.call(h,new RegExp("["+j+"]+","g"),"")),f.addG&&(i+="g"),f.addY&&(i+="y"),i&&(h=v(h+i)),f.isInternalOnly||(g.source!==a&&(k=g.source),null!=g.flags&&(l=i?v(g.flags+i):g.flags)),d=u(new RegExp(d.source,h),z(d)?g.captureNames.slice(0):null,k,l,f.isInternalOnly)}function x(a){return parseInt(a,16)}function y(a){return q?a.flags:e.exec.call(/\/([a-z]*)$/i,RegExp.prototype.toString.call(a))[1]}function z(a){return!(!a[c]||!a[c].captureNames)}function A(a){return parseInt(a,10).toString(16)}function B(a,b){var d,c=a.length;for(d=0;c>d;++d)if(a[d]===b)return d;return-1}function C(a,b){return s.call(a)==="[object "+b+"]"}function D(a,b,c){return e.test.call(c.indexOf("x")>-1?/^(?:\s+|#.*|\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/:/^(?:\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/,a.slice(b))}function E(a){for(;a.length<4;)a="0"+a;return a}function F(a,b){var c;if(v(b)!==b)throw new SyntaxError("Invalid duplicate regex flag "+b);for(a=e.replace.call(a,/^\(\?([\w$]+)\)/,function(a,c){if(e.test.call(/[gy]/,c))throw new SyntaxError("Cannot use flag g or y in mode modifier "+a);return b=v(b+c),""}),c=0;c"}else if(c)return"\\"+(+c+i);return a};if(!C(a,"Array")||!a.length)throw new TypeError("Must provide a nonempty array of patterns to merge");for(m=0;m1&&B(f,"")>-1&&(h=w(this,{removeG:!0,isInternalOnly:!0}),e.replace.call(String(b).slice(f.index),h,function(){var c,b=arguments.length;for(c=1;b-2>c;++c)arguments[c]===a&&(f[c]=a)})),this[c]&&this[c].captureNames)for(i=1;if.index&&(this.lastIndex=f.index)}return this.global||(this.lastIndex=d),f},f.test=function(a){return!!f.exec.call(this,a)},f.match=function(a){var c;if(b.isRegExp(a)){if(a.global)return c=e.match.apply(this,arguments),a.lastIndex=0,c}else a=new RegExp(a);return f.exec.call(a,L(this))},f.replace=function(d,f){var h,i,j,g=b.isRegExp(d);return g?(d[c]&&(i=d[c].captureNames),h=d.lastIndex):d+="",j=C(f,"Function")?e.replace.call(String(this),d,function(){var c,b=arguments;if(i)for(b[0]=new String(b[0]),c=0;ce)throw new SyntaxError("Backreference to undefined group "+b);return a[e+1]||""}if("$"===d)return"$";if("&"===d||0===+d)return a[0];if("`"===d)return a[a.length-1].slice(0,a[a.length-2]);if("'"===d)return a[a.length-1].slice(a[a.length-2]+a[0].length);if(d=+d,!isNaN(d)){if(d>a.length-3)throw new SyntaxError("Backreference to undefined group "+b);return a[d]||""}throw new SyntaxError("Invalid token "+b)})}),g&&(d.global?d.lastIndex=0:d.lastIndex=h),j},f.split=function(c,d){if(!b.isRegExp(c))return e.split.apply(this,arguments);var j,f=String(this),g=[],h=c.lastIndex,i=0;return d=(d===a?-1:d)>>>0,b.forEach(f,c,function(a){a.index+a[0].length>i&&(g.push(f.slice(i,a.index)),a.length>1&&a.indexd?g.slice(0,d):g},t=b.addToken,t(/\\([ABCE-RTUVXYZaeg-mopqyz]|c(?![A-Za-z])|u(?![\dA-Fa-f]{4}|{[\dA-Fa-f]+})|x(?![\dA-Fa-f]{2}))/,function(a,b){if("B"===a[1]&&b===j)return a[0];throw new SyntaxError("Invalid escape "+a[0])},{scope:"all",leadChar:"\\"}),t(/\\u{([\dA-Fa-f]+)}/,function(a,b,c){var d=x(a[1]);if(d>1114111)throw new SyntaxError("Invalid Unicode code point "+a[0]);if(65535>=d)return"\\u"+E(A(d));if(o&&c.indexOf("u")>-1)return a[0];throw new SyntaxError("Cannot use Unicode code point above \\u{FFFF} without flag u")},{scope:"all",leadChar:"\\"}),t(/\[(\^?)]/,function(a){return a[1]?"[\\s\\S]":"\\b\\B"},{leadChar:"["}),t(/\(\?#[^)]*\)/,function(a,b,c){return D(a.input,a.index+a[0].length,c)?"":"(?:)"},{leadChar:"("}),t(/\s+|#.*/,function(a,b,c){return D(a.input,a.index+a[0].length,c)?"":"(?:)"},{flag:"x"}),t(/\./,function(){return"[\\s\\S]"},{flag:"s",leadChar:"."}),t(/\\k<([\w$]+)>/,function(a){var b=isNaN(a[1])?B(this.captureNames,a[1])+1:+a[1],c=a.index+a[0].length;if(!b||b>this.captureNames.length)throw new SyntaxError("Backreference to undefined group "+a[0]);return"\\"+b+(c===a.input.length||isNaN(a.input.charAt(c))?"":"(?:)")},{leadChar:"\\"}),t(/\\(\d+)/,function(a,b){if(!(b===j&&/^[1-9]/.test(a[1])&&+a[1]<=this.captureNames.length)&&"0"!==a[1])throw new SyntaxError("Cannot use octal escape or backreference to undefined group "+a[0]);return a[0]},{scope:"all",leadChar:"\\"}),t(/\(\?P?<([\w$]+)>/,function(a){if(!isNaN(a[1]))throw new SyntaxError("Cannot use integer as capture name "+a[0]);if("length"===a[1]||"__proto__"===a[1])throw new SyntaxError("Cannot use reserved word as capture name "+a[0]);if(B(this.captureNames,a[1])>-1)throw new SyntaxError("Cannot use same name for multiple groups "+a[0]);return this.captureNames.push(a[1]),this.hasNamedCapture=!0,"("},{leadChar:"("}),t(/\((?!\?)/,function(a,b,c){return c.indexOf("n")>-1?"(?:":(this.captureNames.push(null),"(")},{optionalFlags:"n",leadChar:"("}),b}();