-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path34c9e88b04b9410469e0.worker.js
1 lines (1 loc) · 9.49 KB
/
34c9e88b04b9410469e0.worker.js
1
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=7)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.updateFrequencies=function(e,t){for(var r=JSON.parse(JSON.stringify(e)),n=function(e){e[1][0]=0;for(var t=0,n=Object.keys(r);t<n.length;t++){var a=n[t];for(var l in r[a]){var o=r[a][l];u(e[0],o).length===e[0].length&&(e[1][0]++,r[a][l]=o.filter(function(t){return-1===e[0].indexOf(t)}))}}},l=0,o=t;l<o.length;l++)n(o[l]);return a(t)};var n=function(e,t){for(var r=0,n=0,a=Object.keys(t);n<a.length;n++)for(var l=0,o=t[a[n]];l<o.length;l++){var f=o[l];u(e,f).length===e.length&&r++}return r};t.supportOfItem=n;var a=function(e){return e.sort(function(e,t){return e[0].length<t[0].length?1:e[0].length>t[0].length?-1:e[2][0]<t[2][0]?1:e[2][0]>t[2][0]?-1:-1*JSON.stringify(e[0]).localeCompare(JSON.stringify(t[0]))}),e};t.standardCoverOrder=a;var u=function(e,t){var r=e.length>t.length?t:e,n=e.length>t.length?e:t,a=[];return r.map(function(e){-1!==n.indexOf(e)&&a.push(e)}),a};t.subset=u,t.default=function(e){for(var t=function(e){for(var t={},r=0,n=Object.keys(e);r<n.length;r++)for(var a=0,u=e[n[r]];a<u.length;a++)for(var l=0,o=u[a];l<o.length;l++){var f=o[l],i=String(f);null==t[i]&&(t[i]=0),t[i]++}return t}(e),r=[],u=0,l=Object.keys(t);u<l.length;u++){var o=l[u];r.push([[Number(o)],[t[o]],[n([t[o]],e)]])}return a(r)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),a=r(4),u=r(9),l=function(e,t){return-a.default(function(e,t){var r,a=0,u=0;return e.forEach(function(e){u+=e[1][0],n.default(e[0],t)&&(r=e)}),null!=r&&(a=r[1][0]),a/u}(e,t))};t.lengthForSet=l;t.lengthForSetInStandard=function(e,t){for(var r=0,n=0,a=u.default(e,t);n<a.length;n++){var o=a[n];r+=l(e,o)}return r};var o=function(e,t){for(var r=0,n=0,a=Object.keys(e);n<a.length;n++)for(var o=0,f=e[a[n]];o<f.length;o++){for(var i=f[o],s=0,d=0,c=u.default(t,i);d<c.length;d++){var g=c[d];s+=l(t,g)}r+=s}return r};function f(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)}t.codeLengthIncludingStandard=function(e,t,r){return function(e,t,r){for(var n=0,a=0,u=t;a<u.length;a++){var o=u[a],i=l(t,o[0]),s=l(r,o[0]);f(i)&&(n+=i),f(s)&&(n+=s)}return n}(0,t,r)+o(e,t)},t.default=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function(e,t){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}return e===t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),a=r(0);t.getLPercent=function(e,t){var r=a.default(e);return n.codeLengthIncludingStandard(e,t,r)/n.codeLengthIncludingStandard(e,r,r)*100}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t){return Math.log(t)/Math.log(e)};t.getBaseLog=n;t.default=function(e){return n(2,e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),a=r(4),u=r(1),l=r(0);t.createPairCandidates=function(e){for(var t=[],r=0;r<e.length;r++)for(var n=r;n<e.length;n++){var a=e[r][0],u=e[n][0];if(r!==n&&0===l.subset(a,u).length){var f=[a,u,[].concat(a).concat(u),[0]];t.unshift(f)}}return t.sort(o),t};var o=function(e,t){return e[2].length<t[2].length?1:e[2].length>t[2].length?-1:-1*JSON.stringify(e[2]).localeCompare(JSON.stringify(t[2]))},f=function(e,t){return isNaN(e[3][0])?1:isNaN(t[3][0])?-1:e[3][0]<t[3][0]?1:e[3][0]>t[3][0]?-1:-1*JSON.stringify(e[3][0]).localeCompare(JSON.stringify(t[3][0]))};t.default=function(e,t,r,o,i){void 0===i&&(i=0);for(var s=function(e){for(var t=0,r=0,n=e;r<n.length;r++)t+=n[r][1][0];return t}(t),d=((new Date).getTime(),[]),c=JSON.parse(JSON.stringify(e)),g=function(e){e[1][0]=0;for(var t=0,r=Object.keys(c);t<r.length;t++){var n=r[t];for(var a in c[n]){var u=c[n][a];if(l.subset(e[0],u).length===e[0].length){e[1][0]++;var o=JSON.stringify(e[0]);null==d[o]&&(d[o]=[]),d[o].push(Number(a)),c[n][a]=u.filter(function(t){return-1===e[0].indexOf(t)})}}}},v=0,h=t;v<h.length;v++)g(h[v]);for(var p=[],b=0,O=o;b<O.length;b++){var y=O[b];(new Date).getTime();var S=d[JSON.stringify(y[0])];null==S&&(S=[]);var _=d[JSON.stringify(y[1])];null==_&&(_=[]);var N=l.subset(S,_).length;if(0===N);else{for(var j=S.length-N,m=_.length-N,P=s-N,T=0,M=0,x=0,J=0,I=0;I<t.length;I++){var L=t[I][0],k=t[I][1][0],F=t[I][1][0];if(n.default(t[I][0],y[0])?F=j:n.default(t[I][0],y[1])&&(F=m),F!==k){0!==k&&0!==F&&(T+=k*a.default(k)-F*a.default(F),M+=a.default(F)-a.default(k));var C=u.lengthForSetInStandard(r,L);0===k&&(x+=a.default(F)-C),0===F&&(J+=C-a.default(k))}}var E=s*a.default(s)-P*a.default(P)+N*a.default(N)-T,D=a.default(N)-u.lengthForSetInStandard(r,y[2])+t.length*a.default(s)-(t.length+1)*a.default(P)+M+x+J;y[3][0]=E+D,p.push(y)}}switch(console.log("GOT SORT ORDER",i),i){case 0:p.sort(f).reverse();break;case 1:p.sort(f);break;case 2:!function(e){for(var t=e.length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}}(p)}return p}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),a=r(10),u=r(1),l=r(0),o=function(e,t){for(var r=[],a=0,u=t;a<u.length;a++){var l=u[a];e:for(var o=0,f=e;o<f.length;o++){var i=f[o];if(l[0].length>1&&n.default(l[0],i[0])){l[1][0]<i[1][0]&&r.push(l);break e}}}return r.sort(function(e,t){return e[1][0]-t[1][0]}),r};t.default=function(e,t,r,f){for(var i=o(t,r),s=r,d=function(){var t=i.shift(),r=s.filter(function(e){return!n.default(t[0],e[0])});if(r=l.updateFrequencies(e,r),u.codeLengthIncludingStandard(e,r,f)<u.codeLengthIncludingStandard(e,s,f)&&a.default(e,r))for(var d=function(e){0===i.filter(function(t){return n.default(t[0],e[0])}).length&&i.push(e)},c=0,g=o(s,s=r);c<g.length;c++)d(g[c])};i.length>0;)d();return s=s.filter(function(e){return e[1][0]>0})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),a=r(1),u=r(5),l=r(6),o=r(0),f=r(3),i=r(11),s=self,d=function(e,t,r){for(var n=o.default(e),l=u.default(e,t,n,u.createPairCandidates(t),r),f=[],i=0;f.length<10&&i<l.length;){var s=l[i],d=JSON.parse(JSON.stringify(t));d.unshift([s[2],[0],[o.supportOfItem(s[2],e)]]),d=o.updateFrequencies(e,d),a.codeLengthIncludingStandard(e,d,n)<a.codeLengthIncludingStandard(e,t,n)&&f.push({compression:-1,loading:!0,set:s[2],gain:s[3][0],finalCodeTable:[],path:[],codeTableToExplore:t,children:[]}),i++}return f};s.addEventListener("message",function(e){if(e.data.type===i.default.first10Pairs){var t=d(e.data.dataset,e.data.codeTable,e.data.sortType);s.postMessage({type:i.default.pairResult,pairs:t})}else if(e.data.type===i.default.exploreTable){console.log("BG: Explore Table for",e.data);var r=e.data,a=r.pair,u=r.dataset,c=r.path,g=JSON.parse(JSON.stringify(a.codeTableToExplore));g.unshift([a.set,[0],[o.supportOfItem(a.set,u)]]),g=o.updateFrequencies(u,g),g=l.default(u,a.codeTableToExplore,g,o.default(u));var v=n.default(u,g,e.data.sortType);a.finalCodeTable=v,a.compression=f.getLPercent(u,v),a.loading=!1,a.children=d(u,g,e.data.sortType),a.path=c,console.log("BG: Done Exploring Table for",e.data),s.postMessage({type:i.default.exploreTableResult,pair:a,path:c})}}),s.postMessage({type:i.default.booted}),t.default=self},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(3),a=r(1),u=r(5),l=r(6),o=r(0);t.default=function(e,t,r){for(var f=o.default(e),i=!0,s=t||f,d=0,c=Date.now();i;){console.log("in iteration "+d+" of slim current |L%|="+n.getLPercent(e,s)+" elapsed time "+(Date.now()-c)+"ms"),d++,i=!1;var g=u.createPairCandidates(s);e:for(var v=0,h=u.default(e,s,f,g,r);v<h.length;v++){var p=h[v],b=JSON.parse(JSON.stringify(s));if(b.unshift([p[2],[0],[o.supportOfItem(p[2],e)]]),b=o.updateFrequencies(e,b),a.codeLengthIncludingStandard(e,b,f)<a.codeLengthIncludingStandard(e,s,f)){s=b=l.default(e,s,b,f),i=!0;break e}}}return console.log("DONE WITH SLIM"),s}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);t.default=function(e,t){var r=t.slice(0),a=[];e:for(var u=0,l=e;u<l.length;u++){var o=l[u];if(n.subset(o[0],r).length===o[0].length){a.push(o[0]);for(var f=0,i=o[0];f<i.length;f++){var s=i[f];r.splice(r.indexOf(s),1)}if(0===r.length)break e}}return a}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);t.default=function(e,t){for(var r=0,a=Object.keys(e);r<a.length;r++)for(var u=0,l=e[a[r]];u<l.length;u++){var o=l[u].slice(0),f=[];e:for(var i=0,s=t;i<s.length;i++){var d=s[i];if(n.subset(d[0],o).length===d[0].length){f.push(d[0]);for(var c=0,g=d[0];c<g.length;c++){var v=g[c];o.splice(o.indexOf(v),1)}if(0===o.length)break e}}if(0!==o.length)return!1}return!0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={booted:1,first10Pairs:2,pairResult:3,exploreTable:4,exploreTableResult:5}}]);