1const s=["TCGplayer Id","Product Line","Set Name","Product Name","Title","Number","Rarity","Condition","TCG Market Price","TCG Direct Low","TCG Low Price With Shipping","TCG Low Price","Total Quantity","Add to Quantity","TCG Marketplace Price","Photo URL"],f=["string","string","string","string","stringNullable","stringNullable","string","string","priceNullable","priceNullable","priceNullable","priceNullable","intOptionalZero","intOptionalZero","priceOptionalZero","stringNullable"],d=["tcgplayerId","productLine","setName","productName","title","number","rarity","condition","tcgMarketPrice","tcgDirectLow","tcgLowPriceWithShipping","tcgLowPrice","totalQuantity","addToQuantity","tcgMarketplacePrice","photoUrl"];function m(r){const n=[];let e="",t=!1;for(let i=0;i<r.length;i++){const o=r[i];if(o==='"'){if(t&&r[i+1]==='"'){e+='""',i++;continue}t=!t,e+=o;continue}if(!t&&(o===` 2`||o==="\r")){o==="\r"&&r[i+1]===` 3`&&i++,n.push(e),e="";continue}e+=o}return e.length>0&&n.push(e),n}function h(r){const n=[];let e="",t=!1;for(let i=0;i<r.length;i++){const o=r[i];if(o==='"'){if(t&&r[i+1]==='"'){e+='"',i++;continue}t=!t;continue}if(o===","&&!t){n.push(e),e="";continue}e+=o}if(t)throw new Error("unterminated quoted field");return n.push(e),n}function N(r,n){return(n===0?r.replace(/^\uFEFF/,""):r).trim()}function w(r,n){const e=r;switch(n){case"string":return e;case"stringNullable":return e===""?null:e;case"priceNullable":{if(e==="")return null;const t=Number(e);if(!Number.isFinite(t))throw new Error(`expected numeric value, got ${JSON.stringify(r)}`);return t}case"priceOptionalZero":{if(e==="")return 0;const t=Number(e);if(!Number.isFinite(t))throw new Error(`expected numeric value, got ${JSON.stringify(r)}`);return t}case"intOptionalZero":{if(e==="")return 0;const t=Number(e);if(!Number.isInteger(t))throw new Error(`expected integer value, got ${JSON.stringify(r)}`);return t}}}function b(r){const n=[],e=[],t=[],i=m(r);if(i.length===0)return t.push({line:1,error:"missing TCG inventory CSV header"}),{rows:n,rowLines:e,parseErrors:t};let o;try{o=h(i[0])}catch(l){return t.push({line:1,error:`header parse failed: ${l.message}`}),{rows:n,rowLines:e,parseErrors:t}}if(o.length!==s.length)return t.push({line:1,error:`expected ${s.length} header columns, got ${o.length}`}),{rows:n,rowLines:e,parseErrors:t};for(let l=0;l<s.length;l++){const u=N(o[l],l),c=s[l];if(u!==c)return t.push({line:1,error:`header mismatch at column ${l+1}: expected ${JSON.stringify(c)}, got ${JSON.stringify(u)}`}),{rows:n,rowLines:e,parseErrors:t}}for(let l=1;l<i.length;l++){const u=i[l];if(u.length!==0)try{const c=h(u);if(c.length!==s.length)throw new Error(`expected ${s.length} columns, got ${c.length}`);const g={};for(let a=0;a<s.length;a++){const p=w(c[a],f[a]);g[d[a]]=p}n.push(g),e.push(l+1)}catch(c){t.push({line:l+1,error:c.message})}}return{rows:n,rowLines:e,parseErrors:t}}export{b as p};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.