const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-CsE7HSTL.js","./rolldown-runtime-DAXXjFlN.js"])))=>i.map(i=>d[i]);
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./preload-helper-HclGiUj8.js";import{a as n,r,t as i}from"./lib-u36oR1k0.js";import{d as a,f as o,l as s,o as c,u as l}from"./workbook_model-CeXzIW3o.js";var u=`﻿`;function d(e,t={}){let n=p(e),r=s(n);return r.length===0?``:g(m(r,t.sheetId),n.styles??{})}async function f(n){let r=p(n),i=r.styles??{},{default:a}=await t(async()=>{let{default:t}=await import(`./jszip.min-CsE7HSTL.js`).then(t=>e(t.default,1));return{default:t}},__vite__mapDeps([0,1]),import.meta.url),o=new a,c=new Set;for(let e of s(r)){let t=h(e.name,c);o.file(t,u+g(e,i))}return o.generateAsync({type:`uint8array`})}function p(e){let{ok:t,data:n}=a(e);if(!t)throw Error(`Unable to parse spreadsheet data.`);if(!n?.workbook?.sheets)throw Error(`Spreadsheet contains no sheets.`);return n.workbook}function m(e,t){if(t){let n=e.find(e=>e.id===t);if(n)return n}return e[0]}function h(e,t){let n=(e??``).replace(/[\\/:*?"<>|\u0000-\u001f]/g,`_`).trim()||`Sheet`,r=n;for(let e=2;t.has(r.toLowerCase());e++)r=`${n} (${e})`;return t.add(r.toLowerCase()),`${r}.csv`}function g(e,t){let{cellData:n}=e,r=c(n,e.mergeData);if(!r)return``;let{minRow:i,maxRow:a,minCol:o,maxCol:s}=r,l=[];for(let e=i;e<=a;e++){let r=[];for(let i=o;i<=s;i++)r.push(y(_(n[e]?.[i],t)));l.push(r.join(`,`))}return l.join(`\r
`)}function _(e,t){if(!e||e.v==null)return``;if(typeof e.v==`boolean`)return e.v?`TRUE`:`FALSE`;let r=o(e.s,t)?.n?.pattern;if(r&&l(e.v)&&n(r)){let t=v(r,e.v);if(t!=null)return t}return String(e.v)}function v(e,t){try{let n=r(e);if(n.year&&n.month&&n.day){let e=`yyyy-mm-dd`;return n.seconds?e+=` hh:mm:ss`:(n.hours||n.minutes)&&(e+=` hh:mm`),i(e,t)}return i(e,t)}catch{return null}}function y(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}export{d as renderSpreadsheetToCsv,f as renderSpreadsheetToCsvZip};