@ingestro/importer-react 4.10.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.
@@ -0,0 +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-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};
@@ -0,0 +1 @@
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};
@@ -0,0 +1,6 @@
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
+ `,linefeed:`
3
+ `},Fe=e=>{let r=e.trim();return r==="\\n"?`
4
+ `:r==="\\t"?" ":r==="\\r\\n"?`\r
5
+ `:Nt[r.toLowerCase()]??r},$e=e=>{switch(e){case",":return"comma";case";":return"semicolon";case" ":return"space";case"|":return"pipe";case" ":return"tab";case`
6
+ `:return"newline";default:return e.length===0?"(empty)":`'${e}'`}},Gt=e=>e==null?!1:typeof e=="string"?e.trim()!=="":!0,_t=e=>{let r=1,t=`column_${r}`;for(;e.has(t);)r+=1,t=`column_${r}`;return e.add(t),t},Te=e=>{let r=[],t=[],n=new Set(e.headers.filter(o=>o.trim()!==""));for(let o=0;o<e.headers.length;o++){let s=e.headers[o];if(s.trim()!==""){r.push(o),t.push(s),n.add(s);continue}e.rows.some(u=>Gt(u[o]))&&(r.push(o),t.push(_t(n)))}return{headers:t,rows:e.rows.map(o=>r.map(s=>o[s]??""))}},qe=e=>{let r=new Set;return e.map(t=>{if(!r.has(t))return r.add(t),t;let n=2,o=`${t}_${n}`;for(;r.has(o);)n+=1,o=`${t}_${n}`;return r.add(o),o})},S=(e,r,t=[])=>{let n=[...e.headers];for(let s of t){let a=n.indexOf(s);a>=0&&n.splice(a,1)}let o=new Set(n);for(let s of r){if(o.has(s))return s;o.add(s)}return null},Ae=e=>{let r=e.getData(),t=e.getHeaderRowIndex(),n=r[t]??[];return{headers:n.map(o=>f(o)),rows:r.slice(t+1).map(o=>n.map((s,a)=>o[a]))}},y=e=>Te(Ae(e)),A=(e,r)=>{let t=Te(Ae(e));return{headers:t.headers,rows:t.rows.slice(0,r)}},M=(e,r)=>!e.headers.length&&!e.rows.length?new k({data:[],name:r}):new k({data:[e.headers,...e.rows],name:r}),Q=e=>({headers:[...e.headers],rows:e.rows.map(r=>[...r])}),X=e=>e==null?!0:typeof e=="string"?e.trim()==="":!1,O=(e,r,t,n)=>e==="start"?0:e==="end"?t:n?r:r+1,D=({grid:e,newHeaders:r,newCellsForRow:t,insertAt:n,removeIndexes:o=[]})=>{let s=new Set(o),a=e.headers.map((l,p)=>p).filter(l=>!s.has(l)),u=[...a.map(l=>e.headers[l]).slice(0,n),...r,...a.map(l=>e.headers[l]).slice(n)],i=e.rows.map(l=>{let p=a.map(m=>l[m]??""),c=t(l);return[...p.slice(0,n),...c,...p.slice(n)]});return{headers:u,rows:i}},Y=(e,r)=>{if(e==null)return"";if(r==="string")return typeof e=="string"?e:f(e);if(typeof e=="number"&&!Number.isNaN(e))return e;let t=f(e).trim();if(t===""||t.includes("%"))return e;let n=v.convertStringToNumber(t);if(n===null)return e;let o=Number(n);return Number.isNaN(o)?e:o},It=[{shape:"underscore",re:/^(.+?)(\d+)_(.+)$/},{shape:"space",re:/^(.+?)\s+(\d+)\s+(.+)$/}],P=(e,r,t)=>e.shape==="space"?`${e.prefix} ${r} ${t}`:`${e.prefix}${r}_${t}`,kt=e=>{for(let r of It){let t=e.match(r.re);if(!t)continue;let n=t[1],o=t[2],s=t[3];if(P({prefix:n.trim(),shape:r.shape},o,s.trim())===e)return{shape:r.shape,prefix:n,number:o,field:s}}return null},Rr=(e,r,t)=>!t||!r||e.length>0&&(e.length!==r.length||e.some((n,o)=>n!==r[o]))?null:[...t],E=(e,r)=>{let t=r?.trim()??"",n=new Map,o=new Set;for(let l of e){let p=kt(l);if(!p||t&&p.prefix!==t)continue;if(o.has(l))return null;o.add(l);let c=`${p.shape}\0${p.prefix}`,m=n.get(c)??{prefix:p.prefix,shape:p.shape,fields:new Set,numbers:new Set};m.fields.add(p.field),m.numbers.add(p.number),n.set(c,m)}if(n.size!==1)return null;let s=[...n.values()][0];if(s.numbers.size<2)return null;let a=[...s.fields].sort(),u=[...s.numbers].sort((l,p)=>Number(l)-Number(p)||l.localeCompare(p)),i=new Set;for(let l of u)for(let p of a){let c=P(s,l,p);if(!e.includes(c))return null;i.add(c)}return{prefix:s.prefix,shape:s.shape,fields:a,numbers:u,keyColumns:e.filter(l=>!i.has(l))}};var Oe=e=>{if(!e||typeof e!="object")return!1;let r=e.source;if(typeof r!="string"||r.trim()==="")return!1;let t=e.target,n=e.targets;return"targets"in e?Array.isArray(n)&&n.length>0&&n.every(o=>typeof o=="string"&&o.trim()!==""):typeof t=="string"&&t.trim()!==""},te=e=>Array.isArray(e.mappings)?e.mappings.some(r=>!Oe(r)):!1,re=e=>e==="join"||e==="append",j=e=>e.operation===void 0?!1:!re(e.operation),ne=e=>{let r=e.operation===void 0?"join":re(e.operation)?e.operation:null;return r===null?null:{operation:r,mappings:Array.isArray(e.mappings)?e.mappings.filter(Oe):[]}},vr=e=>j(e)||te(e)?null:ne(e),Nr=e=>{if(j(e))return null;let r=e.operation===void 0?"join":re(e.operation)?e.operation:"join",t=Array.isArray(e.mappings)?e.mappings.map(n=>{if(!n||typeof n!="object")return{source:"",target:""};let o=n,s=typeof o.source=="string"?o.source:"",a=typeof o.target=="string"?o.target:"";if(Array.isArray(o.targets)){let u=o.targets.map(i=>typeof i=="string"?i:"");return{source:s,target:u[0]??a,targets:u}}return{source:s,target:a}}):[];return{operation:r,mappings:t}},G=e=>{let r=y(e);return{name:e.getName(),id:e.getId(),type:e.getType(),headerRow:r.headers,values:r.rows}},Z=(e,r)=>e.targets?e.targets[r]:e.target,U=(e,r,t,n=0)=>t.map(o=>({source:e.indexOf(o.source),target:r.indexOf(Z(o,n))})).filter(o=>o.source>=0&&o.target>=0),Me=(e,r)=>e.reduce((t,n)=>n===r?t+1:t,0),Pe=(e,r)=>{if(e.length<2)return"Combine needs more than one sheet";if(!r.mappings.length)return"Required settings are empty";let t=r.mappings.map(o=>o.source);if(new Set(t).size!==t.length)return"Duplicate column in combine mapping";let n=y(e[0]).headers;for(let o of r.mappings)if(Me(n,o.source)>1)return"Duplicate column in combine mapping";for(let o=1;o<e.length;o++){let s=r.mappings.map(i=>Z(i,o-1));if(new Set(s).size!==s.length)return"Duplicate column in combine mapping";let a=y(e[o]).headers;for(let i of r.mappings)if(Me(a,Z(i,o-1))>1)return"Duplicate column in combine mapping";if(U(n,a,r.mappings,o-1).length!==r.mappings.length)return"Unknown column in combine mapping"}return null},ee=(e,r)=>({headers:qe((r[0]??[]).map(t=>f(t))),rows:r.slice(1)}),oe=2e4,V=(e,r)=>e.filter((t,n)=>r.every(o=>o.target!==n)),Dt=(e,r,t,n)=>{let o=new Map;for(let u of r.values){let i=N(u,t,"target");i&&o.set(i,(o.get(i)??0)+1)}let s=0,a=new Set;for(let u of e.values){let i=N(u,t,"source"),l=i?o.get(i)??0:0;if(l&&a.add(i),s+=l||1,s>n)return s}for(let[u,i]of o)if(!a.has(u)&&(s+=i,s>n))return s;for(let u of r.values)if(!N(u,t,"target")&&(s+=1,s>n))return s;return s},Ft=(e,r,t)=>{let n=new Map,o=[];for(let p of r.values){let c=N(p,t,"target");if(!c){o.push(p);continue}let m=n.get(c)??[];m.push(p),n.set(c,m)}let s=new Map,u=[[...e.headerRow,...V(r.headerRow,t)]],i=()=>V(r.headerRow,t).map(()=>""),l=p=>{let c=e.headerRow.map(()=>"");return t.forEach(m=>{c[m.source]=p[m.target]}),[...c,...V(p,t)]};for(let p of e.values){let c=N(p,t,"source"),m=c?n.get(c):void 0,g=c?s.get(c)??0:0;if(m&&g<m.length){s.set(c,g+1),u.push([...p,...V(m[g],t)]);continue}u.push([...p,...i()])}for(let[p,c]of n){let m=s.get(p)??0;for(let g=m;g<c.length;g++)u.push(l(c[g]))}for(let p of o)u.push(l(p));return u},se=async(e,r,t,n,o)=>{let s=U(e.headerRow.map(i=>f(i)),r.headerRow.map(i=>f(i)),t.mappings,n);if(s.length!==t.mappings.length)return null;let a=t.operation==="append"?Ie:_e,u=t.operation!=="append"&&Dt(e,r,s,o)>o?{data:Ft(e,r,s)}:await a(e,r,s);return{...e,headerRow:u.data[0]??[],values:u.data.slice(1)}},Ee=async(e,r,t,n,o=oe)=>{let s=await se(G(M(e,"acc")),G(r),t,n,o);return s?ee(s.name,[s.headerRow,...s.values]):null},Ve=async(e,r,t=oe)=>{let n=G(e[0]);for(let o=1;o<e.length;o++){let s=await se(n,G(e[o]),r,o-1,t);if(!s)return ee(n.name,[n.headerRow,...n.values]);n=s}return ee(n.name,[n.headerRow,...n.values])},Ue=async(e,r,t=oe)=>{let n=Math.max(0,e.length-1);if(n===0||!r.mappings.length)return{count:0,total:0,mapped:0,targetColumns:0,targetCount:n};let o=y(e[0]),s=0,a=0,u=!0;for(let c=1;c<e.length;c++){let m=y(e[c]),g=U(o.headers,m.headers,r.mappings,c-1);g.length!==r.mappings.length&&(u=!1),s+=g.length,a+=m.headers.length}if(r.operation==="append")return{count:0,total:0,mapped:s,targetColumns:a,targetCount:n};if(!u)return{count:0,total:0,mapped:s,targetColumns:a,targetCount:n};let i=G(e[0]),l=0,p=0;for(let c=1;c<e.length;c++){let m=G(e[c]),g=U(i.headerRow.map(f),m.headerRow.map(f),r.mappings,c-1),C=await ke(i,m,g);l+=C.count,p+=C.total;let b=await se(i,m,r,c-1,t);if(!b)break;i=b}return{count:l,total:p,mapped:s,targetColumns:a,targetCount:n}},Gr=e=>{if(!e.length)return[];let r=new Map,t=[];e.forEach((o,s)=>{for(let{baseColumn:a,incomingColumn:u}of o){if(!a||!u)continue;let i=r.get(a);if(!i){if(s>0)continue;i=Array(e.length).fill(void 0),r.set(a,i),t.push(a)}i[s]===void 0&&(i[s]=u)}});let n=e.map(()=>new Set);return t.flatMap(o=>{let s=r.get(o)??[];if(s.length!==e.length)return[];if(s.some(u=>u===void 0))return[];let a=s;return a.some((u,i)=>n[i].has(u))?[]:(a.forEach((u,i)=>n[i].add(u)),[{source:o,target:a[0],targets:a}])})},je=e=>{let r=e[0]?y(e[0]).headers[0]??"":"",t=e.slice(1).map(o=>y(o).headers[0]??""),n=t[0]??"";return{operation:"join",mappings:r&&n?[{source:r,target:n,targets:t}]:[]}};import*as Ke from"@babel/standalone";import{Interpreter as $t}from"eval5";var Tt=e=>(Ke.transform(e,{presets:[["env",{targets:{ie:"11"},modules:!1}]],compact:!1,comments:!1}).code??e).replace(/^["']use strict["'];?\s*/i,"").trim().replace(/;$/,""),Je=()=>Object.create(null),He=(e,r)=>{let t=Je();return e.headers.forEach((n,o)=>{t[n]=r[o]??""}),t},qt=(e,r)=>e.map(t=>Object.prototype.hasOwnProperty.call(r,t)?r[t]:""),At=e=>e==null?"":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:null,Le=(e,r,t)=>{let n=e;for(let o of Object.keys(r)){if(!o.trim())return{headers:e,error:"Generated function returned an empty column name"};if(!n.includes(o)){n=[...n,o];for(let s=0;s<t.length;s++)t[s]=[...t[s],""]}}return{headers:n,error:null}},Mt=e=>{let r=Je();for(let[t,n]of Object.entries(e)){let o=At(n);if(o===null)return{normalized:r,error:`Generated function returned unsupported value for column "${t}"`};r[t]=o}return{normalized:r,error:null}},Be=(e,r)=>{let t=e.headers.map(n=>n.trim());if(t.some(n=>n===""))return{grid:e,error:"Generated steps require non-empty column headers"};if(new Set(t).size!==t.length)return{grid:e,error:"Generated steps require unique column headers"};try{let n=Tt(r),s=new $t({},{timeout:5e3}).evaluate(n);if(typeof s!="function")return{grid:e,error:"Generated function must be callable"};let a=[...e.headers],u=[];if(e.rows.length===0){let i=s(He(e,[]));if(!i||typeof i!="object"||Array.isArray(i))return{grid:e,error:"Generated function must return a row object"};let l=Le(a,i,u);return l.error?{grid:e,error:l.error}:{grid:{headers:l.headers,rows:[]},error:null}}for(let i of e.rows){let l=s(He(e,i));if(!l||typeof l!="object"||Array.isArray(l))return{grid:e,error:"Generated function must return a row object"};let p=Le(a,l,u);if(p.error)return{grid:e,error:p.error};a=p.headers;let{normalized:c,error:m}=Mt(l);if(m)return{grid:e,error:m};u.push(qt(a,c))}return{grid:{headers:a,rows:u},error:null}}catch(n){return{grid:e,error:n instanceof Error?n.message:"Generated step failed to run"}}};var Ot=e=>`Unknown column: ${e}`,Pt=e=>`Duplicate column: ${e}`,$=e=>`Column already exists: ${e}`,R=(e,r)=>{let t=q(e,r);return t===0?Ot(r):t>1?Pt(r):null},h=e=>typeof e=="string"&&e.length>0?e:"",L=["end","start","afterSource"],ge=["end","start"],ye=e=>L.includes(e),Et=e=>ge.includes(e),Vt=["yes","no"],Ut=e=>e==="yes"||e==="no",F=(e,r,t)=>e!=null&&e!==""&&typeof e=="string"&&!r.includes(e)?`Invalid ${t}`:null,he=e=>Array.isArray(e)&&e.every(r=>typeof r=="string")?e:[],ie=e=>({column:h(e.column),by:typeof e.by=="string"?e.by:"",into:he(e.into),position:ye(e.position)?e.position:"end"}),jt=["eq","neq","gte","lte","gt","lt"],ze=e=>jt.includes(e),ae=e=>({column:h(e.column),operator:ze(e.operator)?e.operator:"eq",value:typeof e.value=="string"?e.value:""}),We=["currency","stripCurrency","uppercase","lowercase","trimWhitespace","titleCase","removeSpecialCharacters","addPrefix","addSuffix"],Ht=new Set(["addPrefix","addSuffix"]),Qe=e=>We.includes(e),ue=e=>({column:h(e.column),as:Qe(e.as)?e.as:"currency",text:typeof e.text=="string"?e.text:""}),le=e=>({column:h(e.column),to:h(e.to)}),pe=e=>({columnName:h(e.columnName),value:typeof e.value=="string"?e.value:"",position:Et(e.position)?e.position:"end"}),ce=e=>({columns:he(e.columns)}),me=e=>({column:h(e.column),to:h(e.to),position:ye(e.position)?e.position:"afterSource"}),de=e=>({column:h(e.column),value:f(e.value)}),fe=e=>({columns:he(e.columns),by:typeof e.by=="string"?e.by:"",into:h(e.into),position:ye(e.position)?e.position:"afterSource",dropSources:Ut(e.dropSources)?e.dropSources:"yes"}),Lt=(e,r,t)=>{let n=f(e),o=n.trim(),s=t.trim(),a=Y(e,"number"),u=Y(t,"number"),i=typeof a=="number"?a:Number(o),l=typeof u=="number"?u:Number(s),p=o!==""&&s!==""&&typeof a=="number"&&typeof u=="number"&&!Number.isNaN(i)&&!Number.isNaN(l);switch(r){case"eq":return p?i===l:n===t;case"neq":return p?i!==l:n!==t;case"gte":return s!==""&&!Number.isNaN(l)&&(o===""||Number.isNaN(i))?!1:p?i>=l:n>=t;case"lte":return s!==""&&!Number.isNaN(l)&&(o===""||Number.isNaN(i))?!1:p?i<=l:n<=t;case"gt":return s!==""&&!Number.isNaN(l)&&(o===""||Number.isNaN(i))?!1:p?i>l:n>t;case"lt":return s!==""&&!Number.isNaN(l)&&(o===""||Number.isNaN(i))?!1:p?i<l:n<t;default:return!1}},Kt=e=>{if(e.trim()==="")return e;let r=v.convertStringToNumber(e);if(r===null)return e;let t=Number(r);return Number.isNaN(t)?e:String(t)},Jt=e=>e.replace(/\S+/g,r=>{let t=[...r],n=t[0];return n?n.toUpperCase()+t.slice(1).join("").toLowerCase():r}),Bt=e=>e.replace(/[^\p{L}\p{M}\p{N}\s]/gu,""),H={format:"us",symbol:"$",suffix:!1},zt=new Map(Ge.map(e=>{let r=e.value.trim().toUpperCase();if(r==="EUR")return[r,{format:"eu",symbol:"\u20AC",suffix:!0}];if(r==="USD")return[r,H];let t=e.alternativeMatches?.[0]?.trim()||r;return[r,{format:"us",symbol:t,suffix:!1}]})),Xe=e=>zt.get(f(e).trim().toUpperCase())??null,Wt=(e,r)=>{let t=-1,n=0;return e.headers.forEach((o,s)=>{if(s===r)return;let a=0;for(let u of e.rows){let i=f(u[s]).trim();i&&Xe(i)&&(a+=1)}a>n&&(t=s,n=a)}),t},Qt=(e,r)=>r?e.split(r).join("").trim():e,Xt=(e,r)=>{let t=f(e);if(t.trim()==="")return t;let n=typeof e=="number"?t:Qt(t,r.symbol);if(n.trim()==="")return t;let o=typeof e=="number"?String(e):v.convertStringToNumber(n);if(o===null||!Number.isFinite(Number(o)))return t;let s=v.convertToFormat(Number(o),{targetFormat:r.format,decimalDigits:2});return r.suffix?`${s} ${r.symbol}`:/\p{L}/u.test(r.symbol)?`${r.symbol} ${s}`:`${r.symbol}${s}`},Yt=(e,r,t=H)=>{let n=f(e),{as:o}=r;return o==="uppercase"?n.toUpperCase():o==="lowercase"?n.toLowerCase():o==="stripCurrency"?Kt(n):o==="trimWhitespace"?n.trim():o==="titleCase"?Jt(n):o==="removeSpecialCharacters"?Bt(n):o==="addPrefix"?`${r.text}${n}`:o==="addSuffix"?`${n}${r.text}`:n.trim()===""?n:Xt(e,t)},Ye={type:"splitColumn",displayNameKey:"txt_preprocess_split_column",addable:!0,settings:[{name:"column",type:"string",required:!0,isColumn:!0},{name:"by",type:"string",required:!0,isColumn:!1},{name:"into",type:"string[]",required:!0,isColumn:!1},{name:"position",type:"enum",required:!1,isColumn:!1,options:["end","start","afterSource"]}],validate:(e,r)=>{let t=F(r.position,L,"position");if(t)return t;let{column:n,by:o,into:s}=ie(r);if(!n||!o||s.length===0)return"Required settings are empty";if(s.some(u=>u.trim()===""))return"Destination column names cannot be empty";if(d(e,n)<0)return R(e,n);let a=S(e,s,[n]);return a?$(a):null},apply:(e,r)=>{let{column:t,by:n,into:o,position:s}=ie(r),a=d(e,t);return D({grid:e,newHeaders:o,newCellsForRow:u=>{let i=f(u[a]).split(n);return o.map((l,p)=>i[p]??"")},insertAt:O(s??"end",a,e.headers.length-1,!0),removeIndexes:[a]})},summary:e=>{let{column:r,by:t,into:n,position:o}=ie(e),s=t===" "?"space":t,a=o&&o!=="end"?` (${o})`:"";return`Split ${r} by ${s} \u2192 ${n.map(u=>`\`${u}\``).join(", ")}${a}`}},Ze={type:"filterRows",displayNameKey:"txt_preprocess_filter_rows",addable:!0,settings:[{name:"column",type:"string",required:!0,isColumn:!0},{name:"operator",type:"enum",required:!0,isColumn:!1,options:["eq","neq","gte","lte","gt","lt"]},{name:"value",type:"string",required:!0,isColumn:!1}],validate:(e,r)=>{let{column:t,value:n}=ae(r);return!t||n===""?"Required settings are empty":ze(r.operator)?d(e,t)<0?R(e,t):null:"Invalid operator"},apply:(e,r)=>{let t=ae(r),n=d(e,t.column);return{headers:[...e.headers],rows:e.rows.filter(o=>Lt(o[n],t.operator,t.value))}},summary:e=>{let{column:r,operator:t,value:n}=ae(e);return`Keep rows where \`${r}\` ${{eq:"=",neq:"\u2260",gte:"\u2265",lte:"\u2264",gt:">",lt:"<"}[t]} \`${n}\``}},et={type:"formatColumn",displayNameKey:"txt_preprocess_format_column",addable:!0,settings:[{name:"column",type:"string",required:!0,isColumn:!0},{name:"as",type:"enum",required:!0,isColumn:!1,options:[...We]},{name:"text",type:"string",required:!1,isColumn:!1}],validate:(e,r)=>{let{column:t,as:n,text:o}=ue(r);return t?Qe(r.as)?Ht.has(n)&&o.trim()===""?"Required settings are empty":d(e,t)<0?R(e,t):null:"Unsupported format option":"Required settings are empty"},apply:(e,r)=>{let t=ue(r),n=d(e,t.column),o=t.as==="currency"?Wt(e,n):-1;return{headers:[...e.headers],rows:e.rows.map(s=>s.map((a,u)=>u===n?Yt(a,t,o>=0?Xe(s[o])??H:H):a))}},summary:e=>{let{column:r,as:t,text:n}=ue(e);return t==="addPrefix"?`Add prefix \`${n}\` to \`${r}\``:t==="addSuffix"?`Add suffix \`${n}\` to \`${r}\``:`Format \`${r}\` as ${t}`}},tt={type:"renameColumn",displayNameKey:"txt_preprocess_rename_column",addable:!0,settings:[{name:"column",type:"string",required:!0,isColumn:!0},{name:"to",type:"string",required:!0,isColumn:!1}],validate:(e,r)=>{let{column:t,to:n}=le(r);if(!t||!n||n.trim()==="")return"Required settings are empty";if(d(e,t)<0)return R(e,t);let o=S(e,[n],[t]);return o?$(o):null},apply:(e,r)=>{let{column:t,to:n}=le(r),o=d(e,t);return{headers:e.headers.map((s,a)=>a===o?n:s),rows:e.rows.map(s=>[...s])}},summary:e=>{let{column:r,to:t}=le(e);return`Rename \`${r}\` \u2192 \`${t}\``}},rt={type:"addMetadataColumn",displayNameKey:"txt_preprocess_add_column",addable:!0,settings:[{name:"columnName",type:"string",required:!0,isColumn:!1},{name:"value",type:"string",required:!1,isColumn:!1},{name:"position",type:"enum",required:!1,isColumn:!1,options:ge}],validate:(e,r)=>{let t=F(r.position,ge,"position");if(t)return t;let{columnName:n}=pe(r);if(!n||n.trim()==="")return"Required settings are empty";let o=S(e,[n]);return o?$(o):null},apply:(e,r)=>{let{columnName:t,value:n,position:o}=pe(r);return D({grid:e,newHeaders:[t],newCellsForRow:()=>[n],insertAt:O(o??"end",0,e.headers.length,!1)})},summary:e=>{let{columnName:r,value:t}=pe(e);return`Add \`${r}\` = \`${t}\``}},nt={type:"removeColumn",displayNameKey:"txt_preprocess_remove_column",addable:!0,settings:[{name:"columns",type:"string[]",required:!0,isColumn:!0}],validate:(e,r)=>{let{columns:t}=ce(r);if(!t.length)return"Required settings are empty";for(let n of t)if(d(e,n)<0)return R(e,n);return null},apply:(e,r)=>{let{columns:t}=ce(r),n=new Set(t.map(o=>d(e,o)).filter(o=>o>=0));return{headers:e.headers.filter((o,s)=>!n.has(s)),rows:e.rows.map(o=>o.filter((s,a)=>!n.has(a)))}},summary:e=>{let{columns:r}=ce(e);return`Remove ${r.map(t=>`\`${t}\``).join(", ")}`}},ot={type:"duplicateColumn",displayNameKey:"txt_preprocess_duplicate_column",addable:!0,settings:[{name:"column",type:"string",required:!0,isColumn:!0},{name:"to",type:"string",required:!0,isColumn:!1},{name:"position",type:"enum",required:!1,isColumn:!1,options:["end","start","afterSource"]}],validate:(e,r)=>{let t=F(r.position,L,"position");if(t)return t;let{column:n,to:o}=me(r);if(!n||!o||o.trim()==="")return"Required settings are empty";if(d(e,n)<0)return R(e,n);let s=S(e,[o]);return s?$(s):null},apply:(e,r)=>{let{column:t,to:n,position:o}=me(r),s=d(e,t);return D({grid:e,newHeaders:[n],newCellsForRow:a=>[a[s]??""],insertAt:O(o,s,e.headers.length,!1)})},summary:e=>{let{column:r,to:t}=me(e);return`Duplicate \`${r}\` \u2192 \`${t}\``}},st={type:"fillEmptyCells",displayNameKey:"txt_preprocess_fill_empty_cells",addable:!0,settings:[{name:"column",type:"string",required:!0,isColumn:!0},{name:"value",type:"string",required:!0,isColumn:!1}],validate:(e,r)=>{let{column:t,value:n}=de(r);return!t||n===""?"Required settings are empty":d(e,t)<0?R(e,t):null},apply:(e,r)=>{let{column:t,value:n}=de(r),o=d(e,t);return{headers:[...e.headers],rows:e.rows.map(s=>s.map((a,u)=>u===o&&X(a)?n:a))}},summary:e=>{let{column:r,value:t}=de(e);return`Fill empty \`${r}\` with \`${t}\``}},it={type:"mergeColumns",displayNameKey:"txt_preprocess_merge_columns",addable:!0,settings:[{name:"columns",type:"string[]",required:!0,isColumn:!0},{name:"by",type:"string",required:!0,isColumn:!1},{name:"into",type:"string",required:!0,isColumn:!1},{name:"position",type:"enum",required:!1,isColumn:!1,options:["end","start","afterSource"]},{name:"dropSources",type:"enum",required:!1,isColumn:!1,options:["yes","no"]}],validate:(e,r)=>{let t=F(r.position,L,"position");if(t)return t;let n=F(r.dropSources,Vt,"dropSources");if(n)return n;let o=fe(r);if(!o.columns.length||!o.by||!o.into||o.into.trim()==="")return"Required settings are empty";for(let a of o.columns)if(d(e,a)<0)return R(e,a);let s=S(e,[o.into],o.dropSources==="yes"?o.columns:[]);return s?$(s):null},apply:(e,r)=>{let t=fe(r),n=t.columns.map(c=>d(e,c)),o=n[0]??0,s=t.dropSources==="yes"?n:[],a=new Set(s),u=e.headers.map((c,m)=>m).filter(c=>!a.has(c)),i=u.filter(c=>c<o).length,l=u.indexOf(o),p;return t.position==="start"?p=0:t.position==="end"?p=u.length:t.dropSources==="yes"?p=i:p=l>=0?l+1:i+1,D({grid:e,newHeaders:[t.into],newCellsForRow:c=>[n.map(m=>c[m]).filter(m=>!X(m)).map(m=>f(m)).join(t.by)],insertAt:p,removeIndexes:s})},summary:e=>{let r=fe(e);return`Merge ${r.columns.map(t=>`\`${t}\``).join(", ")} \u2192 \`${r.into}\``}};var Zt=e=>`Unknown column: ${e}`,be=e=>`Column already exists: ${e}`,_=(e,r)=>{let t=q(e,r);return t===0?Zt(r):t>1?`Duplicate column: ${r}`:null},x=e=>typeof e=="string"&&e.length>0?e:"",J=e=>Array.isArray(e)&&e.every(r=>typeof r=="string")?e:[],at=["all","first","last"],ut=e=>at.includes(e),K=e=>({column:x(e.column),by:typeof e.by=="string"?Fe(e.by):""}),Se=e=>({columns:J(e.columns),nameColumn:x(e.nameColumn),valueColumn:x(e.valueColumn)}),Ce=e=>({namesFrom:x(e.namesFrom),valuesFrom:x(e.valuesFrom)}),Re=e=>({by:x(e.by),aggregateColumns:J(e.aggregateColumns),aggregateModes:Array.isArray(e.aggregateModes)?e.aggregateModes.filter(ut):[],delimiter:typeof e.delimiter=="string"?e.delimiter:", "}),we=e=>({groupPrefix:x(e.groupPrefix).trim(),groupFields:J(e.groupFields).map(r=>r.trim()).filter(Boolean),groupIndexColumn:typeof e.groupIndexColumn=="string"&&e.groupIndexColumn.trim()!==""?e.groupIndexColumn:"group"}),er=(e,r,t)=>r==="all"?e.map(n=>f(n)).filter(n=>n.trim()!=="").join(t):r==="last"?e[e.length-1]??"":e[0]??"",Or=(e,r)=>{let{column:t,by:n}=K(r);if(!t||!n)return!1;let o=d(e,t);return o<0?!1:e.rows.some(s=>f(s[o]).split(n).map(u=>u.trim()).filter(Boolean).length>1)},lt={type:"splitIntoRows",displayNameKey:"txt_preprocess_split_into_rows",addable:!0,settings:[{name:"column",type:"string",required:!0,isColumn:!0},{name:"by",type:"string",required:!0,isColumn:!1}],validate:(e,r)=>{let{column:t,by:n}=K(r);return!t||!n?"Required settings are empty":d(e,t)<0?_(e,t):null},apply:(e,r)=>{let{column:t,by:n}=K(r),o=d(e,t),s=[];for(let a of e.rows){let u=f(a[o]).split(n).map(i=>i.trim()).filter(Boolean);if(u.length===0){s.push([...a]);continue}for(let i of u)s.push(a.map((l,p)=>p===o?i:l))}return{headers:[...e.headers],rows:s}},summary:e=>{let{column:r,by:t}=K(e);return`Split \`${r}\` by ${$e(t)} into rows`}},pt={type:"unpivotColumns",displayNameKey:"txt_preprocess_unpivot_columns",addable:!0,settings:[{name:"columns",type:"string[]",required:!0,isColumn:!0},{name:"nameColumn",type:"string",required:!0,isColumn:!1},{name:"valueColumn",type:"string",required:!0,isColumn:!1}],validate:(e,r)=>{let t=Se(r);if(!t.columns.length||!t.nameColumn||!t.valueColumn)return"Required settings are empty";for(let o of t.columns)if(d(e,o)<0)return _(e,o);let n=S(e,[t.nameColumn,t.valueColumn],t.columns);return n?be(n):null},apply:(e,r)=>{let t=Se(r),n=t.columns.map(i=>d(e,i)),o=new Set(n),s=e.headers.map((i,l)=>l).filter(i=>!o.has(i)),a=[...s.map(i=>e.headers[i]),t.nameColumn,t.valueColumn],u=[];for(let i of e.rows)for(let l of n)u.push([...s.map(p=>i[p]??""),e.headers[l],i[l]??""]);return{headers:a,rows:u}},summary:e=>{let r=Se(e);return`Unpivot ${r.columns.map(t=>`\`${t}\``).join(", ")} \u2192 \`${r.nameColumn}\`, \`${r.valueColumn}\``}},ct={type:"pivotColumn",displayNameKey:"txt_preprocess_pivot_column",addable:!0,settings:[{name:"namesFrom",type:"string",required:!0,isColumn:!0},{name:"valuesFrom",type:"string",required:!0,isColumn:!0}],validate:(e,r)=>{let t=Ce(r);if(!t.namesFrom||!t.valuesFrom)return"Required settings are empty";if(t.namesFrom===t.valuesFrom)return"Names and values must come from different columns";for(let i of[t.namesFrom,t.valuesFrom])if(d(e,i)<0)return _(e,i);let n=d(e,t.namesFrom),o=d(e,t.valuesFrom),s=e.headers.filter((i,l)=>l!==n&&l!==o),u=[...new Set(e.rows.map(i=>f(i[n]).trim()).filter(Boolean))].find(i=>s.includes(i));return u?be(u):null},apply:(e,r)=>{let t=Ce(r),n=d(e,t.namesFrom),o=d(e,t.valuesFrom),s=e.headers.map((c,m)=>m).filter(c=>c!==n&&c!==o),a=s.map(c=>e.headers[c]),u=[...new Set(e.rows.map(c=>f(c[n]).trim()).filter(Boolean))].sort(),i=[...a,...u],l=new Map;for(let c of e.rows){let m=s.map(W=>c[W]??""),g=m.map(W=>f(W)).join("\0"),C=f(c[n]).trim();if(!C)continue;let b=l.get(g);b||(b={keys:m,values:new Map},l.set(g,b)),b.values.set(C,c[o]??"")}let p=[...l.values()].map(({keys:c,values:m})=>[...c,...u.map(g=>m.get(g)??"")]);return{headers:i,rows:p}},summary:e=>{let r=Ce(e);return`Pivot \`${r.namesFrom}\` / \`${r.valuesFrom}\` into columns`}},mt={type:"groupRows",displayNameKey:"txt_preprocess_group_rows",addable:!0,settings:[{name:"by",type:"string",required:!0,isColumn:!0},{name:"aggregateColumns",type:"string[]",required:!0,isColumn:!0},{name:"aggregateModes",type:"string[]",required:!0,isColumn:!1,options:at},{name:"delimiter",type:"string",required:!0,isColumn:!1}],validate:(e,r)=>{let t=J(r.aggregateColumns),n=Array.isArray(r.aggregateModes)?r.aggregateModes:[],o=Re(r);if(!o.by||!o.delimiter)return"Required settings are empty";if(d(e,o.by)<0)return _(e,o.by);if(!t.length)return"Required settings are empty";if(t.length!==n.length)return"Aggregate columns and modes must match";for(let s of n)if(!ut(s))return"Invalid aggregate mode";for(let s of t){if(s===o.by)return"Group column cannot be aggregated";if(d(e,s)<0)return _(e,s)}return null},apply:(e,r)=>{let t=Re(r),n=d(e,t.by),o=new Map(t.aggregateColumns.map((u,i)=>[u,t.aggregateModes[i]??"first"])),s=new Map;for(let u of e.rows){let i=f(u[n]),l=s.get(i)??[];l.push(u),s.set(i,l)}let a=[...s.entries()].map(([u,i])=>e.headers.map((l,p)=>{if(l===t.by)return u;let c=o.get(l);return c?er(i.map(m=>m[p]??""),c,t.delimiter):i[0]?.[p]??""}));return{headers:[...e.headers],rows:a}},summary:e=>`Group rows by \`${Re(e).by}\``},dt={type:"unpivotColumnGroups",displayNameKey:"txt_preprocess_unpivot_column_groups",addable:!0,settings:[{name:"groupPrefix",type:"string",required:!0,isColumn:!1},{name:"groupFields",type:"string[]",required:!0,isColumn:!1},{name:"groupIndexColumn",type:"string",required:!1,isColumn:!1}],validate:(e,r)=>{let t=we(r);if(!t.groupPrefix||!t.groupFields.length)return"Required settings are empty";let n=E(e.headers,t.groupPrefix);if(!n||n.prefix!==t.groupPrefix)return"Could not find matching column groups";for(let s of t.groupFields)if(!n.fields.includes(s))return`Unknown group field: ${s}`;for(let s of n.keyColumns){let a=_(e,s);if(a)return a}let o=S(e,[t.groupIndexColumn,...t.groupFields]);return o?be(o):null},apply:(e,r)=>{let t=we(r),n=E(e.headers,t.groupPrefix);if(!n||n.prefix!==t.groupPrefix)return{headers:[...e.headers],rows:e.rows.map(a=>[...a])};let o=[...n.keyColumns,t.groupIndexColumn,...t.groupFields],s=[];for(let a of e.rows)for(let u of n.numbers)s.push([...n.keyColumns.map(i=>a[d(e,i)]??""),u,...t.groupFields.map(i=>a[d(e,P(n,u,i))]??"")]);return{headers:o,rows:s}},summary:e=>`Unpivot \`${we(e).groupPrefix}*\` groups \u2192 rows`},ft=(e,r)=>{let t=e.filter(n=>n!==r);return{aggregateColumns:t,aggregateModes:t.map(()=>"first")}},gt=e=>{let r=E([...e]);if(!r)return null;let t=new Set(e.filter(o=>o.trim()!=="")),n="group";if(t.has(n)){let o=1;for(;t.has(`group_${o}`);)o+=1;n=`group_${o}`}return{groupPrefix:r.prefix,groupFields:r.fields,groupIndexColumn:n}};var yt=[Ye,Ze,et,tt,rt,nt,ot,st,it,lt,pt,ct,mt,dt],tr=new Map(yt.map(e=>[e.type,e])),ht=e=>tr.get(e),B=()=>yt.filter(e=>e.addable),w=(e,r)=>{let t=1,n=`${e}_${t}`;for(;r.has(n);)t+=1,n=`${e}_${t}`;return r.add(n),n},rr=(e,r)=>e?w(`${e}_copy`,new Set(r)):"column_copy",nr=(e,r)=>{if(!e)return[];let t=new Set(r);return[w(e,t),w(e,t)]},St=(e,r)=>{let t=r[0]??"",n=r[1]??"";switch(e){case"splitColumn":return{column:t,by:" ",into:nr(t,r),position:"end"};case"filterRows":return{column:t,operator:"gte",value:"0"};case"formatColumn":return{column:t,as:"currency"};case"renameColumn":{let o=new Set(r);return{column:t,to:t?w(`${t}_renamed`,o):"column"}}case"addMetadataColumn":{let o=new Set(r);return{columnName:w("column",o),value:"",position:"end"}}case"removeColumn":return{columns:t?[t]:[]};case"duplicateColumn":return{column:t,to:rr(t,r),position:"afterSource"};case"fillEmptyCells":return{column:t,value:"0"};case"mergeColumns":{let o=new Set(r);return{columns:t&&n?[t,n]:t?[t]:[],by:" ",into:w("merged",o),position:"afterSource",dropSources:"yes"}}case"splitIntoRows":return{column:t,by:","};case"unpivotColumns":{let o=new Set(r);return{columns:r.slice(0,2),nameColumn:w("attribute",o),valueColumn:w("value",o)}}case"pivotColumn":return{namesFrom:t,valuesFrom:n||t};case"groupRows":{let o=t,s=ft(r,o);return{by:o,delimiter:", ",...s}}case"unpivotColumnGroups":return gt(r)??{groupPrefix:"",groupFields:[],groupIndexColumn:"group"};case"combine":return{operation:"join",mappings:[]};default:return{}}};var or=e=>e[0]?y(e[0]):{headers:[],rows:[]},xe=async({sheets:e,steps:r,keepHistory:t=!0,maxRows:n})=>{let o=l=>n!==void 0&&l.rows.length>n?{headers:l.headers,rows:l.rows.slice(0,n)}:l,s=o(or(e)),a=0,u=[],i=[];for(let l=0;l<r.length;l++){s=o(s);let p=r[l];if(u.push([...s.headers]),t&&i.push(Q(s)),p.kind==="generated"){let g=Be(s,p.generated_function);if(g.error)return{grid:s,appliedCount:a,invalidIndex:l,invalidReason:g.error,headersBefore:u,gridsBefore:i};s=g.grid,a+=1;continue}if(p.type==="combine"){if(j(p.settings))return{grid:s,appliedCount:a,invalidIndex:l,invalidReason:"Invalid combine operation",headersBefore:u,gridsBefore:i};if(te(p.settings))return{grid:s,appliedCount:a,invalidIndex:l,invalidReason:"Invalid combine mapping",headersBefore:u,gridsBefore:i};let g=ne(p.settings);if(!g)return{grid:s,appliedCount:a,invalidIndex:l,invalidReason:"Invalid combine operation",headersBefore:u,gridsBefore:i};let C=Pe(e,g);if(C)return{grid:s,appliedCount:a,invalidIndex:l,invalidReason:C,headersBefore:u,gridsBefore:i};s=await Ve(e,g,n),a+=1;continue}let c=ht(p.type);if(!c)return{grid:s,appliedCount:a,invalidIndex:l,invalidReason:`Unknown step type: ${p.type}`,headersBefore:u,gridsBefore:i};let m=c.validate(s,p.settings);if(m)return{grid:s,appliedCount:a,invalidIndex:l,invalidReason:m,headersBefore:u,gridsBefore:i};s=c.apply(Q(s),p.settings),a+=1}return{grid:o(s),appliedCount:a,invalidIndex:null,invalidReason:null,headersBefore:u,gridsBefore:i}},Jr=(e,r)=>M(e,r);var ve=3,sr=(e,r)=>{let t=new Set;for(let n of e){let o=n.trim().toLowerCase();if(o){if(t.has(o))throw new Error(`Sheet "${r}" has duplicate column "${n}"`);t.add(o)}}},Ct=e=>[...new Set(e.map(r=>r.trim()).filter(r=>r!==""))],Rt=e=>Ct(e.flatMap(r=>y(r).headers)),Qr=({prompt:e,sessionId:r,sheets:t,referencedStepTypes:n,referencedColumns:o})=>{let s=t.map(i=>{let l=A(i,ve);return sr(l.headers,i.getName()),l}),a=Ct(s.flatMap(i=>i.headers)),u=[];for(let i of s){for(let l of i.rows)if(u.push(a.map(p=>{let c=i.headers.findIndex(m=>m.trim()===p);return c>=0?String(l[c]??""):""})),u.length>=ve)break;if(u.length>=ve)break}return{prompt:e,session_id:r,columns:a,sample_rows:u,step_types:B().map(i=>({type:i.type,settings:i.settings.map(l=>({name:l.name,type:l.type,required:l.required,is_column:l.isColumn,...l.options?{options:l.options}:{}}))})),...n?.length?{referenced_step_types:n}:{},...o?.length?{referenced_columns:o}:{}}};var ir=0,Ne=()=>`recipe-step-${++ir}`,ar=new Set(B().map(e=>e.type)),ur=e=>({id:Ne(),kind:"generated",name:e.name,summary:typeof e.summary=="string"&&e.summary.trim()!==""?e.summary.trim():void 0,generated_function:e.generated_function,aiSourced:!0}),lr=(e,r)=>{if(!ar.has(e.type))return null;let t=e.type;return{id:Ne(),kind:"typed",type:t,settings:{...St(t,r),...e.settings},aiSourced:!0}},en=(e,r=[])=>e.steps.flatMap(t=>{if(t.kind==="generated")return[ur(t)];let n=lr(t,r);return n?[n]:[]}),wt=e=>e.length<=1?[]:[{id:Ne(),kind:"typed",type:"combine",settings:je(e)}];var T=e=>e.map(r=>{let t=new k({data:r.data,name:r.name,isNotSetColumn:!0});return t.setHeaderRowIndex(r.headerRowIndex),t}),I=50,z=300,bt=e=>({headers:e.headers.slice(0,z),rows:e.rows.slice(0,I).map(r=>r.slice(0,z))}),pr=e=>bt(A(e,I)),xt=e=>{let r=T(e);return{steps:wt(r),targets:r.slice(1).map((t,n)=>({name:De(t.getName(),n+1),headers:y(t).headers})),columnLabels:Rt(r),sourceGrids:r.map(pr)}},cr=e=>{let r=e.headerRowIndex,t=Math.min((e.data[r]??[]).length,z);return{name:e.name,headerRowIndex:0,data:e.data.slice(r,r+1+I).map(n=>(n??[]).slice(0,t))}},cn=e=>xt(e.map(cr)),mn=async(e,r,t,n)=>{let o=T([r])[0];return o?!e||!t||n<0?y(o):Ee(e,o,t,n):e},mr=(e,r)=>xe({sheets:T(e),steps:r,maxRows:I}),dn=async(e,r)=>{let t=await xe({sheets:T(e),steps:r,keepHistory:!1});if(t.invalidIndex!==null)throw new Error(t.invalidReason??"Invalid recipe step");return t.grid},fn=(e,r)=>Ue(T(e),r,I),gn=async e=>{let r=xt(e),t=await mr(e,r.steps);return{...r,resultGrid:bt(t.grid),appliedCount:t.appliedCount,invalidIndex:t.invalidIndex,headersBefore:t.headersBefore}},yn=e=>({steps:[],targets:[],columnLabels:[],sourceGrids:e.map(r=>{let t=(r.data[r.headerRowIndex]??[]).slice(0,z);return{headers:t.map(n=>n==null?"":String(n)),rows:r.data.slice(r.headerRowIndex+1,r.headerRowIndex+1+I).map(n=>t.map((o,s)=>n?.[s]??""))}}),resultGrid:{headers:[],rows:[]},appliedCount:0,invalidIndex:null,headersBefore:[]});export{dr as a,fr as b,vt as c,gr as d,De as e,f,Fe as g,$e as h,y as i,Rr as j,E as k,Or as l,ft as m,ht as n,B as o,rr as p,nr as q,St as r,ne as s,vr as t,Nr as u,Gr as v,Jr as w,Ne as x,en as y,Ct as z,Rt as A,Qr as B,xt as C,cn as D,mn as E,mr as F,dn as G,fn as H,gn as I,yn as J};
@@ -1 +1 @@
1
- import{a as M,d as U,e as d,i as O,n as N}from"./chunk-VS5JZMGO.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};
package/index.d.ts CHANGED
@@ -710,6 +710,8 @@ export type SettingsAPI = {
710
710
  completeImportLogging?: boolean;
711
711
  submitModalConfiguration?: ISubmitModalConfiguration;
712
712
  prompts?: boolean;
713
+ /** Off by default. Turns on the review error/warning/info cell indicator. */
714
+ showReviewCellState?: boolean;
713
715
  successModalConfiguration?: ISuccessModalConfiguration;
714
716
  workersBaseUrl?: string;
715
717
  mappingViewMode?: 'sourceColumns' | 'targetColumns';
@@ -924,6 +926,7 @@ export type AIpromptThemeAPI = {
924
926
  root?: CSSInterpolation;
925
927
  input?: {
926
928
  root?: CSSInterpolation;
929
+ placeholderColor?: string;
927
930
  variables?: {
928
931
  default?: CSSInterpolation;
929
932
  column?: CSSInterpolation;
@@ -956,6 +959,7 @@ export type AIpromptThemeAPI = {
956
959
  root?: CSSInterpolation;
957
960
  input?: {
958
961
  root?: CSSInterpolation;
962
+ placeholderColor?: string;
959
963
  variables?: {
960
964
  default?: CSSInterpolation;
961
965
  column?: CSSInterpolation;
@@ -1348,6 +1352,7 @@ export type PreProcessingThemeAPI = {
1348
1352
  aiAssist?: {
1349
1353
  root?: CSSInterpolation;
1350
1354
  input?: CSSInterpolation;
1355
+ placeholderColor?: string;
1351
1356
  mentionList?: CSSInterpolation;
1352
1357
  mentionItem?: CSSInterpolation;
1353
1358
  mentionItemActive?: CSSInterpolation;
@@ -1355,6 +1360,14 @@ export type PreProcessingThemeAPI = {
1355
1360
  metadataSelection?: MetadataSelectionThemeAPI;
1356
1361
  formPopover?: PreProcessingFormPopoverThemeAPI;
1357
1362
  };
1363
+ configurePdf?: {
1364
+ instruction?: {
1365
+ placeholderColor?: string;
1366
+ };
1367
+ search?: {
1368
+ placeholderColor?: string;
1369
+ };
1370
+ };
1358
1371
  };
1359
1372
 
1360
1373
  type DropzoneIllustrationStyle = {
@@ -1438,6 +1451,7 @@ type CreateCustomTextField = {
1438
1451
  icon?: CSSInterpolation;
1439
1452
  input?: CSSInterpolation;
1440
1453
  errorMessage?: CSSInterpolation;
1454
+ placeholderColor?: string;
1441
1455
  };
1442
1456
 
1443
1457
  type CreateCustomDropdown = {
@@ -1519,6 +1533,7 @@ type ColumnMatchThemeAPI = {
1519
1533
  backgroundColor?: string;
1520
1534
  };
1521
1535
  loading?: CSSInterpolation;
1536
+ dateFormatPlaceholderColor?: string;
1522
1537
  };
1523
1538
  requiredColumns?: {
1524
1539
  title?: CSSInterpolation;
@@ -1573,6 +1588,7 @@ type FilterConditionDropdown = {
1573
1588
  type FindColumnDropdown = {
1574
1589
  root?: CSSInterpolation;
1575
1590
  icon?: CSSInterpolation;
1591
+ placeholderColor?: string;
1576
1592
  list?: {
1577
1593
  root?: CSSInterpolation;
1578
1594
  item?: CSSInterpolation;
@@ -1605,6 +1621,7 @@ type SmartTableThemeAPI = {
1605
1621
  input?: {
1606
1622
  root?: CSSInterpolation;
1607
1623
  icon?: CSSInterpolation;
1624
+ placeholderColor?: string;
1608
1625
  };
1609
1626
  label?: CSSInterpolation;
1610
1627
  valueList?: {
@@ -1634,6 +1651,12 @@ type SmartTableThemeAPI = {
1634
1651
  removeRows?: {
1635
1652
  root?: CSSInterpolation;
1636
1653
  dialog?: CSSInterpolation;
1654
+ dropdown?: {
1655
+ placeholderColor?: string;
1656
+ search?: {
1657
+ placeholderColor?: string;
1658
+ };
1659
+ };
1637
1660
  };
1638
1661
  freezeBoxShadow?: CSSObject['boxShadow'];
1639
1662
  };