let M=null;function k(u){let m="",s=u;for(;s>0;){const i=(s-1)%26;m=String.fromCharCode(65+i)+m,s=Math.floor((s-1)/26)}return m}function T(u){const m=[",",";","	","|"],s=u.split(`
`).slice(0,20).filter(l=>l.trim()!=="");if(s.length===0)return",";if(s.length===1){const l=s[0];for(const o of m)if(l.includes(o))return o;return","}const i=[];for(const l of m){const o=[];let d=!0;for(const c of s)try{const f=D(c,l);o.push(f.length)}catch{d=!1;break}if(!d||o.length===0)continue;const y=o.reduce((c,f)=>c+f,0)/o.length;if(y<2)continue;const a=o.reduce((c,f)=>c+Math.pow(f-y,2),0)/o.length,E=a===0?1e3:y/Math.sqrt(a),x=Math.min(y/2,10),p=E*x;i.push({delimiter:l,columnCounts:o,avgColumns:y,variance:a,parseSuccess:d,score:p})}return i.length===0?",":(i.sort((l,o)=>{if(Math.abs(l.score-o.score)<.1){const d=[",",";","	","|"];return d.indexOf(l.delimiter)-d.indexOf(o.delimiter)}return o.score-l.score}),i[0].delimiter)}function D(u,m=","){const s=[];let i="",l=!1;for(let o=0;o<u.length;o++){const d=u[o],y=u[o+1];d==='"'?l&&y==='"'?(i+='"',o++):l=!l:d===m&&!l?(s.push(i),i=""):i+=d}return s.push(i),s}function w(u,m=!1){const s={0:"FF000000",1:"FFFFFFFF",2:"FF44546A",3:"FFE7E6E6",4:"FF4472C4",5:"FFED7D31",6:"FFA5A5A5",7:"FFFFC000",8:"FF5B9BD5",9:"FF70AD47"};return u===1&&!m?"FF000000":s[u]}self.addEventListener("message",async u=>{const m=u.data;if(m.type==="parse")try{M||(M=await import("./exceljs.min.30e613b5.js").then(function(a){return a.e}));const{arrayBuffer:s,filename:i}=m,l=i.toLowerCase().endsWith(".csv"),o=new M.Workbook;if(l){const E=new TextDecoder("utf-8").decode(s),x=T(E),p=E.split(`
`).filter(f=>f.trim()!==""),c=o.addWorksheet("Sheet1");p.forEach((f,A)=>{D(f,x).forEach((e,b)=>{const v=c.getCell(A+1,b+1),g=e.trim(),t=Number(g);g!==""&&!isNaN(t)&&g===String(t)?v.value=t:v.value=g})})}else{const a=s.byteLength/1048576;await o.xlsx.load(s),o.model&&o.model.themes}const d=[];o.eachSheet((a,E)=>{const x=a.name;d.push(x);const p={},c={s:{r:0,c:0},e:{r:0,c:0}};if(a.eachRow((f,A)=>{const C=A-1;C>c.e.r&&(c.e.r=C),f.eachCell({includeEmpty:!1},(e,b)=>{const v=b-1;v>c.e.c&&(c.e.c=v);const g=k(b)+A;let t=e.value,F;t&&typeof t=="object"&&(t.result!==void 0?t=t.result:t.richText&&Array.isArray(t.richText)?t=t.richText.map(r=>r.text||"").join(""):t.text!==void 0?t=t.text:t.hyperlink!==void 0?t=t.text||t.hyperlink:t.error!==void 0?t=t.error:t.sharedFormula!==void 0||t.formula!==void 0?t=e.result!==void 0?e.result:"":(console.warn(`[Worker] Unknown cell value type in ${g}:`,t),t="")),e.formula?F=e.formula:e.value&&typeof e.value=="object"&&e.value.formula?F=e.value.formula:e.value&&typeof e.value=="object"&&e.value.sharedFormula&&(F=e.value.sharedFormula);const h={v:t,t:"s"};if(F&&(h.f=F),e.numFmt&&(h.z=e.numFmt),t==null||t===""?h.t="z":typeof t=="number"?h.t="n":typeof t=="boolean"?h.t="b":t instanceof Date&&(h.t="d"),e.style){const r={};if(e.style.font&&(r.font={name:e.style.font.name,sz:e.style.font.size,bold:e.style.font.bold,italic:e.style.font.italic,underline:e.style.font.underline,strike:e.style.font.strike},e.style.font.color)){if(e.style.font.color.argb)r.font.color={rgb:e.style.font.color.argb};else if(e.style.font.color.theme!==void 0){const n=w(e.style.font.color.theme,!1);n?r.font.color={rgb:n}:r.font.color={theme:e.style.font.color.theme}}}if(e.style.fill&&(r.fill={},e.style.fill.type==="pattern"&&(r.fill.patternType=e.style.fill.pattern,e.style.fill.pattern!=="none"))){if(e.style.fill.fgColor){if(e.style.fill.fgColor.argb)r.fill.fgColor={rgb:e.style.fill.fgColor.argb};else if(e.style.fill.fgColor.theme!==void 0){const n=w(e.style.fill.fgColor.theme,!0);n?r.fill.fgColor={rgb:n}:r.fill.fgColor={theme:e.style.fill.fgColor.theme}}}if(e.style.fill.bgColor){if(e.style.fill.bgColor.argb)r.fill.bgColor={rgb:e.style.fill.bgColor.argb};else if(e.style.fill.bgColor.theme!==void 0){const n=w(e.style.fill.bgColor.theme,!0);n?r.fill.bgColor={rgb:n}:r.fill.bgColor={theme:e.style.fill.bgColor.theme}}}}e.style.border&&(r.border={},["top","left","bottom","right"].forEach(n=>{if(e.style.border[n]&&(r.border[n]={style:e.style.border[n].style},e.style.border[n].color)){if(e.style.border[n].color.argb)r.border[n].color={rgb:e.style.border[n].color.argb};else if(e.style.border[n].color.theme!==void 0){const S=w(e.style.border[n].color.theme,!1);S?r.border[n].color={rgb:S}:r.border[n].color={theme:e.style.border[n].color.theme}}}})),e.style.alignment&&(r.alignment={horizontal:e.style.alignment.horizontal,vertical:e.style.alignment.vertical,wrapText:e.style.alignment.wrapText,textRotation:e.style.alignment.textRotation,indent:e.style.alignment.indent}),h.s=r}p[g]=h})}),p["!ref"]=`A1:${k(c.e.c+1)}${c.e.r+1}`,a.model&&a.model.merges&&Array.isArray(a.model.merges)){const f=[];a.model.merges.forEach(A=>{const C=A.split(":");if(C.length===2){const e=C[0].match(/^([A-Z]+)(\d+)$/),b=C[1].match(/^([A-Z]+)(\d+)$/);if(e&&b){const v=e[1].split("").reduce((h,r)=>h*26+r.charCodeAt(0)-65,0),g=b[1].split("").reduce((h,r)=>h*26+r.charCodeAt(0)-65,0),t=parseInt(e[2])-1,F=parseInt(b[2])-1;f.push({s:{r:t,c:v},e:{r:F,c:g}})}}}),f.length>0&&(p["!merges"]=f)}self.postMessage({type:"sheet-data",sheetName:x,sheetData:p})});const y={type:"success",sheetNames:d};self.postMessage(y)}catch(s){console.error("[Worker] Error parsing spreadsheet:",s);const i={type:"error",error:s instanceof Error?s.message:"Unknown error parsing spreadsheet"};self.postMessage(i)}});
//# sourceMappingURL=spreadsheet.worker.fedc1565.js.map