@ingestro/importer-react 4.11.0 → 4.11.1

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.
@@ -1 +1 @@
1
- import{e as K,f as p,p as N}from"./chunk-L5AEQQSP.js";import{a as ee,b as l,c as M,d as _,h as te,i as L,j as R,l as G,m as Y,n as w}from"./chunk-U5BU7B27.js";import{b as q,c as Q,d as h,e as J}from"./chunk-3A4DOV33.js";import{isNil as Oe}from"lodash";var oe=o=>o.some(e=>typeof e=="string"&&l(e)&&!h(e.trim())),D=o=>!oe(o)&&!o.some(e=>typeof e=="boolean"),T=o=>o.filter(e=>typeof e=="string"&&l(e)&&!h(e.trim())),he=(o,e)=>{let t=e?.trim();return t||(D(o),"")};var S=/T\d{1,2}:\d{2}(:\d{2})?(\.\d+)?/i,O=/\b\d{1,2}:\d{2}(:\d{2})?(\.\d+)?(\s*[AaPp][Mm])?\b/,De=/\s+\d{1,2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:\s*[AaPp][Mm])?(?:Z|[+-](?:[01]\d|2[0-3])(?::?[0-5]\d)?)?\s*$/i,v=/\b[AaPp][Mm]\b/,ge=/\d{1,2}:\d{2}:\d{2}\.(\d+)/;var k=o=>o.match(ge)?.[1]?.length??0,re=o=>o<=0||o>9?"":`.${"S".repeat(o)}`,V=o=>{let e=o.trim();return S.test(e)?e.split(/T/i)[0]??"":e.replace(De,"")};var Fe=/^\d{4}([/.\- ])\d{1,2}\1\d{1,2}$/,Me=/^\d{1,2}([/.\- ])\d{1,2}\1(?:\d{2}|\d{4})$/;var ae=o=>{let e=!1,t=!1;for(let r of o){if(typeof r!="string"||!l(r))continue;let a=V(r);if(Fe.test(a)){e=!0;continue}Me.test(a)&&(t=!0)}return{sawYearFirst:e,sawDayOrMonthFirst:t}},y=o=>{let{sawYearFirst:e,sawDayOrMonthFirst:t}=ae(o);return e&&!t},ne=o=>{let{sawYearFirst:e,sawDayOrMonthFirst:t}=ae(o);return e&&t};var U=o=>o?"D":"DD",z=o=>o?"M":"MM";var Se=o=>{let e=k(o),t=e>0||/\d{1,2}:\d{2}:\d{2}/.test(o),r=o.match(/(?:[T\s]|^)(\d{1,2}):\d{2}/i)?.[1]??"";return{isoT:S.test(o),seconds:t,fractionDigits:e,timezone:R(o),meridiem:v.test(o),unpaddedHour:r.length===1,paddedHour:r.length===2&&r.startsWith("0")}},ye=(o,e)=>o.isoT===e.isoT&&o.seconds===e.seconds&&o.fractionDigits===e.fractionDigits&&o.timezone===e.timezone&&o.meridiem===e.meridiem;var Ie=o=>{let e=[];for(let t of o){if(typeof t!="string"||!l(t))continue;let r=te(V(t));r&&(e.includes(r)||e.push(r))}return e},g=o=>{let e=!1,t=!1,r=null,a=!1,n=!1;for(let i of o){if(typeof i!="string"||!l(i))continue;let s=i.trim();if(!(S.test(s)||O.test(s))){if(e=!0,t)return!0;continue}if(t=!0,e)return!0;let d=Se(s);if(d.fractionDigits>9)return!0;if(d.unpaddedHour&&(a=!0),d.paddedHour&&(n=!0),!r){r=d;continue}if(!ye(r,d))return!0}return!!(a&&n)};var C=o=>{if(g(o))return"";let e=!1,t=!1,r=!1,a=!1,n=0,i=!1,s=!1;for(let F of o){if(typeof F!="string"||!l(F))continue;let f=F.trim(),Z=S.test(f);if(!Z&&!O.test(f))continue;e=!0,Z&&(t=!0),v.test(f)&&(r=!0);let j=k(f);j>0?(a=!0,n=j):/\d{1,2}:\d{2}:\d{2}/.test(f)&&(a=!0),R(f)&&(i=!0),(f.match(/(?:[T\s]|^)(\d{1,2}):\d{2}/i)?.[1]??"").length===1&&(s=!0)}if(!e)return"";let m=t?"[T]":" ",u=r?s?"h":"hh":s?"H":"HH",d=r?" A":"",c=re(n),b=i?"Z":"";return a?`${m}${u}:mm:ss${c}${d}${b}`:`${m}${u}:mm${d}${b}`},I=(o,e)=>{let t=o.trim();if(!t||/[Hh]/.test(t))return t;let r=C(e);return r?`${t}${r}`:t};var $=(o,e="",t={firstUnpadded:!1,secondUnpadded:!1})=>`YYYY${o}${z(t.firstUnpadded)}${o}${U(t.secondUnpadded)}${e}`,E=(o,e,t="",r="YYYY",a={firstUnpadded:!1,secondUnpadded:!1})=>`${o==="dM"?[U(a.firstUnpadded),z(a.secondUnpadded),r].join(e):[z(a.firstUnpadded),U(a.secondUnpadded),r].join(e)}${t}`,ie=(o,e="",t="YYYY",r={firstUnpadded:!1,secondUnpadded:!1})=>({dayFirst:E("dM",o,e,t,r),monthFirst:E("Md",o,e,t,r)}),se=["/","-","."],be=(o="",e="YYYY",t={firstUnpadded:!1,secondUnpadded:!1},r=se)=>{let a=[];for(let n of r){let{dayFirst:i,monthFirst:s}=ie(n,o,e,t);a.push(i,s)}return a};var Ve=o=>o.every(e=>typeof e!="number"&&(typeof e!="string"||!l(e))),x=({colType:o,inputFormat:e,samples:t,parserDateFormat:r})=>{if(!_(o))return null;if(M(e))return"configured";if(r?.trim())return"detected";if(D(t))return Ve(t)?"detected":"undetected";let a=T(t);return g(a)||ne(a)?"undetected":y(a)?"detected":Y(a)===null?"undetected":"detected"},Ce=o=>o.getDateFormatPromptResolved?.()??o.getDeclaredInputFormat?.(),X=o=>o.getDateFormatPromptResolved?.()??(typeof o.getDeclaredInputFormat=="function"?o.getDeclaredInputFormat():o.getInputFormat()),Ee=o=>o.some(e=>{let t=e.matchedDataModel?.dataModel;return!t||!e.sheetColumn?!1:x({colType:t.getType(),inputFormat:X(t),samples:e.sheetColumn.getDateInputFormatSamples(),parserDateFormat:e.sheetColumn.getParserDateFormat?.()})==="undetected"});var H={firstUnpadded:!1,secondUnpadded:!1},me=({colType:o,inputFormat:e,samples:t,parserDateFormat:r})=>{let a=x({colType:o,inputFormat:e,samples:t,parserDateFormat:r}),n=T(t);if(a==="configured")return I((e??"").trim(),n);if(a!=="detected")return"";let i=r?.trim();if(i)return i;let s=C(n),m=L(n);if(y(n))return $(m,s,H);let u=Y(n);return u!=="dM"&&u!=="Md"?"":E(u,m,s,"YYYY",H)},xe=(o,e)=>{o.forEach(t=>{let r=t.matchedDataModel?.dataModel;if(!r?.setInputFormat||!t.sheetColumn)return;let a=r.getType(),n=X(r),i=t.sheetColumn.getDateInputFormatSamples(),s=t.sheetColumn.getParserDateFormat?.(),m=T(i),u=x({colType:a,inputFormat:n,samples:i,parserDateFormat:s});if(!u)return;let d=e?.getChosenFormat?.(t)?.trim()||"",c=d||me({colType:a,inputFormat:n,samples:i,parserDateFormat:s});if(!c&&u==="undetected"&&e?.fallbackUndetected&&!D(i)&&!g(m)){let b=L(m),F=C(m);c=y(m)?$(b,F,H):E("dM",b,F,"YYYY",H)}!d&&!M(n)&&D(i)&&!c||c&&r.setInputFormat(I(c,m))})};var Pe=o=>{if(o==null)return"";if(typeof o=="object"&&!Array.isArray(o)&&"value"in o){let e=o.value;return typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:""}return typeof o=="string"||typeof o=="number"||typeof o=="boolean"?o:""},Ae=(o,e)=>o.map(t=>({sheetColumn:{getDateInputFormatSamples:()=>e.map(r=>Pe(r?.[t.getKey()]))},matchedDataModel:{dataModel:t}}));import le from"moment";var _e=5,de=o=>{let e=le(o,q,!0);if(e.isValid())return e;let t=le.parseZone(o,Q,!0);return t.isValid()?t:null},Re=(o,e)=>{if(!l(o))return null;let t=w([o],e)[0];if(typeof t!="string")return null;if(t===o||t===o.trim()){if(!h(t.trim()))return null;let a=de(t.trim());return a?{original:o,parsedMoment:a}:null}let r=de(t);return r?{original:o,parsedMoment:r}:null},Ye=({serial:o,outputFormat:e,textFormatted:t})=>o!=null&&e?J(o).format(e):t??void 0,we=({samples:o,inputFormat:e,outputFormat:t,maxRows:r=_e})=>o.filter(n=>l(n)).slice(0,r).map(n=>{let i=Re(n,e);return i?{original:n,formatted:i.parsedMoment.format(t)}:{original:n,formatted:null}});var ue=(o,e)=>{if(!_(e.getType()))return p.parse(o,{dataModel:e});if(ee(o))return null;let t=`${o}`,r=e.getInputFormat();if(M(r)){if(h(t))return p.parse(t,{dataModel:e});let a=r;if(!G(t,a)){let n=I(a,[t]);if(n!==a&&G(t,n))a=n;else return t}return p.parse(w([t],a)[0],{dataModel:e})}return p.parse(t,{dataModel:e})};var W=class{constructor({sheetColumn:e,matchedDataModel:t,detectedNumberFormats:r}){this.parseSheetValue=(e,t)=>t.dataModel.getType()==="date"?ue(e,t.dataModel):p.parse(e,t);this.getOptionValue=(e,t)=>{if(!t)if(this.matchedDataModel.dataModel){let r=this.sheetColumn.columnKey,n=this.detectedNumberFormats.columns.find(i=>i.column===r)?.numberFormat||this.detectedNumberFormats.global;return this.parseSheetValue(e,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0,numberFormat:n})}else return e;for(let r=0;r<t.length;r++)if(`${t[r]?.sheetOption}`==`${e}`){let a=!Oe(t[r]?.dataModelOptions)&&(t[r]?.dataModelOptions?.length??0)>0;if(t[r]?.autoPreserved===!0&&t[r]?.dataModelOption==null&&!a){if(this.matchedDataModel.dataModel instanceof N){let n=`${e}`,i=this.matchedDataModel.dataModel.getOptions().find(s=>s.label===n||s.value===n);if(i)return p.parse(i.value,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0})}return e}return this.matchedDataModel.dataModel&&this.matchedDataModel.dataModel.getIsMultiSelection()?p.parse(t[r]?.dataModelOptions,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0}):this.matchedDataModel.dataModel?p.parse(t[r]?.dataModelOption,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0}):t[r]?.dataModelOption}};this.getValues=()=>{let e=this.sheetColumn.rows,t=[];for(let r=0;r<e.length;r++){let a=e[r],n=this.getOptionValue(a,this.matchedOptions);t.push(n)}return t};if(this.sheetColumn=e,this.matchedDataModel=t,this.matchedOptions=void 0,this.detectedNumberFormats=r||{global:"eu",columns:[]},this.matchedDataModel.matchedOptions){this.matchedOptions=[];for(let a=0;a<(this.matchedDataModel.matchedOptions?.length??0);a++){let n=this.matchedDataModel.matchedOptions[a];this.matchedDataModel.dataModel?.getIsMultiSelection()?n.dataModelOptions&&this.matchedOptions.push(n):n.dataModelOption!==void 0&&n.dataModelOption!==null?this.matchedOptions.push(n):n.autoPreserved===!0&&!n.userCleared&&this.matchedOptions.push(n)}}}},pe=W;var B=class{constructor(e){this.matchedColumns=[];this.parseValues=()=>{let e=[];this.matchedColumns.forEach(t=>{let r=t.matchedDataModel,n=new pe({sheetColumn:t.sheetColumn,matchedDataModel:r,detectedNumberFormats:this.detectedNumberFormats}).getValues(),i=r.dataModel.getKey();n.forEach((s,m)=>{e[m]?e[m][i]=s:e[m]={[i]:s}})});for(let t=0;t<e.length;++t)for(let r=0;r<this.columns.length;++r){let n=this.columns[r].key;e[t][n]===void 0&&(e[t][n]=null)}return e};this.getValues=()=>(this.matchedColumns=[],this.matching.filter(t=>t.matchedDataModel?.dataModel).forEach(t=>{this.matchedColumns.push({sheetColumn:t.sheetColumn,matchedDataModel:t.matchedDataModel})}),this.parseValues());let{matching:t,detectedNumberFormats:r}=e;this.matching=t,this.detectedNumberFormats=r||{global:"eu",columns:[]},this.columns=e.columns??[]}},ce=B;var ho=({matching:o,detectedNumberFormats:e,columns:t})=>new ce({matching:o,detectedNumberFormats:e,columns:t}).getValues();import*as fe from"comlink";var P=class{static{this.serialize=e=>e.serialize()}static{this.deSerialize=e=>K.isTypeCategory(e.type)?new N({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,options:e.options,validators:[],alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,isMultiSelection:e.isMultiSelection??!1,allowCustomOptions:e.allowCustomOptions,allowedCustomOptionTypes:e.allowedCustomOptionTypes,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration}):new K({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,validators:[],alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,outputFormat:e.outputFormat,inputFormat:e.inputFormat,numberFormat:e.numberFormat,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration})}};var A=class{static{this.serialize=e=>{let t={matching:[],detectedNumberFormats:e.detectedNumberFormats,columns:e.columns};return t.matching=e.matching.map(r=>({sheetColumn:r.sheetColumn,matchedDataModel:r.matchedDataModel?{dataModel:r.matchedDataModel.dataModel?P.serialize(r.matchedDataModel.dataModel):r.matchedDataModel.dataModel,matchedOptions:r.matchedDataModel.matchedOptions}:r.matchedDataModel})),[t,[]]}}static{this.deserialize=e=>({matching:e.matching.map(t=>({sheetColumn:t.sheetColumn,matchedDataModel:t.matchedDataModel?{dataModel:t.matchedDataModel.dataModel?P.deSerialize(t.matchedDataModel.dataModel):t.matchedDataModel.dataModel,matchedOptions:t.matchedDataModel.matchedOptions}:t.matchedDataModel})),detectedNumberFormats:e.detectedNumberFormats,columns:e.columns})}};fe.transferHandlers.set("Matching",{canHandle:o=>!!(o!==null&&typeof o=="object"&&o.matching),serialize:o=>A.serialize(o),deserialize:o=>A.deserialize(o)});export{T as a,he as b,y as c,Ie as d,g as e,C as f,$ as g,ie as h,se as i,be as j,x as k,Ce as l,Ee as m,me as n,xe as o,Ae as p,Ye as q,we as r,ho as s,P as t};
1
+ import{e as K,f as p,p as N}from"./chunk-BOX4EJAD.js";import{a as ee,b as l,c as M,d as _,h as te,i as L,j as R,l as G,m as Y,n as w}from"./chunk-J6ZA6O45.js";import{b as q,c as Q,d as h,e as J}from"./chunk-DNCQE4OX.js";import{isNil as Oe}from"lodash";var oe=o=>o.some(e=>typeof e=="string"&&l(e)&&!h(e.trim())),D=o=>!oe(o)&&!o.some(e=>typeof e=="boolean"),T=o=>o.filter(e=>typeof e=="string"&&l(e)&&!h(e.trim())),he=(o,e)=>{let t=e?.trim();return t||(D(o),"")};var S=/T\d{1,2}:\d{2}(:\d{2})?(\.\d+)?/i,O=/\b\d{1,2}:\d{2}(:\d{2})?(\.\d+)?(\s*[AaPp][Mm])?\b/,De=/\s+\d{1,2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:\s*[AaPp][Mm])?(?:Z|[+-](?:[01]\d|2[0-3])(?::?[0-5]\d)?)?\s*$/i,v=/\b[AaPp][Mm]\b/,ge=/\d{1,2}:\d{2}:\d{2}\.(\d+)/;var k=o=>o.match(ge)?.[1]?.length??0,re=o=>o<=0||o>9?"":`.${"S".repeat(o)}`,V=o=>{let e=o.trim();return S.test(e)?e.split(/T/i)[0]??"":e.replace(De,"")};var Fe=/^\d{4}([/.\- ])\d{1,2}\1\d{1,2}$/,Me=/^\d{1,2}([/.\- ])\d{1,2}\1(?:\d{2}|\d{4})$/;var ae=o=>{let e=!1,t=!1;for(let r of o){if(typeof r!="string"||!l(r))continue;let a=V(r);if(Fe.test(a)){e=!0;continue}Me.test(a)&&(t=!0)}return{sawYearFirst:e,sawDayOrMonthFirst:t}},y=o=>{let{sawYearFirst:e,sawDayOrMonthFirst:t}=ae(o);return e&&!t},ne=o=>{let{sawYearFirst:e,sawDayOrMonthFirst:t}=ae(o);return e&&t};var U=o=>o?"D":"DD",z=o=>o?"M":"MM";var Se=o=>{let e=k(o),t=e>0||/\d{1,2}:\d{2}:\d{2}/.test(o),r=o.match(/(?:[T\s]|^)(\d{1,2}):\d{2}/i)?.[1]??"";return{isoT:S.test(o),seconds:t,fractionDigits:e,timezone:R(o),meridiem:v.test(o),unpaddedHour:r.length===1,paddedHour:r.length===2&&r.startsWith("0")}},ye=(o,e)=>o.isoT===e.isoT&&o.seconds===e.seconds&&o.fractionDigits===e.fractionDigits&&o.timezone===e.timezone&&o.meridiem===e.meridiem;var Ie=o=>{let e=[];for(let t of o){if(typeof t!="string"||!l(t))continue;let r=te(V(t));r&&(e.includes(r)||e.push(r))}return e},g=o=>{let e=!1,t=!1,r=null,a=!1,n=!1;for(let i of o){if(typeof i!="string"||!l(i))continue;let s=i.trim();if(!(S.test(s)||O.test(s))){if(e=!0,t)return!0;continue}if(t=!0,e)return!0;let d=Se(s);if(d.fractionDigits>9)return!0;if(d.unpaddedHour&&(a=!0),d.paddedHour&&(n=!0),!r){r=d;continue}if(!ye(r,d))return!0}return!!(a&&n)};var C=o=>{if(g(o))return"";let e=!1,t=!1,r=!1,a=!1,n=0,i=!1,s=!1;for(let F of o){if(typeof F!="string"||!l(F))continue;let f=F.trim(),Z=S.test(f);if(!Z&&!O.test(f))continue;e=!0,Z&&(t=!0),v.test(f)&&(r=!0);let j=k(f);j>0?(a=!0,n=j):/\d{1,2}:\d{2}:\d{2}/.test(f)&&(a=!0),R(f)&&(i=!0),(f.match(/(?:[T\s]|^)(\d{1,2}):\d{2}/i)?.[1]??"").length===1&&(s=!0)}if(!e)return"";let m=t?"[T]":" ",u=r?s?"h":"hh":s?"H":"HH",d=r?" A":"",c=re(n),b=i?"Z":"";return a?`${m}${u}:mm:ss${c}${d}${b}`:`${m}${u}:mm${d}${b}`},I=(o,e)=>{let t=o.trim();if(!t||/[Hh]/.test(t))return t;let r=C(e);return r?`${t}${r}`:t};var $=(o,e="",t={firstUnpadded:!1,secondUnpadded:!1})=>`YYYY${o}${z(t.firstUnpadded)}${o}${U(t.secondUnpadded)}${e}`,E=(o,e,t="",r="YYYY",a={firstUnpadded:!1,secondUnpadded:!1})=>`${o==="dM"?[U(a.firstUnpadded),z(a.secondUnpadded),r].join(e):[z(a.firstUnpadded),U(a.secondUnpadded),r].join(e)}${t}`,ie=(o,e="",t="YYYY",r={firstUnpadded:!1,secondUnpadded:!1})=>({dayFirst:E("dM",o,e,t,r),monthFirst:E("Md",o,e,t,r)}),se=["/","-","."],be=(o="",e="YYYY",t={firstUnpadded:!1,secondUnpadded:!1},r=se)=>{let a=[];for(let n of r){let{dayFirst:i,monthFirst:s}=ie(n,o,e,t);a.push(i,s)}return a};var Ve=o=>o.every(e=>typeof e!="number"&&(typeof e!="string"||!l(e))),x=({colType:o,inputFormat:e,samples:t,parserDateFormat:r})=>{if(!_(o))return null;if(M(e))return"configured";if(r?.trim())return"detected";if(D(t))return Ve(t)?"detected":"undetected";let a=T(t);return g(a)||ne(a)?"undetected":y(a)?"detected":Y(a)===null?"undetected":"detected"},Ce=o=>o.getDateFormatPromptResolved?.()??o.getDeclaredInputFormat?.(),X=o=>o.getDateFormatPromptResolved?.()??(typeof o.getDeclaredInputFormat=="function"?o.getDeclaredInputFormat():o.getInputFormat()),Ee=o=>o.some(e=>{let t=e.matchedDataModel?.dataModel;return!t||!e.sheetColumn?!1:x({colType:t.getType(),inputFormat:X(t),samples:e.sheetColumn.getDateInputFormatSamples(),parserDateFormat:e.sheetColumn.getParserDateFormat?.()})==="undetected"});var H={firstUnpadded:!1,secondUnpadded:!1},me=({colType:o,inputFormat:e,samples:t,parserDateFormat:r})=>{let a=x({colType:o,inputFormat:e,samples:t,parserDateFormat:r}),n=T(t);if(a==="configured")return I((e??"").trim(),n);if(a!=="detected")return"";let i=r?.trim();if(i)return i;let s=C(n),m=L(n);if(y(n))return $(m,s,H);let u=Y(n);return u!=="dM"&&u!=="Md"?"":E(u,m,s,"YYYY",H)},xe=(o,e)=>{o.forEach(t=>{let r=t.matchedDataModel?.dataModel;if(!r?.setInputFormat||!t.sheetColumn)return;let a=r.getType(),n=X(r),i=t.sheetColumn.getDateInputFormatSamples(),s=t.sheetColumn.getParserDateFormat?.(),m=T(i),u=x({colType:a,inputFormat:n,samples:i,parserDateFormat:s});if(!u)return;let d=e?.getChosenFormat?.(t)?.trim()||"",c=d||me({colType:a,inputFormat:n,samples:i,parserDateFormat:s});if(!c&&u==="undetected"&&e?.fallbackUndetected&&!D(i)&&!g(m)){let b=L(m),F=C(m);c=y(m)?$(b,F,H):E("dM",b,F,"YYYY",H)}!d&&!M(n)&&D(i)&&!c||c&&r.setInputFormat(I(c,m))})};var Pe=o=>{if(o==null)return"";if(typeof o=="object"&&!Array.isArray(o)&&"value"in o){let e=o.value;return typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:""}return typeof o=="string"||typeof o=="number"||typeof o=="boolean"?o:""},Ae=(o,e)=>o.map(t=>({sheetColumn:{getDateInputFormatSamples:()=>e.map(r=>Pe(r?.[t.getKey()]))},matchedDataModel:{dataModel:t}}));import le from"moment";var _e=5,de=o=>{let e=le(o,q,!0);if(e.isValid())return e;let t=le.parseZone(o,Q,!0);return t.isValid()?t:null},Re=(o,e)=>{if(!l(o))return null;let t=w([o],e)[0];if(typeof t!="string")return null;if(t===o||t===o.trim()){if(!h(t.trim()))return null;let a=de(t.trim());return a?{original:o,parsedMoment:a}:null}let r=de(t);return r?{original:o,parsedMoment:r}:null},Ye=({serial:o,outputFormat:e,textFormatted:t})=>o!=null&&e?J(o).format(e):t??void 0,we=({samples:o,inputFormat:e,outputFormat:t,maxRows:r=_e})=>o.filter(n=>l(n)).slice(0,r).map(n=>{let i=Re(n,e);return i?{original:n,formatted:i.parsedMoment.format(t)}:{original:n,formatted:null}});var ue=(o,e)=>{if(!_(e.getType()))return p.parse(o,{dataModel:e});if(ee(o))return null;let t=`${o}`,r=e.getInputFormat();if(M(r)){if(h(t))return p.parse(t,{dataModel:e});let a=r;if(!G(t,a)){let n=I(a,[t]);if(n!==a&&G(t,n))a=n;else return t}return p.parse(w([t],a)[0],{dataModel:e})}return p.parse(t,{dataModel:e})};var W=class{constructor({sheetColumn:e,matchedDataModel:t,detectedNumberFormats:r}){this.parseSheetValue=(e,t)=>t.dataModel.getType()==="date"?ue(e,t.dataModel):p.parse(e,t);this.getOptionValue=(e,t)=>{if(!t)if(this.matchedDataModel.dataModel){let r=this.sheetColumn.columnKey,n=this.detectedNumberFormats.columns.find(i=>i.column===r)?.numberFormat||this.detectedNumberFormats.global;return this.parseSheetValue(e,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0,numberFormat:n})}else return e;for(let r=0;r<t.length;r++)if(`${t[r]?.sheetOption}`==`${e}`){let a=!Oe(t[r]?.dataModelOptions)&&(t[r]?.dataModelOptions?.length??0)>0;if(t[r]?.autoPreserved===!0&&t[r]?.dataModelOption==null&&!a){if(this.matchedDataModel.dataModel instanceof N){let n=`${e}`,i=this.matchedDataModel.dataModel.getOptions().find(s=>s.label===n||s.value===n);if(i)return p.parse(i.value,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0})}return e}return this.matchedDataModel.dataModel&&this.matchedDataModel.dataModel.getIsMultiSelection()?p.parse(t[r]?.dataModelOptions,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0}):this.matchedDataModel.dataModel?p.parse(t[r]?.dataModelOption,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0}):t[r]?.dataModelOption}};this.getValues=()=>{let e=this.sheetColumn.rows,t=[];for(let r=0;r<e.length;r++){let a=e[r],n=this.getOptionValue(a,this.matchedOptions);t.push(n)}return t};if(this.sheetColumn=e,this.matchedDataModel=t,this.matchedOptions=void 0,this.detectedNumberFormats=r||{global:"eu",columns:[]},this.matchedDataModel.matchedOptions){this.matchedOptions=[];for(let a=0;a<(this.matchedDataModel.matchedOptions?.length??0);a++){let n=this.matchedDataModel.matchedOptions[a];this.matchedDataModel.dataModel?.getIsMultiSelection()?n.dataModelOptions&&this.matchedOptions.push(n):n.dataModelOption!==void 0&&n.dataModelOption!==null?this.matchedOptions.push(n):n.autoPreserved===!0&&!n.userCleared&&this.matchedOptions.push(n)}}}},pe=W;var B=class{constructor(e){this.matchedColumns=[];this.parseValues=()=>{let e=[];this.matchedColumns.forEach(t=>{let r=t.matchedDataModel,n=new pe({sheetColumn:t.sheetColumn,matchedDataModel:r,detectedNumberFormats:this.detectedNumberFormats}).getValues(),i=r.dataModel.getKey();n.forEach((s,m)=>{e[m]?e[m][i]=s:e[m]={[i]:s}})});for(let t=0;t<e.length;++t)for(let r=0;r<this.columns.length;++r){let n=this.columns[r].key;e[t][n]===void 0&&(e[t][n]=null)}return e};this.getValues=()=>(this.matchedColumns=[],this.matching.filter(t=>t.matchedDataModel?.dataModel).forEach(t=>{this.matchedColumns.push({sheetColumn:t.sheetColumn,matchedDataModel:t.matchedDataModel})}),this.parseValues());let{matching:t,detectedNumberFormats:r}=e;this.matching=t,this.detectedNumberFormats=r||{global:"eu",columns:[]},this.columns=e.columns??[]}},ce=B;var ho=({matching:o,detectedNumberFormats:e,columns:t})=>new ce({matching:o,detectedNumberFormats:e,columns:t}).getValues();import*as fe from"comlink";var P=class{static{this.serialize=e=>e.serialize()}static{this.deSerialize=e=>K.isTypeCategory(e.type)?new N({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,options:e.options,validators:[],alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,isMultiSelection:e.isMultiSelection??!1,allowCustomOptions:e.allowCustomOptions,allowedCustomOptionTypes:e.allowedCustomOptionTypes,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration}):new K({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,validators:[],alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,outputFormat:e.outputFormat,inputFormat:e.inputFormat,numberFormat:e.numberFormat,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration})}};var A=class{static{this.serialize=e=>{let t={matching:[],detectedNumberFormats:e.detectedNumberFormats,columns:e.columns};return t.matching=e.matching.map(r=>({sheetColumn:r.sheetColumn,matchedDataModel:r.matchedDataModel?{dataModel:r.matchedDataModel.dataModel?P.serialize(r.matchedDataModel.dataModel):r.matchedDataModel.dataModel,matchedOptions:r.matchedDataModel.matchedOptions}:r.matchedDataModel})),[t,[]]}}static{this.deserialize=e=>({matching:e.matching.map(t=>({sheetColumn:t.sheetColumn,matchedDataModel:t.matchedDataModel?{dataModel:t.matchedDataModel.dataModel?P.deSerialize(t.matchedDataModel.dataModel):t.matchedDataModel.dataModel,matchedOptions:t.matchedDataModel.matchedOptions}:t.matchedDataModel})),detectedNumberFormats:e.detectedNumberFormats,columns:e.columns})}};fe.transferHandlers.set("Matching",{canHandle:o=>!!(o!==null&&typeof o=="object"&&o.matching),serialize:o=>A.serialize(o),deserialize:o=>A.deserialize(o)});export{T as a,he as b,y as c,Ie as d,g as e,C as f,$ as g,ie as h,se as i,be as j,x as k,Ce as l,Ee as m,me as n,xe as o,Ae as p,Ye as q,we as r,ho as s,P as t};
@@ -1 +1 @@
1
- import{b as oe,c as g,l as h,n as F}from"./chunk-U5BU7B27.js";import{a as l,d as I,f as b}from"./chunk-KNOWDPDH.js";import{a as G,b as q}from"./chunk-JWTYPSUX.js";import{a as Z,b as J,c as j,d as ee,g as te,h as re,j as ie}from"./chunk-3A4DOV33.js";import{a as d}from"./chunk-EWEVS5OB.js";import{a as Q}from"./chunk-J5WOZVPO.js";var _=class{constructor({validation:e,regex:t,fields:i,errorMessage:o,operator:n,value:s}){this.getValidation=()=>this.validation;this.getRegex=()=>this.regex;this.getFields=()=>this.fields;this.getErrorMessage=()=>this.errorMessage;this.getOperator=()=>this.operator;this.getValue=()=>this.value;this.serialize=()=>({validation:this.getValidation(),fields:this.getFields(),regex:this.getRegex(),errorMessage:this.getErrorMessage(),operator:this.getOperator(),value:this.getValue()});this.validation=e,this.regex=t,this.fields=i??[],this.errorMessage=o,this.operator=n,this.value=s}},Rt=_;var f=class r{constructor({description:e,key:t,example:i,label:o,type:n,validators:s,mappingValidation:a,alternativeMatches:p,columnSize:u,creator:m,baseKey:y,baseKeyCounter:T,outputFormat:M,inputFormat:E,numberFormat:C,hidden:x,disabled:S,optionMappingConfiguration:O,columnWidth:P,excludeFromAutoMatching:R}){this.getDescription=()=>this.description;this.getKey=()=>this.key;this.getExample=()=>this.example;this.getLabel=()=>this.label;this.setLabel=e=>{this.label=e};this.getType=()=>this.type;this.getOutputFormat=()=>r.getOutputFormat(this.outputFormat);this.getInputFormat=()=>this.inputFormat;this.getDeclaredInputFormat=()=>this.declaredInputFormat;this.setInputFormat=e=>{this.inputFormat=e};this.dateFormatPromptResolved=null;this.setDateFormatPromptResolved=e=>{this.dateFormatPromptResolved=e};this.getDateFormatPromptResolved=()=>this.dateFormatPromptResolved;this.resetSessionInputFormat=()=>{this.inputFormat=this.declaredInputFormat,this.dateFormatPromptResolved=null};this.getValidators=()=>this.validators;this.getColumnSize=()=>this.columnSize;this.getColumnWidth=()=>this.columnWidth;this.getIsRequired=()=>!!this.validators.find(t=>t.getValidation()==="REQUIRED");this.getIsUnique=()=>!!this.validators.find(t=>t.getValidation()==="UNIQUE");this.getIsUniqueAndRequired=()=>this.getIsRequired()===!0&&this.getIsUnique()===!0;this.hasMappingValidation=()=>!!(this.mappingValidation&&this.mappingValidation.logic&&this.mappingValidation.logic.trim().length>0);this.getMappingValidation=()=>this.mappingValidation||void 0;this.getAlternativeMatches=()=>this.alternativeMatches.filter(e=>!!e);this.getCreator=()=>this.creator;this.getBaseKey=()=>this.baseKey;this.getBaseKeyCounter=()=>this.baseKeyCounter;this.setCustomKey=({key:e,baseKey:t,baseKeyCounter:i,creator:o})=>{this.baseKey=t,this.key=e,this.baseKeyCounter=i,this.creator=o};this.isDropdown=()=>r.isTypeDropdown(this.getType());this.isCategoryType=()=>r.isTypeCategory(this.getType());this.isBooleanType=()=>this.type==="boolean";this.serialize=()=>({description:this.getDescription(),example:this.getExample(),key:this.getKey(),label:this.getLabel(),type:this.getType(),validators:[],alternativeMatches:this.getAlternativeMatches(),columnSize:this.getColumnSize(),columnWidth:this.getColumnWidth(),outputFormat:this.getOutputFormat(),inputFormat:this.getInputFormat(),isMultiSelection:this.getIsMultiSelection(),numberFormat:this.getNumberFormat(),baseKey:this.getBaseKey(),baseKeyCounter:this.getBaseKeyCounter(),creator:this.getCreator(),hidden:this.isHidden(),disabled:this.isDisabled(),optionMappingConfiguration:this.getOptionMappingConfiguration(),excludeFromAutoMatching:this.isExcludedFromAutoMatching()});this.getIsMultiSelection=()=>!1;this.getNumberFormat=()=>this.numberFormat;this.isDisabled=()=>this.disabled;this.isNumeric=()=>this.type==="int"||this.type==="float"||this.type==="currency_eur"||this.type==="currency_usd"||this.type==="percentage";this.isCurrency=()=>this.type==="currency_eur"||this.type==="currency_usd";this.baseClone=()=>{let e=this.serialize(),t=new r({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,validators:this.getValidators(),alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,columnWidth:e.columnWidth,baseKey:e.baseKey,baseKeyCounter:e.baseKeyCounter,creator:e.creator,numberFormat:e.numberFormat,outputFormat:e.outputFormat,inputFormat:this.declaredInputFormat,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration,excludeFromAutoMatching:e.excludeFromAutoMatching});return t.setInputFormat(this.inputFormat),t.setDateFormatPromptResolved(this.dateFormatPromptResolved),t};this.isHidden=()=>this.hidden;this.isExcludedFromAutoMatching=()=>this.excludeFromAutoMatching;this.getOptionMappingConfiguration=()=>this.optionMappingConfiguration;this.description=e,this.key=t,this.example=i,this.label=o,this.type=n,this.validators=s??[],this.mappingValidation=a,this.alternativeMatches=p?[...p.filter(c=>c!==o&&c!==t)?.map(c=>c?.toString())]:[],this.columnSize=u,this.creator=m,this.baseKey=y||t,this.baseKeyCounter=T||0,this.outputFormat=M||"",this.declaredInputFormat=E??null,this.inputFormat=E??null,this.numberFormat=C||"eu",this.hidden=x??!1,this.disabled=S??!1,this.optionMappingConfiguration=O,this.columnWidth=P,this.excludeFromAutoMatching=R??!1}static{this.getOutputFormat=e=>(e||"DD.MM.YYYY").replace(/d/g,"D").replace(/e|E/g,"")}static{this.isTypeDropdown=e=>r.isTypeCategory(e)||e==="boolean"}static{this.isTypeCategory=e=>e==="single-select"||e==="currency_code"||e==="country_code_alpha_2"||e==="country_code_alpha_3"}};var Oe={ar:"ar-SA",he:"he-IL",de:"de-DE",en:"en-US",es:"es-ES",fr:"fr-FR",it:"it-IT",nl:"nl-NL",pl:"pl-PL",pt:"pt-PT",sv:"sv-SE",cz:"cs-CZ",dk:"da-DK",hu:"hu-HU",lt:"lt-LT",no:"nb-NO",ru:"ru-RU",sk:"sk-SK",zh:"zh-CN"},Yt=r=>r==="ar"||r==="he"?"rtl":"ltr",se=r=>r?Oe[r]??"de-DE":"de-DE",wt=r=>r?se(r).split("-")[0]:void 0;import{isNil as B,isArray as Ot,escapeRegExp as Pt}from"lodash";import{isArray as Pe,isNil as Re,isObject as Ie}from"lodash";var V=class{constructor(){this.parse=(e,t)=>Re(e)||Pe(e)||Ie(e)?null:G().includes(`${e}`.toLowerCase())?!0:q().includes(`${e}`.toLowerCase())?!1:e===""?null:`${e}`}},ae=V;import{isArray as le,isBoolean as pe,isNil as ue,isObject as me}from"lodash";var U=class{constructor(){this.parseSingle=(e,t)=>ue(e)||me(e)||le(e)?null:pe(e)?JSON.stringify(e):b({value:e,dataModel:t.dataModel,isTrim:!0});this.parseMultiple=(e,t)=>le(e)?e.map(i=>b({value:i,dataModel:t.dataModel,isTrim:!0})):ue(e)||me(e)||e===""?null:pe(e)?[JSON.stringify(e)]:[b({value:e,dataModel:t.dataModel,isTrim:!0})];this.parse=(e,t)=>t.dataModel.getIsMultiSelection()&&!t.forceSingle?this.parseMultiple(e,t):this.parseSingle(e,t)}},de=U;import{isArray as Fe,isBoolean as _e,isNil as Ne,isObject as Ve}from"lodash";var L=class{constructor(){this.parse=(e,t)=>{if(Ne(e)||Fe(e)||Ve(e))return null;if(_e(e))return JSON.stringify(e);if(e==="")return null;if(typeof e=="number"){let i=`${e}`;return l(d.isScientificNotation(i)?d.expandScientificNotation(i):i)}return l(`${e}`)}}},ye=L;import{isArray as Ue,isBoolean as Le,isNil as He,isObject as Ye}from"lodash";var H=class{constructor(){this.parse=(e,t)=>He(e)?null:Le(e)?e?"1":"0":Ye(e)||Ue(e)||e===""||l(e)===null?null:this.valueParser(e,t)}},D=H;var Y=class extends D{constructor(){super(...arguments);this.valueParser=(t,i)=>{let o=d.convertStringToNumber(t,{format:i?.numberFormat});return o===null?l(`${t}`):Number(o)}}},ce=Y;var w=class extends D{constructor(){super(...arguments);this.valueParser=(t,i)=>{let o=d.convertStringToNumber(t,{format:i?.numberFormat});return o===null?l(`${t}`):Number(o)}}},Me=w;import{isArray as we,isBoolean as Xe,isNil as ke,isNumber as ve,isObject as $e}from"lodash";var X=class{constructor(){this.parse=(e,t)=>{if(ke(e)||$e(e)||we(e))return null;if(Xe(e))return JSON.stringify(e);if(ve(e))return e;if(e===""||l(e)===null)return null;let i=d.convertStringToNumber(e,{adornment:"percentage"});return i===null?l(`${e}`):Number(i)}}},ge=X;import{isArray as We,isBoolean as Ke,isNil as Be,isObject as ze}from"lodash";var k=class{constructor(){this.parse=(e,t)=>{if(Be(e)||We(e)||ze(e))return null;if(Ke(e))return JSON.stringify(e);if(e===""||l(e)===null)return null;let i=d.convertStringToNumber(e,{format:t?.numberFormat});return i===null?l(`${e}`):Number(i)}}},fe=k;var he=["dd.MM.yyyy HH:mm","dd.MM.yyyy","dd/MM/yyyy HH:mm:ss","dd/MM/yyyy HH:mm","dd/MM/yyyy","dd-MM-yyyy HH:mm:ss","dd-MM-yyyy HH:mm","yyyy-MM-dd'T'HH:mm:ss","yyyy-MM-dd","yyyy-dd-MM","yyyy-MM-dd HH:mm:ss","dd-MM-yyyy","MM-dd-yyyy","MM/dd/yyyy","MM.dd.yyyy","yyyy/MM/dd","yyyyMMdd","dd MMM yyyy","dd MMMM yyyy","MM-dd-yyyy HH:mm:ss","MM/dd/yyyy HH:mm:ss","yyyy-MM-dd HH:mm","MM-dd-yyyy HH:mm","MM/dd/yyyy HH:mm","dd-MMM-yyyy","MMM yyyy","MMMM yyyy","MM/yyyy","M/yyyy","yyyy/MM","MM.yyyy","MM.yy","yyyy.MM","MM-yyyy","yyyy-MM","MMMM d, yyyy","MMM d, yyyy","MM dd yyyy","yyyy-MM-dd'T'HH:mm:ss.SSS","yyyy-MM-dd'T'HH:mm:ss.SSSxxx","yyyy.MM.dd","yyyy MM dd","yyyy/dd/MM","yyyy.dd.MM","dd yyyy MM","dd.yyyy.MM","dd-yyyy-MM","yyyy dd MM","MM yyyy dd","dd/yyyy/MM","MM/yyyy/dd"],Qe=["dd.MM.yyyy","dd/MM/yyyy","dd-MM-yyyy","MM.dd.yyyy","MM/dd/yyyy","MM-dd-yyyy","yyyy.MM.dd","yyyy/MM/dd","yyyy-MM-dd","yyyy.dd.MM","yyyy/dd/MM","yyyy-dd-MM","dd MMM yyyy","dd MMMM yyyy","MMM dd, yyyy","MMMM dd, yyyy","MMM dd yyyy","yyyy MMM dd"],Ge=["ddMMyyyy","MMddyyyy","yyyyMMdd"],qe=[""," HH:mm"," HH:mm:ss"],Ze=["yyyy-MM-dd","yyyy-dd-MM"],Je=["'T'HH:mm:ss","'T'HH:mm:ss.SSS","'T'HH:mm:ss.SSSxxx"],je=[...Qe.flatMap(r=>qe.map(e=>`${r}${e}`)),...Ge,...Ze.flatMap(r=>Je.map(e=>`${r}${e}`))],et=new Set(he),v=new Set([...he,...je.filter(r=>!et.has(r))]);var tt={YYYY:"yyyy",YY:"yy",MMMM:"MMMM",MMM:"MMM",MM:"MM",M:"M",DD:"dd",D:"d",HH:"HH",H:"H",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"SSS",SS:"SS",S:"S",A:"a",a:"a",XXXXX:"XXXXX",XXXX:"XXXX",XXX:"XXX",XX:"XX",X:"X",xxxxx:"xxxxx",xxxx:"xxxx",xxx:"xxx",xx:"xx",x:"x",ZZ:"xxx",Z:"X"},Te=r=>r.replace(/'/g,"''"),rt=r=>{let e="",t=0;for(;t<r.length;){let i=r[t];if(i==="'"){t+=1;let o="";for(;t<r.length;)if(r[t]==="'")if(r[t+1]==="'")o+="'",t+=2;else{t+=1;break}else o+=r[t],t+=1;e+=`'${Te(o)}'`;continue}if(i==="["){t+=1;let o="";for(;t<r.length;)if(r[t]==="]")if(r[t+1]==="]")o+="]",t+=2;else{t+=1;break}else o+=r[t],t+=1;e+=`'${Te(o)}'`;continue}if(i==="T"){e+="'T'",t+=1;continue}if(/[A-Za-z]/.test(i)){let o=1;for(;r[t+o]===i;)o++;let n=r.slice(t,t+o);e+=tt[n]??n,t+=o}else e+=i,t+=1}return e},Ee=/^(yyyy|yy|MMMM|MMM|MM|M|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|XXXXX|XXXX|XXX|XX|X|xxxxx|xxxx|xxx|xx|x|a)/,it=new Set(["HH","H","hh","h","mm","m","ss","s","SSS","SS","S","a","XXXXX","XXXX","XXX","XX","X","xxxxx","xxxx","xxx","xx","x"]),ot=new Set(["MMM","MMMM"]),nt=[".","/","-"," "],st="",at=r=>{let e=[],t=0;for(;t<r.length;){if(r[t]==="'"){t+=1;let n="'";for(;t<r.length;)if(r[t]==="'")if(r[t+1]==="'")n+="''",t+=2;else{n+="'",t+=1;break}else n+=r[t],t+=1;e.push({kind:"text",text:n});continue}let i=r.slice(t).match(Ee);if(i){e.push({kind:"token",token:i[1]}),t+=i[1].length;continue}let o=r[t];for(t+=1;t<r.length&&!(r[t]==="'"||Ee.test(r.slice(t)));)o+=r[t],t+=1;e.push({kind:"text",text:o})}return e},lt=r=>{for(let e=0;e<r.length;e++){let t=r[e];if(t.kind!=="token"||!it.has(t.token))continue;let i=e>0?r[e-1]:null;return i?.kind==="text"&&(/^[T\s]+$/.test(i.text)||i.text==="'T'")?e-1:e}return r.length},be=r=>{let e=at(r);if(e.some(a=>a.kind==="token"&&ot.has(a.token)))return`exact:${r}`;let t=lt(e),i=e.slice(0,t),o=e.slice(t),n="",s=!1;for(let a of i){if(a.kind==="token"){let p=a.token;p==="d"?p="dd":p==="M"?p="MM":p==="yy"&&(p="yyyy"),n+=p,s=!0;continue}s&&a.text.length===1&&nt.includes(a.text)?n+=st:n+=a.text,s=!1}for(let a of o)n+=a.kind==="token"?a.token:a.text;return n},$=null,pt=()=>{if($)return $;let r=new Set;for(let e of v){let t=be(e);t&&r.add(t)}return $=r,r},ut=r=>{if(!g(r))return!1;let e=rt(r.trim());if(v.has(e))return!0;let t=be(e);return!t||t.startsWith("exact:")?!1:pt().has(t)},Cr=r=>{if(!g(r))return null;let e=r.trim();return ut(e)?e:null},mt=({sourceRows:r,inputFormat:e})=>{let t=e.trim(),i=0,o=0;for(let n=0;n<r.length;n++){let s=r[n];oe(s)&&(o+=1,h(s.trim(),t)||(i+=1))}return{mismatchCount:i,totalCount:o}},xr=(r,e)=>{let t=e.trim();if(h(r,t))return!1;let i=r.trim();return/^\d{4}-\d{2}-\d{2}/.test(i)?!!(t.includes("/")||t.includes(".")&&!t.includes("/")):!1},Sr=({columnKey:r,sourceRows:e,inputFormat:t})=>{let{mismatchCount:i,totalCount:o}=mt({sourceRows:e,inputFormat:t});i!==0&&console.warn(`Ingestro: Column '${r}': ${i} of ${o} cells did not match inputFormat '${t.trim()}'.`)};import{parse as dt,format as yt}from"date-fns";import{isArray as ct,isBoolean as Mt,isNil as gt,isObject as ft}from"lodash";import A from"moment";var Ae=/([+-](?:0\d|1[0-4]):?[0-5]\d|Z)$/i,De=(r,e)=>{let o=!!r.match(Ae)?A.parseZone(r,e,!0):A(r,e,!0);return o.isValid()&&o.format(e)===r},W=class{constructor(){this.parse=(e,t)=>{if(gt(e)||ct(e)||ft(e))return null;if(Mt(e))return JSON.stringify(e);let i=t?.dataModel?.getType();if(!i)return l(`${e}`);if(typeof e=="string"){if(e==="")return null;try{if(t?.dataModel?.getType()==="date"){let o=t?.dataModel?.getOutputFormat(),n=t?.dataModel?.getInputFormat(),s=`${e}`,a=!1;if(g(n)&&!t?.skipDeclaredInputFormatNormalization){let y=ee(s);if(h(s,n)||y)y||(s=`${F([s],n)[0]}`),a=!0;else{let M=F([s],n)[0];if(M===s)return De(s,o)?s:l(s);s=`${M}`,a=!0}}if(!a&&De(s,o))return s;let m=!!s.match(Ae)?A.parseZone(s,j):A(s,J);if(m.isValid())return m.format(o);throw new Error("invalid date")}else{let o=te[i];if(!o)return l(`${e}`);let n=dt(e,Z,new Date);return yt(n,o)}}catch{let n=re[i];return n?l(ie(e,n)):l(`${e}`)}}else return l(`${e}`)}}},Ce=W;import{isArray as ht}from"lodash";var Tt=new ce,Et=new Me,bt=new fe,Dt=new ge,At=new ae,Ct=new de,xt=new ye,St=new Ce,K=class{static{this.parse=(e,t)=>{let i;switch(t?.dataModel?.getType()){case"int":i=Tt;break;case"float":i=Et;break;case"boolean":i=At;break;case"single-select":case"currency_code":case"country_code_alpha_2":case"country_code_alpha_3":i=Ct;break;case"percentage":i=Dt;break;case"currency_eur":case"currency_usd":i=bt;break;case"date":case"date_dmy":case"date_mdy":case"date_iso":case"datetime":case"time_hms":case"time_hms_24":case"time_hm":case"time_hm_24":i=St;break;case"email":case"url_www":case"url_https":case"url":case"phone":case"zip_code_de":case"bic":case"vat_eu":case"gtin":case"iban":default:i=xt;break}return i.parse(e,t)}}static{this.parseRawValueToDisplayValue=(e,t)=>{let i=e;if(t.isNumeric)i=d.convertToFormat(e,{targetFormat:t.numberFormat||"eu",adornment:t.type==="percentage"?"percentage":void 0}),["currency_eur","currency_usd"].includes(t.type)&&(t.type==="currency_usd"?i=`$${i}`:i=`${i} \u20AC`);else if(t.type==="boolean"){let n=Q.getInstance().getOptionsForReviewEntries().find(s=>`${s.value}`.includes(`${e}`));n&&(i=`${n.label}`)}else if(f.isTypeCategory(t.type))if(t.isMultiSelection){if(ht(e)){let o=t.options?.filter(n=>e.some(s=>I(n,s)));o&&(i=o.map(n=>n.label).join(", "))}}else{let o=t.options?.find(n=>I(n,e));o&&(i=`${o?.label}`)}return`${i}`}}static{this.parseDisplayValueToRawValue=(e,t)=>{if(t.isNumeric){let i=d.convertToUsWithDecimal(`${e}`,t.numberFormat??"eu");if(i===null)return e;let o=d.convertStringToNumber(i,{format:"us"});return o!==null?Number(o):e}else return e}}},xe=K;var ai=(r,e)=>Number(r).toLocaleString(e??"de-DE",{numberingSystem:"latn"}),li=(r,e)=>{let{value:t,isExact:i,columns:o,isEmptyValues:n}=e;if(n)return B(r)||r==="";if(Ot(r)&&o[0]?.isMultiSelection){let a=o[0],p=r.map(u=>{let m=a.options?.find(y=>`${y.value}`==`${u}`);return m?m.label:`${u}`}).join(", ");return i?p===t:p.toLowerCase().includes(t.toLowerCase())}let s=xe.parseRawValueToDisplayValue(r,o[0]);return i&&!B(r)&&s===t?!0:!!(!i&&!B(r)&&s?.toLowerCase()?.includes(t?.toLowerCase()))},pi=(r,e,t,i)=>{let o=r.map(u=>{let m=i.options?.find(y=>`${y.value}`==`${u}`);return m?m.label:`${u}`}),n=e.split(",").map(u=>u.trim()).filter(Boolean);if(n.length===0)return r;let s=-1;for(let u=0;u<=o.length-n.length;u++){let m=!0;for(let y=0;y<n.length;y++)if(o[u+y].toLowerCase()!==n[y].toLowerCase()){m=!1;break}if(m){s=u;break}}if(s===-1)return r;let a=[...r.slice(0,s),...t,...r.slice(s+n.length)],p=new Set;return a.filter(u=>{let m=`${u}`;return p.has(m)?!1:(p.add(m),!0)})},ui=(r,e,t)=>{let i=new RegExp(Pt(e),"gi");return`${r}`.replace(i,t)},mi=r=>typeof r=="string"?r.replace(/(\r\n|\n|\r)/gm,""):r,di=(r,e)=>e?e.map((t,i)=>r.map(o=>({rowIndex:i,valid:!0,key:o.key,value:t[o.key]}))):[];var z=class r extends f{constructor({description:t,key:i,example:o,label:n,type:s,options:a,validators:p,alternativeMatches:u,columnSize:m,isMultiSelection:y,allowCustomOptions:T,allowedCustomOptionTypes:M,preserveUnmappedOptions:E,creator:C,baseKey:x,baseKeyCounter:S,hidden:O,optionMappingConfiguration:P,...R}){super({description:t,key:i,example:o,label:n,type:s,validators:p,alternativeMatches:u,columnSize:m,creator:C,baseKey:x,baseKeyCounter:S,hidden:O,optionMappingConfiguration:P,...R});this.optionTypeMap=null;this.getOptions=()=>this.options;this.getOptionTypeMap=()=>{if(!this.optionTypeMap){this.optionTypeMap=new Map;for(let t=0;t<this.options.length;t++){let i=this.options[t];this.optionTypeMap.set(i.value,i.type??"string")}}return this.optionTypeMap};this.setOptions=t=>{this.options=t,this.optionTypeMap=null};this.serialize=()=>{let t={description:this.getDescription(),example:this.getExample(),isRequired:this.getIsRequired(),key:this.getKey(),label:this.getLabel(),type:this.getType(),validators:this.getValidators().map(o=>o.serialize()),alternativeMatches:this.getAlternativeMatches(),columnSize:this.getColumnSize(),columnWidth:this.getColumnWidth(),outputFormat:this.getOutputFormat(),inputFormat:this.getInputFormat(),numberFormat:this.getNumberFormat(),baseKey:this.getBaseKey(),baseKeyCounter:this.getBaseKeyCounter(),creator:this.getCreator(),hidden:this.isHidden(),disabled:this.isDisabled(),optionMappingConfiguration:this.getOptionMappingConfiguration(),excludeFromAutoMatching:this.isExcludedFromAutoMatching()},i=this.getOptions();return{...t,options:i,isMultiSelection:this.isMultiSelection,allowCustomOptions:this.allowCustomOptions,allowedCustomOptionTypes:this.allowedCustomOptionTypes?[...this.allowedCustomOptionTypes]:void 0,preserveUnmappedOptions:this.preserveUnmappedOptions}};this.getIsMultiSelection=()=>this.isMultiSelection;this.getAllowCustomOptions=()=>this.allowCustomOptions;this.getAllowedCustomOptionTypes=()=>this.allowedCustomOptionTypes?[...this.allowedCustomOptionTypes]:void 0;this.getPreserveUnmappedOptions=()=>this.preserveUnmappedOptions;this.options=a?.map(c=>({...c,baseKey:c?.baseKey||c.value,baseKeyCounter:c.baseKeyCounter||0,alternativeMatches:c.alternativeMatches.filter(Se=>Se!==c.label),validations:c.validations||[]})),this.isMultiSelection=y,this.allowCustomOptions=T,this.allowedCustomOptionTypes=M?[...M]:void 0,this.preserveUnmappedOptions=E}clone(){let t=this.serialize();return new r({description:t.description,example:t.example,key:t.key,label:t.label,type:t.type,options:t.options,validators:this.getValidators(),alternativeMatches:t.alternativeMatches,columnSize:t.columnSize,columnWidth:t.columnWidth,isMultiSelection:t.isMultiSelection,allowCustomOptions:t.allowCustomOptions,allowedCustomOptionTypes:t.allowedCustomOptionTypes,preserveUnmappedOptions:t.preserveUnmappedOptions,hidden:t.hidden,disabled:t.disabled,optionMappingConfiguration:t.optionMappingConfiguration,excludeFromAutoMatching:t.excludeFromAutoMatching})}},Ti=z;export{Cr as a,xr as b,Sr as c,Rt as d,f as e,xe as f,Yt as g,se as h,wt as i,ai as j,li as k,pi as l,ui as m,mi as n,di as o,Ti as p};
1
+ import{b as oe,c as g,l as h,n as F}from"./chunk-J6ZA6O45.js";import{a as l,d as I,f as b}from"./chunk-KNOWDPDH.js";import{a as G,b as q}from"./chunk-JWTYPSUX.js";import{a as Z,b as J,c as j,d as ee,g as te,h as re,j as ie}from"./chunk-DNCQE4OX.js";import{a as d}from"./chunk-EWEVS5OB.js";import{a as Q}from"./chunk-J5WOZVPO.js";var _=class{constructor({validation:e,regex:t,fields:i,errorMessage:o,operator:n,value:s}){this.getValidation=()=>this.validation;this.getRegex=()=>this.regex;this.getFields=()=>this.fields;this.getErrorMessage=()=>this.errorMessage;this.getOperator=()=>this.operator;this.getValue=()=>this.value;this.serialize=()=>({validation:this.getValidation(),fields:this.getFields(),regex:this.getRegex(),errorMessage:this.getErrorMessage(),operator:this.getOperator(),value:this.getValue()});this.validation=e,this.regex=t,this.fields=i??[],this.errorMessage=o,this.operator=n,this.value=s}},Rt=_;var f=class r{constructor({description:e,key:t,example:i,label:o,type:n,validators:s,mappingValidation:a,alternativeMatches:p,columnSize:u,creator:m,baseKey:y,baseKeyCounter:T,outputFormat:M,inputFormat:E,numberFormat:C,hidden:x,disabled:S,optionMappingConfiguration:O,columnWidth:P,excludeFromAutoMatching:R}){this.getDescription=()=>this.description;this.getKey=()=>this.key;this.getExample=()=>this.example;this.getLabel=()=>this.label;this.setLabel=e=>{this.label=e};this.getType=()=>this.type;this.getOutputFormat=()=>r.getOutputFormat(this.outputFormat);this.getInputFormat=()=>this.inputFormat;this.getDeclaredInputFormat=()=>this.declaredInputFormat;this.setInputFormat=e=>{this.inputFormat=e};this.dateFormatPromptResolved=null;this.setDateFormatPromptResolved=e=>{this.dateFormatPromptResolved=e};this.getDateFormatPromptResolved=()=>this.dateFormatPromptResolved;this.resetSessionInputFormat=()=>{this.inputFormat=this.declaredInputFormat,this.dateFormatPromptResolved=null};this.getValidators=()=>this.validators;this.getColumnSize=()=>this.columnSize;this.getColumnWidth=()=>this.columnWidth;this.getIsRequired=()=>!!this.validators.find(t=>t.getValidation()==="REQUIRED");this.getIsUnique=()=>!!this.validators.find(t=>t.getValidation()==="UNIQUE");this.getIsUniqueAndRequired=()=>this.getIsRequired()===!0&&this.getIsUnique()===!0;this.hasMappingValidation=()=>!!(this.mappingValidation&&this.mappingValidation.logic&&this.mappingValidation.logic.trim().length>0);this.getMappingValidation=()=>this.mappingValidation||void 0;this.getAlternativeMatches=()=>this.alternativeMatches.filter(e=>!!e);this.getCreator=()=>this.creator;this.getBaseKey=()=>this.baseKey;this.getBaseKeyCounter=()=>this.baseKeyCounter;this.setCustomKey=({key:e,baseKey:t,baseKeyCounter:i,creator:o})=>{this.baseKey=t,this.key=e,this.baseKeyCounter=i,this.creator=o};this.isDropdown=()=>r.isTypeDropdown(this.getType());this.isCategoryType=()=>r.isTypeCategory(this.getType());this.isBooleanType=()=>this.type==="boolean";this.serialize=()=>({description:this.getDescription(),example:this.getExample(),key:this.getKey(),label:this.getLabel(),type:this.getType(),validators:[],alternativeMatches:this.getAlternativeMatches(),columnSize:this.getColumnSize(),columnWidth:this.getColumnWidth(),outputFormat:this.getOutputFormat(),inputFormat:this.getInputFormat(),isMultiSelection:this.getIsMultiSelection(),numberFormat:this.getNumberFormat(),baseKey:this.getBaseKey(),baseKeyCounter:this.getBaseKeyCounter(),creator:this.getCreator(),hidden:this.isHidden(),disabled:this.isDisabled(),optionMappingConfiguration:this.getOptionMappingConfiguration(),excludeFromAutoMatching:this.isExcludedFromAutoMatching()});this.getIsMultiSelection=()=>!1;this.getNumberFormat=()=>this.numberFormat;this.isDisabled=()=>this.disabled;this.isNumeric=()=>this.type==="int"||this.type==="float"||this.type==="currency_eur"||this.type==="currency_usd"||this.type==="percentage";this.isCurrency=()=>this.type==="currency_eur"||this.type==="currency_usd";this.baseClone=()=>{let e=this.serialize(),t=new r({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,validators:this.getValidators(),alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,columnWidth:e.columnWidth,baseKey:e.baseKey,baseKeyCounter:e.baseKeyCounter,creator:e.creator,numberFormat:e.numberFormat,outputFormat:e.outputFormat,inputFormat:this.declaredInputFormat,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration,excludeFromAutoMatching:e.excludeFromAutoMatching});return t.setInputFormat(this.inputFormat),t.setDateFormatPromptResolved(this.dateFormatPromptResolved),t};this.isHidden=()=>this.hidden;this.isExcludedFromAutoMatching=()=>this.excludeFromAutoMatching;this.getOptionMappingConfiguration=()=>this.optionMappingConfiguration;this.description=e,this.key=t,this.example=i,this.label=o,this.type=n,this.validators=s??[],this.mappingValidation=a,this.alternativeMatches=p?[...p.filter(c=>c!==o&&c!==t)?.map(c=>c?.toString())]:[],this.columnSize=u,this.creator=m,this.baseKey=y||t,this.baseKeyCounter=T||0,this.outputFormat=M||"",this.declaredInputFormat=E??null,this.inputFormat=E??null,this.numberFormat=C||"eu",this.hidden=x??!1,this.disabled=S??!1,this.optionMappingConfiguration=O,this.columnWidth=P,this.excludeFromAutoMatching=R??!1}static{this.getOutputFormat=e=>(e||"DD.MM.YYYY").replace(/d/g,"D").replace(/e|E/g,"")}static{this.isTypeDropdown=e=>r.isTypeCategory(e)||e==="boolean"}static{this.isTypeCategory=e=>e==="single-select"||e==="currency_code"||e==="country_code_alpha_2"||e==="country_code_alpha_3"}};var Oe={ar:"ar-SA",he:"he-IL",de:"de-DE",en:"en-US",es:"es-ES",fr:"fr-FR",it:"it-IT",nl:"nl-NL",pl:"pl-PL",pt:"pt-PT",sv:"sv-SE",cz:"cs-CZ",dk:"da-DK",hu:"hu-HU",lt:"lt-LT",no:"nb-NO",ru:"ru-RU",sk:"sk-SK",zh:"zh-CN"},Yt=r=>r==="ar"||r==="he"?"rtl":"ltr",se=r=>r?Oe[r]??"de-DE":"de-DE",wt=r=>r?se(r).split("-")[0]:void 0;import{isNil as B,isArray as Ot,escapeRegExp as Pt}from"lodash";import{isArray as Pe,isNil as Re,isObject as Ie}from"lodash";var V=class{constructor(){this.parse=(e,t)=>Re(e)||Pe(e)||Ie(e)?null:G().includes(`${e}`.toLowerCase())?!0:q().includes(`${e}`.toLowerCase())?!1:e===""?null:`${e}`}},ae=V;import{isArray as le,isBoolean as pe,isNil as ue,isObject as me}from"lodash";var U=class{constructor(){this.parseSingle=(e,t)=>ue(e)||me(e)||le(e)?null:pe(e)?JSON.stringify(e):b({value:e,dataModel:t.dataModel,isTrim:!0});this.parseMultiple=(e,t)=>le(e)?e.map(i=>b({value:i,dataModel:t.dataModel,isTrim:!0})):ue(e)||me(e)||e===""?null:pe(e)?[JSON.stringify(e)]:[b({value:e,dataModel:t.dataModel,isTrim:!0})];this.parse=(e,t)=>t.dataModel.getIsMultiSelection()&&!t.forceSingle?this.parseMultiple(e,t):this.parseSingle(e,t)}},de=U;import{isArray as Fe,isBoolean as _e,isNil as Ne,isObject as Ve}from"lodash";var L=class{constructor(){this.parse=(e,t)=>{if(Ne(e)||Fe(e)||Ve(e))return null;if(_e(e))return JSON.stringify(e);if(e==="")return null;if(typeof e=="number"){let i=`${e}`;return l(d.isScientificNotation(i)?d.expandScientificNotation(i):i)}return l(`${e}`)}}},ye=L;import{isArray as Ue,isBoolean as Le,isNil as He,isObject as Ye}from"lodash";var H=class{constructor(){this.parse=(e,t)=>He(e)?null:Le(e)?e?"1":"0":Ye(e)||Ue(e)||e===""||l(e)===null?null:this.valueParser(e,t)}},D=H;var Y=class extends D{constructor(){super(...arguments);this.valueParser=(t,i)=>{let o=d.convertStringToNumber(t,{format:i?.numberFormat});return o===null?l(`${t}`):Number(o)}}},ce=Y;var w=class extends D{constructor(){super(...arguments);this.valueParser=(t,i)=>{let o=d.convertStringToNumber(t,{format:i?.numberFormat});return o===null?l(`${t}`):Number(o)}}},Me=w;import{isArray as we,isBoolean as Xe,isNil as ke,isNumber as ve,isObject as $e}from"lodash";var X=class{constructor(){this.parse=(e,t)=>{if(ke(e)||$e(e)||we(e))return null;if(Xe(e))return JSON.stringify(e);if(ve(e))return e;if(e===""||l(e)===null)return null;let i=d.convertStringToNumber(e,{adornment:"percentage"});return i===null?l(`${e}`):Number(i)}}},ge=X;import{isArray as We,isBoolean as Ke,isNil as Be,isObject as ze}from"lodash";var k=class{constructor(){this.parse=(e,t)=>{if(Be(e)||We(e)||ze(e))return null;if(Ke(e))return JSON.stringify(e);if(e===""||l(e)===null)return null;let i=d.convertStringToNumber(e,{format:t?.numberFormat});return i===null?l(`${e}`):Number(i)}}},fe=k;var he=["dd.MM.yyyy HH:mm","dd.MM.yyyy","dd/MM/yyyy HH:mm:ss","dd/MM/yyyy HH:mm","dd/MM/yyyy","dd-MM-yyyy HH:mm:ss","dd-MM-yyyy HH:mm","yyyy-MM-dd'T'HH:mm:ss","yyyy-MM-dd","yyyy-dd-MM","yyyy-MM-dd HH:mm:ss","dd-MM-yyyy","MM-dd-yyyy","MM/dd/yyyy","MM.dd.yyyy","yyyy/MM/dd","yyyyMMdd","dd MMM yyyy","dd MMMM yyyy","MM-dd-yyyy HH:mm:ss","MM/dd/yyyy HH:mm:ss","yyyy-MM-dd HH:mm","MM-dd-yyyy HH:mm","MM/dd/yyyy HH:mm","dd-MMM-yyyy","MMM yyyy","MMMM yyyy","MM/yyyy","M/yyyy","yyyy/MM","MM.yyyy","MM.yy","yyyy.MM","MM-yyyy","yyyy-MM","MMMM d, yyyy","MMM d, yyyy","MM dd yyyy","yyyy-MM-dd'T'HH:mm:ss.SSS","yyyy-MM-dd'T'HH:mm:ss.SSSxxx","yyyy.MM.dd","yyyy MM dd","yyyy/dd/MM","yyyy.dd.MM","dd yyyy MM","dd.yyyy.MM","dd-yyyy-MM","yyyy dd MM","MM yyyy dd","dd/yyyy/MM","MM/yyyy/dd"],Qe=["dd.MM.yyyy","dd/MM/yyyy","dd-MM-yyyy","MM.dd.yyyy","MM/dd/yyyy","MM-dd-yyyy","yyyy.MM.dd","yyyy/MM/dd","yyyy-MM-dd","yyyy.dd.MM","yyyy/dd/MM","yyyy-dd-MM","dd MMM yyyy","dd MMMM yyyy","MMM dd, yyyy","MMMM dd, yyyy","MMM dd yyyy","yyyy MMM dd"],Ge=["ddMMyyyy","MMddyyyy","yyyyMMdd"],qe=[""," HH:mm"," HH:mm:ss"],Ze=["yyyy-MM-dd","yyyy-dd-MM"],Je=["'T'HH:mm:ss","'T'HH:mm:ss.SSS","'T'HH:mm:ss.SSSxxx"],je=[...Qe.flatMap(r=>qe.map(e=>`${r}${e}`)),...Ge,...Ze.flatMap(r=>Je.map(e=>`${r}${e}`))],et=new Set(he),v=new Set([...he,...je.filter(r=>!et.has(r))]);var tt={YYYY:"yyyy",YY:"yy",MMMM:"MMMM",MMM:"MMM",MM:"MM",M:"M",DD:"dd",D:"d",HH:"HH",H:"H",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"SSS",SS:"SS",S:"S",A:"a",a:"a",XXXXX:"XXXXX",XXXX:"XXXX",XXX:"XXX",XX:"XX",X:"X",xxxxx:"xxxxx",xxxx:"xxxx",xxx:"xxx",xx:"xx",x:"x",ZZ:"xxx",Z:"X"},Te=r=>r.replace(/'/g,"''"),rt=r=>{let e="",t=0;for(;t<r.length;){let i=r[t];if(i==="'"){t+=1;let o="";for(;t<r.length;)if(r[t]==="'")if(r[t+1]==="'")o+="'",t+=2;else{t+=1;break}else o+=r[t],t+=1;e+=`'${Te(o)}'`;continue}if(i==="["){t+=1;let o="";for(;t<r.length;)if(r[t]==="]")if(r[t+1]==="]")o+="]",t+=2;else{t+=1;break}else o+=r[t],t+=1;e+=`'${Te(o)}'`;continue}if(i==="T"){e+="'T'",t+=1;continue}if(/[A-Za-z]/.test(i)){let o=1;for(;r[t+o]===i;)o++;let n=r.slice(t,t+o);e+=tt[n]??n,t+=o}else e+=i,t+=1}return e},Ee=/^(yyyy|yy|MMMM|MMM|MM|M|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|XXXXX|XXXX|XXX|XX|X|xxxxx|xxxx|xxx|xx|x|a)/,it=new Set(["HH","H","hh","h","mm","m","ss","s","SSS","SS","S","a","XXXXX","XXXX","XXX","XX","X","xxxxx","xxxx","xxx","xx","x"]),ot=new Set(["MMM","MMMM"]),nt=[".","/","-"," "],st="",at=r=>{let e=[],t=0;for(;t<r.length;){if(r[t]==="'"){t+=1;let n="'";for(;t<r.length;)if(r[t]==="'")if(r[t+1]==="'")n+="''",t+=2;else{n+="'",t+=1;break}else n+=r[t],t+=1;e.push({kind:"text",text:n});continue}let i=r.slice(t).match(Ee);if(i){e.push({kind:"token",token:i[1]}),t+=i[1].length;continue}let o=r[t];for(t+=1;t<r.length&&!(r[t]==="'"||Ee.test(r.slice(t)));)o+=r[t],t+=1;e.push({kind:"text",text:o})}return e},lt=r=>{for(let e=0;e<r.length;e++){let t=r[e];if(t.kind!=="token"||!it.has(t.token))continue;let i=e>0?r[e-1]:null;return i?.kind==="text"&&(/^[T\s]+$/.test(i.text)||i.text==="'T'")?e-1:e}return r.length},be=r=>{let e=at(r);if(e.some(a=>a.kind==="token"&&ot.has(a.token)))return`exact:${r}`;let t=lt(e),i=e.slice(0,t),o=e.slice(t),n="",s=!1;for(let a of i){if(a.kind==="token"){let p=a.token;p==="d"?p="dd":p==="M"?p="MM":p==="yy"&&(p="yyyy"),n+=p,s=!0;continue}s&&a.text.length===1&&nt.includes(a.text)?n+=st:n+=a.text,s=!1}for(let a of o)n+=a.kind==="token"?a.token:a.text;return n},$=null,pt=()=>{if($)return $;let r=new Set;for(let e of v){let t=be(e);t&&r.add(t)}return $=r,r},ut=r=>{if(!g(r))return!1;let e=rt(r.trim());if(v.has(e))return!0;let t=be(e);return!t||t.startsWith("exact:")?!1:pt().has(t)},Cr=r=>{if(!g(r))return null;let e=r.trim();return ut(e)?e:null},mt=({sourceRows:r,inputFormat:e})=>{let t=e.trim(),i=0,o=0;for(let n=0;n<r.length;n++){let s=r[n];oe(s)&&(o+=1,h(s.trim(),t)||(i+=1))}return{mismatchCount:i,totalCount:o}},xr=(r,e)=>{let t=e.trim();if(h(r,t))return!1;let i=r.trim();return/^\d{4}-\d{2}-\d{2}/.test(i)?!!(t.includes("/")||t.includes(".")&&!t.includes("/")):!1},Sr=({columnKey:r,sourceRows:e,inputFormat:t})=>{let{mismatchCount:i,totalCount:o}=mt({sourceRows:e,inputFormat:t});i!==0&&console.warn(`Ingestro: Column '${r}': ${i} of ${o} cells did not match inputFormat '${t.trim()}'.`)};import{parse as dt,format as yt}from"date-fns";import{isArray as ct,isBoolean as Mt,isNil as gt,isObject as ft}from"lodash";import A from"moment";var Ae=/([+-](?:0\d|1[0-4]):?[0-5]\d|Z)$/i,De=(r,e)=>{let o=!!r.match(Ae)?A.parseZone(r,e,!0):A(r,e,!0);return o.isValid()&&o.format(e)===r},W=class{constructor(){this.parse=(e,t)=>{if(gt(e)||ct(e)||ft(e))return null;if(Mt(e))return JSON.stringify(e);let i=t?.dataModel?.getType();if(!i)return l(`${e}`);if(typeof e=="string"){if(e==="")return null;try{if(t?.dataModel?.getType()==="date"){let o=t?.dataModel?.getOutputFormat(),n=t?.dataModel?.getInputFormat(),s=`${e}`,a=!1;if(g(n)&&!t?.skipDeclaredInputFormatNormalization){let y=ee(s);if(h(s,n)||y)y||(s=`${F([s],n)[0]}`),a=!0;else{let M=F([s],n)[0];if(M===s)return De(s,o)?s:l(s);s=`${M}`,a=!0}}if(!a&&De(s,o))return s;let m=!!s.match(Ae)?A.parseZone(s,j):A(s,J);if(m.isValid())return m.format(o);throw new Error("invalid date")}else{let o=te[i];if(!o)return l(`${e}`);let n=dt(e,Z,new Date);return yt(n,o)}}catch{let n=re[i];return n?l(ie(e,n)):l(`${e}`)}}else return l(`${e}`)}}},Ce=W;import{isArray as ht}from"lodash";var Tt=new ce,Et=new Me,bt=new fe,Dt=new ge,At=new ae,Ct=new de,xt=new ye,St=new Ce,K=class{static{this.parse=(e,t)=>{let i;switch(t?.dataModel?.getType()){case"int":i=Tt;break;case"float":i=Et;break;case"boolean":i=At;break;case"single-select":case"currency_code":case"country_code_alpha_2":case"country_code_alpha_3":i=Ct;break;case"percentage":i=Dt;break;case"currency_eur":case"currency_usd":i=bt;break;case"date":case"date_dmy":case"date_mdy":case"date_iso":case"datetime":case"time_hms":case"time_hms_24":case"time_hm":case"time_hm_24":i=St;break;case"email":case"url_www":case"url_https":case"url":case"phone":case"zip_code_de":case"bic":case"vat_eu":case"gtin":case"iban":default:i=xt;break}return i.parse(e,t)}}static{this.parseRawValueToDisplayValue=(e,t)=>{let i=e;if(t.isNumeric)i=d.convertToFormat(e,{targetFormat:t.numberFormat||"eu",adornment:t.type==="percentage"?"percentage":void 0}),["currency_eur","currency_usd"].includes(t.type)&&(t.type==="currency_usd"?i=`$${i}`:i=`${i} \u20AC`);else if(t.type==="boolean"){let n=Q.getInstance().getOptionsForReviewEntries().find(s=>`${s.value}`.includes(`${e}`));n&&(i=`${n.label}`)}else if(f.isTypeCategory(t.type))if(t.isMultiSelection){if(ht(e)){let o=t.options?.filter(n=>e.some(s=>I(n,s)));o&&(i=o.map(n=>n.label).join(", "))}}else{let o=t.options?.find(n=>I(n,e));o&&(i=`${o?.label}`)}return`${i}`}}static{this.parseDisplayValueToRawValue=(e,t)=>{if(t.isNumeric){let i=d.convertToUsWithDecimal(`${e}`,t.numberFormat??"eu");if(i===null)return e;let o=d.convertStringToNumber(i,{format:"us"});return o!==null?Number(o):e}else return e}}},xe=K;var ai=(r,e)=>Number(r).toLocaleString(e??"de-DE",{numberingSystem:"latn"}),li=(r,e)=>{let{value:t,isExact:i,columns:o,isEmptyValues:n}=e;if(n)return B(r)||r==="";if(Ot(r)&&o[0]?.isMultiSelection){let a=o[0],p=r.map(u=>{let m=a.options?.find(y=>`${y.value}`==`${u}`);return m?m.label:`${u}`}).join(", ");return i?p===t:p.toLowerCase().includes(t.toLowerCase())}let s=xe.parseRawValueToDisplayValue(r,o[0]);return i&&!B(r)&&s===t?!0:!!(!i&&!B(r)&&s?.toLowerCase()?.includes(t?.toLowerCase()))},pi=(r,e,t,i)=>{let o=r.map(u=>{let m=i.options?.find(y=>`${y.value}`==`${u}`);return m?m.label:`${u}`}),n=e.split(",").map(u=>u.trim()).filter(Boolean);if(n.length===0)return r;let s=-1;for(let u=0;u<=o.length-n.length;u++){let m=!0;for(let y=0;y<n.length;y++)if(o[u+y].toLowerCase()!==n[y].toLowerCase()){m=!1;break}if(m){s=u;break}}if(s===-1)return r;let a=[...r.slice(0,s),...t,...r.slice(s+n.length)],p=new Set;return a.filter(u=>{let m=`${u}`;return p.has(m)?!1:(p.add(m),!0)})},ui=(r,e,t)=>{let i=new RegExp(Pt(e),"gi");return`${r}`.replace(i,t)},mi=r=>typeof r=="string"?r.replace(/(\r\n|\n|\r)/gm,""):r,di=(r,e)=>e?e.map((t,i)=>r.map(o=>({rowIndex:i,valid:!0,key:o.key,value:t[o.key]}))):[];var z=class r extends f{constructor({description:t,key:i,example:o,label:n,type:s,options:a,validators:p,alternativeMatches:u,columnSize:m,isMultiSelection:y,allowCustomOptions:T,allowedCustomOptionTypes:M,preserveUnmappedOptions:E,creator:C,baseKey:x,baseKeyCounter:S,hidden:O,optionMappingConfiguration:P,...R}){super({description:t,key:i,example:o,label:n,type:s,validators:p,alternativeMatches:u,columnSize:m,creator:C,baseKey:x,baseKeyCounter:S,hidden:O,optionMappingConfiguration:P,...R});this.optionTypeMap=null;this.getOptions=()=>this.options;this.getOptionTypeMap=()=>{if(!this.optionTypeMap){this.optionTypeMap=new Map;for(let t=0;t<this.options.length;t++){let i=this.options[t];this.optionTypeMap.set(i.value,i.type??"string")}}return this.optionTypeMap};this.setOptions=t=>{this.options=t,this.optionTypeMap=null};this.serialize=()=>{let t={description:this.getDescription(),example:this.getExample(),isRequired:this.getIsRequired(),key:this.getKey(),label:this.getLabel(),type:this.getType(),validators:this.getValidators().map(o=>o.serialize()),alternativeMatches:this.getAlternativeMatches(),columnSize:this.getColumnSize(),columnWidth:this.getColumnWidth(),outputFormat:this.getOutputFormat(),inputFormat:this.getInputFormat(),numberFormat:this.getNumberFormat(),baseKey:this.getBaseKey(),baseKeyCounter:this.getBaseKeyCounter(),creator:this.getCreator(),hidden:this.isHidden(),disabled:this.isDisabled(),optionMappingConfiguration:this.getOptionMappingConfiguration(),excludeFromAutoMatching:this.isExcludedFromAutoMatching()},i=this.getOptions();return{...t,options:i,isMultiSelection:this.isMultiSelection,allowCustomOptions:this.allowCustomOptions,allowedCustomOptionTypes:this.allowedCustomOptionTypes?[...this.allowedCustomOptionTypes]:void 0,preserveUnmappedOptions:this.preserveUnmappedOptions}};this.getIsMultiSelection=()=>this.isMultiSelection;this.getAllowCustomOptions=()=>this.allowCustomOptions;this.getAllowedCustomOptionTypes=()=>this.allowedCustomOptionTypes?[...this.allowedCustomOptionTypes]:void 0;this.getPreserveUnmappedOptions=()=>this.preserveUnmappedOptions;this.options=a?.map(c=>({...c,baseKey:c?.baseKey||c.value,baseKeyCounter:c.baseKeyCounter||0,alternativeMatches:c.alternativeMatches.filter(Se=>Se!==c.label),validations:c.validations||[]})),this.isMultiSelection=y,this.allowCustomOptions=T,this.allowedCustomOptionTypes=M?[...M]:void 0,this.preserveUnmappedOptions=E}clone(){let t=this.serialize();return new r({description:t.description,example:t.example,key:t.key,label:t.label,type:t.type,options:t.options,validators:this.getValidators(),alternativeMatches:t.alternativeMatches,columnSize:t.columnSize,columnWidth:t.columnWidth,isMultiSelection:t.isMultiSelection,allowCustomOptions:t.allowCustomOptions,allowedCustomOptionTypes:t.allowedCustomOptionTypes,preserveUnmappedOptions:t.preserveUnmappedOptions,hidden:t.hidden,disabled:t.disabled,optionMappingConfiguration:t.optionMappingConfiguration,excludeFromAutoMatching:t.excludeFromAutoMatching})}},Ti=z;export{Cr as a,xr as b,Sr as c,Rt as d,f as e,xe as f,Yt as g,se as h,wt as i,ai as j,li as k,pi as l,ui as m,mi as n,di as o,Ti as p};
@@ -1 +1 @@
1
- import{d as F}from"./chunk-JWTYPSUX.js";import{f as O,r as J,s as M,t as C,u as V}from"./chunk-3A4DOV33.js";import{c}from"./chunk-EWEVS5OB.js";import{isEmpty as x,uniq as k}from"lodash";var A=0,y=class{constructor({sheet:e,columnKey:t,rows:s,columnIndex:n,id:r,label:i,refJoinSheetColum:o,parserDateFormat:l}){this.removed=!1;this.label="";this.rowsLoaded=!1;this.parserDateFormatResolved=!1;this.dateInputFormatSamples=null;this.parsedDateSamplesByInputFormat=new Map;this.getColumnKey=()=>this.columnKey;this.getId=()=>this.id;this.getSheet=()=>this.sheet;this.loadRows=()=>{if(this.rowsLoaded||this.columnIndex==null)return;let e=this.sheet.readColumnValues(this.columnIndex);this.rows=x(e)?[""]:e,this.dateInputFormatSamples??=this.rows,this.rowsLoaded=!0};this.getRows=()=>(this.loadRows(),this.rows);this.peekRows=e=>{if(e<=0)return[];if(this.rowsLoaded||this.columnIndex==null)return this.getRows().slice(0,e);let t=this.sheet.readColumnValues(this.columnIndex,e);return x(t)?[""]:t};this.getUniqueRows=()=>(this.uniques===void 0&&(this.uniques=k(this.getRows())),this.uniques);this.remove=()=>{this.removed=!0};this.unRemove=()=>{this.removed=!1};this.isRemoved=()=>this.removed;this.getType=()=>0;this.getFileName=()=>this.sheet.getSheetFileName();this.toJSON=()=>({columnKey:this.columnKey,id:this.id,rows:this.getRows(),type:this.getType()});this.equal=e=>this.getId()===e.getId();this.keyEqual=e=>this.columnKey===e.columnKey;this.setIndex=e=>{this.index=e};this.getIndex=()=>this.index;this.normalizeInputFormatKey=e=>{let t=typeof e=="string"?e.trim():"";return t!==""?t:null};this.dateInputFormatCacheKey=e=>this.normalizeInputFormatKey(e)??"\0auto";this.needsDateFormatParse=e=>!this.parsedDateSamplesByInputFormat.has(this.dateInputFormatCacheKey(e));this.hasParsedDateForInputFormat=e=>!this.needsDateFormatParse(e);this.getParsedDateSamplesForInputFormat=e=>this.parsedDateSamplesByInputFormat.get(this.dateInputFormatCacheKey(e));this.getDateInputFormatSamples=()=>{if(this.dateInputFormatSamples)return this.dateInputFormatSamples;if(this.columnIndex!=null){let e=this.sheet.readColumnValues(this.columnIndex);return this.dateInputFormatSamples=x(e)?[""]:e,this.dateInputFormatSamples}return this.rows};this.getParserDateFormat=()=>(!this.parserDateFormatResolved&&this.columnIndex!=null&&(this.parserDateFormat=this.sheet.excelDisplayFormatAt(this.columnIndex),this.parserDateFormatResolved=!0),this.parserDateFormat);this.applyDateInputFormatParse=(e,t)=>{let s=this.getDateInputFormatSamples();if(e.length!==s.length)throw new Error(`SheetColumn.applyDateInputFormatParse: parsed sample count (${e.length}) must match source sample count (${s.length}) for column "${this.columnKey}".`);this.parsedDateSamplesByInputFormat.set(this.dateInputFormatCacheKey(t),this.withStoredExcelDates(e))};this.getStoredDateSerialAt=e=>{if(this.columnIndex!=null)return this.sheet.readDateSerialAt(this.columnIndex,e)};this.getStoredDateSerials=()=>{if(this.columnIndex!=null)return this.sheet.readColumnDateSerials(this.columnIndex)};this.withStoredExcelDates=e=>{let t=this.getStoredDateSerials();return!t||t.length!==e.length?e:e.map((s,n)=>{let r=t[n];return r==null?s:O(r)})};this.getRefJoinSheetColum=()=>this.refJoinSheetColum;this.columnKey=t.trim(),this.sheet=e,Object.defineProperty(this,"sheet",{value:e,enumerable:!1,writable:!0,configurable:!0}),n!=null&&s==null?(this.columnIndex=n,this.rows=[],this.rowsLoaded=!1):(this.rows=x(s)?[""]:s,this.rowsLoaded=!0,this.dateInputFormatSamples=[...this.rows]),typeof r>"u"?(A++,this.id=`${t}-${A}`):this.id=r,i&&(this.label=i),l&&(this.parserDateFormat=l,this.parserDateFormatResolved=!0),Object.defineProperty(this,"refJoinSheetColum",{value:o,enumerable:!1,writable:!0,configurable:!0})}setRows(e){this.rows=e,this.rowsLoaded=!0,this.uniques=void 0}},g=y;var w=class extends g{constructor({sheet:t,sheetColumns:s,rows:n,id:r,columnKey:i}){super({columnKey:i,rows:n,sheet:t,id:r});this.getType=()=>1;this.getJoinedSheetColumns=()=>this.sheetColumns;this.toJSON=()=>({columnKey:this.columnKey,id:this.id,rows:this.rows,sheetColumns:this.sheetColumns.map(t=>t.toJSON()),type:this.getType()});this.sheetColumns=s}},H=w;var T=["?",",","@"];import{isNaN as z,minBy as q,isString as Y,isEqual as R,isEmpty as B,isNil as G}from"lodash";var D=class{constructor({sheets:e,filename:t,type:s,fileSize:n}){this.globalNumberFormat="eu";this.columnsNumberFormat=[];this.needsConfiguration=!1;this.pendingXmlConfigKey=null;this.pendingXmlConfig=null;this.sourceXml=null;this.sourcePdfFile=null;this.pdfDocument=null;this.selectedPdfTableIds=null;this.pdfModelOutput=null;this.pdfInstructionHistory=null;this.pdfReshapeSessionId=null;this.keepSheetSelection=!1;this.addSheet=e=>{this.sheets.push(e)};this.setNeedsConfiguration=e=>{this.needsConfiguration=e};this.getNeedsConfiguration=()=>this.needsConfiguration;this.setPendingXmlConfigKey=e=>{this.pendingXmlConfigKey=e};this.getPendingXmlConfigKey=()=>this.pendingXmlConfigKey;this.setPendingXmlConfig=e=>{this.pendingXmlConfig=e};this.getPendingXmlConfig=()=>this.pendingXmlConfig;this.setSourceXml=e=>{this.sourceXml=e};this.getSourceXml=()=>this.sourceXml;this.setSourcePdfFile=e=>{this.sourcePdfFile=e};this.getSourcePdfFile=()=>this.sourcePdfFile;this.setPdfDocument=e=>{this.pdfDocument=e};this.getPdfDocument=()=>this.pdfDocument;this.setSelectedPdfTableIds=e=>{this.selectedPdfTableIds=e};this.getSelectedPdfTableIds=()=>this.selectedPdfTableIds;this.setPdfModelOutput=e=>{this.pdfModelOutput=e};this.getPdfModelOutput=()=>this.pdfModelOutput;this.setPdfInstructionHistory=e=>{this.pdfInstructionHistory=e};this.getPdfInstructionHistory=()=>this.pdfInstructionHistory;this.setPdfReshapeSessionId=e=>{this.pdfReshapeSessionId=e};this.getPdfReshapeSessionId=()=>this.pdfReshapeSessionId;this.setKeepSheetSelection=e=>{this.keepSheetSelection=e};this.getKeepSheetSelection=()=>this.keepSheetSelection;this.replaceSheets=e=>{let t=this.needsConfiguration||!!this.pendingXmlConfigKey||!!this.pendingXmlConfig||!!this.sourceXml,s=!!this.sourcePdfFile||!!this.pdfDocument;this.sheets=e,this.sheets.forEach(n=>{n.setSpreadSheet(this)}),this.needsConfiguration=!1,this.pendingXmlConfigKey=null,t?this.keepSheetSelection=!0:s||(this.pendingXmlConfig=null,this.sourceXml=null),s&&(this.keepSheetSelection=!0)};this.isSelected=()=>{for(let e=0;e<this.sheets.length;e++)if(this.sheets[e].isSelected())return!0;return!1};this.getSheets=()=>this.sheets;this.getSelectedSheets=()=>this.sheets.filter(e=>e.isSelected());this.getFilename=()=>this.filename;this.selectAllSheet=e=>this.sheets.forEach(t=>{t.setSelected(e)});this.getType=()=>this.type;this.setType=e=>{this.type=e};this.getFileSize=()=>{let e=this.fileSize/1e6;return Number(parseFloat(`${e}`).toFixed(4))};this.sheets=e,this.filename=t,this.type=s,this.fileSize=n??0,this.sheets.forEach(r=>{r.setSpreadSheet(this)})}setNumberFormat(e){this.globalNumberFormat=e.global,this.columnsNumberFormat=e.columns}getNumberFormat(){return{global:this.globalNumberFormat,columns:this.columnsNumberFormat}}},P=D;var U={dmy:"D/M/YYYY",us:"M/D/YY",de:"DD.MM.YYYY"},K=(u,e)=>u?M(u,C(e)):void 0,_=u=>{let e=C(u);return e==="os"?J():U[e]},fe=({data:u,excelDateCells:e,columnDateFormats:t,maxRow:s=50,maxCol:n=300})=>{let r=Math.min(u.length,s),i=u.slice(0,r).map(o=>o.slice(0,n));return V(i,e,o=>C(t?.[o]))};var L=0,b=class{constructor({data:e,name:t,isNotSetColumn:s,id:n,columnDateFormats:r,excelDateCells:i,excelDateSerials:o}){this.selected=!1;this.isManualSelectHeader=!1;this.columns=[];this.columnsInitialized=!1;this.headerRowIndex=0;this.transposed=!1;this.headerRowIndexes=[];this.addedColumns=[];this.usedSourceCells=new Set;this.mergedHeadersActive=!1;this.mergedRowsBackup=null;this.availableRows=null;this.spreadSheet=new P({filename:"",sheets:[],type:"xlsx",fileSize:0});this.getId=()=>this.id;this.setSpreadSheet=e=>{this.spreadSheet=e};this.getSpreadSheet=()=>this.spreadSheet;this.setSelected=e=>{this.selected=e};this.isSelected=()=>this.selected;this.setHeaderRowIndex=e=>{this.headerRowIndex=e,this.columnsInitialized=!1,this.mergedHeadersActive||(this.headerRowIndexes=[e])};this.setTransposed=e=>{this.transposed=e};this.getTransposed=()=>this.transposed;this.setHeaderRowIndexes=e=>{this.headerRowIndexes=[...e]};this.getHeaderRowIndexes=()=>this.headerRowIndexes.length>0?this.headerRowIndexes:[this.headerRowIndex];this.addAddedColumn=e=>{if(this.addedColumns.push(e),e.sourceCell){let n=`${e.sourceCell.row},${e.sourceCell.col}`;this.usedSourceCells.add(n)}let t=this.data[this.headerRowIndex],s=this.data.length>0?Math.max(...this.data.map(n=>n.length)):0;t&&t.push(e.columnName);for(let n=0;n<this.data.length;n++)if(n!==this.headerRowIndex){for(;this.data[n].length<s;)this.data[n].push("");n<this.headerRowIndex?this.data[n].push(""):this.data[n].push(e.value)}this.setColumns()};this.removeAddedColumn=e=>{let s=(this.data[this.headerRowIndex]?.length||0)-this.addedColumns.length,n=e-s;if(n<0||n>=this.addedColumns.length)return;let r=this.addedColumns[n];if(r?.sourceCell){let i=`${r.sourceCell.row},${r.sourceCell.col}`;this.usedSourceCells.delete(i)}for(let i=0;i<this.data.length;i++)this.data[i].splice(e,1);this.addedColumns.splice(n,1),this.setColumns()};this.removeColumnFromData=e=>{if(!(e<0)){for(let t=0;t<this.data.length;t++)this.data[t].length>e&&this.data[t].splice(e,1);this.clearExcelDateMetadata()}};this.clearAddedColumns=()=>{if(this.addedColumns.length>0){let t=(this.data[this.headerRowIndex]?.length||0)-this.addedColumns.length;for(let s=this.addedColumns.length-1;s>=0;s--){let n=t+s;for(let r=0;r<this.data.length;r++)this.data[r].length>n&&this.data[r].splice(n,1)}}this.addedColumns=[],this.usedSourceCells.clear(),this.setColumns()};this.isSourceCellUsed=(e,t)=>{let s=`${e},${t}`;return this.usedSourceCells.has(s)};this.getAddedColumnBySourceCell=(e,t)=>this.addedColumns.find(s=>s.sourceCell&&s.sourceCell.row===e&&s.sourceCell.col===t);this.getAddedColumns=()=>this.addedColumns;this.setMergedHeadersActive=e=>{this.mergedHeadersActive=e};this.isMergedHeadersActive=()=>this.mergedHeadersActive;this.setMergedRowsBackup=e=>{this.mergedRowsBackup=e};this.getMergedRowsBackup=()=>this.mergedRowsBackup;this.setAvailableRows=e=>{this.availableRows=e};this.getAvailableRows=()=>this.availableRows;this.isLoneWhitelistCharacter=e=>{let t=e.toString()?.trim()??"";return T.some(s=>t===s)};this.isSignificantCell=e=>!B(e)&&!this.isLoneWhitelistCharacter(e);this.collapseAdjacentDuplicates=e=>e.filter((t,s)=>s===0||`${t}`!=`${e[s-1]}`);this.getSignificantCells=e=>{let t=(e??[]).filter(this.isSignificantCell);return this.collapseAdjacentDuplicates(t)};this.getDataTransform=()=>this.data.map((e,t)=>({data:e,index:t,length:this.getSignificantCells(e).length}));this.getMaxLengthColumns=()=>this.getDataTransform().reduce((t,s)=>Math.max(t,s.length),0);this.isHeaderLikeCell=e=>!F.includes(Y(e)?e.toLowerCase():e)&&z(Number(e));this.countHeaderLikeCells=e=>this.getSignificantCells(e).filter(this.isHeaderLikeCell).length;this.setHeaderByAutoDetection=()=>{let t=this.getMaxLengthColumns(),s=this.getDataTransform().slice(0,50).filter(r=>r.length===t&&this.countHeaderLikeCells(r.data)===t),n=s.length===1?s[0].index:q(s,r=>r.length)?.index??0;this.setHeaderRowIndex(n)};this.getHeaderRowIndex=()=>this.headerRowIndex;this.getHeaderRow=()=>this.data[this.headerRowIndex]?.filter(e=>!!e);this.getColumns=()=>(this.ensureColumnsBuilt(),this.columns.filter(e=>!e.isRemoved()));this.getSortedColumns=()=>[...this.getColumns()].sort((e,t)=>c(e.getColumnKey())<c(t.getColumnKey())?-1:c(e.getColumnKey())>c(t.getColumnKey())?1:0);this.getColumnsWithRemoved=()=>(this.ensureColumnsBuilt(),this.columns.filter(e=>e.getType()!==1));this.getColumn=(e,t)=>(this.ensureColumnsBuilt(),this.columns.find(s=>t?c(s.getColumnKey())===c(`${e}`):s.getColumnKey()===e));this.getColumnsByKey=(e,t)=>(this.ensureColumnsBuilt(),this.columns.filter(s=>t?c(s.getColumnKey())===c(`${e}`):s.getColumnKey()===e));this.getValues=()=>{let e=this.data.filter((s,n)=>n>this.headerRowIndex);if(B(e))return[[]];let t=[];for(let s=0;s<e.length;s++){let n=[];for(let r=0;r<this.data[this.headerRowIndex].length;r++)G(this.data[this.headerRowIndex][r])||n.push(this.parseValue(e[s][r]));t.push(n)}return t};this.getData=()=>this.data;this.getExcelDateCells=()=>this.excelDateCells;this.getExcelDateSerials=()=>this.excelDateSerials;this.getColumnDateFormats=()=>this.columnDateFormats;this.getName=()=>this.name;this.getDisplayName=({t:e})=>{if(this.getName()?.length>0)return this.getName();switch(this.spreadSheet.getType()){case"json":return`${e("txt_default_sheet_prefix_name")} 1`;case"csv":return`${e("txt_default_sheet_prefix_name")} 1`;default:return""}};this.getSheetFileName=()=>`${this.spreadSheet.getFilename()}`;this.getIsManualSelectHeader=()=>this.isManualSelectHeader;this.setIsManualSelectHeader=()=>{this.isManualSelectHeader=!0};this.clearIsManualSelectHeader=()=>{this.isManualSelectHeader=!1};this.addColumn=e=>{this.ensureColumnsBuilt(),this.columns.push(new g({columnKey:`${e}`,sheet:this,rows:this.getRowsByColumnIndex(this.getColumnIndex(e))}))};this.removeColumn=e=>{this.ensureColumnsBuilt(),this.columns.find(t=>t.getColumnKey()===e)?.remove()};this.removeColumnByIndex=e=>{this.ensureColumnsBuilt(),this.columns.find((t,s)=>s===e)?.remove()};this.setData=(e,t)=>{if(t!=null&&t!==this&&(e===t.getData()||R(e,t.getData()))&&(t.columnDateFormats!=null||t.excelDateCells!=null||t.excelDateSerials!=null)){this.data=e,this.columnDateFormats=t.columnDateFormats,this.excelDateCells=t.excelDateCells,this.excelDateSerials=t.excelDateSerials;return}if(e===this.data||R(e,this.data)){this.data=e;return}this.data=e,this.clearExcelDateMetadata()};this.clearExcelDateMetadata=()=>{this.columnDateFormats=void 0,this.excelDateCells=void 0,this.excelDateSerials=void 0};this.toJSON=()=>({name:this.name,id:this.id,type:this.getType(),values:this.getValues(),headerRow:this.getHeaderRow()});this.equal=e=>this.id===e.getId();this.getType=()=>0;this.readColumnValues=(e,t)=>this.getRowsByColumnIndex(e,t);this.readDateSerialAt=(e,t)=>{if(!this.excelDateSerials||e<0||t<0)return;let s=this.headerRowIndex+1+t;if(!(s>=this.data.length))return this.excelDateSerials[`${s},${e}`]};this.readColumnDateSerials=e=>{if(!this.excelDateSerials||e===-1)return;let t=[],s=!1;for(let n=0;n<this.data.length-this.headerRowIndex-1;n++){let r=this.readDateSerialAt(e,n);r!=null&&(s=!0),t.push(r)}return s?t:void 0};this.excelDisplayFormatAt=e=>this.getExcelDisplayInputFormat(e);this.getRowsByColumnIndex=(e,t)=>{if(e===-1)return[];let s=[],n=this.columnDateFormats?.[e];for(let r=0;r<this.data.length;r++){let i=this.data[r];if(r>this.headerRowIndex){let o=i[e]??"",l=K(this.excelDateCells?.[`${r},${e}`],n);if(s.push(l??this.parseValue(o)),t!=null&&s.length>=t)break}}return s};this.getExcelDisplayInputFormat=e=>{if(!this.excelDateCells)return;let t=!1;for(let s=this.headerRowIndex+1;s<this.data.length;s++)if((this.data[s]?.[e]??"")!==""){if(!this.excelDateCells[`${s},${e}`])return;t=!0}return t?_(this.columnDateFormats?.[e]):void 0};this.ensureColumnsBuilt=()=>{this.columnsInitialized||this.setColumns()};this.setColumns=()=>{let e=this.data[this.headerRowIndex];if(e){let t=[];for(let s=0;s<e.length;++s){let n=e[s];n&&t.push(new g({columnKey:`${n}`,sheet:this,columnIndex:s,parserDateFormat:this.columnDateFormats?.[s]}))}this.columns=t}else this.columns=[];this.columnsInitialized=!0};this.getColumnIndex=e=>this.data[this.headerRowIndex].findIndex(n=>R(`${n}`,`${e}`));this.parseValue=e=>typeof e=="string"?e.trim():e;this.data=e,this.name=t,this.columnDateFormats=r,this.excelDateCells=i,this.excelDateSerials=o,typeof n>"u"?(L++,this.id=`${t}-${L}`):this.id=n,this.columnsInitialized=!!s}},E=b;var v=class extends E{constructor({joinedData:t,sheets:s,mappings:n,mappingIndexes:r}){super({data:t.data,name:"join-sheet",isNotSetColumn:!0});this.sheets=[];this.joinHistory=[];this.findRefJoinSheetColumn=t=>{let s=this.sheets.length===2?this.sheets[0]:this,n=this.sheets[this.sheets.length-1];if(t<s.getColumns().length)return s.getColumns()[t];let r=t-s.getColumns().length;return n.getColumns().filter((i,o)=>this.joinHistory[this.joinHistory.length-1].mappingIndexes.every(l=>l.target!==o))[r]};this.setJoinColumns=(t,s)=>{let n=this.data[this.headerRowIndex];if(!n){this.columns=[];return}let r=[];for(let i=0;i<n.length;++i){let o=n[i],l=s.findIndex(a=>a.source===i),m=this.columns[i]&&this.columns[i].getType()===1;if(l>=0||m){let a=t[l],h;m&&l>=0?h=[...this.columns[i].getJoinedSheetColumns(),a.target]:m?h=this.columns[i].getJoinedSheetColumns():h=[a.source.getRefJoinSheetColum()??a.source,a.target],r.push(new H({columnKey:`${o}`,sheetColumns:h,sheet:this,rows:this.getRowsByColumnIndex(i)}))}else{let a=this.columns[i]?this.columns[i].getRefJoinSheetColum()??this.columns[i]:this.findRefJoinSheetColumn(i);r.push(new g({columnKey:`${o}`,sheet:a.getSheet(),rows:this.getRowsByColumnIndex(i),refJoinSheetColum:a}))}}this.columns=r};this.getJoinedSheets=()=>this.sheets;this.getType=()=>1;this.joinSheet=(t,s,n,r)=>{this.setData(t.data),this.sheets.push(s),this.joinHistory.push({mappingIndexes:r,type:t.type,row:t.data.length,col:this.data[this.headerRowIndex]?.length??0}),this.setJoinColumns(n,r)};this.getJoinColumns=()=>this.columns.filter(t=>t.getType()===1);this.getJoinHistory=()=>this.joinHistory;this.headerRowIndex=0,this.joinHistory.push({mappingIndexes:r,type:t.type,row:t.data.length,col:this.data[this.headerRowIndex]?.length??0}),this.sheets=s,this.setJoinColumns(n,r)}},Ve=v;var Q=({rowA:u,rowB:e},t)=>t.every(s=>{let n=`${u[s.source]??""}`,r=`${e[s.target]??""}`;return n===r&&n!==""&&r!==""}),$=(u,e,t)=>{let s=[];for(let n of e){let r=`${u[n[t]]??""}`;if(r==="")return"";s.push(r)}return JSON.stringify(s)},Z=(u,e,t)=>{let s=[],n=u.headerRow,r=e.headerRow;for(let i=0;i<n.length;++i)s.push(n[i]);for(let i=0;i<r.length;++i)t.every(o=>o.target!==i)&&s.push(r[i]);return s},Ke=async(u,e)=>{let t=u.values,s=e.values,n=u.headerRow,r=e.headerRow,i=[...n,...r],o=[];o.push(i);for(let l=0;l<t.length;++l)o.push([...t[l],...s[0]]);return{data:o,type:"ADD_TO_ALL_ROWS"}},_e=async(u,e)=>{let t=u.values,s=e.values,n=u.headerRow,r=e.headerRow,i=[...n,...r],o=[];o.push(i);for(let l=0;l<t.length;++l)o.push([...t[l],...r.map(()=>"")]);for(let l=0;l<s.length;++l)o.push([...n.map(()=>""),...s[l]]);return{data:o,type:"JOIN_WITHOUT_COLUMNS"}},Be=async(u,e,t)=>{let s=u.values,n=e.values,r=[],i=[],o={},l=Z(u,e,t);r.push(l);let m=new Map;for(let a=0;a<n.length;++a){let h=$(n[a],t,"target");if(!h)continue;let d=m.get(h);d?d.push(a):m.set(h,[a])}for(let a=0;a<s.length;++a){let h=!1,d=s[a],p=$(d,t,"source");for(let f of p&&m.get(p)||[]){let S=n[f];o[f]=!0,h=!0,r.push([...d,...S.filter((N,j)=>t.every(X=>X.target!==j))])}h||i.push([...d,...e.headerRow.filter((f,S)=>t.every(N=>N.target!==S)).map(()=>"")])}for(let a=0;a<n.length;++a){if(o[a])continue;let h=n[a],d=u.headerRow.map(()=>"");t.forEach(p=>{d[p.source]=h[p.target]}),i.push([...d,...h.filter((p,f)=>t.every(S=>S.target!==f))])}return i.forEach(a=>{r.push(a)}),{data:r,type:"JOIN_ON_COLUMNS"}},Le=async(u,e,t)=>{let s=e.headerRow.filter((o,l)=>t.every(m=>m.target!==l)),r=[[...u.headerRow,...s]];for(let o=0;o<u.values.length;++o){let l=[...u.values[o],...s.map(()=>"")];r.push(l)}let i=e.values;for(let o=0;o<i.length;++o){let l=u.headerRow.map(()=>""),m=[];for(let a=0;a<e.headerRow.length;++a){let h=t.find(d=>d.target===a);h?l[h.source]=i[o][a]:m.push(i[o][a])}r.push([...l,...m])}return{data:r,type:"APPEND_TO_COLUMNS"}},Ee=async(u,e,t)=>{let s=u.values,n=e.values,r=s.length+n.length,i=0,o={};for(let l=0;l<s.length;l++){let m=s[l],a=null,h=0;for(let d=0;d<n.length;d++){let p=n[d];if(Q({rowA:m,rowB:p},t)&&(a=d,h++,h===2))break}h===1&&a!==null&&(i+=1,o[a]=!0)}for(let l=0;l<n.length;l++)o[l]&&(i+=1);return{count:i,total:r}};export{g as a,P as b,fe as c,E as d,Ve as e,$ as f,Ke as g,_e as h,Be as i,Le as j,Ee as k};
1
+ import{d as F}from"./chunk-JWTYPSUX.js";import{f as O,r as J,s as M,t as C,u as V}from"./chunk-DNCQE4OX.js";import{c}from"./chunk-EWEVS5OB.js";import{isEmpty as x,uniq as k}from"lodash";var A=0,y=class{constructor({sheet:e,columnKey:t,rows:s,columnIndex:n,id:r,label:i,refJoinSheetColum:o,parserDateFormat:l}){this.removed=!1;this.label="";this.rowsLoaded=!1;this.parserDateFormatResolved=!1;this.dateInputFormatSamples=null;this.parsedDateSamplesByInputFormat=new Map;this.getColumnKey=()=>this.columnKey;this.getId=()=>this.id;this.getSheet=()=>this.sheet;this.loadRows=()=>{if(this.rowsLoaded||this.columnIndex==null)return;let e=this.sheet.readColumnValues(this.columnIndex);this.rows=x(e)?[""]:e,this.dateInputFormatSamples??=this.rows,this.rowsLoaded=!0};this.getRows=()=>(this.loadRows(),this.rows);this.peekRows=e=>{if(e<=0)return[];if(this.rowsLoaded||this.columnIndex==null)return this.getRows().slice(0,e);let t=this.sheet.readColumnValues(this.columnIndex,e);return x(t)?[""]:t};this.getUniqueRows=()=>(this.uniques===void 0&&(this.uniques=k(this.getRows())),this.uniques);this.remove=()=>{this.removed=!0};this.unRemove=()=>{this.removed=!1};this.isRemoved=()=>this.removed;this.getType=()=>0;this.getFileName=()=>this.sheet.getSheetFileName();this.toJSON=()=>({columnKey:this.columnKey,id:this.id,rows:this.getRows(),type:this.getType()});this.equal=e=>this.getId()===e.getId();this.keyEqual=e=>this.columnKey===e.columnKey;this.setIndex=e=>{this.index=e};this.getIndex=()=>this.index;this.normalizeInputFormatKey=e=>{let t=typeof e=="string"?e.trim():"";return t!==""?t:null};this.dateInputFormatCacheKey=e=>this.normalizeInputFormatKey(e)??"\0auto";this.needsDateFormatParse=e=>!this.parsedDateSamplesByInputFormat.has(this.dateInputFormatCacheKey(e));this.hasParsedDateForInputFormat=e=>!this.needsDateFormatParse(e);this.getParsedDateSamplesForInputFormat=e=>this.parsedDateSamplesByInputFormat.get(this.dateInputFormatCacheKey(e));this.getDateInputFormatSamples=()=>{if(this.dateInputFormatSamples)return this.dateInputFormatSamples;if(this.columnIndex!=null){let e=this.sheet.readColumnValues(this.columnIndex);return this.dateInputFormatSamples=x(e)?[""]:e,this.dateInputFormatSamples}return this.rows};this.getParserDateFormat=()=>(!this.parserDateFormatResolved&&this.columnIndex!=null&&(this.parserDateFormat=this.sheet.excelDisplayFormatAt(this.columnIndex),this.parserDateFormatResolved=!0),this.parserDateFormat);this.applyDateInputFormatParse=(e,t)=>{let s=this.getDateInputFormatSamples();if(e.length!==s.length)throw new Error(`SheetColumn.applyDateInputFormatParse: parsed sample count (${e.length}) must match source sample count (${s.length}) for column "${this.columnKey}".`);this.parsedDateSamplesByInputFormat.set(this.dateInputFormatCacheKey(t),this.withStoredExcelDates(e))};this.getStoredDateSerialAt=e=>{if(this.columnIndex!=null)return this.sheet.readDateSerialAt(this.columnIndex,e)};this.getStoredDateSerials=()=>{if(this.columnIndex!=null)return this.sheet.readColumnDateSerials(this.columnIndex)};this.withStoredExcelDates=e=>{let t=this.getStoredDateSerials();return!t||t.length!==e.length?e:e.map((s,n)=>{let r=t[n];return r==null?s:O(r)})};this.getRefJoinSheetColum=()=>this.refJoinSheetColum;this.columnKey=t.trim(),this.sheet=e,Object.defineProperty(this,"sheet",{value:e,enumerable:!1,writable:!0,configurable:!0}),n!=null&&s==null?(this.columnIndex=n,this.rows=[],this.rowsLoaded=!1):(this.rows=x(s)?[""]:s,this.rowsLoaded=!0,this.dateInputFormatSamples=[...this.rows]),typeof r>"u"?(A++,this.id=`${t}-${A}`):this.id=r,i&&(this.label=i),l&&(this.parserDateFormat=l,this.parserDateFormatResolved=!0),Object.defineProperty(this,"refJoinSheetColum",{value:o,enumerable:!1,writable:!0,configurable:!0})}setRows(e){this.rows=e,this.rowsLoaded=!0,this.uniques=void 0}},g=y;var w=class extends g{constructor({sheet:t,sheetColumns:s,rows:n,id:r,columnKey:i}){super({columnKey:i,rows:n,sheet:t,id:r});this.getType=()=>1;this.getJoinedSheetColumns=()=>this.sheetColumns;this.toJSON=()=>({columnKey:this.columnKey,id:this.id,rows:this.rows,sheetColumns:this.sheetColumns.map(t=>t.toJSON()),type:this.getType()});this.sheetColumns=s}},H=w;var T=["?",",","@"];import{isNaN as z,minBy as q,isString as Y,isEqual as R,isEmpty as B,isNil as G}from"lodash";var D=class{constructor({sheets:e,filename:t,type:s,fileSize:n}){this.globalNumberFormat="eu";this.columnsNumberFormat=[];this.needsConfiguration=!1;this.pendingXmlConfigKey=null;this.pendingXmlConfig=null;this.sourceXml=null;this.sourcePdfFile=null;this.pdfDocument=null;this.selectedPdfTableIds=null;this.pdfModelOutput=null;this.pdfInstructionHistory=null;this.pdfReshapeSessionId=null;this.keepSheetSelection=!1;this.addSheet=e=>{this.sheets.push(e)};this.setNeedsConfiguration=e=>{this.needsConfiguration=e};this.getNeedsConfiguration=()=>this.needsConfiguration;this.setPendingXmlConfigKey=e=>{this.pendingXmlConfigKey=e};this.getPendingXmlConfigKey=()=>this.pendingXmlConfigKey;this.setPendingXmlConfig=e=>{this.pendingXmlConfig=e};this.getPendingXmlConfig=()=>this.pendingXmlConfig;this.setSourceXml=e=>{this.sourceXml=e};this.getSourceXml=()=>this.sourceXml;this.setSourcePdfFile=e=>{this.sourcePdfFile=e};this.getSourcePdfFile=()=>this.sourcePdfFile;this.setPdfDocument=e=>{this.pdfDocument=e};this.getPdfDocument=()=>this.pdfDocument;this.setSelectedPdfTableIds=e=>{this.selectedPdfTableIds=e};this.getSelectedPdfTableIds=()=>this.selectedPdfTableIds;this.setPdfModelOutput=e=>{this.pdfModelOutput=e};this.getPdfModelOutput=()=>this.pdfModelOutput;this.setPdfInstructionHistory=e=>{this.pdfInstructionHistory=e};this.getPdfInstructionHistory=()=>this.pdfInstructionHistory;this.setPdfReshapeSessionId=e=>{this.pdfReshapeSessionId=e};this.getPdfReshapeSessionId=()=>this.pdfReshapeSessionId;this.setKeepSheetSelection=e=>{this.keepSheetSelection=e};this.getKeepSheetSelection=()=>this.keepSheetSelection;this.replaceSheets=e=>{let t=this.needsConfiguration||!!this.pendingXmlConfigKey||!!this.pendingXmlConfig||!!this.sourceXml,s=!!this.sourcePdfFile||!!this.pdfDocument;this.sheets=e,this.sheets.forEach(n=>{n.setSpreadSheet(this)}),this.needsConfiguration=!1,this.pendingXmlConfigKey=null,t?this.keepSheetSelection=!0:s||(this.pendingXmlConfig=null,this.sourceXml=null),s&&(this.keepSheetSelection=!0)};this.isSelected=()=>{for(let e=0;e<this.sheets.length;e++)if(this.sheets[e].isSelected())return!0;return!1};this.getSheets=()=>this.sheets;this.getSelectedSheets=()=>this.sheets.filter(e=>e.isSelected());this.getFilename=()=>this.filename;this.selectAllSheet=e=>this.sheets.forEach(t=>{t.setSelected(e)});this.getType=()=>this.type;this.setType=e=>{this.type=e};this.getFileSize=()=>{let e=this.fileSize/1e6;return Number(parseFloat(`${e}`).toFixed(4))};this.sheets=e,this.filename=t,this.type=s,this.fileSize=n??0,this.sheets.forEach(r=>{r.setSpreadSheet(this)})}setNumberFormat(e){this.globalNumberFormat=e.global,this.columnsNumberFormat=e.columns}getNumberFormat(){return{global:this.globalNumberFormat,columns:this.columnsNumberFormat}}},P=D;var U={dmy:"D/M/YYYY",us:"M/D/YY",de:"DD.MM.YYYY"},K=(u,e)=>u?M(u,C(e)):void 0,_=u=>{let e=C(u);return e==="os"?J():U[e]},fe=({data:u,excelDateCells:e,columnDateFormats:t,maxRow:s=50,maxCol:n=300})=>{let r=Math.min(u.length,s),i=u.slice(0,r).map(o=>o.slice(0,n));return V(i,e,o=>C(t?.[o]))};var L=0,b=class{constructor({data:e,name:t,isNotSetColumn:s,id:n,columnDateFormats:r,excelDateCells:i,excelDateSerials:o}){this.selected=!1;this.isManualSelectHeader=!1;this.columns=[];this.columnsInitialized=!1;this.headerRowIndex=0;this.transposed=!1;this.headerRowIndexes=[];this.addedColumns=[];this.usedSourceCells=new Set;this.mergedHeadersActive=!1;this.mergedRowsBackup=null;this.availableRows=null;this.spreadSheet=new P({filename:"",sheets:[],type:"xlsx",fileSize:0});this.getId=()=>this.id;this.setSpreadSheet=e=>{this.spreadSheet=e};this.getSpreadSheet=()=>this.spreadSheet;this.setSelected=e=>{this.selected=e};this.isSelected=()=>this.selected;this.setHeaderRowIndex=e=>{this.headerRowIndex=e,this.columnsInitialized=!1,this.mergedHeadersActive||(this.headerRowIndexes=[e])};this.setTransposed=e=>{this.transposed=e};this.getTransposed=()=>this.transposed;this.setHeaderRowIndexes=e=>{this.headerRowIndexes=[...e]};this.getHeaderRowIndexes=()=>this.headerRowIndexes.length>0?this.headerRowIndexes:[this.headerRowIndex];this.addAddedColumn=e=>{if(this.addedColumns.push(e),e.sourceCell){let n=`${e.sourceCell.row},${e.sourceCell.col}`;this.usedSourceCells.add(n)}let t=this.data[this.headerRowIndex],s=this.data.length>0?Math.max(...this.data.map(n=>n.length)):0;t&&t.push(e.columnName);for(let n=0;n<this.data.length;n++)if(n!==this.headerRowIndex){for(;this.data[n].length<s;)this.data[n].push("");n<this.headerRowIndex?this.data[n].push(""):this.data[n].push(e.value)}this.setColumns()};this.removeAddedColumn=e=>{let s=(this.data[this.headerRowIndex]?.length||0)-this.addedColumns.length,n=e-s;if(n<0||n>=this.addedColumns.length)return;let r=this.addedColumns[n];if(r?.sourceCell){let i=`${r.sourceCell.row},${r.sourceCell.col}`;this.usedSourceCells.delete(i)}for(let i=0;i<this.data.length;i++)this.data[i].splice(e,1);this.addedColumns.splice(n,1),this.setColumns()};this.removeColumnFromData=e=>{if(!(e<0)){for(let t=0;t<this.data.length;t++)this.data[t].length>e&&this.data[t].splice(e,1);this.clearExcelDateMetadata()}};this.clearAddedColumns=()=>{if(this.addedColumns.length>0){let t=(this.data[this.headerRowIndex]?.length||0)-this.addedColumns.length;for(let s=this.addedColumns.length-1;s>=0;s--){let n=t+s;for(let r=0;r<this.data.length;r++)this.data[r].length>n&&this.data[r].splice(n,1)}}this.addedColumns=[],this.usedSourceCells.clear(),this.setColumns()};this.isSourceCellUsed=(e,t)=>{let s=`${e},${t}`;return this.usedSourceCells.has(s)};this.getAddedColumnBySourceCell=(e,t)=>this.addedColumns.find(s=>s.sourceCell&&s.sourceCell.row===e&&s.sourceCell.col===t);this.getAddedColumns=()=>this.addedColumns;this.setMergedHeadersActive=e=>{this.mergedHeadersActive=e};this.isMergedHeadersActive=()=>this.mergedHeadersActive;this.setMergedRowsBackup=e=>{this.mergedRowsBackup=e};this.getMergedRowsBackup=()=>this.mergedRowsBackup;this.setAvailableRows=e=>{this.availableRows=e};this.getAvailableRows=()=>this.availableRows;this.isLoneWhitelistCharacter=e=>{let t=e.toString()?.trim()??"";return T.some(s=>t===s)};this.isSignificantCell=e=>!B(e)&&!this.isLoneWhitelistCharacter(e);this.collapseAdjacentDuplicates=e=>e.filter((t,s)=>s===0||`${t}`!=`${e[s-1]}`);this.getSignificantCells=e=>{let t=(e??[]).filter(this.isSignificantCell);return this.collapseAdjacentDuplicates(t)};this.getDataTransform=()=>this.data.map((e,t)=>({data:e,index:t,length:this.getSignificantCells(e).length}));this.getMaxLengthColumns=()=>this.getDataTransform().reduce((t,s)=>Math.max(t,s.length),0);this.isHeaderLikeCell=e=>!F.includes(Y(e)?e.toLowerCase():e)&&z(Number(e));this.countHeaderLikeCells=e=>this.getSignificantCells(e).filter(this.isHeaderLikeCell).length;this.setHeaderByAutoDetection=()=>{let t=this.getMaxLengthColumns(),s=this.getDataTransform().slice(0,50).filter(r=>r.length===t&&this.countHeaderLikeCells(r.data)===t),n=s.length===1?s[0].index:q(s,r=>r.length)?.index??0;this.setHeaderRowIndex(n)};this.getHeaderRowIndex=()=>this.headerRowIndex;this.getHeaderRow=()=>this.data[this.headerRowIndex]?.filter(e=>!!e);this.getColumns=()=>(this.ensureColumnsBuilt(),this.columns.filter(e=>!e.isRemoved()));this.getSortedColumns=()=>[...this.getColumns()].sort((e,t)=>c(e.getColumnKey())<c(t.getColumnKey())?-1:c(e.getColumnKey())>c(t.getColumnKey())?1:0);this.getColumnsWithRemoved=()=>(this.ensureColumnsBuilt(),this.columns.filter(e=>e.getType()!==1));this.getColumn=(e,t)=>(this.ensureColumnsBuilt(),this.columns.find(s=>t?c(s.getColumnKey())===c(`${e}`):s.getColumnKey()===e));this.getColumnsByKey=(e,t)=>(this.ensureColumnsBuilt(),this.columns.filter(s=>t?c(s.getColumnKey())===c(`${e}`):s.getColumnKey()===e));this.getValues=()=>{let e=this.data.filter((s,n)=>n>this.headerRowIndex);if(B(e))return[[]];let t=[];for(let s=0;s<e.length;s++){let n=[];for(let r=0;r<this.data[this.headerRowIndex].length;r++)G(this.data[this.headerRowIndex][r])||n.push(this.parseValue(e[s][r]));t.push(n)}return t};this.getData=()=>this.data;this.getExcelDateCells=()=>this.excelDateCells;this.getExcelDateSerials=()=>this.excelDateSerials;this.getColumnDateFormats=()=>this.columnDateFormats;this.getName=()=>this.name;this.getDisplayName=({t:e})=>{if(this.getName()?.length>0)return this.getName();switch(this.spreadSheet.getType()){case"json":return`${e("txt_default_sheet_prefix_name")} 1`;case"csv":return`${e("txt_default_sheet_prefix_name")} 1`;default:return""}};this.getSheetFileName=()=>`${this.spreadSheet.getFilename()}`;this.getIsManualSelectHeader=()=>this.isManualSelectHeader;this.setIsManualSelectHeader=()=>{this.isManualSelectHeader=!0};this.clearIsManualSelectHeader=()=>{this.isManualSelectHeader=!1};this.addColumn=e=>{this.ensureColumnsBuilt(),this.columns.push(new g({columnKey:`${e}`,sheet:this,rows:this.getRowsByColumnIndex(this.getColumnIndex(e))}))};this.removeColumn=e=>{this.ensureColumnsBuilt(),this.columns.find(t=>t.getColumnKey()===e)?.remove()};this.removeColumnByIndex=e=>{this.ensureColumnsBuilt(),this.columns.find((t,s)=>s===e)?.remove()};this.setData=(e,t)=>{if(t!=null&&t!==this&&(e===t.getData()||R(e,t.getData()))&&(t.columnDateFormats!=null||t.excelDateCells!=null||t.excelDateSerials!=null)){this.data=e,this.columnDateFormats=t.columnDateFormats,this.excelDateCells=t.excelDateCells,this.excelDateSerials=t.excelDateSerials;return}if(e===this.data||R(e,this.data)){this.data=e;return}this.data=e,this.clearExcelDateMetadata()};this.clearExcelDateMetadata=()=>{this.columnDateFormats=void 0,this.excelDateCells=void 0,this.excelDateSerials=void 0};this.toJSON=()=>({name:this.name,id:this.id,type:this.getType(),values:this.getValues(),headerRow:this.getHeaderRow()});this.equal=e=>this.id===e.getId();this.getType=()=>0;this.readColumnValues=(e,t)=>this.getRowsByColumnIndex(e,t);this.readDateSerialAt=(e,t)=>{if(!this.excelDateSerials||e<0||t<0)return;let s=this.headerRowIndex+1+t;if(!(s>=this.data.length))return this.excelDateSerials[`${s},${e}`]};this.readColumnDateSerials=e=>{if(!this.excelDateSerials||e===-1)return;let t=[],s=!1;for(let n=0;n<this.data.length-this.headerRowIndex-1;n++){let r=this.readDateSerialAt(e,n);r!=null&&(s=!0),t.push(r)}return s?t:void 0};this.excelDisplayFormatAt=e=>this.getExcelDisplayInputFormat(e);this.getRowsByColumnIndex=(e,t)=>{if(e===-1)return[];let s=[],n=this.columnDateFormats?.[e];for(let r=0;r<this.data.length;r++){let i=this.data[r];if(r>this.headerRowIndex){let o=i[e]??"",l=K(this.excelDateCells?.[`${r},${e}`],n);if(s.push(l??this.parseValue(o)),t!=null&&s.length>=t)break}}return s};this.getExcelDisplayInputFormat=e=>{if(!this.excelDateCells)return;let t=!1;for(let s=this.headerRowIndex+1;s<this.data.length;s++)if((this.data[s]?.[e]??"")!==""){if(!this.excelDateCells[`${s},${e}`])return;t=!0}return t?_(this.columnDateFormats?.[e]):void 0};this.ensureColumnsBuilt=()=>{this.columnsInitialized||this.setColumns()};this.setColumns=()=>{let e=this.data[this.headerRowIndex];if(e){let t=[];for(let s=0;s<e.length;++s){let n=e[s];n&&t.push(new g({columnKey:`${n}`,sheet:this,columnIndex:s,parserDateFormat:this.columnDateFormats?.[s]}))}this.columns=t}else this.columns=[];this.columnsInitialized=!0};this.getColumnIndex=e=>this.data[this.headerRowIndex].findIndex(n=>R(`${n}`,`${e}`));this.parseValue=e=>typeof e=="string"?e.trim():e;this.data=e,this.name=t,this.columnDateFormats=r,this.excelDateCells=i,this.excelDateSerials=o,typeof n>"u"?(L++,this.id=`${t}-${L}`):this.id=n,this.columnsInitialized=!!s}},E=b;var v=class extends E{constructor({joinedData:t,sheets:s,mappings:n,mappingIndexes:r}){super({data:t.data,name:"join-sheet",isNotSetColumn:!0});this.sheets=[];this.joinHistory=[];this.findRefJoinSheetColumn=t=>{let s=this.sheets.length===2?this.sheets[0]:this,n=this.sheets[this.sheets.length-1];if(t<s.getColumns().length)return s.getColumns()[t];let r=t-s.getColumns().length;return n.getColumns().filter((i,o)=>this.joinHistory[this.joinHistory.length-1].mappingIndexes.every(l=>l.target!==o))[r]};this.setJoinColumns=(t,s)=>{let n=this.data[this.headerRowIndex];if(!n){this.columns=[];return}let r=[];for(let i=0;i<n.length;++i){let o=n[i],l=s.findIndex(a=>a.source===i),m=this.columns[i]&&this.columns[i].getType()===1;if(l>=0||m){let a=t[l],h;m&&l>=0?h=[...this.columns[i].getJoinedSheetColumns(),a.target]:m?h=this.columns[i].getJoinedSheetColumns():h=[a.source.getRefJoinSheetColum()??a.source,a.target],r.push(new H({columnKey:`${o}`,sheetColumns:h,sheet:this,rows:this.getRowsByColumnIndex(i)}))}else{let a=this.columns[i]?this.columns[i].getRefJoinSheetColum()??this.columns[i]:this.findRefJoinSheetColumn(i);r.push(new g({columnKey:`${o}`,sheet:a.getSheet(),rows:this.getRowsByColumnIndex(i),refJoinSheetColum:a}))}}this.columns=r};this.getJoinedSheets=()=>this.sheets;this.getType=()=>1;this.joinSheet=(t,s,n,r)=>{this.setData(t.data),this.sheets.push(s),this.joinHistory.push({mappingIndexes:r,type:t.type,row:t.data.length,col:this.data[this.headerRowIndex]?.length??0}),this.setJoinColumns(n,r)};this.getJoinColumns=()=>this.columns.filter(t=>t.getType()===1);this.getJoinHistory=()=>this.joinHistory;this.headerRowIndex=0,this.joinHistory.push({mappingIndexes:r,type:t.type,row:t.data.length,col:this.data[this.headerRowIndex]?.length??0}),this.sheets=s,this.setJoinColumns(n,r)}},Ve=v;var Q=({rowA:u,rowB:e},t)=>t.every(s=>{let n=`${u[s.source]??""}`,r=`${e[s.target]??""}`;return n===r&&n!==""&&r!==""}),$=(u,e,t)=>{let s=[];for(let n of e){let r=`${u[n[t]]??""}`;if(r==="")return"";s.push(r)}return JSON.stringify(s)},Z=(u,e,t)=>{let s=[],n=u.headerRow,r=e.headerRow;for(let i=0;i<n.length;++i)s.push(n[i]);for(let i=0;i<r.length;++i)t.every(o=>o.target!==i)&&s.push(r[i]);return s},Ke=async(u,e)=>{let t=u.values,s=e.values,n=u.headerRow,r=e.headerRow,i=[...n,...r],o=[];o.push(i);for(let l=0;l<t.length;++l)o.push([...t[l],...s[0]]);return{data:o,type:"ADD_TO_ALL_ROWS"}},_e=async(u,e)=>{let t=u.values,s=e.values,n=u.headerRow,r=e.headerRow,i=[...n,...r],o=[];o.push(i);for(let l=0;l<t.length;++l)o.push([...t[l],...r.map(()=>"")]);for(let l=0;l<s.length;++l)o.push([...n.map(()=>""),...s[l]]);return{data:o,type:"JOIN_WITHOUT_COLUMNS"}},Be=async(u,e,t)=>{let s=u.values,n=e.values,r=[],i=[],o={},l=Z(u,e,t);r.push(l);let m=new Map;for(let a=0;a<n.length;++a){let h=$(n[a],t,"target");if(!h)continue;let d=m.get(h);d?d.push(a):m.set(h,[a])}for(let a=0;a<s.length;++a){let h=!1,d=s[a],p=$(d,t,"source");for(let f of p&&m.get(p)||[]){let S=n[f];o[f]=!0,h=!0,r.push([...d,...S.filter((N,j)=>t.every(X=>X.target!==j))])}h||i.push([...d,...e.headerRow.filter((f,S)=>t.every(N=>N.target!==S)).map(()=>"")])}for(let a=0;a<n.length;++a){if(o[a])continue;let h=n[a],d=u.headerRow.map(()=>"");t.forEach(p=>{d[p.source]=h[p.target]}),i.push([...d,...h.filter((p,f)=>t.every(S=>S.target!==f))])}return i.forEach(a=>{r.push(a)}),{data:r,type:"JOIN_ON_COLUMNS"}},Le=async(u,e,t)=>{let s=e.headerRow.filter((o,l)=>t.every(m=>m.target!==l)),r=[[...u.headerRow,...s]];for(let o=0;o<u.values.length;++o){let l=[...u.values[o],...s.map(()=>"")];r.push(l)}let i=e.values;for(let o=0;o<i.length;++o){let l=u.headerRow.map(()=>""),m=[];for(let a=0;a<e.headerRow.length;++a){let h=t.find(d=>d.target===a);h?l[h.source]=i[o][a]:m.push(i[o][a])}r.push([...l,...m])}return{data:r,type:"APPEND_TO_COLUMNS"}},Ee=async(u,e,t)=>{let s=u.values,n=e.values,r=s.length+n.length,i=0,o={};for(let l=0;l<s.length;l++){let m=s[l],a=null,h=0;for(let d=0;d<n.length;d++){let p=n[d];if(Q({rowA:m,rowB:p},t)&&(a=d,h++,h===2))break}h===1&&a!==null&&(i+=1,o[a]=!0)}for(let l=0;l<n.length;l++)o[l]&&(i+=1);return{count:i,total:r}};export{g as a,P as b,fe as c,E as d,Ve as e,$ as f,Ke as g,_e as h,Be as i,Le as j,Ee as k};
@@ -1 +1 @@
1
- import{B as y,b as S,c as E,d as h,n as f}from"./chunk-3A4DOV33.js";var Te="prod",O=()=>{let e=y;return typeof e=="function"?e:void 0},Me=(e,n)=>{let t=O();return t?t(e,n):null};import l from"moment";var Se=e=>e===""||e===null||e===void 0,g=e=>typeof e=="string"&&e.trim()!=="";var V=["date","date_dmy","date_mdy","date_iso","datetime"],P=new Set(V),T=e=>g(e),w=e=>typeof e=="string"&&P.has(e),Ne=({columnKey:e,columnType:n,inputFormat:t})=>!!e&&T(t)&&w(n);var M=["/",".","-"," "],x=e=>{let n=e.trim();if(!n)return null;for(let t of n){let r=M.find(s=>s===t);if(r)return r}return null},Oe=(e,n=".")=>{for(let t of e){if(typeof t!="string")continue;let r=x(t);if(r)return r}return n},R=/(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d|[+-](?:[01]\d|2[0-3])[0-5]\d)$/i,C=/T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?[+-](?:[01]\d|2[0-3])$/i,L=e=>R.test(e)||C.test(e),H={yyyy:"YYYY",yy:"YY",dd:"DD",d:"D",XXXXX:"Z",XXXX:"ZZ",XXX:"Z",XX:"ZZ",X:"ZZ",xxxxx:"Z",xxxx:"ZZ",xxx:"Z",xx:"ZZ",x:"ZZ",ZZ:"ZZ",Z:"Z"},v=e=>e.replace(/\]/g,"]]"),K=/YYYY|YY|MMMM|MMM|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z/g,$=e=>/^(H{1,2}|h{1,2})$/.test(e),_=e=>e.match(K)??[],N=e=>{let n="",t=0;for(;t<e.length;){if(e[t]==="["){let r=t+1;for(;r<e.length;){if(e[r]==="]"&&e[r+1]==="]"){r+=2;continue}if(r+=1,e[r-1]==="]")break}t=r;continue}n+=e[t],t+=1}return n},F=e=>{let n="",t=0;for(;t<e.length;){if(e[t]==="\\"&&t+1<e.length){t+=2;continue}n+=e[t],t+=1}return n},U=e=>{let n=_(e),t=n.some(i=>/^(D|DD)$/.test(i)),r=n.some(i=>/^(Y{2,4})$/.test(i)),s=n.some(i=>/^(M{1,4})$/.test(i));return(t||r)&&!s},B=e=>{let n="",t=0,r=null;for(;t<e.length;){if(e[t]==="["){let i=t+1,o="[";for(;i<e.length;){if(e[i]==="]"&&e[i+1]==="]"){o+="]]",i+=2;continue}if(o+=e[i],i+=1,e[i-1]==="]")break}n+=o,t=i;continue}if(e[t]==="\\"&&t+1<e.length){n+=e[t]+e[t+1],t+=2;continue}let s=e.slice(t).match(/^(YYYY|YY|MMMM|MMM|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z)/);if(s){let i=s[1],o=/^(m{1,2})$/.test(i)&&!(r!==null&&$(r));n+=o?i==="mm"?"MM":"M":i,r=i,t+=i.length;continue}n+=e[t],t+=1}return n},Z=e=>{let n="",t=0;for(;t<e.length;){let s=e[t];if(s==="'"){t+=1;let i="";for(;t<e.length;)if(e[t]==="'")if(e[t+1]==="'")i+="'",t+=2;else{t+=1;break}else i+=e[t],t+=1;n+=`[${v(i)}]`;continue}if(/[A-Za-z]/.test(s)){let i=1;for(;e[t+i]===s;)i++;let o=e.slice(t,t+i);n+=H[o]??o,t+=i}else n+=s,t+=1}let r=F(N(n));return U(r)&&(n=B(n)),n},I=e=>{let n=F(N(e));return _(n).some(t=>t==="Z"||t==="ZZ")},k=/^(YYYY|YY|MMMM|MMM|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z)/,z=new Set(["HH","H","hh","h","mm","m","ss","s","SSS","SS","S","A","a","ZZ","Z"]),G=new Set(["MMM","MMMM"]),Y={D:"day",DD:"day",M:"month",MM:"month",YY:"year",YYYY:"year"},j=/(\s+\d{1,2}:\d{2}(?::\d{2})?(?::\d+|\.\d+)?(?:\s*[AaPp][Mm])?(?:\s*(?:Z|[+-]\d{2}(?::?\d{2})?))?)$/,W=e=>{let n=[],t=0;for(;t<e.length;){if(e[t]==="["){let i=t+1,o="[";for(;i<e.length;){if(e[i]==="]"&&e[i+1]==="]"){o+="]]",i+=2;continue}if(o+=e[i],i+=1,e[i-1]==="]")break}n.push({kind:"text",text:o}),t=i;continue}if(e[t]==="\\"&&t+1<e.length){n.push({kind:"text",text:e[t]+e[t+1]}),t+=2;continue}let r=e.slice(t).match(k);if(r){n.push({kind:"token",token:r[1]}),t+=r[1].length;continue}let s=e[t];for(t+=1;t<e.length&&!(e[t]==="["||e[t]==="\\"||k.test(e.slice(t)));)s+=e[t],t+=1;n.push({kind:"text",text:s})}return n},J=e=>e.map(n=>n.kind==="token"?n.token:n.text).join(""),q=e=>{for(let n=0;n<e.length;n++){let t=e[n];if(t.kind!=="token"||!z.has(t.token))continue;let r=n>0?e[n-1]:null;return r?.kind==="text"&&(/^[T\s]+$/.test(r.text)||r.text==="[T]")?n-1:n}return e.length},Q=e=>{let n=[],t=!1;for(let s of e){if(s.kind==="token"){t=!0;continue}t&&s.text.length>0&&n.push(s.text),t=!1}if(n.length===0)return null;let r=n[0];return!n.every(s=>s===r)||r.length!==1||!M.includes(r)?null:r},A=e=>{let n=[];for(let t of e){if(t.kind!=="token")continue;let r=Y[t.token];if(!r)return null;n.push(r)}return n.length>0?n:null},ee=(e,n)=>{if(Q(e)===null||!A(e))return!1;for(let t of e){if(t.kind==="token"){if(!Y[t.token])return!1;continue}if(t.text.length!==1||!M.includes(t.text))return!1}for(let t of n)if(t.kind==="text"){if(t.text.startsWith("[")){if(t.text!=="[T]")return!1;continue}if(!/^[T\s:.]*$/.test(t.text))return!1}return!0},te=e=>l(String(e).padStart(2,"0"),"YY",!0).year(),ne=(e,n)=>{let t=x(e);if(!t)return l.invalid();let r=e.split(t);if(r.length!==n.length)return l.invalid();if(!r.every(u=>/^\d+$/.test(u)))return l.invalid();let s=1,i=1,o=1970,d=!1;for(let u=0;u<n.length;u++){let m=r[u],a=Number(m);if(!Number.isFinite(a))return l.invalid();switch(n[u]){case"day":if(m.length>2)return l.invalid();s=a;break;case"month":if(m.length>2)return l.invalid();i=a;break;case"year":if(m.length===2)o=te(a);else if(m.length===4)o=a;else return l.invalid();d=!0;break}}if(!d)return l.invalid();let c=l({year:o,month:i-1,day:s});return!c.isValid()||c.year()!==o||c.month()!==i-1||c.date()!==s?l.invalid():c},re=(e,n)=>{if(!n)return{dateText:e,timeText:""};if(n.startsWith("[T]")||n.startsWith("T")){let r=e.indexOf("T");return r<=0?null:{dateText:e.slice(0,r),timeText:e.slice(r)}}let t=e.match(j);return!t||t.index===void 0||t.index===0?null:{dateText:e.slice(0,t.index),timeText:t[1]}},b=(e,n)=>{let t=Z(n),r=I(t),s=W(t);if(s.some(D=>D.kind==="token"&&G.has(D.token)))return r?l.parseZone(e,t,!0):l(e,t,!0);let i=q(s),o=s.slice(0,i),d=s.slice(i),c=A(o);if(!c||!ee(o,d))return r?l.parseZone(e,t,!0):l(e,t,!0);let u=J(d),m=re(e,u);if(!m)return l.invalid();let a=ne(m.dateText,c);if(!a.isValid())return l.invalid();if(!u)return a;let p=r?l.parseZone(m.timeText,u,!0):l(m.timeText,u,!0);return p.isValid()?(a.hours(p.hours()).minutes(p.minutes()).seconds(p.seconds()).milliseconds(p.milliseconds()),r?a.utcOffset(p.utcOffset(),!0):a):l.invalid()},X=e=>e.trim(),ie=(e,n)=>{if(!g(e))return e;let t=e.trim();if(h(t))return t;let r=X(e),s=b(r,n.trim());if(!s.isValid())return e;let i=I(Z(n.trim()))&&L(e);return s.format(i?E:S)},Ve=(e,n)=>{if(!g(e)||h(e.trim()))return!0;let t=X(e);return b(t,n.trim()).isValid()},se=e=>{let n=null;for(let t of e)try{if(typeof t!="string")continue;let r=t.trim(),s=x(r);if(!s)continue;let i=r.split(s).map(u=>u.replace(/[,.\-/]/g,"")).map(Number).filter(u=>isNaN(u)||u<=31),[o,d]=i,c=null;if(!isNaN(o)&&o>12?c="dM":!isNaN(d)&&d>12&&(c="Md"),!c)continue;if(n===null){n=c;continue}if(n!==c)return null}catch{continue}return n},Pe=(e,n)=>{if(T(n)){let s=n.trim();return e.map(i=>ie(i,s))}let t=[],r=se(e);for(let s=0;s<e.length;s++){let i=e[s];t.push(f(i,!1,{allDefaultDateFormat:!0,priorityFormat:r}))}return t};export{Se as a,g as b,T as c,w as d,Ne as e,Te as f,Me as g,x as h,Oe as i,L as j,Z as k,Ve as l,se as m,Pe as n};
1
+ import{B as y,b as S,c as E,d as h,n as f}from"./chunk-DNCQE4OX.js";var Te="prod",O=()=>{let e=y;return typeof e=="function"?e:void 0},Me=(e,n)=>{let t=O();return t?t(e,n):null};import l from"moment";var Se=e=>e===""||e===null||e===void 0,g=e=>typeof e=="string"&&e.trim()!=="";var V=["date","date_dmy","date_mdy","date_iso","datetime"],P=new Set(V),T=e=>g(e),w=e=>typeof e=="string"&&P.has(e),Ne=({columnKey:e,columnType:n,inputFormat:t})=>!!e&&T(t)&&w(n);var M=["/",".","-"," "],x=e=>{let n=e.trim();if(!n)return null;for(let t of n){let r=M.find(s=>s===t);if(r)return r}return null},Oe=(e,n=".")=>{for(let t of e){if(typeof t!="string")continue;let r=x(t);if(r)return r}return n},R=/(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d|[+-](?:[01]\d|2[0-3])[0-5]\d)$/i,C=/T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?[+-](?:[01]\d|2[0-3])$/i,L=e=>R.test(e)||C.test(e),H={yyyy:"YYYY",yy:"YY",dd:"DD",d:"D",XXXXX:"Z",XXXX:"ZZ",XXX:"Z",XX:"ZZ",X:"ZZ",xxxxx:"Z",xxxx:"ZZ",xxx:"Z",xx:"ZZ",x:"ZZ",ZZ:"ZZ",Z:"Z"},v=e=>e.replace(/\]/g,"]]"),K=/YYYY|YY|MMMM|MMM|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z/g,$=e=>/^(H{1,2}|h{1,2})$/.test(e),_=e=>e.match(K)??[],N=e=>{let n="",t=0;for(;t<e.length;){if(e[t]==="["){let r=t+1;for(;r<e.length;){if(e[r]==="]"&&e[r+1]==="]"){r+=2;continue}if(r+=1,e[r-1]==="]")break}t=r;continue}n+=e[t],t+=1}return n},F=e=>{let n="",t=0;for(;t<e.length;){if(e[t]==="\\"&&t+1<e.length){t+=2;continue}n+=e[t],t+=1}return n},U=e=>{let n=_(e),t=n.some(i=>/^(D|DD)$/.test(i)),r=n.some(i=>/^(Y{2,4})$/.test(i)),s=n.some(i=>/^(M{1,4})$/.test(i));return(t||r)&&!s},B=e=>{let n="",t=0,r=null;for(;t<e.length;){if(e[t]==="["){let i=t+1,o="[";for(;i<e.length;){if(e[i]==="]"&&e[i+1]==="]"){o+="]]",i+=2;continue}if(o+=e[i],i+=1,e[i-1]==="]")break}n+=o,t=i;continue}if(e[t]==="\\"&&t+1<e.length){n+=e[t]+e[t+1],t+=2;continue}let s=e.slice(t).match(/^(YYYY|YY|MMMM|MMM|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z)/);if(s){let i=s[1],o=/^(m{1,2})$/.test(i)&&!(r!==null&&$(r));n+=o?i==="mm"?"MM":"M":i,r=i,t+=i.length;continue}n+=e[t],t+=1}return n},Z=e=>{let n="",t=0;for(;t<e.length;){let s=e[t];if(s==="'"){t+=1;let i="";for(;t<e.length;)if(e[t]==="'")if(e[t+1]==="'")i+="'",t+=2;else{t+=1;break}else i+=e[t],t+=1;n+=`[${v(i)}]`;continue}if(/[A-Za-z]/.test(s)){let i=1;for(;e[t+i]===s;)i++;let o=e.slice(t,t+i);n+=H[o]??o,t+=i}else n+=s,t+=1}let r=F(N(n));return U(r)&&(n=B(n)),n},I=e=>{let n=F(N(e));return _(n).some(t=>t==="Z"||t==="ZZ")},k=/^(YYYY|YY|MMMM|MMM|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z)/,z=new Set(["HH","H","hh","h","mm","m","ss","s","SSS","SS","S","A","a","ZZ","Z"]),G=new Set(["MMM","MMMM"]),Y={D:"day",DD:"day",M:"month",MM:"month",YY:"year",YYYY:"year"},j=/(\s+\d{1,2}:\d{2}(?::\d{2})?(?::\d+|\.\d+)?(?:\s*[AaPp][Mm])?(?:\s*(?:Z|[+-]\d{2}(?::?\d{2})?))?)$/,W=e=>{let n=[],t=0;for(;t<e.length;){if(e[t]==="["){let i=t+1,o="[";for(;i<e.length;){if(e[i]==="]"&&e[i+1]==="]"){o+="]]",i+=2;continue}if(o+=e[i],i+=1,e[i-1]==="]")break}n.push({kind:"text",text:o}),t=i;continue}if(e[t]==="\\"&&t+1<e.length){n.push({kind:"text",text:e[t]+e[t+1]}),t+=2;continue}let r=e.slice(t).match(k);if(r){n.push({kind:"token",token:r[1]}),t+=r[1].length;continue}let s=e[t];for(t+=1;t<e.length&&!(e[t]==="["||e[t]==="\\"||k.test(e.slice(t)));)s+=e[t],t+=1;n.push({kind:"text",text:s})}return n},J=e=>e.map(n=>n.kind==="token"?n.token:n.text).join(""),q=e=>{for(let n=0;n<e.length;n++){let t=e[n];if(t.kind!=="token"||!z.has(t.token))continue;let r=n>0?e[n-1]:null;return r?.kind==="text"&&(/^[T\s]+$/.test(r.text)||r.text==="[T]")?n-1:n}return e.length},Q=e=>{let n=[],t=!1;for(let s of e){if(s.kind==="token"){t=!0;continue}t&&s.text.length>0&&n.push(s.text),t=!1}if(n.length===0)return null;let r=n[0];return!n.every(s=>s===r)||r.length!==1||!M.includes(r)?null:r},A=e=>{let n=[];for(let t of e){if(t.kind!=="token")continue;let r=Y[t.token];if(!r)return null;n.push(r)}return n.length>0?n:null},ee=(e,n)=>{if(Q(e)===null||!A(e))return!1;for(let t of e){if(t.kind==="token"){if(!Y[t.token])return!1;continue}if(t.text.length!==1||!M.includes(t.text))return!1}for(let t of n)if(t.kind==="text"){if(t.text.startsWith("[")){if(t.text!=="[T]")return!1;continue}if(!/^[T\s:.]*$/.test(t.text))return!1}return!0},te=e=>l(String(e).padStart(2,"0"),"YY",!0).year(),ne=(e,n)=>{let t=x(e);if(!t)return l.invalid();let r=e.split(t);if(r.length!==n.length)return l.invalid();if(!r.every(u=>/^\d+$/.test(u)))return l.invalid();let s=1,i=1,o=1970,d=!1;for(let u=0;u<n.length;u++){let m=r[u],a=Number(m);if(!Number.isFinite(a))return l.invalid();switch(n[u]){case"day":if(m.length>2)return l.invalid();s=a;break;case"month":if(m.length>2)return l.invalid();i=a;break;case"year":if(m.length===2)o=te(a);else if(m.length===4)o=a;else return l.invalid();d=!0;break}}if(!d)return l.invalid();let c=l({year:o,month:i-1,day:s});return!c.isValid()||c.year()!==o||c.month()!==i-1||c.date()!==s?l.invalid():c},re=(e,n)=>{if(!n)return{dateText:e,timeText:""};if(n.startsWith("[T]")||n.startsWith("T")){let r=e.indexOf("T");return r<=0?null:{dateText:e.slice(0,r),timeText:e.slice(r)}}let t=e.match(j);return!t||t.index===void 0||t.index===0?null:{dateText:e.slice(0,t.index),timeText:t[1]}},b=(e,n)=>{let t=Z(n),r=I(t),s=W(t);if(s.some(D=>D.kind==="token"&&G.has(D.token)))return r?l.parseZone(e,t,!0):l(e,t,!0);let i=q(s),o=s.slice(0,i),d=s.slice(i),c=A(o);if(!c||!ee(o,d))return r?l.parseZone(e,t,!0):l(e,t,!0);let u=J(d),m=re(e,u);if(!m)return l.invalid();let a=ne(m.dateText,c);if(!a.isValid())return l.invalid();if(!u)return a;let p=r?l.parseZone(m.timeText,u,!0):l(m.timeText,u,!0);return p.isValid()?(a.hours(p.hours()).minutes(p.minutes()).seconds(p.seconds()).milliseconds(p.milliseconds()),r?a.utcOffset(p.utcOffset(),!0):a):l.invalid()},X=e=>e.trim(),ie=(e,n)=>{if(!g(e))return e;let t=e.trim();if(h(t))return t;let r=X(e),s=b(r,n.trim());if(!s.isValid())return e;let i=I(Z(n.trim()))&&L(e);return s.format(i?E:S)},Ve=(e,n)=>{if(!g(e)||h(e.trim()))return!0;let t=X(e);return b(t,n.trim()).isValid()},se=e=>{let n=null;for(let t of e)try{if(typeof t!="string")continue;let r=t.trim(),s=x(r);if(!s)continue;let i=r.split(s).map(u=>u.replace(/[,.\-/]/g,"")).map(Number).filter(u=>isNaN(u)||u<=31),[o,d]=i,c=null;if(!isNaN(o)&&o>12?c="dM":!isNaN(d)&&d>12&&(c="Md"),!c)continue;if(n===null){n=c;continue}if(n!==c)return null}catch{continue}return n},Pe=(e,n)=>{if(T(n)){let s=n.trim();return e.map(i=>ie(i,s))}let t=[],r=se(e);for(let s=0;s<e.length;s++){let i=e[s];t.push(f(i,!1,{allDefaultDateFormat:!0,priorityFormat:r}))}return t};export{Se as a,g as b,T as c,w as d,Ne as e,Te as f,Me as g,x as h,Oe as i,L as j,Z as k,Ve as l,se as m,Pe as n};
@@ -1,4 +1,4 @@
1
- import{d as k,f as N,i as _e,j as Ie,k as ke}from"./chunk-ICSUNGF5.js";import{a as Ge}from"./chunk-YN3W6BG7.js";import{a as v}from"./chunk-EWEVS5OB.js";var dr=e=>e.getSpreadSheets()[0].getType()==="dynamic-import",fr="Uploaded data",vt=e=>`Sheet ${e+1}`,gr=e=>Array.isArray(e)&&e.length>0&&e.every(r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&Array.isArray(r.sheets)),De=(e,r)=>typeof e=="string"&&e.trim()!==""?e:vt(r);var d=(e,r)=>{let t=-1;for(let n=0;n<e.headers.length;n++)if(e.headers[n]===r){if(t>=0)return-1;t=n}return t},q=(e,r)=>e.headers.reduce((t,n)=>n===r?t+1:t,0),f=e=>e==null?"":`${e}`,Nt={comma:",",semicolon:";",tab:" ",pipe:"|",space:" ",newline:`
1
+ import{d as k,f as N,i as _e,j as Ie,k as ke}from"./chunk-GE35QTV6.js";import{a as Ge}from"./chunk-YN3W6BG7.js";import{a as v}from"./chunk-EWEVS5OB.js";var dr=e=>e.getSpreadSheets()[0].getType()==="dynamic-import",fr="Uploaded data",vt=e=>`Sheet ${e+1}`,gr=e=>Array.isArray(e)&&e.length>0&&e.every(r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&Array.isArray(r.sheets)),De=(e,r)=>typeof e=="string"&&e.trim()!==""?e:vt(r);var d=(e,r)=>{let t=-1;for(let n=0;n<e.headers.length;n++)if(e.headers[n]===r){if(t>=0)return-1;t=n}return t},q=(e,r)=>e.headers.reduce((t,n)=>n===r?t+1:t,0),f=e=>e==null?"":`${e}`,Nt={comma:",",semicolon:";",tab:" ",pipe:"|",space:" ",newline:`
2
2
  `,linefeed:`
3
3
  `},Fe=e=>{let r=e.trim();return r==="\\n"?`
4
4
  `:r==="\\t"?" ":r==="\\r\\n"?`\r
@@ -1 +1 @@
1
- import{a as M,d as U,e as d,k as O,p as N}from"./chunk-L5AEQQSP.js";import{a as g,b as P,c as L}from"./chunk-YN3W6BG7.js";import{isNil as F}from"lodash";import{isArray as Y}from"lodash";var f=class r{constructor(t,e){this.dataModels=[];this.mapValidation=t=>{switch(t){case"regex":return"REGEX";case"required":return"REQUIRED";case"required_with":return"REQUIRED_WITH";case"required_with_all":return"REQUIRED_WITH_ALL";case"required_with_all_values":return"REQUIRED_WITH_ALL_VALUES";case"required_with_values":return"REQUIRED_WITH_VALUES";case"required_without":return"REQUIRED_WITHOUT";case"required_without_all":return"REQUIRED_WITHOUT_ALL";case"required_without_all_values":return"REQUIRED_WITHOUT_ALL_VALUES";case"required_without_values":return"REQUIRED_WITHOUT_VALUES";case"unique":return"UNIQUE";case"compare":return"COMPARE";default:throw new Error(`validation "${t}" isn't in available options`)}};this.getValidator=(t,e)=>new U({validation:this.mapValidation(t.validate),regex:t.regex??void 0,fields:t.columnValues?.map(a=>({key:a.key,value:a.value??[],type:this.findDataModelTypeByKey(a.key,e),label:this.findDataModelLabelByKey(a.key,e)}))??[],errorMessage:t.errorMessage,operator:t.operator,value:t.value});this.findDataModel=t=>this.columns.find(e=>e.key===t);this.findDataModelTypeByKey=(t,e)=>{let a=this.findDataModel(t);if(a)return r.mapDataModelType({columnType:a.columnType});if(e.checkValidation)throw new Error(`validation key "${t}" isn't found.`);return"string"};this.findDataModelLabelByKey=(t,e)=>{let a=this.findDataModel(t);if(a)return a.label;if(e.checkValidation)throw new Error(`validation key "${t}" isn't found.`);return""};this.validatorParser=t=>{let e=t.validate.toUpperCase(),a=t.columnValues??{},i=t.columns??[];return e==="REQUIRED_WITH_VALUES"||e==="REQUIRED_WITH_ALL_VALUES"||e==="REQUIRED_WITHOUT_VALUES"||e==="REQUIRED_WITHOUT_ALL_VALUES"?Object.keys(a).map(n=>({key:n,value:Y(a[n])?a[n]:[a[n]]})):e==="REQUIRED_WITH"||e==="REQUIRED_WITHOUT"||e==="REQUIRED_WITHOUT_ALL"||e==="REQUIRED_WITH_ALL"?i.map(n=>({key:n})):[]};this.setDataModels=t=>{this.dataModels=this.columns.map(e=>{let a=r.mapDataModelType({columnType:e.columnType});e.numberFormat===void 0&&a==="currency_usd"&&(e.numberFormat="us");let i=e.optionMappingConfiguration?.processingMode??"browser",n=e.optionMappingConfiguration?.layers&&e.optionMappingConfiguration?.layers.length>0?e.optionMappingConfiguration?.layers:["smart","historic","fuzzy","exact"];t.enableNodeProcessing||(i="browser",n=n.filter(o=>o!=="historic"&&o!=="smart")),t.enableReuseMapping||(n=n.filter(o=>o!=="historic"));let u={layers:n,processingMode:i,threshold:e.optionMappingConfiguration?.threshold??.6},s={description:e.description??"",example:e.example??"",key:e.key,label:e.label,type:a,isRequired:!1,outputFormat:e.outputFormat??"",inputFormat:a==="date"?M(e.inputFormat):null,validators:e.validations?.map(o=>this.getValidator({...o,columnValues:this.validatorParser(o)},t)),mappingValidation:e.mappingValidation,alternativeMatches:e.alternativeMatches,columnSize:1,columnWidth:e.columnWidth,numberFormat:e.numberFormat||"eu",hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:u,excludeFromAutoMatching:e.excludeFromAutoMatching};return d.isTypeCategory(a)?new N({...s,type:a,options:r.createDropdownOptions(e),isMultiSelection:e.isMultiSelect??!1,allowCustomOptions:e.allowCustomOptions,allowedCustomOptionTypes:e.allowedCustomOptionTypes,preserveUnmappedOptions:r.sanitizePreserveUnmappedOptions(e.preserveUnmappedOptions)}):new d(s)})};this.getDataModels=()=>this.dataModels;this.columns=t,this.setDataModels(e)}static{this.mapDataModelType=({columnType:t})=>{switch(t){case"boolean":return"boolean";case"int":return"int";case"float":return"float";case"category":return"single-select";case"date":return"date";case"date_dmy":return"date_dmy";case"date_mdy":return"date_mdy";case"date_iso":return"date_iso";case"datetime":return"datetime";case"time_hms":return"time_hms";case"time_hms_24":return"time_hms_24";case"time_hm":return"time_hm";case"time_hm_24":return"time_hm_24";case"email":return"email";case"url_www":return"url_www";case"url_https":return"url_https";case"url":return"url";case"phone":return"phone";case"zip_code_de":return"zip_code_de";case"percentage":return"percentage";case"country_code_alpha_2":return"country_code_alpha_2";case"country_code_alpha_3":return"country_code_alpha_3";case"currency_code":return"currency_code";case"currency_eur":return"currency_eur";case"currency_usd":return"currency_usd";case"bic":return"bic";case"vat_eu":return"vat_eu";case"gtin":return"gtin";case"iban":return"iban";default:return"string"}}}static{this.mapColumnType=({dataType:t})=>{switch(t){case"boolean":return"boolean";case"int":return"int";case"float":return"float";case"single-select":return"category";case"date":return"date";case"date_dmy":return"date_dmy";case"date_mdy":return"date_mdy";case"date_iso":return"date_iso";case"datetime":return"datetime";case"time_hms":return"time_hms";case"time_hms_24":return"time_hms_24";case"time_hm":return"time_hm";case"time_hm_24":return"time_hm_24";case"email":return"email";case"url_www":return"url_www";case"url_https":return"url_https";case"url":return"url";case"phone":return"phone";case"zip_code_de":return"zip_code_de";case"percentage":return"percentage";case"country_code_alpha_2":return"country_code_alpha_2";case"country_code_alpha_3":return"country_code_alpha_3";case"currency_code":return"currency_code";case"currency_eur":return"currency_eur";case"currency_usd":return"currency_usd";case"bic":return"bic";case"vat_eu":return"vat_eu";case"gtin":return"gtin";case"iban":return"iban";default:return"string"}}}static{this.VALID_PRESERVE_UNMAPPED_OPTIONS=["none","optional-off","optional-on","always"]}static{this.sanitizePreserveUnmappedOptions=t=>{if(typeof t=="string"&&r.VALID_PRESERVE_UNMAPPED_OPTIONS.includes(t))return t}}static{this.createDropdownOptions=t=>t.columnType==="category"?t.dropdownOptions?.map(e=>({label:`${e.label}`,value:`${e.value}`,type:e.type,alternativeMatches:e.alternativeMatches??[],validations:e.validations??[],description:e.description??""}))??[]:t.columnType==="currency_code"?g:t.columnType==="country_code_alpha_2"?P:t.columnType==="country_code_alpha_3"?L:[]}},w=f;var Ae=(r,t,e,a,i,n)=>{let u=0,s=0,o=0,l=!1,p=!1,{value:E,columns:A,isExact:H,isEmptyValues:T}=t,y=E?.trim();if(!T&&(F(y)||y.length===0))return;let v=T?r.length-1:r.length;for(let m=0;m<v;m++){let C=r[m],R=Object.keys(C);for(let _=0;_<R.length;_++){let D=A.findIndex(c=>c.key===R[_]),I=D>=0?A[D]:void 0;if(I===void 0)continue;let x=C[R[_]];if(O(x,{value:y??"",columns:[I],isExact:H,isEmptyValues:T})){u++;let c=n.findIndex(k=>k.key===I.key),h=n[c];(e.includes(c)||a.includes(m))&&s++,i.includes(c)&&o++,h.disabled&&(p=!0),d.isTypeCategory(w.mapDataModelType({columnType:h.columnType}))&&(l=!0)}}}return{counter:u,hidden:s,skip:o,matchedCategoryType:l,matchedDisabledColumn:p}};var b=r=>r==null||r===""||typeof r=="string"&&r.trim()==="";var S=r=>b(r)||Array.isArray(r)&&r.length===0,V=(r,t)=>typeof r=="string"?t?r.toLowerCase():r:typeof r=="number"?Number.isNaN(r)?{__nuvoNum:"NaN"}:r===1/0?{__nuvoNum:"+Infinity"}:r===-1/0?{__nuvoNum:"-Infinity"}:r:Array.isArray(r)?r.map(e=>V(e,t)):r,Q=(r,t,e)=>JSON.stringify(t.map(a=>V(r[a]??null,e))),G=({rows:r,columnKeys:t,ignoreCase:e=!1,ignoreBlanks:a=!1,excludeFromRemoval:i=[]})=>{if(t.length===0)return[];let n=new Set(i),u=new Set,s=[];for(let o=0;o<r.length;o++){if(n.has(o))continue;let l=r[o];if(a&&t.some(E=>S(l[E])))continue;let p=Q(l,t,e);u.has(p)?s.push(o):u.add(p)}return s},B=({rows:r,columnKeys:t,excludeFromRemoval:e=[]})=>{if(t.length===0)return[];let a=new Set(e),i=[];for(let n=0;n<r.length;n++){if(a.has(n))continue;let u=r[n];t.every(s=>S(u[s]))&&i.push(n)}return i},Me=r=>r.mode==="duplicate"?G(r):B(r);export{w as a,Ae as b,b as c,S as d,Me as e};
1
+ import{a as M,d as U,e as d,k as O,p as N}from"./chunk-BOX4EJAD.js";import{a as g,b as P,c as L}from"./chunk-YN3W6BG7.js";import{isNil as F}from"lodash";import{isArray as Y}from"lodash";var f=class r{constructor(t,e){this.dataModels=[];this.mapValidation=t=>{switch(t){case"regex":return"REGEX";case"required":return"REQUIRED";case"required_with":return"REQUIRED_WITH";case"required_with_all":return"REQUIRED_WITH_ALL";case"required_with_all_values":return"REQUIRED_WITH_ALL_VALUES";case"required_with_values":return"REQUIRED_WITH_VALUES";case"required_without":return"REQUIRED_WITHOUT";case"required_without_all":return"REQUIRED_WITHOUT_ALL";case"required_without_all_values":return"REQUIRED_WITHOUT_ALL_VALUES";case"required_without_values":return"REQUIRED_WITHOUT_VALUES";case"unique":return"UNIQUE";case"compare":return"COMPARE";default:throw new Error(`validation "${t}" isn't in available options`)}};this.getValidator=(t,e)=>new U({validation:this.mapValidation(t.validate),regex:t.regex??void 0,fields:t.columnValues?.map(a=>({key:a.key,value:a.value??[],type:this.findDataModelTypeByKey(a.key,e),label:this.findDataModelLabelByKey(a.key,e)}))??[],errorMessage:t.errorMessage,operator:t.operator,value:t.value});this.findDataModel=t=>this.columns.find(e=>e.key===t);this.findDataModelTypeByKey=(t,e)=>{let a=this.findDataModel(t);if(a)return r.mapDataModelType({columnType:a.columnType});if(e.checkValidation)throw new Error(`validation key "${t}" isn't found.`);return"string"};this.findDataModelLabelByKey=(t,e)=>{let a=this.findDataModel(t);if(a)return a.label;if(e.checkValidation)throw new Error(`validation key "${t}" isn't found.`);return""};this.validatorParser=t=>{let e=t.validate.toUpperCase(),a=t.columnValues??{},i=t.columns??[];return e==="REQUIRED_WITH_VALUES"||e==="REQUIRED_WITH_ALL_VALUES"||e==="REQUIRED_WITHOUT_VALUES"||e==="REQUIRED_WITHOUT_ALL_VALUES"?Object.keys(a).map(n=>({key:n,value:Y(a[n])?a[n]:[a[n]]})):e==="REQUIRED_WITH"||e==="REQUIRED_WITHOUT"||e==="REQUIRED_WITHOUT_ALL"||e==="REQUIRED_WITH_ALL"?i.map(n=>({key:n})):[]};this.setDataModels=t=>{this.dataModels=this.columns.map(e=>{let a=r.mapDataModelType({columnType:e.columnType});e.numberFormat===void 0&&a==="currency_usd"&&(e.numberFormat="us");let i=e.optionMappingConfiguration?.processingMode??"browser",n=e.optionMappingConfiguration?.layers&&e.optionMappingConfiguration?.layers.length>0?e.optionMappingConfiguration?.layers:["smart","historic","fuzzy","exact"];t.enableNodeProcessing||(i="browser",n=n.filter(o=>o!=="historic"&&o!=="smart")),t.enableReuseMapping||(n=n.filter(o=>o!=="historic"));let u={layers:n,processingMode:i,threshold:e.optionMappingConfiguration?.threshold??.6},s={description:e.description??"",example:e.example??"",key:e.key,label:e.label,type:a,isRequired:!1,outputFormat:e.outputFormat??"",inputFormat:a==="date"?M(e.inputFormat):null,validators:e.validations?.map(o=>this.getValidator({...o,columnValues:this.validatorParser(o)},t)),mappingValidation:e.mappingValidation,alternativeMatches:e.alternativeMatches,columnSize:1,columnWidth:e.columnWidth,numberFormat:e.numberFormat||"eu",hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:u,excludeFromAutoMatching:e.excludeFromAutoMatching};return d.isTypeCategory(a)?new N({...s,type:a,options:r.createDropdownOptions(e),isMultiSelection:e.isMultiSelect??!1,allowCustomOptions:e.allowCustomOptions,allowedCustomOptionTypes:e.allowedCustomOptionTypes,preserveUnmappedOptions:r.sanitizePreserveUnmappedOptions(e.preserveUnmappedOptions)}):new d(s)})};this.getDataModels=()=>this.dataModels;this.columns=t,this.setDataModels(e)}static{this.mapDataModelType=({columnType:t})=>{switch(t){case"boolean":return"boolean";case"int":return"int";case"float":return"float";case"category":return"single-select";case"date":return"date";case"date_dmy":return"date_dmy";case"date_mdy":return"date_mdy";case"date_iso":return"date_iso";case"datetime":return"datetime";case"time_hms":return"time_hms";case"time_hms_24":return"time_hms_24";case"time_hm":return"time_hm";case"time_hm_24":return"time_hm_24";case"email":return"email";case"url_www":return"url_www";case"url_https":return"url_https";case"url":return"url";case"phone":return"phone";case"zip_code_de":return"zip_code_de";case"percentage":return"percentage";case"country_code_alpha_2":return"country_code_alpha_2";case"country_code_alpha_3":return"country_code_alpha_3";case"currency_code":return"currency_code";case"currency_eur":return"currency_eur";case"currency_usd":return"currency_usd";case"bic":return"bic";case"vat_eu":return"vat_eu";case"gtin":return"gtin";case"iban":return"iban";default:return"string"}}}static{this.mapColumnType=({dataType:t})=>{switch(t){case"boolean":return"boolean";case"int":return"int";case"float":return"float";case"single-select":return"category";case"date":return"date";case"date_dmy":return"date_dmy";case"date_mdy":return"date_mdy";case"date_iso":return"date_iso";case"datetime":return"datetime";case"time_hms":return"time_hms";case"time_hms_24":return"time_hms_24";case"time_hm":return"time_hm";case"time_hm_24":return"time_hm_24";case"email":return"email";case"url_www":return"url_www";case"url_https":return"url_https";case"url":return"url";case"phone":return"phone";case"zip_code_de":return"zip_code_de";case"percentage":return"percentage";case"country_code_alpha_2":return"country_code_alpha_2";case"country_code_alpha_3":return"country_code_alpha_3";case"currency_code":return"currency_code";case"currency_eur":return"currency_eur";case"currency_usd":return"currency_usd";case"bic":return"bic";case"vat_eu":return"vat_eu";case"gtin":return"gtin";case"iban":return"iban";default:return"string"}}}static{this.VALID_PRESERVE_UNMAPPED_OPTIONS=["none","optional-off","optional-on","always"]}static{this.sanitizePreserveUnmappedOptions=t=>{if(typeof t=="string"&&r.VALID_PRESERVE_UNMAPPED_OPTIONS.includes(t))return t}}static{this.createDropdownOptions=t=>t.columnType==="category"?t.dropdownOptions?.map(e=>({label:`${e.label}`,value:`${e.value}`,type:e.type,alternativeMatches:e.alternativeMatches??[],validations:e.validations??[],description:e.description??""}))??[]:t.columnType==="currency_code"?g:t.columnType==="country_code_alpha_2"?P:t.columnType==="country_code_alpha_3"?L:[]}},w=f;var Ae=(r,t,e,a,i,n)=>{let u=0,s=0,o=0,l=!1,p=!1,{value:E,columns:A,isExact:H,isEmptyValues:T}=t,y=E?.trim();if(!T&&(F(y)||y.length===0))return;let v=T?r.length-1:r.length;for(let m=0;m<v;m++){let C=r[m],R=Object.keys(C);for(let _=0;_<R.length;_++){let D=A.findIndex(c=>c.key===R[_]),I=D>=0?A[D]:void 0;if(I===void 0)continue;let x=C[R[_]];if(O(x,{value:y??"",columns:[I],isExact:H,isEmptyValues:T})){u++;let c=n.findIndex(k=>k.key===I.key),h=n[c];(e.includes(c)||a.includes(m))&&s++,i.includes(c)&&o++,h.disabled&&(p=!0),d.isTypeCategory(w.mapDataModelType({columnType:h.columnType}))&&(l=!0)}}}return{counter:u,hidden:s,skip:o,matchedCategoryType:l,matchedDisabledColumn:p}};var b=r=>r==null||r===""||typeof r=="string"&&r.trim()==="";var S=r=>b(r)||Array.isArray(r)&&r.length===0,V=(r,t)=>typeof r=="string"?t?r.toLowerCase():r:typeof r=="number"?Number.isNaN(r)?{__nuvoNum:"NaN"}:r===1/0?{__nuvoNum:"+Infinity"}:r===-1/0?{__nuvoNum:"-Infinity"}:r:Array.isArray(r)?r.map(e=>V(e,t)):r,Q=(r,t,e)=>JSON.stringify(t.map(a=>V(r[a]??null,e))),G=({rows:r,columnKeys:t,ignoreCase:e=!1,ignoreBlanks:a=!1,excludeFromRemoval:i=[]})=>{if(t.length===0)return[];let n=new Set(i),u=new Set,s=[];for(let o=0;o<r.length;o++){if(n.has(o))continue;let l=r[o];if(a&&t.some(E=>S(l[E])))continue;let p=Q(l,t,e);u.has(p)?s.push(o):u.add(p)}return s},B=({rows:r,columnKeys:t,excludeFromRemoval:e=[]})=>{if(t.length===0)return[];let a=new Set(e),i=[];for(let n=0;n<r.length;n++){if(a.has(n))continue;let u=r[n];t.every(s=>S(u[s]))&&i.push(n)}return i},Me=r=>r.mode==="duplicate"?G(r):B(r);export{w as a,Ae as b,b as c,S as d,Me as e};