import{t as e}from"./chunk/Log.js";var t=class{parseEntry(e,t,n,r){if(r==`(empty)`){e.putRaw(n,t,new Uint8Array);return}if(/^([0123456789abcdef]{2}-)+[0123456789abcdef]{2}(-\.\.\.)?$/.test(r))try{let i=r.split(`-`);i.at(-1)===`...`&&i.pop();for(let e of i)if(e.length!=2)throw`Invalid byte: `+e;let a=i.map(e=>Number.parseInt(e,16));for(let e of a)if(!Number.isInteger(e)||e<0||e>255)throw`Invalid byte: `+e;e.putRaw(n,t,Uint8Array.from(a));return}catch(e){console.error(`Failed to parse raw: `+r,e)}if(r.startsWith(`[`)&&r.endsWith(`]`))try{let i=r.slice(1,-1).split(`; `);i.length===1&&i[0].length===0&&(i=[]),i.at(-1)===`...`&&i.pop(),i=i.map(e=>JSON.parse(e)),e.putUnknownStruct(n,t,i,!0);return}catch(e){console.error(`Failed to parse array: `+r,e)}try{let i=JSON.parse(r);e.putUnknownStruct(n,t,i,!0)}catch(i){if(/^[0123456789abcdef]{2}$/.test(r)){let i=Number.parseInt(r,16);if(Number.isInteger(i)&&i>=0&&i<=255){e.putRaw(n,t,Uint8Array.from([i]));return}}throw i}}decode(e,t,n){let r=t.split(`
`);if(r[0]==[`Timestamp`,`Key`,`Value`].join(`,`))r.forEach((t,i)=>{if(i==0||t.length==0)return;let a=t.split(`,`);if(a.length!=3)throw`Invalid number of columns (expected 3): ${a.length}`;let[o,s,c]=a,l=Number.parseFloat(o);this.parseEntry(e,l,s,c),n!==void 0&&n(i/r.length)});else if(r[0].startsWith(`Timestamp`)){let t=r[0].split(`,`);r.forEach((i,a)=>{if(a==0||i.length==0)return;let o=i.split(`,`);if(o.length!=t.length)throw`Invalid number of columns (expected ${t.length}): ${o.length}`;let s=Number.parseFloat(o[0]);o.forEach((n,r)=>{r!=0&&this.parseEntry(e,s,t[r],n)}),n!==void 0&&n(a/r.length)})}else throw`Could not recognize columns: ${r[0]}`}};function n(e){self.postMessage(e)}self.onmessage=async r=>{let i=r.data;if(i.type!==`start`)return;let a=e=>{n({type:`progress`,value:e})};try{let r=new TextDecoder().decode(i.data[0]),o=new e(!1);new t().decode(o,r,a),o.getChangedFields(),a(1),n({type:`initial`,log:o.toSerialized(),isPartial:!1})}catch(e){console.error(e),n({type:`failed`});return}};