(function(){"use strict";class m{constructor(t,s){this.data=t,this.shape=s}}function h(e,t,s,o,n){e.h=t,e.w=s,e.m=o,e.cnts=o===0?[0]:n}function _(e,t){let s;for(s=0;s<t;s++)e[s]={h:0,w:0,m:0,cnts:[0]},h(e[s],0,0,0,[0])}class p{constructor(t){this._R=[],_(this._R,t),this._n=t}}class d{constructor(t,s,o){this._mask=new Uint8Array(t*s*o),this._h=t,this._w=s,this._n=o}toDataArray(){return new m(this._mask,[this._h,this._w,this._n])}}function k(e){const t=y(e),{h:s}=t._R[0],{w:o}=t._R[0],n=t._n,a=new d(s,o,n);return g(t._R,a._mask,n),a.toDataArray()}function w(e,t,s){const o=new Uint8Array(t*s*2);for(let n=0;n<s;n+=1)for(let a=0;a<t;a+=1){const r=n+a*s,i=e[r]?255:0,c=(n*t+a)*2;o[c]=i,o[c+1]=i}return o}function g(e,t,s){let o,n,a,r=0;for(o=0;o<s;o++){let i=!1;for(n=0;n<e[o].m;n++){for(a=0;a<e[o].cnts[n];a++)t[r++]=i===!1?0:1;i=!i}}}function y(e){const t=e.length,s=new p(t);let o,n;for(let a=0;a<e.length;a++){const r=e[a];o=r.counts,n=o,A(s._R[a],n,r.size[0],r.size[1])}return s}function A(e,t,s,o){let n=0,a=0,r,i,c,f=[];for(;t[n];)n++;for(f=[],n=0;t[a];){for(i=0,r=0,c=1;c;){const u=t.charCodeAt(a)-48;i|=(u&31)<<5*r,c=u&32,a++,r++,!c&&u&16&&(i|=-1<<5*r)}n>2&&(i+=f[n-2]),f[n++]=i}h(e,s,o,n,f)}let l=!1;self.onmessage=async e=>{const{command:t,rleMasks:s}=e.data;if(t==="stop"){l=!0;return}if(t==="start"||!t){l=!1;const o=[];for(const n of s){if(l)break;await new Promise(a=>setTimeout(a,0)),o.push(M(n.trackId,n.frameId,n.rleWrapper.rle))}l?self.postMessage({status:"stopped"}):self.postMessage({rleLuminanceMasks:o})}};function M(e,t,s){const o=w(k([s]).data,s.size[1],s.size[0]),n=s.size[0],a=s.size[1];return{trackId:e,frameId:t,width:a,height:n,data:o}}})();
//# sourceMappingURL=rleWorker-BVzqs6R2.js.map
