@kanunilabs/pivotgrid-core 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -3
- package/dist/import.worker.cjs +2 -2
- package/dist/import.worker.js +2 -2
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -33,9 +33,9 @@ Software you agree to these terms.
|
|
|
33
33
|
|
|
34
34
|
4. ENTERPRISE FEATURES
|
|
35
35
|
Certain features require a separate paid license
|
|
36
|
-
(@kanunilabs/pivotgrid-react-enterprise, @kanunilabs/
|
|
37
|
-
or @kanunilabs/datagrid-enterprise).
|
|
38
|
-
features.
|
|
36
|
+
(@kanunilabs/pivotgrid-react-enterprise, @kanunilabs/pivotgrid-enterprise,
|
|
37
|
+
@kanunilabs/datagrid-react-enterprise or @kanunilabs/datagrid-enterprise).
|
|
38
|
+
This license grants no right to those features.
|
|
39
39
|
|
|
40
40
|
5. NO WARRANTY
|
|
41
41
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
package/dist/import.worker.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';function T(e){return e.charCodeAt(0)===65279?e.slice(1):e}function S(e){return typeof e.text=="function"?e.text():new Promise((t,n)=>{let r=new FileReader;r.onload=i=>t(i.target?.result??""),r.onerror=()=>n(new Error("Dosya okuma hatas\u0131.")),r.readAsText(e,"utf-8");})}function N(e){let t=[",",";"," ","|"],n=T(e).split(/\r\n|\r|\n/).filter(s=>s.length>0).slice(0,5);if(n.length===0)return ",";let r=",",i=-1;for(let s of t){let a=n.map(d=>
|
|
1
|
+
'use strict';function T(e){return e.charCodeAt(0)===65279?e.slice(1):e}function S(e){return typeof e.text=="function"?e.text():new Promise((t,n)=>{let r=new FileReader;r.onload=i=>t(i.target?.result??""),r.onerror=()=>n(new Error("Dosya okuma hatas\u0131.")),r.readAsText(e,"utf-8");})}function N(e){let t=[",",";"," ","|"],n=T(e).split(/\r\n|\r|\n/).filter(s=>s.length>0).slice(0,5);if(n.length===0)return ",";let r=",",i=-1;for(let s of t){let a=n.map(d=>B(d,s)),o=a.reduce((d,f)=>d+f,0);if(o===0)continue;let l=a[0],u=a.every(d=>d===l),c=o+(u?100:0)+l*10;c>i&&(i=c,r=s);}return r}function B(e,t){let n=0,r=false;for(let i=0;i<e.length;i++){let s=e[i];if(s==='"'){if(r&&e[i+1]==='"'){i++;continue}r=!r;}else !r&&s===t&&n++;}return n}function X(e,t,n){let r=T(e),i=t||N(r),s=[],a="",o=[],l=false,u=false,c=r.length,d=n?Math.max(1<<18,Math.ceil(c/100)):0,f=d;for(let g=0;g<r.length;g++){d&&g>=f&&(n(g/c),f+=d);let p=r[g];if(l){p==='"'?r[g+1]==='"'?(a+='"',g++):l=false:a+=p;continue}p==='"'?(l=true,u=true):p===i?(o.push(a),a="",u=true):p===`
|
|
2
2
|
`||p==="\r"?(p==="\r"&&r[g+1]===`
|
|
3
|
-
`&&g++,o.push(a),s.push(o),o=[],a="",u=false):(a+=p,u=true);}return (u||a.length>0||o.length>0)&&(o.push(a),s.push(o)),n&&n(1),s}var A=new Set(["true","yes","evet","do\u011Fru","dogru"]),F=new Set(["false","no","hay\u0131r","hayir","yanl\u0131\u015F","yanlis"]);function
|
|
3
|
+
`&&g++,o.push(a),s.push(o),o=[],a="",u=false):(a+=p,u=true);}return (u||a.length>0||o.length>0)&&(o.push(a),s.push(o)),n&&n(1),s}var A=new Set(["true","yes","evet","do\u011Fru","dogru"]),F=new Set(["false","no","hay\u0131r","hayir","yanl\u0131\u015F","yanlis"]);function z(e){let t=e.trim().toLowerCase();return A.has(t)||F.has(t)}function Y(e){if(typeof e=="boolean")return e;let t=String(e).trim().toLowerCase();return A.has(t)||t==="1"||t==="y"||t==="on"?true:F.has(t)||t==="0"||t==="n"||t==="off"?false:null}function K(e){return /^0\d+$/.test(e)}var H=/[₺$€£¥]/g,Z=/[\s ]/g;function _(e){if(typeof e=="number")return isNaN(e)?null:e;let t=String(e).trim();if(!t)return null;t=t.replace(Z,"").replace(H,"");let n=false;t.endsWith("%")&&(n=true,t=t.slice(0,-1));let r=false;if(/^\(.*\)$/.test(t)&&(r=true,t=t.slice(1,-1)),!/^[+-]?[0-9.,]*[0-9][0-9.,]*$/.test(t))return null;let i=t.includes("."),s=t.includes(",");if(i&&s)t.lastIndexOf(",")>t.lastIndexOf(".")?t=t.replace(/\./g,"").replace(",","."):t=t.replace(/,/g,"");else if(s){let o=t.split(",");o.length===2&&o[1].length!==3?t=t.replace(",","."):t=t.replace(/,/g,"");}else i&&t.split(".").length>2&&(t=t.replace(/\./g,""));let a=Number(t);return isNaN(a)?null:(r&&(a=-a),n&&(a=a/100),a)}var U=/^\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:?\d{2})?)?$/,V=/^(\d{4})[/.](\d{1,2})[/.](\d{1,2})$/,Q=/^(\d{1,2})[/.\-](\d{1,2})[/.\-](\d{4})$/;function D(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;let t=String(e).trim();if(!t)return null;if(U.test(t)){let i=new Date(t.replace(" ","T"));return isNaN(i.getTime())?null:i}let n=V.exec(t);if(n){let i=new Date(+n[1],+n[2]-1,+n[3]);return C(i,+n[1],+n[2],+n[3])?i:null}let r=Q.exec(t);if(r){let i=+r[1],s=+r[2],a=+r[3],o,l;i>12&&s<=12?(o=i,l=s):s>12&&i<=12?(o=s,l=i):(o=i,l=s);let u=new Date(a,l-1,o);return C(u,a,l,o)?u:null}return null}function C(e,t,n,r){return !isNaN(e.getTime())&&e.getFullYear()===t&&e.getMonth()===n-1&&e.getDate()===r}function G(e){if(e==null||e==="")return "blank";if(typeof e=="boolean")return "boolean";if(typeof e=="number")return isNaN(e)?"blank":"number";if(e instanceof Date)return isNaN(e.getTime())?"blank":"date";let t=String(e).trim();return t===""?"blank":z(t)?"boolean":K(t)?"string":D(t)?"date":_(t)!==null?"number":"string"}function x(e){let t={string:0,number:0,date:0,boolean:0};for(let i of e){let s=G(i);s!=="blank"&&t[s]++;}let n="string",r=0;return Object.keys(t).forEach(i=>{t[i]>r&&(r=t[i],n=i);}),n}function v(e,t){if(e==null||e==="")return null;switch(t){case "number":return _(e);case "date":return D(e)??(e instanceof Date?e:null);case "boolean":return Y(e);default:return e}}var E=new Set(["__proto__","constructor","prototype"]);function y(e){return E.has(e)?`${e}_`:e}function M(e){let t=false;for(let n of e)if(!(!n||typeof n!="object")){for(let r of Object.keys(n))if(E.has(r)){t=true;break}if(t)break}return t?e.map(n=>{if(!n||typeof n!="object")return n;let r={};for(let i of Object.keys(n))r[y(i)]=n[i];return r}):e}var O=200,I=2e4;function q(e){let t=new Map;return e.map(n=>{let r=t.get(n)??0;return t.set(n,r+1),y(r===0?n:`${n}_${r+1}`)})}function P(e,t){if(e.length===0)return [];let n=[],r=new Set,i=Math.min(e.length,500);for(let o=0;o<i;o++){let l=e[o];if(!(!l||typeof l!="object"))for(let u of Object.keys(l))r.has(u)||(r.add(u),n.push(u));}let s=new Map;for(let o of n){let l=[];for(let u=0;u<e.length&&l.length<O;u++){let c=e[u]?.[o];c!=null&&String(c).trim()!==""&&l.push(c);}s.set(o,x(l));}let a=new Array(e.length);for(let o=0;o<e.length;o++){let l=e[o]||{},u={};for(let c of n){let d=l[c];u[y(c)]=d==null||d===""?null:v(d,s.get(c));}a[o]=u;}return a}function $(e,t){let n=T(e);if(!n.trim())return [];let r=N(n),i=X(n,r,t?c=>t({phase:"parsing",percent:Math.round(c*60)}):void 0);if(i.length===0)return [];let s=0;for(;s<i.length&&i[s].every(c=>c.trim()==="");)s++;if(s>=i.length)return [];let a=q(i[s].map((c,d)=>c.trim()||`Column${d+1}`)),o=i.slice(s+1).filter(c=>!(c.length===1&&c[0].trim()==="")),l=a.map((c,d)=>{let f=[];for(let g=0;g<o.length&&f.length<O;g++){let p=o[g][d];p!==void 0&&p.trim()!==""&&f.push(p);}return x(f)}),u=new Array(o.length);for(let c=0;c<o.length;c++){let d=o[c],f={};for(let g=0;g<a.length;g++){let p=d[g];f[a[g]]=p===void 0||p===""?null:v(p,l[g]);}u[c]=f,t&&c>0&&c%I===0&&t({phase:"typing",percent:60+Math.round(c/o.length*40)});}return t&&t({phase:"typing",percent:100}),u}var b=class e{supports(t){return t.name.split(".").pop()?.toLowerCase()==="xml"||t.type==="application/xml"||t.type==="text/xml"}async read(t){let n=await S(t);return e.parse(n)}static parse(t){if(!t||!t.trim())return [];let n=J(t),i=et(n).map(nt).filter(s=>Object.keys(s).length>0);return P(i)}};function J(e){let t={tag:"#root",attrs:{},children:[],text:"",parent:null},n=t,r=0,i=e.length;for(;r<i;){let s=e.indexOf("<",r);if(s===-1){n.text+=e.slice(r);break}if(s>r&&(n.text+=e.slice(r,s)),e.startsWith("<!--",s)){let f=e.indexOf("-->",s+4);r=f===-1?i:f+3;continue}if(e.startsWith("<![CDATA[",s)){let f=e.indexOf("]]>",s+9);n.text+=e.slice(s+9,f===-1?i:f),r=f===-1?i:f+3;continue}if(e.startsWith("<?",s)){let f=e.indexOf("?>",s+2);r=f===-1?i:f+2;continue}if(e.startsWith("<!",s)){let f=e.indexOf(">",s+2);r=f===-1?i:f+1;continue}let a=e.indexOf(">",s+1);if(a===-1)break;let o=e.slice(s+1,a).trim();if(o.startsWith("/")){let f=o.slice(1).trim(),g=n;for(;g&&g.tag!==f;)g=g.parent;g&&g.parent&&(n=g.parent),r=a+1;continue}let l=o.endsWith("/");l&&(o=o.slice(0,-1).trim());let{name:u,attrs:c}=tt(o),d={tag:u,attrs:c,children:[],text:"",parent:n};n.children.push(d),l||(n=d),r=a+1;}return t}var j=/([^\s=/]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function tt(e){let t=e.search(/\s/),n=(t===-1?e:e.slice(0,t)).trim(),r={};if(t!==-1){let i=e.slice(t+1),s;for(j.lastIndex=0;(s=j.exec(i))!==null;)r[s[1]]=R(s[2]??s[3]??"");}return {name:n,attrs:r}}function et(e){let t=e.children[0];if(!t)return [];let n=t.children;return n.length===0?[]:n.some(i=>i.children.length>0||Object.keys(i.attrs).length>0)?n:[t]}function nt(e){let t={},n=new Map,r=(i,s)=>{let a=i||"value",o=n.get(a)??0;n.set(a,o+1),t[y(o===0?a:`${a}_${o+1}`)]=s;};for(let[i,s]of Object.entries(e.attrs))r(i,s);if(e.children.length===0){let i=e.text.trim();i&&r(e.tag,R(i));}else for(let i of e.children)r(i.tag,R(W(i).trim()));return t}function W(e){if(e.children.length===0)return e.text;let t=e.text;for(let n of e.children)t+=W(n);return t}var rt=/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,it={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:"\xA0"};function R(e){return e.indexOf("&")===-1?e:e.replace(rt,(t,n)=>{if(n[0]==="#"){let r=n[1]==="x"||n[1]==="X"?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return Number.isFinite(r)?String.fromCodePoint(r):t}return it[n]??t})}var h=class{static extractFieldsFromData(t,n=50){if(!t||t.length===0)return [];let r=[],i=Math.max(n,50),s=this.collectKeys(t,i),a=false,o=false;return s.forEach(l=>{let u=this.inferType(t,l,n),c="chooser";!a&&this.isAutoRowCandidate(t,l,u,i)?(c="row",a=true):!o&&this.isAutoDataCandidate(l,u)&&(c="data",o=true);let d={id:`f_${l}`,dataField:l,caption:this.formatCaption(l),dataType:u,area:c,areaIndex:0};u==="number"?d.summaryType="sum":u==="date"&&(d.groupInterval="month"),r.push(d);}),r}static buildFieldsFromPlan(t,n,r=50){let i=[],s=false,a=false,o=Math.max(r,50);for(let l of t){let u="chooser";!s&&this.isAutoRowCandidate(n,l.dataField,l.dataType,o)?(u="row",s=true):!a&&this.isAutoDataCandidate(l.dataField,l.dataType)&&(u="data",a=true);let c={id:`f_${l.dataField}`,dataField:l.dataField,caption:l.caption,dataType:l.dataType,area:u,areaIndex:0};l.dataType==="number"?c.summaryType="sum":l.dataType==="date"&&(c.groupInterval="month"),i.push(c);}return i}static isAutoRowCandidate(t,n,r,i){return !(n.startsWith("__EMPTY")||r!=="string"&&r!=="date"||this.isIdentifierLikeKey(n)||r==="string"&&t&&this.isHighCardinalityStringColumn(t,n,i))}static isAutoDataCandidate(t,n){return n==="number"&&!t.startsWith("__EMPTY")&&!this.isIdentifierLikeKey(t)}static isHighCardinalityStringColumn(t,n,r){let i=Math.min(t.length,r),s=new Set,a=0;for(let o=0;o<i;o++){let l=t[o]?.[n];l==null||l===""||(a++,s.add(String(l)));}return a<20?false:s.size/a>=.9}static isIdentifierLikeKey(t){let n=t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase(),r=n.replace(/[^a-z0-9]/g,"");return r==="id"||r==="uuid"||r==="guid"||r==="key"?true:/(^|[\s_.-])(id|uuid|guid|key)($|[\s_.-])/.test(n)}static collectKeys(t,n){let r=[],i=new Set,s=Math.min(t.length,n);for(let a=0;a<s;a++){let o=t[a];if(!(!o||typeof o!="object"))for(let l of Object.keys(o))i.has(l)||(i.add(l),r.push(l));}return r}static inferType(t,n,r){let i=Math.min(t.length,r),s=new Array(i);for(let a=0;a<i;a++)s[a]=t[a]?.[n];return x(s)}static formatCaption(t){return t.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/^./,n=>n.toUpperCase()).trim()}};var k=self;k.onmessage=async e=>{let t=e.data;if(!t||t.type!=="parse")return;let{jobId:n,kind:r,file:i}=t;try{if(r==="csv"){m(n,"reading",3);let s=await i.text(),a=$(s,l=>{m(n,l.phase,5+Math.round(l.percent*.92));});m(n,"finalizing",98);let o=h.extractFieldsFromData(a);w(n,{mode:"data",data:a,fields:o});return}if(r==="xml"){m(n,"reading",10);let s=await i.text();m(n,"parsing",50);let a=b.parse(s);m(n,"finalizing",90);let o=h.extractFieldsFromData(a);w(n,{mode:"data",data:a,fields:o});return}if(r==="json"){m(n,"reading",10);let s=await i.text();m(n,"parsing",45);let a=JSON.parse(s);if(Array.isArray(a)){m(n,"finalizing",90);let o=M(a),l=h.extractFieldsFromData(o);w(n,{mode:"data",data:o,fields:l});}else w(n,{mode:"raw",value:a});return}L(n,`Desteklenmeyen i\xE7e aktarma t\xFCr\xFC: ${String(r)}`);}catch(s){L(n,s instanceof Error?s.message:String(s));}};function m(e,t,n){k.postMessage({type:"progress",jobId:e,phase:t,percent:n});}function w(e,t){k.postMessage({type:"done",jobId:e,payload:t});}function L(e,t){k.postMessage({type:"error",jobId:e,message:t});}
|
package/dist/import.worker.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
function T(e){return e.charCodeAt(0)===65279?e.slice(1):e}function S(e){return typeof e.text=="function"?e.text():new Promise((t,n)=>{let r=new FileReader;r.onload=i=>t(i.target?.result??""),r.onerror=()=>n(new Error("Dosya okuma hatas\u0131.")),r.readAsText(e,"utf-8");})}function N(e){let t=[",",";"," ","|"],n=T(e).split(/\r\n|\r|\n/).filter(s=>s.length>0).slice(0,5);if(n.length===0)return ",";let r=",",i=-1;for(let s of t){let a=n.map(d=>
|
|
1
|
+
function T(e){return e.charCodeAt(0)===65279?e.slice(1):e}function S(e){return typeof e.text=="function"?e.text():new Promise((t,n)=>{let r=new FileReader;r.onload=i=>t(i.target?.result??""),r.onerror=()=>n(new Error("Dosya okuma hatas\u0131.")),r.readAsText(e,"utf-8");})}function N(e){let t=[",",";"," ","|"],n=T(e).split(/\r\n|\r|\n/).filter(s=>s.length>0).slice(0,5);if(n.length===0)return ",";let r=",",i=-1;for(let s of t){let a=n.map(d=>B(d,s)),o=a.reduce((d,f)=>d+f,0);if(o===0)continue;let l=a[0],u=a.every(d=>d===l),c=o+(u?100:0)+l*10;c>i&&(i=c,r=s);}return r}function B(e,t){let n=0,r=false;for(let i=0;i<e.length;i++){let s=e[i];if(s==='"'){if(r&&e[i+1]==='"'){i++;continue}r=!r;}else !r&&s===t&&n++;}return n}function X(e,t,n){let r=T(e),i=t||N(r),s=[],a="",o=[],l=false,u=false,c=r.length,d=n?Math.max(1<<18,Math.ceil(c/100)):0,f=d;for(let g=0;g<r.length;g++){d&&g>=f&&(n(g/c),f+=d);let p=r[g];if(l){p==='"'?r[g+1]==='"'?(a+='"',g++):l=false:a+=p;continue}p==='"'?(l=true,u=true):p===i?(o.push(a),a="",u=true):p===`
|
|
2
2
|
`||p==="\r"?(p==="\r"&&r[g+1]===`
|
|
3
|
-
`&&g++,o.push(a),s.push(o),o=[],a="",u=false):(a+=p,u=true);}return (u||a.length>0||o.length>0)&&(o.push(a),s.push(o)),n&&n(1),s}var A=new Set(["true","yes","evet","do\u011Fru","dogru"]),F=new Set(["false","no","hay\u0131r","hayir","yanl\u0131\u015F","yanlis"]);function
|
|
3
|
+
`&&g++,o.push(a),s.push(o),o=[],a="",u=false):(a+=p,u=true);}return (u||a.length>0||o.length>0)&&(o.push(a),s.push(o)),n&&n(1),s}var A=new Set(["true","yes","evet","do\u011Fru","dogru"]),F=new Set(["false","no","hay\u0131r","hayir","yanl\u0131\u015F","yanlis"]);function z(e){let t=e.trim().toLowerCase();return A.has(t)||F.has(t)}function Y(e){if(typeof e=="boolean")return e;let t=String(e).trim().toLowerCase();return A.has(t)||t==="1"||t==="y"||t==="on"?true:F.has(t)||t==="0"||t==="n"||t==="off"?false:null}function K(e){return /^0\d+$/.test(e)}var H=/[₺$€£¥]/g,Z=/[\s ]/g;function _(e){if(typeof e=="number")return isNaN(e)?null:e;let t=String(e).trim();if(!t)return null;t=t.replace(Z,"").replace(H,"");let n=false;t.endsWith("%")&&(n=true,t=t.slice(0,-1));let r=false;if(/^\(.*\)$/.test(t)&&(r=true,t=t.slice(1,-1)),!/^[+-]?[0-9.,]*[0-9][0-9.,]*$/.test(t))return null;let i=t.includes("."),s=t.includes(",");if(i&&s)t.lastIndexOf(",")>t.lastIndexOf(".")?t=t.replace(/\./g,"").replace(",","."):t=t.replace(/,/g,"");else if(s){let o=t.split(",");o.length===2&&o[1].length!==3?t=t.replace(",","."):t=t.replace(/,/g,"");}else i&&t.split(".").length>2&&(t=t.replace(/\./g,""));let a=Number(t);return isNaN(a)?null:(r&&(a=-a),n&&(a=a/100),a)}var U=/^\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:?\d{2})?)?$/,V=/^(\d{4})[/.](\d{1,2})[/.](\d{1,2})$/,Q=/^(\d{1,2})[/.\-](\d{1,2})[/.\-](\d{4})$/;function D(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;let t=String(e).trim();if(!t)return null;if(U.test(t)){let i=new Date(t.replace(" ","T"));return isNaN(i.getTime())?null:i}let n=V.exec(t);if(n){let i=new Date(+n[1],+n[2]-1,+n[3]);return C(i,+n[1],+n[2],+n[3])?i:null}let r=Q.exec(t);if(r){let i=+r[1],s=+r[2],a=+r[3],o,l;i>12&&s<=12?(o=i,l=s):s>12&&i<=12?(o=s,l=i):(o=i,l=s);let u=new Date(a,l-1,o);return C(u,a,l,o)?u:null}return null}function C(e,t,n,r){return !isNaN(e.getTime())&&e.getFullYear()===t&&e.getMonth()===n-1&&e.getDate()===r}function G(e){if(e==null||e==="")return "blank";if(typeof e=="boolean")return "boolean";if(typeof e=="number")return isNaN(e)?"blank":"number";if(e instanceof Date)return isNaN(e.getTime())?"blank":"date";let t=String(e).trim();return t===""?"blank":z(t)?"boolean":K(t)?"string":D(t)?"date":_(t)!==null?"number":"string"}function x(e){let t={string:0,number:0,date:0,boolean:0};for(let i of e){let s=G(i);s!=="blank"&&t[s]++;}let n="string",r=0;return Object.keys(t).forEach(i=>{t[i]>r&&(r=t[i],n=i);}),n}function v(e,t){if(e==null||e==="")return null;switch(t){case "number":return _(e);case "date":return D(e)??(e instanceof Date?e:null);case "boolean":return Y(e);default:return e}}var E=new Set(["__proto__","constructor","prototype"]);function y(e){return E.has(e)?`${e}_`:e}function M(e){let t=false;for(let n of e)if(!(!n||typeof n!="object")){for(let r of Object.keys(n))if(E.has(r)){t=true;break}if(t)break}return t?e.map(n=>{if(!n||typeof n!="object")return n;let r={};for(let i of Object.keys(n))r[y(i)]=n[i];return r}):e}var O=200,I=2e4;function q(e){let t=new Map;return e.map(n=>{let r=t.get(n)??0;return t.set(n,r+1),y(r===0?n:`${n}_${r+1}`)})}function P(e,t){if(e.length===0)return [];let n=[],r=new Set,i=Math.min(e.length,500);for(let o=0;o<i;o++){let l=e[o];if(!(!l||typeof l!="object"))for(let u of Object.keys(l))r.has(u)||(r.add(u),n.push(u));}let s=new Map;for(let o of n){let l=[];for(let u=0;u<e.length&&l.length<O;u++){let c=e[u]?.[o];c!=null&&String(c).trim()!==""&&l.push(c);}s.set(o,x(l));}let a=new Array(e.length);for(let o=0;o<e.length;o++){let l=e[o]||{},u={};for(let c of n){let d=l[c];u[y(c)]=d==null||d===""?null:v(d,s.get(c));}a[o]=u;}return a}function $(e,t){let n=T(e);if(!n.trim())return [];let r=N(n),i=X(n,r,t?c=>t({phase:"parsing",percent:Math.round(c*60)}):void 0);if(i.length===0)return [];let s=0;for(;s<i.length&&i[s].every(c=>c.trim()==="");)s++;if(s>=i.length)return [];let a=q(i[s].map((c,d)=>c.trim()||`Column${d+1}`)),o=i.slice(s+1).filter(c=>!(c.length===1&&c[0].trim()==="")),l=a.map((c,d)=>{let f=[];for(let g=0;g<o.length&&f.length<O;g++){let p=o[g][d];p!==void 0&&p.trim()!==""&&f.push(p);}return x(f)}),u=new Array(o.length);for(let c=0;c<o.length;c++){let d=o[c],f={};for(let g=0;g<a.length;g++){let p=d[g];f[a[g]]=p===void 0||p===""?null:v(p,l[g]);}u[c]=f,t&&c>0&&c%I===0&&t({phase:"typing",percent:60+Math.round(c/o.length*40)});}return t&&t({phase:"typing",percent:100}),u}var b=class e{supports(t){return t.name.split(".").pop()?.toLowerCase()==="xml"||t.type==="application/xml"||t.type==="text/xml"}async read(t){let n=await S(t);return e.parse(n)}static parse(t){if(!t||!t.trim())return [];let n=J(t),i=et(n).map(nt).filter(s=>Object.keys(s).length>0);return P(i)}};function J(e){let t={tag:"#root",attrs:{},children:[],text:"",parent:null},n=t,r=0,i=e.length;for(;r<i;){let s=e.indexOf("<",r);if(s===-1){n.text+=e.slice(r);break}if(s>r&&(n.text+=e.slice(r,s)),e.startsWith("<!--",s)){let f=e.indexOf("-->",s+4);r=f===-1?i:f+3;continue}if(e.startsWith("<![CDATA[",s)){let f=e.indexOf("]]>",s+9);n.text+=e.slice(s+9,f===-1?i:f),r=f===-1?i:f+3;continue}if(e.startsWith("<?",s)){let f=e.indexOf("?>",s+2);r=f===-1?i:f+2;continue}if(e.startsWith("<!",s)){let f=e.indexOf(">",s+2);r=f===-1?i:f+1;continue}let a=e.indexOf(">",s+1);if(a===-1)break;let o=e.slice(s+1,a).trim();if(o.startsWith("/")){let f=o.slice(1).trim(),g=n;for(;g&&g.tag!==f;)g=g.parent;g&&g.parent&&(n=g.parent),r=a+1;continue}let l=o.endsWith("/");l&&(o=o.slice(0,-1).trim());let{name:u,attrs:c}=tt(o),d={tag:u,attrs:c,children:[],text:"",parent:n};n.children.push(d),l||(n=d),r=a+1;}return t}var j=/([^\s=/]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function tt(e){let t=e.search(/\s/),n=(t===-1?e:e.slice(0,t)).trim(),r={};if(t!==-1){let i=e.slice(t+1),s;for(j.lastIndex=0;(s=j.exec(i))!==null;)r[s[1]]=R(s[2]??s[3]??"");}return {name:n,attrs:r}}function et(e){let t=e.children[0];if(!t)return [];let n=t.children;return n.length===0?[]:n.some(i=>i.children.length>0||Object.keys(i.attrs).length>0)?n:[t]}function nt(e){let t={},n=new Map,r=(i,s)=>{let a=i||"value",o=n.get(a)??0;n.set(a,o+1),t[y(o===0?a:`${a}_${o+1}`)]=s;};for(let[i,s]of Object.entries(e.attrs))r(i,s);if(e.children.length===0){let i=e.text.trim();i&&r(e.tag,R(i));}else for(let i of e.children)r(i.tag,R(W(i).trim()));return t}function W(e){if(e.children.length===0)return e.text;let t=e.text;for(let n of e.children)t+=W(n);return t}var rt=/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,it={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:"\xA0"};function R(e){return e.indexOf("&")===-1?e:e.replace(rt,(t,n)=>{if(n[0]==="#"){let r=n[1]==="x"||n[1]==="X"?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return Number.isFinite(r)?String.fromCodePoint(r):t}return it[n]??t})}var h=class{static extractFieldsFromData(t,n=50){if(!t||t.length===0)return [];let r=[],i=Math.max(n,50),s=this.collectKeys(t,i),a=false,o=false;return s.forEach(l=>{let u=this.inferType(t,l,n),c="chooser";!a&&this.isAutoRowCandidate(t,l,u,i)?(c="row",a=true):!o&&this.isAutoDataCandidate(l,u)&&(c="data",o=true);let d={id:`f_${l}`,dataField:l,caption:this.formatCaption(l),dataType:u,area:c,areaIndex:0};u==="number"?d.summaryType="sum":u==="date"&&(d.groupInterval="month"),r.push(d);}),r}static buildFieldsFromPlan(t,n,r=50){let i=[],s=false,a=false,o=Math.max(r,50);for(let l of t){let u="chooser";!s&&this.isAutoRowCandidate(n,l.dataField,l.dataType,o)?(u="row",s=true):!a&&this.isAutoDataCandidate(l.dataField,l.dataType)&&(u="data",a=true);let c={id:`f_${l.dataField}`,dataField:l.dataField,caption:l.caption,dataType:l.dataType,area:u,areaIndex:0};l.dataType==="number"?c.summaryType="sum":l.dataType==="date"&&(c.groupInterval="month"),i.push(c);}return i}static isAutoRowCandidate(t,n,r,i){return !(n.startsWith("__EMPTY")||r!=="string"&&r!=="date"||this.isIdentifierLikeKey(n)||r==="string"&&t&&this.isHighCardinalityStringColumn(t,n,i))}static isAutoDataCandidate(t,n){return n==="number"&&!t.startsWith("__EMPTY")&&!this.isIdentifierLikeKey(t)}static isHighCardinalityStringColumn(t,n,r){let i=Math.min(t.length,r),s=new Set,a=0;for(let o=0;o<i;o++){let l=t[o]?.[n];l==null||l===""||(a++,s.add(String(l)));}return a<20?false:s.size/a>=.9}static isIdentifierLikeKey(t){let n=t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase(),r=n.replace(/[^a-z0-9]/g,"");return r==="id"||r==="uuid"||r==="guid"||r==="key"?true:/(^|[\s_.-])(id|uuid|guid|key)($|[\s_.-])/.test(n)}static collectKeys(t,n){let r=[],i=new Set,s=Math.min(t.length,n);for(let a=0;a<s;a++){let o=t[a];if(!(!o||typeof o!="object"))for(let l of Object.keys(o))i.has(l)||(i.add(l),r.push(l));}return r}static inferType(t,n,r){let i=Math.min(t.length,r),s=new Array(i);for(let a=0;a<i;a++)s[a]=t[a]?.[n];return x(s)}static formatCaption(t){return t.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/^./,n=>n.toUpperCase()).trim()}};var k=self;k.onmessage=async e=>{let t=e.data;if(!t||t.type!=="parse")return;let{jobId:n,kind:r,file:i}=t;try{if(r==="csv"){m(n,"reading",3);let s=await i.text(),a=$(s,l=>{m(n,l.phase,5+Math.round(l.percent*.92));});m(n,"finalizing",98);let o=h.extractFieldsFromData(a);w(n,{mode:"data",data:a,fields:o});return}if(r==="xml"){m(n,"reading",10);let s=await i.text();m(n,"parsing",50);let a=b.parse(s);m(n,"finalizing",90);let o=h.extractFieldsFromData(a);w(n,{mode:"data",data:a,fields:o});return}if(r==="json"){m(n,"reading",10);let s=await i.text();m(n,"parsing",45);let a=JSON.parse(s);if(Array.isArray(a)){m(n,"finalizing",90);let o=M(a),l=h.extractFieldsFromData(o);w(n,{mode:"data",data:o,fields:l});}else w(n,{mode:"raw",value:a});return}L(n,`Desteklenmeyen i\xE7e aktarma t\xFCr\xFC: ${String(r)}`);}catch(s){L(n,s instanceof Error?s.message:String(s));}};function m(e,t,n){k.postMessage({type:"progress",jobId:e,phase:t,percent:n});}function w(e,t){k.postMessage({type:"done",jobId:e,payload:t});}function L(e,t){k.postMessage({type:"error",jobId:e,message:t});}
|