UNPKG

maths.ts

Version:

Math utilities library for TypeScript, JavaScript and Node.js

1 lines 126 kB
var maths=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.m=e,n.c=t,n.p="",n(0)}([function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0});const i=n(1);t.metaheuristics=i;const o=n(10);t.structures=o;const s=n(16);t.arithmetic=s;const a=n(32);t.discrete=a;const u=n(34);t.graph=u,r(n(42)),r(n(46))},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(2)),r(n(8)),r(n(9))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3),i=n(7),o=r("mh::sa");t.simulatedAnnealing=function(e,t=1,n=2,r=100,s=0,a=function(e){return e-.1},u=5){let c=e.generateSolution(),l=e.solutionValue(c),f=0;for(let h=r;h>s;){const r=e.generateNeighbors(c,n,t)[i.randInt(0,t)],s=e.solutionValue(r),p=l-s;o("Temperature = "+h,"e^(AE/t) = "+Math.exp(p/h)),o("curS: "+c,"canS: "+r),o("curS value: "+l,"canS value: "+s),p<0?(c=r,l=s,o("Update, better solution!")):Math.random()>=Math.exp(p/h)?(c=r,l=s,o("Update, high enough temperature!"),h=a(h)):f++===u&&(f=0,h=a(h))}return c}},function(e,t,n){(function(r){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}(t=e.exports=n(5)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&"%c"===e&&(o=++i)}),e.splice(o,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(t,n(4))},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var u,c=[],l=!1,f=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&p())}function p(){if(!l){var e=a(h);l=!0;for(var t=c.length;t;){for(u=c,c=[];++f<t;)u&&u[f].run();f=-1,t=c.length}u=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new d(e,t)),1!==c.length||l||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){function r(e){var n;function r(){if(r.enabled){var e=r,i=+new Date,o=i-(n||i);e.diff=o,e.prev=n,e.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var u=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(n,r){if("%%"===n)return n;u++;var i=t.formatters[r];if("function"==typeof i){var o=s[u];n=i.call(e,o),s.splice(u,1),u--}return n}),t.formatArgs.call(e,s),(r.log||t.log||console.log.bind(console)).apply(e,s)}}return r.namespace=e,r.enabled=t.enabled(e),r.useColors=t.useColors(),r.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),r.destroy=i,"function"==typeof t.init&&t.init(r),t.instances.push(r),r}function i(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n<i;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var o=t.instances[n];o.enabled=t.enabled(o.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(6),t.instances=[],t.names=[],t.skips=[],t.formatters={}},function(e,t){var n=1e3,r=60*n,i=60*r,o=24*i,s=365.25*o;function a(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}e.exports=function(e,t){t=t||{};var u,c=typeof e;if("string"===c&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===c&&!1===isNaN(e))return t.long?a(u=e,o,"day")||a(u,i,"hour")||a(u,r,"minute")||a(u,n,"second")||u+" ms":function(e){if(e>=o)return Math.round(e/o)+"d";if(e>=i)return Math.round(e/i)+"h";if(e>=r)return Math.round(e/r)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.randInt=function(e,t){return Math.floor(Math.random()*(t-e))+e},t.factorial=function(e){let t=1;for(let n=2;n<=e;n++)t*=n;return t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3),i=n(7);r("mh::hs");t.harmonicSearch=function(e,t=30,n=.7,r=2,o=500){const s=[];for(let n=0;n<t;n++)s.push(e.generateSolution());for(let t=0;t<o;t++){let t;t=n>Math.random()?e.generateNeighbors(s[i.randInt(0,s.length)],r)[0]:e.generateSolution();const o=a();e.solutionValue(t)>=e.solutionValue(s[o])&&(s[o]=t)}return s[function(){let t=-1,n=-1/0;for(let r=0;r<s.length;r++){const i=e.solutionValue(s[r]);n<i&&(t=r,n=i)}return t}()];function a(){let t=-1,n=1/0;for(let r=0;r<s.length;r++){const i=e.solutionValue(s[r]);n>i&&(t=r,n=i)}return t}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3)("mh::ts");t.tabooSearch=function(e,t=5,n=2,i=30,o=100){const s=e.generateSolution(),a=[];let u=s;r("Initial sol: "+u);let c=e.solutionValue(u);for(let f=0;f<o;f++){const o=[];e.generateNeighbors(s,n,t).forEach(t=>{r("%s=%d",""+t,e.solutionValue(t)),l(t,a)||o.push(t)});let f=o[0],h=0;o.forEach(t=>{const n=e.solutionValue(t);n>h&&(h=n,f=t)}),r("Picked: %s=%d",""+f,h),h>c&&(r("Solution updated to "+f),u=f,c=h,a.unshift(f),a.length>=i&&a.pop())}return r(a),u;function l(t,n){for(let r=0;r<n.length;r++)if(e.compareSolutions(n[r],t))return!0;return!1}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(11);t.Graph=r.default;const i=n(13);t.Vertex=i.default;const o=n(12);t.Edge=o.default;const s=n(14);t.Matrix=s.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(12),i=n(13);t.default=class{constructor(e,t=!1){this.directed=t,this._vertexes=[],this.directed=t;for(let t=0;t<e;t++)this.addVertex()}get vertexes(){return this._vertexes}get edges(){const e=[];return this.vertexes.forEach(t=>t.edges.forEach(t=>e.push(t))),e}addVertex(e,t){this.vertexes.push(new i.default(this.vertexes.length,e,t))}addEdge(e,t,n,i){this.vertexes[e].addEdge(new r.default(this.vertexes[e],this.vertexes[t],n,i)),this.directed||this.vertexes[t].addEdge(new r.default(this.vertexes[t],this.vertexes[e],n,i))}heuristicValue(e,t){return this._heuristic?this._heuristic(this.vertexes[e],this.vertexes[t]):0}setHeuristic(e){this._heuristic=e}toString(){return this._vertexes.length<=0?"Empty graph":"Graph:\n\t"+this.vertexes.join("\n\t")}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e,t,n,r){this._source=e,this._destination=t,this.info=r,"number"==typeof n?this.weight=n:this.setWeightFunction(n),this.info=r}get weight(){return this.weightFunction?this.weightFunction(this.source,this.destination):void 0===this._weight?1:this._weight}set weight(e){this._weight=e}get source(){return this._source}set source(e){this._source=e}get destination(){return this._destination}set destination(e){this._destination=e}setWeightFunction(e){this.weightFunction=e}removeWeightFunction(){this.weightFunction=void 0}toString(){return"("+this.source.name+", "+this.destination.name+(void 0!==this.weight?", "+this.weight:"")+")"}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e,t,n){this.id=e,this._name=t,this.info=n,this.info=n,this._edges=[]}get edges(){return this._edges}get name(){return this._name?this._name:this.id+""}set name(e){this._name=e}addEdge(e){for(let t=0;t<this._edges.length;t++)if(this.edges[t].source.equals(e.source)&&this.edges[t].destination===e.destination&&this.edges[t].weight&&e.weight&&this.edges[t].weight>e.weight)return void(this.edges[t]=e);this.edges.push(e)}getNeighborHood(){return this.edges.map(e=>e.destination)}equals(e){return e._edges===this._edges&&this._name===e._name}toString(){return this.name+(this.edges.length?": ":"")+this.edges.join(", ")}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(15),i=n(31);class o{constructor(e=1,t=1){"number"==typeof e?this.mxnConstructor(e,t):this.matrixConstructor(e)}get M(){return this.matrix.length}get N(){return this.matrix[0].length}get nodeMatrix(){return this.matrix.map(e=>e.map(r.default.newNode))}get numberMatrix(){return this.matrix.map(e=>e.map(e=>e.numberValue))}get stringMatrix(){return this.matrix.map(e=>e.map(e=>e+""))}get isSquare(){return this.M===this.N}get transpose(){const e=new o(this.N,this.M);for(let t=0;t<e.M;t++)for(let n=0;n<e.N;n++)e.matrix[t][n]=this.matrix[n][t].clone();return e}get adjucate(){if(!this.isSquare)throw new Error("Only a square matrix has adjucate");const e=new o(this.M,this.N);for(let t=0;t<e.M;t++)for(let n=0;n<e.N;n++)e.matrix[t][n]=t+n&1?s(a(this.matrix,n,t)).negate():s(a(this.matrix,n,t));return e}get inverse(){if(!this.isSquare)throw new Error("Only a square matrix has inverse");const e=this.adjucate,t=this.determinant;for(const n of e.matrix)for(const e of n)e.divideHere(t);return e}get determinant(){if(!this.isSquare)throw new Error("Determinant can only be calculated on a square matrix");return s(this.matrix)}add(e){if(e.M!==this.M||e.N!==this.N)throw new Error("The sizes of the matrix does not match to execute addition between them.");const t=new o(this.M,this.N);for(let n=0;n<this.M;n++)for(let r=0;r<this.N;r++)t.matrix[n][r]=this.matrix[n][r].add(e.matrix[n][r]);return t}multiply(e){if(this.N!==e.M)throw new Error("The sizes of the matrix does not match to execute multiplication between them.");const t=new o(this.M,e.N);for(let n=0;n<t.M;n++)for(let i=0;i<t.N;i++){t.matrix[n][i]=new r.default(0);for(let r=0;r<this.N;r++)t.matrix[n][i].addHere(this.matrix[n][r].multiply(e.matrix[r][i]))}return t}pivoting(e,t){let n;for(let r=0;r<this.matrix.length;r++)if(r!==t){n=this.matrix[r][e].clone();for(let e=0;e<this.matrix[r].length;e++)this.matrix[r][e].subtractHere(this.matrix[t][e].multiply(n))}}toString(){return this.matrix.map(e=>e.join("\t")).join("\n")}toHTMLElement(){const e=i("<table>");for(let t=0;t<this.matrix.length;t++){const n=i("<tr>").appendTo(e);for(let e=0;e<this.matrix[t].length;e++)n.append(i("<td>",{html:this.matrix[t][e]+""}))}return e[0]}clone(){return new o(this.matrix)}mxnConstructor(e,t){this.matrix=[];for(let n=0;n<e;n++){this.matrix.push([]);for(let e=0;e<t;e++)this.matrix[n].push(new r.default)}}matrixConstructor(e){e instanceof o&&(e=e.matrix.map(e=>e.map(e=>e.clone()))),this.matrix=e.map(e=>e.map(r.default.newNode))}}function s(e){if(2===e.length)return e[0][0].multiply(e[1][1]).subtract(e[0][1].multiply(e[1][0]));if(1===e.length)return e[0][0].clone();const t=new r.default(0);for(let n=0;n<e.length;n++)0==(1&n)?t.addHere(e[0][n].multiply(s(a(e,0,n)))):t.subtractHere(e[0][n].multiply(s(a(e,0,n))));return t}function a(e,t,n){const r=[];for(let i=0;i<e.length;i++)i!==t&&r.push(e[i].slice(0,n).concat(e[i].slice(n+1,e.length)));return r}t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(16),i=n(29),o=n(30);t.numberRegex=/-?(((\d+)(\.\d+)?)|(\.\d+))/,t.symbolRegex=/[a-z]\w*/i;class s{constructor(e,n){if(this.parent=n,this.children=[],this.exponent=1,this.type=a.Constant,this.value=NaN,this._positive=!0,function(e){if("string"==typeof e){const t=/^-?(((\d+)(\.\d+)?)|(\.\d+))$/;return"number"==typeof e||t.test(e)}return"number"==typeof e}(e))this.value=Number(e),this.type=a.Constant,this.rationalize();else if(e instanceof s){this.value=e.value,this.parent=e.parent,this.type=e.type,this.exponent="number"==typeof e.exponent?e.exponent:new s(e.exponent),this._positive=e._positive;for(const t of e.children)this.children.push(new s(t))}else if("string"==typeof e){let n=u(e=function(e){if(0===(e=e.replace(/ +/g,"").replace(/ *\( */g,"(").replace(/ *\) */g,")").replace(/ *\+ */g,"+").replace(/ *\* */g,"*").replace(/ *- */g,"-").replace(/ *\/ */g,"/").replace(/ *\^ */g,"^")).length||e.search(/\( *\)/)>=0)throw new i.InputError("There cannot be empty expressions on input.");if(e.search(/(([*+\/^])([*+\/^])+)|(\(([*+\/^])+)|(([*+\/^])+\))/)>=0)throw new Error("There are two operators that does not suppose to be together: "+e+".");return e}(e));for(;1===n.length&&(n=u(e=n[0]))[0]!==e;);!function e(n,r){let o;2===r.length&&"-"===r[0]&&(o=r.shift());1===r.length&&(r=u(r[0]));if(1===r.length)switch(n.type=function(e){let n;if(t.numberRegex.test(e)&&e.match(t.numberRegex)[0]===e)return a.Constant;if(n=e.match(t.symbolRegex)[0])return 0===e.indexOf(n)&&"("===e[n.length]?a.Function:a.Variable;return}(r[0])){case a.Variable:n.value=r[0].match(t.symbolRegex)[0];break;case a.Function:n.value=r[0].match(t.symbolRegex)[0],n.children=[new s(r[0].replace(n.value,""),n)];break;case a.Constant:n.value=Number(r[0]),n.rationalize();break;default:throw new i.InputError("Something unexpected happened.")}else{let t=-1;for(let e=1;e<r.length;e++)void 0!==s.operators[r[e]]&&void 0===s.operators[r[e-1]]&&(t<0||s.operators[r[e]].priority<s.operators[r[t]].priority)&&(t=e);"^^"!==(n.value=r[t])&&(n.type=a.Operator,n.children.push(new s(void 0,n)),e(n.children[0],r.slice(0,t)),n.children.push(new s(void 0,n)),e(n.children[1],r.slice(t+1)))}"-"===o&&(n.positive=!1)}(this,n),this.simplify()}}static get operators(){return s.scope.operators}static get functions(){return s.scope.functions}static get constants(){return s.scope.constants}get positive(){return this._positive}set positive(e){this.type===a.Constant&&this.positive!==e?this.value=-this.value:this._positive=e}get isFraction(){return"/"===this.value}get numberValue(){return this.getNumberValue()}get negative(){return!this.positive}set negative(e){this.positive=!e}static newNode(e){return new s(e)}static add(e,t){return e instanceof s?e.add(t):t instanceof s?t.add(e):new s(e).add(t)}static multiply(e,t){return e instanceof s?e.multiply(t):t instanceof s?t.multiply(e):new s(e).multiply(t)}static setConstant(e,t){}getNumberValue(e){let t;if(this.type===a.Constant&&"number"==typeof this.value)t=this.value;else if(this.type===a.Operator)t=s.operators[this.value].fn(this.children[0],this.children[1],e);else if(this.type===a.Function)t=s.functions[this.value].fn(this.children[0],e);else try{t=e[this.value]}catch(e){t=s.constants[this.value]}return 1!==this.exponent&&(t="number"==typeof this.exponent?Math.pow(t,this.exponent):Math.pow(t,this.exponent.getNumberValue(e))),this._positive?t:-t}add(e){const t=new s,n=new s(e);return t.type=a.Operator,t.value="+",this.isFraction?(n.isFraction?(t.children[0]=this.children[0].multiply(n.children[1]).add(this.children[1].multiply(n.children[0])),t.children[1]=this.children[1].multiply(n.children[1])):(t.children[0]=this.children[0].add(this.children[1].multiply(n)),t.children[1]=this.children[1].clone()),t.value="/"):n.isFraction?(t.children[0]=n.children[1].multiply(this).add(n.children[0]),t.children[1]=n.children[1],t.value="/"):(t.children[0]=this.clone(),t.children[1]=n),t.simplify(),t}subtract(e){const t=new s,n=new s(e);return t.type=a.Operator,t.value="-",this.isFraction?(n.isFraction?(t.children[0]=this.children[0].multiply(n.children[1]).subtract(this.children[1].multiply(n.children[0])),t.children[1]=this.children[1].multiply(n.children[1])):(t.children[0]=this.children[0].subtract(this.children[1].multiply(n)),t.children[1]=this.children[1].clone()),t.value="/"):n.isFraction?(t.children[0]=n.children[1].multiply(this).subtract(n.children[0]),t.children[1]=n.children[1],t.value="/"):(t.children[0]=this.clone(),t.children[1]=n),t.simplify(),t}multiply(e){const t=new s,n=new s(e);return t.type=a.Operator,t.value="*",this.isFraction?(n.isFraction?(t.children[0]=this.children[0].multiply(n.children[0]),t.children[1]=this.children[1].multiply(n.children[1])):(t.children[0]=this.children[0].multiply(n),t.children[1]=this.children[1].clone()),t.value="/"):n.isFraction?(t.children[0]=n.children[0].multiply(this),t.children[1]=n.children[1],t.value="/"):(t.children[0]=this.clone(),t.children[1]=n),t.simplify(),t}divide(e){const t=new s,n=new s(e);return t.type=a.Operator,t.value="/",this.isFraction?n.isFraction?(t.children[0]=this.children[0].multiply(n.children[1]),t.children[1]=this.children[1].multiply(n.children[0])):(t.children[0]=this.children[0].clone(),t.children[1]=this.children[1].multiply(n)):n.isFraction?(t.children[0]=n.children[1].multiply(this),t.children[1]=n.children[0]):(t.children[0]=this.clone(),t.children[1]=n),t.simplify(),t}pow(e){const t=new s(this);return t.powHere(e),t.simplify(),t}negate(){const e=this.clone();return e.negateHere(),e}addHere(e){return this.update(this.add(e)),this}subtractHere(e){return this.update(this.subtract(e)),this}multiplyHere(e){return this.update(this.multiply(e)),this}divideHere(e){return this.update(this.divide(e)),this}powHere(e){return"number"==typeof this.exponent?this.exponent=new s(this.exponent+"*("+e+")"):this.exponent.multiplyHere(e),this}negateHere(){return this.positive=!this.positive,this}compare(e,t="="){const n=this.numberValue;switch(e instanceof s&&(e=e.numberValue),t){case">":return n>e;case"<":return n<e;case">=":return n>=e;case"<=":return n<=e;case"!=":return n!==e;default:return n===e}}toString(){let e;return e=this.type===a.Function?this.value+"("+this.children.join(", ")+")":this.type===a.Operator?this.printChild(this.children[0])+this.value+this.printChild(this.children[1]):this.value+"",this._positive?e:this.type===a.Operator?"-("+e+")":"-"+e}clone(){return new s(this)}isNaN(){return isNaN(this.numberValue)}simplify(){for(const e of this.children)e.simplify();const e=this.numberValue;if(this.type===a.Constant||isNaN(e)||e!==Math.floor(e)){if(this.type===a.Operator)switch(this.value){case"+":this.simplifyAddition();break;case"-":this.simplifySubtraction();break;case"*":this.simplifyProduct();break;case"/":this.simplifyDivision()}}else this.update(e)}rationalize(){const e=this.value<0;if("number"!=typeof this.value||Math.floor(this.value)===this.value)return;const t=""+(this.value<0?-this.value:this.value),n=t.length-1,i=(Math.round(this.value)+"").length,o=Number(t.replace(".","")),u=Math.pow(10,n-i),c=r.gcd(Number(o),u);this.type=a.Operator,this.value="/",this.children=[new s((e?-o:o)/c),new s(u/c)]}update(e){"number"==typeof e?(this.type=a.Constant,this.value=e,this.children=[],this._positive=!0,this.exponent=1,this.rationalize()):(this.type=e.type,this.value=e.value,this.children=e.children,this._positive=e._positive,this.exponent=e.exponent)}printChild(e){const t=s.operators[e.value];if(void 0===t)return e.toString();const n=s.operators[this.value];return t.priority>=n.priority&&"/"!==e.value?e.toString():"("+e.toString()+")"}simplifyDivision(){if(1===Math.abs(this.children[1].numberValue)){const e=-1===this.children[1].numberValue;return this.update(this.children[0]),void(e&&this.negateHere())}const e=this.children[0].numberValue,t=this.children[1].numberValue;if(void 0!==e&&void 0!==t&&Math.floor(e)===e&&Math.floor(t)===t){const n=r.gcd(e,t);this.children[0].value=e/n,this.children[1].value=t/n}}simplifyProduct(){let e;return 1===Math.abs(this.children[0].numberValue)?(e=-1===this.children[0].numberValue,this.update(this.children[1]),void(e&&this.negateHere())):1===Math.abs(this.children[1].numberValue)?(e=-1===this.children[1].numberValue,this.update(this.children[0]),void(e&&this.negateHere())):void 0}simplifyAddition(){0===this.children[0].numberValue&&this.update(this.children[1]),0===this.children[1].numberValue&&this.update(this.children[0])}simplifySubtraction(){0===this.children[0].numberValue&&(this.update(this.children[1]),this.negateHere()),0===this.children[1].numberValue&&this.update(this.children[0])}}var a;function u(e){const n=[];let r;for(let a=0;a<e.length;a++)if("("===e[a])r=c(e.substring(a,e.length)),n.push(r),a+=r.length+1;else if(1===(o=e[a]).length&&o.search(/[0-9]/i)>=0||"."===e[a])r=e.substring(a,e.length).match(t.numberRegex)[0],n.push(r),a+=r.length-1;else if(l(e[a]))"("===e[a+(r=e.substring(a,e.length).match(t.symbolRegex)[0]).length]&&(r+="("+c(e.substring(a+r.length,e.length))+")"),n.push(r),a+=r.length-1;else if(void 0!==s.operators[e[a]])n.push(e[a]);else if(")"===e[a])throw new i.InputError({message:"There is an extra closing bracket",input:e});var o;return n}function c(e){if("("!==e[0])throw new i.InputError({message:"The expression does not start with a bracket.",input:e});let t,n;for(t=n=1;0!==t&&n<e.length;n++)")"===e[n]?t--:"("===e[n]&&t++;if(0!==t)throw new i.InputError({message:"Expression with extra open bracket.",input:e});return e.substring(1,n-1)}function l(e){return 1===e.length&&0===e.search(/[a-z]|[A-Z]/i)}s.scope=o,t.default=s,function(e){e[e.Operator=0]="Operator",e[e.Constant=1]="Constant",e[e.Function=2]="Function",e[e.Variable=3]="Variable"}(a=t.NodeType||(t.NodeType={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(17);t.sieveOfEratosthenes=r.sieveOfEratosthenes,function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(28))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(18),i=1100401;t.sieveOfEratosthenes=function(e=i){const t=new r.BitSet(e),n=Math.round(Math.sqrt(e)),o=[];for(let r=2;r<=n;r++)if(!t.get(r)){o.push(r);for(let n=0;n<e;n+=r)t.set(n,!0)}for(let r=n+(1&n?2:1);r<e;r+=2)t.get(r)||o.push(r);return o}},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(19)),r(n(24))},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(20)),r(n(22)),r(n(21)),r(n(23))},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){void 0===t&&(t=s);var n=e.call(this)||this;return n.compareFunction=t,n}return i(t,e),t.prototype.push=function(e){var t,n=0;for(n=0;n<this.size()&&!((t=this.compareFunction(e,this._store[n]))>0);n++)if(0===t){n++;break}this._store.splice(n,0,e)},t.prototype.info=function(){return this._store},t}(n(21).Queue);function s(e,t){return e===t?0:e>t?1:-1}t.PriorityQueue=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){this._store=[]}return e.prototype.size=function(){return this._store.length},e.prototype.front=function(){return this._store[0]},e.prototype.back=function(){return this._store[this.size()-1]},e.prototype.pop=function(){return this._store.shift()},e.prototype.popBack=function(){return this._store.pop()},e.prototype.push=function(e){this._store.push(e)},e.prototype.empty=function(){return 0===this.size()},e}();t.Queue=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=8*Uint32Array.BYTES_PER_ELEMENT,r=function(){function e(e,t){void 0===e&&(e=1),this._numOn=0,this._size=0,t?this.setFromBuffer(t,e):this.size=e}return e.prototype.get=function(e){return 0!=(this._buffer[i(e)]&1<<o(e))},e.prototype.set=function(e,t){t&&this.size<=e&&(this.size=e+1),t!==this.get(e)&&(t?this._buffer[i(e)]|=1<<o(e):this._buffer[i(e)]&=~(1<<o(e)),this._numOn+=t?1:-1)},e.prototype.setAll=function(e){var t=this._size%n;0!==t&&e?(c(this._buffer,4294967295,this._buffer.length-1),this._buffer[this._buffer.length-1]=(1<<t)-1):c(this._buffer,e?4294967295:0),this._numOn=e?this._size:0},e.prototype.setFromBuffer=function(e,t){this._buffer=new Uint32Array(e),this._size=t,this._numOn=a(this._buffer,t)},e.prototype.clone=function(){return new e(this.size,this.buffer)},e.prototype.any=function(){return this.numOn>0},e.prototype.all=function(){return this.numOn===this.size},e.prototype.none=function(){return!this.any()},Object.defineProperty(e.prototype,"size",{get:function(){return this._size},set:function(e){if(e!==this._size){var t=this._buffer,r=this._buffer=new Uint32Array(s(e));if(this._size=e,t)if(r.length<t.length){r.set(t.subarray(0,r.length));var i=e%n;i>0&&(r[r.length-1]&=(1<<i)-1),this._numOn=a(r,e)}else r.set(t);else this._numOn=0}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._buffer},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numOn",{get:function(){return this._numOn},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numOff",{get:function(){return this.size-this.numOn},enumerable:!0,configurable:!0}),e}();function i(e){return Math.floor(e/n)}function o(e){return e%n}function s(e){return Math.ceil(e/n)}function a(e,t){for(var r=s(t),i=t%n,o=0,a=0;a<r;a++)o+=a===r-1&&i>0?u(e[a],i):u(e[a]);return o}function u(e,t){return void 0!==t&&(e&=(1<<t)-1),e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,e+=e>>8,127&(e+=e>>16)}function c(e,t,n){void 0===n&&(n=e.length),e.fill(t,0,n)}t.BitSet=r},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){this._store=[]}return e.prototype.size=function(){return this._store.length},e.prototype.top=function(){return this._store[0]},e.prototype.pop=function(){return this._store.shift()},e.prototype.push=function(e){this._store.unshift(e)},e.prototype.empty=function(){return 0===this.size()},e}();t.Stack=n},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(25)),r(n(27))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(26);t.lowerBound=function(e,t,n,i,o){void 0===o&&(o=r.defaultComparison);var s=function t(n,r){if(n===r)return n;var s=n+r>>1,a=o(i,e[s]);return 0===a?s:a<0?t(n,s):t(s+1,r)}(t,n);return o(i,e[s])<0&&0!==s?s-1:s===n?s-1:s}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultComparison=function(e,t){return e>t?1:e<t?-1:0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(26);t.upperBound=function(e,t,n,i,o){void 0===o&&(o=r.defaultComparison);var s=u(t,n),a=(o(i,e[s]),u(t,n));return e[a]===i?a+1:a;function u(t,n){if(t===n)return t;var r=t+n>>1,s=o(i,e[r]);return 0===s?r:s<0?u(t,r):u(r+1,n)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(17);function i(...e){let n=1;for(let r=0;!o(t.PRIMES[r],e);r++)for(;s(t.PRIMES[r],e);){n*=t.PRIMES[r];for(let n=0;n<e.length;n++)e[n]/=t.PRIMES[r]}return n}function o(e,t){for(const n of t)if(e>n)return!0;return!1}function s(e,t){for(const n of t)if(n%e!=0)return!1;return!0}t.PRIMES=r.sieveOfEratosthenes(),t.getPrimeFactors=function(e){const n=[];for(let r=0;t.PRIMES[r]<=e;r++)for(;e%t.PRIMES[r]==0;)n.push(t.PRIMES[r]),e/=t.PRIMES[r];return n},t.lcm=function(...e){return e.reduce((e,t)=>t*e/i(e,t))},t.gcd=i},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.InputError=class extends Error{constructor(e){super("string"==typeof e?e:e.message+" -- at: "+e.input)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(29);t.operators={"+":{priority:1,params:2,fn:(e,t,n)=>{const r=e.getNumberValue(n),i=t.getNumberValue(n);if(void 0!==r&&void 0!==i)return r+i}},"-":{priority:1,params:2,fn:(e,t,n)=>{const r=e.getNumberValue(n),i=t.getNumberValue(n);if(void 0!==r&&void 0!==i)return r-i}},"*":{priority:2,params:2,fn:(e,t,n)=>{const r=e.getNumberValue(n),i=t.getNumberValue(n);if(void 0!==r&&void 0!==i)return r*i}},"/":{priority:2,params:2,fn:(e,t,n)=>{const r=e.getNumberValue(n),i=t.getNumberValue(n);if(void 0!==r&&void 0!==i)return r/i}},"^":{priority:3,params:2,fn:(e,t,n)=>{const r=e.getNumberValue(n),i=t.getNumberValue(n);if(void 0!==r&&void 0!==i)return Math.pow(r,i)}},"!":{priority:4,params:1,fn:(e,t)=>{let n;return void 0!==(n=e.getNumberValue(t))?function e(t){if(t<0||Math.floor(t)===t)throw new r.InputError("At this moment we are only capable to calculate positive integers[0, inf).");if(t<2)return 1;return t*e(t-1)}(n):n}}},t.functions={sin:{fn:(e,t)=>{let n;return void 0!==(n=e.getNumberValue(t))?Math.sin(n):n}},cos:{fn:(e,t)=>{let n;return void 0!==(n=e.getNumberValue(t))?Math.cos(n):n}},tan:{fn:(e,t)=>{let n;return void 0!==(n=e.getNumberValue(t))?Math.tan(n):n}},asin:{fn:(e,t)=>{let n;return void 0!==(n=e.getNumberValue(t))?Math.asin(n):n}},acos:{fn:(e,t)=>{let n;return void 0!==(n=e.getNumberValue(t))?Math.acos(n):n}},atan:{fn:(e,t)=>{let n;return void 0!==(n=e.getNumberValue(t))?Math.atan(n):n}},log:{fn:(e,t)=>{let n;return void 0!==(n=e.getNumberValue(t))?Math.log(n):n}}},t.constants={e:Math.E,pi:Math.PI,PI:void 0,E:void 0},t.constants.E=t.constants.e,t.constants.PI=t.constants.pi},function(e,t,n){var r;!function(t,n){"use strict";"object"==typeof e&&"object"==typeof e.exports?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:this,function(n,i){"use strict";var o=[],s=n.document,a=Object.getPrototypeOf,u=o.slice,c=o.concat,l=o.push,f=o.indexOf,h={},p=h.toString,d=h.hasOwnProperty,g=d.toString,m=g.call(Object),v={},y=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},b=function(e){return null!=e&&e===e.window},x={type:!0,src:!0,noModule:!0};function w(e,t,n){var r,i=(t=t||s).createElement("script");if(i.text=e,n)for(r in x)n[r]&&(i[r]=n[r]);t.head.appendChild(i).parentNode.removeChild(i)}function C(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?h[p.call(e)]||"object":typeof e}var T=function(e,t){return new T.fn.init(e,t)},E=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function S(e){var t=!!e&&"length"in e&&e.length,n=C(e);return!y(e)&&!b(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}T.fn=T.prototype={jquery:"3.3.1",constructor:T,length:0,toArray:function(){return u.call(this)},get:function(e){return null==e?u.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=T.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return T.each(this,e)},map:function(e){return this.pushStack(T.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(u.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:l,sort:o.sort,splice:o.splice},T.extend=T.fn.extend=function(){var e,t,n,r,i,o,s=arguments[0]||{},a=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[a]||{},a++),"object"==typeof s||y(s)||(s={}),a===u&&(s=this,a--);a<u;a++)if(null!=(e=arguments[a]))for(t in e)n=s[t],s!==(r=e[t])&&(c&&r&&(T.isPlainObject(r)||(i=Array.isArray(r)))?(i?(i=!1,o=n&&Array.isArray(n)?n:[]):o=n&&T.isPlainObject(n)?n:{},s[t]=T.extend(c,o,r)):void 0!==r&&(s[t]=r));return s},T.extend({expando:"jQuery"+("3.3.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==p.call(e))&&(!(t=a(e))||"function"==typeof(n=d.call(t,"constructor")&&t.constructor)&&g.call(n)===m)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e){w(e)},each:function(e,t){var n,r=0;if(S(e))for(n=e.length;r<n&&!1!==t.call(e[r],r,e[r]);r++);else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(E,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(S(Object(e))?T.merge(n,"string"==typeof e?[e]:e):l.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:f.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,s=!n;i<o;i++)!t(e[i],i)!==s&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,s=[];if(S(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&s.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&s.push(i);return c.apply([],s)},guid:1,support:v}),"function"==typeof Symbol&&(T.fn[Symbol.iterator]=o[Symbol.iterator]),T.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){h["[object "+t+"]"]=t.toLowerCase()});var N=function(e){var t,n,r,i,o,s,a,u,c,l,f,h,p,d,g,m,v,y,b,x="sizzle"+1*new Date,w=e.document,C=0,T=0,E=se(),S=se(),N=se(),_=function(e,t){return e===t&&(f=!0),0},j={}.hasOwnProperty,k=[],O=k.pop,M=k.push,A=k.push,D=k.slice,F=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},P="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",q="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",H="\\["+L+"*("+q+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+q+"))|)"+L+"*\\]",I=":("+q+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+H+")*)|.*)\\)|)",V=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),B=new RegExp("^"+L+"*,"+L+"*"),W=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),z=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),$=new RegExp(I),U=new RegExp("^"+q+"$"),X={ID:new RegExp("^#("+q+")"),CLASS:new RegExp("^\\.("+q+")"),TAG:new RegExp("^("+q+"|[*])"),ATTR:new RegExp("^"+H),PSEUDO:new RegExp("^"+I),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){h()},ie=ye(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{A.apply(k=D.call(w.childNodes),w.childNodes),k[w.childNodes.length].nodeType}catch(e){A={apply:k.length?function(e,t){M.apply(e,D.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}function oe(e,t,r,i){var o,a,c,l,f,d,v,y=t&&t.ownerDocument,C=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==C&&9!==C&&11!==C)return r;if(!i&&((t?t.ownerDocument||t:w)!==p&&h(t),t=t||p,g)){if(11!==C&&(f=J.exec(e)))if(o=f[1]){if(9===C){if(!(c=t.getElementById(o)))return r;if(c.id===o)return r.push(c),r}else if(y&&(c=y.getElementById(o))&&b(t,c)&&c.id===o)return r.push(c),r}else{if(f[2])return A.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return A.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!N[e+" "]&&(!m||!m.test(e))){if(1!==C)y=t,v=e;else if("object"!==t.nodeName.toLowerCase()){for((l=t.getAttribute("id"))?l=l.replace(te,ne):t.setAttribute("id",l=x),a=(d=s(e)).length;a--;)d[a]="#"+l+" "+ve(d[a]);v=d.join(","),y=K.test(e)&&ge(t.parentNode)||t}if(v)try{return A.apply(r,y.querySelectorAll(v)),r}catch(e){}finally{l===x&&t.removeAttribute("id")}}}return u(e.replace(R,"$1"),t,r,i)}function se(){var e=[];return function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}}function ae(e){return e[x]=!0,e}function ue(e){var t=p.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ce(e,t){for(var n=e.split("|"),i=n.length;i--;)r.attrHandle[n[i]]=t}function le(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function he(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function pe(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function de(e){return ae(function(t){return t=+t,ae(function(n,r){for(var i,o=e([],n.length,t),s=o.length;s--;)n[i=o[s]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},h=oe.setDocument=function(e){var t,i,s=e?e.ownerDocument||e:w;return s!==p&&9===s.nodeType&&s.documentElement?(d=(p=s).documentElement,g=!o(p),w!==p&&(i=p.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(p.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Y.test(p.getElementsByClassName),n.getById=ue(function(e){return d.appendChild(e).id=x,!p.getElementsByName||!p.getElementsByName(x).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];for(i=t.getElementsByName(e),r=0;o=i[r++];)if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],m=[],(n.qsa=Y.test(p.querySelectorAll))&&(ue(function(e){d.appendChild(e).innerHTML="<a id='"+x+"'></a><select id='"+x+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]="+L+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||m.push("\\["+L+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+x+"-]").length||m.push("~="),e.querySelectorAll(":checked").length||m.push(":checked"),e.querySelectorAll("a#"+x+"+*").length||m.push(".#.+[+~]")}),ue(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=p.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&m.push("name"+L+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&m.push(":enabled",":disabled"),d.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&m.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),m.push(",.*:")})),(n.matchesSelector=Y.test(y=d.matches||d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=y.call(e,"*"),y.call(e,"[s!='']:x"),v.push("!=",I)}),m=m.length&&new RegExp(m.join("|")),v=v.length&&new RegExp(v.join("|")),t=Y.test(d.compareDocumentPosition),b=t||Y.test(d.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},_=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===p||e.ownerDocument===w&&b(w,e)?-1:t===p||t.ownerDocument===w&&b(w,t)?1:l?F(l,e)-F(l,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,s=[e],a=[t];if(!i||!o)return e===p?-1:t===p?1:i?-1:o?1:l?F(l,e)-F(l,t):0;if(i===o)return le(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)a.unshift(n);for(;s[r]===a[r];)r++;return r?le(s[r],a[r]):s[r]===w?-1:a[r]===w?1:0},p):p},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&h(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!N[t+" "]&&(!v||!v.test(t))&&(!m||!m.test(t)))try{var r=y.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,p,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==p&&h(e),b(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==p&&h(e);var i=r.attrHandle[t.toLowerCase()],o=i&&j.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,l=!n.sortStable&&e.slice(0),e.sort(_),f){for(;t=e[o++];)t===e[o]&&(i=r.push(o));for(;i--;)e.splice(r[i],1)}return l=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else for(;t=e[r++];)n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:ae,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return X.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&$.test(n)&&(t=s(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+L+")"+e+"("+L+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace(V," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),s="last"!==e.slice(-4),a="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var c,l,f,h,p,d,g=o!==s?"nextSibling":"previousSibling",m=t.parentNode,v=a&&t.nodeName.toLowerCase(),y=!u&&!a,b=!1;if(m){if(o){for(;g;){for(h=t;h=h[g];)if(a?h.nodeName.toLowerCase()===v:1===h.nodeType)return!1;d=g="only"===e&&!d&&"nextSibling"}return!0}if(d=[s?m.firstChild:m.lastChild],s&&y){for(b=(p=(c=(l=(f=(h=m)[x]||(h[x]={}))[h.uniqueID]||(f[h.uniqueID]={}))[e]||[])[0]===C&&c[1])&&c[2],h=p&&m.childNodes[p];h=++p&&h&&h[g]||(b=p=0)||d.pop();)if(1===h.nodeType&&++b&&h===t){l[e]=[C,p,b];break}}else if(y&&(b=p=(c=(l=(f=(h=t)[x]||(h[x]={}))[h.uniqueID]||(f[h.uniqueID]={}))[e]||[])[0]===C&&c[1]),!1===b)for(;(h=++p&&h&&h[g]||(b=p=0)||d.pop())&&((a?h.nodeName.toLowerCase()!==v:1!==h.nodeType)||!++b||(y&&((l=(f=h[x]||(h[x]={}))[h.uniqueID]||(f[h.uniqueID]={}))[e]=[C,b]),h!==t)););return(b-=i)===r||b%r==0&&b/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[x]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?ae(function(e,n){for(var r,o=i(e,t),s=o.length;s--;)e[r=F(e,o[s])]=!(n[r]=o[s])}):function(e){return i(e,0,n)}):i}},pseudos:{not:ae(function(e){var t=[],n=[],r=a(e.replace(R,"$1"));return r[x]?ae(function(e,t,n,i){for(var o,s=r(e,null,i,[]),a=e.length;a--;)(o=s[a])&&(e[a]=!(t[a]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:ae(function(e){return function(t){return oe(e,t).length>0}}),contains:ae(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:ae(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCa