PageSourceSearch

https://cloud.agenty.com/assets/page-BL4IMA16.js

js agenty.com collected 2026-09-24 12:15:21 UTC 8,616 bytes, 2 lines download raw bytes

1import{j as e,M as G,O as K,P as X,Q as Z,N as ee,U as x,V as se,aL as ae,ax as w,ay as y,az as C,aA as S,aB as H,J as P,L as B,b7 as le,H as R,W as F}from"./ui-CfRm5DTA.js";import{r as u,aA as te,b as re,aB as ie,L as de,aC as ne,aD as ce}from"./icons-CoWim_VM.js";import{a as $,A as I}from"./api-TVx_5Nik.js";import{b as oe}from"./index-CO7lCi65.js";function fe(){var V;const O=oe(),[l,p]=u.useState(1),[a,n]=u.useState({listName:"",description:"",file:null,delimiter:"comma",hasHeader:"true",textQualifier:"double"}),[h,L]=u.useState([]),[D,Q]=u.useState([]),[A,T]=u.useState(!1),j=[{value:"comma",label:"Comma (,)",char:","},{value:"tab",label:"Tab",char:"	"},{value:"pipe",label:"Pipe (|)",char:"|"},{value:"semicolon",label:"Semicolon (;)",char:";"},{value:"colon",label:"Colon (:)",char:":"}],N=[{value:"double",label:'Double Quote (")',char:'"'},{value:"single",label:"Single Quote (')",char:"'"},{value:"caret",label:"Caret (^)",char:"^"},{value:"none",label:"None",char:""}],Y=[{value:"true",label:"Yes"},{value:"false",label:"No"}],_=s=>{const t=s.target.files[0];t&&n({...a,file:t})},q=s=>{var U,k,E;const t=(U=j.find(i=>i.value===a.delimiter))==null?void 0:U.char,r=(k=N.find(i=>i.value===a.textQualifier))==null?void 0:k.char,d=a.hasHeader==="true",c=s.toString().split(`
2`).filter(i=>i.trim()),o=[];if(c){for(const i of c){const f=[];let m="",g=!1;for(let v=0;v<i.length;v++){const b=i[v];r&&b===r?g=!g:b===t&&!g?(f.push(m.trim()),m=""):m+=b}f.push(m.trim()),o.push(f)}if(d&&o.length>0)Q(o[0]),L(o.slice(1));else{const i=((E=o[0])==null?void 0:E.length)||0;Q(Array.from({length:i},(f,m)=>`Column ${m+1}`)),L(o)}}},z=async()=>{var t,r;T(!0);const s=F.loading("Creating list...");try{const d=await $.post(I.lists,{name:a.listName,description:a.description});if(!d)throw new Error("Upload failed, please try again later");await $.upload(`${I.lists}/${d.list_id}/upload`,a.file,{header:a.hasHeader,delimiter:(t=j.find(c=>c.value===a.delimiter))==null?void 0:t.char,qualifier:(r=N.find(c=>c.value===a.textQualifier))==null?void 0:r.char}),F.success("List created successfully",{id:s}),O(`/lists/${d.list_id}`)}catch(d){F.error(d.message,{id:s})}finally{T(!1)}},M=()=>{if(l===1&&a.file){const s=new FileReader;s.onload=t=>{var r;q((r=t.target)==null?void 0:r.result),p(2)},s.readAsText(a.file)}else l===2?p(3):l===3&&z()},J=()=>{p(l-1)},W=()=>l===1?a.listName&&a.file:!0;return e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsxs(G,{className:"w-full max-w-4xl",children:[e.jsxs(K,{className:"text-center",children:[e.jsx(X,{className:"text-2xl",children:"Create New List"}),e.jsxs(Z,{children:["Step ",l," of 3"]}),e.jsx("div",{className:"flex justify-center gap-2 mt-4",children:[1,2,3].map(s=>e.jsx("div",{className:`h-2 w-16 rounded-full transition-colors ${s<=l?"bg-primary":"bg-muted"}`},s))})]}),e.jsxs(ee,{className:"mt-6",children:[l===1&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"listName",children:"List Name *"}),e.jsx(se,{id:"listName",placeholder:"Enter list name",value:a.listName,onChange:s=>n({...a,listName:s.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"description",children:"Description (Optional)"}),e.jsx(ae,{id:"description",placeholder:"Enter list description",value:a.description,onChange:s=>n({...a,description:s.target.value}),rows:3})]}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"flex items-center justify-center w-full",children:e.jsxs("label",{htmlFor:"file-upload",className:"flex flex-col items-center justify-center w-full h-32 border-2 border-dashed rounded-lg cursor-pointer hover:bg-muted/50",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center pt-5 pb-6",children:[e.jsx(te,{className:"w-8 h-8 mb-2 text-muted-foreground"}),a.file?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Selected file: ",a.file.name]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mb-2 text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-semibold",children:"Click to upload"})," ","or drag and drop"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"CSV or TSV files only"})]})]}),e.jsx("input",{id:"file-upload",type:"file",accept:".csv,.tsv,.txt",className:"hidden",onChange:_})]})})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"delimiter",children:"Delimiter"}),e.jsxs(w,{value:a.delimiter,onValueChange:s=>n({...a,delimiter:s}),children:[e.jsx(y,{className:"w-full",id:"delimiter",children:e.jsx(C,{})}),e.jsx(S,{children:j.map(s=>e.jsx(H,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"hasHeader",children:"Has Header"}),e.jsxs(w,{value:a.hasHeader,onValueChange:s=>n({...a,hasHeader:s}),children:[e.jsx(y,{className:"w-full",id:"hasHeader",children:e.jsx(C,{})}),e.jsx(S,{children:Y.map(s=>e.jsx(H,{value:s.value,children:s.label},s.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"textQualifier",children:"Text Qualifier"}),e.jsxs(w,{value:a.textQualifier,onValueChange:s=>n({...a,textQualifier:s}),children:[e.jsx(y,{className:"w-full",id:"textQualifier",children:e.jsx(C,{})}),e.jsx(S,{children:N.map(s=>e.jsx(H,{value:s.value,children:s.label},s.value))})]})]})]}),l===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2 text-muted-foreground mb-4",children:e.jsx("span",{className:"font-medium",children:"Preview"})}),e.jsx(P,{children:e.jsxs(B,{children:["Showing preview of ",Math.min(h.length,10)," of"," ",h.length," rows"]})}),e.jsx("div",{className:"border rounded-lg overflow-auto max-h-96",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"border-b bg-muted/50",children:e.jsx("tr",{children:D.map((s,t)=>e.jsx("th",{className:"px-4 py-3 text-left font-semibold text-foreground",children:s},t))})}),e.jsx("tbody",{children:h.slice(0,10).map((s,t)=>e.jsx("tr",{className:"border-b last:border-0 hover:bg-muted/50",children:s.map((r,d)=>e.jsx("td",{className:"px-4 py-3 text-foreground",children:r},d))},t))})]})})})]}),l===3&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center gap-2 text-muted-foreground mb-4",children:e.jsx("span",{className:"font-medium",children:"Upload Summary"})}),e.jsxs(P,{className:"bg-muted",children:[e.jsx(re,{className:"h-4 w-4"}),e.jsx(B,{className:"ml-2",children:"Your list is ready to be uploaded!"})]}),e.jsxs("div",{className:"space-y-4 bg-muted/50 p-6 rounded-lg",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"List Name"}),e.jsx("p",{className:"font-medium text-foreground",children:a.listName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"File Name"}),e.jsx("p",{className:"font-medium text-foreground",children:(V=a.file)==null?void 0:V.name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Rows"}),e.jsx("p",{className:"font-medium text-foreground text-lg",children:h.length})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Columns"}),e.jsx("p",{className:"font-medium text-foreground text-lg",children:D.length})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delimiter"}),e.jsx("p",{className:"font-medium text-foreground capitalize",children:a.delimiter})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Has Header"}),e.jsx("p",{className:"font-medium text-foreground",children:a.hasHeader==="true"?"Yes":"No"})]})]}),a.description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Description"}),e.jsx("p",{className:"font-medium text-foreground",children:a.description})]})]})]})]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsxs(R,{variant:"outline",onClick:J,disabled:l===1,children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),"Back"]}
2),e.jsx(R,{onClick:M,disabled:!W()||l===3&&A,children:l===3?e.jsxs(e.Fragment,{children:[A?e.jsx(de,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(ne,{className:"mr-2 h-4 w-4"}),"Upload List"]}):e.jsxs(e.Fragment,{children:["Next",e.jsx(ce,{className:"ml-2 h-4 w-4"})]})})]})]})})}export{fe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.