!function(){"use strict";const{indexOf:e,slice:t}=[],n=(t,n,r,l,o,a)=>{const c="selectedIndex"in n;let s=c;for(;l<o;){const o=t(r[l],1);if(n.insertBefore(o,a),c&&s&&o.selected){s=!s;let{selectedIndex:t}=n;n.selectedIndex=t<0?l:e.call(n.querySelectorAll("option"),o)}l++}},r=(e,t)=>e==t,l=e=>e,o=(e,t,n,r,l,o,a)=>{const c=o-l;if(c<1)return-1;for(;n-t>=c;){let c=t,s=l;for(;c<n&&s<o&&a(e[c],r[s]);)c++,s++;if(s===o)return t;t=c+1}return-1},a=(e,t,n,r,l)=>n<r?e(t[n],0):0<n?e(t[n-1],-0).nextSibling:l,c=(e,t,n,r)=>{for(;n<r;)i(e(t[n++],-1))},s=(e,t,n)=>{let r=1,l=t;for(;r<l;){const t=(r+l)/2>>>0;n<e[t]?l=t:r=t+1}return r},d=(e,t,r,l,o,a,d,i,f,u,h,b,g)=>{((e,t,r,l,o,a,s,d,i)=>{const f=[],u=e.length;let h=s,b=0;for(;b<u;)switch(e[b++]){case 0:o++,h++;break;case 1:f.push(l[o]),n(t,r,l,o++,o,h<d?t(a[h],0):i);break;case-1:h++}for(b=0;b<u;)switch(e[b++]){case 0:s++;break;case-1:-1<f.indexOf(a[s])?s++:c(t,a,s++,s)}})(((e,t,n,r,l,o,a)=>{const c=n+o,s=[];let d,i,f,u,h,b,g;e:for(d=0;d<=c;d++){if(d>50)return null;for(g=d-1,h=d?s[d-1]:[0,0],b=s[d]=[],i=-d;i<=d;i+=2){for(u=i===-d||i!==d&&h[g+i-1]<h[g+i+1]?h[g+i+1]:h[g+i-1]+1,f=u-i;u<o&&f<n&&a(r[l+u],e[t+f]);)u++,f++;if(u===o&&f===n)break e;b[d+i]=u}}const p=Array(d/2+c/2);let y=p.length-1;for(d=s.length-1;d>=0;d--){for(;u>0&&f>0&&a(r[l+u-1],e[t+f-1]);)p[y--]=0,u--,f--;if(!d)break;g=d-1,h=d?s[d-1]:[0,0],i=u-f,i===-d||i!==d&&h[g+i-1]<h[g+i+1]?(f--,p[y--]=1):(u--,p[y--]=-1)}return p})(r,l,a,d,i,u,b)||((e,t,n,r,l,o,a,c)=>{let d=0,i=r<c?r:c;const f=Array(i++),u=Array(i);u[0]=-1;for(let e=1;e<i;e++)u[e]=a;const h=l.slice(o,a);for(let r=t;r<n;r++){const t=h.indexOf(e[r]);if(-1<t){const e=t+o;d=s(u,i,e),-1<d&&(u[d]=e,f[d]={newi:r,oldi:e,prev:f[d-1]})}}for(d=--i,--a;u[d]>a;)--d;i=c+r-d;const b=Array(i);let g=f[d];for(--n;g;){const{newi:e,oldi:t}=g;for(;n>e;)b[--i]=1,--n;for(;a>t;)b[--i]=-1,--a;b[--i]=0,--n,--a,g=g.prev}for(;n>=t;)b[--i]=1,--n;for(;a>=o;)b[--i]=-1,--a;return b})(r,l,o,a,d,i,f,u),e,t,r,l,d,i,h,g)},i=e=>(e.remove||f).call(e);function f(){const{parentNode:e}=this;e&&e.removeChild(this)}
/*! (c) 2018 Andrea Giammarchi (ISC) */const u=(e,t,s,i)=>{i||(i={});const f=i.compare||r,u=i.node||l,h=null==i.before?null:u(i.before,0),b=t.length;let g=b,p=0,y=s.length,m=0;for(;p<g&&m<y&&f(t[p],s[m]);)p++,m++;for(;p<g&&m<y&&f(t[g-1],s[y-1]);)g--,y--;const w=p===g,k=m===y;if(w&&k)return s;if(w&&m<y)return n(u,e,s,m,y,a(u,t,p,b,h)),s;if(k&&p<g)return c(u,t,p,g),s;const x=g-p,v=y-m;let q=-1;if(x<v){if(q=o(s,m,y,t,p,g,f),-1<q)return n(u,e,s,m,q,u(t[p],0)),n(u,e,s,q+x,y,a(u,t,g,b,h)),s}else if(v<x&&(q=o(t,p,g,s,m,y,f),-1<q))return c(u,t,p,q),c(u,t,q+v,g),s;return x<2||v<2?(n(u,e,s,m,y,u(t[p],0)),c(u,t,p,g),s):x===v&&((e,t,n,r,l,o)=>{for(;r<l&&o(n[r],e[t-1]);)r++,t--;return 0===t})(s,y,t,p,g,f)?(n(u,e,s,m,y,a(u,t,g,b,h)),s):(d(u,e,s,m,y,v,t,p,g,x,b,f,h),s)};let h=1;const b=e=>Math.round(1e3*Math.random())%e,g=e=>{const t=["pretty","large","big","small","tall","short","long","handsome","plain","quaint","clean","elegant","easy","angry","crazy","helpful","mushy","odd","unsightly","adorable","important","inexpensive","cheap","expensive","fancy"],n=["red","yellow","blue","green","pink","brown","purple","brown","white","black","orange"],r=["table","chair","house","bbq","desk","car","pony","cookie","sandwich","burger","pizza","mouse","keyboard"],l=new Array(e);for(let o=0;o<e;o++)l[o]={id:h++,label:t[b(t.length)]+" "+n[b(n.length)]+" "+r[b(r.length)]};return l},p=(e,t,n)=>{n[t]={...e,label:e.label+" !!!"}},y=e=>{e.label+=" !!!"},m=document.createElement("template");m.innerHTML='\n<tr>\n  <td class="col-md-1"></td>\n  <td class="col-md-4">\n    <a></a>\n  </td>\n  <td class="col-md-1"><a><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td>\n  <td class="col-md-6"></td>\n</tr>\n'.trim();const w=m.content.firstChild,k=[],x=(e,t,n,r,l)=>k[e]||((e,t,n,r,l)=>{const o=w.cloneNode(!0),a=o.querySelector("td");a.textContent=o.id=n;const[c,s]=o.querySelectorAll("a");c.textContent=r,c.addEventListener("click",()=>e(+o.id)),s.addEventListener("click",()=>t(+o.id));const d={danger:!1,id:n,label:r,row:o,selector:c,td:a};return k[l]=d})(t,n,r,l,e),v=document.querySelector("tbody");let q=[].slice.call(v.children);const A=((e,t=!1)=>{const n=e||(()=>{}),r=t?p:y,l={data:[],selected:-1,add(){t&&(l.data=l.data.slice(0)),l.data.push(...g(1e3)),n(l)},clear(){l.data=[],n(l)},run(){l.data=g(1e3),n(l)},runLots(){l.data=g(1e4),n(l)},swapRows(){t&&(l.data=l.data.slice(0));const{data:e}=l;if(e.length>998){const t=e[1];e[1]=e[998],e[998]=t}n(l)},update(){t&&(l.data=l.data.slice(0));const{data:e}=l;for(let t=0,{length:n}=e;t<n;t+=10)r(e[t],t,e);n(l)},remove(e){t&&(l.data=l.data.slice(0));const{data:r}=l;r.splice(r.findIndex(t=>t.id===e),1),n(l)},select(e){l.selected=e,n(l)}};return l})(({data:e,selected:t,select:n,remove:r})=>{var l;q=u(v,q,e.map((e,l)=>{const{id:o,label:a}=e,c=x(l,n,r,o,a),{row:s,selector:d,td:i}=c;c.id!==o&&(i.textContent=s.id=c.id=o),c.label!==a&&(d.textContent=c.label=a);const f=o===t;return c.danger!==f&&s.classList.toggle("danger",c.danger=f),s})),l=q.length,k.splice(l)});Object.keys(A).forEach(e=>{const t=document.querySelector("#"+e.toLowerCase());t&&t.addEventListener("click",()=>A[e]())})}();
