@fileflow/sdk 0.1.31 → 0.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";const l=require("react/jsx-runtime"),P=require("react"),C=require("./index-DnSXPtpU.js");function xt(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const je=xt(P);/**
1
+ "use strict";const l=require("react/jsx-runtime"),P=require("react"),C=require("./index-CQzYw3WX.js");function xt(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const je=xt(P);/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -60,5 +60,5 @@
60
60
  *
61
61
  * @license MIT
62
62
  */function Ke(e,o){return e?Nn(e)?je.createElement(e,o):e:null}function Nn(e){return Vn(e)||typeof e=="function"||Pn(e)}function Vn(e){return typeof e=="function"&&(()=>{const o=Object.getPrototypeOf(e);return o.prototype&&o.prototype.isReactComponent})()}function Pn(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function kn(e){const o={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[t]=je.useState(()=>({current:Sn(o)})),[n,r]=je.useState(()=>t.current.initialState);return t.current.setOptions(s=>({...s,...e,state:{...n,...e.state},onStateChange:i=>{r(i),e.onStateChange==null||e.onStateChange(i)}})),t.current}const rt=({editable:e=!0,deletable:o=!0,pageSize:t=25,onCellEdit:n,onRowDelete:r})=>{const{rows:s,schema:i,mappings:f,errorsByRow:u,editingCell:d,startEditing:g,stopEditing:p,updateCell:c,deleteRow:a}=ee(),[m,h]=P.useState([]),[x,v]=P.useState(""),[w,j]=P.useState(""),[F,$]=P.useState(null),[V]=P.useState("onChange"),K=P.useMemo(()=>f.filter(R=>R.targetKey!==null).map(R=>{const _=i==null?void 0:i.columns.find(I=>I.key===R.targetKey);return{sourceColumn:R.sourceColumn,targetKey:R.targetKey,label:(_==null?void 0:_.label)||R.targetKey,type:(_==null?void 0:_.type)||"string"}}),[f,i]),Z=P.useCallback((R,_)=>{const I=u.get(R);return I==null?void 0:I.find(Y=>Y.columnKey===_)},[u]),re=P.useCallback((R,_)=>{if(!i)return null;const I=i.columns.find(le=>le.key===_);if(!I)return null;const b=qe(R,I).find(le=>le.severity==="error");return b?b.message:null},[i]),z=(R,_,I)=>{j(I),$(null),g(R,_)},O=(R,_)=>{j(R);const I=re(R,_);$(I)},se=()=>{F||(d&&(c(d.rowIndex,d.columnKey,w),n==null||n(d.rowIndex,d.columnKey,w)),$(null),p())},A=()=>{j(""),$(null),p()},fe=R=>{a(R),r==null||r(R)},te=bt(),ne=P.useMemo(()=>[te.accessor("rowIndex",{header:"#",size:o?80:60,enableResizing:!1,cell:R=>{const _=R.getValue();return l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[l.jsx("span",{className:"ff-font-mono ff-text-xs",style:{color:"var(--ff-text-muted)"},children:_+1}),o&&l.jsx("button",{onClick:I=>{I.stopPropagation(),fe(_)},title:"Delete row",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"4px",borderRadius:"4px",cursor:"pointer",color:"#8e8d89",background:"transparent",border:"none",transition:"color 0.15s, background-color 0.15s",marginLeft:"2px",flexShrink:0},onMouseEnter:I=>{I.currentTarget.style.color="#d43338",I.currentTarget.style.backgroundColor="#fcdede"},onMouseLeave:I=>{I.currentTarget.style.color="#8e8d89",I.currentTarget.style.backgroundColor="transparent"},children:l.jsx(Et,{style:{width:"14px",height:"14px",display:"block"}})})]})}}),...K.map(R=>te.accessor(_=>_.data[R.targetKey]||_.data[R.sourceColumn],{id:R.targetKey,header:R.label,size:150,minSize:80,cell:_=>{const I=_.row.original.rowIndex,Y=String(_.getValue()??""),b=Z(I,R.targetKey);return(d==null?void 0:d.rowIndex)===I&&(d==null?void 0:d.columnKey)===R.targetKey?l.jsxs("div",{className:"ff-min-w-[280px]",children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-2",children:[l.jsx("input",{type:"text",value:w,onChange:J=>O(J.target.value,R.targetKey),onKeyDown:J=>{J.key==="Enter"&&!F&&se(),J.key==="Escape"&&A()},className:C.clsx("ff-input ff-py-2 ff-px-3 ff-text-sm ff-flex-1 ff-min-w-[160px]",F&&"ff-input-error"),autoFocus:!0}),l.jsx("button",{onClick:se,disabled:!!F,className:"ff-btn ff-btn-primary ff-btn-sm ff-flex-shrink-0",style:F?{opacity:.5,cursor:"not-allowed"}:void 0,children:"Save"}),l.jsx("button",{onClick:A,className:"ff-btn ff-btn-secondary ff-btn-sm ff-flex-shrink-0",children:"Cancel"})]}),F&&l.jsx("p",{className:"ff-text-xs ff-mt-1",style:{color:"var(--ff-error)"},children:F})]}):l.jsxs("div",{className:C.clsx("ff-group ff-flex ff-items-center ff-gap-2",(b==null?void 0:b.severity)==="error"&&"ff-cell-error",(b==null?void 0:b.severity)==="warning"&&"ff-cell-warning"),children:[l.jsx("span",{className:"ff-flex-1 ff-truncate",children:Y||l.jsx("span",{style:{color:"var(--ff-text-muted)"},children:"—"})}),b&&l.jsxs("div",{className:"ff-relative ff-group/tooltip",children:[b.severity==="error"?l.jsx(C.CircleAlert,{className:"ff-w-4 ff-h-4",style:{color:"var(--ff-error)"}}):l.jsx(C.TriangleAlert,{className:"ff-w-4 ff-h-4",style:{color:"var(--ff-warning)"}}),l.jsxs("div",{className:"ff-tooltip ff-bottom-full ff-left-1/2 ff-transform ff--translate-x-1/2 ff-mb-2 ff-w-48 group-hover/tooltip:ff-tooltip-visible",children:[b.message,b.suggestion&&l.jsx("span",{className:"ff-block ff-mt-1",style:{color:"var(--ff-text-muted)"},children:b.suggestion})]})]}),e&&l.jsx("button",{onClick:()=>z(I,R.targetKey,Y),className:"ff-opacity-0 group-hover:ff-opacity-100 ff-p-1 ff-rounded ff-transition-opacity ff-edit-btn",children:l.jsx(Pt,{className:"ff-w-3 ff-h-3"})})]})}}))],[K,d,w,F,e,o,Z,te]),E=kn({data:s,columns:ne,columnResizeMode:V,enableColumnResizing:!0,state:{sorting:m,globalFilter:x},onSortingChange:h,onGlobalFilterChange:v,getCoreRowModel:yn(),getPaginationRowModel:$n(),getSortedRowModel:Mn(),getFilteredRowModel:In(),initialState:{pagination:{pageSize:t}}});return l.jsxs("div",{className:"ff-space-y-4",children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-justify-between",children:[l.jsx("input",{type:"text",value:x,onChange:R=>v(R.target.value),placeholder:"Search all columns...",className:"ff-input ff-max-w-xs"}),l.jsxs("div",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[E.getFilteredRowModel().rows.length," rows"]})]}),l.jsx("div",{className:"ff-table-container ff-max-h-[500px]",children:l.jsxs("table",{className:"ff-table",style:{width:E.getCenterTotalSize()},children:[l.jsx("thead",{children:E.getHeaderGroups().map(R=>l.jsx("tr",{children:R.headers.map(_=>l.jsxs("th",{style:{width:_.getSize(),position:"relative"},onClick:_.column.getCanSort()?_.column.getToggleSortingHandler():void 0,className:C.clsx(_.column.getCanSort()&&"ff-cursor-pointer ff-select-none"),children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-1",children:[Ke(_.column.columnDef.header,_.getContext()),_.column.getIsSorted()&&l.jsx("span",{children:_.column.getIsSorted()==="asc"?"↑":"↓"})]}),_.column.getCanResize()&&l.jsx("div",{onMouseDown:_.getResizeHandler(),onTouchStart:_.getResizeHandler(),className:"ff-resize-handle",style:{position:"absolute",right:0,top:0,height:"100%",width:"5px",cursor:"col-resize",userSelect:"none",touchAction:"none"}})]},_.id))},R.id))}),l.jsx("tbody",{children:E.getRowModel().rows.map(R=>{const _=u.has(R.original.rowIndex);return l.jsx("tr",{className:C.clsx(_&&"ff-row-error"),children:R.getVisibleCells().map(I=>l.jsx("td",{style:{width:I.column.getSize()},children:Ke(I.column.columnDef.cell,I.getContext())},I.id))},R.id)})})]})}),l.jsxs("div",{className:"ff-flex ff-items-center ff-justify-between ff-px-2",children:[l.jsxs("div",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:["Page ",E.getState().pagination.pageIndex+1," of ",E.getPageCount()]}),l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-2",children:[l.jsxs("button",{onClick:()=>E.previousPage(),disabled:!E.getCanPreviousPage(),className:"ff-btn ff-btn-secondary ff-btn-sm",children:[l.jsx(_t,{className:"ff-w-4 ff-h-4"}),"Previous"]}),l.jsxs("button",{onClick:()=>E.nextPage(),disabled:!E.getCanNextPage(),className:"ff-btn ff-btn-secondary ff-btn-sm",children:["Next",l.jsx(C.ChevronRight,{className:"ff-w-4 ff-h-4"})]})]})]})]})},st=({showDetails:e=!0})=>{const{validationResults:o}=ee();if(!o)return null;const{isValid:t,totalRows:n,validRows:r,errorCount:s,warningCount:i,infoCount:f,summary:u}=o,d=Math.round(r/n*100);return l.jsxs("div",{className:"ff-space-y-4",children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-4 ff-p-4 ff-rounded-lg ff-border",style:{backgroundColor:t?"var(--ff-success-light)":"var(--ff-error-light)",borderColor:t?"var(--ff-success)":"var(--ff-error)"},children:[t?l.jsx(C.CircleCheckBig,{className:"ff-w-8 ff-h-8",style:{color:"var(--ff-success)"}}):l.jsx(C.CircleX,{className:"ff-w-8 ff-h-8",style:{color:"var(--ff-error)"}}),l.jsxs("div",{children:[l.jsx("h3",{className:"ff-text-lg ff-font-semibold",style:{color:t?"var(--ff-success-dark)":"var(--ff-error-dark)"},children:t?"Validation Passed":"Validation Failed"}),l.jsxs("p",{className:"ff-text-sm",style:{color:t?"var(--ff-success)":"var(--ff-error)"},children:[r," of ",n," rows are valid (",d,"%)"]})]})]}),l.jsxs("div",{className:"ff-grid ff-grid-cols-4 ff-gap-4",children:[l.jsxs("div",{className:"ff-border ff-rounded-lg ff-p-4 ff-text-center",style:{backgroundColor:"var(--ff-bg-primary)",borderColor:"var(--ff-border-light)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-text-primary)"},children:n}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:"Total Rows"})]}),l.jsxs("div",{className:"ff-border ff-rounded-lg ff-p-4 ff-text-center",style:{backgroundColor:"var(--ff-success-light)",borderColor:"var(--ff-success)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-success-dark)"},children:r}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-success)"},children:"Valid Rows"})]}),l.jsxs("div",{className:"ff-border ff-rounded-lg ff-p-4 ff-text-center",style:{backgroundColor:"var(--ff-error-light)",borderColor:"var(--ff-error)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-error-dark)"},children:s}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-error)"},children:"Errors"})]}),l.jsxs("div",{className:"ff-border ff-rounded-lg ff-p-4 ff-text-center",style:{backgroundColor:"var(--ff-warning-light)",borderColor:"var(--ff-warning)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-warning-dark)"},children:i}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-warning)"},children:"Warnings"})]})]}),e&&u.byColumn&&Object.keys(u.byColumn).length>0&&l.jsxs("div",{className:"ff-border ff-rounded-xl ff-overflow-hidden",style:{backgroundColor:"var(--ff-bg-primary)",borderColor:"var(--ff-border-light)"},children:[l.jsx("div",{className:"ff-px-4 ff-py-3",style:{backgroundColor:"var(--ff-bg-secondary)"},children:l.jsx("h4",{className:"ff-font-medium ff-text-sm",style:{color:"var(--ff-text-secondary)"},children:"Issues by Column"})}),l.jsx("div",{children:Object.entries(u.byColumn).filter(([,g])=>g.errorCount>0||g.warningCount>0).map(([g,p],c,a)=>l.jsxs("div",{className:"ff-flex ff-items-center ff-justify-between ff-px-4 ff-py-3",style:{borderTop:c>0?"1px solid var(--ff-border-light)":void 0},children:[l.jsxs("div",{className:"ff-flex-1 ff-min-w-0 ff-mr-4",children:[l.jsx("p",{className:"ff-font-medium ff-text-sm",style:{color:"var(--ff-text-primary)"},children:p.columnKey}),p.mostCommonError&&l.jsx("p",{className:"ff-text-sm ff-truncate",style:{color:"var(--ff-text-muted)"},children:p.mostCommonError})]}),l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-2 ff-flex-shrink-0",children:[p.errorCount>0&&l.jsxs("span",{className:"ff-badge ff-badge-error ff-whitespace-nowrap",children:[l.jsx(C.CircleX,{className:"ff-w-3 ff-h-3 ff-mr-1"}),p.errorCount," ",p.errorCount===1?"error":"errors"]}),p.warningCount>0&&l.jsxs("span",{className:"ff-badge ff-badge-warning ff-whitespace-nowrap",children:[l.jsx(C.TriangleAlert,{className:"ff-w-3 ff-h-3 ff-mr-1"}),p.warningCount," ",p.warningCount===1?"warning":"warnings"]})]})]},g))})]}),e&&u.duplicates&&u.duplicates.length>0&&l.jsx("div",{className:"ff-border ff-rounded-lg ff-p-4",style:{backgroundColor:"var(--ff-warning-light)",borderColor:"var(--ff-warning)"},children:l.jsxs("div",{className:"ff-flex ff-items-start ff-gap-3",children:[l.jsx(C.TriangleAlert,{className:"ff-w-5 ff-h-5 ff-flex-shrink-0 ff-mt-0.5",style:{color:"var(--ff-warning)"}}),l.jsxs("div",{children:[l.jsx("h4",{className:"ff-font-medium",style:{color:"var(--ff-warning-dark)"},children:"Duplicate Values Found"}),l.jsxs("ul",{className:"ff-mt-2 ff-space-y-1 ff-text-sm",style:{color:"var(--ff-warning-dark)"},children:[u.duplicates.slice(0,5).map((g,p)=>l.jsxs("li",{children:[l.jsx("span",{className:"ff-font-mono",children:g.columnKey}),': "',String(g.value),'" appears'," ",g.rowIndices.length," times (rows"," ",g.rowIndices.slice(0,3).map(c=>c+1).join(", "),g.rowIndices.length>3?"...":"",")"]},p)),u.duplicates.length>5&&l.jsxs("li",{style:{color:"var(--ff-warning)"},children:["... and ",u.duplicates.length-5," more duplicate groups"]})]})]})]})})]})},Fe=["upload","mapping","validation","complete"],En=({template:e,schema:o,mode:t="modal",theme:n,useShadowDom:r=!1,error:s,onComplete:i,onCancel:f,onError:u})=>{const{step:d,sessionId:g,file:p,rows:c,mappings:a,validationResults:m,isLoading:h,error:x,setSchema:v,setSessionId:w,setParsedData:j,setMappings:F,setUnmapped:$,setValidationResults:V,setStep:K,nextStep:Z,previousStep:re,setLoading:z,setError:O,reset:se}=ee(),[A,fe]=P.useState(null),[te,ne]=P.useState(null),[E,R]=P.useState(0),[_,I]=P.useState(""),[Y,b]=P.useState(null),[le,J]=P.useState(null),[ie,Le]=P.useState([]);P.useEffect(()=>{if(ne(null),e)if(C.templateExists(e)){const M=C.getTemplateSchema(e);M?fe(M):(ne(`Failed to load template "${e}"`),u==null||u(new Error(`Failed to load template "${e}"`)))}else{const M=`Template "${e}" not found. Available templates: ${C.VALID_TEMPLATE_IDS.join(", ")}`;ne(M),u==null||u(new Error(M))}else if(o)fe(o);else{const M=`No template or schema provided. Please specify a template (${C.VALID_TEMPLATE_IDS.join(", ")}) or provide a custom schema.`;ne(M),u==null||u(new Error(M))}},[e,o,u]),P.useEffect(()=>{A&&(v(A),De(A))},[A]);const De=async M=>{try{z(!0);const k=await C.getClient().createImportSession(M);w(k.sessionId)}catch(N){const k=N;O(k.message),u==null||u(k)}finally{z(!1)}},lt=M=>{const N=[];let k="",H=!1;for(let q=0;q<M.length;q++){const D=M[q];D==='"'?H&&M[q+1]==='"'?(k+='"',q++):H=!H:D===","&&!H?(N.push(k.trim()),k=""):k+=D}return N.push(k.trim()),N},it=P.useCallback(async M=>{if(g)try{z(!0),O(null),F([]),$([],[]),V(null),R(10),I("Uploading file...");const N=C.getClient();R(20),I("Uploading to server...");const k=await N.uploadFile(g,M);R(40),I("Parsing all rows...");const q=(await M.text()).split(`
63
- `).filter(U=>U.trim()),D=k.data.headers,B=q.slice(1).map((U,de)=>{const He=lt(U),Ge={};return D.forEach((ht,vt)=>{Ge[ht]=He[vt]||""}),{rowIndex:de,data:Ge,rawData:He}});R(60),I("Processing rows..."),j({headers:D,rows:B,totalRows:B.length,sampleRows:B.slice(0,5)}),R(80),I("Matching columns..."),K("mapping"),await at(),R(100),I("Done")}catch(N){O(`Failed to process the uploaded file: ${N.message}`)}finally{z(!1),R(0),I("")}},[g]),at=async()=>{if(g)try{z(!0);const N=await C.getClient().matchColumns(g);F(N.mappings),$(N.unmappedSource,N.unmappedTarget)}catch(M){O(`Column matching failed: ${M.message}`)}finally{z(!1)}},ut=async()=>{if(g)try{z(!0),O(null);const N=await C.getClient().validateImport(g);V(N.validation),Z()}catch(M){O(`Validation failed: ${M.message}`)}finally{z(!1)}},ft=async()=>{if(g)try{z(!0),O(null),b(null);const M=[...c];Le(M);const H=await C.getClient().completeImport(g,{skipInvalidRows:!0,acknowledgeWarnings:!0});J(H),K("complete"),i==null||i(H)}catch(M){b(M.message),K("complete")}finally{z(!1)}},he=()=>{se(),f==null||f()},dt=()=>{b(null),J(null),Le([]),R(0),I(""),se(),A&&(v(A),De(A))},oe=()=>Fe.indexOf(d),ct=()=>{switch(d){case"upload":return p!==null;case"mapping":return a.length>0&&a.some(M=>M.targetKey!==null);case"validation":return m!==null&&m.errorCount===0;default:return!1}},gt=async()=>{switch(d){case"mapping":await ut();break;case"validation":await ft();break;default:Z()}},pt=d==="upload"&&h&&E>0||d==="mapping"&&h&&E>0;if(te)return l.jsx(C.StyleProvider,{theme:n,useShadowDom:r,children:l.jsx("div",{className:"ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6",children:l.jsxs("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:[l.jsx("div",{className:"ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4",style:{backgroundColor:"var(--ff-error-light)"},children:l.jsx(C.X,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-error)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Configuration Error"}),l.jsx("p",{className:"ff-text-center ff-max-w-md ff-mb-4",style:{color:"var(--ff-text-muted)"},children:te}),f&&l.jsx("button",{onClick:he,className:"ff-btn ff-btn-secondary",children:"Close"})]})})});if(!A)return l.jsx(C.StyleProvider,{theme:n,useShadowDom:r,children:l.jsx("div",{className:"ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6",children:l.jsxs("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:[l.jsx(C.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{style:{color:"var(--ff-text-muted)"},children:"Loading template..."})]})})});const mt=t==="embed"?"ff-container ff-embed":"ff-container ff-modal",ze=s||Y,Ae=l.jsx(l.Fragment,{children:l.jsxs("div",{className:mt,children:[l.jsxs("div",{className:"ff-modal-header",children:[l.jsxs("div",{className:"ff-modal-header-left",children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-3",children:[l.jsx("div",{className:"ff-modal-icon",children:l.jsx($t,{})}),l.jsx("h2",{className:"ff-modal-title",children:"Import Data"})]}),l.jsx("div",{className:"ff-steps ff-ml-4",children:Fe.map((M,N)=>l.jsxs(P.Fragment,{children:[l.jsx("div",{className:C.clsx("ff-step",oe()===N&&"ff-step-active",oe()>N&&"ff-step-complete",oe()<N&&"ff-step-pending"),children:oe()>N?"✓":N+1}),N<Fe.length-1&&l.jsx("div",{className:C.clsx("ff-step-connector",oe()>N&&"ff-step-connector-complete")})]},M))})]}),l.jsx("button",{onClick:he,className:"ff-modal-close",children:l.jsx(C.X,{className:"ff-w-5 ff-h-5"})})]}),l.jsxs("div",{className:"ff-modal-body",children:[x&&l.jsx("div",{className:"ff-mb-4 ff-p-4 ff-border ff-rounded-lg ff-text-sm",style:{backgroundColor:"var(--ff-error-light)",borderColor:"var(--ff-error)",color:"var(--ff-error)"},children:x}),d==="upload"&&l.jsx("div",{className:"ff-py-4",children:l.jsx("div",{className:"ff-max-w-xl ff-mx-auto",children:h&&E>0?l.jsxs("div",{className:"ff-p-8 ff-text-center",children:[l.jsx(C.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{className:"ff-font-medium ff-mb-2",style:{color:"var(--ff-text-primary)"},children:_}),l.jsx("div",{className:"ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2",children:l.jsx("div",{className:"ff-progress-bar",style:{width:`${E}%`,transition:"width 0.3s ease"}})}),l.jsxs("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[E,"% complete"]})]}):l.jsx(Ue,{onFileSelect:it})})}),d==="mapping"&&(h&&E>0?l.jsxs("div",{className:"ff-py-12 ff-text-center",children:[l.jsx(C.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{className:"ff-font-medium ff-mb-3",style:{color:"var(--ff-text-primary)"},children:_}),l.jsx("div",{className:"ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2",children:l.jsx("div",{className:"ff-progress-bar",style:{width:`${E}%`,transition:"width 0.3s ease"}})}),l.jsxs("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[E,"% complete"]})]}):l.jsx(Xe,{})),d==="validation"&&l.jsxs("div",{className:"ff-space-y-6",children:[l.jsx(st,{}),l.jsx(rt,{editable:!0})]}),d==="complete"&&l.jsx("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:ze?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4",style:{backgroundColor:"var(--ff-error-light)"},children:l.jsx(C.X,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-error)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Import Failed"}),l.jsx("p",{className:"ff-text-center ff-max-w-md ff-mb-4",style:{color:"var(--ff-text-muted)"},children:ze})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ff-w-20 ff-h-20 ff-rounded-2xl ff-flex ff-items-center ff-justify-center ff-mb-6",style:{backgroundColor:"var(--ff-success-light)"},children:l.jsx(C.CircleCheckBig,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-success)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Import Complete!"}),l.jsx("p",{className:"ff-mb-6",style:{color:"var(--ff-text-muted)"},children:"Your data has been successfully imported."}),l.jsxs("div",{className:"ff-flex ff-gap-6 ff-mb-6",children:[l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-success)",backgroundColor:"var(--ff-success-light)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-success-dark)"},children:ie.length}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-success)"},children:"Rows Imported"})]}),l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-border-light)",backgroundColor:"var(--ff-bg-primary)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-text-primary)"},children:a.filter(M=>M.targetKey!==null).length}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:"Columns Mapped"})]})]}),ie.length>0&&(()=>{const M=ie.slice(0,5),N=M[0],k=(N==null?void 0:N.data)||N,H=Object.keys(typeof k=="object"?k:{}).slice(0,6),q=(A==null?void 0:A.columns)||[];return H.length===0?null:l.jsxs("div",{className:"ff-w-full ff-mb-6",children:[l.jsx("p",{className:"ff-text-xs ff-font-semibold ff-uppercase ff-tracking-wider ff-mb-2",style:{color:"var(--ff-text-muted)"},children:"Imported Data Preview"}),l.jsx("div",{className:"ff-table-container ff-max-h-[250px]",children:l.jsxs("table",{className:"ff-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{style:{width:40},children:"#"}),H.map(D=>{const B=q.find(U=>U.key===D);return l.jsx("th",{children:(B==null?void 0:B.label)||D},D)}),H.length<Object.keys(typeof k=="object"?k:{}).length&&l.jsx("th",{children:"..."})]})}),l.jsx("tbody",{children:M.map((D,B)=>{const U=(D==null?void 0:D.data)||D;return l.jsxs("tr",{children:[l.jsx("td",{children:l.jsx("span",{className:"ff-font-mono ff-text-xs",style:{color:"var(--ff-text-muted)"},children:B+1})}),H.map(de=>l.jsx("td",{children:l.jsx("span",{className:"ff-text-sm ff-truncate ff-block ff-max-w-[150px]",children:String((U==null?void 0:U[de])??"—")})},de)),H.length<Object.keys(typeof k=="object"?k:{}).length&&l.jsx("td",{children:l.jsx("span",{style:{color:"var(--ff-text-muted)"},children:"..."})})]},B)})})]})}),ie.length>5&&l.jsxs("p",{className:"ff-text-xs ff-mt-1",style:{color:"var(--ff-text-muted)"},children:["Showing ",M.length," of ",ie.length," imported rows"]})]})})()]})})]}),l.jsx("div",{className:"ff-modal-footer",children:d==="complete"?l.jsxs(l.Fragment,{children:[f?l.jsx("button",{onClick:he,className:"ff-btn ff-btn-ghost",children:"Close"}):l.jsx("div",{}),l.jsx("button",{onClick:dt,className:"ff-btn ff-btn-primary",children:"Start New Import"})]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:re,disabled:oe()===0||h,className:"ff-btn ff-btn-ghost",children:"Back"}),!pt&&l.jsx("button",{onClick:gt,disabled:!ct()||h,className:"ff-btn ff-btn-primary",children:h?l.jsxs(l.Fragment,{children:[l.jsx(C.LoaderCircle,{className:"ff-w-4 ff-h-4 ff-animate-spin"})," Processing..."]}):d==="validation"?m&&m.errorCount>0?`Fix ${m.errorCount} error${m.errorCount>1?"s":""} to continue`:"Complete Import":"Continue"})]})})]})});return l.jsx(C.StyleProvider,{theme:n,useShadowDom:r,children:t==="modal"?l.jsx("div",{className:"ff-overlay",children:Ae}):l.jsx("div",{className:"ff-embed-resizable",children:Ae})})};exports.ColumnMapper=Xe;exports.DataTable=rt;exports.FileUploader=Ue;exports.ImportWizard=En;exports.ValidationSummary=st;exports.useImportStore=ee;
64
- //# sourceMappingURL=ImportWizard-BsXU0Tm7.js.map
63
+ `).filter(U=>U.trim()),D=k.data.headers,B=q.slice(1).map((U,de)=>{const He=lt(U),Ge={};return D.forEach((ht,vt)=>{Ge[ht]=He[vt]||""}),{rowIndex:de,data:Ge,rawData:He}});R(60),I("Processing rows..."),j({headers:D,rows:B,totalRows:B.length,sampleRows:B.slice(0,5)}),R(80),I("Matching columns..."),K("mapping"),await at(),R(100),I("Done")}catch(N){O(`Failed to process the uploaded file: ${N.message}`)}finally{z(!1),R(0),I("")}},[g]),at=async()=>{if(g)try{z(!0);const N=await C.getClient().matchColumns(g);F(N.mappings),$(N.unmappedSource,N.unmappedTarget)}catch(M){O(`Column matching failed: ${M.message}`)}finally{z(!1)}},ut=async()=>{if(g)try{z(!0),O(null);const N=await C.getClient().validateImport(g);V(N.validation),Z()}catch(M){O(`Validation failed: ${M.message}`)}finally{z(!1)}},ft=async()=>{if(g)try{z(!0),O(null),b(null);const M=[...c];Le(M);const H=await C.getClient().completeImport(g,{skipInvalidRows:!0,acknowledgeWarnings:!0});J(H),K("complete"),i==null||i(H)}catch(M){b(M.message),K("complete")}finally{z(!1)}},he=()=>{se(),f==null||f()},dt=()=>{b(null),J(null),Le([]),R(0),I(""),se(),A&&(v(A),De(A))},oe=()=>Fe.indexOf(d),ct=()=>{switch(d){case"upload":return p!==null;case"mapping":return a.length>0&&a.some(M=>M.targetKey!==null);case"validation":return m!==null&&m.errorCount===0;default:return!1}},gt=async()=>{switch(d){case"mapping":await ut();break;case"validation":await ft();break;default:Z()}},pt=d==="upload"&&h&&E>0||d==="mapping"&&h&&E>0;if(te)return l.jsx(C.StyleProvider,{theme:n,useShadowDom:r,children:l.jsx("div",{className:"ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6",children:l.jsxs("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:[l.jsx("div",{className:"ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4",style:{backgroundColor:"var(--ff-error-light)"},children:l.jsx(C.X,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-error)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Configuration Error"}),l.jsx("p",{className:"ff-text-center ff-max-w-md ff-mb-4",style:{color:"var(--ff-text-muted)"},children:te}),f&&l.jsx("button",{onClick:he,className:"ff-btn ff-btn-secondary",children:"Close"})]})})});if(!A)return l.jsx(C.StyleProvider,{theme:n,useShadowDom:r,children:l.jsx("div",{className:"ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6",children:l.jsxs("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:[l.jsx(C.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{style:{color:"var(--ff-text-muted)"},children:"Loading template..."})]})})});const mt=t==="embed"?"ff-container ff-embed":"ff-container ff-modal",ze=s||Y,Ae=l.jsx(l.Fragment,{children:l.jsxs("div",{className:mt,children:[l.jsxs("div",{className:"ff-modal-header",children:[l.jsxs("div",{className:"ff-modal-header-left",children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-3",children:[l.jsx("div",{className:"ff-modal-icon",children:l.jsx($t,{})}),l.jsx("h2",{className:"ff-modal-title",children:"Import Data"})]}),l.jsx("div",{className:"ff-steps ff-ml-4",children:Fe.map((M,N)=>l.jsxs(P.Fragment,{children:[l.jsx("div",{className:C.clsx("ff-step",oe()===N&&"ff-step-active",oe()>N&&"ff-step-complete",oe()<N&&"ff-step-pending"),children:oe()>N?"✓":N+1}),N<Fe.length-1&&l.jsx("div",{className:C.clsx("ff-step-connector",oe()>N&&"ff-step-connector-complete")})]},M))})]}),l.jsx("button",{onClick:he,className:"ff-modal-close",children:l.jsx(C.X,{className:"ff-w-5 ff-h-5"})})]}),l.jsxs("div",{className:"ff-modal-body",children:[x&&l.jsx("div",{className:"ff-mb-4 ff-p-4 ff-border ff-rounded-lg ff-text-sm",style:{backgroundColor:"var(--ff-error-light)",borderColor:"var(--ff-error)",color:"var(--ff-error)"},children:x}),d==="upload"&&l.jsx("div",{className:"ff-py-4",children:l.jsx("div",{className:"ff-max-w-xl ff-mx-auto",children:h&&E>0?l.jsxs("div",{className:"ff-p-8 ff-text-center",children:[l.jsx(C.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{className:"ff-font-medium ff-mb-2",style:{color:"var(--ff-text-primary)"},children:_}),l.jsx("div",{className:"ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2",children:l.jsx("div",{className:"ff-progress-bar",style:{width:`${E}%`,transition:"width 0.3s ease"}})}),l.jsxs("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[E,"% complete"]})]}):l.jsx(Ue,{onFileSelect:it})})}),d==="mapping"&&(h&&E>0?l.jsxs("div",{className:"ff-py-12 ff-text-center",children:[l.jsx(C.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{className:"ff-font-medium ff-mb-3",style:{color:"var(--ff-text-primary)"},children:_}),l.jsx("div",{className:"ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2",children:l.jsx("div",{className:"ff-progress-bar",style:{width:`${E}%`,transition:"width 0.3s ease"}})}),l.jsxs("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[E,"% complete"]})]}):l.jsx(Xe,{})),d==="validation"&&l.jsxs("div",{className:"ff-space-y-6",children:[l.jsx(st,{}),l.jsx(rt,{editable:!0})]}),d==="complete"&&l.jsx("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:ze?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4",style:{backgroundColor:"var(--ff-error-light)"},children:l.jsx(C.X,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-error)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Import Failed"}),l.jsx("p",{className:"ff-text-center ff-max-w-md ff-mb-4",style:{color:"var(--ff-text-muted)"},children:ze})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ff-w-20 ff-h-20 ff-rounded-2xl ff-flex ff-items-center ff-justify-center ff-mb-6",style:{backgroundColor:"var(--ff-success-light)"},children:l.jsx(C.CircleCheckBig,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-success)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Import Complete!"}),l.jsx("p",{className:"ff-mb-6",style:{color:"var(--ff-text-muted)"},children:"Your data has been successfully imported."}),l.jsxs("div",{className:"ff-flex ff-gap-6 ff-mb-6",children:[l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-success)",backgroundColor:"var(--ff-success-light)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-success-dark)"},children:ie.length}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-success)"},children:"Rows Imported"})]}),l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-border-light)",backgroundColor:"var(--ff-bg-primary)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-text-primary)"},children:a.filter(M=>M.targetKey!==null).length}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:"Columns Mapped"})]})]}),ie.length>0&&(()=>{const M=ie.slice(0,5),N=M[0],k=(N==null?void 0:N.data)||N,H=Object.keys(typeof k=="object"?k:{}).slice(0,6),q=(A==null?void 0:A.columns)||[];return H.length===0?null:l.jsxs("div",{className:"ff-w-full ff-mb-6",children:[l.jsx("p",{className:"ff-text-xs ff-font-semibold ff-uppercase ff-tracking-wider ff-mb-2",style:{color:"var(--ff-text-muted)"},children:"Imported Data Preview"}),l.jsx("div",{className:"ff-table-container ff-max-h-[250px]",children:l.jsxs("table",{className:"ff-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{style:{width:40},children:"#"}),H.map(D=>{const B=q.find(U=>U.key===D);return l.jsx("th",{children:(B==null?void 0:B.label)||D},D)}),H.length<Object.keys(typeof k=="object"?k:{}).length&&l.jsx("th",{children:"..."})]})}),l.jsx("tbody",{children:M.map((D,B)=>{const U=(D==null?void 0:D.data)||D;return l.jsxs("tr",{children:[l.jsx("td",{children:l.jsx("span",{className:"ff-font-mono ff-text-xs",style:{color:"var(--ff-text-muted)"},children:B+1})}),H.map(de=>l.jsx("td",{children:l.jsx("span",{className:"ff-text-sm ff-truncate ff-block ff-max-w-[150px]",children:String((U==null?void 0:U[de])??"—")})},de)),H.length<Object.keys(typeof k=="object"?k:{}).length&&l.jsx("td",{children:l.jsx("span",{style:{color:"var(--ff-text-muted)"},children:"..."})})]},B)})})]})}),ie.length>5&&l.jsxs("p",{className:"ff-text-xs ff-mt-1",style:{color:"var(--ff-text-muted)"},children:["Showing ",M.length," of ",ie.length," imported rows"]})]})})()]})})]}),l.jsx("div",{className:"ff-modal-footer",children:d==="complete"?l.jsxs(l.Fragment,{children:[f?l.jsx("button",{onClick:he,className:"ff-btn ff-btn-ghost",children:"Close"}):l.jsx("div",{}),l.jsx("button",{onClick:dt,className:"ff-btn ff-btn-primary",children:"Start New Import"})]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:re,disabled:oe()===0||h,className:"ff-btn ff-btn-ghost",children:"Back"}),!pt&&l.jsx("button",{onClick:gt,disabled:!ct()||h,className:"ff-btn ff-btn-primary",children:h?l.jsxs(l.Fragment,{children:[l.jsx(C.LoaderCircle,{className:"ff-w-4 ff-h-4 ff-animate-spin"})," Processing..."]}):d==="validation"?m&&m.errorCount>0?`Fix ${m.errorCount} error${m.errorCount>1?"s":""} to continue`:"Complete Import":"Continue"})]})})]})});return l.jsx(C.StyleProvider,{theme:n,useShadowDom:r,children:t==="modal"?l.jsx("div",{className:"ff-overlay",children:Ae}):Ae})};exports.ColumnMapper=Xe;exports.DataTable=rt;exports.FileUploader=Ue;exports.ImportWizard=En;exports.ValidationSummary=st;exports.useImportStore=ee;
64
+ //# sourceMappingURL=ImportWizard-4E5fcskQ.js.map