@ingestro/importer-react 4.9.5 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{b as _,p as N}from"./chunk-FCZBBIUR.js";var He="prod",Y=()=>{let e=N;return typeof e=="function"?e:void 0},Oe=(e,n)=>{let t=Y();return t?t(e,n):null};import l from"moment";var g="dd.MM.yyyy HH:mm:ss:SSS";var f="DD.MM.YYYY HH:mm:ss:SSS",h="DD.MM.YYYY HH:mm:ss:SSSZ";import{parse as H,format as O,isMatch as U}from"date-fns";import m from"moment";var E=e=>m(e,f,!0).isValid()||m(e,h,!0).isValid(),I={date_dmy:"dd.MM.yyyy",date_mdy:"MM.dd.yyyy",date_iso:"yyyy-MM-dd",datetime:"yyyy-MM-dd HH:mm:ss",time_hm:"hh:mm aaa",time_hms:"hh:mm:ss aaa",time_hm_24:"HH:mm",time_hms_24:"HH:mm:ss"},Xe={time_hm:"hh:mm a",time_hms:"hh:mm:ss a",time_hm_24:"HH:mm",time_hms_24:"HH:mm:ss"},Le=e=>{try{return O(H(e,g,new Date),"dd.MM.yyyy")}catch{return e}},G=(e,n,t,r)=>{try{if(typeof e=="string"){if(r===!1||isNaN(Date.parse(e))&&!B(e))return e;let s=t||["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","dd/MM/yyyy","dd-MM-yyyy HH:mm:ss","dd-MM-yyyy HH:mm","yyyy-MM-dd'T'HH:mm:ssZ","yyyy-MM-dd'T'HH:mm:ss","yyyy-MM-dd","yyyy-MM-dd HH:mm:ss","dd-MM-yyyy"],i;for(let o=0;o<s.length;++o)if(U(e,s[o])){i=s[o];break}if(i)return O(H(e,i,new Date),n||g);throw new Error("not found format")}else throw new Error("not date string")}catch{return e}},$=["YYYY-MM-DDTHH:mm:ss.SSSZ","X","x"],Ye=(e,n)=>{e===null&&(e=""),e=/^\d{3,}$/.test(e)?parseInt(e,10):e;let t=/^\d{1,2}$/.test(e);t&&(e+=":00");let r=m(e,$,!0).isValid()?m(e):m(e,n),s=r.isValid(),i=m(e,n,!0).isValid()&&!t;return e===""&&(s=!0,i=!0),s&&!i?r.format(n):e},Ae=(e,n)=>{let t=()=>m.parseZone(e).format(n);try{if(typeof e=="string"){if(m(e,n,!0).isValid())return n.includes("Z")?t():m.utc(e,n).format(n);if(m(e).isValid())return n.includes("Z")?t():m.utc(e).format(n);throw new Error("not found format")}else throw new Error("not date string")}catch{return e}},Ue=(e,n)=>{switch(n){case"date_dmy":case"date_mdy":case"date_iso":case"datetime":return G(e,I[n],[I[n]]);default:return e}},B=e=>{let[n,t,r]=e?.split(" ")?.[0]?.split(/[./-]/);return!!(Number(r)&&Number(t)<=12&&Number(n)<=31)};var $e=e=>e===""||e===null||e===void 0,y=e=>typeof e=="string"&&e.trim()!=="";var K=["date","date_dmy","date_mdy","date_iso","datetime"],P=new Set(K),T=e=>y(e),z=e=>typeof e=="string"&&P.has(e),ze=({columnKey:e,columnType:n,inputFormat:t})=>!!e&&T(t)&&z(n);var S=["/",".","-"," "],x=e=>{let n=e.trim();if(!n)return null;for(let t of n){let r=S.find(s=>s===t);if(r)return r}return null},tt=(e,n=".")=>{for(let t of e){if(typeof t!="string")continue;let r=x(t);if(r)return r}return n},W=/(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d|[+-](?:[01]\d|2[0-3])[0-5]\d)$/i,j=/T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?[+-](?:[01]\d|2[0-3])$/i,J=e=>W.test(e)||j.test(e),q={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,"]]"),Q=/YYYY|YY|MMMM|MMM|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z/g,ee=e=>/^(H{1,2}|h{1,2})$/.test(e),k=e=>e.match(Q)??[],F=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},Z=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},te=e=>{let n=k(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},ne=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&&ee(r));n+=o?i==="mm"?"MM":"M":i,r=i,t+=i.length;continue}n+=e[t],t+=1}return n},b=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+=q[o]??o,t+=i}else n+=s,t+=1}let r=Z(F(n));return te(r)&&(n=ne(n)),n},C=e=>{let n=Z(F(e));return k(n).some(t=>t==="Z"||t==="ZZ")},R=/^(YYYY|YY|MMMM|MMM|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z)/,re=new Set(["HH","H","hh","h","mm","m","ss","s","SSS","SS","S","A","a","ZZ","Z"]),ie=new Set(["MMM","MMMM"]),w={D:"day",DD:"day",M:"month",MM:"month",YY:"year",YYYY:"year"},se=/(\s+\d{1,2}:\d{2}(?::\d{2})?(?::\d+|\.\d+)?(?:\s*[AaPp][Mm])?(?:\s*(?:Z|[+-]\d{2}(?::?\d{2})?))?)$/,oe=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(R);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]==="\\"||R.test(e.slice(t)));)s+=e[t],t+=1;n.push({kind:"text",text:s})}return n},le=e=>e.map(n=>n.kind==="token"?n.token:n.text).join(""),ce=e=>{for(let n=0;n<e.length;n++){let t=e[n];if(t.kind!=="token"||!re.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},ue=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||!S.includes(r)?null:r},V=e=>{let n=[];for(let t of e){if(t.kind!=="token")continue;let r=w[t.token];if(!r)return null;n.push(r)}return n.length>0?n:null},ae=(e,n)=>{if(ue(e)===null||!V(e))return!1;for(let t of e){if(t.kind==="token"){if(!w[t.token])return!1;continue}if(t.text.length!==1||!S.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},me=e=>l(String(e).padStart(2,"0"),"YY",!0).year(),de=(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(c=>/^\d+$/.test(c)))return l.invalid();let s=1,i=1,o=1970,M=!1;for(let c=0;c<n.length;c++){let d=r[c],a=Number(d);if(!Number.isFinite(a))return l.invalid();switch(n[c]){case"day":if(d.length>2)return l.invalid();s=a;break;case"month":if(d.length>2)return l.invalid();i=a;break;case"year":if(d.length===2)o=me(a);else if(d.length===4)o=a;else return l.invalid();M=!0;break}}if(!M)return l.invalid();let u=l({year:o,month:i-1,day:s});return!u.isValid()||u.year()!==o||u.month()!==i-1||u.date()!==s?l.invalid():u},Me=(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(se);return!t||t.index===void 0||t.index===0?null:{dateText:e.slice(0,t.index),timeText:t[1]}},X=(e,n)=>{let t=b(n),r=C(t),s=oe(t);if(s.some(D=>D.kind==="token"&&ie.has(D.token)))return r?l.parseZone(e,t,!0):l(e,t,!0);let i=ce(s),o=s.slice(0,i),M=s.slice(i),u=V(o);if(!u||!ae(o,M))return r?l.parseZone(e,t,!0):l(e,t,!0);let c=le(M),d=Me(e,c);if(!d)return l.invalid();let a=de(d.dateText,u);if(!a.isValid())return l.invalid();if(!c)return a;let p=r?l.parseZone(d.timeText,c,!0):l(d.timeText,c,!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()},L=e=>e.trim(),pe=(e,n)=>{if(!y(e))return e;let t=e.trim();if(E(t))return t;let r=L(e),s=X(r,n.trim());if(!s.isValid())return e;let i=C(b(n.trim()))&&J(e);return s.format(i?h:f)},nt=(e,n)=>{if(!y(e)||E(e.trim()))return!0;let t=L(e);return X(t,n.trim()).isValid()},ye=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(c=>c.replace(/[,.\-/]/g,"")).map(Number).filter(c=>isNaN(c)||c<=31),[o,M]=i,u=null;if(!isNaN(o)&&o>12?u="dM":!isNaN(M)&&M>12&&(u="Md"),!u)continue;if(n===null){n=u;continue}if(n!==u)return null}catch{continue}return n},rt=(e,n)=>{if(T(n)){let s=n.trim();return e.map(i=>pe(i,s))}let t=[],r=ye(e);for(let s=0;s<e.length;s++){let i=e[s];t.push(_(i,!1,{allDefaultDateFormat:!0,priorityFormat:r}))}return t};export{g as a,f as b,h as c,E as d,I as e,Xe as f,Le as g,Ye as h,Ae as i,Ue as j,$e as k,y as l,T as m,z as n,ze as o,He as p,Oe as q,x as r,tt as s,J as t,b as u,nt as v,ye as w,rt as x};
@@ -0,0 +1 @@
1
+ import{d as N}from"./chunk-JWTYPSUX.js";import{f as F,g as O,h as S,i as J}from"./chunk-FCZBBIUR.js";import{c as p}from"./chunk-EWEVS5OB.js";import{isEmpty as y,uniq as j}from"lodash";var M=0,I=class{constructor({sheet:e,columnKey:t,rows:s,columnIndex:n,id:r,label:o,refJoinSheetColum:i,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=y(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 y(t)?[""]:t};this.getUniqueRows=()=>(this.uniques===void 0&&(this.uniques=j(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=y(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),e)};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=y(s)?[""]:s,this.rowsLoaded=!0,this.dateInputFormatSamples=[...this.rows]),typeof r>"u"?(M++,this.id=`${t}-${M}`):this.id=r,o&&(this.label=o),l&&(this.parserDateFormat=l,this.parserDateFormatResolved=!0),Object.defineProperty(this,"refJoinSheetColum",{value:i,enumerable:!1,writable:!0,configurable:!0})}setRows(e){this.rows=e,this.rowsLoaded=!0,this.uniques=void 0}},g=I;var x=class extends g{constructor({sheet:t,sheetColumns:s,rows:n,id:r,columnKey:o}){super({columnKey:o,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}},V=x;var A=["?",",","@"];import{isNaN as U,minBy as W,isString as z,isEqual as q,isEmpty as K,isNil as Y}from"lodash";var R=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}}},H=R;var X={dmy:"D/M/YYYY",us:"M/D/YY",de:"DD.MM.YYYY"},P=(u,e)=>u?O(u,S(e)):void 0,T=u=>{let e=S(u);return e==="os"?F():X[e]},ce=({data:u,excelDateCells:e,columnDateFormats:t,maxRow:s=50,maxCol:n=300})=>{let r=Math.min(u.length,s),o=u.slice(0,r).map(i=>i.slice(0,n));return J(o,e,i=>S(t?.[i]))};var _=0,D=class{constructor({data:e,name:t,isNotSetColumn:s,id:n,columnDateFormats:r,excelDateCells: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 H({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 o=`${r.sourceCell.row},${r.sourceCell.col}`;this.usedSourceCells.delete(o)}for(let o=0;o<this.data.length;o++)this.data[o].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.columnDateFormats=void 0,this.excelDateCells=void 0}};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 A.some(s=>t===s)};this.isSignificantCell=e=>!K(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=>!N.includes(z(e)?e.toLowerCase():e)&&U(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:W(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)=>p(e.getColumnKey())<p(t.getColumnKey())?-1:p(e.getColumnKey())>p(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?p(s.getColumnKey())===p(`${e}`):s.getColumnKey()===e));this.getColumnsByKey=(e,t)=>(this.ensureColumnsBuilt(),this.columns.filter(s=>t?p(s.getColumnKey())===p(`${e}`):s.getColumnKey()===e));this.getValues=()=>{let e=this.data.filter((s,n)=>n>this.headerRowIndex);if(K(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++)Y(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.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=>{this.data=e,this.columnDateFormats=void 0,this.excelDateCells=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.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 o=this.data[r];if(r>this.headerRowIndex){let i=o[e]??"",l=P(this.excelDateCells?.[`${r},${e}`],n);if(s.push(l??this.parseValue(i)),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?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=>q(`${n}`,`${e}`));this.parseValue=e=>typeof e=="string"?e.trim():e;this.data=e,this.name=t,this.columnDateFormats=r,this.excelDateCells=o,typeof n>"u"?(_++,this.id=`${t}-${_}`):this.id=n,this.columnsInitialized=!!s}},B=D;var v=class extends B{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((o,i)=>this.joinHistory[this.joinHistory.length-1].mappingIndexes.every(l=>l.target!==i))[r]};this.setJoinColumns=(t,s)=>{let n=this.data[this.headerRowIndex];if(!n){this.columns=[];return}let r=[];for(let o=0;o<n.length;++o){let i=n[o],l=s.findIndex(a=>a.source===o),m=this.columns[o]&&this.columns[o].getType()===1;if(l>=0||m){let a=t[l],h;m&&l>=0?h=[...this.columns[o].getJoinedSheetColumns(),a.target]:m?h=this.columns[o].getJoinedSheetColumns():h=[a.source.getRefJoinSheetColum()??a.source,a.target],r.push(new V({columnKey:`${i}`,sheetColumns:h,sheet:this,rows:this.getRowsByColumnIndex(o)}))}else{let a=this.columns[o]?this.columns[o].getRefJoinSheetColum()??this.columns[o]:this.findRefJoinSheetColumn(o);r.push(new g({columnKey:`${i}`,sheet:a.getSheet(),rows:this.getRowsByColumnIndex(o),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)}},Je=v;var G=({rowA:u,rowB:e},t)=>t.every(s=>{let n=`${u[s.source]??""}`,r=`${e[s.target]??""}`;return n===r&&n!==""&&r!==""}),L=(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)},Q=(u,e,t)=>{let s=[],n=u.headerRow,r=e.headerRow;for(let o=0;o<n.length;++o)s.push(n[o]);for(let o=0;o<r.length;++o)t.every(i=>i.target!==o)&&s.push(r[o]);return s},Pe=async(u,e)=>{let t=u.values,s=e.values,n=u.headerRow,r=e.headerRow,o=[...n,...r],i=[];i.push(o);for(let l=0;l<t.length;++l)i.push([...t[l],...s[0]]);return{data:i,type:"ADD_TO_ALL_ROWS"}},Te=async(u,e)=>{let t=u.values,s=e.values,n=u.headerRow,r=e.headerRow,o=[...n,...r],i=[];i.push(o);for(let l=0;l<t.length;++l)i.push([...t[l],...r.map(()=>"")]);for(let l=0;l<s.length;++l)i.push([...n.map(()=>""),...s[l]]);return{data:i,type:"JOIN_WITHOUT_COLUMNS"}},Ke=async(u,e,t)=>{let s=u.values,n=e.values,r=[],o=[],i={},l=Q(u,e,t);r.push(l);let m=new Map;for(let a=0;a<n.length;++a){let h=L(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],c=L(d,t,"source");for(let f of c&&m.get(c)||[]){let C=n[f];i[f]=!0,h=!0,r.push([...d,...C.filter((b,$)=>t.every(E=>E.target!==$))])}h||o.push([...d,...e.headerRow.filter((f,C)=>t.every(b=>b.target!==C)).map(()=>"")])}for(let a=0;a<n.length;++a){if(i[a])continue;let h=n[a],d=u.headerRow.map(()=>"");t.forEach(c=>{d[c.source]=h[c.target]}),o.push([...d,...h.filter((c,f)=>t.every(C=>C.target!==f))])}return o.forEach(a=>{r.push(a)}),{data:r,type:"JOIN_ON_COLUMNS"}},_e=async(u,e,t)=>{let s=e.headerRow.filter((i,l)=>t.every(m=>m.target!==l)),r=[[...u.headerRow,...s]];for(let i=0;i<u.values.length;++i){let l=[...u.values[i],...s.map(()=>"")];r.push(l)}let o=e.values;for(let i=0;i<o.length;++i){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]=o[i][a]:m.push(o[i][a])}r.push([...l,...m])}return{data:r,type:"APPEND_TO_COLUMNS"}},Be=async(u,e,t)=>{let s=u.values,n=e.values,r=s.length+n.length,o=0,i={};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 c=n[d];if(G({rowA:m,rowB:c},t)&&(a=d,h++,h===2))break}h===1&&a!==null&&(o+=1,i[a]=!0)}for(let l=0;l<n.length;l++)i[l]&&(o+=1);return{count:o,total:r}};export{g as a,H as b,ce as c,B as d,Je as e,L as f,Pe as g,Te as h,Ke as i,_e as j,Be as k};
@@ -0,0 +1,7 @@
1
+ import{a as W}from"./chunk-J5WOZVPO.js";var Fe=e=>!e||typeof e!="string"?"":e.replace(/<[^>]*>/g,""),_e=e=>!!e&&/[A-Za-z0-9_]/.test(e),J=e=>{let r=[],n=/(['"])((?:(?!\1)[^\\]|\\.)*)(\1)/g,t;for(;(t=n.exec(e))!==null;)r.push({start:t.index,end:t.index+t[0].length});return r},Z=(e,r)=>r.some(n=>e>=n.start&&e<n.end),Q=(e,r,n)=>{let t=e,s=[...r,{label:"rowIndex",key:"rowIndex"}];for(let i of s){let{label:o,key:a}=i,l=`@${o}`,u=J(t),c=a==="rowIndex"?`row.${a}`:`row["${a.trim()}"]`,m="",d=0,f=0;for(;f<t.length;){let p=t.indexOf(l,f);if(p===-1)break;let w=p+l.length,R=!_e(t[w]);m+=t.slice(d,p),R&&!Z(p,u)?m+=c:m+=l,d=w,f=w}m+=t.slice(d),t=m}if(n){let i=W.getInstance().getTruthyWords(),o=W.getInstance().getFalsyWords(),a=J(t),l=(u,c,m)=>{let d=u;for(let f of c){let p=String(f);if(!p)continue;let w=p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),R=new RegExp(`\\b${w}\\b`,"gi"),A="",x=0,E;for(R.lastIndex=0;(E=R.exec(d))!==null;){let F=E.index,ge=F+E[0].length;A+=d.slice(x,F),Z(F,a)?A+=m:A+=E[0],x=ge,E.index===R.lastIndex&&R.lastIndex++}A+=d.slice(x),d=A}return d};t=l(t,i,"true"),t=l(t,o,"false")}return t},We=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&").replace(/@/g,"[@]");import{Interpreter as fe}from"eval5";import*as Ee from"@babel/standalone";var $="REMOVE_ROW",I="REMOVE_DUPLICATE_ROWS",P="REMOVE_DUPLICATE_ROWS_BY",B="REMOVE_EMPTY_ROWS",V="REMOVE_EMPTY_ROWS_BY",y="IGNORE_CASE",v="IGNORE_BLANKS",q=[y,v],S=[I,P,B,V],N=[$,...S],D=[$,I,B],he=new RegExp(`\\b(?:${D.join("|")})\\(\\)|\\b(?:${N.join("|")})\\b|\\b(?:${q.join("|")})\\b`),X=/^[A-Z][A-Z0-9_]*$/,O=Object.freeze({__removeRowMarker:!0});var g=(e,r)=>{if(e[r]!=="/")return null;if(e[r+1]==="/"){let n=r+2,t=" ";for(;n<e.length&&e[n]!==`
2
+ `;)t+=" ",n+=1;return{end:n,erased:t}}if(e[r+1]==="*"){let n=r+2,t=" ";for(;n<e.length;){if(e[n]==="*"&&e[n+1]==="/")return t+=" ",n+=2,{end:n,erased:t};t+=e[n]===`
3
+ `?`
4
+ `:" ",n+=1}return{end:n,erased:t}}return null};var we=new Set(["return","typeof","instanceof","in","of","void","delete","new","await","case","throw","else","do","default","yield"]),_=(e,r)=>{if(e[r]!=="/"||e[r+1]==="/"||e[r+1]==="*")return null;let n=r-1;for(;n>=0&&/[ \t]/.test(e[n]);)n-=1;if(n>=0){let a=e[n];if(a==="+"||a==="-"||a===")"||a==="]")return null;if(/[\w$]/.test(a)){let l=n;for(;l>0&&/[\w$]/.test(e[l-1]);)l-=1;let u=e.slice(l,n+1);if(!we.has(u))return null}}let t=r+1,s=!1,i=!1,o=-1;for(;t<e.length&&e[t]!==`
5
+ `;){if(s){s=!1,t+=1;continue}if(e[t]==="\\"){s=!0,t+=1;continue}if(e[t]==="["&&!i){i=!0,o=t,t+=1;continue}if(e[t]==="]"&&i){t===o+1||t===o+2&&e[o+1]==="^"||(i=!1,o=-1),t+=1;continue}if(e[t]==="/"&&!i){for(t+=1;t<e.length&&/[a-z]/i.test(e[t]);)t+=1;return{end:t,erased:" ".repeat(t-r)}}t+=1}return null};var ee=(e,r)=>{let n="",t=0;for(;t<e.length;){let s=g(e,t);if(s){n+=e.slice(t,s.end),t=s.end;continue}let i=_(e,t);if(i){n+=e.slice(t,i.end),t=i.end;continue}let o=t+1;for(;o<e.length&&!(g(e,o)!==null||_(e,o)!==null);)o+=1;n+=r(e.slice(t,o)),t=o}return n};var G=(e,r)=>{let n=e[r],t=r+1;for(;t<e.length;){if(e[t]==="\\"){t+=2;continue}if(e[t]===n)return t+1;t+=1}return t},K=(e,r)=>{let n=r,t=1;for(;n<e.length&&t>0;){let s=e[n];if(s==="'"||s==='"'){n=G(e,n);continue}if(s==="`"){n=Oe(e,n);continue}if(s==="/"){let i=g(e,n);if(i){n=i.end;continue}let o=_(e,n);if(o){n=o.end;continue}}if(s==="{"&&(t+=1),s==="}"&&(t-=1,t===0))return n;n+=1}return n},Oe=(e,r)=>{let n=r+1;for(;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]==="`")return n+1;if(e[n]==="$"&&e[n+1]==="{"){n=K(e,n+2)+1;continue}n+=1}return n};var j=(e,r)=>{let n="",t=0,s=i=>{let o=i+1,a="`";for(;o<e.length;){if(e[o]==="\\"){a+=e.slice(o,Math.min(o+2,e.length)),o+=2;continue}if(e[o]==="`"){a+="`",o+=1;break}if(e[o]==="$"&&e[o+1]==="{"){a+="${",o+=2;let l=K(e,o);a+=j(e.slice(o,l),r),l<e.length&&e[l]==="}"?(a+="}",o=l+1):o=l;continue}a+=e[o],o+=1}return{end:o,mapped:a}};for(;t<e.length;){let i=g(e,t);if(i){n+=e.slice(t,i.end),t=i.end;continue}let o=_(e,t);if(o){n+=e.slice(t,o.end),t=o.end;continue}let a=e[t];if(a==="'"||a==='"'){let u=G(e,t);n+=e.slice(t,u),t=u;continue}if(a==="`"){let{end:u,mapped:c}=s(t);n+=c,t=u;continue}let l=t+1;for(;l<e.length&&!(g(e,l)!==null||_(e,l)!==null||e[l]==="'"||e[l]==='"'||e[l]==="`");)l+=1;n+=r(e.slice(t,l)),t=l}return n};var xe=new RegExp(`@(?=(?:${N.join("|")})\\s*\\()`,"g"),be=new RegExp(`\\b(${D.join("|")})\\(\\)\\(\\)`,"g"),Ae=e=>e.replace(xe,"").replace(be,"$1()"),C=e=>j(e,r=>ee(r,Ae));var ne=(e,r)=>r+1>=e.length?{end:r+1,erased:" "}:{end:r+2,erased:" "},te=(e,r,n)=>{let t=r+1,s=" ";for(;t<e.length;){if(e[t]==="\\"){let i=ne(e,t);s+=i.erased,t=i.end;continue}if(e[t]===n){s+=" ",t+=1;break}s+=" ",t+=1}return{end:t,erased:s}},T=e=>{let r="",n=0,t=s=>{let i=s+1,o=" ";for(;i<e.length;){if(e[i]==="\\"){let a=ne(e,i);o+=a.erased,i=a.end;continue}if(e[i]==="`"){o+=" ",i+=1;break}if(e[i]==="$"&&e[i+1]==="{"){o+="${",i+=2;let a=1;for(;i<e.length&&a>0;){let l=e[i];if(l==="'"||l==='"'){let u=te(e,i,l);o+=u.erased,i=u.end;continue}if(l==="`"){let u=t(i);o+=u.erased,i=u.end;continue}if(l==="/"){let u=g(e,i);if(u){o+=u.erased,i=u.end;continue}let c=_(e,i);if(c){o+=c.erased,i=c.end;continue}}if(l==="{"&&(a+=1),l==="}"&&(a-=1,a===0)){o+="}",i+=1;break}o+=l,i+=1}continue}o+=" ",i+=1}return{end:i,erased:o}};for(;n<e.length;){let s=e[n];if(s==="'"||s==='"'){let{end:i,erased:o}=te(e,n,s);r+=o,n=i;continue}if(s==="`"){let{end:i,erased:o}=t(n);r+=o,n=i;continue}r+=s,n+=1}return r};var re=(e,r)=>{let n="",t=0;for(;t<e.length;){let s=r(e,t);if(s){n+=s.erased,t=s.end;continue}n+=e[t],t+=1}return n},b=e=>re(re(T(e),_),g);var H=new RegExp(`\\b(${S.join("|")})\\s*\\(`,"g"),oe=/\bREMOVE_ROW\s*\(\s*\)/g,Le=new RegExp(`^\\s*(${S.join("|")})\\s*\\([\\s\\S]*\\)\\s*$`),h=(e,r,n)=>({code:e,messageKey:r,params:n}),ye=(e,r)=>{let n=0;for(let t=r;t<e.length;t++){let s=e[t];if(s==="(")n+=1;else if(s===")"&&(n-=1,n===0))return t}return-1},ve=e=>{let r=[],n="",t=0,s=null;for(let i=0;i<e.length;i++){let o=e[i];if(s){n+=o,o===s&&e[i-1]!=="\\"&&(s=null);continue}if(o==='"'||o==="'"||o==="`"){s=o,n+=o;continue}if(o==="("||o==="["||o==="{"){t+=1,n+=o;continue}if(o===")"||o==="]"||o==="}"){t-=1,n+=o;continue}if(o===","&&t===0){n.trim()&&r.push(n.trim()),n="";continue}n+=o}return n.trim()&&r.push(n.trim()),r},Se=(e,r)=>{if(e===y||e===v)return{flag:e};let n=e.match(/^@(.+)$/);if(n){let o=n[1].trim(),a=r.find(l=>l.label===o);return a?{key:a.key}:{unknown:o}}let t=e.match(/^(?:row\s*)?\[\s*["']([^"']+)["']\s*\]$/);if(t){let o=t[1].trim(),a=r.find(l=>l.key===o||l.key.trim()===o);return a?{key:a.key}:{unknown:o}}let s=e.match(/^row\.([a-zA-Z_$][\w$]*)$/);if(s){let o=s[1].trim(),a=r.find(l=>l.key===o||l.key.trim()===o);return a?{key:a.key}:{unknown:o}}let i=e.match(/^row\.(.+)$/);return i?{unknown:i[1].trim()}:{unknown:e}},Ce=(e,r)=>{let n=T(e).trim(),t=n.match(new RegExp(`^(${S.join("|")})\\s*\\(`));if(!t)return{kind:"sheetAction",error:h("SHEET_HELPER_IN_CONDITION","txt_prompts_sheet_helper_must_stand_alone")};let s=t[1],i=n.indexOf("(",t[0].length-1),o=ye(n,i);if(o<0||n.slice(o+1).trim()!=="")return{kind:"sheetAction",error:h("SHEET_HELPER_IN_CONDITION","txt_prompts_sheet_helper_must_stand_alone")};let l=e.trim().slice(i+1,o),u=ve(l),c=s===I||s===P,m=s===P||s===V,d=c?"duplicate":"empty";if(!m&&u.length>0){for(let x of u)if((x===y||x===v)&&!c)return{kind:"sheetAction",error:h("FLAG_ON_EMPTY_HELPER","txt_prompts_flags_only_for_duplicates")}}let f=[],p=new Set,w=!1,R=!1;for(let x of u){let E=Se(x,r);if(E){if("flag"in E){if(!c)return{kind:"sheetAction",error:h("FLAG_ON_EMPTY_HELPER","txt_prompts_flags_only_for_duplicates")};if(p.has(E.flag))return{kind:"sheetAction",error:h("DUPLICATE_FLAG","txt_prompts_duplicate_flag",{flag:E.flag})};p.add(E.flag),E.flag===y&&(w=!0),E.flag===v&&(R=!0);continue}if("unknown"in E)return X.test(E.unknown)?{kind:"sheetAction",error:h("INVALID_FLAG","txt_prompts_invalid_flag",{flag:E.unknown})}:m?{kind:"sheetAction",error:h("UNKNOWN_COLUMN","txt_prompts_unknown_column",{column:E.unknown})}:{kind:"sheetAction",error:h("NO_ARG_HELPER_WITH_COLUMNS","txt_prompts_use_by_helper",{helper:s,byHelper:`${s}_BY`})};if(!m)return{kind:"sheetAction",error:h("NO_ARG_HELPER_WITH_COLUMNS","txt_prompts_use_by_helper",{helper:s,byHelper:`${s}_BY`})};f.push(E.key)}}return m&&f.length===0?{kind:"sheetAction",error:h("MISSING_COLUMN","txt_prompts_missing_by_column")}:{kind:"sheetAction",params:{mode:d,columnKeys:f,...c?{ignoreCase:w,ignoreBlanks:R}:{}}}},Te=(e,r)=>{let n=0,t=0;for(let s=r-1;s>=0;s--){let i=e[s];if(i===")")n+=1;else if(i==="("){if(n-=1,n<0)return!1}else if(i==="}")t+=1;else if(i==="{"){if(t-=1,t<0)return!1}else{if(n===0&&t===0&&i==="?")return!0;if(n===0&&t===0&&i===";")return!1}}return!1},ke=e=>e.replace(/\bREMOVE_ROW\s*\(\s*\)\s*\(\s*\)/g,"REMOVE_ROW()"),U=e=>{let r=ke(b(e));oe.lastIndex=0;let n;for(;(n=oe.exec(r))!==null;){let t=n.index,s=t+n[0].length,i=t-1;for(;i>=0&&(/\s/.test(r[i])||r[i]==="(");)i-=1;let o=i>=0?r[i]:"",a=s;for(;a<r.length&&(/\s/.test(r[a])||r[a]===")");)a+=1;let l=a<r.length?r[a]:"";if(!(o==="?"||o===":"&&Te(r,i))||l==="?"||l===","||l==="+"||l==="-"||l==="*"||l==="/"||l==="%"||l==="&"||l==="|"||l==="="||l==="!"||l==="<"||l===">"||l==="."||l==="["||l==="(")return h("REMOVE_ROW_PLACEMENT","txt_prompts_remove_row_placement")}},ie=e=>{let r=b(e);return/\bREMOVE_ROW\s*\(/.test(r)?!0:(H.lastIndex=0,H.test(r))},se=(e,r)=>{if(!e?.trim())return{kind:"valueTransform"};let n=b(e);H.lastIndex=0;let t=H.test(n),s=/\bREMOVE_ROW\s*\(/.test(n);if(t)return Le.test(e.trim())?s?{kind:"sheetAction",error:h("SHEET_HELPER_IN_CONDITION","txt_prompts_sheet_helper_must_stand_alone")}:Ce(e,r):{kind:"sheetAction",error:h("SHEET_HELPER_IN_CONDITION","txt_prompts_sheet_helper_must_stand_alone")};if(s){let i=U(e);return i?{kind:"conditionalRemove",error:i}:{kind:"conditionalRemove"}}return{kind:"valueTransform"}},L=e=>e===O?!0:typeof e!="object"||e===null?!1:e.__removeRowMarker===!0;var Y=({t:e,count:r})=>({title:e("txt_confirm_title"),description:e("txt_confirm_remove_selected_rows",{count:r}),confirmButton:e("txt_continue")});var Ie=({t:e,showConfirmModal:r,visualRows:n,dataRowCount:t,mode:s,onConfirm:i,onCancel:o})=>{if(n.length===0)return o(),!1;let{title:a,description:l,confirmButton:u}=Y({t:e,count:n.length,dataRowCount:t,mode:s});return r({isShowIcon:!0,title:a,description:l,textPositiveButton:e("txt_cancel"),textNegativeButton:u,onClickPositiveButton:o,onClickNegativeButton:i,disabledClickOutside:!0}),!0};var le=({sourceDataArray:e,updates:r,selectedColumn:n})=>r.map(([t,s])=>{let i=e[t],o=typeof i=="object"&&i!==null&&!Array.isArray(i)?i[n]??null:null;return[t,s,o]}),ae=(e,r)=>{if(r.length===0)return e;let n=[...new Set(r)].sort((t,s)=>t-s);return e.map(([t,s,i])=>{let o=t,a=0;for(let l of n)l<o&&(a+=1);return[o-a,s,i]})};var vt=e=>e?`${e}_errors`:"model-data_errors",St=(e,r,n,t)=>!e&&r===0&&!n&&t>1,k=e=>e!=null&&e!==-1,Ct=(e,r)=>k(e)&&k(r);var M=10,ue=({hot:e,outputResponses:r,selectedColumn:n,lastValidRowIndex:t,kind:s,applyOnlyErrors:i,errors:o,currentColumnIndex:a})=>{let l=[],u=[],c=[],m=[],d=0,f=0;for(let p=0;p<r.length;p++){let w=e?.toVisualRow(p);if(!k(w)||p>t)continue;d+=1;let R=r[p]?.[0]??null;if(L(R)){s==="conditionalRemove"&&(f+=1,typeof w=="number"&&u.push(w),c.length<M&&c.push([R]),!i&&m.length<M&&m.push([R,p+1]));continue}l.push([p,n,R]),c.length<M&&c.push([R]),i?o?.[p]?.[a??-1]?.validate&&(s!=="conditionalRemove"||m.length<M)&&m.push([R,p+1]):s==="conditionalRemove"?m.length<M&&m.push([R,p+1]):m.push([R,p+1])}return{updateOutputResponses:l,previewOutputResponses:c,rowsToRemoveVisual:u,testOutputRows:m,dataRowCount:d,removeCount:f}};var z=e=>(e?.countRows()??0)-2,Pe=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ce=({hot:e,sourceDataArray:r,rowsToRemove:n,selectedColumnKey:t,maxPreviewRows:s=10})=>{let i=new Set(n),o=z(e),a=[];for(let l=0;l<=o&&a.length<s;l++){let u=e?.toVisualRow(l);if(!k(u))continue;let c=r[l];if(!Pe(c))continue;let m=typeof u=="number"&&i.has(u);a.push({...c,...m&&t?{[t]:O}:{},ai_prompt_error_row_index:l+1})}return a};var Me=/^[^\s,;()[\]{}+\-*/=<>!&|?.]+(?:\s+[^\s,;()[\]{}+\-*/=<>!&|?.]+)*/,me=(e,r)=>{let n=b(C(e)),t=[...r.map(s=>s.label),"rowIndex"].sort((s,i)=>i.length-s.length);for(let s=0;s<n.length;s++){if(n[s]!=="@")continue;let i=n.slice(s+1),o=t.find(l=>i.startsWith(l)&&!/[\w$]/.test(i.charAt(l.length)||""));if(o){s+=o.length;continue}return i.match(Me)?.[0]?.trim()||void 0}};var Ve=["eval","Function","setTimeout","setInterval","fetch","XMLHttpRequest","document","window"],pe=new RegExp(`\\b(?:${Ve.join("|")})\\b`,"g"),Ne=/^[^\s,;()[\]{}+\-*/=<>!&|?.]+(?:\s+[^\s,;()[\]{}+\-*/=<>!&|?.]+)*/,De=(e,r)=>{for(let n=r;n>=0;n--){if(e[n]==="@"){let t=e.slice(n+1).match(Ne)?.[0];if(!t)return!1;let s=n+1+t.length;return r>=n&&r<s}if(/[,;()[\]{}+\-*/=<>!&|?\n]/.test(e[n]))return!1}return!1},de=e=>{let r=C(e),n=b(r);pe.lastIndex=0;let t;for(;(t=pe.exec(n))!==null;)if(!De(n,t.index))throw new Error(`Formula contains potentially unsafe operations: ${t[0]}`);return`(row) => {
6
+ return (${r})
7
+ }`};var Re=class{constructor(){this.formula="";this.outputData=[];this.initialize=()=>Promise.resolve();this.cleanupData=()=>{this.outputData=[]};this.setFormula=r=>(this.formula=r,Promise.resolve());this.check=()=>!0;this.parse=async(r,n,t)=>{this.outputData=[];let s=Q(this.formula,n,t),i=this.generateInputValues(r,n),o=i?.[0];await this.validateFunction([o],n,s);let a=this.replaceNullishCoalescingWithLogicalOr(s),l=this.transpileToES5(a);for(let u=0;u<i.length;u++)try{let c={$$inputs:{...i[u],rowIndex:u+1},REMOVE_ROW:()=>O},f=new fe(c,{timeout:5e3}).evaluate(l)(c.$$inputs);if(L(f)){this.outputData[u]=[O];continue}let p=f===void 0?"":f;this.outputData[u]=[JSON.parse(JSON.stringify(p))]}catch(c){throw new Error(`Error in row ${u+1}: ${c instanceof Error?c.message:"Check your formula"}`)}return this.outputData};this.validateFunction=async(r,n,t)=>{let s=[...n.map(u=>u.key.trim()),"rowIndex"],i=t||this.formula;if(i){let u=/row\.([a-zA-Z_][\w$]*)/g,c=i.matchAll(u);for(let m of c){let d=m[1];if(!s.includes(d))throw new Error(`Invalid variable: row.${d} is not a valid column reference`)}}let o=r[0],a=this.replaceNullishCoalescingWithLogicalOr(t||this.formula),l=this.transpileToES5(a);try{let u={$$inputs:{...o,rowIndex:0},REMOVE_ROW:()=>O},d=new fe(u,{timeout:5e3}).evaluate(l)(u.$$inputs);if(L(d)){this.outputData[0]=[O];return}let f=d===void 0?"":d;this.outputData[0]=[JSON.parse(JSON.stringify(f))]}catch(u){let c=u instanceof Error?u.message:"Invalid Syntax";throw Error(c)}};this.generateInputValues=(r,n)=>{let t=[];for(let s=0;s<r.length;++s)t[s]={},n.forEach((i,o)=>{let a=r[s],l=i.key.trim(),m=(Array.isArray(a)?a[o]:a[l])??"";t[s][l]=m}),t[s].rowIndex=s;return t};this.replaceNullishCoalescingWithLogicalOr=r=>r.replace(/\?\?/g,"||");this.transpileToES5=r=>{try{let t=Ee.transform(r,{presets:[["env",{targets:{ie:"11"},modules:!1}]],compact:!1,comments:!1}).code||r;return t=t.replace(/^["']use strict["'];?\s*/i,"").trim().replace(/;$/,""),t}catch(n){throw new Error(n instanceof Error?n.message:"Invalid syntax")}}}};export{vt as a,St as b,Ct as c,$ as d,I as e,P as f,B as g,V as h,y as i,v as j,N as k,he as l,G as m,K as n,j as o,C as p,ie as q,se as r,L as s,Y as t,Ie as u,le as v,ae as w,ue as x,z as y,ce as z,me as A,de as B,Fe as C,Q as D,We as E,Re as F};
@@ -0,0 +1 @@
1
+ import{isNil as m}from"lodash";var p=class n{static{this.currencySymbol={eu:"\u20AC",us:"$"}}static{this.percentageSymbol="%"}static{this.maxSafeNumberLength=Number.MAX_SAFE_INTEGER}static{this.CURRENCY_CODE_RE=/(?<![A-Za-z])(?:EUR|USD)(?![A-Za-z])/gi}static{this.ADORNMENT_SYMBOL_RE=new RegExp(`[${Object.values(n.currencySymbol).join("")}${n.percentageSymbol}]`,"g")}static{this.SCIENTIFIC_NOTATION_RE=/^([+-]?)(?:(\d+)(?:\.(\d*))?|\.(\d+))[eE]([+-]?\d+)$/}static stripCurrencyAdornment(e){return e.replace(n.CURRENCY_CODE_RE,"").replace(n.ADORNMENT_SYMBOL_RE,"").replace(/\s+/g,"")}static isScientificNotation(e){return n.SCIENTIFIC_NOTATION_RE.test(e)}static convertToFormat(e,r){if(e==null||e===""||typeof e=="string"&&e.trim()==="")return"";let t="";if(typeof e=="string"){let o=this.convertStringToNumber(e,{targetFormat:r?.targetFormat});if(o===null)return e;t=o}else if(typeof e=="number"){let o=e;r?.adornment==="percentage"&&(o=e*100,o=Number(o.toFixed(10))),t=o.toString()}else throw new Error(`[convertToFormat] unsupported type of the "value" - ${typeof e}`);n.isScientificNotation(t)&&(t=n.expandScientificNotation(t));let[a,i]=t.split("."),s=r?.decimalDigits||i?.length||0,u="";try{let o=Number(t);if(!isFinite(o))return t;u=n.formatUS(o,s)}catch{return t}if(r?.targetFormat==="eu"){let o=u.replace(/,/g,"$").replace(/\./g,",").replace(/\$/g,".");return this.appendAdornment(o,r)}return this.appendAdornment(u,r)}static detectNumberFormat(e,r){let t=[];for(let u=0;u<e.length;u++)(e[u]===","||e[u]===".")&&t.push(e[u]);if(t.length===0)return;let a=n.stripCurrencyAdornment(e).replace(/[+-]/g,"");if(t.length===1){let[u,o]=a.split(t[0]);return u.length>3?t[0]===","?"eu":"us":u.replace(/0/g,"")===""?t[0]===","?"eu":"us":/^\d{3}$/.test(o)?r?.targetFormat?r?.targetFormat:r?.resolveUncertainty===!1?void 0:t[0]===","?"us":"eu":t[0]===","?"eu":"us"}let i=/^([1-9]\d{0,2})(\.\d{3})*(,\d+)?$/,s=/^([1-9]\d{0,2})(,\d{3})*(\.\d+)?$/;return i.test(a)?"eu":s.test(a)?"us":null}static convertToUsWithDecimal(e,r){let t=n.stripCurrencyAdornment(e.trim());if(n.isScientificNotation(t))return t;let a=e,i=n.getDelimiters(e),s=t.replace(/[+-]/g,"");if(i.length===1){let[u,o]=s.split(i[0]);if(/^\d{3}$/.test(o))return r==="us"?a=`${e}`?.replace(/,/g,""):a=`${e}`?.replace(/\./g,"$")?.replace(/,/,".").replace(/\$/g,""),a}return this.replaceDelimiter(e)}static{this.convertStringToNumber=(e,r)=>{if(typeof e=="number")return`${e}`;if(typeof e!="string")return null;let t=n.stripCurrencyAdornment(e.trim());if(t==="")return e;if(n.isScientificNotation(t)){if(!Number.isFinite(Number(t)))return null;let s=t;return r?.adornment==="percentage"&&e.includes(n.percentageSymbol)&&(s=Number((Number(s)/100).toFixed(10)).toString()),s}let a=this.detectNumberFormat(t,{targetFormat:r?.format??r?.targetFormat}),i="";if(a===null||(a==="us"||m(a)?i=t.replace(/,/g,""):i=t.replace(/\./g,"$").replace(/,/,".").replace(/\$/g,""),i.length>n.maxSafeNumberLength&&(i=i.slice(0,n.maxSafeNumberLength),i.at(-1)==="."&&(i=i.slice(0,n.maxSafeNumberLength-1))),isNaN(Number(i))))return null;if(r?.adornment==="percentage"&&e.includes(n.percentageSymbol)){let s=Number(i)/100;i=Number(s.toFixed(10)).toString()}return i}}static hasDecimalPart(e,r){if(typeof e=="number")return e%1!==0;let t=e.trim(),a=r||this.detectNumberFormat(t);return a===null?!1:a==="us"?e.includes("."):e.includes(",")}static appendAdornment(e,r){return r?.adornment==="currency"?r.symbol==="us"?`${this.currencySymbol.us}${e}`:`${e} ${this.currencySymbol[r.symbol??"eu"]}`:r?.adornment==="percentage"?`${e} ${this.percentageSymbol}`:e}static getDelimiters(e){let r=[];for(let t=0;t<e.length;t++)(e[t]===","||e[t]===".")&&r.push(e[t]);return r}static expandScientificNotation(e){let r=e.match(n.SCIENTIFIC_NOTATION_RE);if(!r)return e;let[,t,a="",i="",s="",u]=r,o=s||i,l=parseInt(u,10),d=a+o,c=a.length+l;return(c<=0?-c:c>=d.length?c-d.length:0)>1e3?e:c<=0?`${t}0.${"0".repeat(-c)}${d}`:c>=d.length?`${t}${d}${"0".repeat(c-d.length)}`:`${t}${d.slice(0,c)}.${d.slice(c)}`}static formatUS(e,r){return new Intl.NumberFormat("en-US",{useGrouping:!0,minimumFractionDigits:r,maximumFractionDigits:r}).format(e)}static replaceDelimiter(e){let r=e,t=n.detectNumberFormat(`${e}`);return m(t)?null:(t==="eu"?r=`${e}`?.replace(/\./g,"$")?.replace(/,/,".").replace(/\$/g,""):r=`${e}`?.replace(/,/g,""),r)}};var y=n=>n.trim()?.replace(/[-!$%^&*()+|~=`{}\[\]:";'<>?,.\/]/g,"")?.replace(/^_+/,"")?.replace(/_+$/,"")?.replace(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/g,"")?.replace(/ /g,"_")?.replace(/ß/g,"ss")?.replace(/ä/g,"ae")?.replace(/ö/g,"oe")?.replace(/ü/g,"ue")?.toLowerCase(),I=n=>n?.replace(/[-!$%^&*()_+|~=`{}\\[\]:";'<>?,.\\/]/g," ")?.replace(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/g," ")?.toLowerCase();export{p as a,y as b,I as c};