function Vector(a,b,c){this.x=a||0,this.y=b||0,this.z=c||0}function UntidyPriorityQueue(a,b){this.m_tab=new Array(a);for(var c=0;a>c;c++)this.m_tab[c]=[];this.m_size=a,this.m_nb_elem=0,this.m_t0=0,this.m_i0=0,this.m_delta=b/a,this.m_inc_max=b,this.empty=function(){return 0==this.m_nb_elem},this.push=function(a,b){var c=0;if(this.empty())this.m_t0=b,this.m_i0=0;else if(b-this.m_t0>this.m_inc_max&&(console.log("Error: Increment="+(b-this.m_t0)+" >> Inc max "+this.m_inc_max),console.log("       e="+a+", t="+b+", m_t0="+this.m_t0)),c=Math.floor((b-this.m_t0)*this.m_size/this.m_inc_max),c>=0)c=c>=this.m_size?this.m_size-1:c,c=(c+this.m_i0)%this.m_size;else{for(;c++<0;)if(this.m_i0=this.m_i0>0?this.m_i0-1:this.m_i0-1+this.m_size,this.m_t0-=this.m_delta,this.m_tab[this.m_i0].length){console.log("Error : While shifting the begining of the queue, circular array not empty at the end"),console.log("        e="+a+", t="+b),this.m_i0=(this.m_i0+1)%this.m_size,this.m_t0+=this.m_delta;break}c=this.m_i0}return this.m_nb_elem++,this.m_tab[c].push(a),c},this.pop=function(){if(!this.empty()){for(;!this.m_tab[this.m_i0].length;)this.m_i0=(this.m_i0+1)%this.m_size,this.m_t0+=this.m_delta;return this.m_nb_elem--,this.m_tab[this.m_i0].shift()}},this.top=function(){if(!this.empty()){for(;!this.m_tab[this.m_i0].length;)this.m_i0=(this.m_i0+1)%this.m_size,this.m_t0+=this.m_delta;return this.m_nb_elem--,this.m_tab[this.m_i0][0]}},this.increase_priority=function(a,b,c){Math.abs(c-this.m_t0)>this.m_inc_max&&(console.log("Error : Increment="+(c-this.m_t0)+" >> Inc max "+this.m_inc_max),console.log("        e="+a+", t="+c+", m_t0"+this.m_t0));var d=Math.floor((c-this.m_t0)*this.m_size/this.m_inc_max);if(d>=0)d=d>=this.m_size?this.m_size-1:d,d=(d+this.m_i0)%this.m_size;else{for(;d++<0;)if(this.m_i0=this.m_i0>0?this.m_i0-1:this.m_i0-1+this.m_size,this.m_t0-=this.m_delta,this.m_tab[this.m_i0].length){console.log("Error : While shifting the begining of the queue, circular array not empty at the end"),console.log("        e="+a+", t="+c),this.m_i0=(this.m_i0+1)%this.m_size,this.m_t0+=this.m_delta;break}d=this.m_i0}return this.m_tab[b].splice(this.m_tab[b].indexOf(a),1),this.m_tab[d].push(a),d},this.clear=function(){this.m_nb_elem=0,this.m_t0=0,this.m_i0=0;for(var a=0;a<this.m_size;a++)this.m_tab[a].splice(0,this.m_tab[a].length)},this.size=function(){return this.m_nb_elem}}function createcanvas(a,b,c){var d=document.createElement("canvas");if(d.width=b,d.height=c,0===a.localeCompare("CANVAS")||0===a.localeCompare("canvas"));else{var e=document.getElementById(a);e.appendChild(d)}return d}function getHisograms(a){var b=new Image;b.src=a;var c=createcanvas("canvas",b.width,b.height),d=c.getContext("2d");d.drawImage(b,0,0);var e=d.getImageData(0,0,b.width,b.height),f=getChanels_U8(e),g=get_histogram(f[0]),h=get_histogram(f[1]),i=get_histogram(f[2]);return normalize(g,b.width*b.height),normalize(h,b.width*b.height),normalize(i,b.width*b.height),[g,h,i]}function getChanels_U8(a){for(var b=0,c=0,d=new jsfeat.matrix_t(a.width,a.height,jsfeat.U8_t|jsfeat.C1_t),e=new jsfeat.matrix_t(a.width,a.height,jsfeat.U8_t|jsfeat.C1_t),f=new jsfeat.matrix_t(a.width,a.height,jsfeat.U8_t|jsfeat.C1_t),g=new jsfeat.matrix_t(a.width,a.height,jsfeat.U8_t|jsfeat.C1_t),h=0;h<a.height;h++)for(var i=0;i<a.width;i++,b+=4,c+=1)d.data[c]=a.data[b],e.data[c]=a.data[b+1],f.data[c]=a.data[b+2],g.data[c]=a.data[b+3];return[d.data,e.data,f.data,g.data]}function get_histogram(a){for(var b=new Array(256),c=0;256>c;++c)b[c]=0;for(var c=0;c<a.length;++c)++b[a[c]];return b}function normalize(a,b){for(var c=0;c<a.length;++c)a[c]=a[c]/b}function histogramEqualizationTransform(a){for(var b=0,c=new Array(a.length),d=0;d<a.length;++d)c[d]=(a.length-1)*a[d]+b,b=c[d],c[d]=Math.round(c[d]);return c}function step3(a,b){for(var c=new Array(a.length),d=0;d<a.length;++d)c[d]=findClosest(a[d],b,d);return c}function findClosest(a,b,c){for(var d=9999,e=0,f=0;f<b.length;++f){var g=a-b[f];g=g>=0?g:-g,d>g&&(d=g,e=f)}for(var h=[],i=0;i<b.length;++i){var j=a-b[i];j=j>=0?j:-j,j===d&&i!==e&&h.push(i)}h.push(e),d=9999;for(var i=0;i<h.length;++i){var g=c-h[i];g=g>=0?g:-g,d>=g&&(d=g,e=h[i])}return d>10&&(e=c),e}function correctImg(a,b,c){for(var d=0,e=0,f=0;f<b.height;f++)for(var g=0;g<b.width;g++,d+=4,e+=1)c.data[d]=a[0][b.data[d]],c.data[d+1]=a[1][b.data[d+1]],c.data[d+2]=a[2][b.data[d+2]],c.data[d+3]=b.data[d+3]}function findBlobs(a,b,c,d){var e,f,g=1,h={numberOfUnique:0,data:new Array(b*c)},i=[],j=1,k=[0];for(f=0;c>f;f++)for(i.push([]),e=0;b>e;e++)i[f].push(0);for(var l,m,n,o,p,q,r,s,t,u=0,v=2;v--;){for(f=1;c-1>f;f++)for(e=1;b-1>e;e++)g=f*b+e,u=a[g]>=d,u&&(m=i[f-1][e-1]||0,l=i[f-1][e-0]||0,n=i[f-1][e+1]||0,o=i[f-0][e-1]||0,p=i[f-0][e+1]||0,q=i[f+1][e-1]||0,r=i[f+1][e-0]||0,s=i[f+1][e+1]||0,t=o,o>0&&t>o&&(t=o),p>0&&t>p&&(t=p),l>0&&t>l&&(t=l),n>0&&t>n&&(t=n),m>0&&t>m&&(t=m),r>0&&t>r&&(t=r),s>0&&t>s&&(t=s),q>0&&t>q&&(t=q),0===t?(i[f][e]=j,k.push(j),j+=1):(t<k[m]&&(k[m]=t),t<k[l]&&(k[l]=t),t<k[n]&&(k[n]=t),t<k[o]&&(k[o]=t),t<k[p]&&(k[p]=t),t<k[q]&&(k[q]=t),t<k[r]&&(k[r]=t),t<k[s]&&(k[s]=t),i[f][e]=t));for(var w=k.length;w--;){for(j=k[w];j!==k[j];)j=k[j];k[w]=j}for(f=0;c>f;f++)for(e=0;b>e;e++)if(j=i[f][e],0!==j){for(;j!==k[j];)j=k[j];i[f][e]=j}g=1,j=1}var x=unique(k),w=0;for(j in x)h.numberOfUnique=w,k[j]=w++;for(g=0,f=0;c>f;f++)for(e=0;b>e;e++,g++)j=i[f][e],i[f][e]=k[j],h.data[g]=k[j];return h}function unique(a){var b,c,d={},e=a.length;for(c=0;e>c;c+=1)b=a[c],d[b]?d[b]+=1:d[b]=1;return d}function redrawScrean(a,b,c,d){var e=b[0],f=d?d:0,g=[[0,0,255,255],[255,255,0,255],[255,0,255,255],[0,255,255,255],[255,0,0,255],[0,0,0,255],[0,0,255,255],[255,255,0,255],[255,0,255,255],[0,255,255,255],[255,0,0,255],[0,0,0,255]];result_canvas_bottom.width=e.width,result_canvas_bottom.height=e.height,result_canvas_top.width=e.width,result_canvas_top.height=e.height;var h=result_canvas_bottom.getContext("2d"),i=document.createElement("CANVAS");i.width=e.width,i.height=e.height;for(var j=i.getContext("2d"),k=h.createImageData(e.width,e.height),l=0,m=0,n=0;n<e.height;n++)for(var o=0;o<e.width;o++,l+=4,m+=1)for(var p=0;p<a.length;p++)a[p][0][m]===p+1&&0!=b[a[p][1]].data[l+3]&&(f!=p+1&&(k.data[l]=g[a[p][1]-1][0]?e.data[l]:0,k.data[l+1]=g[a[p][1]-1][1]?e.data[l+1]:0,k.data[l+2]=g[a[p][1]-1][2]?e.data[l+2]:0),k.data[l+3]=255);for(var l=0,m=0,n=0;n<e.height;n++)for(var o=0;o<e.width;o++,l+=4,m+=1)for(var p=0;p<a.length;p++)a[p][0][m]===p+1&&0!=b[a[p][1]].data[l+3]&&(c[p+1]&&(k.data[l]=f==p+1?b[a[p][1]].data[l]/2:0,k.data[l+1]=c[p+1]?b[a[p][1]].data[l+1]:g[a[p][1]-1][1]?e.data[l+1]:0,k.data[l+2]=f==p+1?b[a[p][1]].data[l+2]/2:0),k.data[l+3]=255);j.putImageData(k,0,0),h.putImageData(e,0,0),h.drawImage(i,0,0)}function zeros(a){for(var b=new Array(a),c=0;a>c;c++)b[c]=0;return b}function maskOutRed(a,b,c,d,e){for(var f=0,g=0,h=0,i=0;c>i;i++)for(var j=0;b>j;j++,h+=1)f=4*h,g=d.data[f+3]>=127,g&&(255==d.data[f]&&0==d.data[f+1]&&0==d.data[f+2]?e[h]=0:0==d.data[f]&&255==d.data[f+1]&&0==d.data[f+2]&&(e[h]=a))}function blend(){var a=_.contains(mouse.getBlobSelected(),!0);if(a!==!0)return console.log("do naada"),alert("First, select which Layer/s to blend by click them in the image"),0;$("#btn1").show(),$("#outputresult").show(),$("#formInterface").show(),formInterface;var b=document.createElement("CANVAS"),c=document.createElement("CANVAS");b.width=c.width=finalcanvas.width=cwidth,b.height=c.height=finalcanvas.height=cheight;for(var d=c.getContext("2d"),e=b.getContext("2d"),f=finalcanvas.getContext("2d"),g=!0,h=0;h<=_.size(mouse.getBlobSelected());h++)if(mouse.getBlobSelected()[h]===!0){var i=h;d.putImageData(modImgData[blobData[h-1][1]],0,0),e.putImageData(imgData[0],0,0),g&&(f.putImageData(imgData[0],0,0),g=!1);var j=blobData[i-1][0],k=d.getImageData(0,0,c.width,c.height),l=getMask(j,k,i);console.log("start Blending, blobnr:",i,"ref img :",blobData[h-1][1]),poissonBlendImages(b,c,l,finalcanvas)}}function getMask(a,b,c){var d=document.createElement("CANVAS");d.width=b.width,d.height=b.height;for(var e=d.getContext("2d"),f=e.getImageData(0,0,b.width,b.height),g=0,h=0;h<b.height;h++)for(var i=0;i<b.width;i++,g+=1){var j=4*g;a[g]===c&&0!=b.data[j+3]?(f.data[j+0]=0,f.data[j+1]=255,f.data[j+2]=0,f.data[j+3]=255):(f.data[j+0]=b.data[j+0],f.data[j+1]=b.data[j+1],f.data[j+2]=b.data[j+2],f.data[j+3]=b.data[j+3])}return e.putImageData(f,0,0),d}function changeKey(a,b,c){b!==c&&(Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(a,b)),delete a[b])}function adjustBlendPosition(){for(var a=src_ctx.getImageData(0,0,base_size.width,base_size.height),b=mask_ctx.getImageData(0,0,base_size.width,base_size.height),c=result_ctx.getImageData(0,0,base_size.width,base_size.height),d=1;d<base_size.height-1;d++)for(var e=1;e<base_size.width-1;e++){var f=4*(d*base_size.width+e);if(0==b.data[f+0]&&255==b.data[f+1]&&0==b.data[f+2]&&255==b.data[f+3])for(var g=f+4*(blend_position_offset.y*base_size.width+blend_position_offset.x),h=0;3>h;h++)c.data[g+h]=a.data[f+h]}result_ctx.putImageData(c,0,0)}function poissonBlendImages(a,b,c,d){var e=a.getContext("2d");src_ctx=b.getContext("2d"),mask_ctx=c.getContext("2d"),result_ctx=d.getContext("2d"),base_size.width=b.width,base_size.height=b.height,adjustBlendPosition();for(var f,g,h=e.getImageData(0,0,b.width,b.height),i=src_ctx.getImageData(0,0,b.width,b.height),j=mask_ctx.getImageData(0,0,b.width,b.height),k=result_ctx.getImageData(0,0,b.width,b.height),l=!1,m=1,n=0;;){f=0,g=0;for(var o=1;o<base_size.height-1;o++)for(var p=1;p<base_size.width-1;p++){var q=4*(o*base_size.width+p);if(0==j.data[q+0]&&255==j.data[q+1]&&0==j.data[q+2]&&255==j.data[q+3])for(var r=q+4*(blend_position_offset.y*base_size.width+blend_position_offset.x),s=[4*((o-1)*base_size.width+p),4*((o+1)*base_size.width+p),4*(o*base_size.width+(p-1)),4*(o*base_size.width+(p+1))],t=s.length,u=0;3>u;u++){for(var v=0,w=0,x=0,y=0;t>y;y++){var z=s[y]+4*(blend_position_offset.y*base_size.width+blend_position_offset.x);0==j.data[s[y]+0]&&255==j.data[s[y]+1]&&0==j.data[s[y]+2]&&255==j.data[s[y]+3]?v+=k.data[z+u]:x+=h.data[z+u],w+=l&&Math.abs(h.data[r+u]-h.data[z+u])>Math.abs(i.data[q+u]-i.data[s[y]+u])?h.data[r+u]-h.data[z+u]:i.data[q+u]-i.data[s[y]+u]}var A=(v+w+x)/t;f+=Math.abs(A-k.data[r+u]),g+=Math.abs(A),k.data[r+u]=A}}n++;var B=f/g;if(!B||m-B===0)break;m=B}result_ctx.putImageData(k,0,0);var C=document.getElementById("instructbtn");return C.scrollIntoView(!0),d}!function(a,b){function c(a){var b=a.length,c=ib.type(a);return ib.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||"function"!==c&&(0===b||"number"==typeof b&&b>0&&b-1 in a)}function d(a){var b=xb[a]={};return ib.each(a.match(kb)||[],function(a,c){b[c]=!0}),b}function e(a,c,d,e){if(ib.acceptData(a)){var f,g,h=ib.expando,i="string"==typeof c,j=a.nodeType,k=j?ib.cache:a,l=j?a[h]:a[h]&&h;if(l&&k[l]&&(e||k[l].data)||!i||d!==b)return l||(j?a[h]=l=_.pop()||ib.guid++:l=h),k[l]||(k[l]={},j||(k[l].toJSON=ib.noop)),("object"==typeof c||"function"==typeof c)&&(e?k[l]=ib.extend(k[l],c):k[l].data=ib.extend(k[l].data,c)),f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[ib.camelCase(c)]=d),i?(g=f[c],null==g&&(g=f[ib.camelCase(c)])):g=f,g}}function f(a,b,c){if(ib.acceptData(a)){var d,e,f,g=a.nodeType,i=g?ib.cache:a,j=g?a[ib.expando]:ib.expando;if(i[j]){if(b&&(f=c?i[j]:i[j].data)){ib.isArray(b)?b=b.concat(ib.map(b,ib.camelCase)):b in f?b=[b]:(b=ib.camelCase(b),b=b in f?[b]:b.split(" "));for(d=0,e=b.length;e>d;d++)delete f[b[d]];if(!(c?h:ib.isEmptyObject)(f))return}(c||(delete i[j].data,h(i[j])))&&(g?ib.cleanData([a],!0):ib.support.deleteExpando||i!=i.window?delete i[j]:i[j]=null)}}}function g(a,c,d){if(d===b&&1===a.nodeType){var e="data-"+c.replace(zb,"-$1").toLowerCase();if(d=a.getAttribute(e),"string"==typeof d){try{d="true"===d?!0:"false"===d?!1:"null"===d?null:+d+""===d?+d:yb.test(d)?ib.parseJSON(d):d}catch(f){}ib.data(a,c,d)}else d=b}return d}function h(a){var b;for(b in a)if(("data"!==b||!ib.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function i(){return!0}function j(){return!1}function k(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}function l(a,b,c){if(b=b||0,ib.isFunction(b))return ib.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return ib.grep(a,function(a){return a===b===c});if("string"==typeof b){var d=ib.grep(a,function(a){return 1===a.nodeType});if(Rb.test(b))return ib.filter(b,d,!c);b=ib.filter(b,d)}return ib.grep(a,function(a){return ib.inArray(a,b)>=0===c})}function m(a){var b=Ub.split("|"),c=a.createDocumentFragment();if(c.createElement)for(;b.length;)c.createElement(b.pop());return c}function n(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function o(a){var b=a.getAttributeNode("type");return a.type=(b&&b.specified)+"/"+a.type,a}function p(a){var b=ec.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function q(a,b){for(var c,d=0;null!=(c=a[d]);d++)ib._data(c,"globalEval",!b||ib._data(b[d],"globalEval"))}function r(a,b){if(1===b.nodeType&&ib.hasData(a)){var c,d,e,f=ib._data(a),g=ib._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)ib.event.add(b,c,h[c][d])}g.data&&(g.data=ib.extend({},g.data))}}function s(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!ib.support.noCloneEvent&&b[ib.expando]){e=ib._data(b);for(d in e.events)ib.removeEvent(b,d,e.handle);b.removeAttribute(ib.expando)}"script"===c&&b.text!==a.text?(o(b).text=a.text,p(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),ib.support.html5Clone&&a.innerHTML&&!ib.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&bc.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}function t(a,c){var d,e,f=0,g=typeof a.getElementsByTagName!==V?a.getElementsByTagName(c||"*"):typeof a.querySelectorAll!==V?a.querySelectorAll(c||"*"):b;if(!g)for(g=[],d=a.childNodes||a;null!=(e=d[f]);f++)!c||ib.nodeName(e,c)?g.push(e):ib.merge(g,t(e,c));return c===b||c&&ib.nodeName(a,c)?ib.merge([a],g):g}function u(a){bc.test(a.type)&&(a.defaultChecked=a.checked)}function v(a,b){if(b in a)return b;for(var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=yc.length;e--;)if(b=yc[e]+c,b in a)return b;return d}function w(a,b){return a=b||a,"none"===ib.css(a,"display")||!ib.contains(a.ownerDocument,a)}function x(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=ib._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&w(d)&&(f[g]=ib._data(d,"olddisplay",B(d.nodeName)))):f[g]||(e=w(d),(c&&"none"!==c||!e)&&ib._data(d,"olddisplay",e?c:ib.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function y(a,b,c){var d=rc.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function z(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=ib.css(a,c+xc[f],!0,e)),d?("content"===c&&(g-=ib.css(a,"padding"+xc[f],!0,e)),"margin"!==c&&(g-=ib.css(a,"border"+xc[f]+"Width",!0,e))):(g+=ib.css(a,"padding"+xc[f],!0,e),"padding"!==c&&(g+=ib.css(a,"border"+xc[f]+"Width",!0,e)));return g}function A(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=kc(a),g=ib.support.boxSizing&&"border-box"===ib.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=lc(a,b,f),(0>e||null==e)&&(e=a.style[b]),sc.test(e))return e;d=g&&(ib.support.boxSizingReliable||e===a.style[b]),e=parseFloat(e)||0}return e+z(a,b,c||(g?"border":"content"),d,f)+"px"}function B(a){var b=W,c=uc[a];return c||(c=C(a,b),"none"!==c&&c||(jc=(jc||ib("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(b.documentElement),b=(jc[0].contentWindow||jc[0].contentDocument).document,b.write("<!doctype html><html><body>"),b.close(),c=C(a,b),jc.detach()),uc[a]=c),c}function C(a,b){var c=ib(b.createElement(a)).appendTo(b.body),d=ib.css(c[0],"display");return c.remove(),d}function D(a,b,c,d){var e;if(ib.isArray(b))ib.each(b,function(b,e){c||Ac.test(a)?d(a,e):D(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==ib.type(b))d(a,b);else for(e in b)D(a+"["+e+"]",b[e],c,d)}function E(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(kb)||[];if(ib.isFunction(c))for(;d=f[e++];)"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function F(a,c,d,e){function f(i){var j;return g[i]=!0,ib.each(a[i]||[],function(a,i){var k=i(c,d,e);return"string"!=typeof k||h||g[k]?h?!(j=k):b:(c.dataTypes.unshift(k),f(k),!1)}),j}var g={},h=a===Rc;return f(c.dataTypes[0])||!g["*"]&&f("*")}function G(a,c){var d,e,f=ib.ajaxSettings.flatOptions||{};for(e in c)c[e]!==b&&((f[e]?a:d||(d={}))[e]=c[e]);return d&&ib.extend(!0,a,d),a}function H(a,c,d){var e,f,g,h,i=a.contents,j=a.dataTypes,k=a.responseFields;for(h in k)h in d&&(c[k[h]]=d[h]);for(;"*"===j[0];)j.shift(),f===b&&(f=a.mimeType||c.getResponseHeader("Content-Type"));if(f)for(h in i)if(i[h]&&i[h].test(f)){j.unshift(h);break}if(j[0]in d)g=j[0];else{for(h in d){if(!j[0]||a.converters[h+" "+j[0]]){g=h;break}e||(e=h)}g=g||e}return g?(g!==j[0]&&j.unshift(g),d[g]):b}function I(a,b){var c,d,e,f,g={},h=0,i=a.dataTypes.slice(),j=i[0];if(a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i[1])for(e in a.converters)g[e.toLowerCase()]=a.converters[e];for(;d=i[++h];)if("*"!==d){if("*"!==j&&j!==d){if(e=g[j+" "+d]||g["* "+d],!e)for(c in g)if(f=c.split(" "),f[1]===d&&(e=g[j+" "+f[0]]||g["* "+f[0]])){e===!0?e=g[c]:g[c]!==!0&&(d=f[0],i.splice(h--,0,d));break}if(e!==!0)if(e&&a["throws"])b=e(b);else try{b=e(b)}catch(k){return{state:"parsererror",error:e?k:"No conversion from "+j+" to "+d}}}j=d}return{state:"success",data:b}}function J(){try{return new a.XMLHttpRequest}catch(b){}}function K(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function L(){return setTimeout(function(){$c=b}),$c=ib.now()}function M(a,b){ib.each(b,function(b,c){for(var d=(ed[b]||[]).concat(ed["*"]),e=0,f=d.length;f>e;e++)if(d[e].call(a,b,c))return})}function N(a,b,c){var d,e,f=0,g=dd.length,h=ib.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$c||L(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:ib.extend({},b),opts:ib.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$c||L(),duration:c.duration,tweens:[],createTween:function(b,c){var d=ib.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(O(k,j.opts.specialEasing);g>f;f++)if(d=dd[f].call(j,a,k,j.opts))return d;return M(j,k),ib.isFunction(j.opts.start)&&j.opts.start.call(a,j),ib.fx.timer(ib.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}function O(a,b){var c,d,e,f,g;for(e in a)if(d=ib.camelCase(e),f=b[d],c=a[e],ib.isArray(c)&&(f=c[1],c=a[e]=c[0]),e!==d&&(a[d]=c,delete a[e]),g=ib.cssHooks[d],g&&"expand"in g){c=g.expand(c),delete a[d];for(e in c)e in a||(a[e]=c[e],b[e]=f)}else b[d]=f}function P(a,b,c){var d,e,f,g,h,i,j,k,l,m=this,n=a.style,o={},p=[],q=a.nodeType&&w(a);c.queue||(k=ib._queueHooks(a,"fx"),null==k.unqueued&&(k.unqueued=0,l=k.empty.fire,k.empty.fire=function(){k.unqueued||l()}),k.unqueued++,m.always(function(){m.always(function(){k.unqueued--,ib.queue(a,"fx").length||k.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[n.overflow,n.overflowX,n.overflowY],"inline"===ib.css(a,"display")&&"none"===ib.css(a,"float")&&(ib.support.inlineBlockNeedsLayout&&"inline"!==B(a.nodeName)?n.zoom=1:n.display="inline-block")),c.overflow&&(n.overflow="hidden",ib.support.shrinkWrapBlocks||m.always(function(){n.overflow=c.overflow[0],n.overflowX=c.overflow[1],n.overflowY=c.overflow[2]}));for(e in b)if(g=b[e],ad.exec(g)){if(delete b[e],i=i||"toggle"===g,g===(q?"hide":"show"))continue;p.push(e)}if(f=p.length){h=ib._data(a,"fxshow")||ib._data(a,"fxshow",{}),"hidden"in h&&(q=h.hidden),i&&(h.hidden=!q),q?ib(a).show():m.done(function(){ib(a).hide()}),m.done(function(){var b;ib._removeData(a,"fxshow");for(b in o)ib.style(a,b,o[b])});for(e=0;f>e;e++)d=p[e],j=m.createTween(d,q?h[d]:0),o[d]=h[d]||ib.style(a,d),d in h||(h[d]=j.start,q&&(j.end=j.start,j.start="width"===d||"height"===d?1:0))}}function Q(a,b,c,d,e){return new Q.prototype.init(a,b,c,d,e)}function R(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=xc[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function S(a){return ib.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}var T,U,V=typeof b,W=a.document,X=a.location,Y=a.jQuery,Z=a.$,$={},_=[],ab="1.9.1",bb=_.concat,cb=_.push,db=_.slice,eb=_.indexOf,fb=$.toString,gb=$.hasOwnProperty,hb=ab.trim,ib=function(a,b){return new ib.fn.init(a,b,U)},jb=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,kb=/\S+/g,lb=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,mb=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,nb=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,ob=/^[\],:{}\s]*$/,pb=/(?:^|:|,)(?:\s*\[)+/g,qb=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,rb=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,sb=/^-ms-/,tb=/-([\da-z])/gi,ub=function(a,b){return b.toUpperCase()},vb=function(a){(W.addEventListener||"load"===a.type||"complete"===W.readyState)&&(wb(),ib.ready())},wb=function(){W.addEventListener?(W.removeEventListener("DOMContentLoaded",vb,!1),a.removeEventListener("load",vb,!1)):(W.detachEvent("onreadystatechange",vb),a.detachEvent("onload",vb))};ib.fn=ib.prototype={jquery:ab,constructor:ib,init:function(a,c,d){var e,f;if(!a)return this;if("string"==typeof a){if(e="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:mb.exec(a),!e||!e[1]&&c)return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a);if(e[1]){if(c=c instanceof ib?c[0]:c,ib.merge(this,ib.parseHTML(e[1],c&&c.nodeType?c.ownerDocument||c:W,!0)),nb.test(e[1])&&ib.isPlainObject(c))for(e in c)ib.isFunction(this[e])?this[e](c[e]):this.attr(e,c[e]);return this}if(f=W.getElementById(e[2]),f&&f.parentNode){if(f.id!==e[2])return d.find(a);this.length=1,this[0]=f}return this.context=W,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):ib.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),ib.makeArray(a,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return db.call(this)},get:function(a){return null==a?this.toArray():0>a?this[this.length+a]:this[a]},pushStack:function(a){var b=ib.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return ib.each(this,a,b)},ready:function(a){return ib.ready.promise().done(a),this},slice:function(){return this.pushStack(db.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},map:function(a){return this.pushStack(ib.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:cb,sort:[].sort,splice:[].splice},ib.fn.init.prototype=ib.fn,ib.extend=ib.fn.extend=function(){var a,c,d,e,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;for("boolean"==typeof h&&(k=h,h=arguments[1]||{},i=2),"object"==typeof h||ib.isFunction(h)||(h={}),j===i&&(h=this,--i);j>i;i++)if(null!=(f=arguments[i]))for(e in f)a=h[e],d=f[e],h!==d&&(k&&d&&(ib.isPlainObject(d)||(c=ib.isArray(d)))?(c?(c=!1,g=a&&ib.isArray(a)?a:[]):g=a&&ib.isPlainObject(a)?a:{},h[e]=ib.extend(k,g,d)):d!==b&&(h[e]=d));return h},ib.extend({noConflict:function(b){return a.$===ib&&(a.$=Z),b&&a.jQuery===ib&&(a.jQuery=Y),ib},isReady:!1,readyWait:1,holdReady:function(a){a?ib.readyWait++:ib.ready(!0)},ready:function(a){if(a===!0?!--ib.readyWait:!ib.isReady){if(!W.body)return setTimeout(ib.ready);ib.isReady=!0,a!==!0&&--ib.readyWait>0||(T.resolveWith(W,[ib]),ib.fn.trigger&&ib(W).trigger("ready").off("ready"))}},isFunction:function(a){return"function"===ib.type(a)},isArray:Array.isArray||function(a){return"array"===ib.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?$[fb.call(a)]||"object":typeof a},isPlainObject:function(a){if(!a||"object"!==ib.type(a)||a.nodeType||ib.isWindow(a))return!1;try{if(a.constructor&&!gb.call(a,"constructor")&&!gb.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||gb.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw Error(a)},parseHTML:function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||W;var d=nb.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=ib.buildFragment([a],b,e),e&&ib(e).remove(),ib.merge([],d.childNodes))},parseJSON:function(c){return a.JSON&&a.JSON.parse?a.JSON.parse(c):null===c?c:"string"==typeof c&&(c=ib.trim(c),c&&ob.test(c.replace(qb,"@").replace(rb,"]").replace(pb,"")))?Function("return "+c)():(ib.error("Invalid JSON: "+c),b)},parseXML:function(c){var d,e;if(!c||"string"!=typeof c)return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return d&&d.documentElement&&!d.getElementsByTagName("parsererror").length||ib.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&ib.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(sb,"ms-").replace(tb,ub)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,d){var e,f=0,g=a.length,h=c(a);if(d){if(h)for(;g>f&&(e=b.apply(a[f],d),e!==!1);f++);else for(f in a)if(e=b.apply(a[f],d),e===!1)break}else if(h)for(;g>f&&(e=b.call(a[f],f,a[f]),e!==!1);f++);else for(f in a)if(e=b.call(a[f],f,a[f]),e===!1)break;return a},trim:hb&&!hb.call("﻿ ")?function(a){return null==a?"":hb.call(a)}:function(a){return null==a?"":(a+"").replace(lb,"")},makeArray:function(a,b){var d=b||[];return null!=a&&(c(Object(a))?ib.merge(d,"string"==typeof a?[a]:a):cb.call(d,a)),d},inArray:function(a,b,c){var d;if(b){if(eb)return eb.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=c.length,e=a.length,f=0;if("number"==typeof d)for(;d>f;f++)a[e++]=c[f];else for(;c[f]!==b;)a[e++]=c[f++];return a.length=e,a},grep:function(a,b,c){var d,e=[],f=0,g=a.length;for(c=!!c;g>f;f++)d=!!b(a[f],f),c!==d&&e.push(a[f]);return e},map:function(a,b,d){var e,f=0,g=a.length,h=c(a),i=[];if(h)for(;g>f;f++)e=b(a[f],f,d),null!=e&&(i[i.length]=e);else for(f in a)e=b(a[f],f,d),null!=e&&(i[i.length]=e);return bb.apply([],i)},guid:1,proxy:function(a,c){var d,e,f;return"string"==typeof c&&(f=a[c],c=a,a=f),ib.isFunction(a)?(d=db.call(arguments,2),e=function(){return a.apply(c||this,d.concat(db.call(arguments)))},e.guid=a.guid=a.guid||ib.guid++,e):b},access:function(a,c,d,e,f,g,h){var i=0,j=a.length,k=null==d;if("object"===ib.type(d)){f=!0;for(i in d)ib.access(a,c,i,d[i],!0,g,h)}else if(e!==b&&(f=!0,ib.isFunction(e)||(h=!0),k&&(h?(c.call(a,e),c=null):(k=c,c=function(a,b,c){return k.call(ib(a),c)})),c))for(;j>i;i++)c(a[i],d,h?e:e.call(a[i],i,c(a[i],d)));return f?a:k?c.call(a):j?c(a[0],d):g},now:function(){return(new Date).getTime()}}),ib.ready.promise=function(b){if(!T)if(T=ib.Deferred(),"complete"===W.readyState)setTimeout(ib.ready);else if(W.addEventListener)W.addEventListener("DOMContentLoaded",vb,!1),a.addEventListener("load",vb,!1);else{W.attachEvent("onreadystatechange",vb),a.attachEvent("onload",vb);var c=!1;try{c=null==a.frameElement&&W.documentElement}catch(d){}c&&c.doScroll&&function e(){if(!ib.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}wb(),ib.ready()}}()}return T.promise(b)},ib.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){$["[object "+b+"]"]=b.toLowerCase()}),U=ib(W);var xb={};ib.Callbacks=function(a){a="string"==typeof a?xb[a]||d(a):ib.extend({},a);var c,e,f,g,h,i,j=[],k=!a.once&&[],l=function(b){for(e=a.memory&&b,f=!0,h=i||0,i=0,g=j.length,c=!0;j&&g>h;h++)if(j[h].apply(b[0],b[1])===!1&&a.stopOnFalse){e=!1;break}c=!1,j&&(k?k.length&&l(k.shift()):e?j=[]:m.disable())},m={add:function(){if(j){var b=j.length;!function d(b){ib.each(b,function(b,c){var e=ib.type(c);"function"===e?a.unique&&m.has(c)||j.push(c):c&&c.length&&"string"!==e&&d(c)})}(arguments),c?g=j.length:e&&(i=b,l(e))}return this},remove:function(){return j&&ib.each(arguments,function(a,b){for(var d;(d=ib.inArray(b,j,d))>-1;)j.splice(d,1),c&&(g>=d&&g--,h>=d&&h--)}),this},has:function(a){return a?ib.inArray(a,j)>-1:!(!j||!j.length)},empty:function(){return j=[],this},disable:function(){return j=k=e=b,this},disabled:function(){return!j},lock:function(){return k=b,e||m.disable(),this},locked:function(){return!k},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],!j||f&&!k||(c?k.push(b):l(b)),this},fire:function(){return m.fireWith(this,arguments),this},fired:function(){return!!f}};return m},ib.extend({Deferred:function(a){var b=[["resolve","done",ib.Callbacks("once memory"),"resolved"],["reject","fail",ib.Callbacks("once memory"),"rejected"],["notify","progress",ib.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return ib.Deferred(function(c){ib.each(b,function(b,f){var g=f[0],h=ib.isFunction(a[b])&&a[b];e[f[1]](function(){var a=h&&h.apply(this,arguments);a&&ib.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[g+"With"](this===d?c.promise():this,h?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?ib.extend(a,d):d}},e={};return d.pipe=d.then,ib.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b,c,d,e=0,f=db.call(arguments),g=f.length,h=1!==g||a&&ib.isFunction(a.promise)?g:0,i=1===h?a:ib.Deferred(),j=function(a,c,d){return function(e){c[a]=this,d[a]=arguments.length>1?db.call(arguments):e,d===b?i.notifyWith(c,d):--h||i.resolveWith(c,d)}};if(g>1)for(b=Array(g),c=Array(g),d=Array(g);g>e;e++)f[e]&&ib.isFunction(f[e].promise)?f[e].promise().done(j(e,d,f)).fail(i.reject).progress(j(e,c,b)):--h;return h||i.resolveWith(d,f),i.promise()}}),ib.support=function(){var b,c,d,e,f,g,h,i,j,k,l=W.createElement("div");if(l.setAttribute("className","t"),l.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",c=l.getElementsByTagName("*"),d=l.getElementsByTagName("a")[0],!c||!d||!c.length)return{};f=W.createElement("select"),h=f.appendChild(W.createElement("option")),e=l.getElementsByTagName("input")[0],d.style.cssText="top:1px;float:left;opacity:.5",b={getSetAttribute:"t"!==l.className,leadingWhitespace:3===l.firstChild.nodeType,tbody:!l.getElementsByTagName("tbody").length,htmlSerialize:!!l.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:"/a"===d.getAttribute("href"),opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:!!e.value,optSelected:h.selected,enctype:!!W.createElement("form").enctype,html5Clone:"<:nav></:nav>"!==W.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===W.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},e.checked=!0,b.noCloneChecked=e.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!h.disabled;
try{delete l.test}catch(m){b.deleteExpando=!1}e=W.createElement("input"),e.setAttribute("value",""),b.input=""===e.getAttribute("value"),e.value="t",e.setAttribute("type","radio"),b.radioValue="t"===e.value,e.setAttribute("checked","t"),e.setAttribute("name","t"),g=W.createDocumentFragment(),g.appendChild(e),b.appendChecked=e.checked,b.checkClone=g.cloneNode(!0).cloneNode(!0).lastChild.checked,l.attachEvent&&(l.attachEvent("onclick",function(){b.noCloneEvent=!1}),l.cloneNode(!0).click());for(k in{submit:!0,change:!0,focusin:!0})l.setAttribute(i="on"+k,"t"),b[k+"Bubbles"]=i in a||l.attributes[i].expando===!1;return l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",b.clearCloneStyle="content-box"===l.style.backgroundClip,ib(function(){var c,d,e,f="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",g=W.getElementsByTagName("body")[0];g&&(c=W.createElement("div"),c.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",g.appendChild(c).appendChild(l),l.innerHTML="<table><tr><td></td><td>t</td></tr></table>",e=l.getElementsByTagName("td"),e[0].style.cssText="padding:0;margin:0;border:0;display:none",j=0===e[0].offsetHeight,e[0].style.display="",e[1].style.display="none",b.reliableHiddenOffsets=j&&0===e[0].offsetHeight,l.innerHTML="",l.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=4===l.offsetWidth,b.doesNotIncludeMarginInBodyOffset=1!==g.offsetTop,a.getComputedStyle&&(b.pixelPosition="1%"!==(a.getComputedStyle(l,null)||{}).top,b.boxSizingReliable="4px"===(a.getComputedStyle(l,null)||{width:"4px"}).width,d=l.appendChild(W.createElement("div")),d.style.cssText=l.style.cssText=f,d.style.marginRight=d.style.width="0",l.style.width="1px",b.reliableMarginRight=!parseFloat((a.getComputedStyle(d,null)||{}).marginRight)),typeof l.style.zoom!==V&&(l.innerHTML="",l.style.cssText=f+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=3===l.offsetWidth,l.style.display="block",l.innerHTML="<div></div>",l.firstChild.style.width="5px",b.shrinkWrapBlocks=3!==l.offsetWidth,b.inlineBlockNeedsLayout&&(g.style.zoom=1)),g.removeChild(c),c=l=e=d=null)}),c=f=g=h=d=e=null,b}();var yb=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,zb=/([A-Z])/g;ib.extend({cache:{},expando:"jQuery"+(ab+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?ib.cache[a[ib.expando]]:a[ib.expando],!!a&&!h(a)},data:function(a,b,c){return e(a,b,c)},removeData:function(a,b){return f(a,b)},_data:function(a,b,c){return e(a,b,c,!0)},_removeData:function(a,b){return f(a,b,!0)},acceptData:function(a){if(a.nodeType&&1!==a.nodeType&&9!==a.nodeType)return!1;var b=a.nodeName&&ib.noData[a.nodeName.toLowerCase()];return!b||b!==!0&&a.getAttribute("classid")===b}}),ib.fn.extend({data:function(a,c){var d,e,f=this[0],h=0,i=null;if(a===b){if(this.length&&(i=ib.data(f),1===f.nodeType&&!ib._data(f,"parsedAttrs"))){for(d=f.attributes;d.length>h;h++)e=d[h].name,e.indexOf("data-")||(e=ib.camelCase(e.slice(5)),g(f,e,i[e]));ib._data(f,"parsedAttrs",!0)}return i}return"object"==typeof a?this.each(function(){ib.data(this,a)}):ib.access(this,function(c){return c===b?f?g(f,a,ib.data(f,a)):null:(this.each(function(){ib.data(this,a,c)}),b)},null,c,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){ib.removeData(this,a)})}}),ib.extend({queue:function(a,c,d){var e;return a?(c=(c||"fx")+"queue",e=ib._data(a,c),d&&(!e||ib.isArray(d)?e=ib._data(a,c,ib.makeArray(d)):e.push(d)),e||[]):b},dequeue:function(a,b){b=b||"fx";var c=ib.queue(a,b),d=c.length,e=c.shift(),f=ib._queueHooks(a,b),g=function(){ib.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),f.cur=e,e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return ib._data(a,c)||ib._data(a,c,{empty:ib.Callbacks("once memory").add(function(){ib._removeData(a,b+"queue"),ib._removeData(a,c)})})}}),ib.fn.extend({queue:function(a,c){var d=2;return"string"!=typeof a&&(c=a,a="fx",d--),d>arguments.length?ib.queue(this[0],a):c===b?this:this.each(function(){var b=ib.queue(this,a,c);ib._queueHooks(this,a),"fx"===a&&"inprogress"!==b[0]&&ib.dequeue(this,a)})},dequeue:function(a){return this.each(function(){ib.dequeue(this,a)})},delay:function(a,b){return a=ib.fx?ib.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){var d,e=1,f=ib.Deferred(),g=this,h=this.length,i=function(){--e||f.resolveWith(g,[g])};for("string"!=typeof a&&(c=a,a=b),a=a||"fx";h--;)d=ib._data(g[h],a+"queueHooks"),d&&d.empty&&(e++,d.empty.add(i));return i(),f.promise(c)}});var Ab,Bb,Cb=/[\t\r\n]/g,Db=/\r/g,Eb=/^(?:input|select|textarea|button|object)$/i,Fb=/^(?:a|area)$/i,Gb=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,Hb=/^(?:checked|selected)$/i,Ib=ib.support.getSetAttribute,Jb=ib.support.input;ib.fn.extend({attr:function(a,b){return ib.access(this,ib.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){ib.removeAttr(this,a)})},prop:function(a,b){return ib.access(this,ib.prop,a,b,arguments.length>1)},removeProp:function(a){return a=ib.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g=0,h=this.length,i="string"==typeof a&&a;if(ib.isFunction(a))return this.each(function(b){ib(this).addClass(a.call(this,b,this.className))});if(i)for(b=(a||"").match(kb)||[];h>g;g++)if(c=this[g],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(Cb," "):" ")){for(f=0;e=b[f++];)0>d.indexOf(" "+e+" ")&&(d+=e+" ");c.className=ib.trim(d)}return this},removeClass:function(a){var b,c,d,e,f,g=0,h=this.length,i=0===arguments.length||"string"==typeof a&&a;if(ib.isFunction(a))return this.each(function(b){ib(this).removeClass(a.call(this,b,this.className))});if(i)for(b=(a||"").match(kb)||[];h>g;g++)if(c=this[g],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(Cb," "):"")){for(f=0;e=b[f++];)for(;d.indexOf(" "+e+" ")>=0;)d=d.replace(" "+e+" "," ");c.className=a?ib.trim(d):""}return this},toggleClass:function(a,b){var c=typeof a,d="boolean"==typeof b;return this.each(ib.isFunction(a)?function(c){ib(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c)for(var e,f=0,g=ib(this),h=b,i=a.match(kb)||[];e=i[f++];)h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e);else(c===V||"boolean"===c)&&(this.className&&ib._data(this,"__className__",this.className),this.className=this.className||a===!1?"":ib._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(Cb," ").indexOf(b)>=0)return!0;return!1},val:function(a){var c,d,e,f=this[0];return arguments.length?(e=ib.isFunction(a),this.each(function(c){var f,g=ib(this);1===this.nodeType&&(f=e?a.call(this,c,g.val()):a,null==f?f="":"number"==typeof f?f+="":ib.isArray(f)&&(f=ib.map(f,function(a){return null==a?"":a+""})),d=ib.valHooks[this.type]||ib.valHooks[this.nodeName.toLowerCase()],d&&"set"in d&&d.set(this,f,"value")!==b||(this.value=f))})):f?(d=ib.valHooks[f.type]||ib.valHooks[f.nodeName.toLowerCase()],d&&"get"in d&&(c=d.get(f,"value"))!==b?c:(c=f.value,"string"==typeof c?c.replace(Db,""):null==c?"":c)):void 0}}),ib.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(ib.support.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&ib.nodeName(c.parentNode,"optgroup"))){if(b=ib(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c=ib.makeArray(b);return ib(a).find("option").each(function(){this.selected=ib.inArray(ib(this).val(),c)>=0}),c.length||(a.selectedIndex=-1),c}}},attr:function(a,c,d){var e,f,g,h=a.nodeType;return a&&3!==h&&8!==h&&2!==h?typeof a.getAttribute===V?ib.prop(a,c,d):(f=1!==h||!ib.isXMLDoc(a),f&&(c=c.toLowerCase(),e=ib.attrHooks[c]||(Gb.test(c)?Bb:Ab)),d===b?e&&f&&"get"in e&&null!==(g=e.get(a,c))?g:(typeof a.getAttribute!==V&&(g=a.getAttribute(c)),null==g?b:g):null!==d?e&&f&&"set"in e&&(g=e.set(a,d,c))!==b?g:(a.setAttribute(c,d+""),d):(ib.removeAttr(a,c),b)):void 0},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(kb);if(f&&1===a.nodeType)for(;c=f[e++];)d=ib.propFix[c]||c,Gb.test(c)?!Ib&&Hb.test(c)?a[ib.camelCase("default-"+c)]=a[d]=!1:a[d]=!1:ib.attr(a,c,""),a.removeAttribute(Ib?c:d)},attrHooks:{type:{set:function(a,b){if(!ib.support.radioValue&&"radio"===b&&ib.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,f,g,h=a.nodeType;return a&&3!==h&&8!==h&&2!==h?(g=1!==h||!ib.isXMLDoc(a),g&&(c=ib.propFix[c]||c,f=ib.propHooks[c]),d!==b?f&&"set"in f&&(e=f.set(a,d,c))!==b?e:a[c]=d:f&&"get"in f&&null!==(e=f.get(a,c))?e:a[c]):void 0},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):Eb.test(a.nodeName)||Fb.test(a.nodeName)&&a.href?0:b}}}}),Bb={get:function(a,c){var d=ib.prop(a,c),e="boolean"==typeof d&&a.getAttribute(c),f="boolean"==typeof d?Jb&&Ib?null!=e:Hb.test(c)?a[ib.camelCase("default-"+c)]:!!e:a.getAttributeNode(c);return f&&f.value!==!1?c.toLowerCase():b},set:function(a,b,c){return b===!1?ib.removeAttr(a,c):Jb&&Ib||!Hb.test(c)?a.setAttribute(!Ib&&ib.propFix[c]||c,c):a[ib.camelCase("default-"+c)]=a[c]=!0,c}},Jb&&Ib||(ib.attrHooks.value={get:function(a,c){var d=a.getAttributeNode(c);return ib.nodeName(a,"input")?a.defaultValue:d&&d.specified?d.value:b},set:function(a,c,d){return ib.nodeName(a,"input")?(a.defaultValue=c,b):Ab&&Ab.set(a,c,d)}}),Ib||(Ab=ib.valHooks.button={get:function(a,c){var d=a.getAttributeNode(c);return d&&("id"===c||"name"===c||"coords"===c?""!==d.value:d.specified)?d.value:b},set:function(a,c,d){var e=a.getAttributeNode(d);return e||a.setAttributeNode(e=a.ownerDocument.createAttribute(d)),e.value=c+="","value"===d||c===a.getAttribute(d)?c:b}},ib.attrHooks.contenteditable={get:Ab.get,set:function(a,b,c){Ab.set(a,""===b?!1:b,c)}},ib.each(["width","height"],function(a,c){ib.attrHooks[c]=ib.extend(ib.attrHooks[c],{set:function(a,d){return""===d?(a.setAttribute(c,"auto"),d):b}})})),ib.support.hrefNormalized||(ib.each(["href","src","width","height"],function(a,c){ib.attrHooks[c]=ib.extend(ib.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return null==d?b:d}})}),ib.each(["href","src"],function(a,b){ib.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}})),ib.support.style||(ib.attrHooks.style={get:function(a){return a.style.cssText||b},set:function(a,b){return a.style.cssText=b+""}}),ib.support.optSelected||(ib.propHooks.selected=ib.extend(ib.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),ib.support.enctype||(ib.propFix.enctype="encoding"),ib.support.checkOn||ib.each(["radio","checkbox"],function(){ib.valHooks[this]={get:function(a){return null===a.getAttribute("value")?"on":a.value}}}),ib.each(["radio","checkbox"],function(){ib.valHooks[this]=ib.extend(ib.valHooks[this],{set:function(a,c){return ib.isArray(c)?a.checked=ib.inArray(ib(a).val(),c)>=0:b}})});var Kb=/^(?:input|select|textarea)$/i,Lb=/^key/,Mb=/^(?:mouse|contextmenu)|click/,Nb=/^(?:focusinfocus|focusoutblur)$/,Ob=/^([^.]*)(?:\.(.+)|)$/;ib.event={global:{},add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r=ib._data(a);if(r){for(d.handler&&(j=d,d=j.handler,f=j.selector),d.guid||(d.guid=ib.guid++),(h=r.events)||(h=r.events={}),(l=r.handle)||(l=r.handle=function(a){return typeof ib===V||a&&ib.event.triggered===a.type?b:ib.event.dispatch.apply(l.elem,arguments)},l.elem=a),c=(c||"").match(kb)||[""],i=c.length;i--;)g=Ob.exec(c[i])||[],o=q=g[1],p=(g[2]||"").split(".").sort(),k=ib.event.special[o]||{},o=(f?k.delegateType:k.bindType)||o,k=ib.event.special[o]||{},m=ib.extend({type:o,origType:q,data:e,handler:d,guid:d.guid,selector:f,needsContext:f&&ib.expr.match.needsContext.test(f),namespace:p.join(".")},j),(n=h[o])||(n=h[o]=[],n.delegateCount=0,k.setup&&k.setup.call(a,e,p,l)!==!1||(a.addEventListener?a.addEventListener(o,l,!1):a.attachEvent&&a.attachEvent("on"+o,l))),k.add&&(k.add.call(a,m),m.handler.guid||(m.handler.guid=d.guid)),f?n.splice(n.delegateCount++,0,m):n.push(m),ib.event.global[o]=!0;a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=ib.hasData(a)&&ib._data(a);if(q&&(k=q.events)){for(b=(b||"").match(kb)||[""],j=b.length;j--;)if(h=Ob.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){for(l=ib.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=k[n]||[],h=h[2]&&RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;f--;)g=m[f],!e&&p!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||ib.removeEvent(a,n,q.handle),delete k[n])}else for(n in k)ib.event.remove(a,n+b[j],c,d,!0);ib.isEmptyObject(k)&&(delete q.handle,ib._removeData(a,"events"))}},trigger:function(c,d,e,f){var g,h,i,j,k,l,m,n=[e||W],o=gb.call(c,"type")?c.type:c,p=gb.call(c,"namespace")?c.namespace.split("."):[];if(i=l=e=e||W,3!==e.nodeType&&8!==e.nodeType&&!Nb.test(o+ib.event.triggered)&&(o.indexOf(".")>=0&&(p=o.split("."),o=p.shift(),p.sort()),h=0>o.indexOf(":")&&"on"+o,c=c[ib.expando]?c:new ib.Event(o,"object"==typeof c&&c),c.isTrigger=!0,c.namespace=p.join("."),c.namespace_re=c.namespace?RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,c.result=b,c.target||(c.target=e),d=null==d?[c]:ib.makeArray(d,[c]),k=ib.event.special[o]||{},f||!k.trigger||k.trigger.apply(e,d)!==!1)){if(!f&&!k.noBubble&&!ib.isWindow(e)){for(j=k.delegateType||o,Nb.test(j+o)||(i=i.parentNode);i;i=i.parentNode)n.push(i),l=i;l===(e.ownerDocument||W)&&n.push(l.defaultView||l.parentWindow||a)}for(m=0;(i=n[m++])&&!c.isPropagationStopped();)c.type=m>1?j:k.bindType||o,g=(ib._data(i,"events")||{})[c.type]&&ib._data(i,"handle"),g&&g.apply(i,d),g=h&&i[h],g&&ib.acceptData(i)&&g.apply&&g.apply(i,d)===!1&&c.preventDefault();if(c.type=o,!(f||c.isDefaultPrevented()||k._default&&k._default.apply(e.ownerDocument,d)!==!1||"click"===o&&ib.nodeName(e,"a")||!ib.acceptData(e)||!h||!e[o]||ib.isWindow(e))){l=e[h],l&&(e[h]=null),ib.event.triggered=o;try{e[o]()}catch(q){}ib.event.triggered=b,l&&(e[h]=l)}return c.result}},dispatch:function(a){a=ib.event.fix(a);var c,d,e,f,g,h=[],i=db.call(arguments),j=(ib._data(this,"events")||{})[a.type]||[],k=ib.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){for(h=ib.event.handlers.call(this,a,j),c=0;(f=h[c++])&&!a.isPropagationStopped();)for(a.currentTarget=f.elem,g=0;(e=f.handlers[g++])&&!a.isImmediatePropagationStopped();)(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,d=((ib.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),d!==b&&(a.result=d)===!1&&(a.preventDefault(),a.stopPropagation()));return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,c){var d,e,f,g,h=[],i=c.delegateCount,j=a.target;if(i&&j.nodeType&&(!a.button||"click"!==a.type))for(;j!=this;j=j.parentNode||this)if(1===j.nodeType&&(j.disabled!==!0||"click"!==a.type)){for(f=[],g=0;i>g;g++)e=c[g],d=e.selector+" ",f[d]===b&&(f[d]=e.needsContext?ib(d,this).index(j)>=0:ib.find(d,this,null,[j]).length),f[d]&&f.push(e);f.length&&h.push({elem:j,handlers:f})}return c.length>i&&h.push({elem:this,handlers:c.slice(i)}),h},fix:function(a){if(a[ib.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];for(g||(this.fixHooks[e]=g=Mb.test(e)?this.mouseHooks:Lb.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new ib.Event(f),b=d.length;b--;)c=d[b],a[c]=f[c];return a.target||(a.target=f.srcElement||W),3===a.target.nodeType&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,g.filter?g.filter(a,f):a},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,c){var d,e,f,g=c.button,h=c.fromElement;return null==a.pageX&&null!=c.clientX&&(e=a.target.ownerDocument||W,f=e.documentElement,d=e.body,a.pageX=c.clientX+(f&&f.scrollLeft||d&&d.scrollLeft||0)-(f&&f.clientLeft||d&&d.clientLeft||0),a.pageY=c.clientY+(f&&f.scrollTop||d&&d.scrollTop||0)-(f&&f.clientTop||d&&d.clientTop||0)),!a.relatedTarget&&h&&(a.relatedTarget=h===a.target?c.toElement:h),a.which||g===b||(a.which=1&g?1:2&g?3:4&g?2:0),a}},special:{load:{noBubble:!0},click:{trigger:function(){return ib.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):b}},focus:{trigger:function(){if(this!==W.activeElement&&this.focus)try{return this.focus(),!1}catch(a){}},delegateType:"focusin"},blur:{trigger:function(){return this===W.activeElement&&this.blur?(this.blur(),!1):b},delegateType:"focusout"},beforeunload:{postDispatch:function(a){a.result!==b&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=ib.extend(new ib.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?ib.event.trigger(e,null,b):ib.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},ib.removeEvent=W.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]===V&&(a[d]=null),a.detachEvent(d,c))},ib.Event=function(a,c){return this instanceof ib.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?i:j):this.type=a,c&&ib.extend(this,c),this.timeStamp=a&&a.timeStamp||ib.now(),this[ib.expando]=!0,b):new ib.Event(a,c)},ib.Event.prototype={isDefaultPrevented:j,isPropagationStopped:j,isImmediatePropagationStopped:j,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=i,a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=i,a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=i,this.stopPropagation()}},ib.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){ib.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!ib.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),ib.support.submitBubbles||(ib.event.special.submit={setup:function(){return ib.nodeName(this,"form")?!1:(ib.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=ib.nodeName(c,"input")||ib.nodeName(c,"button")?c.form:b;d&&!ib._data(d,"submitBubbles")&&(ib.event.add(d,"submit._submit",function(a){a._submit_bubble=!0}),ib._data(d,"submitBubbles",!0))}),b)},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&ib.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){return ib.nodeName(this,"form")?!1:(ib.event.remove(this,"._submit"),b)}}),ib.support.changeBubbles||(ib.event.special.change={setup:function(){return Kb.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(ib.event.add(this,"propertychange._change",function(a){"checked"===a.originalEvent.propertyName&&(this._just_changed=!0)}),ib.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),ib.event.simulate("change",this,a,!0)})),!1):(ib.event.add(this,"beforeactivate._change",function(a){var b=a.target;Kb.test(b.nodeName)&&!ib._data(b,"changeBubbles")&&(ib.event.add(b,"change._change",function(a){!this.parentNode||a.isSimulated||a.isTrigger||ib.event.simulate("change",this.parentNode,a,!0)}),ib._data(b,"changeBubbles",!0))}),b)},handle:function(a){var c=a.target;return this!==c||a.isSimulated||a.isTrigger||"radio"!==c.type&&"checkbox"!==c.type?a.handleObj.handler.apply(this,arguments):b},teardown:function(){return ib.event.remove(this,"._change"),!Kb.test(this.nodeName)}}),ib.support.focusinBubbles||ib.each({focus:"focusin",blur:"focusout"},function(a,b){var c=0,d=function(a){ib.event.simulate(b,a.target,ib.event.fix(a),!0)};ib.event.special[b]={setup:function(){0===c++&&W.addEventListener(a,d,!0)},teardown:function(){0===--c&&W.removeEventListener(a,d,!0)}}}),ib.fn.extend({on:function(a,c,d,e,f){var g,h;if("object"==typeof a){"string"!=typeof c&&(d=d||c,c=b);for(g in a)this.on(g,c,d,a[g],f);return this}if(null==d&&null==e?(e=c,d=c=b):null==e&&("string"==typeof c?(e=d,d=b):(e=d,d=c,c=b)),e===!1)e=j;else if(!e)return this;return 1===f&&(h=e,e=function(a){return ib().off(a),h.apply(this,arguments)},e.guid=h.guid||(h.guid=ib.guid++)),this.each(function(){ib.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,c,d){var e,f;if(a&&a.preventDefault&&a.handleObj)return e=a.handleObj,ib(a.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler),this;if("object"==typeof a){for(f in a)this.off(f,c,a[f]);return this}return(c===!1||"function"==typeof c)&&(d=c,c=b),d===!1&&(d=j),this.each(function(){ib.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)},trigger:function(a,b){return this.each(function(){ib.event.trigger(a,b,this)})},triggerHandler:function(a,c){var d=this[0];return d?ib.event.trigger(a,c,d,!0):b}}),function(a,b){function c(a){return ob.test(a+"")}function d(){var a,b=[];return a=function(c,d){return b.push(c+=" ")>y.cacheLength&&delete a[b.shift()],a[c]=d}}function e(a){return a[N]=!0,a}function f(a){var b=F.createElement("div");try{return a(b)}catch(c){return!1}finally{b=null}}function g(a,b,c,d){var e,f,g,h,i,j,k,n,o,p;if((b?b.ownerDocument||b:O)!==F&&E(b),b=b||F,c=c||[],!a||"string"!=typeof a)return c;if(1!==(h=b.nodeType)&&9!==h)return[];if(!H&&!d){if(e=pb.exec(a))if(g=e[1]){if(9===h){if(f=b.getElementById(g),!f||!f.parentNode)return c;if(f.id===g)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(g))&&L(b,f)&&f.id===g)return c.push(f),c}else{if(e[2])return Z.apply(c,$.call(b.getElementsByTagName(a),0)),c;if((g=e[3])&&P.getByClassName&&b.getElementsByClassName)return Z.apply(c,$.call(b.getElementsByClassName(g),0)),c}if(P.qsa&&!I.test(a)){if(k=!0,n=N,o=b,p=9===h&&a,1===h&&"object"!==b.nodeName.toLowerCase()){for(j=l(a),(k=b.getAttribute("id"))?n=k.replace(sb,"\\$&"):b.setAttribute("id",n),n="[id='"+n+"'] ",i=j.length;i--;)j[i]=n+m(j[i]);o=nb.test(a)&&b.parentNode||b,p=j.join(",")}if(p)try{return Z.apply(c,$.call(o.querySelectorAll(p),0)),c}catch(q){}finally{k||b.removeAttribute("id")}}}return u(a.replace(gb,"$1"),b,c,d)}function h(a,b){var c=b&&a,d=c&&(~b.sourceIndex||W)-(~a.sourceIndex||W);if(d)return d;if(c)for(;c=c.nextSibling;)if(c===b)return-1;return a?1:-1}function i(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function j(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function k(a){return e(function(b){return b=+b,e(function(c,d){for(var e,f=a([],c.length,b),g=f.length;g--;)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function l(a,b){var c,d,e,f,h,i,j,k=T[a+" "];if(k)return b?0:k.slice(0);for(h=a,i=[],j=y.preFilter;h;){(!c||(d=hb.exec(h)))&&(d&&(h=h.slice(d[0].length)||h),i.push(e=[])),c=!1,(d=jb.exec(h))&&(c=d.shift(),e.push({value:c,type:d[0].replace(gb," ")}),h=h.slice(c.length));for(f in y.filter)!(d=mb[f].exec(h))||j[f]&&!(d=j[f](d))||(c=d.shift(),e.push({value:c,type:f,matches:d}),h=h.slice(c.length));if(!c)break}return b?h.length:h?g.error(a):T(a,i).slice(0)}function m(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function n(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=R++;return b.first?function(b,c,f){for(;b=b[d];)if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j,k=Q+" "+f;if(g){for(;b=b[d];)if((1===b.nodeType||e)&&a(b,c,g))return!0}else for(;b=b[d];)if(1===b.nodeType||e)if(j=b[N]||(b[N]={}),(i=j[d])&&i[0]===k){if((h=i[1])===!0||h===x)return h===!0}else if(i=j[d]=[k],i[1]=a(b,c,g)||x,i[1]===!0)return!0}}function o(a){return a.length>1?function(b,c,d){for(var e=a.length;e--;)if(!a[e](b,c,d))return!1;return!0}:a[0]}function p(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function q(a,b,c,d,f,g){return d&&!d[N]&&(d=q(d)),f&&!f[N]&&(f=q(f,g)),e(function(e,g,h,i){var j,k,l,m=[],n=[],o=g.length,q=e||t(b||"*",h.nodeType?[h]:h,[]),r=!a||!e&&b?q:p(q,m,a,h,i),s=c?f||(e?a:o||d)?[]:g:r;if(c&&c(r,s,h,i),d)for(j=p(s,n),d(j,[],h,i),k=j.length;k--;)(l=j[k])&&(s[n[k]]=!(r[n[k]]=l));if(e){if(f||a){if(f){for(j=[],k=s.length;k--;)(l=s[k])&&j.push(r[k]=l);f(null,s=[],j,i)}for(k=s.length;k--;)(l=s[k])&&(j=f?_.call(e,l):m[k])>-1&&(e[j]=!(g[j]=l))}}else s=p(s===g?s.splice(o,s.length):s),f?f(null,g,s,i):Z.apply(g,s)})}function r(a){for(var b,c,d,e=a.length,f=y.relative[a[0].type],g=f||y.relative[" "],h=f?1:0,i=n(function(a){return a===b},g,!0),j=n(function(a){return _.call(b,a)>-1},g,!0),k=[function(a,c,d){return!f&&(d||c!==D)||((b=c).nodeType?i(a,c,d):j(a,c,d))}];e>h;h++)if(c=y.relative[a[h].type])k=[n(o(k),c)];else{if(c=y.filter[a[h].type].apply(null,a[h].matches),c[N]){for(d=++h;e>d&&!y.relative[a[d].type];d++);return q(h>1&&o(k),h>1&&m(a.slice(0,h-1)).replace(gb,"$1"),c,d>h&&r(a.slice(h,d)),e>d&&r(a=a.slice(d)),e>d&&m(a))}k.push(c)}return o(k)}function s(a,b){var c=0,d=b.length>0,f=a.length>0,h=function(e,h,i,j,k){var l,m,n,o=[],q=0,r="0",s=e&&[],t=null!=k,u=D,v=e||f&&y.find.TAG("*",k&&h.parentNode||h),w=Q+=null==u?1:Math.random()||.1;for(t&&(D=h!==F&&h,x=c);null!=(l=v[r]);r++){if(f&&l){for(m=0;n=a[m++];)if(n(l,h,i)){j.push(l);break}t&&(Q=w,x=++c)}d&&((l=!n&&l)&&q--,e&&s.push(l))}if(q+=r,d&&r!==q){for(m=0;n=b[m++];)n(s,o,h,i);if(e){if(q>0)for(;r--;)s[r]||o[r]||(o[r]=Y.call(j));o=p(o)}Z.apply(j,o),t&&!e&&o.length>0&&q+b.length>1&&g.uniqueSort(j)}return t&&(Q=w,D=u),s};return d?e(h):h}function t(a,b,c){for(var d=0,e=b.length;e>d;d++)g(a,b[d],c);return c}function u(a,b,c,d){var e,f,g,h,i,j=l(a);if(!d&&1===j.length){if(f=j[0]=j[0].slice(0),f.length>2&&"ID"===(g=f[0]).type&&9===b.nodeType&&!H&&y.relative[f[1].type]){if(b=y.find.ID(g.matches[0].replace(ub,vb),b)[0],!b)return c;a=a.slice(f.shift().value.length)}for(e=mb.needsContext.test(a)?0:f.length;e--&&(g=f[e],!y.relative[h=g.type]);)if((i=y.find[h])&&(d=i(g.matches[0].replace(ub,vb),nb.test(f[0].type)&&b.parentNode||b))){if(f.splice(e,1),a=d.length&&m(f),!a)return Z.apply(c,$.call(d,0)),c;break}}return B(a,j)(d,b,H,c,nb.test(a)),c}function v(){}var w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N="sizzle"+-new Date,O=a.document,P={},Q=0,R=0,S=d(),T=d(),U=d(),V=typeof b,W=1<<31,X=[],Y=X.pop,Z=X.push,$=X.slice,_=X.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},ab="[\\x20\\t\\r\\n\\f]",bb="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",cb=bb.replace("w","w#"),db="([*^$|!~]?=)",eb="\\["+ab+"*("+bb+")"+ab+"*(?:"+db+ab+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+cb+")|)|)"+ab+"*\\]",fb=":("+bb+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+eb.replace(3,8)+")*)|.*)\\)|)",gb=RegExp("^"+ab+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ab+"+$","g"),hb=RegExp("^"+ab+"*,"+ab+"*"),jb=RegExp("^"+ab+"*([\\x20\\t\\r\\n\\f>+~])"+ab+"*"),kb=RegExp(fb),lb=RegExp("^"+cb+"$"),mb={ID:RegExp("^#("+bb+")"),CLASS:RegExp("^\\.("+bb+")"),NAME:RegExp("^\\[name=['\"]?("+bb+")['\"]?\\]"),TAG:RegExp("^("+bb.replace("w","w*")+")"),ATTR:RegExp("^"+eb),PSEUDO:RegExp("^"+fb),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ab+"*(even|odd|(([+-]|)(\\d*)n|)"+ab+"*(?:([+-]|)"+ab+"*(\\d+)|))"+ab+"*\\)|)","i"),needsContext:RegExp("^"+ab+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ab+"*((?:-\\d)?\\d*)"+ab+"*\\)|)(?=[^-]|$)","i")},nb=/[\x20\t\r\n\f]*[+~]/,ob=/^[^{]+\{\s*\[native code/,pb=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,qb=/^(?:input|select|textarea|button)$/i,rb=/^h\d$/i,sb=/'|\\/g,tb=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,ub=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,vb=function(a,b){var c="0x"+b-65536;return c!==c?b:0>c?String.fromCharCode(c+65536):String.fromCharCode(55296|c>>10,56320|1023&c)};try{$.call(O.documentElement.childNodes,0)[0].nodeType}catch(wb){$=function(a){for(var b,c=[];b=this[a++];)c.push(b);return c}}A=g.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},E=g.setDocument=function(a){var d=a?a.ownerDocument||a:O;return d!==F&&9===d.nodeType&&d.documentElement?(F=d,G=d.documentElement,H=A(d),P.tagNameNoComments=f(function(a){return a.appendChild(d.createComment("")),!a.getElementsByTagName("*").length}),P.attributes=f(function(a){a.innerHTML="<select></select>";var b=typeof a.lastChild.getAttribute("multiple");return"boolean"!==b&&"string"!==b}),P.getByClassName=f(function(a){return a.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",a.getElementsByClassName&&a.getElementsByClassName("e").length?(a.lastChild.className="e",2===a.getElementsByClassName("e").length):!1}),P.getByName=f(function(a){a.id=N+0,a.innerHTML="<a name='"+N+"'></a><div name='"+N+"'></div>",G.insertBefore(a,G.firstChild);var b=d.getElementsByName&&d.getElementsByName(N).length===2+d.getElementsByName(N+0).length;return P.getIdNotName=!d.getElementById(N),G.removeChild(a),b}),y.attrHandle=f(function(a){return a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!==V&&"#"===a.firstChild.getAttribute("href")})?{}:{href:function(a){return a.getAttribute("href",2)},type:function(a){return a.getAttribute("type")}},P.getIdNotName?(y.find.ID=function(a,b){if(typeof b.getElementById!==V&&!H){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},y.filter.ID=function(a){var b=a.replace(ub,vb);return function(a){return a.getAttribute("id")===b}}):(y.find.ID=function(a,c){if(typeof c.getElementById!==V&&!H){var d=c.getElementById(a);return d?d.id===a||typeof d.getAttributeNode!==V&&d.getAttributeNode("id").value===a?[d]:b:[]}},y.filter.ID=function(a){var b=a.replace(ub,vb);return function(a){var c=typeof a.getAttributeNode!==V&&a.getAttributeNode("id");return c&&c.value===b}}),y.find.TAG=P.tagNameNoComments?function(a,c){return typeof c.getElementsByTagName!==V?c.getElementsByTagName(a):b}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){for(;c=f[e++];)1===c.nodeType&&d.push(c);return d}return f},y.find.NAME=P.getByName&&function(a,c){return typeof c.getElementsByName!==V?c.getElementsByName(name):b},y.find.CLASS=P.getByClassName&&function(a,c){return typeof c.getElementsByClassName===V||H?b:c.getElementsByClassName(a)
},J=[],I=[":focus"],(P.qsa=c(d.querySelectorAll))&&(f(function(a){a.innerHTML="<select><option selected=''></option></select>",a.querySelectorAll("[selected]").length||I.push("\\["+ab+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||I.push(":checked")}),f(function(a){a.innerHTML="<input type='hidden' i=''/>",a.querySelectorAll("[i^='']").length&&I.push("[*^$]="+ab+"*(?:\"\"|'')"),a.querySelectorAll(":enabled").length||I.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),I.push(",.*:")})),(P.matchesSelector=c(K=G.matchesSelector||G.mozMatchesSelector||G.webkitMatchesSelector||G.oMatchesSelector||G.msMatchesSelector))&&f(function(a){P.disconnectedMatch=K.call(a,"div"),K.call(a,"[s!='']:x"),J.push("!=",fb)}),I=RegExp(I.join("|")),J=RegExp(J.join("|")),L=c(G.contains)||G.compareDocumentPosition?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},M=G.compareDocumentPosition?function(a,b){var c;return a===b?(C=!0,0):(c=b.compareDocumentPosition&&a.compareDocumentPosition&&a.compareDocumentPosition(b))?1&c||a.parentNode&&11===a.parentNode.nodeType?a===d||L(O,a)?-1:b===d||L(O,b)?1:0:4&c?-1:1:a.compareDocumentPosition?-1:1}:function(a,b){var c,e=0,f=a.parentNode,g=b.parentNode,i=[a],j=[b];if(a===b)return C=!0,0;if(!f||!g)return a===d?-1:b===d?1:f?-1:g?1:0;if(f===g)return h(a,b);for(c=a;c=c.parentNode;)i.unshift(c);for(c=b;c=c.parentNode;)j.unshift(c);for(;i[e]===j[e];)e++;return e?h(i[e],j[e]):i[e]===O?-1:j[e]===O?1:0},C=!1,[0,0].sort(M),P.detectDuplicates=C,F):F},g.matches=function(a,b){return g(a,null,null,b)},g.matchesSelector=function(a,b){if((a.ownerDocument||a)!==F&&E(a),b=b.replace(tb,"='$1']"),!(!P.matchesSelector||H||J&&J.test(b)||I.test(b)))try{var c=K.call(a,b);if(c||P.disconnectedMatch||a.document&&11!==a.document.nodeType)return c}catch(d){}return g(b,F,null,[a]).length>0},g.contains=function(a,b){return(a.ownerDocument||a)!==F&&E(a),L(a,b)},g.attr=function(a,b){var c;return(a.ownerDocument||a)!==F&&E(a),H||(b=b.toLowerCase()),(c=y.attrHandle[b])?c(a):H||P.attributes?a.getAttribute(b):((c=a.getAttributeNode(b))||a.getAttribute(b))&&a[b]===!0?b:c&&c.specified?c.value:null},g.error=function(a){throw Error("Syntax error, unrecognized expression: "+a)},g.uniqueSort=function(a){var b,c=[],d=1,e=0;if(C=!P.detectDuplicates,a.sort(M),C){for(;b=a[d];d++)b===a[d-1]&&(e=c.push(d));for(;e--;)a.splice(c[e],1)}return a},z=g.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(1===e||9===e||11===e){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=z(a)}else if(3===e||4===e)return a.nodeValue}else for(;b=a[d];d++)c+=z(b);return c},y=g.selectors={cacheLength:50,createPseudo:e,match:mb,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ub,vb),a[3]=(a[4]||a[5]||"").replace(ub,vb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||g.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&g.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return mb.CHILD.test(a[0])?null:(a[4]?a[2]=a[4]:c&&kb.test(c)&&(b=l(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){return"*"===a?function(){return!0}:(a=a.replace(ub,vb).toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=S[a+" "];return b||(b=RegExp("(^|"+ab+")"+a+"("+ab+"|$)"))&&S(a,function(a){return b.test(a.className||typeof a.getAttribute!==V&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=g.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){for(;p;){for(l=b;l=l[p];)if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){for(k=q[N]||(q[N]={}),j=k[a]||[],n=j[0]===Q&&j[1],m=j[0]===Q&&j[2],l=n&&q.childNodes[n];l=++n&&l&&l[p]||(m=n=0)||o.pop();)if(1===l.nodeType&&++m&&l===b){k[a]=[Q,n,m];break}}else if(s&&(j=(b[N]||(b[N]={}))[a])&&j[0]===Q)m=j[1];else for(;(l=++n&&l&&l[p]||(m=n=0)||o.pop())&&((h?l.nodeName.toLowerCase()!==r:1!==l.nodeType)||!++m||(s&&((l[N]||(l[N]={}))[a]=[Q,m]),l!==b)););return m-=e,m===d||0===m%d&&m/d>=0}}},PSEUDO:function(a,b){var c,d=y.pseudos[a]||y.setFilters[a.toLowerCase()]||g.error("unsupported pseudo: "+a);return d[N]?d(b):d.length>1?(c=[a,a,"",b],y.setFilters.hasOwnProperty(a.toLowerCase())?e(function(a,c){for(var e,f=d(a,b),g=f.length;g--;)e=_.call(a,f[g]),a[e]=!(c[e]=f[g])}):function(a){return d(a,0,c)}):d}},pseudos:{not:e(function(a){var b=[],c=[],d=B(a.replace(gb,"$1"));return d[N]?e(function(a,b,c,e){for(var f,g=d(a,null,e,[]),h=a.length;h--;)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:e(function(a){return function(b){return g(a,b).length>0}}),contains:e(function(a){return function(b){return(b.textContent||b.innerText||z(b)).indexOf(a)>-1}}),lang:e(function(a){return lb.test(a||"")||g.error("unsupported lang: "+a),a=a.replace(ub,vb).toLowerCase(),function(b){var c;do if(c=H?b.getAttribute("xml:lang")||b.getAttribute("lang"):b.lang)return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===G},focus:function(a){return a===F.activeElement&&(!F.hasFocus||F.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeName>"@"||3===a.nodeType||4===a.nodeType)return!1;return!0},parent:function(a){return!y.pseudos.empty(a)},header:function(a){return rb.test(a.nodeName)},input:function(a){return qb.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||b.toLowerCase()===a.type)},first:k(function(){return[0]}),last:k(function(a,b){return[b-1]}),eq:k(function(a,b,c){return[0>c?c+b:c]}),even:k(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:k(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:k(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:k(function(a,b,c){for(var d=0>c?c+b:c;b>++d;)a.push(d);return a})}};for(w in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})y.pseudos[w]=i(w);for(w in{submit:!0,reset:!0})y.pseudos[w]=j(w);B=g.compile=function(a,b){var c,d=[],e=[],f=U[a+" "];if(!f){for(b||(b=l(a)),c=b.length;c--;)f=r(b[c]),f[N]?d.push(f):e.push(f);f=U(a,s(e,d))}return f},y.pseudos.nth=y.pseudos.eq,y.filters=v.prototype=y.pseudos,y.setFilters=new v,E(),g.attr=ib.attr,ib.find=g,ib.expr=g.selectors,ib.expr[":"]=ib.expr.pseudos,ib.unique=g.uniqueSort,ib.text=g.getText,ib.isXMLDoc=g.isXML,ib.contains=g.contains}(a);var Pb=/Until$/,Qb=/^(?:parents|prev(?:Until|All))/,Rb=/^.[^:#\[\.,]*$/,Sb=ib.expr.match.needsContext,Tb={children:!0,contents:!0,next:!0,prev:!0};ib.fn.extend({find:function(a){var b,c,d,e=this.length;if("string"!=typeof a)return d=this,this.pushStack(ib(a).filter(function(){for(b=0;e>b;b++)if(ib.contains(d[b],this))return!0}));for(c=[],b=0;e>b;b++)ib.find(a,this[b],c);return c=this.pushStack(e>1?ib.unique(c):c),c.selector=(this.selector?this.selector+" ":"")+a,c},has:function(a){var b,c=ib(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(ib.contains(this,c[b]))return!0})},not:function(a){return this.pushStack(l(this,a,!1))},filter:function(a){return this.pushStack(l(this,a,!0))},is:function(a){return!!a&&("string"==typeof a?Sb.test(a)?ib(a,this.context).index(this[0])>=0:ib.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=Sb.test(a)||"string"!=typeof a?ib(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c.ownerDocument&&c!==b&&11!==c.nodeType;){if(g?g.index(c)>-1:ib.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}return this.pushStack(f.length>1?ib.unique(f):f)},index:function(a){return a?"string"==typeof a?ib.inArray(this[0],ib(a)):ib.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){var c="string"==typeof a?ib(a,b):ib.makeArray(a&&a.nodeType?[a]:a),d=ib.merge(this.get(),c);return this.pushStack(ib.unique(d))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}}),ib.fn.andSelf=ib.fn.addBack,ib.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return ib.dir(a,"parentNode")},parentsUntil:function(a,b,c){return ib.dir(a,"parentNode",c)},next:function(a){return k(a,"nextSibling")},prev:function(a){return k(a,"previousSibling")},nextAll:function(a){return ib.dir(a,"nextSibling")},prevAll:function(a){return ib.dir(a,"previousSibling")},nextUntil:function(a,b,c){return ib.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return ib.dir(a,"previousSibling",c)},siblings:function(a){return ib.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return ib.sibling(a.firstChild)},contents:function(a){return ib.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:ib.merge([],a.childNodes)}},function(a,b){ib.fn[a]=function(c,d){var e=ib.map(this,b,c);return Pb.test(a)||(d=c),d&&"string"==typeof d&&(e=ib.filter(d,e)),e=this.length>1&&!Tb[a]?ib.unique(e):e,this.length>1&&Qb.test(a)&&(e=e.reverse()),this.pushStack(e)}}),ib.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),1===b.length?ib.find.matchesSelector(b[0],a)?[b[0]]:[]:ib.find.matches(a,b)},dir:function(a,c,d){for(var e=[],f=a[c];f&&9!==f.nodeType&&(d===b||1!==f.nodeType||!ib(f).is(d));)1===f.nodeType&&e.push(f),f=f[c];return e},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}});var Ub="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Vb=/ jQuery\d+="(?:null|\d+)"/g,Wb=RegExp("<(?:"+Ub+")[\\s/>]","i"),Xb=/^\s+/,Yb=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Zb=/<([\w:]+)/,$b=/<tbody/i,_b=/<|&#?\w+;/,ac=/<(?:script|style|link)/i,bc=/^(?:checkbox|radio)$/i,cc=/checked\s*(?:[^=]|=\s*.checked.)/i,dc=/^$|\/(?:java|ecma)script/i,ec=/^true\/(.*)/,fc=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,gc={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:ib.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},hc=m(W),ic=hc.appendChild(W.createElement("div"));gc.optgroup=gc.option,gc.tbody=gc.tfoot=gc.colgroup=gc.caption=gc.thead,gc.th=gc.td,ib.fn.extend({text:function(a){return ib.access(this,function(a){return a===b?ib.text(this):this.empty().append((this[0]&&this[0].ownerDocument||W).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(ib.isFunction(a))return this.each(function(b){ib(this).wrapAll(a.call(this,b))});if(this[0]){var b=ib(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){for(var a=this;a.firstChild&&1===a.firstChild.nodeType;)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(ib.isFunction(a)?function(b){ib(this).wrapInner(a.call(this,b))}:function(){var b=ib(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=ib.isFunction(a);return this.each(function(c){ib(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){ib.nodeName(this,"body")||ib(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(a,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=0;null!=(c=this[d]);d++)(!a||ib.filter(a,[c]).length>0)&&(b||1!==c.nodeType||ib.cleanData(t(c)),c.parentNode&&(b&&ib.contains(c.ownerDocument,c)&&q(t(c,"script")),c.parentNode.removeChild(c)));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){for(1===a.nodeType&&ib.cleanData(t(a,!1));a.firstChild;)a.removeChild(a.firstChild);a.options&&ib.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return ib.clone(this,a,b)})},html:function(a){return ib.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return 1===c.nodeType?c.innerHTML.replace(Vb,""):b;if(!("string"!=typeof a||ac.test(a)||!ib.support.htmlSerialize&&Wb.test(a)||!ib.support.leadingWhitespace&&Xb.test(a)||gc[(Zb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(Yb,"<$1></$2>");try{for(;e>d;d++)c=this[d]||{},1===c.nodeType&&(ib.cleanData(t(c,!1)),c.innerHTML=a);c=0}catch(f){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){var b=ib.isFunction(a);return b||"string"==typeof a||(a=ib(a).not(this).detach()),this.domManip([a],!0,function(a){var b=this.nextSibling,c=this.parentNode;c&&(ib(this).remove(),c.insertBefore(a,b))})},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){a=bb.apply([],a);var e,f,g,h,i,j,k=0,l=this.length,m=this,q=l-1,r=a[0],s=ib.isFunction(r);if(s||!(1>=l||"string"!=typeof r||ib.support.checkClone)&&cc.test(r))return this.each(function(e){var f=m.eq(e);s&&(a[0]=r.call(this,e,c?f.html():b)),f.domManip(a,c,d)});if(l&&(j=ib.buildFragment(a,this[0].ownerDocument,!1,this),e=j.firstChild,1===j.childNodes.length&&(j=e),e)){for(c=c&&ib.nodeName(e,"tr"),h=ib.map(t(j,"script"),o),g=h.length;l>k;k++)f=j,k!==q&&(f=ib.clone(f,!0,!0),g&&ib.merge(h,t(f,"script"))),d.call(c&&ib.nodeName(this[k],"table")?n(this[k],"tbody"):this[k],f,k);if(g)for(i=h[h.length-1].ownerDocument,ib.map(h,p),k=0;g>k;k++)f=h[k],dc.test(f.type||"")&&!ib._data(f,"globalEval")&&ib.contains(i,f)&&(f.src?ib.ajax({url:f.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):ib.globalEval((f.text||f.textContent||f.innerHTML||"").replace(fc,"")));j=e=null}return this}}),ib.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){ib.fn[a]=function(a){for(var c,d=0,e=[],f=ib(a),g=f.length-1;g>=d;d++)c=d===g?this:this.clone(!0),ib(f[d])[b](c),cb.apply(e,c.get());return this.pushStack(e)}}),ib.extend({clone:function(a,b,c){var d,e,f,g,h,i=ib.contains(a.ownerDocument,a);if(ib.support.html5Clone||ib.isXMLDoc(a)||!Wb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ic.innerHTML=a.outerHTML,ic.removeChild(f=ic.firstChild)),!(ib.support.noCloneEvent&&ib.support.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||ib.isXMLDoc(a)))for(d=t(f),h=t(a),g=0;null!=(e=h[g]);++g)d[g]&&s(e,d[g]);if(b)if(c)for(h=h||t(a),d=d||t(f),g=0;null!=(e=h[g]);g++)r(e,d[g]);else r(a,f);return d=t(f,"script"),d.length>0&&q(d,!i&&t(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,l=a.length,n=m(b),o=[],p=0;l>p;p++)if(f=a[p],f||0===f)if("object"===ib.type(f))ib.merge(o,f.nodeType?[f]:f);else if(_b.test(f)){for(h=h||n.appendChild(b.createElement("div")),i=(Zb.exec(f)||["",""])[1].toLowerCase(),k=gc[i]||gc._default,h.innerHTML=k[1]+f.replace(Yb,"<$1></$2>")+k[2],e=k[0];e--;)h=h.lastChild;if(!ib.support.leadingWhitespace&&Xb.test(f)&&o.push(b.createTextNode(Xb.exec(f)[0])),!ib.support.tbody)for(f="table"!==i||$b.test(f)?"<table>"!==k[1]||$b.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;e--;)ib.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j);for(ib.merge(o,h.childNodes),h.textContent="";h.firstChild;)h.removeChild(h.firstChild);h=n.lastChild}else o.push(b.createTextNode(f));for(h&&n.removeChild(h),ib.support.appendChecked||ib.grep(t(o,"input"),u),p=0;f=o[p++];)if((!d||-1===ib.inArray(f,d))&&(g=ib.contains(f.ownerDocument,f),h=t(n.appendChild(f),"script"),g&&q(h),c))for(e=0;f=h[e++];)dc.test(f.type||"")&&c.push(f);return h=null,n},cleanData:function(a,b){for(var c,d,e,f,g=0,h=ib.expando,i=ib.cache,j=ib.support.deleteExpando,k=ib.event.special;null!=(c=a[g]);g++)if((b||ib.acceptData(c))&&(e=c[h],f=e&&i[e])){if(f.events)for(d in f.events)k[d]?ib.event.remove(c,d):ib.removeEvent(c,d,f.handle);i[e]&&(delete i[e],j?delete c[h]:typeof c.removeAttribute!==V?c.removeAttribute(h):c[h]=null,_.push(e))}}});var jc,kc,lc,mc=/alpha\([^)]*\)/i,nc=/opacity\s*=\s*([^)]*)/,oc=/^(top|right|bottom|left)$/,pc=/^(none|table(?!-c[ea]).+)/,qc=/^margin/,rc=RegExp("^("+jb+")(.*)$","i"),sc=RegExp("^("+jb+")(?!px)[a-z%]+$","i"),tc=RegExp("^([+-])=("+jb+")","i"),uc={BODY:"block"},vc={position:"absolute",visibility:"hidden",display:"block"},wc={letterSpacing:0,fontWeight:400},xc=["Top","Right","Bottom","Left"],yc=["Webkit","O","Moz","ms"];ib.fn.extend({css:function(a,c){return ib.access(this,function(a,c,d){var e,f,g={},h=0;if(ib.isArray(c)){for(f=kc(a),e=c.length;e>h;h++)g[c[h]]=ib.css(a,c[h],!1,f);return g}return d!==b?ib.style(a,c,d):ib.css(a,c)},a,c,arguments.length>1)},show:function(){return x(this,!0)},hide:function(){return x(this)},toggle:function(a){var b="boolean"==typeof a;return this.each(function(){(b?a:w(this))?ib(this).show():ib(this).hide()})}}),ib.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=lc(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":ib.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var f,g,h,i=ib.camelCase(c),j=a.style;if(c=ib.cssProps[i]||(ib.cssProps[i]=v(j,i)),h=ib.cssHooks[c]||ib.cssHooks[i],d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];if(g=typeof d,"string"===g&&(f=tc.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(ib.css(a,c)),g="number"),!(null==d||"number"===g&&isNaN(d)||("number"!==g||ib.cssNumber[i]||(d+="px"),ib.support.clearCloneStyle||""!==d||0!==c.indexOf("background")||(j[c]="inherit"),h&&"set"in h&&(d=h.set(a,d,e))===b)))try{j[c]=d}catch(k){}}},css:function(a,c,d,e){var f,g,h,i=ib.camelCase(c);return c=ib.cssProps[i]||(ib.cssProps[i]=v(a.style,i)),h=ib.cssHooks[c]||ib.cssHooks[i],h&&"get"in h&&(g=h.get(a,!0,d)),g===b&&(g=lc(a,c,e)),"normal"===g&&c in wc&&(g=wc[c]),""===d||d?(f=parseFloat(g),d===!0||ib.isNumeric(f)?f||0:g):g},swap:function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e}}),a.getComputedStyle?(kc=function(b){return a.getComputedStyle(b,null)},lc=function(a,c,d){var e,f,g,h=d||kc(a),i=h?h.getPropertyValue(c)||h[c]:b,j=a.style;return h&&(""!==i||ib.contains(a.ownerDocument,a)||(i=ib.style(a,c)),sc.test(i)&&qc.test(c)&&(e=j.width,f=j.minWidth,g=j.maxWidth,j.minWidth=j.maxWidth=j.width=i,i=h.width,j.width=e,j.minWidth=f,j.maxWidth=g)),i}):W.documentElement.currentStyle&&(kc=function(a){return a.currentStyle},lc=function(a,c,d){var e,f,g,h=d||kc(a),i=h?h[c]:b,j=a.style;return null==i&&j&&j[c]&&(i=j[c]),sc.test(i)&&!oc.test(c)&&(e=j.left,f=a.runtimeStyle,g=f&&f.left,g&&(f.left=a.currentStyle.left),j.left="fontSize"===c?"1em":i,i=j.pixelLeft+"px",j.left=e,g&&(f.left=g)),""===i?"auto":i}),ib.each(["height","width"],function(a,c){ib.cssHooks[c]={get:function(a,d,e){return d?0===a.offsetWidth&&pc.test(ib.css(a,"display"))?ib.swap(a,vc,function(){return A(a,c,e)}):A(a,c,e):b},set:function(a,b,d){var e=d&&kc(a);return y(a,b,d?z(a,c,d,ib.support.boxSizing&&"border-box"===ib.css(a,"boxSizing",!1,e),e):0)}}}),ib.support.opacity||(ib.cssHooks.opacity={get:function(a,b){return nc.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=ib.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===ib.trim(f.replace(mc,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=mc.test(f)?f.replace(mc,e):f+" "+e)}}),ib(function(){ib.support.reliableMarginRight||(ib.cssHooks.marginRight={get:function(a,c){return c?ib.swap(a,{display:"inline-block"},lc,[a,"marginRight"]):b}}),!ib.support.pixelPosition&&ib.fn.position&&ib.each(["top","left"],function(a,c){ib.cssHooks[c]={get:function(a,d){return d?(d=lc(a,c),sc.test(d)?ib(a).position()[c]+"px":d):b}}})}),ib.expr&&ib.expr.filters&&(ib.expr.filters.hidden=function(a){return 0>=a.offsetWidth&&0>=a.offsetHeight||!ib.support.reliableHiddenOffsets&&"none"===(a.style&&a.style.display||ib.css(a,"display"))},ib.expr.filters.visible=function(a){return!ib.expr.filters.hidden(a)}),ib.each({margin:"",padding:"",border:"Width"},function(a,b){ib.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+xc[d]+b]=f[d]||f[d-2]||f[0];return e}},qc.test(a)||(ib.cssHooks[a+b].set=y)});var zc=/%20/g,Ac=/\[\]$/,Bc=/\r?\n/g,Cc=/^(?:submit|button|image|reset|file)$/i,Dc=/^(?:input|select|textarea|keygen)/i;ib.fn.extend({serialize:function(){return ib.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=ib.prop(this,"elements");return a?ib.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!ib(this).is(":disabled")&&Dc.test(this.nodeName)&&!Cc.test(a)&&(this.checked||!bc.test(a))}).map(function(a,b){var c=ib(this).val();return null==c?null:ib.isArray(c)?ib.map(c,function(a){return{name:b.name,value:a.replace(Bc,"\r\n")}}):{name:b.name,value:c.replace(Bc,"\r\n")}}).get()}}),ib.param=function(a,c){var d,e=[],f=function(a,b){b=ib.isFunction(b)?b():null==b?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(c===b&&(c=ib.ajaxSettings&&ib.ajaxSettings.traditional),ib.isArray(a)||a.jquery&&!ib.isPlainObject(a))ib.each(a,function(){f(this.name,this.value)});else for(d in a)D(d,a[d],c,f);return e.join("&").replace(zc,"+")},ib.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){ib.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),ib.fn.hover=function(a,b){return this.mouseenter(a).mouseleave(b||a)};var Ec,Fc,Gc=ib.now(),Hc=/\?/,Ic=/#.*$/,Jc=/([?&])_=[^&]*/,Kc=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Lc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mc=/^(?:GET|HEAD)$/,Nc=/^\/\//,Oc=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Pc=ib.fn.load,Qc={},Rc={},Sc="*/".concat("*");try{Fc=X.href}catch(Tc){Fc=W.createElement("a"),Fc.href="",Fc=Fc.href}Ec=Oc.exec(Fc.toLowerCase())||[],ib.fn.load=function(a,c,d){if("string"!=typeof a&&Pc)return Pc.apply(this,arguments);var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),ib.isFunction(c)?(d=c,c=b):c&&"object"==typeof c&&(g="POST"),h.length>0&&ib.ajax({url:a,type:g,dataType:"html",data:c}).done(function(a){f=arguments,h.html(e?ib("<div>").append(ib.parseHTML(a)).find(e):a)}).complete(d&&function(a,b){h.each(d,f||[a.responseText,b,a])}),this},ib.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){ib.fn[b]=function(a){return this.on(b,a)}}),ib.each(["get","post"],function(a,c){ib[c]=function(a,d,e,f){return ib.isFunction(d)&&(f=f||e,e=d,d=b),ib.ajax({url:a,type:c,dataType:f,data:d,success:e})}}),ib.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Fc,type:"GET",isLocal:Lc.test(Ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Sc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":ib.parseJSON,"text xml":ib.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?G(G(a,ib.ajaxSettings),b):G(ib.ajaxSettings,a)},ajaxPrefilter:E(Qc),ajaxTransport:E(Rc),ajax:function(a,c){function d(a,c,d,e){var f,l,s,t,v,x=c;2!==u&&(u=2,i&&clearTimeout(i),k=b,h=e||"",w.readyState=a>0?4:0,d&&(t=H(m,w,d)),a>=200&&300>a||304===a?(m.ifModified&&(v=w.getResponseHeader("Last-Modified"),v&&(ib.lastModified[g]=v),v=w.getResponseHeader("etag"),v&&(ib.etag[g]=v)),204===a?(f=!0,x="nocontent"):304===a?(f=!0,x="notmodified"):(f=I(m,t),x=f.state,l=f.data,s=f.error,f=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),w.status=a,w.statusText=(c||x)+"",f?p.resolveWith(n,[l,x,w]):p.rejectWith(n,[w,x,s]),w.statusCode(r),r=b,j&&o.trigger(f?"ajaxSuccess":"ajaxError",[w,m,f?l:s]),q.fireWith(n,[w,x]),j&&(o.trigger("ajaxComplete",[w,m]),--ib.active||ib.event.trigger("ajaxStop")))}"object"==typeof a&&(c=a,a=b),c=c||{};var e,f,g,h,i,j,k,l,m=ib.ajaxSetup({},c),n=m.context||m,o=m.context&&(n.nodeType||n.jquery)?ib(n):ib.event,p=ib.Deferred(),q=ib.Callbacks("once memory"),r=m.statusCode||{},s={},t={},u=0,v="canceled",w={readyState:0,getResponseHeader:function(a){var b;if(2===u){if(!l)for(l={};b=Kc.exec(h);)l[b[1].toLowerCase()]=b[2];b=l[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===u?h:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return u||(a=t[c]=t[c]||a,s[a]=b),this},overrideMimeType:function(a){return u||(m.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>u)for(b in a)r[b]=[r[b],a[b]];else w.always(a[w.status]);return this},abort:function(a){var b=a||v;return k&&k.abort(b),d(0,b),this}};if(p.promise(w).complete=q.add,w.success=w.done,w.error=w.fail,m.url=((a||m.url||Fc)+"").replace(Ic,"").replace(Nc,Ec[1]+"//"),m.type=c.method||c.type||m.method||m.type,m.dataTypes=ib.trim(m.dataType||"*").toLowerCase().match(kb)||[""],null==m.crossDomain&&(e=Oc.exec(m.url.toLowerCase()),m.crossDomain=!(!e||e[1]===Ec[1]&&e[2]===Ec[2]&&(e[3]||("http:"===e[1]?80:443))==(Ec[3]||("http:"===Ec[1]?80:443)))),m.data&&m.processData&&"string"!=typeof m.data&&(m.data=ib.param(m.data,m.traditional)),F(Qc,m,c,w),2===u)return w;j=m.global,j&&0===ib.active++&&ib.event.trigger("ajaxStart"),m.type=m.type.toUpperCase(),m.hasContent=!Mc.test(m.type),g=m.url,m.hasContent||(m.data&&(g=m.url+=(Hc.test(g)?"&":"?")+m.data,delete m.data),m.cache===!1&&(m.url=Jc.test(g)?g.replace(Jc,"$1_="+Gc++):g+(Hc.test(g)?"&":"?")+"_="+Gc++)),m.ifModified&&(ib.lastModified[g]&&w.setRequestHeader("If-Modified-Since",ib.lastModified[g]),ib.etag[g]&&w.setRequestHeader("If-None-Match",ib.etag[g])),(m.data&&m.hasContent&&m.contentType!==!1||c.contentType)&&w.setRequestHeader("Content-Type",m.contentType),w.setRequestHeader("Accept",m.dataTypes[0]&&m.accepts[m.dataTypes[0]]?m.accepts[m.dataTypes[0]]+("*"!==m.dataTypes[0]?", "+Sc+"; q=0.01":""):m.accepts["*"]);for(f in m.headers)w.setRequestHeader(f,m.headers[f]);if(m.beforeSend&&(m.beforeSend.call(n,w,m)===!1||2===u))return w.abort();v="abort";for(f in{success:1,error:1,complete:1})w[f](m[f]);if(k=F(Rc,m,c,w)){w.readyState=1,j&&o.trigger("ajaxSend",[w,m]),m.async&&m.timeout>0&&(i=setTimeout(function(){w.abort("timeout")},m.timeout));try{u=1,k.send(s,d)}catch(x){if(!(2>u))throw x;d(-1,x)}}else d(-1,"No Transport");return w},getScript:function(a,c){return ib.get(a,b,c,"script")},getJSON:function(a,b,c){return ib.get(a,b,c,"json")}}),ib.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return ib.globalEval(a),a}}}),ib.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),ib.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=W.head||ib("head")[0]||W.documentElement;return{send:function(b,e){c=W.createElement("script"),c.async=!0,a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,b){(b||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,c.parentNode&&c.parentNode.removeChild(c),c=null,b||e(200,"success"))},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(b,!0)}}}});var Uc=[],Vc=/(=)\?(?=&|$)|\?\?/;ib.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Uc.pop()||ib.expando+"_"+Gc++;return this[a]=!0,a}}),ib.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.jsonp!==!1&&(Vc.test(c.url)?"url":"string"==typeof c.data&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vc.test(c.data)&&"data");return i||"jsonp"===c.dataTypes[0]?(f=c.jsonpCallback=ib.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,i?c[i]=c[i].replace(Vc,"$1"+f):c.jsonp!==!1&&(c.url+=(Hc.test(c.url)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||ib.error(f+" was not called"),h[0]},c.dataTypes[0]="json",g=a[f],a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,Uc.push(f)),h&&ib.isFunction(g)&&g(h[0]),h=g=b}),"script"):b});var Wc,Xc,Yc=0,Zc=a.ActiveXObject&&function(){var a;for(a in Wc)Wc[a](b,!0)};ib.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&J()||K()}:J,Xc=ib.ajaxSettings.xhr(),ib.support.cors=!!Xc&&"withCredentials"in Xc,Xc=ib.support.ajax=!!Xc,Xc&&ib.ajaxTransport(function(c){if(!c.crossDomain||ib.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();if(c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async),c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),c.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l;try{if(d&&(e||4===i.readyState))if(d=b,g&&(i.onreadystatechange=ib.noop,Zc&&delete Wc[g]),e)4!==i.readyState&&i.abort();else{l={},h=i.status,j=i.getAllResponseHeaders(),"string"==typeof i.responseText&&(l.text=i.responseText);try{k=i.statusText}catch(m){k=""}h||!c.isLocal||c.crossDomain?1223===h&&(h=204):h=l.text?200:404}}catch(n){e||f(-1,n)}l&&f(h,k,l,j)},c.async?4===i.readyState?setTimeout(d):(g=++Yc,Zc&&(Wc||(Wc={},ib(a).unload(Zc)),Wc[g]=d),i.onreadystatechange=d):d()
},abort:function(){d&&d(b,!0)}}}});var $c,_c,ad=/^(?:toggle|show|hide)$/,bd=RegExp("^(?:([+-])=|)("+jb+")([a-z%]*)$","i"),cd=/queueHooks$/,dd=[P],ed={"*":[function(a,b){var c,d,e=this.createTween(a,b),f=bd.exec(b),g=e.cur(),h=+g||0,i=1,j=20;if(f){if(c=+f[2],d=f[3]||(ib.cssNumber[a]?"":"px"),"px"!==d&&h){h=ib.css(e.elem,a,!0)||c||1;do i=i||".5",h/=i,ib.style(e.elem,a,h+d);while(i!==(i=e.cur()/g)&&1!==i&&--j)}e.unit=d,e.start=h,e.end=f[1]?h+(f[1]+1)*c:c}return e}]};ib.Animation=ib.extend(N,{tweener:function(a,b){ib.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ed[c]=ed[c]||[],ed[c].unshift(b)},prefilter:function(a,b){b?dd.unshift(a):dd.push(a)}}),ib.Tween=Q,Q.prototype={constructor:Q,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(ib.cssNumber[c]?"":"px")},cur:function(){var a=Q.propHooks[this.prop];return a&&a.get?a.get(this):Q.propHooks._default.get(this)},run:function(a){var b,c=Q.propHooks[this.prop];return this.pos=b=this.options.duration?ib.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Q.propHooks._default.set(this),this}},Q.prototype.init.prototype=Q.prototype,Q.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=ib.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){ib.fx.step[a.prop]?ib.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[ib.cssProps[a.prop]]||ib.cssHooks[a.prop])?ib.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Q.propHooks.scrollTop=Q.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},ib.each(["toggle","show","hide"],function(a,b){var c=ib.fn[b];ib.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(R(b,!0),a,d,e)}}),ib.fn.extend({fadeTo:function(a,b,c,d){return this.filter(w).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=ib.isEmptyObject(a),f=ib.speed(b,c,d),g=function(){var b=N(this,ib.extend({},a),f);g.finish=function(){b.stop(!0)},(e||ib._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,c,d){var e=function(a){var b=a.stop;delete a.stop,b(d)};return"string"!=typeof a&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,c=null!=a&&a+"queueHooks",f=ib.timers,g=ib._data(this);if(c)g[c]&&g[c].stop&&e(g[c]);else for(c in g)g[c]&&g[c].stop&&cd.test(c)&&e(g[c]);for(c=f.length;c--;)f[c].elem!==this||null!=a&&f[c].queue!==a||(f[c].anim.stop(d),b=!1,f.splice(c,1));(b||!d)&&ib.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=ib._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=ib.timers,g=d?d.length:0;for(c.finish=!0,ib.queue(this,a,[]),e&&e.cur&&e.cur.finish&&e.cur.finish.call(this),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),ib.each({slideDown:R("show"),slideUp:R("hide"),slideToggle:R("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){ib.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),ib.speed=function(a,b,c){var d=a&&"object"==typeof a?ib.extend({},a):{complete:c||!c&&b||ib.isFunction(a)&&a,duration:a,easing:c&&b||b&&!ib.isFunction(b)&&b};return d.duration=ib.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in ib.fx.speeds?ib.fx.speeds[d.duration]:ib.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){ib.isFunction(d.old)&&d.old.call(this),d.queue&&ib.dequeue(this,d.queue)},d},ib.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},ib.timers=[],ib.fx=Q.prototype.init,ib.fx.tick=function(){var a,c=ib.timers,d=0;for($c=ib.now();c.length>d;d++)a=c[d],a()||c[d]!==a||c.splice(d--,1);c.length||ib.fx.stop(),$c=b},ib.fx.timer=function(a){a()&&ib.timers.push(a)&&ib.fx.start()},ib.fx.interval=13,ib.fx.start=function(){_c||(_c=setInterval(ib.fx.tick,ib.fx.interval))},ib.fx.stop=function(){clearInterval(_c),_c=null},ib.fx.speeds={slow:600,fast:200,_default:400},ib.fx.step={},ib.expr&&ib.expr.filters&&(ib.expr.filters.animated=function(a){return ib.grep(ib.timers,function(b){return a===b.elem}).length}),ib.fn.offset=function(a){if(arguments.length)return a===b?this:this.each(function(b){ib.offset.setOffset(this,a,b)});var c,d,e={top:0,left:0},f=this[0],g=f&&f.ownerDocument;return g?(c=g.documentElement,ib.contains(c,f)?(typeof f.getBoundingClientRect!==V&&(e=f.getBoundingClientRect()),d=S(g),{top:e.top+(d.pageYOffset||c.scrollTop)-(c.clientTop||0),left:e.left+(d.pageXOffset||c.scrollLeft)-(c.clientLeft||0)}):e):void 0},ib.offset={setOffset:function(a,b,c){var d=ib.css(a,"position");"static"===d&&(a.style.position="relative");var e,f,g=ib(a),h=g.offset(),i=ib.css(a,"top"),j=ib.css(a,"left"),k=("absolute"===d||"fixed"===d)&&ib.inArray("auto",[i,j])>-1,l={},m={};k?(m=g.position(),e=m.top,f=m.left):(e=parseFloat(i)||0,f=parseFloat(j)||0),ib.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(l.top=b.top-h.top+e),null!=b.left&&(l.left=b.left-h.left+f),"using"in b?b.using.call(a,l):g.css(l)}},ib.fn.extend({position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===ib.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),ib.nodeName(a[0],"html")||(c=a.offset()),c.top+=ib.css(a[0],"borderTopWidth",!0),c.left+=ib.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-ib.css(d,"marginTop",!0),left:b.left-c.left-ib.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||W.documentElement;a&&!ib.nodeName(a,"html")&&"static"===ib.css(a,"position");)a=a.offsetParent;return a||W.documentElement})}}),ib.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);ib.fn[a]=function(e){return ib.access(this,function(a,e,f){var g=S(a);return f===b?g?c in g?g[c]:g.document.documentElement[e]:a[e]:(g?g.scrollTo(d?ib(g).scrollLeft():f,d?f:ib(g).scrollTop()):a[e]=f,b)},a,e,arguments.length,null)}}),ib.each({Height:"height",Width:"width"},function(a,c){ib.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,e){ib.fn[e]=function(e,f){var g=arguments.length&&(d||"boolean"!=typeof e),h=d||(e===!0||f===!0?"margin":"border");return ib.access(this,function(c,d,e){var f;return ib.isWindow(c)?c.document.documentElement["client"+a]:9===c.nodeType?(f=c.documentElement,Math.max(c.body["scroll"+a],f["scroll"+a],c.body["offset"+a],f["offset"+a],f["client"+a])):e===b?ib.css(c,d,h):ib.style(c,d,e,h)},c,g?e:b,g,null)}})}),a.jQuery=a.$=ib,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return ib})}(window);var jsfeat=jsfeat||{REVISION:"ALPHA"};!function(a){var b=1.192092896e-7,c=1e-37,d=256,e=512,f=1024,g=2048,h=4096,i=1,j=2,k=3,l=4,m=new Int32Array([-1,1,4,-1,4,-1,-1,-1,8,-1,-1,-1,-1,-1,-1,-1,8]),n=function(){return function(a){return 65280&a}}(),o=function(){return function(a){return 255&a}}(),p=function(){return function(a){return m[(65280&a)>>8]}}(),q=0,r=1,s=2,t=3,u=1,v=1,w=2,x=function(){function a(a,b){this.size=-8&(a+7|0),"undefined"==typeof b?this.buffer=new ArrayBuffer(this.size):(this.buffer=b,this.size=b.length),this.u8=new Uint8Array(this.buffer),this.i32=new Int32Array(this.buffer),this.f32=new Float32Array(this.buffer),this.f64=new Float64Array(this.buffer)}return a}(),y=function(){function a(a,b,c,g){this.type=0|n(c),this.channel=0|o(c),this.cols=0|a,this.rows=0|b,"undefined"==typeof g?this.allocate():(this.buffer=g,this.data=this.type&d?this.buffer.u8:this.type&e?this.buffer.i32:this.type&f?this.buffer.f32:this.buffer.f64)}return a.prototype.allocate=function(){delete this.data,delete this.buffer,this.buffer=new x(this.cols*p(this.type)*this.channel*this.rows),this.data=this.type&d?this.buffer.u8:this.type&e?this.buffer.i32:this.type&f?this.buffer.f32:this.buffer.f64},a.prototype.copy_to=function(a){for(var b=a.data,c=this.data,d=0,e=this.cols*this.rows*this.channel|0;e-4>d;d+=4)b[d]=c[d],b[d+1]=c[d+1],b[d+2]=c[d+2],b[d+3]=c[d+3];for(;e>d;++d)b[d]=c[d]},a.prototype.resize=function(a,b,c){"undefined"==typeof c&&(c=this.channel);var d=a*p(this.type)*c*b;d>this.buffer.size?(this.cols=a,this.rows=b,this.channel=c,this.allocate()):(this.cols=a,this.rows=b,this.channel=c)},a}(),z=function(){function a(a){this.levels=0|a,this.data=new Array(a),this.pyrdown=jsfeat.imgproc.pyrdown}return a.prototype.allocate=function(a,b,c){for(var d=this.levels;--d>=0;)this.data[d]=new y(a>>d,b>>d,c)},a.prototype.build=function(a,b){"undefined"==typeof b&&(b=!0);var c=2,d=a,e=this.data[0];if(!b)for(var f=a.cols*a.rows;--f>=0;)e.data[f]=a.data[f];for(e=this.data[1],this.pyrdown(d,e);c<this.levels;++c)d=e,e=this.data[c],this.pyrdown(d,e)},a}(),A=function(){function a(a,b,c,d,e){"undefined"==typeof a&&(a=0),"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=0),"undefined"==typeof d&&(d=0),"undefined"==typeof e&&(e=-1),this.x=a,this.y=b,this.score=c,this.level=d,this.angle=e}return a}();a.U8_t=d,a.S32_t=e,a.F32_t=f,a.S64_t=g,a.F64_t=h,a.C1_t=i,a.C2_t=j,a.C3_t=k,a.C4_t=l,a.U8C1_t=d|i,a.U8C3_t=d|k,a.U8C4_t=d|l,a.F32C1_t=f|i,a.F32C2_t=f|j,a.S32C1_t=e|i,a.S32C2_t=e|j,a.EPSILON=b,a.FLT_MIN=c,a.COLOR_RGBA2GRAY=q,a.COLOR_RGB2GRAY=r,a.COLOR_BGRA2GRAY=s,a.COLOR_BGR2GRAY=t,a.BOX_BLUR_NOSCALE=u,a.SVD_U_T=v,a.SVD_V_T=w,a.get_data_type=n,a.get_channel=o,a.get_data_type_size=p,a.data_t=x,a.matrix_t=y,a.pyramid_t=z,a.keypoint_t=A}(jsfeat),function(a){var b=function(){var a,b,c=function(){function a(a){this.next=null,this.data=new jsfeat.data_t(a),this.size=this.data.size,this.buffer=this.data.buffer,this.u8=this.data.u8,this.i32=this.data.i32,this.f32=this.data.f32,this.f64=this.data.f64}return a.prototype.resize=function(a){delete this.data,this.data=new jsfeat.data_t(a),this.size=this.data.size,this.buffer=this.data.buffer,this.u8=this.data.u8,this.i32=this.data.i32,this.f32=this.data.f32,this.f64=this.data.f64},a}(),d=0;return{allocate:function(e,f){a=b=new c(f);for(var g=0;e>g;++g){var h=new c(f);b=b.next=h,d++}},get_buffer:function(b){var c=a;return a=a.next,d--,b>c.size&&c.resize(b),c},put_buffer:function(a){b=b.next=a,d++}}}();a.cache=b,b.allocate(30,2560)}(jsfeat),function(a){var b=function(){var a=new Int32Array(96);return{get_gaussian_kernel:function(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=jsfeat.cache.get_buffer(a<<2),l=k.f32;if(1==(1&a)&&7>=a&&0>=b)switch(a>>1){case 0:l[0]=1,j=1;break;case 1:l[0]=.25,l[1]=.5,l[2]=.25,j=1;break;case 2:l[0]=.0625,l[1]=.25,l[2]=.375,l[3]=.25,l[4]=.0625,j=1;break;case 3:l[0]=.03125,l[1]=.109375,l[2]=.21875,l[3]=.28125,l[4]=.21875,l[5]=.109375,l[6]=.03125,j=1}else for(h=b>0?b:.3*(.5*(a-1)-1)+.8,i=-.5/(h*h);a>e;++e)f=e-.5*(a-1),g=Math.exp(i*f*f),l[e]=g,j+=g;if(d&jsfeat.U8_t)for(j=256/j,e=0;a>e;++e)c[e]=l[e]*j+.5|0;else for(j=1/j,e=0;a>e;++e)c[e]=l[e]*j;jsfeat.cache.put_buffer(k)},perspective_4point_transform:function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=b,s=j,t=g,u=r*s*t,v=o,w=r*v,x=s*w,y=k,z=r*y,A=f,B=c,C=n,D=B*C,E=D*A,F=C*A*y,G=C*t,H=C*y,I=s*t,J=v*s,K=v*A,L=y*A,M=1/(G-H-I+J-K+L),N=r*C,O=B*A,P=t*r,Q=v*P,R=B*s,S=D*y,T=B*y*A,U=t*v*s,V=v*B,W=-(x-u+z*A-A*w-D*s+E-F+G*s)*M,X=(u-x-N*t+N*y+E-s*O+K*s-F)*M,Y=r,Z=(-y*w+Q+R*t-D*t+S-T+K*y-U)*M,$=(-Q+P*y-V*s+S-T+V*A+U-G*y)*M,_=B,ab=(-z+P+R-O+H-G-J+K)*M,bb=(-w+z+D-R+K-L-G+I)*M;r=d,s=l,t=i,u=r*s*t,v=q,w=r*v,x=s*w,y=m,z=r*y,A=h,B=e,C=p,D=B*C,E=D*A,F=C*A*y,G=C*t,H=C*y,I=s*t,J=v*s,K=v*A,L=y*A,M=1/(G-H-I+J-K+L),N=r*C,O=B*A,P=t*r,Q=v*P,R=B*s,S=D*y,T=B*y*A,U=t*v*s,V=v*B;var cb=-(x-u+z*A-A*w-D*s+E-F+G*s)*M,db=(u-x-N*t+N*y+E-s*O+K*s-F)*M,eb=r,fb=(-y*w+Q+R*t-D*t+S-T+K*y-U)*M,gb=(-Q+P*y-V*s+S-T+V*A+U-G*y)*M,hb=B,ib=(-z+P+R-O+H-G-J+K)*M,jb=(-w+z+D-R+K-L-G+I)*M;s=$-bb*_,t=W*$,u=W*_,w=Z*X,x=Y*Z,z=X*ab;var kb=Y*ab;C=1/(t-u*bb-w+x*bb+z*_-kb*$),E=-Z+_*ab;var lb=-Z*bb+$*ab;L=-X+Y*bb;var mb=W-kb;O=W*bb-z,P=-X*_+Y*$;var nb=u-x,ob=t-w;T=s*C;var pb=L*C,qb=P*C,rb=a.data;rb[0]=cb*T+db*E*C-eb*lb*C,rb[1]=cb*pb+db*mb*C-eb*O*C,rb[2]=-cb*qb-db*nb*C+eb*ob*C,rb[3]=fb*T+gb*E*C-hb*lb*C,rb[4]=fb*pb+gb*mb*C-hb*O*C,rb[5]=-fb*qb-gb*nb*C+hb*ob*C,rb[6]=ib*T+jb*E*C-lb*C,rb[7]=ib*pb+jb*mb*C-O*C,rb[8]=-ib*qb-jb*nb*C+ob*C},qsort:function(b,c,d,e){var f,g,h,i,j=7,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=a;if(!(1>=d-c+1))for(C[0]=c,C[1]=d;k>=0;)for(l=C[k<<1],m=C[(k<<1)+1],k--;;){if(o=m-l+1,j>=o){for(q=l+1;m>=q;q++)for(r=q;r>l&&e(b[r],b[r-1]);r--)f=b[r],b[r]=b[r-1],b[r-1]=f;break}for(B=0,t=l,v=m,x=l+(o>>1),o>40&&(s=o>>3,y=l,z=l+s,A=l+(s<<1),g=b[y],h=b[z],i=b[A],l=e(g,h)?e(h,i)?z:e(g,i)?A:y:e(i,h)?z:e(g,i)?y:A,y=x-s,z=x,A=x+s,g=b[y],h=b[z],i=b[A],x=e(g,h)?e(h,i)?z:e(g,i)?A:y:e(i,h)?z:e(g,i)?y:A,y=m-(s<<1),z=m-s,A=m,g=b[y],h=b[z],i=b[A],m=e(g,h)?e(h,i)?z:e(g,i)?A:y:e(i,h)?z:e(g,i)?y:A),y=l,z=x,A=m,g=b[y],h=b[z],i=b[A],x=e(g,h)?e(h,i)?z:e(g,i)?A:y:e(i,h)?z:e(g,i)?y:A,x!=t&&(f=b[x],b[x]=b[t],b[t]=f,x=t),l=u=t+1,m=w=v,g=b[x];;){for(;m>=l&&!e(g,b[l]);)e(b[l],g)||(l>u&&(f=b[u],b[u]=b[l],b[l]=f),B=1,u++),l++;for(;m>=l&&!e(b[m],g);)e(g,b[m])||(w>m&&(f=b[w],b[w]=b[m],b[m]=f),B=1,w--),m--;if(l>m)break;f=b[l],b[l]=b[m],b[m]=f,B=1,l++,m--}if(0==B){for(l=t,m=v,q=l+1;m>=q;q++)for(r=q;r>l&&e(b[r],b[r-1]);r--)f=b[r],b[r]=b[r-1],b[r-1]=f;break}for(o=Math.min(u-t,l-u),p=l-o|0,n=0;o>n;++n,++p)f=b[t+n],b[t+n]=b[p],b[p]=f;for(o=Math.min(v-w,w-m),p=v-o+1|0,n=0;o>n;++n,++p)f=b[l+n],b[l+n]=b[p],b[p]=f;if(o=l-u,p=w-m,o>1)p>1?o>p?(++k,C[k<<1]=t,C[(k<<1)+1]=t+o-1,l=v-p+1,m=v):(++k,C[k<<1]=v-p+1,C[(k<<1)+1]=v,l=t,m=t+o-1):(l=t,m=t+o-1);else{if(!(p>1))break;l=v-p+1,m=v}}},median:function(a,b,c){for(var d,e=0,f=0,g=0,h=b+c>>1;;){if(b>=c)return a[h];if(c==b+1)return a[b]>a[c]&&(d=a[b],a[b]=a[c],a[c]=d),a[h];for(e=b+c>>1,a[e]>a[c]&&(d=a[e],a[e]=a[c],a[c]=d),a[b]>a[c]&&(d=a[b],a[b]=a[c],a[c]=d),a[e]>a[b]&&(d=a[e],a[e]=a[b],a[b]=d),f=b+1,d=a[e],a[e]=a[f],a[f]=d,g=c;;){do++f;while(a[b]>a[f]);do--g;while(a[g]>a[b]);if(f>g)break;d=a[f],a[f]=a[g],a[g]=d}d=a[b],a[b]=a[g],a[g]=d,h>=g?b=f:g>=h&&(c=g-1)}return 0}}}();a.math=b}(jsfeat),function(a){var b=function(){return{identity:function(a,b){"undefined"==typeof b&&(b=1);for(var c=a.data,d=a.rows,e=a.cols,f=e+1|0,g=d*e,h=g;--g>=0;)c[g]=0;for(g=h,h=0;g>h;)c[h]=b,h+=f},transpose:function(a,b){for(var c=0,d=0,e=b.rows,f=b.cols,g=0,h=0,i=0,j=b.data,k=a.data;e>c;h+=1,g+=f,c++)for(i=h,d=0;f>d;i+=e,d++)k[i]=j[g+d]},multiply:function(a,b,c){for(var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=b.cols,m=b.rows,n=c.cols,o=b.data,p=c.data,q=a.data,r=0;m>d;g+=l,d++)for(j=0,e=0;n>e;k++,j++,e++){for(i=j,h=g,r=0,f=0;l>f;h++,i+=n,f++)r+=o[h]*p[i];q[k]=r}},multiply_ABt:function(a,b,c){for(var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=b.cols,l=b.rows,m=c.rows,n=b.data,o=c.data,p=a.data,q=0;l>d;g+=k,d++)for(i=0,e=0;m>e;j++,e++){for(h=g,q=0,f=0;k>f;h++,i++,f++)q+=n[h]*o[i];p[j]=q}},multiply_AtB:function(a,b,c){for(var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=b.cols,m=b.rows,n=c.cols,o=b.data,p=c.data,q=a.data,r=0;l>d;g++,d++)for(j=0,e=0;n>e;k++,j++,e++){for(i=j,h=g,r=0,f=0;m>f;h+=l,i+=n,f++)r+=o[h]*p[i];q[k]=r}},multiply_AAt:function(a,b){for(var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=b.cols,m=b.rows,n=b.data,o=a.data,p=0;m>c;f+=m+1,g=h,c++)for(j=f,k=f,i=g,d=c;m>d;j++,k+=m,d++){for(h=g,p=0,e=0;l>e;e++)p+=n[h++]*n[i++];o[j]=p,o[k]=p}},multiply_AtA:function(a,b){for(var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=b.cols,m=b.rows,n=b.data,o=a.data,p=0;l>c;i+=l,c++)for(f=c,k=i+c,j=k,d=c;l>d;j++,k+=l,d++){for(g=f,h=d,p=0,e=0;m>e;g+=l,h+=l,e++)p+=n[g]*n[h];o[j]=p,o[k]=p}},identity_3x3:function(a,b){"undefined"==typeof b&&(b=1);var c=a.data;c[0]=c[4]=c[8]=b,c[1]=c[2]=c[3]=0,c[5]=c[6]=c[7]=0},invert_3x3:function(a,b){var c=a.data,d=b.data,e=c[4],f=c[8],g=c[5],h=c[7],i=c[0],j=i*e,k=i*g,l=c[3],m=c[1],n=l*m,o=c[2],p=l*o,q=c[6],r=q*m,s=q*o,t=1/(j*f-k*h-n*f+p*h+r*g-s*e);d[0]=(e*f-g*h)*t,d[1]=-(m*f-o*h)*t,d[2]=-(-m*g+o*e)*t,d[3]=-(l*f-g*q)*t,d[4]=(i*f-s)*t,d[5]=-(k-p)*t,d[6]=-(-l*h+e*q)*t,d[7]=-(i*h-r)*t,d[8]=(j-n)*t},multiply_3x3:function(a,b,c){var d=a.data,e=b.data,f=c.data,g=e[0],h=e[1],i=e[2],j=e[3],k=e[4],l=e[5],m=e[6],n=e[7],o=e[8],p=f[0],q=f[1],r=f[2],s=f[3],t=f[4],u=f[5],v=f[6],w=f[7],x=f[8];d[0]=g*p+h*s+i*v,d[1]=g*q+h*t+i*w,d[2]=g*r+h*u+i*x,d[3]=j*p+k*s+l*v,d[4]=j*q+k*t+l*w,d[5]=j*r+k*u+l*x,d[6]=m*p+n*s+o*v,d[7]=m*q+n*t+o*w,d[8]=m*r+n*u+o*x},mat3x3_determinant:function(a){var b=a.data;return b[0]*b[4]*b[8]-b[0]*b[5]*b[7]-b[3]*b[1]*b[8]+b[3]*b[2]*b[7]+b[6]*b[1]*b[5]-b[6]*b[2]*b[4]},determinant_3x3:function(a,b,c,d,e,f,g,h,i){return a*e*i-a*f*h-d*b*i+d*c*h+g*b*f-g*c*e}}}();a.matmath=b}(jsfeat),function(a){var b=function(){var a=function(a,b,c,d){d=a[b],a[b]=a[c],a[c]=d},b=function(a,b){return a=Math.abs(a),b=Math.abs(b),a>b?(b/=a,a*Math.sqrt(1+b*b)):b>0?(a/=b,b*Math.sqrt(1+a*a)):0},c=function(c,d,e,f,g,h){var i=jsfeat.EPSILON,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=h*h*30,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=jsfeat.cache.get_buffer(h<<2),D=jsfeat.cache.get_buffer(h<<2),E=C.i32,F=D.i32;if(f)for(;h>j;j++){for(l=j*g,k=0;h>k;k++)f[l+k]=0;f[l+j]=1}for(l=0;h>l;l++){if(e[l]=c[(d+1)*l],h-1>l){for(m=l+1,t=Math.abs(c[d*l+m]),j=l+2;h>j;j++)u=Math.abs(c[d*l+j]),u>t&&(t=u,m=j);E[l]=m}if(l>0){for(m=0,t=Math.abs(c[l]),j=1;l>j;j++)u=Math.abs(c[d*j+l]),u>t&&(t=u,m=j);F[l]=m}}if(h>1)for(;s>r;r++){for(l=0,t=Math.abs(c[E[0]]),j=1;h-1>j;j++)u=Math.abs(c[d*j+E[j]]),u>t&&(t=u,l=j);for(n=E[l],j=1;h>j;j++)u=Math.abs(c[d*F[j]+j]),u>t&&(t=u,l=F[j],n=j);if(v=c[d*l+n],Math.abs(v)<=i)break;for(w=.5*(e[n]-e[l]),x=Math.abs(w)+b(v,w),y=b(v,x),z=x/y,y=v/y,x=v/x*v,0>w&&(y=-y,x=-x),c[d*l+n]=0,e[l]-=x,e[n]+=x,j=0;l>j;j++)p=d*j+l,q=d*j+n,A=c[p],B=c[q],c[p]=A*z-B*y,c[q]=A*y+B*z;for(j=l+1;n>j;j++)p=d*l+j,q=d*j+n,A=c[p],B=c[q],c[p]=A*z-B*y,c[q]=A*y+B*z;for(j=n+1,p=d*l+j,q=d*n+j;h>j;j++,p++,q++)A=c[p],B=c[q],c[p]=A*z-B*y,c[q]=A*y+B*z;if(f)for(p=g*l,q=g*n,j=0;h>j;j++,p++,q++)A=f[p],B=f[q],f[p]=A*z-B*y,f[q]=A*y+B*z;for(k=0;2>k;k++){if(o=0==k?l:n,h-1>o){for(m=o+1,t=Math.abs(c[d*o+m]),j=o+2;h>j;j++)u=Math.abs(c[d*o+j]),u>t&&(t=u,m=j);E[o]=m}if(o>0){for(m=0,t=Math.abs(c[o]),j=1;o>j;j++)u=Math.abs(c[d*j+o]),u>t&&(t=u,m=j);F[o]=m}}}for(l=0;h-1>l;l++){for(m=l,j=l+1;h>j;j++)e[m]<e[j]&&(m=j);if(l!=m&&(a(e,m,l,t),f))for(j=0;h>j;j++)a(f,g*m+j,g*l+j,t)}jsfeat.cache.put_buffer(C),jsfeat.cache.put_buffer(D)},d=function(c,d,e,f,g,h,i,j){for(var k=2*jsfeat.EPSILON,l=jsfeat.FLT_MIN,m=0,n=0,o=0,p=0,q=Math.max(h,30),r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=4660,J=0,K=0,L=0,M=jsfeat.cache.get_buffer(i<<3),N=M.f64;i>m;m++){for(o=0,B=0;h>o;o++)y=c[m*d+o],B+=y*y;if(N[m]=B,f){for(o=0;i>o;o++)f[m*g+o]=0;f[m*g+m]=1}}for(;q>p;p++){for(v=0,m=0;i-1>m;m++)for(n=m+1;i>n;n++){for(r=m*d|0,s=n*d|0,F=N[m],G=0,H=N[n],o=2,G+=c[r]*c[s],G+=c[r+1]*c[s+1];h>o;o++)G+=c[r+o]*c[s+o];if(!(Math.abs(G)<=k*Math.sqrt(F*H))){for(G*=2,C=F-H,D=b(G,C),0>C?(E=.5*(D-C),x=Math.sqrt(E/D),w=G/(D*x*2)):(w=Math.sqrt((D+C)/(2*D)),x=G/(D*w*2)),F=0,H=0,o=2,z=w*c[r]+x*c[s],A=-x*c[r]+w*c[s],c[r]=z,c[s]=A,F+=z*z,H+=A*A,z=w*c[r+1]+x*c[s+1],A=-x*c[r+1]+w*c[s+1],c[r+1]=z,c[s+1]=A,F+=z*z,H+=A*A;h>o;o++)z=w*c[r+o]+x*c[s+o],A=-x*c[r+o]+w*c[s+o],c[r+o]=z,c[s+o]=A,F+=z*z,H+=A*A;if(N[m]=F,N[n]=H,v=1,f)for(t=m*g|0,u=n*g|0,o=2,z=w*f[t]+x*f[u],A=-x*f[t]+w*f[u],f[t]=z,f[u]=A,z=w*f[t+1]+x*f[u+1],A=-x*f[t+1]+w*f[u+1],f[t+1]=z,f[u+1]=A;i>o;o++)z=w*f[t+o]+x*f[u+o],A=-x*f[t+o]+w*f[u+o],f[t+o]=z,f[u+o]=A}}if(0==v)break}for(m=0;i>m;m++){for(o=0,B=0;h>o;o++)y=c[m*d+o],B+=y*y;N[m]=Math.sqrt(B)}for(m=0;i-1>m;m++){for(n=m,o=m+1;i>o;o++)N[n]<N[o]&&(n=o);if(m!=n&&(a(N,m,n,B),f)){for(o=0;h>o;o++)a(c,m*d+o,n*d+o,y);for(o=0;i>o;o++)a(f,m*g+o,n*g+o,y)}}for(m=0;i>m;m++)e[m]=N[m];if(!f)return void jsfeat.cache.put_buffer(M);for(m=0;j>m;m++){for(B=i>m?N[m]:0;l>=B;){for(K=1/h,o=0;h>o;o++)I=214013*I+2531011,J=0!=(I>>16&32767&256)?K:-K,c[m*d+o]=J;for(p=0;2>p;p++)for(n=0;m>n;n++){for(B=0,o=0;h>o;o++)B+=c[m*d+o]*c[n*d+o];for(L=0,o=0;h>o;o++)y=c[m*d+o]-B*c[n*d+o],c[m*d+o]=y,L+=Math.abs(y);for(L=L?1/L:0,o=0;h>o;o++)c[m*d+o]*=L}for(B=0,o=0;h>o;o++)y=c[m*d+o],B+=y*y;B=Math.sqrt(B)}for(x=1/B,o=0;h>o;o++)c[m*d+o]*=x}jsfeat.cache.put_buffer(M)};return{lu_solve:function(b,c){var d,e,f,g,h=0,i=0,j=0,k=1,l=b.cols,m=b.data,n=c.data;for(h=0;l>h;h++){for(j=h,i=h+1;l>i;i++)Math.abs(m[i*l+h])>Math.abs(m[j*l+h])&&(j=i);if(Math.abs(m[j*l+h])<jsfeat.EPSILON)return 0;if(j!=h){for(i=h;l>i;i++)a(m,h*l+i,j*l+i,d);a(n,h,j,d),k=-k}for(f=-1/m[h*l+h],i=h+1;l>i;i++){for(e=m[i*l+h]*f,j=h+1;l>j;j++)m[i*l+j]+=e*m[h*l+j];n[i]+=e*n[h]}m[h*l+h]=-f}for(h=l-1;h>=0;h--){for(g=n[h],j=h+1;l>j;j++)g-=m[h*l+j]*n[j];n[h]=g*m[h*l+h]}return 1},cholesky_solve:function(a,b){var c,d,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=a.cols,m=a.data,n=b.data;for(e=0;l>e;e++)for(d=1,h=e*l,i=h,f=e;l>f;f++){for(c=m[i+e],g=0;e>g;g++)c-=m[g*l+e]*m[i+g];if(f==e){if(m[i+e]=c,0==c)return 0;d=1/c}else m[h+f]=c,m[i+e]=c*d;i+=l}for(h=0,j=0;l>j;j++){for(c=n[j],k=0;j>k;k++)c-=m[h+k]*n[k];n[j]=c,h+=l}for(h=0,j=0;l>j;j++)n[j]/=m[h+j],h+=l;for(j=l-1;j>=0;j--){for(c=n[j],k=j+1,h=k*l;l>k;k++)c-=m[h+j]*n[k],h+=l;n[j]=c}return 1},svd_decompose:function(a,b,c,e,f){"undefined"==typeof f&&(f=0);var g=0,h=0,i=a.rows,j=a.cols,k=i,l=j,m=a.type|jsfeat.C1_t;l>k&&(g=1,h=k,k=l,l=h);var n=jsfeat.cache.get_buffer(k*k<<3),o=jsfeat.cache.get_buffer(l<<3),p=jsfeat.cache.get_buffer(l*l<<3),q=new jsfeat.matrix_t(k,k,m,n.data),r=new jsfeat.matrix_t(1,l,m,o.data),s=new jsfeat.matrix_t(l,l,m,p.data);if(0==g)jsfeat.matmath.transpose(q,a);else{for(h=0;j*i>h;h++)q.data[h]=a.data[h];for(;l*k>h;h++)q.data[h]=0}if(d(q.data,k,r.data,s.data,l,k,l,k),b){for(h=0;l>h;h++)b.data[h]=r.data[h];for(;j>h;h++)b.data[h]=0}if(0==g){if(c&&f&jsfeat.SVD_U_T)for(h=k*k;--h>=0;)c.data[h]=q.data[h];else c&&jsfeat.matmath.transpose(c,q);if(e&&f&jsfeat.SVD_V_T)for(h=l*l;--h>=0;)e.data[h]=s.data[h];else e&&jsfeat.matmath.transpose(e,s)}else{if(c&&f&jsfeat.SVD_U_T)for(h=l*l;--h>=0;)c.data[h]=s.data[h];else c&&jsfeat.matmath.transpose(c,s);if(e&&f&jsfeat.SVD_V_T)for(h=k*k;--h>=0;)e.data[h]=q.data[h];else e&&jsfeat.matmath.transpose(e,q)}jsfeat.cache.put_buffer(n),jsfeat.cache.put_buffer(o),jsfeat.cache.put_buffer(p)},svd_solve:function(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=a.rows,j=a.cols,k=0,l=0,m=0,n=a.type|jsfeat.C1_t,o=jsfeat.cache.get_buffer(i*i<<3),p=jsfeat.cache.get_buffer(j<<3),q=jsfeat.cache.get_buffer(j*j<<3),r=new jsfeat.matrix_t(i,i,n,o.data),s=new jsfeat.matrix_t(1,j,n,p.data),t=new jsfeat.matrix_t(j,j,n,q.data),u=c.data,v=r.data,w=s.data,x=t.data;for(this.svd_decompose(a,s,r,t,0),m=jsfeat.EPSILON*w[0]*j;j>d;d++,h+=j){for(l=0,e=0;j>e;e++)if(w[e]>m){for(f=0,k=0,g=0;i>f;f++,g+=j)k+=v[g+e]*u[f];l+=k*x[h+e]/w[e]}b.data[d]=l}jsfeat.cache.put_buffer(o),jsfeat.cache.put_buffer(p),jsfeat.cache.put_buffer(q)},svd_invert:function(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=b.rows,j=b.cols,k=0,l=0,m=b.type|jsfeat.C1_t,n=jsfeat.cache.get_buffer(i*i<<3),o=jsfeat.cache.get_buffer(j<<3),p=jsfeat.cache.get_buffer(j*j<<3),q=new jsfeat.matrix_t(i,i,m,n.data),r=new jsfeat.matrix_t(1,j,m,o.data),s=new jsfeat.matrix_t(j,j,m,p.data),t=a.data,u=q.data,v=r.data,w=s.data;for(this.svd_decompose(b,r,q,s,0),l=jsfeat.EPSILON*v[0]*j;j>c;c++,g+=j)for(d=0,f=0;i>d;d++,h++){for(e=0,k=0;j>e;e++,f++)v[e]>l&&(k+=w[g+e]*u[f]/v[e]);t[h]=k}jsfeat.cache.put_buffer(n),jsfeat.cache.put_buffer(o),jsfeat.cache.put_buffer(p)},eigenVV:function(a,b,d){for(var e=a.cols,f=e*e,g=a.type|jsfeat.C1_t,h=jsfeat.cache.get_buffer(e*e<<3),i=jsfeat.cache.get_buffer(e<<3),j=new jsfeat.matrix_t(e,e,g,h.data),k=new jsfeat.matrix_t(1,e,g,i.data);--f>=0;)j.data[f]=a.data[f];if(c(j.data,e,k.data,b?b.data:null,e,e),d)for(;--e>=0;)d.data[e]=k.data[e];jsfeat.cache.put_buffer(h),jsfeat.cache.put_buffer(i)}}}();a.linalg=b}(jsfeat),function(a){var b=function(){var a=function(a){return a*a},b=function(a,b,c,d,e){for(var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e>f;++f)g+=a[f].x,h+=a[f].y,k+=b[f].x,l+=b[f].y;for(g/=e,h/=e,k/=e,l/=e,f=0;e>f;++f)o=a[f].x-g,p=a[f].y-h,i+=Math.sqrt(o*o+p*p),o=b[f].x-k,p=b[f].y-l,m+=Math.sqrt(o*o+p*p);i/=e,m/=e,j=Math.SQRT2/i,n=Math.SQRT2/m,c[0]=c[4]=j,c[2]=-g*j,c[5]=-h*j,c[1]=c[3]=c[6]=c[7]=0,c[8]=1,d[0]=d[4]=n,d[2]=-k*n,d[5]=-l*n,d[1]=d[3]=d[6]=d[7]=0,d[8]=1},c=new jsfeat.matrix_t(3,3,jsfeat.F32_t|jsfeat.C1_t),d=new jsfeat.matrix_t(3,3,jsfeat.F32_t|jsfeat.C1_t),e=new jsfeat.matrix_t(6,6,jsfeat.F32_t|jsfeat.C1_t),f=new jsfeat.matrix_t(6,1,jsfeat.F32_t|jsfeat.C1_t),g=function(){function g(){}return g.prototype.run=function(a,g,h,i){var j,k,l=0,m=0,n=h.type|jsfeat.C1_t,o=h.data,p=c.data,q=d.data,r=0,s=0;b(a,g,p,q,i);for(var t=jsfeat.cache.get_buffer(2*i*6<<3),u=jsfeat.cache.get_buffer(2*i<<3),v=new jsfeat.matrix_t(6,2*i,n,t.data),w=new jsfeat.matrix_t(1,2*i,n,u.data),x=v.data,y=w.data;i>l;++l)j=a[l],k=g[l],r=p[0]*j.x+p[1]*j.y+p[2],s=p[3]*j.x+p[4]*j.y+p[5],m=2*l*6,x[m]=r,x[m+1]=s,x[m+2]=1,x[m+3]=0,x[m+4]=0,x[m+5]=0,m+=6,x[m]=0,x[m+1]=0,x[m+2]=0,x[m+3]=r,x[m+4]=s,x[m+5]=1,y[l<<1]=q[0]*k.x+q[1]*k.y+q[2],y[(l<<1)+1]=q[3]*k.x+q[4]*k.y+q[5];return jsfeat.matmath.multiply_AtA(e,v),jsfeat.matmath.multiply_AtB(f,v,w),jsfeat.linalg.lu_solve(e,f),o[0]=f.data[0],o[1]=f.data[1],o[2]=f.data[2],o[3]=f.data[3],o[4]=f.data[4],o[5]=f.data[5],o[6]=0,o[7]=0,o[8]=1,jsfeat.matmath.invert_3x3(d,d),jsfeat.matmath.multiply_3x3(h,d,h),jsfeat.matmath.multiply_3x3(h,h,c),jsfeat.cache.put_buffer(t),jsfeat.cache.put_buffer(u),1},g.prototype.error=function(b,c,d,e,f){for(var g,h,i=0,j=d.data;f>i;++i)g=b[i],h=c[i],e[i]=a(h.x-j[0]*g.x-j[1]*g.y-j[2])+a(h.y-j[3]*g.x-j[4]*g.y-j[5])},g.prototype.check_subset=function(){return!0},g}(),h=new jsfeat.matrix_t(9,9,jsfeat.F32_t|jsfeat.C1_t),i=new jsfeat.matrix_t(9,9,jsfeat.F32_t|jsfeat.C1_t),j=function(){function a(){}return a.prototype.run=function(a,b,e,f){for(var g=0,j=0,k=e.data,l=c.data,m=d.data,n=h.data,o=i.data,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;f>g;++g)v+=b[g].x,w+=b[g].y,z+=a[g].x,A+=a[g].y;for(v/=f,w/=f,z/=f,A/=f,g=0;f>g;++g)t+=Math.abs(b[g].x-v),u+=Math.abs(b[g].y-w),x+=Math.abs(a[g].x-z),y+=Math.abs(a[g].y-A);if(Math.abs(t)<jsfeat.EPSILON||Math.abs(u)<jsfeat.EPSILON||Math.abs(x)<jsfeat.EPSILON||Math.abs(y)<jsfeat.EPSILON)return 0;for(t=f/t,u=f/u,x=f/x,y=f/y,l[0]=x,l[1]=0,l[2]=-z*x,l[3]=0,l[4]=y,l[5]=-A*y,l[6]=0,l[7]=0,l[8]=1,m[0]=1/t,m[1]=0,m[2]=v,m[3]=0,m[4]=1/u,m[5]=w,m[6]=0,m[7]=0,m[8]=1,g=81;--g>=0;)n[g]=0;for(g=0;f>g;++g)p=(b[g].x-v)*t,q=(b[g].y-w)*u,r=(a[g].x-z)*x,s=(a[g].y-A)*y,n[0]+=r*r,n[1]+=r*s,n[2]+=r,n[6]+=r*-p*r,n[7]+=r*-p*s,n[8]+=r*-p,n[10]+=s*s,n[11]+=s,n[15]+=s*-p*r,n[16]+=s*-p*s,n[17]+=s*-p,n[20]+=1,n[24]+=-p*r,n[25]+=-p*s,n[26]+=-p,n[30]+=r*r,n[31]+=r*s,n[32]+=r,n[33]+=r*-q*r,n[34]+=r*-q*s,n[35]+=r*-q,n[40]+=s*s,n[41]+=s,n[42]+=s*-q*r,n[43]+=s*-q*s,n[44]+=s*-q,n[50]+=1,n[51]+=-q*r,n[52]+=-q*s,n[53]+=-q,n[60]+=-p*r*-p*r+-q*r*-q*r,n[61]+=-p*r*-p*s+-q*r*-q*s,n[62]+=-p*r*-p+-q*r*-q,n[70]+=-p*s*-p*s+-q*s*-q*s,n[71]+=-p*s*-p+-q*s*-q,n[80]+=-p*-p+-q*-q;for(g=0;9>g;++g)for(j=0;g>j;++j)n[9*g+j]=n[9*j+g];return jsfeat.linalg.eigenVV(h,i),k[0]=o[72],k[1]=o[73],k[2]=o[74],k[3]=o[75],k[4]=o[76],k[5]=o[77],k[6]=o[78],k[7]=o[79],k[8]=o[80],jsfeat.matmath.multiply_3x3(e,d,e),jsfeat.matmath.multiply_3x3(e,e,c),p=1/k[8],k[0]*=p,k[1]*=p,k[2]*=p,k[3]*=p,k[4]*=p,k[5]*=p,k[6]*=p,k[7]*=p,k[8]=1,1},a.prototype.error=function(a,b,c,d,e){for(var f,g,h=0,i=0,j=0,k=0,l=c.data;e>h;++h)f=a[h],g=b[h],i=1/(l[6]*f.x+l[7]*f.y+1),j=(l[0]*f.x+l[1]*f.y+l[2])*i-g.x,k=(l[3]*f.x+l[4]*f.y+l[5])*i-g.y,d[h]=j*j+k*k},a.prototype.check_subset=function(a,b,c){if(4==c){var d=0,e=a[0],f=a[1],g=a[2],h=a[3],i=b[0],j=b[1],k=b[2],l=b[3],m=e.x,n=e.y,o=1,p=f.x,q=f.y,r=1,s=g.x,t=g.y,u=1,v=i.x,w=i.y,x=1,y=j.x,z=j.y,A=1,B=k.x,C=k.y,D=1,E=jsfeat.matmath.determinant_3x3(m,n,o,p,q,r,s,t,u),F=jsfeat.matmath.determinant_3x3(v,w,x,y,z,A,B,C,D);if(0>E*F&&d++,m=f.x,n=f.y,p=g.x,q=g.y,s=h.x,t=h.y,v=j.x,w=j.y,y=k.x,z=k.y,B=l.x,C=l.y,E=jsfeat.matmath.determinant_3x3(m,n,o,p,q,r,s,t,u),F=jsfeat.matmath.determinant_3x3(v,w,x,y,z,A,B,C,D),0>E*F&&d++,m=e.x,n=e.y,p=g.x,q=g.y,s=h.x,t=h.y,v=i.x,w=i.y,y=k.x,z=k.y,B=l.x,C=l.y,E=jsfeat.matmath.determinant_3x3(m,n,o,p,q,r,s,t,u),F=jsfeat.matmath.determinant_3x3(v,w,x,y,z,A,B,C,D),0>E*F&&d++,m=e.x,n=e.y,p=f.x,q=f.y,s=h.x,t=h.y,v=i.x,w=i.y,y=j.x,z=j.y,B=l.x,C=l.y,E=jsfeat.matmath.determinant_3x3(m,n,o,p,q,r,s,t,u),F=jsfeat.matmath.determinant_3x3(v,w,x,y,z,A,B,C,D),0>E*F&&d++,0!=d&&4!=d)return!1}return!0},a}();return{affine2d:g,homography2d:j}}(),c=function(){function a(a,b,c,d){"undefined"==typeof a&&(a=0),"undefined"==typeof b&&(b=.5),"undefined"==typeof c&&(c=.5),"undefined"==typeof d&&(d=.99),this.size=a,this.thresh=b,this.eps=c,this.prob=d}return a.prototype.update_iters=function(a,b){var c=Math.log(1-this.prob),d=Math.log(1-Math.pow(1-a,this.size));return 0|(d>=0||-c>=b*-d?b:Math.round(c/d))},a}(),d=function(){var a=function(a,b,c,d,e,f,g){for(var h=1e3,i=[],j=0,k=0,l=0,m=0,n=!1;h>l;++l){for(j=0;d>j&&h>l;){for(n=!1,m=0;!n;)for(n=!0,m=i[j]=0|Math.floor(Math.random()*e),k=0;j>k;++k)if(m==i[k]){n=!1;break}f[j]=b[m],g[j]=c[m],a.check_subset(f,g,j+1)?++j:l++}break}return j==d&&h>l},b=function(a,b,c,d,e,f,g,h){var i=0,j=0,k=0,l=f*f;for(a.error(c,d,b,g,e);e>j;++j)k=g[j]<=l,h[j]=k,i+=k;return i};return{ransac:function(c,d,e,f,g,h,i,j){if("undefined"==typeof j&&(j=1e3),g<c.size)return!1;var k=c.size,l=j,m=0,n=!1,o=[],p=[],q=!1,r=h.cols,s=h.rows,t=h.type|jsfeat.C1_t,u=jsfeat.cache.get_buffer(r*s<<3),v=jsfeat.cache.get_buffer(g),w=jsfeat.cache.get_buffer(g<<2),x=new jsfeat.matrix_t(r,s,t,u.data),y=new jsfeat.matrix_t(g,1,jsfeat.U8C1_t,v.data),z=-1,A=0,B=0,C=w.f32;if(g==k){if(d.run(e,f,x,g)<=0)return jsfeat.cache.put_buffer(u),jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w),!1;if(x.copy_to(h),i)for(;--g>=0;)i.data[g]=1;return jsfeat.cache.put_buffer(u),jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w),!0}for(;l>m;++m){if(q=a(d,e,f,k,g,o,p),!q){if(0==m)return jsfeat.cache.put_buffer(u),jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w),!1;break}B=d.run(o,p,x,k),0>=B||(A=b(d,x,e,f,g,c.thresh,C,y.data),A>Math.max(z,k-1)&&(x.copy_to(h),z=A,i&&y.copy_to(i),l=c.update_iters((g-A)/g,l),n=!0))}return jsfeat.cache.put_buffer(u),jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w),n},lmeds:function(c,d,e,f,g,h,i,j){if("undefined"==typeof j&&(j=1e3),g<c.size)return!1;var k=c.size,l=j,m=0,n=!1,o=[],p=[],q=!1,r=h.cols,s=h.rows,t=h.type|jsfeat.C1_t,u=jsfeat.cache.get_buffer(r*s<<3),v=jsfeat.cache.get_buffer(g),w=jsfeat.cache.get_buffer(g<<2),x=new jsfeat.matrix_t(r,s,t,u.data),y=new jsfeat.matrix_t(g,1,jsfeat.U8_t|jsfeat.C1_t,v.data),z=0,A=0,B=w.f32,C=1e9,D=0,E=0;if(c.eps=.45,l=c.update_iters(c.eps,l),g==k){if(d.run(e,f,x,g)<=0)return jsfeat.cache.put_buffer(u),jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w),!1;if(x.copy_to(h),i)for(;--g>=0;)i.data[g]=1;return jsfeat.cache.put_buffer(u),jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w),!0}for(;l>m;++m){if(q=a(d,e,f,k,g,o,p),!q){if(0==m)return jsfeat.cache.put_buffer(u),jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w),!1;break}A=d.run(o,p,x,k),0>=A||(d.error(e,f,x,B,g),E=jsfeat.math.median(B,0,g-1),C>E&&(C=E,x.copy_to(h),n=!0))}return n&&(D=2.5*1.4826*(1+5/(g-k))*Math.sqrt(C),D=Math.max(D,.001),z=b(d,h,e,f,g,D,B,y.data),i&&y.copy_to(i),n=z>=k),jsfeat.cache.put_buffer(u),jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w),n}}}();a.ransac_params_t=c,a.motion_model=b,a.motion_estimator=d}(jsfeat),function(a){var b=function(){var a=function(a,b,c,d){for(var e=0,f=a.channel,g=a.cols,h=a.rows,i=a.data,j=b.data,k=g/c,l=h/d,m=k*l*65536|0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=jsfeat.cache.get_buffer(c*f<<2),E=jsfeat.cache.get_buffer(c*f<<2),F=jsfeat.cache.get_buffer(2*g*3<<2),G=D.i32,H=E.i32,I=F.i32;c>n;n++){for(v=n*k,w=v+k,r=v+1-1e-6|0,s=0|w,r=Math.min(r,g-1),s=Math.min(s,g-1),r>v&&(I[u++]=n*f|0,I[u++]=(r-1)*f|0,I[u++]=256*(r-v)|0,e++),p=r;s>p;p++)e++,I[u++]=n*f|0,I[u++]=p*f|0,I[u++]=256;
w-s>.001&&(e++,I[u++]=n*f|0,I[u++]=s*f|0,I[u++]=256*(w-s)|0)}for(n=0;c*f>n;n++)G[n]=H[n]=0;for(o=0,q=0;h>q;q++){for(x=g*q,u=0;e>u;u++)for(z=I[3*u],r=I[3*u+1],A=I[3*u+2],t=0;f>t;t++)G[z+t]+=i[x+r+t]*A;if(q+1>=(o+1)*l||q==h-1){if(B=256*Math.max(q+1-(o+1)*l,0)|0,C=256-B,y=c*o,0>=B)for(n=0;c*f>n;n++)j[y+n]=Math.min(Math.max((H[n]+256*G[n])/m,0),255),H[n]=G[n]=0;else for(n=0;c*f>n;n++)j[y+n]=Math.min(Math.max((H[n]+G[n]*C)/m,0),255),H[n]=G[n]*B,G[n]=0;o++}else for(n=0;c*f>n;n++)H[n]+=256*G[n],G[n]=0}jsfeat.cache.put_buffer(E),jsfeat.cache.put_buffer(D),jsfeat.cache.put_buffer(F)},b=function(a,b,c,d){for(var e=0,f=a.channel,g=a.cols,h=a.rows,i=a.data,j=b.data,k=g/c,l=h/d,m=1/(k*l),n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=jsfeat.cache.get_buffer(c*f<<2),E=jsfeat.cache.get_buffer(c*f<<2),F=jsfeat.cache.get_buffer(2*g*3<<2),G=D.f32,H=E.f32,I=F.f32;c>n;n++){for(v=n*k,w=v+k,r=v+1-1e-6|0,s=0|w,r=Math.min(r,g-1),s=Math.min(s,g-1),r>v&&(e++,I[u++]=(r-1)*f|0,I[u++]=n*f|0,I[u++]=(r-v)*m),p=r;s>p;p++)e++,I[u++]=p*f|0,I[u++]=n*f|0,I[u++]=m;w-s>.001&&(e++,I[u++]=s*f|0,I[u++]=n*f|0,I[u++]=(w-s)*m)}for(n=0;c*f>n;n++)G[n]=H[n]=0;for(o=0,q=0;h>q;q++){for(x=g*q,u=0;e>u;u++)for(r=0|I[3*u],z=0|I[3*u+1],A=I[3*u+2],t=0;f>t;t++)G[z+t]+=i[x+r+t]*A;if(q+1>=(o+1)*l||q==h-1){if(B=Math.max(q+1-(o+1)*l,0),C=1-B,y=c*o,Math.abs(B)<.001)for(n=0;c*f>n;n++)j[y+n]=H[n]+G[n],H[n]=G[n]=0;else for(n=0;c*f>n;n++)j[y+n]=H[n]+G[n]*C,H[n]=G[n]*B,G[n]=0;o++}else for(n=0;c*f>n;n++)H[n]+=G[n],G[n]=0}jsfeat.cache.put_buffer(E),jsfeat.cache.put_buffer(D),jsfeat.cache.put_buffer(F)},c=function(a,b,c,d,e,f,g,h){for(var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=f[0],s=0,t=d<<1,u=3*d,v=d<<2;e>i;++i){for(n=b[l],j=0;h>j;++j)a[j]=n;for(j=0;d-2>=j;j+=2)a[j+h]=b[l+j],a[j+h+1]=b[l+j+1];for(;d>j;++j)a[j+h]=b[l+j];for(n=b[l+d-1],j=d;h+d>j;++j)a[j+h]=n;for(j=0;d-4>=j;j+=4){for(n=a[j]*r,o=a[j+1]*r,p=a[j+2]*r,q=a[j+3]*r,k=1;g>k;++k)s=f[k],n+=a[k+j]*s,o+=a[k+j+1]*s,p+=a[k+j+2]*s,q+=a[k+j+3]*s;c[m+j]=Math.min(n>>8,255),c[m+j+1]=Math.min(o>>8,255),c[m+j+2]=Math.min(p>>8,255),c[m+j+3]=Math.min(q>>8,255)}for(;d>j;++j){for(n=a[j]*r,k=1;g>k;++k)n+=a[k+j]*f[k];c[m+j]=Math.min(n>>8,255)}l+=d,m+=d}for(i=0;d>i;++i){for(n=c[i],j=0;h>j;++j)a[j]=n;for(k=i,j=0;e-2>=j;j+=2,k+=t)a[j+h]=c[k],a[j+h+1]=c[k+d];for(;e>j;++j,k+=d)a[j+h]=c[k];for(n=c[(e-1)*d+i],j=e;h+e>j;++j)a[j+h]=n;for(m=i,j=0;e-4>=j;j+=4,m+=v){for(n=a[j]*r,o=a[j+1]*r,p=a[j+2]*r,q=a[j+3]*r,k=1;g>k;++k)s=f[k],n+=a[k+j]*s,o+=a[k+j+1]*s,p+=a[k+j+2]*s,q+=a[k+j+3]*s;c[m]=Math.min(n>>8,255),c[m+d]=Math.min(o>>8,255),c[m+t]=Math.min(p>>8,255),c[m+u]=Math.min(q>>8,255)}for(;e>j;++j,m+=d){for(n=a[j]*r,k=1;g>k;++k)n+=a[k+j]*f[k];c[m]=Math.min(n>>8,255)}}},d=function(a,b,c,d,e,f,g,h){for(var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=f[0],s=0,t=d<<1,u=3*d,v=d<<2;e>i;++i){for(n=b[l],j=0;h>j;++j)a[j]=n;for(j=0;d-2>=j;j+=2)a[j+h]=b[l+j],a[j+h+1]=b[l+j+1];for(;d>j;++j)a[j+h]=b[l+j];for(n=b[l+d-1],j=d;h+d>j;++j)a[j+h]=n;for(j=0;d-4>=j;j+=4){for(n=a[j]*r,o=a[j+1]*r,p=a[j+2]*r,q=a[j+3]*r,k=1;g>k;++k)s=f[k],n+=a[k+j]*s,o+=a[k+j+1]*s,p+=a[k+j+2]*s,q+=a[k+j+3]*s;c[m+j]=n,c[m+j+1]=o,c[m+j+2]=p,c[m+j+3]=q}for(;d>j;++j){for(n=a[j]*r,k=1;g>k;++k)n+=a[k+j]*f[k];c[m+j]=n}l+=d,m+=d}for(i=0;d>i;++i){for(n=c[i],j=0;h>j;++j)a[j]=n;for(k=i,j=0;e-2>=j;j+=2,k+=t)a[j+h]=c[k],a[j+h+1]=c[k+d];for(;e>j;++j,k+=d)a[j+h]=c[k];for(n=c[(e-1)*d+i],j=e;h+e>j;++j)a[j+h]=n;for(m=i,j=0;e-4>=j;j+=4,m+=v){for(n=a[j]*r,o=a[j+1]*r,p=a[j+2]*r,q=a[j+3]*r,k=1;g>k;++k)s=f[k],n+=a[k+j]*s,o+=a[k+j+1]*s,p+=a[k+j+2]*s,q+=a[k+j+3]*s;c[m]=n,c[m+d]=o,c[m+t]=p,c[m+u]=q}for(;e>j;++j,m+=d){for(n=a[j]*r,k=1;g>k;++k)n+=a[k+j]*f[k];c[m]=n}}};return{grayscale:function(a,b,c,d,e){"undefined"==typeof e&&(e=jsfeat.COLOR_RGBA2GRAY);var f=0,g=0,h=0,i=0,j=0,k=0,l=4899,m=9617,n=1868,o=4;(e==jsfeat.COLOR_BGRA2GRAY||e==jsfeat.COLOR_BGR2GRAY)&&(l=1868,n=4899),(e==jsfeat.COLOR_RGB2GRAY||e==jsfeat.COLOR_BGR2GRAY)&&(o=3);var p=o<<1,q=3*o|0;d.resize(b,c,1);var r=d.data;for(g=0;c>g;++g,i+=b,h+=b*o){for(f=0,j=h,k=i;b-4>=f;f+=4,j+=o<<2,k+=4)r[k]=a[j]*l+a[j+1]*m+a[j+2]*n+8192>>14,r[k+1]=a[j+o]*l+a[j+o+1]*m+a[j+o+2]*n+8192>>14,r[k+2]=a[j+p]*l+a[j+p+1]*m+a[j+p+2]*n+8192>>14,r[k+3]=a[j+q]*l+a[j+q+1]*m+a[j+q+2]*n+8192>>14;for(;b>f;++f,++k,j+=o)r[k]=a[j]*l+a[j+1]*m+a[j+2]*n+8192>>14}},resample:function(c,d,e,f){var g=c.rows,h=c.cols;g>f&&h>e&&(d.resize(e,f,c.channel),c.type&jsfeat.U8_t&&d.type&jsfeat.U8_t&&256>g*h/(f*e)?a(c,d,e,f):b(c,d,e,f))},box_blur_gray:function(a,b,c,d){"undefined"==typeof d&&(d=0);var e=a.cols,f=a.rows,g=f<<1,h=e<<1,i=0,j=0,k=0,l=0,m=(c<<1)+1|0,n=c+1|0,o=n+1|0,p=d&jsfeat.BOX_BLUR_NOSCALE?1:1/(m*m),q=jsfeat.cache.get_buffer(e*f<<2),r=0,s=0,t=0,u=0,v=0,w=q.i32,x=a.data,y=0;for(b.resize(e,f,a.channel),k=0;f>k;++k){for(s=k,r=n*x[t],i=t+1|0,l=t+c|0;l>=i;++i)r+=x[i];for(u=t+n|0,v=t,y=x[v],j=0;c>j;++j,s+=f)w[s]=r,r+=x[u]-y,u++;for(;e-o>j;j+=2,s+=g)w[s]=r,r+=x[u]-x[v],w[s+f]=r,r+=x[u+1]-x[v+1],u+=2,v+=2;for(;e-n>j;++j,s+=f)w[s]=r,r+=x[u]-x[v],u++,v++;for(y=x[u-1];e>j;++j,s+=f)w[s]=r,r+=y-x[v],v++;t+=e}if(t=0,x=b.data,1==p)for(k=0;e>k;++k){for(s=k,r=n*w[t],i=t+1|0,l=t+c|0;l>=i;++i)r+=w[i];for(u=t+n,v=t,y=w[v],j=0;c>j;++j,s+=e)x[s]=r,r+=w[u]-y,u++;for(;f-o>j;j+=2,s+=h)x[s]=r,r+=w[u]-w[v],x[s+e]=r,r+=w[u+1]-w[v+1],u+=2,v+=2;for(;f-n>j;++j,s+=e)x[s]=r,r+=w[u]-w[v],u++,v++;for(y=w[u-1];f>j;++j,s+=e)x[s]=r,r+=y-w[v],v++;t+=f}else for(k=0;e>k;++k){for(s=k,r=n*w[t],i=t+1|0,l=t+c|0;l>=i;++i)r+=w[i];for(u=t+n,v=t,y=w[v],j=0;c>j;++j,s+=e)x[s]=r*p,r+=w[u]-y,u++;for(;f-o>j;j+=2,s+=h)x[s]=r*p,r+=w[u]-w[v],x[s+e]=r*p,r+=w[u+1]-w[v+1],u+=2,v+=2;for(;f-n>j;++j,s+=e)x[s]=r*p,r+=w[u]-w[v],u++,v++;for(y=w[u-1];f>j;++j,s+=e)x[s]=r*p,r+=y-w[v],v++;t+=f}jsfeat.cache.put_buffer(q)},gaussian_blur:function(a,b,e,f){"undefined"==typeof f&&(f=0),"undefined"==typeof e&&(e=0),e=0==e?2*Math.max(1,4*f+1-1e-8)+1|0:e;var g=e>>1,h=a.cols,i=a.rows,j=a.type,k=j&jsfeat.U8_t;b.resize(h,i,a.channel);var l,m,n=a.data,o=b.data,p=e+Math.max(i,h)|0,q=jsfeat.cache.get_buffer(p<<2),r=jsfeat.cache.get_buffer(e<<2);k?(l=q.i32,m=r.i32):j&jsfeat.S32_t?(l=q.i32,m=r.f32):(l=q.f32,m=r.f32),jsfeat.math.get_gaussian_kernel(e,f,m,j),k?c(l,n,o,h,i,m,e,g):d(l,n,o,h,i,m,e,g),jsfeat.cache.put_buffer(q),jsfeat.cache.put_buffer(r)},pyrdown:function(a,b,c,d){"undefined"==typeof c&&(c=0),"undefined"==typeof d&&(d=0);var e=a.cols,f=a.rows,g=e>>1,h=f>>1,i=g-(c<<1),j=h-(d<<1),k=0,l=0,m=c+d*e,n=0,o=0,p=0;b.resize(g,h,a.channel);var q=a.data,r=b.data;for(l=0;j>l;++l){for(n=m,p=o,k=0;i-2>=k;k+=2,p+=2,n+=4)r[p]=q[n]+q[n+1]+q[n+e]+q[n+e+1]+2>>2,r[p+1]=q[n+2]+q[n+3]+q[n+e+2]+q[n+e+3]+2>>2;for(;i>k;++k,++p,n+=2)r[p]=q[n]+q[n+1]+q[n+e]+q[n+e+1]+2>>2;m+=e<<1,o+=g}},scharr_derivatives:function(a,b){var c,d,e,f,g,h,i,j,k=a.cols,l=a.rows,m=k<<1,n=0,o=0,p=0,q=0,r=0,s=0,t=0;b.resize(k,l,2);var u=a.data,v=b.data,w=jsfeat.cache.get_buffer(k+2<<2),x=jsfeat.cache.get_buffer(k+2<<2);for(a.type&jsfeat.U8_t||a.type&jsfeat.S32_t?(i=w.i32,j=x.i32):(i=w.f32,j=x.f32);l>o;++o,r+=k){for(q=(o>0?o-1:1)*k|0,s=(l-1>o?o+1:l-2)*k|0,t=o*m|0,n=0,p=1;k-2>=n;n+=2,p+=2)c=u[q+n],d=u[s+n],i[p]=3*(c+d)+10*u[r+n],j[p]=d-c,c=u[q+n+1],d=u[s+n+1],i[p+1]=3*(c+d)+10*u[r+n+1],j[p+1]=d-c;for(;k>n;++n,++p)c=u[q+n],d=u[s+n],i[p]=3*(c+d)+10*u[r+n],j[p]=d-c;for(n=k+1|0,i[0]=i[1],i[n]=i[k],j[0]=j[1],j[n]=j[k],n=0;k-4>=n;n+=4)c=j[n+2],d=j[n+1],e=j[n+3],f=j[n+4],g=i[n+2],h=i[n+3],v[t++]=g-i[n],v[t++]=3*(c+j[n])+10*d,v[t++]=h-i[n+1],v[t++]=3*(e+d)+10*c,v[t++]=i[n+4]-g,v[t++]=3*(f+c)+10*e,v[t++]=i[n+5]-h,v[t++]=3*(j[n+5]+e)+10*f;for(;k>n;++n)v[t++]=i[n+2]-i[n],v[t++]=3*(j[n+2]+j[n])+10*j[n+1]}jsfeat.cache.put_buffer(w),jsfeat.cache.put_buffer(x)},sobel_derivatives:function(a,b){var c,d,e,f,g,h,i,j,k=a.cols,l=a.rows,m=k<<1,n=0,o=0,p=0,q=0,r=0,s=0,t=0;b.resize(k,l,2);var u=a.data,v=b.data,w=jsfeat.cache.get_buffer(k+2<<2),x=jsfeat.cache.get_buffer(k+2<<2);for(a.type&jsfeat.U8_t||a.type&jsfeat.S32_t?(i=w.i32,j=x.i32):(i=w.f32,j=x.f32);l>o;++o,r+=k){for(q=(o>0?o-1:1)*k|0,s=(l-1>o?o+1:l-2)*k|0,t=o*m|0,n=0,p=1;k-2>=n;n+=2,p+=2)c=u[q+n],d=u[s+n],i[p]=c+d+2*u[r+n],j[p]=d-c,c=u[q+n+1],d=u[s+n+1],i[p+1]=c+d+2*u[r+n+1],j[p+1]=d-c;for(;k>n;++n,++p)c=u[q+n],d=u[s+n],i[p]=c+d+2*u[r+n],j[p]=d-c;for(n=k+1|0,i[0]=i[1],i[n]=i[k],j[0]=j[1],j[n]=j[k],n=0;k-4>=n;n+=4)c=j[n+2],d=j[n+1],e=j[n+3],f=j[n+4],g=i[n+2],h=i[n+3],v[t++]=g-i[n],v[t++]=c+j[n]+2*d,v[t++]=h-i[n+1],v[t++]=e+d+2*c,v[t++]=i[n+4]-g,v[t++]=f+c+2*e,v[t++]=i[n+5]-h,v[t++]=j[n+5]+e+2*f;for(;k>n;++n)v[t++]=i[n+2]-i[n],v[t++]=j[n+2]+j[n]+2*j[n+1]}jsfeat.cache.put_buffer(w),jsfeat.cache.put_buffer(x)},compute_integral_image:function(a,b,c,d){var e=0|a.cols,f=0|a.rows,g=a.data,h=e+1|0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(b&&c){for(;h>m;++m)b[m]=0,c[m]=0;for(k=h+1|0,l=1,m=0,p=0;f>m;++m,++k,++l){for(i=j=0,n=0;e-2>=n;n+=2,p+=2,k+=2,l+=2)o=g[p],i+=o,j+=o*o,b[k]=b[l]+i,c[k]=c[l]+j,o=g[p+1],i+=o,j+=o*o,b[k+1]=b[l+1]+i,c[k+1]=c[l+1]+j;for(;e>n;++n,++p,++k,++l)o=g[p],i+=o,j+=o*o,b[k]=b[l]+i,c[k]=c[l]+j}}else if(b){for(;h>m;++m)b[m]=0;for(k=h+1|0,l=1,m=0,p=0;f>m;++m,++k,++l){for(i=0,n=0;e-2>=n;n+=2,p+=2,k+=2,l+=2)i+=g[p],b[k]=b[l]+i,i+=g[p+1],b[k+1]=b[l+1]+i;for(;e>n;++n,++p,++k,++l)i+=g[p],b[k]=b[l]+i}}else if(c){for(;h>m;++m)c[m]=0;for(k=h+1|0,l=1,m=0,p=0;f>m;++m,++k,++l){for(j=0,n=0;e-2>=n;n+=2,p+=2,k+=2,l+=2)o=g[p],j+=o*o,c[k]=c[l]+j,o=g[p+1],j+=o*o,c[k+1]=c[l+1]+j;for(;e>n;++n,++p,++k,++l)o=g[p],j+=o*o,c[k]=c[l]+j}}if(d){for(m=0;h>m;++m)d[m]=0;for(k=h+1|0,l=0,m=0,p=0;f>m;++m,++k,++l){for(n=0;e-2>=n;n+=2,p+=2,k+=2,l+=2)d[k]=g[p]+d[l],d[k+1]=g[p+1]+d[l+1];for(;e>n;++n,++p,++k,++l)d[k]=g[p]+d[l]}for(k=h+e|0,l=e,m=0;f>m;++m,k+=h,l+=h)d[k]+=d[l];for(n=e-1;n>0;--n)for(k=n+f*h,l=k-h,m=f;m>0;--m,k-=h,l-=h)d[k]+=d[l]+d[l+1]}},equalize_histogram:function(a,b){var c=a.cols,d=a.rows,e=a.data;b.resize(c,d,a.channel);var f,g,h=b.data,i=c*d,j=0,k=0,l=jsfeat.cache.get_buffer(1024);for(f=l.i32;256>j;++j)f[j]=0;for(j=0;i>j;++j)++f[e[j]];for(k=f[0],j=1;256>j;++j)k=f[j]+=k;for(g=255/i,j=0;i>j;++j)h[j]=f[e[j]]*g+.5|0;jsfeat.cache.put_buffer(l)},canny:function(a,b,c,d){{var e=a.cols,f=a.rows;a.data}b.resize(e,f,a.channel);var g=b.data,h=0,i=0,j=0,k=e<<1,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=jsfeat.cache.get_buffer(f*k<<2),u=jsfeat.cache.get_buffer(3*(e+2)<<2),v=jsfeat.cache.get_buffer((f+2)*(e+2)<<2),w=jsfeat.cache.get_buffer(f*e<<2),x=u.i32,y=v.i32,z=w.i32,A=t.i32,B=new jsfeat.matrix_t(e,f,jsfeat.S32C2_t,t.data),C=1,D=e+2+1|0,E=2*(e+2)+1|0,F=e+2|0,G=F+1|0,H=0;for(this.sobel_derivatives(a,B),c>d&&(h=c,c=d,d=h),h=3*(e+2)|0;--h>=0;)x[h]=0;for(h=(f+2)*(e+2)|0;--h>=0;)y[h]=0;for(;e>i;++i,j+=2)o=A[j],p=A[j+1],x[D+i]=(o^o>>31)-(o>>31)+((p^p>>31)-(p>>31));for(h=1;f>=h;++h,j+=k){if(h==f)for(i=E+e;--i>=E;)x[i]=0;else for(i=0;e>i;i++)o=A[j+(i<<1)],p=A[j+(i<<1)+1],x[E+i]=(o^o>>31)-(o>>31)+((p^p>>31)-(p>>31));for(l=j-k|0,y[G-1]=0,m=0,i=0;e>i;++i,l+=2){if(n=x[D+i],n>c)if(o=A[l],p=A[l+1],q=o^p,o=(o^o>>31)-(o>>31)|0,p=(p^p>>31)-(p>>31)|0,r=13573*o,s=r+(o+o<<15),p<<=15,r>p){if(n>x[D+i-1]&&n>=x[D+i+1]){n>d&&!m&&2!=y[G+i-F]?(y[G+i]=2,m=1,z[H++]=G+i):y[G+i]=1;continue}}else if(p>s){if(n>x[C+i]&&n>=x[E+i]){n>d&&!m&&2!=y[G+i-F]?(y[G+i]=2,m=1,z[H++]=G+i):y[G+i]=1;continue}}else if(q=0>q?-1:1,n>x[C+i-q]&&n>x[E+i+q]){n>d&&!m&&2!=y[G+i-F]?(y[G+i]=2,m=1,z[H++]=G+i):y[G+i]=1;continue}y[G+i]=0,m=0}y[G+e]=0,G+=F,i=C,C=D,D=E,E=i}for(i=G-F-1,h=0;F>h;++h,++i)y[i]=0;for(;H>0;)G=z[--H],G-=F+1,1==y[G]&&(y[G]=2,z[H++]=G),G+=1,1==y[G]&&(y[G]=2,z[H++]=G),G+=1,1==y[G]&&(y[G]=2,z[H++]=G),G+=F,1==y[G]&&(y[G]=2,z[H++]=G),G-=2,1==y[G]&&(y[G]=2,z[H++]=G),G+=F,1==y[G]&&(y[G]=2,z[H++]=G),G+=1,1==y[G]&&(y[G]=2,z[H++]=G),G+=1,1==y[G]&&(y[G]=2,z[H++]=G);for(G=F+1,C=0,h=0;f>h;++h,G+=F)for(i=0;e>i;++i)g[C++]=255*(2==y[G+i]);jsfeat.cache.put_buffer(t),jsfeat.cache.put_buffer(u),jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w)},warp_perspective:function(a,b,c,d){"undefined"==typeof d&&(d=0);for(var e=0|a.cols,f=0|a.rows,g=0|b.cols,h=0|b.rows,i=a.data,j=b.data,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=c.data,A=z[0],B=z[1],C=z[2],D=z[3],E=z[4],F=z[5],G=z[6],H=z[7],I=z[8],J=0;h>l;++l)for(r=B*l+C,s=E*l+F,t=H*l+I,k=0;g>k;++k,++J,r+=A,s+=D,t+=G)u=1/t,p=r*u,q=s*u,n=0|p,o=0|q,p>0&&q>0&&e-1>n&&f-1>o?(v=Math.max(p-n,0),w=Math.max(q-o,0),m=e*o+n|0,x=i[m]+v*(i[m+1]-i[m]),y=i[m+e]+v*(i[m+e+1]-i[m+e]),j[J]=x+w*(y-x)):j[J]=d},warp_affine:function(a,b,c,d){"undefined"==typeof d&&(d=0);for(var e=a.cols,f=a.rows,g=b.cols,h=b.rows,i=a.data,j=b.data,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=c.data,w=v[0],x=v[1],y=v[2],z=v[3],A=v[4],B=v[5],C=0;h>l;++l)for(p=x*l+y,q=A*l+B,k=0;g>k;++k,++C,p+=w,q+=z)n=0|p,o=0|q,n>=0&&o>=0&&e-1>n&&f-1>o?(r=p-n,s=q-o,m=e*o+n,t=i[m]+r*(i[m+1]-i[m]),u=i[m+e]+r*(i[m+e+1]-i[m+e]),j[C]=t+s*(u-t)):j[C]=d},skindetector:function(a,b){for(var c,d,e,f,g=a.width*a.height;g--;)f=4*g,c=a.data[f],d=a.data[f+1],e=a.data[f+2],b[g]=c>95&&d>40&&e>20&&c>d&&c>e&&c-Math.min(d,e)>15&&Math.abs(c-d)>15?255:0}}}();a.imgproc=b}(jsfeat),function(a){var b=function(){var a=new Int32Array([0,3,1,3,2,2,3,1,3,0,3,-1,2,-2,1,-3,0,-3,-1,-3,-2,-2,-3,-1,-3,0,-3,1,-2,2,-1,3]),b=new Uint8Array(512),c=new Int32Array(25),d=new Int32Array(25),e=function(b,c,d){for(var e=0,f=a;d>e;++e)b[e]=f[e<<1]+f[(e<<1)+1]*c;for(;25>e;++e)b[e]=b[e-d]},f=function(a,b,c,d,e){for(var f=25,g=0,h=a[b],i=e,j=0,k=0,l=0;f>g;++g)d[g]=h-a[b+c[g]];for(g=0;16>g;g+=2)j=Math.min(d[g+1],d[g+2]),j=Math.min(j,d[g+3]),i>=j||(j=Math.min(j,d[g+4]),j=Math.min(j,d[g+5]),j=Math.min(j,d[g+6]),j=Math.min(j,d[g+7]),j=Math.min(j,d[g+8]),i=Math.max(i,Math.min(j,d[g])),i=Math.max(i,Math.min(j,d[g+9])));for(k=-i,g=0;16>g;g+=2)l=Math.max(d[g+1],d[g+2]),l=Math.max(l,d[g+3]),l=Math.max(l,d[g+4]),l=Math.max(l,d[g+5]),l>=k||(l=Math.max(l,d[g+6]),l=Math.max(l,d[g+7]),l=Math.max(l,d[g+8]),k=Math.min(k,Math.max(l,d[g])),k=Math.min(k,Math.max(l,d[g+9])));return-k-1},g=20;return{set_threshold:function(a){g=Math.min(Math.max(a,0),255);for(var c=-255;255>=c;++c)b[c+255]=-g>c?1:c>g?2:0;return g},detect:function(a,h,i){"undefined"==typeof i&&(i=3);var j,k=8,l=25,m=a.data,n=a.cols,o=a.rows,p=0,q=0,r=0,s=0,t=0,u=0,v=jsfeat.cache.get_buffer(3*n),w=jsfeat.cache.get_buffer(3*(n+1)<<2),x=v.u8,y=w.i32,z=c,A=d,B=Math.max(3,i),C=Math.min(o-2,o-i),D=Math.max(3,i),E=Math.min(n-3,n-i),F=0,G=0,H=f,I=b,J=g,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0;e(z,n,16);var W=z[0],X=z[1],Y=z[2],Z=z[3],$=z[4],_=z[5],ab=z[6],bb=z[7],cb=z[8],db=z[9],eb=z[10],fb=z[11],gb=z[12],hb=z[13],ib=z[14],jb=z[15];for(p=0;3*n>p;++p)x[p]=0;for(p=B;C>p;++p){for(Q=p*n+D|0,u=(p-3)%3,P=u*n|0,O=u*(n+1)|0,q=0;n>q;++q)x[P+q]=0;if(N=0,C-1>p)for(q=D;E>q;++q,++Q)if(K=m[Q],L=-K+255,M=I[L+m[Q+W]]|I[L+m[Q+cb]],0!=M&&(M&=I[L+m[Q+Y]]|I[L+m[Q+eb]],M&=I[L+m[Q+$]]|I[L+m[Q+gb]],M&=I[L+m[Q+ab]]|I[L+m[Q+ib]],0!=M)){if(M&=I[L+m[Q+X]]|I[L+m[Q+db]],M&=I[L+m[Q+Z]]|I[L+m[Q+fb]],M&=I[L+m[Q+_]]|I[L+m[Q+hb]],M&=I[L+m[Q+bb]]|I[L+m[Q+jb]],1&M)for(s=K-J,F=0,r=0;l>r;++r)if(t=m[Q+z[r]],s>t){if(++F,F>k){++N,y[O+N]=q,x[P+q]=H(m,Q,z,A,J);break}}else F=0;if(2&M)for(s=K+J,F=0,r=0;l>r;++r)if(t=m[Q+z[r]],t>s){if(++F,F>k){++N,y[O+N]=q,x[P+q]=H(m,Q,z,A,J);break}}else F=0}if(y[O+n]=N,p!=B)for(u=(p-4+3)%3,R=u*n|0,O=u*(n+1)|0,u=(p-5+3)%3,S=u*n|0,N=y[O+n],r=0;N>r;++r)q=y[O+r],T=q+1|0,U=q-1|0,V=x[R+q],V>x[R+T]&&V>x[R+U]&&V>x[S+U]&&V>x[S+q]&&V>x[S+T]&&V>x[P+U]&&V>x[P+q]&&V>x[P+T]&&(j=h[G],j.x=q,j.y=p-1,j.score=V,G++)}return jsfeat.cache.put_buffer(v),jsfeat.cache.put_buffer(w),G}}}();a.fast_corners=b,b.set_threshold(20)}(jsfeat),function(a){var b=function(){var a=function(a,b,c,d,e,f,g,h,i,j){var k=0,l=0,m=h*c+g|0,n=m;for(k=h;j>k;++k,m+=c,n=m)for(l=g;i>l;++l,++n)b[n]=-4*a[n]+a[n+e]+a[n-e]+a[n+f]+a[n-f]},b=function(a,b,c,d,e,f,g){var h=-2*a[b]+a[b+d]+a[b-d],i=-2*a[b]+a[b+e]+a[b-e],j=a[b+f]+a[b-f]-a[b+g]-a[b-g],k=0|Math.sqrt((h-i)*(h-i)+4*j*j);return Math.min(Math.abs(c-k),Math.abs(-(c+k)))};return{laplacian_threshold:30,min_eigen_value_threshold:25,detect:function(c,d,e){"undefined"==typeof e&&(e=5);var f,g=0,h=0,i=c.cols,j=c.rows,k=c.data,l=5,m=5*i|0,n=3+3*i|0,o=3-3*i|0,p=jsfeat.cache.get_buffer(i*j<<2),q=p.i32,r=0,s=0,t=0,u=0,v=0,w=this.laplacian_threshold,x=this.min_eigen_value_threshold,y=0|Math.max(5,e),z=0|Math.max(3,e),A=0|Math.min(i-5,i-e),B=0|Math.min(j-3,j-e);for(g=i*j;--g>=0;)q[g]=0;for(a(k,q,i,j,l,m,y,z,A,B),s=z*i+y|0,h=z;B>h;++h,s+=i)for(g=y,t=s;A>g;++g,++t)r=q[t],(-w>r&&r<q[t-1]&&r<q[t+1]&&r<q[t-i]&&r<q[t+i]&&r<q[t-i-1]&&r<q[t+i-1]&&r<q[t-i+1]&&r<q[t+i+1]||r>w&&r>q[t-1]&&r>q[t+1]&&r>q[t-i]&&r>q[t+i]&&r>q[t-i-1]&&r>q[t+i-1]&&r>q[t-i+1]&&r>q[t+i+1])&&(u=b(k,t,r,l,m,n,o),u>x&&(f=d[v],f.x=g,f.y=h,f.score=u,++v,++g,++t));return jsfeat.cache.put_buffer(p),v}}}();a.yape06=b}(jsfeat),function(a){var b=function(){var a=function(a,b,c){var d,e,f=0;for(d=c,e=0;d>e;e++,f++)d=Math.sqrt(c*c-e*e)+.5|0,b[f]=d+a*e;for(d--;e>d&&d>=0;d--,f++)e=Math.sqrt(c*c-d*d)+.5|0,b[f]=d+a*e;for(;e>-d;d--,f++)e=Math.sqrt(c*c-d*d)+.5|0,b[f]=d+a*e;for(e--;e>=0;e--,f++)d=-Math.sqrt(c*c-e*e)-.5|0,b[f]=d+a*e;for(;e>d;e--,f++)d=-Math.sqrt(c*c-e*e)-.5|0,b[f]=d+a*e;for(d++;0>=d;d++,f++)e=-Math.sqrt(c*c-d*d)-.5|0,b[f]=d+a*e;for(;-e>d;d++,f++)e=-Math.sqrt(c*c-d*d)-.5|0,b[f]=d+a*e;for(e++;0>e;e++,f++)d=Math.sqrt(c*c-e*e)+.5|0,b[f]=d+a*e;return b[f]=b[0],b[f+1]=b[1],f},b=function(a,b,c){var d=0;return 0!=a[b+1]&&d++,0!=a[b-1]&&d++,0!=a[b+c]&&d++,0!=a[b+c+1]&&d++,0!=a[b+c-1]&&d++,0!=a[b-c]&&d++,0!=a[b-c+1]&&d++,0!=a[b-c-1]&&d++,d},c=function(a,b,c,d,e){var f,g;if(c>0)for(b-=d*e,g=-e;e>=g;++g){for(f=-e;e>=f;++f)if(a[b+f]>c)return!1;b+=d}else for(b-=d*e,g=-e;e>=g;++g){for(f=-e;e>=f;++f)if(a[b+f]<c)return!1;b+=d}return!0},d=function(a,b,c,d,e,f,g,h){var i=0,j=0,k=g-1|0,l=0,m=0,n=0,o=0,p=0;if(l=a[b+f[j]],e>=l)if(l>=d)if(m=a[b+f[k]],e>=m){if(m>=d)return void(c[b]=0);if(k++,n=a[b+f[k]],n>e)if(k++,o=a[b+f[k]],o>e)p=3;else{if(!(d>o))return void(c[b]=0);p=6}else if(k++,o=a[b+f[k]],o>e)p=7;else{if(!(d>o))return void(c[b]=0);p=2}}else if(k++,n=a[b+f[k]],n>e)if(k++,o=a[b+f[k]],o>e)p=3;else{if(!(d>o))return void(c[b]=0);p=6}else{if(!(d>n))return void(c[b]=0);if(k++,o=a[b+f[k]],o>e)p=7;else{if(!(d>o))return void(c[b]=0);p=2}}else{if(m=a[b+f[k]],m>e)return void(c[b]=0);if(k++,n=a[b+f[k]],n>e)return void(c[b]=0);if(k++,o=a[b+f[k]],o>e)return void(c[b]=0);p=1}else{if(m=a[b+f[k]],d>m)return void(c[b]=0);if(k++,n=a[b+f[k]],d>n)return void(c[b]=0);if(k++,o=a[b+f[k]],d>o)return void(c[b]=0);p=0}for(j=1;g>=j;j++)switch(l=a[b+f[j]],p){case 0:if(l>e){if(n=o,k++,o=a[b+f[k]],d>o)return void(c[b]=0);i-=l+n,p=0;break}if(d>l){if(n>e)return void(c[b]=0);if(o>e)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],o>e)return void(c[b]=0);i-=l+n,p=8;break}if(e>=n)return void(c[b]=0);if(e>=o)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],o>e){i-=l+n,p=3;break}if(d>o){i-=l+n,p=6;break}return void(c[b]=0);case 1:if(d>l){if(n=o,k++,o=a[b+f[k]],o>e)return void(c[b]=0);i-=l+n,p=1;break}if(l>e){if(d>n)return void(c[b]=0);if(d>o)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],d>o)return void(c[b]=0);i-=l+n,p=9;break}if(n>=d)return void(c[b]=0);if(o>=d)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],d>o){i-=l+n,p=2;break}if(o>e){i-=l+n,p=7;break}return void(c[b]=0);case 2:if(l>e)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],d>l){if(o>e)return void(c[b]=0);i-=l+n,p=4;break}if(o>e){i-=l+n,p=7;break}if(d>o){i-=l+n,p=2;break}return void(c[b]=0);case 3:if(d>l)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],l>e){if(d>o)return void(c[b]=0);i-=l+n,p=5;break}if(o>e){i-=l+n,p=3;break}if(d>o){i-=l+n,p=6;break}return void(c[b]=0);case 4:if(l>e)return void(c[b]=0);if(d>l){if(n=o,k++,o=a[b+f[k]],o>e)return void(c[b]=0);i-=l+n,p=1;break}if(o>=d)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],d>o){i-=l+n,p=2;break}if(o>e){i-=l+n,p=7;break}return void(c[b]=0);case 5:if(d>l)return void(c[b]=0);if(l>e){if(n=o,k++,o=a[b+f[k]],d>o)return void(c[b]=0);i-=l+n,p=0;break}if(e>=o)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],o>e){i-=l+n,p=3;break}if(d>o){i-=l+n,p=6;break}return void(c[b]=0);case 7:if(l>e)return void(c[b]=0);if(d>l)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],o>e){i-=l+n,p=3;break}if(d>o){i-=l+n,p=6;break}return void(c[b]=0);case 6:if(l>e)return void(c[b]=0);if(d>l)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],d>o){i-=l+n,p=2;break}if(o>e){i-=l+n,p=7;break}return void(c[b]=0);case 8:if(l>e){if(d>o)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],d>o)return void(c[b]=0);i-=l+n,p=9;break}if(d>l){if(n=o,k++,o=a[b+f[k]],o>e)return void(c[b]=0);i-=l+n,p=1;break}return void(c[b]=0);case 9:if(d>l){if(o>e)return void(c[b]=0);if(n=o,k++,o=a[b+f[k]],o>e)return void(c[b]=0);i-=l+n,p=8;break}if(l>e){if(n=o,k++,o=a[b+f[k]],d>o)return void(c[b]=0);i-=l+n,p=0;break}return void(c[b]=0)}c[b]=i+h*a[b]},e=function(){function b(b,c,d){this.dirs=new Int32Array(1024),this.dirs_count=0|a(b,this.dirs,d),this.scores=new Int32Array(b*c),this.radius=0|d}return b}();return{level_tables:[],tau:7,init:function(a,b,c,d){"undefined"==typeof d&&(d=1);var f;for(c=Math.min(c,7),c=Math.max(c,3),f=0;d>f;++f)this.level_tables[f]=new e(a>>f,b>>f,c)},detect:function(a,e,f){"undefined"==typeof f&&(f=4);var g,h=this.level_tables[0],i=0|h.radius,j=i-1|0,k=h.dirs,l=0|h.dirs_count,m=l>>1,n=a.data,o=0|a.cols,p=0|a.rows,q=o>>1,r=h.scores,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0|this.tau,B=0,C=0|Math.max(i+1,f),D=0|Math.max(i+1,f),E=0|Math.min(o-i-2,o-f),F=0|Math.min(p-i-2,p-f);for(u=D*o+C|0,t=D;F>t;++t,u+=o)for(s=C,v=u;E>s;++s,++v)w=n[v]+A,x=n[v]-A,x<n[v+i]&&n[v+i]<w&&x<n[v-i]&&n[v-i]<w?r[v]=0:d(n,v,r,x,w,k,m,l);for(u=D*o+C|0,t=D;F>t;++t,u+=o)for(s=C,v=u;E>s;++s,++v)z=r[v],y=Math.abs(z),5>y?(++s,++v):b(r,v,o)>=3&&c(r,v,z,q,i)&&(g=e[B],g.x=s,g.y=t,g.score=y,++B,s+=j,v+=j);return B}}}();a.yape=b}(jsfeat),function(a){var b=function(){var a=new Int32Array([8,-3,9,5,4,2,7,-12,-11,9,-8,2,7,-12,12,-13,2,-13,2,12,1,-7,1,6,-2,-10,-2,-4,-13,-13,-11,-8,-13,-3,-12,-9,10,4,11,9,-13,-8,-8,-9,-11,7,-9,12,7,7,12,6,-4,-5,-3,0,-13,2,-12,-3,-9,0,-7,5,12,-6,12,-1,-3,6,-2,12,-6,-13,-4,-8,11,-13,12,-8,4,7,5,1,5,-3,10,-3,3,-7,6,12,-8,-7,-6,-2,-2,11,-1,-10,-13,12,-8,10,-7,3,-5,-3,-4,2,-3,7,-10,-12,-6,11,5,-12,6,-7,5,-6,7,-1,1,0,4,-5,9,11,11,-13,4,7,4,12,2,-1,4,4,-4,-12,-2,7,-8,-5,-7,-10,4,11,9,12,0,-8,1,-13,-13,-2,-8,2,-3,-2,-2,3,-6,9,-4,-9,8,12,10,7,0,9,1,3,7,-5,11,-10,-13,-6,-11,0,10,7,12,1,-6,-3,-6,12,10,-9,12,-4,-13,8,-8,-12,-13,0,-8,-4,3,3,7,8,5,7,10,-7,-1,7,1,-12,3,-10,5,6,2,-4,3,-10,-13,0,-13,5,-13,-7,-12,12,-13,3,-11,8,-7,12,-4,7,6,-10,12,8,-9,-1,-7,-6,-2,-5,0,12,-12,5,-7,5,3,-10,8,-13,-7,-7,-4,5,-3,-2,-1,-7,2,9,5,-11,-11,-13,-5,-13,-1,6,0,-1,5,-3,5,2,-4,-13,-4,12,-9,-6,-9,6,-12,-10,-8,-4,10,2,12,-3,7,12,12,12,-7,-13,-6,5,-4,9,-3,4,7,-1,12,2,-7,6,-5,1,-13,11,-12,5,-3,7,-2,-6,7,-8,12,-7,-13,-7,-11,-12,1,-3,12,12,2,-6,3,0,-4,3,-2,-13,-1,-13,1,9,7,1,8,-6,1,-1,3,12,9,1,12,6,-1,-9,-1,3,-13,-13,-10,5,7,7,10,12,12,-5,12,9,6,3,7,11,5,-13,6,10,2,-12,2,3,3,8,4,-6,2,6,12,-13,9,-12,10,3,-8,4,-7,9,-11,12,-4,-6,1,12,2,-8,6,-9,7,-4,2,3,3,-2,6,3,11,0,3,-3,8,-8,7,8,9,3,-11,-5,-6,-4,-10,11,-5,10,-5,-8,-3,12,-10,5,-9,0,8,-1,12,-6,4,-6,6,-11,-10,12,-8,7,4,-2,6,7,-2,0,-2,12,-5,-8,-5,2,7,-6,10,12,-9,-13,-8,-8,-5,-13,-5,-2,8,-8,9,-13,-9,-11,-9,0,1,-8,1,-2,7,-4,9,1,-2,1,-1,-4,11,-6,12,-11,-12,-9,-6,4,3,7,7,12,5,5,10,8,0,-4,2,8,-9,12,-5,-13,0,7,2,12,-1,2,1,7,5,11,7,-9,3,5,6,-8,-13,-4,-8,9,-5,9,-3,-3,-4,-7,-3,-12,6,5,8,0,-7,6,-6,12,-13,6,-5,-2,1,-10,3,10,4,1,8,-4,-2,-2,2,-13,2,-12,12,12,-2,-13,0,-6,4,1,9,3,-6,-10,-3,-5,-3,-13,-1,1,7,5,12,-11,4,-2,5,-7,-13,9,-9,-5,7,1,8,6,7,-8,7,6,-7,-4,-7,1,-8,11,-7,-8,-13,6,-12,-8,2,4,3,9,10,-5,12,3,-6,-5,-6,7,8,-3,9,-8,2,-12,2,8,-11,-2,-10,3,-12,-13,-7,-9,-11,0,-10,-5,5,-3,11,8,-2,-13,-1,12,-1,-8,0,9,-13,-11,-12,-5,-10,-2,-10,11,-3,9,-2,-13,2,-3,3,2,-9,-13,-4,0,-4,6,-3,-10,-4,12,-2,-7,-6,-11,-4,9,6,-3,6,11,-13,11,-5,5,11,11,12,6,7,-5,12,-2,-1,12,0,7,-4,-8,-3,-2,-7,1,-6,7,-13,-12,-8,-13,-7,-2,-6,-8,-8,5,-6,-9,-5,-1,-4,5,-13,7,-8,10,1,5,5,-13,1,0,10,-13,9,12,10,-1,5,-8,10,-9,-1,11,1,-13,-9,-3,-6,2,-1,-10,1,12,-13,1,-8,-10,8,-11,10,-6,2,-13,3,-6,7,-13,12,-9,-10,-10,-5,-7,-10,-8,-8,-13,4,-6,8,5,3,12,8,-13,-4,2,-3,-3,5,-13,10,-12,4,-13,5,-1,-9,9,-4,3,0,3,3,-9,-12,1,-6,1,3,2,4,-8,-10,-10,-10,9,8,-13,12,12,-8,-12,-6,-5,2,2,3,7,10,6,11,-8,6,8,8,-12,-7,10,-6,5,-3,-9,-3,9,-1,-13,-1,5,-3,-7,-3,4,-8,-2,-8,3,4,2,12,12,2,-5,3,11,6,-9,11,-13,3,-1,7,12,11,-1,12,4,-3,0,-3,6,4,-11,4,12,2,-4,2,1,-10,-6,-8,1,-13,7,-11,1,-13,12,-11,-13,6,0,11,-13,0,-1,1,4,-13,3,-9,-2,-9,8,-6,-3,-13,-6,-8,-2,5,-9,8,10,2,7,3,-9,-1,-6,-1,-1,9,5,11,-2,11,-3,12,-8,3,0,3,5,-1,4,0,10,3,-6,4,5,-13,0,-10,5,5,8,12,11,8,9,9,-6,7,-4,8,-12,-10,4,-10,9,7,3,12,4,9,-7,10,-2,7,0,12,-2,-1,-6,0,-11]),b=new jsfeat.matrix_t(3,3,jsfeat.F32_t|jsfeat.C1_t),c=new jsfeat.matrix_t(32,32,jsfeat.U8_t|jsfeat.C1_t),d=function(a,c,d,e,f,g){var h=Math.cos(d),i=Math.sin(d);b.data[0]=h,b.data[1]=-i,b.data[2]=(-h+i)*g*.5+e,b.data[3]=i,b.data[4]=h,b.data[5]=(-i-h)*g*.5+f,jsfeat.imgproc.warp_affine(a,c,b,128)};return{describe:function(b,e,f,g){var h=32,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=(b.data,b.cols,b.rows,c.data),r=528,s=0;g.type&jsfeat.U8_t?g.resize(h,f,1):(g.type=jsfeat.U8_t,g.cols=h,g.rows=f,g.channel=1,g.allocate());var t=g.data,u=0;for(i=0;f>i;++i){for(k=e[i].x,l=e[i].y,m=e[i].angle,d(b,c,m,k,l,32),s=0,j=0;h>j;++j)n=q[r+32*a[s+1]+a[s]],s+=2,o=q[r+32*a[s+1]+a[s]],s+=2,p=o>n|0,n=q[r+32*a[s+1]+a[s]],s+=2,o=q[r+32*a[s+1]+a[s]],s+=2,p|=(o>n)<<1,n=q[r+32*a[s+1]+a[s]],s+=2,o=q[r+32*a[s+1]+a[s]],s+=2,p|=(o>n)<<2,n=q[r+32*a[s+1]+a[s]],s+=2,o=q[r+32*a[s+1]+a[s]],s+=2,p|=(o>n)<<3,n=q[r+32*a[s+1]+a[s]],s+=2,o=q[r+32*a[s+1]+a[s]],s+=2,p|=(o>n)<<4,n=q[r+32*a[s+1]+a[s]],s+=2,o=q[r+32*a[s+1]+a[s]],s+=2,p|=(o>n)<<5,n=q[r+32*a[s+1]+a[s]],s+=2,o=q[r+32*a[s+1]+a[s]],s+=2,p|=(o>n)<<6,n=q[r+32*a[s+1]+a[s]],s+=2,o=q[r+32*a[s+1]+a[s]],s+=2,p|=(o>n)<<7,t[u+j]=p;u+=h}}}}();a.orb=b}(jsfeat),function(a){var b=function(){var a=jsfeat.imgproc.scharr_derivatives;return{track:function(b,c,d,e,f,g,h,i,j,k){"undefined"==typeof h&&(h=30),"undefined"==typeof i&&(i=new Uint8Array(f)),"undefined"==typeof j&&(j=.01),"undefined"==typeof k&&(k=1e-4);var l=.5*(g-1),m=g*g|0,n=m<<1,o=b.data,p=c.data,q=o[0].data,r=p[0].data,s=o[0].cols,t=o[0].rows,u=0,v=0,w=jsfeat.cache.get_buffer(m<<2),x=jsfeat.cache.get_buffer(n<<2),y=jsfeat.cache.get_buffer(t*(s<<1)<<2),z=new jsfeat.matrix_t(s,t,jsfeat.S32C2_t,y.data),A=w.i32,B=x.i32,C=y.i32,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,$=0,_=0,ab=0,bb=0,cb=0,db=0,eb=0,fb=0,gb=0,hb=0,ib=14,jb=14,kb=jb-5,lb=1<<kb-1,mb=1<<ib,nb=1<<jb-1,ob=1/(1<<20),pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0,wb=0,xb=0,yb=0,zb=0,Ab=0,Bb=1.1920929e-7;for(j*=j;f>W;++W)i[W]=1;var Cb=b.levels-1|0;for($=Cb;$>=0;--$)for(J=1/(1<<$),u=s>>$,v=t>>$,D=u<<1,q=o[$].data,r=p[$].data,cb=u-g|0,db=v-g|0,a(o[$],z),_=0;f>_;++_)if(W=_<<1,X=W+1,K=d[W]*J,L=d[X]*J,$==Cb?(M=K,N=L):(M=2*e[W],N=2*e[X]),e[W]=M,e[X]=N,K-=l,L-=l,S=0|K,T=0|L,Y=bb>=S|S>=cb|bb>=T|T>=db,0==Y){for(eb=K-S,fb=L-T,pb=(1-eb)*(1-fb)*mb+.5|0,qb=eb*(1-fb)*mb+.5|0,rb=(1-eb)*fb*mb+.5|0,sb=mb-pb-qb-rb,wb=0,xb=0,yb=0,Z=0;g>Z;++Z)for(E=(Z+T)*u+S|0,F=E<<1,G=Z*g|0,H=G<<1,Y=0;g>Y;++Y,++E,++G,F+=2)tb=q[E]*pb+q[E+1]*qb+q[E+u]*rb+q[E+u+1]*sb,tb=tb+lb>>kb,ub=C[F]*pb+C[F+2]*qb+C[F+D]*rb+C[F+D+2]*sb,ub=ub+nb>>jb,vb=C[F+1]*pb+C[F+3]*qb+C[F+D+1]*rb+C[F+D+3]*sb,vb=vb+nb>>jb,A[G]=tb,B[H++]=ub,B[H++]=vb,wb+=ub*ub,xb+=ub*vb,yb+=vb*vb;if(wb*=ob,xb*=ob,yb*=ob,zb=wb*yb-xb*xb,Ab=(yb+wb-Math.sqrt((wb-yb)*(wb-yb)+4*xb*xb))/n,k>Ab||Bb>zb)0==$&&(i[_]=0);else for(zb=1/zb,M-=l,N-=l,O=0,P=0,ab=0;h>ab;++ab){if(U=0|M,V=0|N,Y=bb>=U|U>=cb|bb>=V|V>=db,0!=Y){0==$&&(i[_]=0);break}for(eb=M-U,fb=N-V,pb=(1-eb)*(1-fb)*mb+.5|0,qb=eb*(1-fb)*mb+.5|0,rb=(1-eb)*fb*mb+.5|0,sb=mb-pb-qb-rb,gb=0,hb=0,Z=0;g>Z;++Z)for(I=(Z+V)*u+U|0,G=Z*g|0,H=G<<1,Y=0;g>Y;++Y,++I,++G)tb=r[I]*pb+r[I+1]*qb+r[I+u]*rb+r[I+u+1]*sb,tb=tb+lb>>kb,tb-=A[G],gb+=tb*B[H++],hb+=tb*B[H++];if(gb*=ob,hb*=ob,Q=(xb*hb-yb*gb)*zb,R=(xb*gb-wb*hb)*zb,M+=Q,N+=R,e[W]=M+l,e[X]=N+l,j>=Q*Q+R*R)break;if(ab>0&&Math.abs(Q+O)<.01&&Math.abs(R+P)<.01){e[W]-=.5*Q,e[X]-=.5*R;break}O=Q,P=R}}else 0==$&&(i[_]=0);jsfeat.cache.put_buffer(w),jsfeat.cache.put_buffer(x),jsfeat.cache.put_buffer(y)}}}();a.optical_flow_lk=b}(jsfeat),function(a){var b=function(){var a=function(a,b){var c=.25*a.width+.5|0;return b.x<=a.x+c&&b.x>=a.x-c&&b.y<=a.y+c&&b.y>=a.y-c&&b.width<=1.5*a.width+.5|0&&1.5*b.width+.5|0>=a.width};return{edges_density:.07,detect_single_scale:function(a,b,c,d,e,f,g,h){var i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I=h.size[0]*g|0,J=h.size[1]*g|0,K=.5*g+1.5|0,L=K,M=e-I|0,N=f-J|0,O=e+1|0,P=1/(I*J),Q=!0,R=0,S=I,T=J*O,U=T+I,V=I*J*255*this.edges_density|0,W=[];for(m=0;N>m;m+=L)for(R=m*O,l=0;M>l;l+=K,R+=K)if(o=a[R]-a[R+S]-a[R+T]+a[R+U],d&&(n=d[R]-d[R+S]-d[R+T]+d[R+U],V>n||20>o))l+=K,R+=K;else{for(o*=P,p=(b[R]-b[R+S]-b[R+T]+b[R+U])*P-o*o,q=p>0?Math.sqrt(p):1,r=h.complexClassifiers,v=r.length,Q=!0,i=0;v>i;++i){for(s=r[i],y=s.threshold,t=s.simpleClassifiers,w=t.length,z=0,j=0;w>j;++j){if(u=t[j],A=0,C=u.features,x=C.length,1===u.tilted)for(k=0;x>k;++k)B=C[k],D=~~(l+B[0]*g)+~~(m+B[1]*g)*O,G=~~(B[2]*g),H=~~(B[3]*g),E=G*O,F=H*O,A+=(c[D]-c[D+G+E]-c[D-H+F]+c[D+G-H+E+F])*B[4];else for(k=0;x>k;++k)B=C[k],D=~~(l+B[0]*g)+~~(m+B[1]*g)*O,G=~~(B[2]*g),H=~~(B[3]*g),F=H*O,A+=(a[D]-a[D+G]-a[D+F]+a[D+F+G])*B[4];z+=A*P<u.threshold*q?u.left_val:u.right_val}if(y>z){Q=!1;break}}Q&&(W.push({x:l,y:m,width:I,height:J,neighbor:1,confidence:z}),l+=K,R+=K)}return W},detect_multi_scale:function(a,b,c,d,e,f,g,h,i){"undefined"==typeof h&&(h=1.2),"undefined"==typeof i&&(i=1);for(var j=g.size[0],k=g.size[1],l=[];e>i*j&&f>i*k;)l=l.concat(this.detect_single_scale(a,b,c,d,e,f,i,g)),i*=h;return l},group_rectangles:function(b,c){"undefined"==typeof c&&(c=1);var d,e,f=b.length,g=[];for(d=0;f>d;++d)g[d]={parent:-1,element:b[d],rank:0};for(d=0;f>d;++d)if(g[d].element){for(var h=d;-1!=g[h].parent;)h=g[h].parent;for(e=0;f>e;++e)if(d!=e&&g[e].element&&a(g[d].element,g[e].element)){for(var i=e;-1!=g[i].parent;)i=g[i].parent;if(i!=h){g[h].rank>g[i].rank?g[i].parent=h:(g[h].parent=i,g[h].rank==g[i].rank&&g[i].rank++,h=i);for(var j,k=e;-1!=g[k].parent;)j=k,k=g[k].parent,g[j].parent=h;for(k=d;-1!=g[k].parent;)j=k,k=g[k].parent,g[j].parent=h}}}var l=[],m=0;for(d=0;f>d;d++){e=-1;var n=d;if(g[n].element){for(;-1!=g[n].parent;)n=g[n].parent;g[n].rank>=0&&(g[n].rank=~m++),e=~g[n].rank}l[d]=e}var o=[];for(d=0;m+1>d;++d)o[d]={neighbors:0,x:0,y:0,width:0,height:0,confidence:0};for(d=0;f>d;++d){var p=b[d],q=l[d];0==o[q].neighbors&&(o[q].confidence=p.confidence),++o[q].neighbors,o[q].x+=p.x,o[q].y+=p.y,o[q].width+=p.width,o[q].height+=p.height,o[q].confidence=Math.max(o[q].confidence,p.confidence)}var r=[];for(d=0;m>d;++d)f=o[d].neighbors,f>=c&&r.push({x:(2*o[d].x+f)/(2*f),y:(2*o[d].y+f)/(2*f),width:(2*o[d].width+f)/(2*f),height:(2*o[d].height+f)/(2*f),neighbors:o[d].neighbors,confidence:o[d].confidence});var s=[];for(f=r.length,d=0;f>d;++d){var p=r[d],t=!0;for(e=0;f>e;++e){var u=r[e],v=.25*u.width+.5|0;if(d!=e&&p.x>=u.x-v&&p.y>=u.y-v&&p.x+p.width<=u.x+u.width+v&&p.y+p.height<=u.y+u.height+v&&(u.neighbors>Math.max(3,p.neighbors)||p.neighbors<3)){t=!1;break}}t&&s.push(p)}return s}}}();a.haar=b}(jsfeat),function(a){var b=function(){var a=function(a,b){var c=.25*a.width+.5|0;return b.x<=a.x+c&&b.x>=a.x-c&&b.y<=a.y+c&&b.y>=a.y-c&&b.width<=1.5*a.width+.5|0&&1.5*b.width+.5|0>=a.width},b=new jsfeat.pyramid_t(1);return{interval:4,scale:1.1486,next:5,scale_to:1,prepare_cascade:function(a){for(var b=a.stage_classifier.length,c=0;b>c;c++)for(var d=a.stage_classifier[c].feature,e=a.stage_classifier[c].count,f=a.stage_classifier[c]._feature=new Array(e),g=0;e>g;g++)f[g]={size:d[g].size,px:new Array(d[g].size),pz:new Array(d[g].size),nx:new Array(d[g].size),nz:new Array(d[g].size)}},build_pyramid:function(a,c,d,e){"undefined"==typeof e&&(e=4);var f=a.cols,g=a.rows,h=0,i=0,j=0,k=!1,l=a,m=a,n=jsfeat.U8_t|jsfeat.C1_t;this.interval=e,this.scale=Math.pow(2,1/(this.interval+1)),this.next=this.interval+1|0,this.scale_to=Math.log(Math.min(f/c,g/d))/Math.log(this.scale)|0;var o=4*(this.scale_to+2*this.next)|0;for(b.levels!=o&&(b.levels=o,b.data=new Array(o),k=!0,b.data[0]=a),h=1;h<=this.interval;++h)i=f/Math.pow(this.scale,h)|0,j=g/Math.pow(this.scale,h)|0,l=b.data[h<<2],(k||i!=l.cols||j!=l.rows)&&(b.data[h<<2]=new jsfeat.matrix_t(i,j,n),l=b.data[h<<2]),jsfeat.imgproc.resample(a,l,i,j);
for(h=this.next;h<this.scale_to+2*this.next;++h)m=b.data[(h<<2)-(this.next<<2)],l=b.data[h<<2],i=m.cols>>1,j=m.rows>>1,(k||i!=l.cols||j!=l.rows)&&(b.data[h<<2]=new jsfeat.matrix_t(i,j,n),l=b.data[h<<2]),jsfeat.imgproc.pyrdown(m,l);for(h=2*this.next;h<this.scale_to+2*this.next;++h)m=b.data[(h<<2)-(this.next<<2)],i=m.cols>>1,j=m.rows>>1,l=b.data[(h<<2)+1],(k||i!=l.cols||j!=l.rows)&&(b.data[(h<<2)+1]=new jsfeat.matrix_t(i,j,n),l=b.data[(h<<2)+1]),jsfeat.imgproc.pyrdown(m,l,1,0),l=b.data[(h<<2)+2],(k||i!=l.cols||j!=l.rows)&&(b.data[(h<<2)+2]=new jsfeat.matrix_t(i,j,n),l=b.data[(h<<2)+2]),jsfeat.imgproc.pyrdown(m,l,0,1),l=b.data[(h<<2)+3],(k||i!=l.cols||j!=l.rows)&&(b.data[(h<<2)+3]=new jsfeat.matrix_t(i,j,n),l=b.data[(h<<2)+3]),jsfeat.imgproc.pyrdown(m,l,1,1);return b},detect:function(a,b){var c,d,e,f,g,h=(this.interval,this.scale),i=this.next,j=this.scale_to,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=!0,D=!0,E=1,F=1,G=[0,1,0,1],H=[0,0,1,1],I=[],J=a.data,K=1,L=2,M=4,N=[],O=[0,0,0],P=[0,0,0],Q=[0,0,0];for(k=0;j>k;k++){for(y=k<<2,z=J[y+(i<<3)].cols-(b.width>>2),A=J[y+(i<<3)].rows-(b.height>>2),P[0]=J[y].cols*K,P[1]=J[y+(i<<2)].cols*K,P[2]=J[y+(i<<3)].cols*K,Q[0]=J[y].cols*M-z*M,Q[1]=J[y+(i<<2)].cols*L-z*L,Q[2]=J[y+(i<<3)].cols*K-z*K,r=b.stage_classifier.length,l=0;r>l;l++)for(e=b.stage_classifier[l].feature,d=b.stage_classifier[l]._feature,s=b.stage_classifier[l].count,m=0;s>m;m++)for(f=d[m],g=e[m],t=0|g.size,q=0;t>q;q++)f.px[q]=g.px[q]*K+g.py[q]*P[g.pz[q]],f.pz[q]=g.pz[q],f.nx[q]=g.nx[q]*K+g.ny[q]*P[g.nz[q]],f.nz[q]=g.nz[q];for(N[0]=J[y].data,N[1]=J[y+(i<<2)].data,q=0;4>q;q++)for(N[2]=J[y+(i<<3)+q].data,O[0]=G[q]*L+H[q]*J[y].cols*L,O[1]=G[q]*K+H[q]*J[y+(i<<2)].cols*K,O[2]=0,p=0;A>p;p++){for(o=0;z>o;o++){for(B=0,C=!0,r=b.stage_classifier.length,l=0;r>l;l++){for(B=0,c=b.stage_classifier[l].alpha,d=b.stage_classifier[l]._feature,s=b.stage_classifier[l].count,m=0;s>m;m++)if(f=d[m],v=N[f.pz[0]][O[f.pz[0]]+f.px[0]],w=N[f.nz[0]][O[f.nz[0]]+f.nx[0]],w>=v)B+=c[m<<1];else{for(D=!0,t=f.size,x=1;t>x;x++){if(f.pz[x]>=0&&(u=N[f.pz[x]][O[f.pz[x]]+f.px[x]],v>u)){if(w>=u){D=!1;break}v=u}if(f.nz[x]>=0&&(n=N[f.nz[x]][O[f.nz[x]]+f.nx[x]],n>w)){if(n>=v){D=!1;break}w=n}}B+=D?c[(m<<1)+1]:c[m<<1]}if(B<b.stage_classifier[l].threshold){C=!1;break}}C&&(I.push({x:(4*o+2*G[q])*E,y:(4*p+2*H[q])*F,width:b.width*E,height:b.height*F,neighbor:1,confidence:B}),++o,O[0]+=M,O[1]+=L,O[2]+=K),O[0]+=M,O[1]+=L,O[2]+=K}O[0]+=Q[0],O[1]+=Q[1],O[2]+=Q[2]}E*=h,F*=h}return I},group_rectangles:function(b,c){"undefined"==typeof c&&(c=1);var d,e,f=b.length,g=[];for(d=0;f>d;++d)g[d]={parent:-1,element:b[d],rank:0};for(d=0;f>d;++d)if(g[d].element){for(var h=d;-1!=g[h].parent;)h=g[h].parent;for(e=0;f>e;++e)if(d!=e&&g[e].element&&a(g[d].element,g[e].element)){for(var i=e;-1!=g[i].parent;)i=g[i].parent;if(i!=h){g[h].rank>g[i].rank?g[i].parent=h:(g[h].parent=i,g[h].rank==g[i].rank&&g[i].rank++,h=i);for(var j,k=e;-1!=g[k].parent;)j=k,k=g[k].parent,g[j].parent=h;for(k=d;-1!=g[k].parent;)j=k,k=g[k].parent,g[j].parent=h}}}var l=[],m=0;for(d=0;f>d;d++){e=-1;var n=d;if(g[n].element){for(;-1!=g[n].parent;)n=g[n].parent;g[n].rank>=0&&(g[n].rank=~m++),e=~g[n].rank}l[d]=e}var o=[];for(d=0;m+1>d;++d)o[d]={neighbors:0,x:0,y:0,width:0,height:0,confidence:0};for(d=0;f>d;++d){var p=b[d],q=l[d];0==o[q].neighbors&&(o[q].confidence=p.confidence),++o[q].neighbors,o[q].x+=p.x,o[q].y+=p.y,o[q].width+=p.width,o[q].height+=p.height,o[q].confidence=Math.max(o[q].confidence,p.confidence)}var r=[];for(d=0;m>d;++d)f=o[d].neighbors,f>=c&&r.push({x:(2*o[d].x+f)/(2*f),y:(2*o[d].y+f)/(2*f),width:(2*o[d].width+f)/(2*f),height:(2*o[d].height+f)/(2*f),neighbors:o[d].neighbors,confidence:o[d].confidence});var s=[];for(f=r.length,d=0;f>d;++d){var p=r[d],t=!0;for(e=0;f>e;++e){var u=r[e],v=.25*u.width+.5|0;if(d!=e&&p.x>=u.x-v&&p.y>=u.y-v&&p.x+p.width<=u.x+u.width+v&&p.y+p.height<=u.y+u.height+v&&(u.neighbors>Math.max(3,p.neighbors)||p.neighbors<3)){t=!1;break}}t&&s.push(p)}return s}}}();a.bbf=b}(jsfeat),function(a){"undefined"==typeof module||"undefined"==typeof module.exports?window.jsfeat=a:module.exports=a}(jsfeat);var numeric="undefined"==typeof exports?function(){}:exports;"undefined"!=typeof global&&(global.numeric=numeric),numeric.version="1.2.6",numeric.bench=function(a,b){var c,d,e,f;for("undefined"==typeof b&&(b=15),e=.5,c=new Date;;){for(e*=2,f=e;f>3;f-=4)a(),a(),a(),a();for(;f>0;)a(),f--;if(d=new Date,d-c>b)break}for(f=e;f>3;f-=4)a(),a(),a(),a();for(;f>0;)a(),f--;return d=new Date,1e3*(3*e-1)/(d-c)},numeric._myIndexOf=function(a){var b,c=this.length;for(b=0;c>b;++b)if(this[b]===a)return b;return-1},numeric.myIndexOf=Array.prototype.indexOf?Array.prototype.indexOf:numeric._myIndexOf,numeric.Function=Function,numeric.precision=4,numeric.largeArray=50,numeric.prettyPrint=function(a){function b(a){if(0===a)return"0";if(isNaN(a))return"NaN";if(0>a)return"-"+b(-a);if(isFinite(a)){var c=Math.floor(Math.log(a)/Math.log(10)),d=a/Math.pow(10,c),e=d.toPrecision(numeric.precision);return 10===parseFloat(e)&&(c++,d=1,e=d.toPrecision(numeric.precision)),parseFloat(e).toString()+"e"+c.toString()}return"Infinity"}function c(a){var e;if("undefined"==typeof a)return d.push(Array(numeric.precision+8).join(" ")),!1;if("string"==typeof a)return d.push('"'+a+'"'),!1;if("boolean"==typeof a)return d.push(a.toString()),!1;if("number"==typeof a){var f=b(a),g=a.toPrecision(numeric.precision),h=parseFloat(a.toString()).toString(),i=[f,g,h,parseFloat(g).toString(),parseFloat(h).toString()];for(e=1;e<i.length;e++)i[e].length<f.length&&(f=i[e]);return d.push(Array(numeric.precision+8-f.length).join(" ")+f),!1}if(null===a)return d.push("null"),!1;if("function"==typeof a){d.push(a.toString());var j=!1;for(e in a)a.hasOwnProperty(e)&&(d.push(j?",\n":"\n{"),j=!0,d.push(e),d.push(": \n"),c(a[e]));return j&&d.push("}\n"),!0}if(a instanceof Array){if(a.length>numeric.largeArray)return d.push("...Large Array..."),!0;var j=!1;for(d.push("["),e=0;e<a.length;e++)e>0&&(d.push(","),j&&d.push("\n ")),j=c(a[e]);return d.push("]"),!0}d.push("{");var j=!1;for(e in a)a.hasOwnProperty(e)&&(j&&d.push(",\n"),j=!0,d.push(e),d.push(": \n"),c(a[e]));return d.push("}"),!0}var d=[];return c(a),d.join("")},numeric.parseDate=function(a){function b(a){if("string"==typeof a)return Date.parse(a.replace(/-/g,"/"));if(a instanceof Array){var c,d=[];for(c=0;c<a.length;c++)d[c]=b(a[c]);return d}throw new Error("parseDate: parameter must be arrays of strings")}return b(a)},numeric.parseFloat=function(a){function b(a){if("string"==typeof a)return parseFloat(a);if(a instanceof Array){var c,d=[];for(c=0;c<a.length;c++)d[c]=b(a[c]);return d}throw new Error("parseFloat: parameter must be arrays of strings")}return b(a)},numeric.parseCSV=function(a){var b,c,d=a.split("\n"),e=[],f=/(([^'",]*)|('[^']*')|("[^"]*")),/g,g=/^\s*(([+-]?[0-9]+(\.[0-9]*)?(e[+-]?[0-9]+)?)|([+-]?[0-9]*(\.[0-9]+)?(e[+-]?[0-9]+)?))\s*$/,h=function(a){return a.substr(0,a.length-1)},i=0;for(c=0;c<d.length;c++){var j,k=(d[c]+",").match(f);if(k.length>0){for(e[i]=[],b=0;b<k.length;b++)j=h(k[b]),e[i][b]=g.test(j)?parseFloat(j):j;i++}}return e},numeric.toCSV=function(a){var b,c,d,e,f,g,h=numeric.dim(a);for(d=h[0],e=h[1],g=[],b=0;d>b;b++){for(f=[],c=0;d>c;c++)f[c]=a[b][c].toString();g[b]=f.join(", ")}return g.join("\n")+"\n"},numeric.getURL=function(a){var b=new XMLHttpRequest;return b.open("GET",a,!1),b.send(),b},numeric.imageURL=function(a){function b(a){var b,c,d,e,f,g,h,i,j=a.length,k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="";for(b=0;j>b;b+=3)c=a[b],d=a[b+1],e=a[b+2],f=c>>2,g=((3&c)<<4)+(d>>4),h=((15&d)<<2)+(e>>6),i=63&e,b+1>=j?h=i=64:b+2>=j&&(i=64),l+=k.charAt(f)+k.charAt(g)+k.charAt(h)+k.charAt(i);return l}function c(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=a.length);{var d,e=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],f=-1,g=0;a.length}for(d=b;c>d;d++)g=255&(f^a[d]),f=f>>>8^e[g];return-1^f}var d,e,f,g,h,i,j,k,l,m,n=a[0].length,o=a[0][0].length,p=[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,o>>24&255,o>>16&255,o>>8&255,255&o,n>>24&255,n>>16&255,n>>8&255,255&n,8,2,0,0,0,-1,-2,-3,-4,-5,-6,-7,-8,73,68,65,84,8,29];for(m=c(p,12,29),p[29]=m>>24&255,p[30]=m>>16&255,p[31]=m>>8&255,p[32]=255&m,d=1,e=0,j=0;n>j;j++){for(p.push(n-1>j?0:1),h=3*o+1+(0===j)&255,i=3*o+1+(0===j)>>8&255,p.push(h),p.push(i),p.push(255&~h),p.push(255&~i),0===j&&p.push(0),k=0;o>k;k++)for(f=0;3>f;f++)h=a[f][j][k],h=h>255?255:0>h?0:Math.round(h),d=(d+h)%65521,e=(e+d)%65521,p.push(h);p.push(0)}return l=(e<<16)+d,p.push(l>>24&255),p.push(l>>16&255),p.push(l>>8&255),p.push(255&l),g=p.length-41,p[33]=g>>24&255,p[34]=g>>16&255,p[35]=g>>8&255,p[36]=255&g,m=c(p,37),p.push(m>>24&255),p.push(m>>16&255),p.push(m>>8&255),p.push(255&m),p.push(0),p.push(0),p.push(0),p.push(0),p.push(73),p.push(69),p.push(78),p.push(68),p.push(174),p.push(66),p.push(96),p.push(130),"data:image/png;base64,"+b(p)},numeric._dim=function(a){for(var b=[];"object"==typeof a;)b.push(a.length),a=a[0];return b},numeric.dim=function(a){var b,c;return"object"==typeof a?(b=a[0],"object"==typeof b?(c=b[0],"object"==typeof c?numeric._dim(a):[a.length,b.length]):[a.length]):[]},numeric.mapreduce=function(a,b){return Function("x","accum","_s","_k",'if(typeof accum === "undefined") accum = '+b+';\nif(typeof x === "number") { var xi = x; '+a+'; return accum; }\nif(typeof _s === "undefined") _s = numeric.dim(x);\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i,xi;\nif(_k < _s.length-1) {\n    for(i=_n-1;i>=0;i--) {\n        accum = arguments.callee(x[i],accum,_s,_k+1);\n    }    return accum;\n}\nfor(i=_n-1;i>=1;i-=2) { \n    xi = x[i];\n    '+a+";\n    xi = x[i-1];\n    "+a+";\n}\nif(i === 0) {\n    xi = x[i];\n    "+a+"\n}\nreturn accum;")},numeric.mapreduce2=function(a,b){return Function("x","var n = x.length;\nvar i,xi;\n"+b+";\nfor(i=n-1;i!==-1;--i) { \n    xi = x[i];\n    "+a+";\n}\nreturn accum;")},numeric.same=function a(b,c){var d,e;if(b instanceof Array&&c instanceof Array){if(e=b.length,e!==c.length)return!1;for(d=0;e>d;d++)if(b[d]!==c[d]){if("object"!=typeof b[d])return!1;if(!a(b[d],c[d]))return!1}return!0}return!1},numeric.rep=function(a,b,c){"undefined"==typeof c&&(c=0);var d,e=a[c],f=Array(e);if(c===a.length-1){for(d=e-2;d>=0;d-=2)f[d+1]=b,f[d]=b;return-1===d&&(f[0]=b),f}for(d=e-1;d>=0;d--)f[d]=numeric.rep(a,b,c+1);return f},numeric.dotMMsmall=function(a,b){var c,d,e,f,g,h,i,j,k,l,m;for(f=a.length,g=b.length,h=b[0].length,i=Array(f),c=f-1;c>=0;c--){for(j=Array(h),k=a[c],e=h-1;e>=0;e--){for(l=k[g-1]*b[g-1][e],d=g-2;d>=1;d-=2)m=d-1,l+=k[d]*b[d][e]+k[m]*b[m][e];0===d&&(l+=k[0]*b[0][e]),j[e]=l}i[c]=j}return i},numeric._getCol=function(a,b,c){var d,e=a.length;for(d=e-1;d>0;--d)c[d]=a[d][b],--d,c[d]=a[d][b];0===d&&(c[0]=a[0][b])},numeric.dotMMbig=function(a,b){var c,d,e,f,g=numeric._getCol,h=b.length,i=Array(h),j=a.length,k=b[0].length,l=new Array(j),m=numeric.dotVV;for(--h,--j,d=j;-1!==d;--d)l[d]=Array(k);for(--k,d=k;-1!==d;--d)for(g(b,d,i),e=j;-1!==e;--e)f=0,c=a[e],l[e][d]=m(c,i);return l},numeric.dotMV=function(a,b){var c,d=a.length,e=(b.length,Array(d)),f=numeric.dotVV;for(c=d-1;c>=0;c--)e[c]=f(a[c],b);return e},numeric.dotVM=function(a,b){var c,d,e,f,g,h,i;for(e=a.length,f=b[0].length,g=Array(f),d=f-1;d>=0;d--){for(h=a[e-1]*b[e-1][d],c=e-2;c>=1;c-=2)i=c-1,h+=a[c]*b[c][d]+a[i]*b[i][d];0===c&&(h+=a[0]*b[0][d]),g[d]=h}return g},numeric.dotVV=function(a,b){var c,d,e=a.length,f=a[e-1]*b[e-1];for(c=e-2;c>=1;c-=2)d=c-1,f+=a[c]*b[c]+a[d]*b[d];return 0===c&&(f+=a[0]*b[0]),f},numeric.dot=function(a,b){var c=numeric.dim;switch(1e3*c(a).length+c(b).length){case 2002:return b.length<10?numeric.dotMMsmall(a,b):numeric.dotMMbig(a,b);case 2001:return numeric.dotMV(a,b);case 1002:return numeric.dotVM(a,b);case 1001:return numeric.dotVV(a,b);case 1e3:return numeric.mulVS(a,b);case 1:return numeric.mulSV(a,b);case 0:return a*b;default:throw new Error("numeric.dot only works on vectors and matrices")}},numeric.diag=function(a){var b,c,d,e,f=a.length,g=Array(f);for(b=f-1;b>=0;b--){for(e=Array(f),c=b+2,d=f-1;d>=c;d-=2)e[d]=0,e[d-1]=0;for(d>b&&(e[d]=0),e[b]=a[b],d=b-1;d>=1;d-=2)e[d]=0,e[d-1]=0;0===d&&(e[0]=0),g[b]=e}return g},numeric.getDiag=function(a){var b,c=Math.min(a.length,a[0].length),d=Array(c);for(b=c-1;b>=1;--b)d[b]=a[b][b],--b,d[b]=a[b][b];return 0===b&&(d[0]=a[0][0]),d},numeric.identity=function(a){return numeric.diag(numeric.rep([a],1))},numeric.pointwise=function(a,b,c){"undefined"==typeof c&&(c="");var d,e,f=[],g=/\[i\]$/,h="",i=!1;for(d=0;d<a.length;d++)g.test(a[d])?(e=a[d].substring(0,a[d].length-3),h=e):e=a[d],"ret"===e&&(i=!0),f.push(e);return f[a.length]="_s",f[a.length+1]="_k",f[a.length+2]='if(typeof _s === "undefined") _s = numeric.dim('+h+');\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i'+(i?"":", ret = Array(_n)")+";\nif(_k < _s.length-1) {\n    for(i=_n-1;i>=0;i--) ret[i] = arguments.callee("+a.join(",")+",_s,_k+1);\n    return ret;\n}\n"+c+"\nfor(i=_n-1;i!==-1;--i) {\n    "+b+"\n}\nreturn ret;",Function.apply(null,f)},numeric.pointwise2=function(a,b,c){"undefined"==typeof c&&(c="");var d,e,f=[],g=/\[i\]$/,h="",i=!1;for(d=0;d<a.length;d++)g.test(a[d])?(e=a[d].substring(0,a[d].length-3),h=e):e=a[d],"ret"===e&&(i=!0),f.push(e);return f[a.length]="var _n = "+h+".length;\nvar i"+(i?"":", ret = Array(_n)")+";\n"+c+"\nfor(i=_n-1;i!==-1;--i) {\n"+b+"\n}\nreturn ret;",Function.apply(null,f)},numeric._biforeach=function b(a,c,d,e,f){if(e===d.length-1)return void f(a,c);var g,h=d[e];for(g=h-1;g>=0;g--)b("object"==typeof a?a[g]:a,"object"==typeof c?c[g]:c,d,e+1,f)},numeric._biforeach2=function c(a,b,d,e,f){if(e===d.length-1)return f(a,b);var g,h=d[e],i=Array(h);for(g=h-1;g>=0;--g)i[g]=c("object"==typeof a?a[g]:a,"object"==typeof b?b[g]:b,d,e+1,f);return i},numeric._foreach=function d(a,b,c,e){if(c===b.length-1)return void e(a);var f,g=b[c];for(f=g-1;f>=0;f--)d(a[f],b,c+1,e)},numeric._foreach2=function e(a,b,c,d){if(c===b.length-1)return d(a);var f,g=b[c],h=Array(g);for(f=g-1;f>=0;f--)h[f]=e(a[f],b,c+1,d);return h},numeric.ops2={add:"+",sub:"-",mul:"*",div:"/",mod:"%",and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">=",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"},numeric.opseq={addeq:"+=",subeq:"-=",muleq:"*=",diveq:"/=",modeq:"%=",lshifteq:"<<=",rshifteq:">>=",rrshifteq:">>>=",bandeq:"&=",boreq:"|=",bxoreq:"^="},numeric.mathfuns=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan","isNaN","isFinite"],numeric.mathfuns2=["atan2","pow","max","min"],numeric.ops1={neg:"-",not:"!",bnot:"~",clone:""},numeric.mapreducers={any:["if(xi) return true;","var accum = false;"],all:["if(!xi) return false;","var accum = true;"],sum:["accum += xi;","var accum = 0;"],prod:["accum *= xi;","var accum = 1;"],norm2Squared:["accum += xi*xi;","var accum = 0;"],norminf:["accum = max(accum,abs(xi));","var accum = 0, max = Math.max, abs = Math.abs;"],norm1:["accum += abs(xi)","var accum = 0, abs = Math.abs;"],sup:["accum = max(accum,xi);","var accum = -Infinity, max = Math.max;"],inf:["accum = min(accum,xi);","var accum = Infinity, min = Math.min;"]},function(){var a,b;for(a=0;a<numeric.mathfuns2.length;++a)b=numeric.mathfuns2[a],numeric.ops2[b]=b;for(a in numeric.ops2)if(numeric.ops2.hasOwnProperty(a)){b=numeric.ops2[a];var c,d,e="";-1!==numeric.myIndexOf.call(numeric.mathfuns2,a)?(e="var "+b+" = Math."+b+";\n",c=function(a,c,d){return a+" = "+b+"("+c+","+d+")"},d=function(a,c){return a+" = "+b+"("+a+","+c+")"}):(c=function(a,c,d){return a+" = "+c+" "+b+" "+d},d=numeric.opseq.hasOwnProperty(a+"eq")?function(a,c){return a+" "+b+"= "+c}:function(a,c){return a+" = "+a+" "+b+" "+c}),numeric[a+"VV"]=numeric.pointwise2(["x[i]","y[i]"],c("ret[i]","x[i]","y[i]"),e),numeric[a+"SV"]=numeric.pointwise2(["x","y[i]"],c("ret[i]","x","y[i]"),e),numeric[a+"VS"]=numeric.pointwise2(["x[i]","y"],c("ret[i]","x[i]","y"),e),numeric[a]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar VV = numeric."+a+"VV, VS = numeric."+a+"VS, SV = numeric."+a+'SV;\nvar dim = numeric.dim;\nfor(i=1;i!==n;++i) { \n  y = arguments[i];\n  if(typeof x === "object") {\n      if(typeof y === "object") x = numeric._biforeach2(x,y,dim(x),0,VV);\n      else x = numeric._biforeach2(x,y,dim(x),0,VS);\n  } else if(typeof y === "object") x = numeric._biforeach2(x,y,dim(y),0,SV);\n  else '+d("x","y")+"\n}\nreturn x;\n"),numeric[b]=numeric[a],numeric[a+"eqV"]=numeric.pointwise2(["ret[i]","x[i]"],d("ret[i]","x[i]"),e),numeric[a+"eqS"]=numeric.pointwise2(["ret[i]","x"],d("ret[i]","x"),e),numeric[a+"eq"]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar V = numeric."+a+"eqV, S = numeric."+a+'eqS\nvar s = numeric.dim(x);\nfor(i=1;i!==n;++i) { \n  y = arguments[i];\n  if(typeof y === "object") numeric._biforeach(x,y,s,0,V);\n  else numeric._biforeach(x,y,s,0,S);\n}\nreturn x;\n')}for(a=0;a<numeric.mathfuns2.length;++a)b=numeric.mathfuns2[a],delete numeric.ops2[b];for(a=0;a<numeric.mathfuns.length;++a)b=numeric.mathfuns[a],numeric.ops1[b]=b;for(a in numeric.ops1)numeric.ops1.hasOwnProperty(a)&&(e="",b=numeric.ops1[a],-1!==numeric.myIndexOf.call(numeric.mathfuns,a)&&Math.hasOwnProperty(b)&&(e="var "+b+" = Math."+b+";\n"),numeric[a+"eqV"]=numeric.pointwise2(["ret[i]"],"ret[i] = "+b+"(ret[i]);",e),numeric[a+"eq"]=Function("x",'if(typeof x !== "object") return '+b+"x\nvar i;\nvar V = numeric."+a+"eqV;\nvar s = numeric.dim(x);\nnumeric._foreach(x,s,0,V);\nreturn x;\n"),numeric[a+"V"]=numeric.pointwise2(["x[i]"],"ret[i] = "+b+"(x[i]);",e),numeric[a]=Function("x",'if(typeof x !== "object") return '+b+"(x)\nvar i;\nvar V = numeric."+a+"V;\nvar s = numeric.dim(x);\nreturn numeric._foreach2(x,s,0,V);\n"));for(a=0;a<numeric.mathfuns.length;++a)b=numeric.mathfuns[a],delete numeric.ops1[b];for(a in numeric.mapreducers)numeric.mapreducers.hasOwnProperty(a)&&(b=numeric.mapreducers[a],numeric[a+"V"]=numeric.mapreduce2(b[0],b[1]),numeric[a]=Function("x","s","k",b[1]+'if(typeof x !== "object") {    xi = x;\n'+b[0]+';\n    return accum;\n}if(typeof s === "undefined") s = numeric.dim(x);\nif(typeof k === "undefined") k = 0;\nif(k === s.length-1) return numeric.'+a+"V(x);\nvar xi;\nvar n = x.length, i;\nfor(i=n-1;i!==-1;--i) {\n   xi = arguments.callee(x[i]);\n"+b[0]+";\n}\nreturn accum;\n"))}(),numeric.truncVV=numeric.pointwise(["x[i]","y[i]"],"ret[i] = round(x[i]/y[i])*y[i];","var round = Math.round;"),numeric.truncVS=numeric.pointwise(["x[i]","y"],"ret[i] = round(x[i]/y)*y;","var round = Math.round;"),numeric.truncSV=numeric.pointwise(["x","y[i]"],"ret[i] = round(x/y[i])*y[i];","var round = Math.round;"),numeric.trunc=function(a,b){return"object"==typeof a?"object"==typeof b?numeric.truncVV(a,b):numeric.truncVS(a,b):"object"==typeof b?numeric.truncSV(a,b):Math.round(a/b)*b},numeric.inv=function(a){var b,c,d,e,f,g,h,a,i=numeric.dim(a),j=Math.abs,k=i[0],l=i[1],m=numeric.clone(a),n=numeric.identity(k);for(g=0;l>g;++g){var o=-1,p=-1;for(f=g;f!==k;++f)h=j(m[f][g]),h>p&&(o=f,p=h);for(c=m[o],m[o]=m[g],m[g]=c,e=n[o],n[o]=n[g],n[g]=e,a=c[g],h=g;h!==l;++h)c[h]/=a;for(h=l-1;-1!==h;--h)e[h]/=a;for(f=k-1;-1!==f;--f)if(f!==g){for(b=m[f],d=n[f],a=b[g],h=g+1;h!==l;++h)b[h]-=c[h]*a;for(h=l-1;h>0;--h)d[h]-=e[h]*a,--h,d[h]-=e[h]*a;0===h&&(d[0]-=e[0]*a)}}return n},numeric.det=function(a){var b=numeric.dim(a);if(2!==b.length||b[0]!==b[1])throw new Error("numeric: det() only works on square matrices");var c,d,e,f,g,h,i,j,k=b[0],l=1,m=numeric.clone(a);for(d=0;k-1>d;d++){for(e=d,c=d+1;k>c;c++)Math.abs(m[c][d])>Math.abs(m[e][d])&&(e=c);for(e!==d&&(i=m[e],m[e]=m[d],m[d]=i,l*=-1),f=m[d],c=d+1;k>c;c++){for(g=m[c],h=g[d]/f[d],e=d+1;k-1>e;e+=2)j=e+1,g[e]-=f[e]*h,g[j]-=f[j]*h;e!==k&&(g[e]-=f[e]*h)}if(0===f[d])return 0;l*=f[d]}return l*m[d][d]},numeric.transpose=function(a){var b,c,d,e,f,g=a.length,h=a[0].length,i=Array(h);for(c=0;h>c;c++)i[c]=Array(g);for(b=g-1;b>=1;b-=2){for(e=a[b],d=a[b-1],c=h-1;c>=1;--c)f=i[c],f[b]=e[c],f[b-1]=d[c],--c,f=i[c],f[b]=e[c],f[b-1]=d[c];0===c&&(f=i[0],f[b]=e[0],f[b-1]=d[0])}if(0===b){for(d=a[0],c=h-1;c>=1;--c)i[c][0]=d[c],--c,i[c][0]=d[c];0===c&&(i[0][0]=d[0])}return i},numeric.negtranspose=function(a){var b,c,d,e,f,g=a.length,h=a[0].length,i=Array(h);for(c=0;h>c;c++)i[c]=Array(g);for(b=g-1;b>=1;b-=2){for(e=a[b],d=a[b-1],c=h-1;c>=1;--c)f=i[c],f[b]=-e[c],f[b-1]=-d[c],--c,f=i[c],f[b]=-e[c],f[b-1]=-d[c];0===c&&(f=i[0],f[b]=-e[0],f[b-1]=-d[0])}if(0===b){for(d=a[0],c=h-1;c>=1;--c)i[c][0]=-d[c],--c,i[c][0]=-d[c];0===c&&(i[0][0]=-d[0])}return i},numeric._random=function f(a,b){var c,d,e=a[b],g=Array(e);if(b===a.length-1){for(d=Math.random,c=e-1;c>=1;c-=2)g[c]=d(),g[c-1]=d();return 0===c&&(g[0]=d()),g}for(c=e-1;c>=0;c--)g[c]=f(a,b+1);return g},numeric.random=function(a){return numeric._random(a,0)},numeric.norm2=function(a){return Math.sqrt(numeric.norm2Squared(a))},numeric.linspace=function(a,b,c){if("undefined"==typeof c&&(c=Math.max(Math.round(b-a)+1,1)),2>c)return 1===c?[a]:[];var d,e=Array(c);for(c--,d=c;d>=0;d--)e[d]=(d*b+(c-d)*a)/c;return e},numeric.getBlock=function(a,b,c){function d(a,f){var g,h=b[f],i=c[f]-h,j=Array(i);if(f===e.length-1){for(g=i;g>=0;g--)j[g]=a[g+h];return j}for(g=i;g>=0;g--)j[g]=d(a[g+h],f+1);return j}var e=numeric.dim(a);return d(a,0)},numeric.setBlock=function(a,b,c,d){function e(a,d,g){var h,i=b[g],j=c[g]-i;if(g===f.length-1)for(h=j;h>=0;h--)a[h+i]=d[h];for(h=j;h>=0;h--)e(a[h+i],d[h],g+1)}var f=numeric.dim(a);return e(a,d,0),a},numeric.getRange=function(a,b,c){var d,e,f,g,h=b.length,i=c.length,j=Array(h);for(d=h-1;-1!==d;--d)for(j[d]=Array(i),f=j[d],g=a[b[d]],e=i-1;-1!==e;--e)f[e]=g[c[e]];return j},numeric.blockMatrix=function(a){var b=numeric.dim(a);if(b.length<4)return numeric.blockMatrix([a]);var c,d,e,f,g,h=b[0],i=b[1];for(c=0,d=0,e=0;h>e;++e)c+=a[e][0].length;for(f=0;i>f;++f)d+=a[0][f][0].length;var j=Array(c);for(e=0;c>e;++e)j[e]=Array(d);var k,l,m,n,o,p=0;for(e=0;h>e;++e){for(k=d,f=i-1;-1!==f;--f)for(g=a[e][f],k-=g[0].length,m=g.length-1;-1!==m;--m)for(o=g[m],l=j[p+m],n=o.length-1;-1!==n;--n)l[k+n]=o[n];p+=a[e][0].length}return j},numeric.tensor=function(a,b){if("number"==typeof a||"number"==typeof b)return numeric.mul(a,b);var c=numeric.dim(a),d=numeric.dim(b);if(1!==c.length||1!==d.length)throw new Error("numeric: tensor product is only defined for vectors");var e,f,g,h,i=c[0],j=d[0],k=Array(i);for(f=i-1;f>=0;f--){for(e=Array(j),h=a[f],g=j-1;g>=3;--g)e[g]=h*b[g],--g,e[g]=h*b[g],--g,e[g]=h*b[g],--g,e[g]=h*b[g];for(;g>=0;)e[g]=h*b[g],--g;k[f]=e}return k},numeric.T=function(a,b){this.x=a,this.y=b},numeric.t=function(a,b){return new numeric.T(a,b)},numeric.Tbinop=function(a,b,c,d,e){numeric.indexOf;if("string"!=typeof e){var f;e="";for(f in numeric)numeric.hasOwnProperty(f)&&(a.indexOf(f)>=0||b.indexOf(f)>=0||c.indexOf(f)>=0||d.indexOf(f)>=0)&&f.length>1&&(e+="var "+f+" = numeric."+f+";\n")}return Function(["y"],"var x = this;\nif(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n"+e+"\nif(x.y) {  if(y.y) {    return new numeric.T("+d+");\n  }\n  return new numeric.T("+c+");\n}\nif(y.y) {\n  return new numeric.T("+b+");\n}\nreturn new numeric.T("+a+");\n")},numeric.T.prototype.add=numeric.Tbinop("add(x.x,y.x)","add(x.x,y.x),y.y","add(x.x,y.x),x.y","add(x.x,y.x),add(x.y,y.y)"),numeric.T.prototype.sub=numeric.Tbinop("sub(x.x,y.x)","sub(x.x,y.x),neg(y.y)","sub(x.x,y.x),x.y","sub(x.x,y.x),sub(x.y,y.y)"),numeric.T.prototype.mul=numeric.Tbinop("mul(x.x,y.x)","mul(x.x,y.x),mul(x.x,y.y)","mul(x.x,y.x),mul(x.y,y.x)","sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))"),numeric.T.prototype.reciprocal=function(){var a=numeric.mul,b=numeric.div;if(this.y){var c=numeric.add(a(this.x,this.x),a(this.y,this.y));return new numeric.T(b(this.x,c),b(numeric.neg(this.y),c))}return new T(b(1,this.x))},numeric.T.prototype.div=function g(a){if(a instanceof numeric.T||(a=new numeric.T(a)),a.y)return this.mul(a.reciprocal());var g=numeric.div;return this.y?new numeric.T(g(this.x,a.x),g(this.y,a.x)):new numeric.T(g(this.x,a.x))},numeric.T.prototype.dot=numeric.Tbinop("dot(x.x,y.x)","dot(x.x,y.x),dot(x.x,y.y)","dot(x.x,y.x),dot(x.y,y.x)","sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))"),numeric.T.prototype.transpose=function(){var a=numeric.transpose,b=this.x,c=this.y;return c?new numeric.T(a(b),a(c)):new numeric.T(a(b))},numeric.T.prototype.transjugate=function(){var a=numeric.transpose,b=this.x,c=this.y;return c?new numeric.T(a(b),numeric.negtranspose(c)):new numeric.T(a(b))},numeric.Tunop=function(a,b,c){return"string"!=typeof c&&(c=""),Function("var x = this;\n"+c+"\nif(x.y) {  "+b+";\n}\n"+a+";\n")},numeric.T.prototype.exp=numeric.Tunop("return new numeric.T(ex)","return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))","var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;"),numeric.T.prototype.conj=numeric.Tunop("return new numeric.T(x.x);","return new numeric.T(x.x,numeric.neg(x.y));"),numeric.T.prototype.neg=numeric.Tunop("return new numeric.T(neg(x.x));","return new numeric.T(neg(x.x),neg(x.y));","var neg = numeric.neg;"),numeric.T.prototype.sin=numeric.Tunop("return new numeric.T(numeric.sin(x.x))","return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));"),numeric.T.prototype.cos=numeric.Tunop("return new numeric.T(numeric.cos(x.x))","return x.exp().add(x.neg().exp()).div(2);"),numeric.T.prototype.abs=numeric.Tunop("return new numeric.T(numeric.abs(x.x));","return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));","var mul = numeric.mul;"),numeric.T.prototype.log=numeric.Tunop("return new numeric.T(numeric.log(x.x));","var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\nreturn new numeric.T(numeric.log(r.x),theta.x);"),numeric.T.prototype.norm2=numeric.Tunop("return numeric.norm2(x.x);","var f = numeric.norm2Squared;\nreturn Math.sqrt(f(x.x)+f(x.y));"),numeric.T.prototype.inv=function(){var a=this;if("undefined"==typeof a.y)return new numeric.T(numeric.inv(a.x));var b,c,d,e,f,g,h,i,j,k,l,b,c,d,m,n,o,p,q,r,s,t=a.x.length,u=numeric.identity(t),v=numeric.rep([t,t],0),w=numeric.clone(a.x),x=numeric.clone(a.y);for(b=0;t>b;b++){for(o=w[b][b],p=x[b][b],m=o*o+p*p,d=b,c=b+1;t>c;c++)o=w[c][b],p=x[c][b],n=o*o+p*p,n>m&&(d=c,m=n);for(d!==b&&(s=w[b],w[b]=w[d],w[d]=s,s=x[b],x[b]=x[d],x[d]=s,s=u[b],u[b]=u[d],u[d]=s,s=v[b],v[b]=v[d],v[d]=s),e=w[b],f=x[b],i=u[b],j=v[b],o=e[b],p=f[b],c=b+1;t>c;c++)q=e[c],r=f[c],e[c]=(q*o+r*p)/m,f[c]=(r*o-q*p)/m;for(c=0;t>c;c++)q=i[c],r=j[c],i[c]=(q*o+r*p)/m,j[c]=(r*o-q*p)/m;for(c=b+1;t>c;c++){for(g=w[c],h=x[c],k=u[c],l=v[c],o=g[b],p=h[b],d=b+1;t>d;d++)q=e[d],r=f[d],g[d]-=q*o-r*p,h[d]-=r*o+q*p;for(d=0;t>d;d++)q=i[d],r=j[d],k[d]-=q*o-r*p,l[d]-=r*o+q*p}}for(b=t-1;b>0;b--)for(i=u[b],j=v[b],c=b-1;c>=0;c--)for(k=u[c],l=v[c],o=w[c][b],p=x[c][b],d=t-1;d>=0;d--)q=i[d],r=j[d],k[d]-=o*q-p*r,l[d]-=o*r+p*q;return new numeric.T(u,v)},numeric.T.prototype.get=function(a){var b,c=this.x,d=this.y,e=0,f=a.length;if(d){for(;f>e;)b=a[e],c=c[b],d=d[b],e++;return new numeric.T(c,d)}for(;f>e;)b=a[e],c=c[b],e++;return new numeric.T(c)},numeric.T.prototype.set=function(a,b){var c,d=this.x,e=this.y,f=0,g=a.length,h=b.x,i=b.y;if(0===g)return i?this.y=i:e&&(this.y=void 0),this.x=d,this;if(i){for(e||(e=numeric.rep(numeric.dim(d),0),this.y=e);g-1>f;)c=a[f],d=d[c],e=e[c],f++;return c=a[f],d[c]=h,e[c]=i,this}if(e){for(;g-1>f;)c=a[f],d=d[c],e=e[c],f++;return c=a[f],d[c]=h,e[c]=h instanceof Array?numeric.rep(numeric.dim(h),0):0,this}for(;g-1>f;)c=a[f],d=d[c],f++;return c=a[f],d[c]=h,this},numeric.T.prototype.getRows=function(a,b){var c,d,e=b-a+1,f=Array(e),g=this.x,h=this.y;for(c=a;b>=c;c++)f[c-a]=g[c];if(h){for(d=Array(e),c=a;b>=c;c++)d[c-a]=h[c];return new numeric.T(f,d)}return new numeric.T(f)},numeric.T.prototype.setRows=function(a,b,c){var d,e=this.x,f=this.y,g=c.x,h=c.y;for(d=a;b>=d;d++)e[d]=g[d-a];if(h)for(f||(f=numeric.rep(numeric.dim(e),0),this.y=f),d=a;b>=d;d++)f[d]=h[d-a];else if(f)for(d=a;b>=d;d++)f[d]=numeric.rep([g[d-a].length],0);return this},numeric.T.prototype.getRow=function(a){var b=this.x,c=this.y;return c?new numeric.T(b[a],c[a]):new numeric.T(b[a])},numeric.T.prototype.setRow=function(a,b){var c=this.x,d=this.y,e=b.x,f=b.y;return c[a]=e,f?(d||(d=numeric.rep(numeric.dim(c),0),this.y=d),d[a]=f):d&&(d=numeric.rep([e.length],0)),this},numeric.T.prototype.getBlock=function(a,b){var c=this.x,d=this.y,e=numeric.getBlock;return d?new numeric.T(e(c,a,b),e(d,a,b)):new numeric.T(e(c,a,b))},numeric.T.prototype.setBlock=function(a,b,c){c instanceof numeric.T||(c=new numeric.T(c));var d=this.x,e=this.y,f=numeric.setBlock,g=c.x,h=c.y;return h?(e||(this.y=numeric.rep(numeric.dim(this),0),e=this.y),f(d,a,b,g),f(e,a,b,h),this):(f(d,a,b,g),void(e&&f(e,a,b,numeric.rep(numeric.dim(g),0))))},numeric.T.rep=function(a,b){var c=numeric.T;b instanceof c||(b=new c(b));var d=b.x,e=b.y,f=numeric.rep;return e?new c(f(a,d),f(a,e)):new c(f(a,d))},numeric.T.diag=function h(a){a instanceof numeric.T||(a=new numeric.T(a));var b=a.x,c=a.y,h=numeric.diag;return c?new numeric.T(h(b),h(c)):new numeric.T(h(b))},numeric.T.eig=function(){if(this.y)throw new Error("eig: not implemented for complex matrices.");return numeric.eig(this.x)},numeric.T.identity=function(a){return new numeric.T(numeric.identity(a))},numeric.T.prototype.getDiag=function(){var a=numeric,b=this.x,c=this.y;return c?new a.T(a.getDiag(b),a.getDiag(c)):new a.T(a.getDiag(b))
},numeric.house=function(a){var b=numeric.clone(a),c=a[0]>=0?1:-1,d=c*numeric.norm2(a);b[0]+=d;var e=numeric.norm2(b);if(0===e)throw new Error("eig: internal error");return numeric.div(b,e)},numeric.toUpperHessenberg=function(a){var b=numeric.dim(a);if(2!==b.length||b[0]!==b[1])throw new Error("numeric: toUpperHessenberg() only works on square matrices");var c,d,e,f,g,h,i,j,k,l,m=b[0],n=numeric.clone(a),o=numeric.identity(m);for(d=0;m-2>d;d++){for(f=Array(m-d-1),c=d+1;m>c;c++)f[c-d-1]=n[c][d];if(numeric.norm2(f)>0){for(g=numeric.house(f),h=numeric.getBlock(n,[d+1,d],[m-1,m-1]),i=numeric.tensor(g,numeric.dot(g,h)),c=d+1;m>c;c++)for(j=n[c],k=i[c-d-1],e=d;m>e;e++)j[e]-=2*k[e-d];for(h=numeric.getBlock(n,[0,d+1],[m-1,m-1]),i=numeric.tensor(numeric.dot(h,g),g),c=0;m>c;c++)for(j=n[c],k=i[c],e=d+1;m>e;e++)j[e]-=2*k[e-d-1];for(h=Array(m-d-1),c=d+1;m>c;c++)h[c-d-1]=o[c];for(i=numeric.tensor(g,numeric.dot(g,h)),c=d+1;m>c;c++)for(l=o[c],k=i[c-d-1],e=0;m>e;e++)l[e]-=2*k[e]}}return{H:n,Q:o}},numeric.epsilon=2.220446049250313e-16,numeric.QRFrancis=function(a,b){"undefined"==typeof b&&(b=1e4),a=numeric.clone(a);var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u=(numeric.clone(a),numeric.dim(a)),v=u[0],w=numeric.identity(v);if(3>v)return{Q:w,B:[[0,v-1]]};var x=numeric.epsilon;for(t=0;b>t;t++){for(r=0;v-1>r;r++)if(Math.abs(a[r+1][r])<x*(Math.abs(a[r][r])+Math.abs(a[r+1][r+1]))){var y=numeric.QRFrancis(numeric.getBlock(a,[0,0],[r,r]),b),z=numeric.QRFrancis(numeric.getBlock(a,[r+1,r+1],[v-1,v-1]),b);for(n=Array(r+1),q=0;r>=q;q++)n[q]=w[q];for(o=numeric.dot(y.Q,n),q=0;r>=q;q++)w[q]=o[q];for(n=Array(v-r-1),q=r+1;v>q;q++)n[q-r-1]=w[q];for(o=numeric.dot(z.Q,n),q=r+1;v>q;q++)w[q]=o[q-r-1];return{Q:w,B:y.B.concat(numeric.add(z.B,r+1))}}if(e=a[v-2][v-2],f=a[v-2][v-1],g=a[v-1][v-2],h=a[v-1][v-1],j=e+h,i=e*h-f*g,k=numeric.getBlock(a,[0,0],[2,2]),j*j>=4*i){var A,B;A=.5*(j+Math.sqrt(j*j-4*i)),B=.5*(j-Math.sqrt(j*j-4*i)),k=numeric.add(numeric.sub(numeric.dot(k,k),numeric.mul(k,A+B)),numeric.diag(numeric.rep([3],A*B)))}else k=numeric.add(numeric.sub(numeric.dot(k,k),numeric.mul(k,j)),numeric.diag(numeric.rep([3],i)));for(c=[k[0][0],k[1][0],k[2][0]],d=numeric.house(c),n=[a[0],a[1],a[2]],o=numeric.tensor(d,numeric.dot(d,n)),q=0;3>q;q++)for(m=a[q],p=o[q],s=0;v>s;s++)m[s]-=2*p[s];for(n=numeric.getBlock(a,[0,0],[v-1,2]),o=numeric.tensor(numeric.dot(n,d),d),q=0;v>q;q++)for(m=a[q],p=o[q],s=0;3>s;s++)m[s]-=2*p[s];for(n=[w[0],w[1],w[2]],o=numeric.tensor(d,numeric.dot(d,n)),q=0;3>q;q++)for(l=w[q],p=o[q],s=0;v>s;s++)l[s]-=2*p[s];var C;for(r=0;v-2>r;r++){for(s=r;r+1>=s;s++)if(Math.abs(a[s+1][s])<x*(Math.abs(a[s][s])+Math.abs(a[s+1][s+1]))){var y=numeric.QRFrancis(numeric.getBlock(a,[0,0],[s,s]),b),z=numeric.QRFrancis(numeric.getBlock(a,[s+1,s+1],[v-1,v-1]),b);for(n=Array(s+1),q=0;s>=q;q++)n[q]=w[q];for(o=numeric.dot(y.Q,n),q=0;s>=q;q++)w[q]=o[q];for(n=Array(v-s-1),q=s+1;v>q;q++)n[q-s-1]=w[q];for(o=numeric.dot(z.Q,n),q=s+1;v>q;q++)w[q]=o[q-s-1];return{Q:w,B:y.B.concat(numeric.add(z.B,s+1))}}for(C=Math.min(v-1,r+3),c=Array(C-r),q=r+1;C>=q;q++)c[q-r-1]=a[q][r];for(d=numeric.house(c),n=numeric.getBlock(a,[r+1,r],[C,v-1]),o=numeric.tensor(d,numeric.dot(d,n)),q=r+1;C>=q;q++)for(m=a[q],p=o[q-r-1],s=r;v>s;s++)m[s]-=2*p[s-r];for(n=numeric.getBlock(a,[0,r+1],[v-1,C]),o=numeric.tensor(numeric.dot(n,d),d),q=0;v>q;q++)for(m=a[q],p=o[q],s=r+1;C>=s;s++)m[s]-=2*p[s-r-1];for(n=Array(C-r),q=r+1;C>=q;q++)n[q-r-1]=w[q];for(o=numeric.tensor(d,numeric.dot(d,n)),q=r+1;C>=q;q++)for(l=w[q],p=o[q-r-1],s=0;v>s;s++)l[s]-=2*p[s]}}throw new Error("numeric: eigenvalue iteration does not converge -- increase maxiter?")},numeric.eig=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=numeric.toUpperHessenberg(a),u=numeric.QRFrancis(t.H,b),v=numeric.T,w=a.length,x=u.B,y=numeric.dot(u.Q,numeric.dot(t.H,numeric.transpose(u.Q))),z=new v(numeric.dot(u.Q,t.Q)),A=x.length,B=Math.sqrt;for(d=0;A>d;d++)if(c=x[d][0],c!==x[d][1]){if(f=c+1,g=y[c][c],h=y[c][f],i=y[f][c],j=y[f][f],0===h&&0===i)continue;k=-g-j,l=g*j-h*i,m=k*k-4*l,m>=0?(n=0>k?-.5*(k-B(m)):-.5*(k+B(m)),r=(g-n)*(g-n)+h*h,s=i*i+(j-n)*(j-n),r>s?(r=B(r),p=(g-n)/r,q=h/r):(s=B(s),p=i/s,q=(j-n)/s),e=new v([[q,-p],[p,q]]),z.setRows(c,f,e.dot(z.getRows(c,f)))):(n=-.5*k,o=.5*B(-m),r=(g-n)*(g-n)+h*h,s=i*i+(j-n)*(j-n),r>s?(r=B(r+o*o),p=(g-n)/r,q=h/r,n=0,o/=r):(s=B(s+o*o),p=i/s,q=(j-n)/s,n=o/s,o=0),e=new v([[q,-p],[p,q]],[[n,o],[o,-n]]),z.setRows(c,f,e.dot(z.getRows(c,f))))}var C=z.dot(a).dot(z.transjugate()),w=a.length,D=numeric.T.identity(w);for(f=0;w>f;f++)if(f>0)for(d=f-1;d>=0;d--){var E=C.get([d,d]),F=C.get([f,f]);numeric.neq(E.x,F.x)||numeric.neq(E.y,F.y)?(n=C.getRow(d).getBlock([d],[f-1]),o=D.getRow(f).getBlock([d],[f-1]),D.set([f,d],C.get([d,f]).neg().sub(n.dot(o)).div(E.sub(F)))):D.setRow(f,D.getRow(d))}for(f=0;w>f;f++)n=D.getRow(f),D.setRow(f,n.div(n.norm2()));return D=D.transpose(),D=z.transjugate().dot(D),{lambda:C.getDiag(),E:D}},numeric.ccsSparse=function(a){var b,c,d,e,f=a.length,g=[];for(d=f-1;-1!==d;--d){c=a[d];for(e in c){for(e=parseInt(e);e>=g.length;)g[g.length]=0;0!==c[e]&&g[e]++}}var b=g.length,h=Array(b+1);for(h[0]=0,d=0;b>d;++d)h[d+1]=h[d]+g[d];var i=Array(h[b]),j=Array(h[b]);for(d=f-1;-1!==d;--d){c=a[d];for(e in c)0!==c[e]&&(g[e]--,i[h[e]+g[e]]=d,j[h[e]+g[e]]=c[e])}return[h,i,j]},numeric.ccsFull=function(a){var b,c,d,e,f=a[0],g=a[1],h=a[2],i=numeric.ccsDim(a),j=i[0],k=i[1],l=numeric.rep([j,k],0);for(b=0;k>b;b++)for(d=f[b],e=f[b+1],c=d;e>c;++c)l[g[c]][b]=h[c];return l},numeric.ccsTSolve=function(a,b,c,d,e){function f(a){var b;if(0===c[a]){for(c[a]=1,b=g[a];b<g[a+1];++b)f(h[b]);e[l]=a,++l}}var g=a[0],h=a[1],i=a[2],j=g.length-1,k=Math.max,l=0;"undefined"==typeof d&&(c=numeric.rep([j],0)),"undefined"==typeof d&&(d=numeric.linspace(0,c.length-1)),"undefined"==typeof e&&(e=[]);var m,n,o,p,q,r,s;for(m=d.length-1;-1!==m;--m)f(d[m]);for(e.length=l,m=e.length-1;-1!==m;--m)c[e[m]]=0;for(m=d.length-1;-1!==m;--m)n=d[m],c[n]=b[n];for(m=e.length-1;-1!==m;--m){for(n=e[m],o=g[n],p=k(g[n+1],o),q=o;q!==p;++q)if(h[q]===n){c[n]/=i[q];break}for(s=c[n],q=o;q!==p;++q)r=h[q],r!==n&&(c[r]-=s*i[q])}return c},numeric.ccsDFS=function(a){this.k=Array(a),this.k1=Array(a),this.j=Array(a)},numeric.ccsDFS.prototype.dfs=function(a,b,c,d,e,f){var g,h,i,j=0,k=e.length,l=this.k,m=this.k1,n=this.j;if(0===d[a])for(d[a]=1,n[0]=a,l[0]=h=b[a],m[0]=i=b[a+1];;)if(h>=i){if(e[k]=n[j],0===j)return;++k,--j,h=l[j],i=m[j]}else g=f[c[h]],0===d[g]?(d[g]=1,l[j]=h,++j,n[j]=g,h=b[g],m[j]=i=b[g+1]):++h},numeric.ccsLPSolve=function(a,b,c,d,e,f,g){var h,i,j,k,l,m,n,o,p,q=a[0],r=a[1],s=a[2],t=(q.length-1,b[0]),u=b[1],v=b[2];for(i=t[e],j=t[e+1],d.length=0,h=i;j>h;++h)g.dfs(f[u[h]],q,r,c,d,f);for(h=d.length-1;-1!==h;--h)c[d[h]]=0;for(h=i;h!==j;++h)k=f[u[h]],c[k]=v[h];for(h=d.length-1;-1!==h;--h){for(k=d[h],l=q[k],m=q[k+1],n=l;m>n;++n)if(f[r[n]]===k){c[k]/=s[n];break}for(p=c[k],n=l;m>n;++n)o=f[r[n]],o!==k&&(c[o]-=p*s[n])}return c},numeric.ccsLUP1=function(a,b){var c,d,e,f,g,h,i,j=a[0].length-1,k=[numeric.rep([j+1],0),[],[]],l=[numeric.rep([j+1],0),[],[]],m=k[0],n=k[1],o=k[2],p=l[0],q=l[1],r=l[2],s=numeric.rep([j],0),t=numeric.rep([j],0),u=numeric.ccsLPSolve,v=(Math.max,Math.abs),w=numeric.linspace(0,j-1),x=numeric.linspace(0,j-1),y=new numeric.ccsDFS(j);for("undefined"==typeof b&&(b=1),c=0;j>c;++c){for(u(k,a,s,t,c,x,y),f=-1,g=-1,d=t.length-1;-1!==d;--d)e=t[d],c>=e||(h=v(s[e]),h>f&&(g=e,f=h));for(v(s[c])<b*f&&(d=w[c],f=w[g],w[c]=f,x[f]=c,w[g]=d,x[d]=g,f=s[c],s[c]=s[g],s[g]=f),f=m[c],g=p[c],i=s[c],n[f]=w[c],o[f]=1,++f,d=t.length-1;-1!==d;--d)e=t[d],h=s[e],t[d]=0,s[e]=0,c>=e?(q[g]=e,r[g]=h,++g):(n[f]=w[e],o[f]=h/i,++f);m[c+1]=f,p[c+1]=g}for(d=n.length-1;-1!==d;--d)n[d]=x[n[d]];return{L:k,U:l,P:w,Pinv:x}},numeric.ccsDFS0=function(a){this.k=Array(a),this.k1=Array(a),this.j=Array(a)},numeric.ccsDFS0.prototype.dfs=function(a,b,c,d,e,f){var g,h,i,j=0,k=e.length,l=this.k,m=this.k1,n=this.j;if(0===d[a])for(d[a]=1,n[0]=a,l[0]=h=b[f[a]],m[0]=i=b[f[a]+1];;){if(isNaN(h))throw new Error("Ow!");if(h>=i){if(e[k]=f[n[j]],0===j)return;++k,--j,h=l[j],i=m[j]}else g=c[h],0===d[g]?(d[g]=1,l[j]=h,++j,n[j]=g,g=f[g],h=b[g],m[j]=i=b[g+1]):++h}},numeric.ccsLPSolve0=function(a,b,c,d,e,f,g,h){var i,j,k,l,m,n,o,p,q,r=a[0],s=a[1],t=a[2],u=(r.length-1,b[0]),v=b[1],w=b[2];for(j=u[e],k=u[e+1],d.length=0,i=j;k>i;++i)h.dfs(v[i],r,s,c,d,f,g);for(i=d.length-1;-1!==i;--i)l=d[i],c[g[l]]=0;for(i=j;i!==k;++i)l=v[i],c[l]=w[i];for(i=d.length-1;-1!==i;--i){for(l=d[i],p=g[l],m=r[l],n=r[l+1],o=m;n>o;++o)if(s[o]===p){c[p]/=t[o];break}for(q=c[p],o=m;n>o;++o)c[s[o]]-=q*t[o];c[p]=q}},numeric.ccsLUP0=function(a,b){var c,d,e,f,g,h,i,j=a[0].length-1,k=[numeric.rep([j+1],0),[],[]],l=[numeric.rep([j+1],0),[],[]],m=k[0],n=k[1],o=k[2],p=l[0],q=l[1],r=l[2],s=numeric.rep([j],0),t=numeric.rep([j],0),u=numeric.ccsLPSolve0,v=(Math.max,Math.abs),w=numeric.linspace(0,j-1),x=numeric.linspace(0,j-1),y=new numeric.ccsDFS0(j);for("undefined"==typeof b&&(b=1),c=0;j>c;++c){for(u(k,a,s,t,c,x,w,y),f=-1,g=-1,d=t.length-1;-1!==d;--d)e=t[d],c>=e||(h=v(s[w[e]]),h>f&&(g=e,f=h));for(v(s[w[c]])<b*f&&(d=w[c],f=w[g],w[c]=f,x[f]=c,w[g]=d,x[d]=g),f=m[c],g=p[c],i=s[w[c]],n[f]=w[c],o[f]=1,++f,d=t.length-1;-1!==d;--d)e=t[d],h=s[w[e]],t[d]=0,s[w[e]]=0,c>=e?(q[g]=e,r[g]=h,++g):(n[f]=w[e],o[f]=h/i,++f);m[c+1]=f,p[c+1]=g}for(d=n.length-1;-1!==d;--d)n[d]=x[n[d]];return{L:k,U:l,P:w,Pinv:x}},numeric.ccsLUP=numeric.ccsLUP0,numeric.ccsDim=function(a){return[numeric.sup(a[1])+1,a[0].length-1]},numeric.ccsGetBlock=function(a,b,c){var d=numeric.ccsDim(a),e=d[0],f=d[1];"undefined"==typeof b?b=numeric.linspace(0,e-1):"number"==typeof b&&(b=[b]),"undefined"==typeof c?c=numeric.linspace(0,f-1):"number"==typeof c&&(c=[c]);var g,h,i,j,k,l=b.length,m=c.length,n=numeric.rep([f],0),o=[],p=[],q=[n,o,p],r=a[0],s=a[1],t=a[2],u=numeric.rep([e],0),v=0,w=numeric.rep([e],0);for(h=0;m>h;++h){j=c[h];var x=r[j],y=r[j+1];for(g=x;y>g;++g)i=s[g],w[i]=1,u[i]=t[g];for(g=0;l>g;++g)k=b[g],w[k]&&(o[v]=g,p[v]=u[b[g]],++v);for(g=x;y>g;++g)i=s[g],w[i]=0;n[h+1]=v}return q},numeric.ccsDot=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=a[0],o=a[1],p=a[2],q=b[0],r=b[1],s=b[2],t=numeric.ccsDim(a),u=numeric.ccsDim(b),v=t[0],w=(t[1],u[1]),x=numeric.rep([v],0),y=numeric.rep([v],0),z=Array(v),A=numeric.rep([w],0),B=[],C=[],D=[A,B,C];for(e=0;e!==w;++e){for(f=q[e],g=q[e+1],k=0,d=f;g>d;++d)for(l=r[d],m=s[d],h=n[l],i=n[l+1],c=h;i>c;++c)j=o[c],0===y[j]&&(z[k]=j,y[j]=1,k+=1),x[j]=x[j]+p[c]*m;for(f=A[e],g=f+k,A[e+1]=g,d=k-1;-1!==d;--d)m=f+d,c=z[d],B[m]=c,C[m]=x[c],y[c]=0,x[c]=0;A[e+1]=A[e]+k}return D},numeric.ccsLUPSolve=function(a,b){var c=a.L,d=a.U,e=(a.P,b[0]),f=!1;"object"!=typeof e&&(b=[[0,b.length],numeric.linspace(0,b.length-1),b],e=b[0],f=!0);var g,h,i,j,k,l,m=b[1],n=b[2],o=c[0].length-1,p=e.length-1,q=numeric.rep([o],0),r=Array(o),s=numeric.rep([o],0),t=Array(o),u=numeric.rep([p+1],0),v=[],w=[],x=numeric.ccsTSolve,y=0;for(g=0;p>g;++g){for(k=0,i=e[g],j=e[g+1],h=i;j>h;++h)l=a.Pinv[m[h]],t[k]=l,s[l]=n[h],++k;for(t.length=k,x(c,s,q,t,r),h=t.length-1;-1!==h;--h)s[t[h]]=0;if(x(d,q,s,r,t),f)return s;for(h=r.length-1;-1!==h;--h)q[r[h]]=0;for(h=t.length-1;-1!==h;--h)l=t[h],v[y]=l,w[y]=s[l],s[l]=0,++y;u[g+1]=y}return[u,v,w]},numeric.ccsbinop=function(a,b){return"undefined"==typeof b&&(b=""),Function("X","Y","var Xi = X[0], Xj = X[1], Xv = X[2];\nvar Yi = Y[0], Yj = Y[1], Yv = Y[2];\nvar n = Xi.length-1,m = Math.max(numeric.sup(Xj),numeric.sup(Yj))+1;\nvar Zi = numeric.rep([n+1],0), Zj = [], Zv = [];\nvar x = numeric.rep([m],0),y = numeric.rep([m],0);\nvar xk,yk,zk;\nvar i,j,j0,j1,k,p=0;\n"+b+"for(i=0;i<n;++i) {\n  j0 = Xi[i]; j1 = Xi[i+1];\n  for(j=j0;j!==j1;++j) {\n    k = Xj[j];\n    x[k] = 1;\n    Zj[p] = k;\n    ++p;\n  }\n  j0 = Yi[i]; j1 = Yi[i+1];\n  for(j=j0;j!==j1;++j) {\n    k = Yj[j];\n    y[k] = Yv[j];\n    if(x[k] === 0) {\n      Zj[p] = k;\n      ++p;\n    }\n  }\n  Zi[i+1] = p;\n  j0 = Xi[i]; j1 = Xi[i+1];\n  for(j=j0;j!==j1;++j) x[Xj[j]] = Xv[j];\n  j0 = Zi[i]; j1 = Zi[i+1];\n  for(j=j0;j!==j1;++j) {\n    k = Zj[j];\n    xk = x[k];\n    yk = y[k];\n"+a+"\n    Zv[j] = zk;\n  }\n  j0 = Xi[i]; j1 = Xi[i+1];\n  for(j=j0;j!==j1;++j) x[Xj[j]] = 0;\n  j0 = Yi[i]; j1 = Yi[i+1];\n  for(j=j0;j!==j1;++j) y[Yj[j]] = 0;\n}\nreturn [Zi,Zj,Zv];")},function(){var k,A,B,C;for(k in numeric.ops2)A=isFinite(eval("1"+numeric.ops2[k]+"0"))?"[Y[0],Y[1],numeric."+k+"(X,Y[2])]":"NaN",B=isFinite(eval("0"+numeric.ops2[k]+"1"))?"[X[0],X[1],numeric."+k+"(X[2],Y)]":"NaN",C=isFinite(eval("1"+numeric.ops2[k]+"0"))&&isFinite(eval("0"+numeric.ops2[k]+"1"))?"numeric.ccs"+k+"MM(X,Y)":"NaN",numeric["ccs"+k+"MM"]=numeric.ccsbinop("zk = xk "+numeric.ops2[k]+"yk;"),numeric["ccs"+k]=Function("X","Y",'if(typeof X === "number") return '+A+';\nif(typeof Y === "number") return '+B+";\nreturn "+C+";\n")}(),numeric.ccsScatter=function(a){var b,c=a[0],d=a[1],e=a[2],f=numeric.sup(d)+1,g=c.length,h=numeric.rep([f],0),i=Array(g),j=Array(g),k=numeric.rep([f],0);for(b=0;g>b;++b)k[d[b]]++;for(b=0;f>b;++b)h[b+1]=h[b]+k[b];var l,m,n=h.slice(0);for(b=0;g>b;++b)m=d[b],l=n[m],i[l]=c[b],j[l]=e[b],n[m]=n[m]+1;return[h,i,j]},numeric.ccsGather=function(a){var b,c,d,e,f,g=a[0],h=a[1],i=a[2],j=g.length-1,k=h.length,l=Array(k),m=Array(k),n=Array(k);for(f=0,b=0;j>b;++b)for(d=g[b],e=g[b+1],c=d;c!==e;++c)m[f]=b,l[f]=h[c],n[f]=i[c],++f;return[l,m,n]},numeric.sdim=function i(a,b,c){if("undefined"==typeof b&&(b=[]),"object"!=typeof a)return b;"undefined"==typeof c&&(c=0),c in b||(b[c]=0),a.length>b[c]&&(b[c]=a.length);var d;for(d in a)a.hasOwnProperty(d)&&i(a[d],b,c+1);return b},numeric.sclone=function j(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=numeric.sdim(a).length);var d,e=Array(a.length);if(b===c-1){for(d in a)a.hasOwnProperty(d)&&(e[d]=a[d]);return e}for(d in a)a.hasOwnProperty(d)&&(e[d]=j(a[d],b+1,c));return e},numeric.sdiag=function(a){var b,c,d=a.length,e=Array(d);for(b=d-1;b>=1;b-=2)c=b-1,e[b]=[],e[b][b]=a[b],e[c]=[],e[c][c]=a[c];return 0===b&&(e[0]=[],e[0][0]=a[b]),e},numeric.sidentity=function(a){return numeric.sdiag(numeric.rep([a],1))},numeric.stranspose=function(a){{var b,c,d,e=[];a.length}for(b in a)if(a.hasOwnProperty(b)){d=a[b];for(c in d)d.hasOwnProperty(c)&&("object"!=typeof e[c]&&(e[c]=[]),e[c][b]=d[c])}return e},numeric.sLUP=function(){throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.")},numeric.sdotMM=function(a,b){var c,d,e,f,g,h,i,j=a.length,k=(b.length,numeric.stranspose(b)),l=k.length,m=Array(j);for(e=j-1;e>=0;e--){for(i=[],c=a[e],g=l-1;g>=0;g--){h=0,d=k[g];for(f in c)c.hasOwnProperty(f)&&f in d&&(h+=c[f]*d[f]);h&&(i[g]=h)}m[e]=i}return m},numeric.sdotMV=function(a,b){var c,d,e,f,g=a.length,h=Array(g);for(d=g-1;d>=0;d--){c=a[d],f=0;for(e in c)c.hasOwnProperty(e)&&b[e]&&(f+=c[e]*b[e]);f&&(h[d]=f)}return h},numeric.sdotVM=function(a,b){var c,d,e,f,g=[];for(c in a)if(a.hasOwnProperty(c)){e=b[c],f=a[c];for(d in e)e.hasOwnProperty(d)&&(g[d]||(g[d]=0),g[d]+=f*e[d])}return g},numeric.sdotVV=function(a,b){var c,d=0;for(c in a)a[c]&&b[c]&&(d+=a[c]*b[c]);return d},numeric.sdot=function(a,b){var c=numeric.sdim(a).length,d=numeric.sdim(b).length,e=1e3*c+d;switch(e){case 0:return a*b;case 1001:return numeric.sdotVV(a,b);case 2001:return numeric.sdotMV(a,b);case 1002:return numeric.sdotVM(a,b);case 2002:return numeric.sdotMM(a,b);default:throw new Error("numeric.sdot not implemented for tensors of order "+c+" and "+d)}},numeric.sscatter=function(a){var b,c,d,e,f=a[0].length,g=a.length,h=[];for(c=f-1;c>=0;--c)if(a[g-1][c]){for(e=h,d=0;g-2>d;d++)b=a[d][c],e[b]||(e[b]=[]),e=e[b];e[a[d][c]]=a[d+1][c]}return h},numeric.sgather=function k(a,b,c){"undefined"==typeof b&&(b=[]),"undefined"==typeof c&&(c=[]);var d,e,f;d=c.length;for(e in a)if(a.hasOwnProperty(e))if(c[d]=parseInt(e),f=a[e],"number"==typeof f){if(f){if(0===b.length)for(e=d+1;e>=0;--e)b[e]=[];for(e=d;e>=0;--e)b[e].push(c[e]);b[d+1].push(f)}}else k(f,b,c);return c.length>d&&c.pop(),b},numeric.cLU=function(a){var b,c,d,e,f,g,h=a[0],i=a[1],j=a[2],k=h.length,l=0;for(b=0;k>b;b++)h[b]>l&&(l=h[b]);l++;var m,n,o,p=Array(l),q=Array(l),r=numeric.rep([l],1/0),s=numeric.rep([l],-1/0);for(d=0;k>d;d++)b=h[d],c=i[d],c<r[b]&&(r[b]=c),c>s[b]&&(s[b]=c);for(b=0;l-1>b;b++)s[b]>s[b+1]&&(s[b+1]=s[b]);for(b=l-1;b>=1;b--)r[b]<r[b-1]&&(r[b-1]=r[b]);var t=0,u=0;for(b=0;l>b;b++)q[b]=numeric.rep([s[b]-r[b]+1],0),p[b]=numeric.rep([b-r[b]],0),t+=b-r[b]+1,u+=s[b]-b+1;for(d=0;k>d;d++)b=h[d],q[b][i[d]-r[b]]=j[d];for(b=0;l-1>b;b++)for(e=b-r[b],m=q[b],c=b+1;r[c]<=b&&l>c;c++)if(f=b-r[c],g=s[b]-b,n=q[c],o=n[f]/m[e],o){for(d=1;g>=d;d++)n[d+f]-=o*m[d+e];p[c][b-r[c]]=o}var k,v,w,m=[],n=[],x=[],y=[],z=[],A=[];for(k=0,v=0,b=0;l>b;b++){for(e=r[b],f=s[b],w=q[b],c=b;f>=c;c++)w[c-e]&&(m[k]=b,n[k]=c,x[k]=w[c-e],k++);for(w=p[b],c=e;b>c;c++)w[c-e]&&(y[v]=b,z[v]=c,A[v]=w[c-e],v++);y[v]=b,z[v]=b,A[v]=1,v++}return{U:[m,n,x],L:[y,z,A]}},numeric.cLUsolve=function(a,b){var c,d,e=a.L,f=a.U,g=numeric.clone(b),h=e[0],i=e[1],j=e[2],k=f[0],l=f[1],m=f[2],n=k.length,o=(h.length,g.length);for(d=0,c=0;o>c;c++){for(;i[d]<c;)g[c]-=j[d]*g[i[d]],d++;d++}for(d=n-1,c=o-1;c>=0;c--){for(;l[d]>c;)g[c]-=m[d]*g[l[d]],d--;g[c]/=m[d],d--}return g},numeric.cgrid=function(a,b){"number"==typeof a&&(a=[a,a]);var c,d,e,f=numeric.rep(a,-1);if("function"!=typeof b)switch(b){case"L":b=function(b,c){return b>=a[0]/2||c<a[1]/2};break;default:b=function(){return!0}}for(e=0,c=1;c<a[0]-1;c++)for(d=1;d<a[1]-1;d++)b(c,d)&&(f[c][d]=e,e++);return f},numeric.cdelsq=function(a){var b,c,d,e,f,g=[[-1,0],[0,-1],[0,1],[1,0]],h=numeric.dim(a),i=h[0],j=h[1],k=[],l=[],m=[];for(b=1;i-1>b;b++)for(c=1;j-1>c;c++)if(!(a[b][c]<0)){for(d=0;4>d;d++)e=b+g[d][0],f=c+g[d][1],a[e][f]<0||(k.push(a[b][c]),l.push(a[e][f]),m.push(-1));k.push(a[b][c]),l.push(a[b][c]),m.push(4)}return[k,l,m]},numeric.cdotMV=function(a,b){var c,d,e,f=a[0],g=a[1],h=a[2],i=f.length;for(e=0,d=0;i>d;d++)f[d]>e&&(e=f[d]);for(e++,c=numeric.rep([e],0),d=0;i>d;d++)c[f[d]]+=h[d]*b[g[d]];return c},numeric.Spline=function(a,b,c,d,e){this.x=a,this.yl=b,this.yr=c,this.kl=d,this.kr=e},numeric.Spline.prototype._at=function(a,b){var a,c,d,e,f=this.x,g=this.yl,h=this.yr,i=this.kl,j=this.kr,k=numeric.add,l=numeric.sub,m=numeric.mul;c=l(m(i[b],f[b+1]-f[b]),l(h[b+1],g[b])),d=k(m(j[b+1],f[b]-f[b+1]),l(h[b+1],g[b])),e=(a-f[b])/(f[b+1]-f[b]);var n=e*(1-e);return k(k(k(m(1-e,g[b]),m(e,h[b+1])),m(c,n*(1-e))),m(d,n*e))},numeric.Spline.prototype.at=function(a){if("number"==typeof a){var b,c,d,e=this.x,f=e.length,g=Math.floor;for(b=0,c=f-1;c-b>1;)d=g((b+c)/2),e[d]<=a?b=d:c=d;return this._at(a,b)}var h,f=a.length,i=Array(f);for(h=f-1;-1!==h;--h)i[h]=this.at(a[h]);return i},numeric.Spline.prototype.diff=function(){var a,b,c,d=this.x,e=this.yl,f=this.yr,g=this.kl,h=this.kr,i=e.length,j=g,k=h,l=Array(i),m=Array(i),n=numeric.add,o=numeric.mul,p=numeric.div,q=numeric.sub;for(a=i-1;-1!==a;--a)b=d[a+1]-d[a],c=q(f[a+1],e[a]),l[a]=p(n(o(c,6),o(g[a],-4*b),o(h[a+1],-2*b)),b*b),m[a+1]=p(n(o(c,-6),o(g[a],2*b),o(h[a+1],4*b)),b*b);return new numeric.Spline(d,j,k,l,m)},numeric.Spline.prototype.roots=function(){function a(a){return a*a}var b=[],c=this.x,d=this.yl,e=this.yr,f=this.kl,g=this.kr;"number"==typeof d[0]&&(d=[d],e=[e],f=[f],g=[g]);var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F=d.length,G=c.length-1,b=Array(F),H=Math.sqrt;for(h=0;h!==F;++h){for(k=d[h],l=e[h],m=f[h],n=g[h],o=[],i=0;i!==G;i++){for(i>0&&l[i]*k[i]<0&&o.push(c[i]),w=c[i+1]-c[i],x=c[i],r=k[i],s=l[i+1],p=m[i]/w,q=n[i+1]/w,v=a(p-q+3*(r-s))+12*q*r,t=q+3*r+2*p-3*s,u=3*(q+p+2*(r-s)),0>=v?(z=t/u,y=z>c[i]&&z<c[i+1]?[c[i],z,c[i+1]]:[c[i],c[i+1]]):(z=(t-H(v))/u,A=(t+H(v))/u,y=[c[i]],z>c[i]&&z<c[i+1]&&y.push(z),A>c[i]&&A<c[i+1]&&y.push(A),y.push(c[i+1])),C=y[0],z=this._at(C,i),j=0;j<y.length-1;j++)if(D=y[j+1],A=this._at(D,i),0!==z)if(0===A||z*A>0)C=D,z=A;else{for(var I=0;E=(z*D-A*C)/(z-A),!(C>=E||E>=D);)if(B=this._at(E,i),B*A>0)D=E,A=B,-1===I&&(z*=.5),I=-1;else{if(!(B*z>0))break;C=E,z=B,1===I&&(A*=.5),I=1}o.push(E),C=y[j+1],z=this._at(C,i)}else o.push(C),C=D,z=A;0===A&&o.push(D)}b[h]=o}return"number"==typeof this.yl[0]?b[0]:b},numeric.spline=function(a,b,c,d){var e,f=a.length,g=[],h=[],i=[],j=numeric.sub,k=numeric.mul,l=numeric.add;for(e=f-2;e>=0;e--)h[e]=a[e+1]-a[e],i[e]=j(b[e+1],b[e]);("string"==typeof c||"string"==typeof d)&&(c=d="periodic");var m=[[],[],[]];switch(typeof c){case"undefined":g[0]=k(3/(h[0]*h[0]),i[0]),m[0].push(0,0),m[1].push(0,1),m[2].push(2/h[0],1/h[0]);break;case"string":g[0]=l(k(3/(h[f-2]*h[f-2]),i[f-2]),k(3/(h[0]*h[0]),i[0])),m[0].push(0,0,0),m[1].push(f-2,0,1),m[2].push(1/h[f-2],2/h[f-2]+2/h[0],1/h[0]);break;default:g[0]=c,m[0].push(0),m[1].push(0),m[2].push(1)}for(e=1;f-1>e;e++)g[e]=l(k(3/(h[e-1]*h[e-1]),i[e-1]),k(3/(h[e]*h[e]),i[e])),m[0].push(e,e,e),m[1].push(e-1,e,e+1),m[2].push(1/h[e-1],2/h[e-1]+2/h[e],1/h[e]);switch(typeof d){case"undefined":g[f-1]=k(3/(h[f-2]*h[f-2]),i[f-2]),m[0].push(f-1,f-1),m[1].push(f-2,f-1),m[2].push(1/h[f-2],2/h[f-2]);break;case"string":m[1][m[1].length-1]=0;break;default:g[f-1]=d,m[0].push(f-1),m[1].push(f-1),m[2].push(1)}g="number"!=typeof g[0]?numeric.transpose(g):[g];var n=Array(g.length);if("string"==typeof c)for(e=n.length-1;-1!==e;--e)n[e]=numeric.ccsLUPSolve(numeric.ccsLUP(numeric.ccsScatter(m)),g[e]),n[e][f-1]=n[e][0];else for(e=n.length-1;-1!==e;--e)n[e]=numeric.cLUsolve(numeric.cLU(m),g[e]);return n="number"==typeof b[0]?n[0]:numeric.transpose(n),new numeric.Spline(a,b,b,n,n)},numeric.fftpow2=function l(a,b){var c=a.length;if(1!==c){var d,e,f=Math.cos,g=Math.sin,h=Array(c/2),i=Array(c/2),j=Array(c/2),k=Array(c/2);for(e=c/2,d=c-1;-1!==d;--d)--e,j[e]=a[d],k[e]=b[d],--d,h[e]=a[d],i[e]=b[d];l(h,i),l(j,k),e=c/2;var m,n,o,p=-6.283185307179586/c;for(d=c-1;-1!==d;--d)--e,-1===e&&(e=c/2-1),m=p*d,n=f(m),o=g(m),a[d]=h[e]+n*j[e]-o*k[e],b[d]=i[e]+n*k[e]+o*j[e]}},numeric._ifftpow2=function m(a,b){var c=a.length;if(1!==c){var d,e,f=Math.cos,g=Math.sin,h=Array(c/2),i=Array(c/2),j=Array(c/2),k=Array(c/2);for(e=c/2,d=c-1;-1!==d;--d)--e,j[e]=a[d],k[e]=b[d],--d,h[e]=a[d],i[e]=b[d];m(h,i),m(j,k),e=c/2;var l,n,o,p=6.283185307179586/c;for(d=c-1;-1!==d;--d)--e,-1===e&&(e=c/2-1),l=p*d,n=f(l),o=g(l),a[d]=h[e]+n*j[e]-o*k[e],b[d]=i[e]+n*k[e]+o*j[e]}},numeric.ifftpow2=function(a,b){numeric._ifftpow2(a,b),numeric.diveq(a,a.length),numeric.diveq(b,b.length)},numeric.convpow2=function(a,b,c,d){numeric.fftpow2(a,b),numeric.fftpow2(c,d);var e,f,g,h,i,j=a.length;for(e=j-1;-1!==e;--e)f=a[e],h=b[e],g=c[e],i=d[e],a[e]=f*g-h*i,b[e]=f*i+h*g;numeric.ifftpow2(a,b)},numeric.T.prototype.fft=function(){{var a,b,c=this.x,d=this.y,e=c.length,f=Math.log,g=f(2),h=Math.ceil(f(2*e-1)/g),i=Math.pow(2,h),j=numeric.rep([i],0),k=numeric.rep([i],0),l=Math.cos,m=Math.sin,n=-3.141592653589793/e,o=numeric.rep([i],0),p=numeric.rep([i],0);Math.floor(e/2)}for(a=0;e>a;a++)o[a]=c[a];if("undefined"!=typeof d)for(a=0;e>a;a++)p[a]=d[a];for(j[0]=1,a=1;i/2>=a;a++)b=n*a*a,j[a]=l(b),k[a]=m(b),j[i-a]=l(b),k[i-a]=m(b);var q=new numeric.T(o,p),r=new numeric.T(j,k);return q=q.mul(r),numeric.convpow2(q.x,q.y,numeric.clone(r.x),numeric.neg(r.y)),q=q.mul(r),q.x.length=e,q.y.length=e,q},numeric.T.prototype.ifft=function(){{var a,b,c=this.x,d=this.y,e=c.length,f=Math.log,g=f(2),h=Math.ceil(f(2*e-1)/g),i=Math.pow(2,h),j=numeric.rep([i],0),k=numeric.rep([i],0),l=Math.cos,m=Math.sin,n=3.141592653589793/e,o=numeric.rep([i],0),p=numeric.rep([i],0);Math.floor(e/2)}for(a=0;e>a;a++)o[a]=c[a];if("undefined"!=typeof d)for(a=0;e>a;a++)p[a]=d[a];for(j[0]=1,a=1;i/2>=a;a++)b=n*a*a,j[a]=l(b),k[a]=m(b),j[i-a]=l(b),k[i-a]=m(b);var q=new numeric.T(o,p),r=new numeric.T(j,k);return q=q.mul(r),numeric.convpow2(q.x,q.y,numeric.clone(r.x),numeric.neg(r.y)),q=q.mul(r),q.x.length=e,q.y.length=e,q.div(e)},numeric.gradient=function(a,b){var c=b.length,d=a(b);if(isNaN(d))throw new Error("gradient: f(x) is a NaN!");var e,f,g,h,i,j,k,l,m,n,o=Math.max,p=numeric.clone(b),q=Array(c),o=(numeric.div,numeric.sub,Math.max),r=.001,s=Math.abs,t=Math.min,u=0;for(e=0;c>e;e++)for(var v=o(1e-6*d,1e-8);;){if(++u,u>20)throw new Error("Numerical gradient fails");if(p[e]=b[e]+v,f=a(p),p[e]=b[e]-v,g=a(p),p[e]=b[e],isNaN(f)||isNaN(g))v/=16;else{if(q[e]=(f-g)/(2*v),i=b[e]-v,j=b[e],k=b[e]+v,l=(f-d)/v,m=(d-g)/v,n=o(s(q[e]),s(d),s(f),s(g),s(i),s(j),s(k),1e-8),h=t(o(s(l-q[e]),s(m-q[e]),s(l-m))/n,v/n),!(h>r))break;v/=16}}return q},numeric.uncmin=function(a,b,c,d,e,f,g){var h=numeric.gradient;"undefined"==typeof g&&(g={}),"undefined"==typeof c&&(c=1e-8),"undefined"==typeof d&&(d=function(b){return h(a,b)}),"undefined"==typeof e&&(e=1e3),b=numeric.clone(b);var i,j,k=b.length,l=a(b);if(isNaN(l))throw new Error("uncmin: f(x0) is a NaN!");var m=Math.max,n=numeric.norm2;c=m(c,numeric.epsilon);var o,p,q,r,s,t,u,v,w,x,y=g.Hinv||numeric.identity(k),z=numeric.dot,A=(numeric.inv,numeric.sub),B=numeric.add,C=numeric.tensor,D=numeric.div,E=numeric.mul,F=numeric.all,G=numeric.isFinite,H=numeric.neg,I=0,J="";for(p=d(b);e>I;){if("function"==typeof f&&f(I,b,l,p,y)){J="Callback returned true";break}if(!F(G(p))){J="Gradient has Infinity or NaN";break}if(o=H(z(y,p)),!F(G(o))){J="Search direction has Infinity or NaN";break}if(x=n(o),c>x){J="Newton step smaller than tol";break}for(w=1,j=z(p,o),s=b;e>I&&!(c>w*x)&&(r=E(o,w),s=B(b,r),i=a(s),i-l>=.1*w*j||isNaN(i));)w*=.5,++I;if(c>w*x){J="Line search step size smaller than tol";break}if(I===e){J="maxit reached during line search";break}q=d(s),t=A(q,p),v=z(t,r),u=z(y,t),y=A(B(y,E((v+z(t,u))/(v*v),C(r,r))),D(B(C(u,r),C(r,u)),v)),b=s,l=i,p=q,++I}return{solution:b,f:l,gradient:p,invHessian:y,iterations:I,message:J}},numeric.Dopri=function(a,b,c,d,e,f,g){this.x=a,this.y=b,this.f=c,this.ymid=d,this.iterations=e,this.events=g,this.message=f},numeric.Dopri.prototype._at=function(a,b){function c(a){return a*a}var d,e,f,g,h,i,a,j,k,l,m,n=this,o=n.x,p=n.y,q=n.f,r=n.ymid,s=(o.length,Math.floor,.5),t=numeric.add,u=numeric.mul,v=numeric.sub;return d=o[b],e=o[b+1],g=p[b],h=p[b+1],j=e-d,f=d+s*j,i=r[b],k=v(q[b],u(g,1/(d-f)+2/(d-e))),l=v(q[b+1],u(h,1/(e-f)+2/(e-d))),m=[c(a-e)*(a-f)/c(d-e)/(d-f),c(a-d)*c(a-e)/c(d-f)/c(e-f),c(a-d)*(a-f)/c(e-d)/(e-f),(a-d)*c(a-e)*(a-f)/c(d-e)/(d-f),(a-e)*c(a-d)*(a-f)/c(d-e)/(e-f)],t(t(t(t(u(g,m[0]),u(i,m[1])),u(h,m[2])),u(k,m[3])),u(l,m[4]))},numeric.Dopri.prototype.at=function(a){var b,c,d,e=Math.floor;if("number"!=typeof a){var f=a.length,g=Array(f);for(b=f-1;-1!==b;--b)g[b]=this.at(a[b]);return g}var h=this.x;for(b=0,c=h.length-1;c-b>1;)d=e(.5*(b+c)),h[d]<=a?b=d:c=d;return this._at(a,b)},numeric.dopri=function(a,b,c,d,e,f,g){"undefined"==typeof e&&(e=1e-6),"undefined"==typeof f&&(f=1e3);var h,i,j,k,l,m,n,o,p,q,r,s,t,u=[a],v=[c],w=[d(a,c)],x=[],y=.2,z=[.075,.225],A=[44/45,-56/15,32/9],B=[19372/6561,-25360/2187,64448/6561,-212/729],C=[9017/3168,-355/33,46732/5247,49/176,-5103/18656],D=[35/384,0,500/1113,125/192,-2187/6784,11/84],E=[.10013431883002395,0,.3918321794184259,-.02982460176594817,.05893268337240795,-.04497888809104361,.023904308236133973],F=[.2,.3,.8,8/9,1,1],G=[-71/57600,0,71/16695,-71/1920,17253/339200,-22/525,.025],H=0,I=(b-a)/10,J=0,K=numeric.add,L=numeric.mul,M=(Math.max,Math.min),N=Math.abs,O=numeric.norminf,P=Math.pow,Q=numeric.any,R=numeric.lt,S=numeric.and,T=(numeric.sub,new numeric.Dopri(u,v,w,x,-1,""));for("function"==typeof g&&(r=g(a,c));b>a&&f>J;)if(++J,a+I>b&&(I=b-a),h=d(a+F[0]*I,K(c,L(y*I,w[H]))),i=d(a+F[1]*I,K(K(c,L(z[0]*I,w[H])),L(z[1]*I,h))),j=d(a+F[2]*I,K(K(K(c,L(A[0]*I,w[H])),L(A[1]*I,h)),L(A[2]*I,i))),k=d(a+F[3]*I,K(K(K(K(c,L(B[0]*I,w[H])),L(B[1]*I,h)),L(B[2]*I,i)),L(B[3]*I,j))),l=d(a+F[4]*I,K(K(K(K(K(c,L(C[0]*I,w[H])),L(C[1]*I,h)),L(C[2]*I,i)),L(C[3]*I,j)),L(C[4]*I,k))),p=K(K(K(K(K(c,L(w[H],I*D[0])),L(i,I*D[2])),L(j,I*D[3])),L(k,I*D[4])),L(l,I*D[5])),m=d(a+I,p),n=K(K(K(K(K(L(w[H],I*G[0]),L(i,I*G[2])),L(j,I*G[3])),L(k,I*G[4])),L(l,I*G[5])),L(m,I*G[6])),q="number"==typeof n?N(n):O(n),q>e){if(I=.2*I*P(e/q,.25),a+I===a){T.msg="Step size became too small";break}}else{if(x[H]=K(K(K(K(K(K(c,L(w[H],I*E[0])),L(i,I*E[2])),L(j,I*E[3])),L(k,I*E[4])),L(l,I*E[5])),L(m,I*E[6])),++H,u[H]=a+I,v[H]=p,w[H]=m,"function"==typeof g){var U,V,W=a,X=a+.5*I;if(s=g(X,x[H-1]),t=S(R(r,0),R(0,s)),Q(t)||(W=X,X=a+I,r=s,s=g(X,p),t=S(R(r,0),R(0,s))),Q(t)){for(var Y,Z,$=0,_=1,ab=1;;){if("number"==typeof r)V=(ab*s*W-_*r*X)/(ab*s-_*r);else for(V=X,o=r.length-1;-1!==o;--o)r[o]<0&&s[o]>0&&(V=M(V,(ab*s[o]*W-_*r[o]*X)/(ab*s[o]-_*r[o])));if(W>=V||V>=X)break;U=T._at(V,H-1),Z=g(V,U),Y=S(R(r,0),R(0,Z)),Q(Y)?(X=V,s=Z,t=Y,ab=1,-1===$?_*=.5:_=1,$=-1):(W=V,r=Z,_=1,1===$?ab*=.5:ab=1,$=1)}return p=T._at(.5*(a+V),H-1),T.f[H]=d(V,U),T.x[H]=V,T.y[H]=U,T.ymid[H-1]=p,T.events=t,T.iterations=J,T}}a+=I,c=p,r=s,I=M(.8*I*P(e/q,.25),4*I)}return T.iterations=J,T},numeric.LU=function(a,b){b=b||!1;var c,d,e,f,g,h,i,j,k,l=Math.abs,m=a.length,n=m-1,o=new Array(m);for(b||(a=numeric.clone(a)),e=0;m>e;++e){for(i=e,h=a[e],k=l(h[e]),d=e+1;m>d;++d)f=l(a[d][e]),f>k&&(k=f,i=d);for(o[e]=i,i!=e&&(a[e]=a[i],a[i]=h,h=a[e]),g=h[e],c=e+1;m>c;++c)a[c][e]/=g;for(c=e+1;m>c;++c){for(j=a[c],d=e+1;n>d;++d)j[d]-=j[e]*h[d],++d,j[d]-=j[e]*h[d];d===n&&(j[d]-=j[e]*h[d])}}return{LU:a,P:o}},numeric.LUsolve=function(a,b){var c,d,e,f,g,h=a.LU,i=h.length,j=numeric.clone(b),k=a.P;for(c=i-1;-1!==c;--c)j[c]=b[c];for(c=0;i>c;++c)for(e=k[c],k[c]!==c&&(g=j[c],j[c]=j[e],j[e]=g),f=h[c],d=0;c>d;++d)j[c]-=j[d]*f[d];for(c=i-1;c>=0;--c){for(f=h[c],d=c+1;i>d;++d)j[c]-=j[d]*f[d];j[c]/=f[c]}return j},numeric.solve=function(a,b,c){return numeric.LUsolve(numeric.LU(a,c),b)},numeric.echelonize=function(a){var b,c,d,e,f,g,h,i,j=numeric.dim(a),k=j[0],l=j[1],m=numeric.identity(k),n=Array(k),o=Math.abs,p=numeric.diveq;for(a=numeric.clone(a),b=0;k>b;++b){for(d=0,f=a[b],g=m[b],c=1;l>c;++c)o(f[d])<o(f[c])&&(d=c);for(n[b]=d,p(g,f[d]),p(f,f[d]),c=0;k>c;++c)if(c!==b){for(h=a[c],i=h[d],e=l-1;-1!==e;--e)h[e]-=f[e]*i;for(h=m[c],e=k-1;-1!==e;--e)h[e]-=g[e]*i}}return{I:m,A:a,P:n}},numeric.__solveLP=function(a,b,c,d,e,f,g){var h,i,j,k,l=numeric.sum,m=(numeric.log,numeric.mul),n=numeric.sub,o=numeric.dot,p=numeric.div,q=numeric.add,r=a.length,s=c.length,t=!1,u=0,v=1,w=(numeric.transpose(b),numeric.svd,numeric.transpose),x=(numeric.leq,Math.sqrt),y=Math.abs,z=(numeric.muleq,numeric.norminf,numeric.any,Math.min),A=numeric.all,B=numeric.gt,C=Array(r),D=Array(s),E=(numeric.rep([s],1),numeric.solve),F=n(c,o(b,f)),G=o(a,a);for(j=u;e>j;++j){var H,I;for(H=s-1;-1!==H;--H)D[H]=p(b[H],F[H]);var J=w(D);for(H=r-1;-1!==H;--H)C[H]=l(J[H]);v=.25*y(G/o(a,C));var K=100*x(G/o(C,C));for((!isFinite(v)||v>K)&&(v=K),k=q(a,m(v,C)),i=o(J,D),H=r-1;-1!==H;--H)i[H][H]+=1;I=E(i,p(k,v),!0);var L=p(F,o(b,I)),M=1;for(H=s-1;-1!==H;--H)L[H]<0&&(M=z(M,-.999*L[H]));if(h=n(f,m(I,M)),F=n(c,o(b,h)),!A(B(F,0)))return{solution:f,message:"",iterations:j};if(f=h,d>v)return{solution:h,message:"",iterations:j};if(g){var N=o(a,k),O=o(b,k);for(t=!0,H=s-1;-1!==H;--H)if(N*O[H]<0){t=!1;break}}else t=f[r-1]>=0?!1:!0;if(t)return{solution:h,message:"Unbounded",iterations:j}}return{solution:f,message:"maximum iteration count exceeded",iterations:j}},numeric._solveLP=function(a,b,c,d,e){var f,g=a.length,h=c.length,i=(numeric.sum,numeric.log,numeric.mul,numeric.sub),j=numeric.dot,k=(numeric.div,numeric.add,numeric.rep([g],0).concat([1])),l=numeric.rep([h,1],-1),m=numeric.blockMatrix([[b,l]]),n=c,f=numeric.rep([g],0).concat(Math.max(0,numeric.sup(numeric.neg(c)))+1),o=numeric.__solveLP(k,m,n,d,e,f,!1),p=numeric.clone(o.solution);p.length=g;var q=numeric.inf(i(c,j(b,p)));if(0>q)return{solution:0/0,message:"Infeasible",iterations:o.iterations};var r=numeric.__solveLP(a,b,c,d,e-o.iterations,p,!0);return r.iterations+=o.iterations,r},numeric.solveLP=function(a,b,c,d,e,f,g){if("undefined"==typeof g&&(g=1e3),"undefined"==typeof f&&(f=numeric.epsilon),"undefined"==typeof d)return numeric._solveLP(a,b,c,f,g);var h,i=d.length,j=d[0].length,k=b.length,l=numeric.echelonize(d),m=numeric.rep([j],0),n=l.P,o=[];for(h=n.length-1;-1!==h;--h)m[n[h]]=1;for(h=j-1;-1!==h;--h)0===m[h]&&o.push(h);var p=numeric.getRange,q=numeric.linspace(0,i-1),r=numeric.linspace(0,k-1),s=p(d,q,o),t=p(b,r,n),u=p(b,r,o),v=numeric.dot,w=numeric.sub,x=v(t,l.I),y=w(u,v(x,s)),z=w(c,v(x,e)),A=Array(n.length),B=Array(o.length);for(h=n.length-1;-1!==h;--h)A[h]=a[n[h]];
for(h=o.length-1;-1!==h;--h)B[h]=a[o[h]];var C=w(B,v(A,v(l.I,s))),D=numeric._solveLP(C,y,z,f,g),E=D.solution;if(E!==E)return D;var F=v(l.I,w(e,v(s,E))),G=Array(a.length);for(h=n.length-1;-1!==h;--h)G[n[h]]=F[h];for(h=o.length-1;-1!==h;--h)G[o[h]]=E[h];return{solution:G,message:D.message,iterations:D.iterations}},numeric.MPStoLP=function(a){function b(b){throw new Error("MPStoLP: "+b+"\nLine "+c+": "+a[c]+"\nCurrent state: "+h[g]+"\n")}a instanceof String&&a.split("\n");var c,d,e,f,g=0,h=["Initial state","NAME","ROWS","COLUMNS","RHS","BOUNDS","ENDATA"],i=a.length,j=0,k={},l=[],m=0,n={},o=0,p=[],q=[],r=[];for(c=0;i>c;++c){e=a[c];var s=e.match(/\S*/g),t=[];for(d=0;d<s.length;++d)""!==s[d]&&t.push(s[d]);if(0!==t.length){for(d=0;d<h.length&&e.substr(0,h[d].length)!==h[d];++d);if(d<h.length){if(g=d,1===d&&(f=t[1]),6===d)return{name:f,c:p,A:numeric.transpose(q),b:r,rows:k,vars:n}}else switch(g){case 0:case 1:b("Unexpected line");case 2:switch(t[0]){case"N":0===j?j=t[1]:b("Two or more N rows");break;case"L":k[t[1]]=m,l[m]=1,r[m]=0,++m;break;case"G":k[t[1]]=m,l[m]=-1,r[m]=0,++m;break;case"E":k[t[1]]=m,l[m]=0,r[m]=0,++m;break;default:b("Parse error "+numeric.prettyPrint(t))}break;case 3:n.hasOwnProperty(t[0])||(n[t[0]]=o,p[o]=0,q[o]=numeric.rep([m],0),++o);var u=n[t[0]];for(d=1;d<t.length;d+=2)if(t[d]!==j){var v=k[t[d]];q[u][v]=(l[v]<0?-1:1)*parseFloat(t[d+1])}else p[u]=parseFloat(t[d+1]);break;case 4:for(d=1;d<t.length;d+=2)r[k[t[d]]]=(l[k[t[d]]]<0?-1:1)*parseFloat(t[d+1]);break;case 5:break;case 6:b("Internal error")}}}b("Reached end of file without ENDATA")},numeric.seedrandom={pow:Math.pow,random:Math.random},function(a,b,c,d,e,f,g){function h(a){var b,d,e=this,f=a.length,g=0,h=e.i=e.j=e.m=0;for(e.S=[],e.c=[],f||(a=[f++]);c>g;)e.S[g]=g++;for(g=0;c>g;g++)b=e.S[g],h=k(h+b+a[g%f]),d=e.S[h],e.S[g]=d,e.S[h]=b;e.g=function(a){var b=e.S,d=k(e.i+1),f=b[d],g=k(e.j+f),h=b[g];b[d]=h,b[g]=f;for(var i=b[k(f+h)];--a;)d=k(d+1),f=b[d],g=k(g+f),h=b[g],b[d]=h,b[g]=f,i=i*c+b[k(f+h)];return e.i=d,e.j=g,i},e.g(c)}function i(a,b,c,d,e){if(c=[],e=typeof a,b&&"object"==e)for(d in a)if(d.indexOf("S")<5)try{c.push(i(a[d],b-1))}catch(f){}return c.length?c:a+("string"!=e?"\x00":"")}function j(a,b,c,d){for(a+="",c=0,d=0;d<a.length;d++)b[k(d)]=k((c^=19*b[k(d)])+a.charCodeAt(d));a="";for(d in b)a+=String.fromCharCode(b[d]);return a}function k(a){return a&c-1}b.seedrandom=function(k,l){var m,n=[];return k=j(i(l?[k,a]:arguments.length?k:[(new Date).getTime(),a,window],3),n),m=new h(n),j(m.S,a),b.random=function(){for(var a=m.g(d),b=g,h=0;e>a;)a=(a+h)*c,b*=c,h=m.g(1);for(;a>=f;)a/=2,b/=2,h>>>=1;return(a+h)/b},k},g=b.pow(c,d),e=b.pow(2,e),f=2*e,j(b.random(),a)}([],numeric.seedrandom,256,6,52),function(a){function b(a){if("object"!=typeof a)return a;var c,d=[],e=a.length;for(c=0;e>c;c++)d[c+1]=b(a[c]);return d}function c(a){if("object"!=typeof a)return a;var b,d=[],e=a.length;for(b=1;e>b;b++)d[b-1]=c(a[b]);return d}function d(a,b,c){var d,e,f,g,h;for(f=1;c>=f;f+=1){for(a[f][f]=1/a[f][f],h=-a[f][f],d=1;f>d;d+=1)a[d][f]=h*a[d][f];if(g=f+1,g>c)break;for(e=g;c>=e;e+=1)for(h=a[f][e],a[f][e]=0,d=1;f>=d;d+=1)a[d][e]=a[d][e]+h*a[d][f]}}function e(a,b,c,d){var e,f,g,h;for(f=1;c>=f;f+=1){for(h=0,e=1;f>e;e+=1)h+=a[e][f]*d[e];d[f]=(d[f]-h)/a[f][f]}for(g=1;c>=g;g+=1)for(f=c+1-g,d[f]=d[f]/a[f][f],h=-d[f],e=1;f>e;e+=1)d[e]=d[e]+h*a[e][f]}function f(a,b,c,d){var e,f,g,h,i,j;for(f=1;c>=f;f+=1){if(d[1]=f,j=0,g=f-1,1>g){if(j=a[f][f]-j,0>=j)break;a[f][f]=Math.sqrt(j)}else{for(h=1;g>=h;h+=1){for(i=a[h][f],e=1;h>e;e+=1)i-=a[e][f]*a[e][h];i/=a[h][h],a[h][f]=i,j+=i*i}if(j=a[f][f]-j,0>=j)break;a[f][f]=Math.sqrt(j)}d[1]=0}}function g(a,b,c,g,h,i,j,k,l,m,n,o,p,q,r,s){function t(){for(q[1]=q[1]+1,A=H,y=1;m>=y;y+=1){for(A+=1,N=-k[y],z=1;g>=z;z+=1)N+=j[z][y]*h[z];if(Math.abs(N)<V&&(N=0),y>n)r[A]=N;else if(r[A]=-Math.abs(N),N>0){for(z=1;g>=z;z+=1)j[z][y]=-j[z][y];k[y]=-k[y]}}for(y=1;p>=y;y+=1)r[H+o[y]]=0;for(J=0,M=0,y=1;m>=y;y+=1)r[H+y]<M*r[L+y]&&(J=y,M=r[H+y]/r[L+y]);return 0===J?999:0}function u(){for(y=1;g>=y;y+=1){for(N=0,z=1;g>=z;z+=1)N+=a[z][y]*j[z][J];r[y]=N}for(B=E,y=1;g>=y;y+=1)r[B+y]=0;for(z=p+1;g>=z;z+=1)for(y=1;g>=y;y+=1)r[B+y]=r[B+y]+a[y][z]*r[z];for(T=!0,y=p;y>=1;y-=1){for(N=r[y],A=G+y*(y+3)/2,B=A-y,z=y+1;p>=z;z+=1)N-=r[A]*r[F+z],A+=z;if(N/=r[B],r[F+y]=N,o[y]<n)break;if(0>N)break;T=!1,D=y}if(!T)for(O=r[I+D]/r[F+D],y=1;p>=y&&!(o[y]<n)&&!(r[F+y]<0);y+=1)M=r[I+y]/r[F+y],O>M&&(O=M,D=y);for(N=0,y=E+1;E+g>=y;y+=1)N+=r[y]*r[y];if(Math.abs(N)<=V){if(T)return s[1]=1,999;for(y=1;p>=y;y+=1)r[I+y]=r[I+y]-O*r[F+y];return r[I+p+1]=r[I+p+1]+O,700}for(N=0,y=1;g>=y;y+=1)N+=r[E+y]*j[y][J];for(P=-r[H+J]/N,U=!0,T||P>O&&(P=O,U=!1),y=1;g>=y;y+=1)h[y]=h[y]+P*r[E+y],Math.abs(h[y])<V&&(h[y]=0);for(i[1]=i[1]+P*N*(P/2+r[I+p+1]),y=1;p>=y;y+=1)r[I+y]=r[I+y]-P*r[F+y];if(r[I+p+1]=r[I+p+1]+P,!U){for(N=-k[J],z=1;g>=z;z+=1)N+=h[z]*j[z][J];if(J>n)r[H+J]=N;else if(r[H+J]=-Math.abs(N),N>0){for(z=1;g>=z;z+=1)j[z][J]=-j[z][J];k[J]=-k[J]}return 700}for(p+=1,o[p]=J,A=G+(p-1)*p/2+1,y=1;p-1>=y;y+=1)r[A]=r[y],A+=1;if(p===g)r[A]=r[g];else{for(y=g;y>=p+1&&0!==r[y]&&(Q=Math.max(Math.abs(r[y-1]),Math.abs(r[y])),R=Math.min(Math.abs(r[y-1]),Math.abs(r[y])),M=r[y-1]>=0?Math.abs(Q*Math.sqrt(1+R*R/(Q*Q))):-Math.abs(Q*Math.sqrt(1+R*R/(Q*Q))),Q=r[y-1]/M,R=r[y]/M,1!==Q);y-=1)if(0===Q)for(r[y-1]=R*M,z=1;g>=z;z+=1)M=a[z][y-1],a[z][y-1]=a[z][y],a[z][y]=M;else for(r[y-1]=M,S=R/(1+Q),z=1;g>=z;z+=1)M=Q*a[z][y-1]+R*a[z][y],a[z][y]=S*(a[z][y-1]+M)-a[z][y],a[z][y-1]=M;r[A]=r[p]}return 0}function v(){if(A=G+D*(D+1)/2+1,B=A+D,0===r[B])return 798;if(Q=Math.max(Math.abs(r[B-1]),Math.abs(r[B])),R=Math.min(Math.abs(r[B-1]),Math.abs(r[B])),M=r[B-1]>=0?Math.abs(Q*Math.sqrt(1+R*R/(Q*Q))):-Math.abs(Q*Math.sqrt(1+R*R/(Q*Q))),Q=r[B-1]/M,R=r[B]/M,1===Q)return 798;if(0===Q){for(y=D+1;p>=y;y+=1)M=r[B-1],r[B-1]=r[B],r[B]=M,B+=y;for(y=1;g>=y;y+=1)M=a[y][D],a[y][D]=a[y][D+1],a[y][D+1]=M}else{for(S=R/(1+Q),y=D+1;p>=y;y+=1)M=Q*r[B-1]+R*r[B],r[B]=S*(r[B-1]+M)-r[B],r[B-1]=M,B+=y;for(y=1;g>=y;y+=1)M=Q*a[y][D]+R*a[y][D+1],a[y][D+1]=S*(a[y][D]+M)-a[y][D+1],a[y][D]=M}return 0}function w(){for(B=A-D,y=1;D>=y;y+=1)r[B]=r[A],A+=1,B+=1;return r[I+D]=r[I+D+1],o[D]=o[D+1],D+=1,p>D?797:0}function x(){return r[I+p]=r[I+p+1],r[I+p+1]=0,o[p]=0,p-=1,q[2]=q[2]+1,0}var y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y;K=Math.min(g,m),A=2*g+K*(K+5)/2+2*m+1,V=1e-60;do V+=V,W=1+.1*V,X=1+.2*V;while(1>=W||1>=X);for(y=1;g>=y;y+=1)r[y]=b[y];for(y=g+1;A>=y;y+=1)r[y]=0;for(y=1;m>=y;y+=1)o[y]=0;if(C=[],0===s[1]){if(f(a,c,g,C),0!==C[1])return void(s[1]=2);e(a,c,g,b),d(a,c,g)}else{for(z=1;g>=z;z+=1)for(h[z]=0,y=1;z>=y;y+=1)h[z]=h[z]+a[y][z]*b[y];for(z=1;g>=z;z+=1)for(b[z]=0,y=z;g>=y;y+=1)b[z]=b[z]+a[z][y]*h[y]}for(i[1]=0,z=1;g>=z;z+=1)for(h[z]=b[z],i[1]=i[1]+r[z]*h[z],r[z]=0,y=z+1;g>=y;y+=1)a[y][z]=0;for(i[1]=-i[1]/2,s[1]=0,E=g,F=E+g,I=F+K,G=I+K+1,H=G+K*(K+1)/2,L=H+m,y=1;m>=y;y+=1){for(N=0,z=1;g>=z;z+=1)N+=j[z][y]*j[z][y];r[L+y]=Math.sqrt(N)}for(p=0,q[1]=0,q[2]=0,Y=0;;){if(Y=t(),999===Y)return;for(;Y=u(),0!==Y;){if(999===Y)return;if(700===Y)if(D===p)x();else{for(;v(),Y=w(),797===Y;);x()}}}}function h(a,d,e,f,h,i){a=b(a),d=b(d),e=b(e);var j,k,l,m,n,o,p=[],q=[],r=[],s=[],t=[];if(h=h||0,i=i?b(i):[void 0,0],f=f?b(f):[],k=a.length-1,l=e[1].length-1,!f)for(j=1;l>=j;j+=1)f[j]=0;for(j=1;l>=j;j+=1)q[j]=0;for(m=0,n=Math.min(k,l),j=1;k>=j;j+=1)r[j]=0;for(p[1]=0,j=1;2*k+n*(n+5)/2+2*l+1>=j;j+=1)s[j]=0;for(j=1;2>=j;j+=1)t[j]=0;return g(a,d,k,k,r,p,e,f,k,l,h,q,m,t,s,i),o="",1===i[1]&&(o="constraints are inconsistent, no solution!"),2===i[1]&&(o="matrix D in quadratic function is not positive definite!"),{solution:c(r),value:c(p),unconstrained_solution:c(d),iterations:c(t),iact:c(q),message:o}}a.solveQP=h}(numeric),numeric.svd=function(a){function b(a,b){return a=Math.abs(a),b=Math.abs(b),a>b?a*Math.sqrt(1+b*b/a/a):0==b?a:b*Math.sqrt(1+a*a/b/b)}var c,d=numeric.epsilon,e=1e-64/d,f=50,g=0,h=0,i=0,j=0,k=0,l=numeric.clone(a),m=l.length,n=l[0].length;if(n>m)throw"Need more rows than columns";var o=new Array(n),p=new Array(n);for(h=0;n>h;h++)o[h]=p[h]=0;var q=numeric.rep([n,n],0),r=0,s=0,t=0,u=0,v=0,w=0,x=0;for(h=0;n>h;h++){for(o[h]=s,x=0,k=h+1,i=h;m>i;i++)x+=l[i][h]*l[i][h];if(e>=x)s=0;else for(r=l[h][h],s=Math.sqrt(x),r>=0&&(s=-s),t=r*s-x,l[h][h]=r-s,i=k;n>i;i++){for(x=0,j=h;m>j;j++)x+=l[j][h]*l[j][i];for(r=x/t,j=h;m>j;j++)l[j][i]+=r*l[j][h]}for(p[h]=s,x=0,i=k;n>i;i++)x+=l[h][i]*l[h][i];if(e>=x)s=0;else{for(r=l[h][h+1],s=Math.sqrt(x),r>=0&&(s=-s),t=r*s-x,l[h][h+1]=r-s,i=k;n>i;i++)o[i]=l[h][i]/t;for(i=k;m>i;i++){for(x=0,j=k;n>j;j++)x+=l[i][j]*l[h][j];for(j=k;n>j;j++)l[i][j]+=x*o[j]}}v=Math.abs(p[h])+Math.abs(o[h]),v>u&&(u=v)}for(h=n-1;-1!=h;h+=-1){if(0!=s){for(t=s*l[h][h+1],i=k;n>i;i++)q[i][h]=l[h][i]/t;for(i=k;n>i;i++){for(x=0,j=k;n>j;j++)x+=l[h][j]*q[j][i];for(j=k;n>j;j++)q[j][i]+=x*q[j][h]}}for(i=k;n>i;i++)q[h][i]=0,q[i][h]=0;q[h][h]=1,s=o[h],k=h}for(h=n-1;-1!=h;h+=-1){for(k=h+1,s=p[h],i=k;n>i;i++)l[h][i]=0;if(0!=s){for(t=l[h][h]*s,i=k;n>i;i++){for(x=0,j=k;m>j;j++)x+=l[j][h]*l[j][i];for(r=x/t,j=h;m>j;j++)l[j][i]+=r*l[j][h]}for(i=h;m>i;i++)l[i][h]=l[i][h]/s}else for(i=h;m>i;i++)l[i][h]=0;l[h][h]+=1}for(d*=u,j=n-1;-1!=j;j+=-1)for(var y=0;f>y;y++){var z=!1;for(k=j;-1!=k;k+=-1){if(Math.abs(o[k])<=d){z=!0;break}if(Math.abs(p[k-1])<=d)break}if(!z){g=0,x=1;var A=k-1;for(h=k;j+1>h&&(r=x*o[h],o[h]=g*o[h],!(Math.abs(r)<=d));h++)for(s=p[h],t=b(r,s),p[h]=t,g=s/t,x=-r/t,i=0;m>i;i++)v=l[i][A],w=l[i][h],l[i][A]=v*g+w*x,l[i][h]=-v*x+w*g}if(w=p[j],k==j){if(0>w)for(p[j]=-w,i=0;n>i;i++)q[i][j]=-q[i][j];break}if(y>=f-1)throw"Error: no convergence.";for(u=p[k],v=p[j-1],s=o[j-1],t=o[j],r=((v-w)*(v+w)+(s-t)*(s+t))/(2*t*v),s=b(r,1),r=0>r?((u-w)*(u+w)+t*(v/(r-s)-t))/u:((u-w)*(u+w)+t*(v/(r+s)-t))/u,g=1,x=1,h=k+1;j+1>h;h++){for(s=o[h],v=p[h],t=x*s,s=g*s,w=b(r,t),o[h-1]=w,g=r/w,x=t/w,r=u*g+s*x,s=-u*x+s*g,t=v*x,v*=g,i=0;n>i;i++)u=q[i][h-1],w=q[i][h],q[i][h-1]=u*g+w*x,q[i][h]=-u*x+w*g;for(w=b(r,t),p[h-1]=w,g=r/w,x=t/w,r=g*s+x*v,u=-x*s+g*v,i=0;m>i;i++)v=l[i][h-1],w=l[i][h],l[i][h-1]=v*g+w*x,l[i][h]=-v*x+w*g}o[k]=0,o[j]=r,p[j]=u}for(h=0;h<p.length;h++)p[h]<d&&(p[h]=0);for(h=0;n>h;h++)for(i=h-1;i>=0;i--)if(p[i]<p[h]){for(g=p[i],p[i]=p[h],p[h]=g,j=0;j<l.length;j++)c=l[j][h],l[j][h]=l[j][i],l[j][i]=c;for(j=0;j<q.length;j++)c=q[j][h],q[j][h]=q[j][i],q[j][i]=c;h=i}return{U:l,S:p,V:q}},function(){var a=this,b=a._,c=Array.prototype,d=Object.prototype,e=Function.prototype,f=c.slice,g=d.toString,h=d.hasOwnProperty,i=Array.isArray,j=Object.keys,k=e.bind,l=Object.create,m=function(){},n=function(a){return a instanceof n?a:this instanceof n?void(this._wrapped=a):new n(a)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=n),exports._=n):a._=n,n.VERSION="1.8.3";var o=function(a,b,c){if(void 0===b)return a;switch(null==c?3:c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)}}return function(){return a.apply(b,arguments)}},p=function(a,b,c){return null==a?n.identity:n.isFunction(a)?o(a,b,c):n.isObject(a)?n.matcher(a):n.property(a)};n.iteratee=function(a,b){return p(a,b,1/0)};var q=function(a,b){return b=null==b?a.length-1:+b,function(){for(var c=Math.max(arguments.length-b,0),d=Array(c),e=0;c>e;e++)d[e]=arguments[e+b];switch(b){case 0:return a.call(this,d);case 1:return a.call(this,arguments[0],d);case 2:return a.call(this,arguments[0],arguments[1],d)}var f=Array(b+1);for(e=0;b>e;e++)f[e]=arguments[e];return f[b]=d,a.apply(this,f)}},r=function(a){if(!n.isObject(a))return{};if(l)return l(a);m.prototype=a;var b=new m;return m.prototype=null,b},s=function(a){return function(b){return null==b?void 0:b[a]}},t=Math.pow(2,53)-1,u=s("length"),v=function(a){var b=u(a);return"number"==typeof b&&b>=0&&t>=b};n.each=n.forEach=function(a,b,c){b=o(b,c);var d,e;if(v(a))for(d=0,e=a.length;e>d;d++)b(a[d],d,a);else{var f=n.keys(a);for(d=0,e=f.length;e>d;d++)b(a[f[d]],f[d],a)}return a},n.map=n.collect=function(a,b,c){b=p(b,c);for(var d=!v(a)&&n.keys(a),e=(d||a).length,f=Array(e),g=0;e>g;g++){var h=d?d[g]:g;f[g]=b(a[h],h,a)}return f};var w=function(a){var b=function(b,c,d,e,f,g){for(;f>=0&&g>f;f+=a){var h=e?e[f]:f;d=c(d,b[h],h,b)}return d};return function(c,d,e,f){d=o(d,f,4);var g=!v(c)&&n.keys(c),h=(g||c).length,i=a>0?0:h-1;return arguments.length<3&&(e=c[g?g[i]:i],i+=a),b(c,d,e,g,i,h)}};n.reduce=n.foldl=n.inject=w(1),n.reduceRight=n.foldr=w(-1),n.find=n.detect=function(a,b,c){var d;return d=v(a)?n.findIndex(a,b,c):n.findKey(a,b,c),void 0!==d&&-1!==d?a[d]:void 0},n.filter=n.select=function(a,b,c){var d=[];return b=p(b,c),n.each(a,function(a,c,e){b(a,c,e)&&d.push(a)}),d},n.reject=function(a,b,c){return n.filter(a,n.negate(p(b)),c)},n.every=n.all=function(a,b,c){b=p(b,c);for(var d=!v(a)&&n.keys(a),e=(d||a).length,f=0;e>f;f++){var g=d?d[f]:f;if(!b(a[g],g,a))return!1}return!0},n.some=n.any=function(a,b,c){b=p(b,c);for(var d=!v(a)&&n.keys(a),e=(d||a).length,f=0;e>f;f++){var g=d?d[f]:f;if(b(a[g],g,a))return!0}return!1},n.contains=n.includes=n.include=function(a,b,c,d){return v(a)||(a=n.values(a)),("number"!=typeof c||d)&&(c=0),n.indexOf(a,b,c)>=0},n.invoke=q(function(a,b,c){var d=n.isFunction(b);return n.map(a,function(a){var e=d?b:a[b];return null==e?e:e.apply(a,c)})}),n.pluck=function(a,b){return n.map(a,n.property(b))},n.where=function(a,b){return n.filter(a,n.matcher(b))},n.findWhere=function(a,b){return n.find(a,n.matcher(b))},n.max=function(a,b,c){var d,e,f=-1/0,g=-1/0;if(null==b&&null!=a){a=v(a)?a:n.values(a);for(var h=0,i=a.length;i>h;h++)d=a[h],d>f&&(f=d)}else b=p(b,c),n.each(a,function(a,c,d){e=b(a,c,d),(e>g||e===-1/0&&f===-1/0)&&(f=a,g=e)});return f},n.min=function(a,b,c){var d,e,f=1/0,g=1/0;if(null==b&&null!=a){a=v(a)?a:n.values(a);for(var h=0,i=a.length;i>h;h++)d=a[h],f>d&&(f=d)}else b=p(b,c),n.each(a,function(a,c,d){e=b(a,c,d),(g>e||1/0===e&&1/0===f)&&(f=a,g=e)});return f},n.shuffle=function(a){for(var b,c=v(a)?a:n.values(a),d=c.length,e=Array(d),f=0;d>f;f++)b=n.random(0,f),b!==f&&(e[f]=e[b]),e[b]=c[f];return e},n.sample=function(a,b,c){return null==b||c?(v(a)||(a=n.values(a)),a[n.random(a.length-1)]):n.shuffle(a).slice(0,Math.max(0,b))},n.sortBy=function(a,b,c){return b=p(b,c),n.pluck(n.map(a,function(a,c,d){return{value:a,index:c,criteria:b(a,c,d)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||void 0===c)return 1;if(d>c||void 0===d)return-1}return a.index-b.index}),"value")};var x=function(a,b){return function(c,d,e){var f=b?[[],[]]:{};return d=p(d,e),n.each(c,function(b,e){var g=d(b,e,c);a(f,b,g)}),f}};n.groupBy=x(function(a,b,c){n.has(a,c)?a[c].push(b):a[c]=[b]}),n.indexBy=x(function(a,b,c){a[c]=b}),n.countBy=x(function(a,b,c){n.has(a,c)?a[c]++:a[c]=1}),n.toArray=function(a){return a?n.isArray(a)?f.call(a):v(a)?n.map(a,n.identity):n.values(a):[]},n.size=function(a){return null==a?0:v(a)?a.length:n.keys(a).length},n.partition=x(function(a,b,c){a[c?0:1].push(b)},!0),n.first=n.head=n.take=function(a,b,c){return null==a?void 0:null==b||c?a[0]:n.initial(a,a.length-b)},n.initial=function(a,b,c){return f.call(a,0,Math.max(0,a.length-(null==b||c?1:b)))},n.last=function(a,b,c){return null==a?void 0:null==b||c?a[a.length-1]:n.rest(a,Math.max(0,a.length-b))},n.rest=n.tail=n.drop=function(a,b,c){return f.call(a,null==b||c?1:b)},n.compact=function(a){return n.filter(a,n.identity)};var y=function(a,b,c,d){for(var e=[],f=0,g=d||0,h=u(a);h>g;g++){var i=a[g];if(v(i)&&(n.isArray(i)||n.isArguments(i))){b||(i=y(i,b,c));var j=0,k=i.length;for(e.length+=k;k>j;)e[f++]=i[j++]}else c||(e[f++]=i)}return e};n.flatten=function(a,b){return y(a,b,!1)},n.without=q(function(a,b){return n.difference(a,b)}),n.uniq=n.unique=function(a,b,c,d){n.isBoolean(b)||(d=c,c=b,b=!1),null!=c&&(c=p(c,d));for(var e=[],f=[],g=0,h=u(a);h>g;g++){var i=a[g],j=c?c(i,g,a):i;b?(g&&f===j||e.push(i),f=j):c?n.contains(f,j)||(f.push(j),e.push(i)):n.contains(e,i)||e.push(i)}return e},n.union=function(){return n.uniq(y(arguments,!0,!0))},n.intersection=function(a){for(var b=[],c=arguments.length,d=0,e=u(a);e>d;d++){var f=a[d];if(!n.contains(b,f)){for(var g=1;c>g&&n.contains(arguments[g],f);g++);g===c&&b.push(f)}}return b},n.difference=function(a){var b=y(arguments,!0,!0,1);return n.filter(a,function(a){return!n.contains(b,a)})},n.zip=function(){return n.unzip(arguments)},n.unzip=function(a){for(var b=a&&n.max(a,u).length||0,c=Array(b),d=0;b>d;d++)c[d]=n.pluck(a,d);return c},n.object=function(a,b){for(var c={},d=0,e=u(a);e>d;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c};var z=function(a){return function(b,c,d){c=p(c,d);for(var e=u(b),f=a>0?0:e-1;f>=0&&e>f;f+=a)if(c(b[f],f,b))return f;return-1}};n.findIndex=z(1),n.findLastIndex=z(-1),n.sortedIndex=function(a,b,c,d){c=p(c,d,1);for(var e=c(b),f=0,g=u(a);g>f;){var h=Math.floor((f+g)/2);c(a[h])<e?f=h+1:g=h}return f};var A=function(a,b,c){return function(d,e,g){var h=0,i=u(d);if("number"==typeof g)a>0?h=g>=0?g:Math.max(g+i,h):i=g>=0?Math.min(g+1,i):g+i+1;else if(c&&g&&i)return g=c(d,e),d[g]===e?g:-1;if(e!==e)return g=b(f.call(d,h,i),n.isNaN),g>=0?g+h:-1;for(g=a>0?h:i-1;g>=0&&i>g;g+=a)if(d[g]===e)return g;return-1}};n.indexOf=A(1,n.findIndex,n.sortedIndex),n.lastIndexOf=A(-1,n.findLastIndex),n.range=function(a,b,c){null==b&&(b=a||0,a=0),c=c||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=Array(d),f=0;d>f;f++,a+=c)e[f]=a;return e};var B=function(a,b,c,d,e){if(!(d instanceof b))return a.apply(c,e);var f=r(a.prototype),g=a.apply(f,e);return n.isObject(g)?g:f};n.bind=function(a,b){if(k&&a.bind===k)return k.apply(a,f.call(arguments,1));if(!n.isFunction(a))throw new TypeError("Bind must be called on a function");var c=f.call(arguments,2),d=q(function(e){return B(a,d,b,this,c.concat(e))});return d},n.partial=q(function(a,b){var c=n.partial.placeholder,d=function(){for(var e=0,f=b.length,g=Array(f),h=0;f>h;h++)g[h]=b[h]===c?arguments[e++]:b[h];for(;e<arguments.length;)g.push(arguments[e++]);return B(a,d,this,this,g)};return d}),n.partial.placeholder=n,n.bindAll=q(function(a,b){if(b.length<1)throw new Error("bindAll must be passed function names");return n.each(b,function(b){a[b]=n.bind(a[b],a)})}),n.memoize=function(a,b){var c=function(d){var e=c.cache,f=""+(b?b.apply(this,arguments):d);return n.has(e,f)||(e[f]=a.apply(this,arguments)),e[f]};return c.cache={},c},n.delay=q(function(a,b,c){return setTimeout(function(){return a.apply(null,c)},b)}),n.defer=n.partial(n.delay,n,1),n.throttle=function(a,b,c){var d,e,f,g=null,h=0;c||(c={});var i=function(){h=c.leading===!1?0:n.now(),g=null,f=a.apply(d,e),g||(d=e=null)};return function(){var j=n.now();h||c.leading!==!1||(h=j);var k=b-(j-h);return d=this,e=arguments,0>=k||k>b?(g&&(clearTimeout(g),g=null),h=j,f=a.apply(d,e),g||(d=e=null)):g||c.trailing===!1||(g=setTimeout(i,k)),f}},n.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=n.now()-g;b>j&&j>=0?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),d||(f=e=null)))};return function(){f=this,e=arguments,g=n.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},n.wrap=function(a,b){return n.partial(b,a)},n.negate=function(a){return function(){return!a.apply(this,arguments)}},n.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},n.after=function(a,b){return function(){return--a<1?b.apply(this,arguments):void 0}},n.before=function(a,b){var c;return function(){return--a>0&&(c=b.apply(this,arguments)),1>=a&&(b=null),c}},n.once=n.partial(n.before,2),n.restArgs=q;var C=!{toString:null}.propertyIsEnumerable("toString"),D=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],E=function(a,b){var c=D.length,e=a.constructor,f=n.isFunction(e)&&e.prototype||d,g="constructor";for(n.has(a,g)&&!n.contains(b,g)&&b.push(g);c--;)g=D[c],g in a&&a[g]!==f[g]&&!n.contains(b,g)&&b.push(g)};n.keys=function(a){if(!n.isObject(a))return[];if(j)return j(a);var b=[];for(var c in a)n.has(a,c)&&b.push(c);return C&&E(a,b),b},n.allKeys=function(a){if(!n.isObject(a))return[];var b=[];for(var c in a)b.push(c);return C&&E(a,b),b},n.values=function(a){for(var b=n.keys(a),c=b.length,d=Array(c),e=0;c>e;e++)d[e]=a[b[e]];return d},n.mapObject=function(a,b,c){b=p(b,c);for(var d=n.keys(a),e=d.length,f={},g=0;e>g;g++){var h=d[g];f[h]=b(a[h],h,a)}return f},n.pairs=function(a){for(var b=n.keys(a),c=b.length,d=Array(c),e=0;c>e;e++)d[e]=[b[e],a[b[e]]];return d},n.invert=function(a){for(var b={},c=n.keys(a),d=0,e=c.length;e>d;d++)b[a[c[d]]]=c[d];return b},n.functions=n.methods=function(a){var b=[];for(var c in a)n.isFunction(a[c])&&b.push(c);return b.sort()};var F=function(a,b){return function(c){var d=arguments.length;if(2>d||null==c)return c;for(var e=1;d>e;e++)for(var f=arguments[e],g=a(f),h=g.length,i=0;h>i;i++){var j=g[i];b&&void 0!==c[j]||(c[j]=f[j])}return c}};n.extend=F(n.allKeys),n.extendOwn=n.assign=F(n.keys),n.findKey=function(a,b,c){b=p(b,c);for(var d,e=n.keys(a),f=0,g=e.length;g>f;f++)if(d=e[f],b(a[d],d,a))return d},n.pick=function(a,b,c){var d,e,f={},g=a;if(null==g)return f;n.isFunction(b)?(e=n.allKeys(g),d=o(b,c)):(e=y(arguments,!1,!1,1),d=function(a,b,c){return b in c},g=Object(g));for(var h=0,i=e.length;i>h;h++){var j=e[h],k=g[j];d(k,j,g)&&(f[j]=k)}return f},n.omit=function(a,b,c){if(n.isFunction(b))b=n.negate(b);else{var d=n.map(y(arguments,!1,!1,1),String);b=function(a,b){return!n.contains(d,b)}}return n.pick(a,b,c)},n.defaults=F(n.allKeys,!0),n.create=function(a,b){var c=r(a);return b&&n.extendOwn(c,b),c},n.clone=function(a){return n.isObject(a)?n.isArray(a)?a.slice():n.extend({},a):a},n.tap=function(a,b){return b(a),a},n.isMatch=function(a,b){var c=n.keys(b),d=c.length;if(null==a)return!d;for(var e=Object(a),f=0;d>f;f++){var g=c[f];if(b[g]!==e[g]||!(g in e))return!1}return!0};var G=function(a,b,c,d){if(a===b)return 0!==a||1/a===1/b;if(null==a||null==b)return a===b;a instanceof n&&(a=a._wrapped),b instanceof n&&(b=b._wrapped);var e=g.call(a);if(e!==g.call(b))return!1;switch(e){case"[object RegExp]":case"[object String]":return""+a==""+b;case"[object Number]":return+a!==+a?+b!==+b:0===+a?1/+a===1/b:+a===+b;case"[object Date]":case"[object Boolean]":return+a===+b}var f="[object Array]"===e;if(!f){if("object"!=typeof a||"object"!=typeof b)return!1;var h=a.constructor,i=b.constructor;if(h!==i&&!(n.isFunction(h)&&h instanceof h&&n.isFunction(i)&&i instanceof i)&&"constructor"in a&&"constructor"in b)return!1}c=c||[],d=d||[];for(var j=c.length;j--;)if(c[j]===a)return d[j]===b;if(c.push(a),d.push(b),f){if(j=a.length,j!==b.length)return!1;for(;j--;)if(!G(a[j],b[j],c,d))return!1}else{var k,l=n.keys(a);if(j=l.length,n.keys(b).length!==j)return!1;for(;j--;)if(k=l[j],!n.has(b,k)||!G(a[k],b[k],c,d))return!1}return c.pop(),d.pop(),!0};n.isEqual=function(a,b){return G(a,b)},n.isEmpty=function(a){return null==a?!0:v(a)&&(n.isArray(a)||n.isString(a)||n.isArguments(a))?0===a.length:0===n.keys(a).length},n.isElement=function(a){return!(!a||1!==a.nodeType)},n.isArray=i||function(a){return"[object Array]"===g.call(a)},n.isObject=function(a){var b=typeof a;return"function"===b||"object"===b&&!!a},n.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(a){n["is"+a]=function(b){return g.call(b)==="[object "+a+"]"}}),n.isArguments(arguments)||(n.isArguments=function(a){return n.has(a,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(n.isFunction=function(a){return"function"==typeof a||!1}),n.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))},n.isNaN=function(a){return n.isNumber(a)&&a!==+a},n.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"===g.call(a)},n.isNull=function(a){return null===a},n.isUndefined=function(a){return void 0===a},n.has=function(a,b){return null!=a&&h.call(a,b)},n.noConflict=function(){return a._=b,this},n.identity=function(a){return a},n.constant=function(a){return function(){return a}},n.noop=function(){},n.property=s,n.propertyOf=function(a){return null==a?function(){}:function(b){return a[b]}},n.matcher=n.matches=function(a){return a=n.extendOwn({},a),function(b){return n.isMatch(b,a)}},n.times=function(a,b,c){var d=Array(Math.max(0,a));b=o(b,c,1);for(var e=0;a>e;e++)d[e]=b(e);return d},n.random=function(a,b){return null==b&&(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))},n.now=Date.now||function(){return(new Date).getTime()};var H={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},I=n.invert(H),J=function(a){var b=function(b){return a[b]},c="(?:"+n.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};n.escape=J(H),n.unescape=J(I),n.result=function(a,b,c){var d=null==a?void 0:a[b];return void 0===d&&(d=c),n.isFunction(d)?d.call(a):d};var K=0;n.uniqueId=function(a){var b=++K+"";return a?a+b:b},n.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var L=/(.)^/,M={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},N=/\\|'|\r|\n|\u2028|\u2029/g,O=function(a){return"\\"+M[a]};n.template=function(a,b,c){!b&&c&&(b=c),b=n.defaults({},b,n.templateSettings);var d=RegExp([(b.escape||L).source,(b.interpolate||L).source,(b.evaluate||L).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(N,O),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(b.variable||"obj","_",f)}catch(h){throw h.source=f,h}var i=function(a){return g.call(this,a,n)},j=b.variable||"obj";return i.source="function("+j+"){\n"+f+"}",i},n.chain=function(a){var b=n(a);return b._chain=!0,b};var P=function(a,b){return a._chain?n(b).chain():b};n.mixin=function(a){n.each(n.functions(a),function(b){var c=n[b]=a[b];n.prototype[b]=q(function(a){return a.unshift(this._wrapped),P(this,c.apply(n,a))})})},n.mixin(n),n.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=c[a];n.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],P(this,c)}}),n.each(["concat","join","slice"],function(a){var b=c[a];n.prototype[a]=function(){return P(this,b.apply(this._wrapped,arguments))}}),n.prototype.value=function(){return this._wrapped},n.prototype.valueOf=n.prototype.toJSON=n.prototype.value,n.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return n})}.call(this),Vector.prototype={dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},length:function(){return Math.sqrt(this.dot(this))}};var stopwatch=function(){"use strict";function a(){this.start_time=0,this.stop_time=0,this.run_time=0,this.running=!1}return a.prototype.start=function(){this.start_time=(new Date).getTime(),this.running=!0},a.prototype.stop=function(){this.stop_time=(new Date).getTime(),this.run_time=this.stop_time-this.start_time,this.running=!1},a.prototype.get_runtime=function(){return this.run_time},a.prototype.reset=function(){this.run_time=0},a}(),ring_buffer=function(){"use strict";function a(a){this.arr=new Int32Array(a),this.begin=0,this.end=-1,this.num_el=0,this.arr_size=a}return a.prototype.push_back=function(a){this.num_el<this.arr_size?(this.end++,this.arr[this.end]=a,this.num_el++):(this.end=(this.end+1)%this.arr_size,this.begin=(this.begin+1)%this.arr_size,this.arr[this.end]=a)},a.prototype.get=function(a){return this.arr[(this.begin+a)%this.arr_size]},a.prototype.size=function(){return this.num_el},a}(),profiler=function(){"use strict";function a(){this.timers=[],this.frame_timer=new stopwatch}var b=0,c=new ring_buffer(20);return a.prototype.add=function(a){this.timers.push([a,new stopwatch])},a.prototype.new_frame=function(){++b;var a=0,d=0|this.timers.length;for(a=0;d>a;++a){var e=this.timers[a][1];e.reset()}if(b>=1){this.frame_timer.stop(),c.push_back(this.frame_timer.get_runtime());var f=c.size(),g=0;for(a=0;f>a;++a)g+=c.get(a);this.frame_timer.start()}},a.prototype.find_task=function(a){var b=0|this.timers.length,c=0;for(c=0;b>c;++c){var d=this.timers[c];if(d[0]===a)return d}return null},a.prototype.start=function(a){var b=this.find_task(a);b[1].start()},a.prototype.stop=function(a){var b=this.find_task(a);b[1].stop()},a.prototype.log=function(a){var b=0|this.timers.length,c=0,d="";if(a)return this.timers[0][1].get_runtime();for(c=0;b>c;++c){var e=this.timers[c];d+=e[0]+": "+e[1].get_runtime()+"ms<br/>"}return d},a}();!function(a){"use strict";a.imagewarp=function(a,b,c,d){function e(a,d){function e(a){var b=[[a[0],a[1],a[2]],[a[3],a[4],a[5]],[a[6],a[7],a[8]]],c=[[1,0,f.minW],[0,1,f.minH],[0,0,1]];return b=numeric.dot(b,c),[b[0][0],b[0][1],b[0][2],b[1][0],b[1][1],b[1][2],b[2][0],b[2][1],b[2][2]]}h=createcanvas("canvas",n,o),i=h.getContext("2d");var f=new v(b),m=createcanvas(a,n,o);m.width=f.maxW,m.height=f.maxH;for(var r=m.getContext("2d"),u=getHisograms(c[0]),w=0;w<d.length;w++){for(var x=getHisograms(c[w+1]),y=new Array(3),z=0;z<y.length;++z){var A=x[z],B=u[z],C=histogramEqualizationTransform(A),D=histogramEqualizationTransform(B);y[z]=step3(C,D)}var E=i.getImageData(0,0,n,o);i.drawImage(d[w].img,0,0,j,k);var F=i.getImageData(0,0,n,o);correctImg(y,F,E),h.width=f.maxW,h.height=f.maxH,d[w].warpData=i.getImageData(0,0,f.maxW,f.maxH);var G=i.getImageData(0,0,f.maxW,f.maxH),H=e(b[w]);g(F,d[w].warpData,H),g(E,G,H),i.putImageData(d[w].warpData,0,0);var I=document.createElement("CANVAS");I.width=h.width,I.height=h.height,I.getContext("2d").drawImage(i.canvas,0,0),q[w+1]=I,r.drawImage(i.canvas,0,0);var J=i.getImageData(-f.minW,-f.minH,n,o);s.push(J),i.putImageData(G,0,0);var J=i.getImageData(-f.minW,-f.minH,n,o);t.push(J)}r.drawImage(p.img,-f.minW,-f.minH,n,o),s[0]=r.getImageData(-f.minW,-f.minH,n,o),h.width=f.maxW,h.height=f.maxH,i.drawImage(p.img,-f.minW,-f.minH,n,o),l=i.getImageData(0,0,f.maxW,f.maxH);var I=document.createElement("CANVAS");I.width=h.width,I.height=h.height,I.getContext("2d").drawImage(i.canvas,0,0),q[0]=I}function f(a,b){var c=[[b[0],b[1],b[2]],[b[3],b[4],b[5]],[b[6],b[7],b[8]]],d=numeric.inv(c),e=[a[0],a[1],1],f=numeric.dot(d,e);return[f[0]/f[2],f[1]/f[2]]}function g(a,b,c){for(var d=0|b.width,e=0|b.height,f=0|a.width,g=0|a.height,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=c,z=y[0],A=y[1],B=y[2],C=y[3],D=y[4],E=y[5],F=y[6],G=y[7],H=y[8],I=0,J=0;e>J;++J){m=A*J+B,n=D*J+E,o=G*J+H;for(var K=0;d>K;K++,I+=4,m+=z,n+=C,o+=F)p=1/o,k=m*p,l=n*p,i=0|k,j=0|l,k>0&&l>0&&f-1>i&&g-1>j?(q=Math.max(k-i,0),r=Math.max(l-j,0),h=4*a.width*j+4*i|0,s=a.data[h]+q*(a.data[h+4]-a.data[h]),t=a.data[h+4*f]+q*(a.data[h+4*f+4]-a.data[h+4*f]),u=a.data[h+1]+q*(a.data[h+4+1]-a.data[h+1]),v=a.data[h+4*f+1]+q*(a.data[h+4*f+4+1]-a.data[h+4*f+1]),w=a.data[h+2]+q*(a.data[h+4+2]-a.data[h+2]),x=a.data[h+4*f+2]+q*(a.data[h+4*f+4+2]-a.data[h+4*f+2]),b.data[I+0]=s+r*(t-s),b.data[I+1]=u+r*(v-u),b.data[I+2]=w+r*(x-w),b.data[4*J*b.width+4*K+3]=255):b.data[4*J*b.width+4*K+3]=0}}for(var h,i,j,k,l,m=function(a){this.warpData=0,this.img=new Image,this.img.src=a},n=0,o=0,p=new m(c[0]),q=new Array(c.length),r=[],s=[0],t=[0],u=0;u<c.length-1;u++)r.push(new m(c[u+1]));p.img.onload=function(){var b=findScale(p.img.width,p.img.height);n=j=p.img.width*b|0,o=k=p.img.height*b|0,j=p.img.width*b|0,k=p.img.height*b|0,e(a,r),d()};var v=function(a){for(var b=[[0,0],[j,0],[0,k],[j,k]],c=[],d=[],e=0;e<a.length;e++)for(var g in b)c.push(f(b[g],a[e])[0]),d.push(f(b[g],a[e])[1]);c.push(0),d.push(0),this.minW=_.min(c),this.minH=_.min(d),c.push(j),d.push(k),this.maxW=_.max(c)-this.minW,this.maxH=_.max(d)-this.minH};return{getOverlap:function(){return s},getModOverlap:function(){return t},getMosaic:function(){return[l,r]},getMosaic2:function(){return q}}}}(this),function(a){"use strict";
a.findDiff=function(a,b,c,d,e){function f(){for(var e=5,f=.5,g=25,j=3,k=120,l=15,m=new jsfeat.matrix_t(c,d,jsfeat.F32_t|jsfeat.C1_t),n=0;3>n;n++){var o=new jsfeat.matrix_t(c,d,jsfeat.F32_t|jsfeat.C1_t),p=new jsfeat.matrix_t(c,d,jsfeat.F32_t|jsfeat.C1_t);jsfeat.imgproc.gaussian_blur(a[n],o,e,f),jsfeat.imgproc.gaussian_blur(b[n],p,e,f);var q=numeric.sub(o.data,p.data);q=numeric.abs(q),numeric.addeq(m.data,q)}numeric.diveq(m.data,3);var r=new jsfeat.matrix_t(c,d,jsfeat.F32_t|jsfeat.C1_t),s=new jsfeat.matrix_t(c,d,jsfeat.F32_t|jsfeat.C1_t),t=new jsfeat.matrix_t(c,d,jsfeat.F32_t|jsfeat.C1_t);r.data=numeric.floor(m.data);for(var n=s.cols*s.rows;--n>=0;)0==b[3].data[n]&&(r.data[n]=0);jsfeat.imgproc.gaussian_blur(r,s,k,l);var u=findBlobs(s.data,c,d,24);return h=s.data,jsfeat.imgproc.gaussian_blur(r,t,g,j),i=t.data,u}var g=new profiler;g.add("statdiff"),g.start("statdiff");var h,i,j=c,k=d,l=f();return g.stop("statdiff"),console.log("Bluring done in:",g.log(1),"ms"),{getGauss:function(){return{g:h,r:i}},getData:function(){return l},compareToThres:function(a){return l=findBlobs(h,j,k,a)},getSize:function(a){var b=unique(l.data);return b[a]},compareSingleBlob:function(a,b,c){var d=findBlobs2(l.data,h,b,j,k,a,c);return d},paint:function(a,b,c,d){var e=0;2==d?e=0:3==d&&(e=a);var f=b+c*j,g=f-j,h=f-2*j,i=f-1,m=f-2,n=f-j-1,o=f-j+1,p=f+1,q=f+2,r=f+j,s=f+2*j,t=f+j-1,u=f+j+1;return b>0&&j>b&&c>=0&&k>c?(l.data[f]=e,h>j&&(l.data[h]=e,l.data[g]=e,l.data[n]=e,l.data[o]=e),m>3&&(l.data[m]=e,l.data[i]=e),j-3>b&&(l.data[q]=e,l.data[p]=e),k-2>c&&(l.data[s]=e,l.data[r]=e,l.data[t]=e,l.data[u]=e)):console.log("utanför"),l.data.slice()}}}}(this);var cwidth,cheight,imgData=[],modImgData=[],blobData=[];!function(a){"use strict";a.interactMouse=function(a,b,c,d,e,f){function g(a){if(blobData[H-1][1]>1){for(var b=0,c=0;H>c;c++)blobData[c][1]<blobData[H-1][1]&&b++;var d=H-b;p[H]=new relativeBlobTreshold(H,myblobs1[blobData[H-1][1]].getGauss(),result_canvas_top.width,result_canvas_top.height,n,a,myblobs1[blobData[H-1][1]].getSize(d),imgData[blobData[H-1][1]].data)}else p[H]=new relativeBlobTreshold(H,myblobs1[blobData[H-1][1]].getGauss(),result_canvas_top.width,result_canvas_top.height,n,a,myblobs1[blobData[H-1][1]].getSize(H),imgData[blobData[H-1][1]].data);blobData[H-1][0]=p[H].getBlob(),redrawScrean(blobData,imgData,m,y),document.body.style.cursor="auto";var e;for(e in m)if(m[e])for(var f=0;f<blobData[e-1][0].length;f++)blobData[e-1][0][f]==e&&(q[f]=Number(e));C=!1}function h(a,b,c){blobData[b-1][0][a]===b&&(H=b,y=b,console.log("HIT on blob",b,blobData[b-1][1]),m[b]=!m[b],p[b]?(console.log("already exist"),m[b]||(y=0,H=0,A=0,t=0)):(document.body.style.cursor="wait",C=!0,c.push(blobData[b-1][1])))}function i(a){var b=0,c=[],d=[],e=[];blobData=[];for(var f=1;f<imagesRef.length;f++){var g=imgData[f];g.blobs=myblobs1[f].compareToThres(a);for(var h=0;h<g.blobs.numberOfUnique;h++){for(var i=h+1,k=j(g.blobs.data.length),l=!1,n=0,o=0;o<g.blobs.data.length;o++)if(i===g.blobs.data[o]&&(k[o]=i+b,0!=q[o])){l=!0,n=q[o];break}if(l){k=j(g.blobs.data.length);for(var o=0;o<g.blobs.data.length;o++)q[o]==n&&(k[o]=i+b);c.push(!0),d.push(n)}else c.push(!1);blobData.push([k,f])}b+=g.blobs.numberOfUnique}for(var f=0;b>f;f++)c[f]&&e.push(f+1);var r=0;if(d.length>0){var s=d.length,t=_.zip(d,e);t=_.sortBy(t,function(a){return-a[1]}),t=_.uniq(t,!1,function(a){return a[0]});var u=_.unzip(t);d=u[0],e=u[1],r=s-d.length;for(var v=0;v<d.length;v++)p[d[v]].changeId(e[v]),changeKey(p,d[v],e[v]+99);for(var v=0;v<d.length;v++)changeKey(p,d[v]+99+(e[v]-d[v]),e[v]);E=blobData.length}else console.log("the array is empty",m);c=[];for(var f=0;b>f;f++)c.push(_.contains(e,f+1)?!0:!1);m={};for(var f=0;b>f;f++)m[f+1]=c[f]?!0:!1;redrawScrean(blobData,imgData,m)}function j(a){for(var b=new Array(a),c=0;a>c;c++)b[c]=0;return b}function k(a){var b=0;blobData=[];for(var c=1;c<imagesRef.length;c++){var d=imgData[c];d.blobs=myblobs1[c].compareToThres(a);for(var e=0;e<d.blobs.numberOfUnique;e++){for(var f=e+1,g=j(d.blobs.data.length),h=0;h<d.blobs.data.length;h++)f===d.blobs.data[h]&&(g[h]=f+b);blobData.push([g,c])}b+=d.blobs.numberOfUnique}m={};for(var c=0;b>c;c++)m[c+1]=!1;E=blobData.length,redrawScrean(blobData,imgData,m)}var l,m={},n=24,o=24,p={},q=[],r=0,s=0,t=0,u=[],v=1,w=2,x=3,y=0,z=0,A=0,B=0,C=!1,D=$("input[name=optradio]:checked","#myForm").val();$("#myForm input").on("change",function(){D=$("input[name=optradio]:checked","#myForm").val(),console.log("RADIO ",D),console.log(m),console.log(_.contains(m,!0)),1==D||_.contains(m,!0)?document.body.style.cursor=1==D?"auto":3==D?"cell":"crosshair":($("input[name=optradio]")[0].checked=!0,D=1,alert("First, select which Layer/s to paint or erase on"))});var E=0,F=!1,G=!1,H=0;m=c,cwidth=d,cheight=e;var I=function(){function a(a){var b=a.charAt(0);if("#"===b)var c=document.getElementById(a.slice(1,a.length));else var c=document.getElementById(a);var d={},e=function(a,b){var e,f=a.split(" "),g=f.length;for(e=0;g>e;e+=1)c.attachEvent?c.attachEvent("on"+f[e],b):c.addEventListener(f[e],b,!1);return d};return d.on=e,d.element=c,d}console.log("Do SET Up"),document.body.style.cursor="auto";var b=function(a){var b,c,d=[],e=0,f=0,g=0;if("touchstart"===a.type||"touchmove"===a.type||"touchend"===a.type)for(b=a.touches.length,c=0;b>c;c+=1)e+=1;else e+=1;var h=result_canvas_top.getBoundingClientRect();for(c=0;e>c;c+=1)d[c]={x:0,y:0},f=(a.clientX-h.left)*(result_canvas_top.width/h.width)|0,f>0&&f<=result_canvas_top.width&&(d[c].x=f),g=(a.clientY-h.top)*(result_canvas_top.height/h.height)|0,g>0&&g<=result_canvas_top.height&&(d[c].y=g);return d},c=[],f=[],l={};return function(I,J){!function(a){return function(){a()}}(J);l=a(I),l.width=0,l.height=0,l.on("touchstart mousedown",function(a){if(a.preventDefault?a.preventDefault():a.returnValue&&(a.returnValue=!1),G=!0,D==v){f=b(a);for(var c=1;E+1>c;c++){var d=Math.abs(f[0].y)*result_canvas_top.width+Math.abs(f[0].x);h(d,c,u)}redrawScrean(blobData,imgData,m,y)}}).on("touchmove mousemove",function(a){var g=c;c=f,f=b(a,l.element);var h,i=f[0].x,j=f[0].y;if(!F&&G){var k=f[0].x-c[0].x,n=f[0].y-c[0].y;32>k*k+n*n?(f=c,c=g):(console.log("set drag = true"),F=!0)}if(F&&(D==w||D==x)&&H){var o=l.element.getContext("2d");o.lineWidth=16,o.lineCap="round",o.beginPath(),D==w&&(o.globalCompositeOperation="source-over",o.strokeStyle="rgba(255, 0, 0, 1)"),D==x&&(o.globalCompositeOperation="source-over",o.strokeStyle="rgba(0, 255, 0, 1)"),o.moveTo(c[0].x,c[0].y),o.lineTo(f[0].x,f[0].y),o.stroke(),h=o.getImageData(0,0,d,e)}if(_.some(m)||F){var k=f[0].x-c[0].x,n=f[0].y-c[0].y;if(32>k*k+n*n)f=c,c=g;else{!F||D!=w&&D!=x||(H&&maskOutRed(H,d,e,h,blobData[H-1][0]),redrawScrean(blobData,imgData,m,y));var p=j*result_canvas_top.width+i;z=y;var q,r=[];for(q in m)if(m[q]){var s=Number(q);0!==blobData[s-1][0][p]?(y=s,H=s,r.push(1)):r.push(0)}_.contains(r,1)||F||(y=0,H=0),z!=y&&redrawScrean(blobData,imgData,m,y)}}B=A,A=0;for(var p=0,u=1;u<blobData.length+1;u++)if(p=Math.abs(f[0].y)*result_canvas_top.width+Math.abs(f[0].x),blobData[u-1][0][p]===u&&(A=u,2>t)){t++;break}B==A||y?2==t&&(t=4):0!==A?console.log("hovered In",A):t=0,a.preventDefault&&a.preventDefault()}).on("touchend mouseup mouseout",function(){if(G=!1,C){document.body.style.cursor="auto";var a=Math.abs(f[0].y)*result_canvas_top.width+Math.abs(f[0].x);g(a)}if(C&&f[0]){var a=Math.abs(f[0].y)*result_canvas_top.width+Math.abs(f[0].x);g(a)}else C=!1,document.body.style.cursor="auto";F&&(F=!1)}).on("DOMMouseScroll mousewheel",function(a){a.preventDefault?a.preventDefault():a.returnValue&&(a.returnValue=!1);var b=a.wheelDelta?a.wheelDelta/40:a.detail?-a.detail:0;if(r+=b,H)p[H]?r>s?(blobData[H-1][0]=p[H].updateThresholdDecreas(),redrawScrean(blobData,imgData,m,y)):s>r&&(blobData[H-1][0]=p[H].updateThresholdIncreas(),redrawScrean(blobData,imgData,m,y)):document.body.style.cursor="auto";else if(_.some(m)){b>0&&550>n?n+=1:0>b&&n>=0&&(n-=1),q=j(blobData[0][0].length);var c;for(c in m)if(m[c])for(var d=0;d<blobData[c-1][0].length;d++)blobData[c-1][0][d]==c&&(q[d]=Number(c));i(n),o=n}else b>0&&550>n?(n+=1,k(n),o=n):0>b&&n>=0&&(n-=1,k(n),o=n);s=r})}}();return{setup:function(){!function(){E=a.length,blobData=a.slice(),imgData=b.slice(),modImgData=f.slice(),I("#blobstop",function(){var a=document.getElementById("blobstop");l=a.getContext("2d"),console.log("do nada")})}()},setNblobs:function(a,b,c){E=a.length,blobData=a.slice(),imgData=b.slice(),m=c},getBlobSelected:function(){return m}}}}(this);var src_ctx,mask_ctx,result_ctx,base_size={width:0,height:0},blend_position_offset={x:0,y:0};