PageSourceSearch

https://loveacrossborders.com/assets/books.admin._bookId.ingest-fn2esZCa.js

js loveacrossborders.com collected 2026-10-08 14:17:09 UTC 5,988 bytes, 1 lines download raw bytes

1import{I as A,u as D,r as l,j as e,L as E,t as n}from"./index-hs4a0mYW.js";import{u as T}from"./useQuery-C-iGd3mh.js";import{u as R}from"./useMutation-CsVV5qgy.js";import{u as L}from"./useServerFn-DgMZqDJQ.js";import{i as _,g as K}from"./books.functions-BjM2fbuH.js";import{e as M}from"./extract-text-Dj6Ou_lK.js";import{I as d,C as f,a as O,N as s,e as P,b as C,i as U,j as q,g as b,h as z}from"./brand-BVAz6htY.js";import{A as G}from"./arrow-left-bJxZenjV.js";import{F as X}from"./file-text-G_mxHyOn.js";import{U as H}from"./upload-hM-7dRRF.js";function re(){const{bookId:r}=A.useParams(),m=D(),i=L(K),x=L(_),{data:c,refetch:$}=T({queryKey:["books",r],queryFn:()=>i({data:{id:r}})}),[h,y]=l.useState(""),[j,S]=l.useState(""),[o,u]=l.useState(""),[N,k]=l.useState(!1),g=R({mutationFn:()=>x({data:{bookId:r,text:o,chapterLabel:h.trim(),pageLabel:j.trim(),replace:N}}),onSuccess:t=>{n.success(`Ingested ${t.inserted} chunks.`),u(""),k(!1),$()},onError:t=>n.error(t.message)}),[F,v]=l.useState(!1),[I,w]=l.useState(0),B=async t=>{if(t.size>5e7){n.error("File too large (50 MB max).");return}try{v(!0),w(0);const a=await M(t,w);u(a),h||y(t.name.replace(/\.(pdf|docx|epub|txt|md)$/i,"")),n.success(`Extracted ${a.length.toLocaleString()} characters.`)}catch(a){n.error(a instanceof Error?a.message:"Could not read the file.")}finally{v(!1)}};return e.jsxs("div",{className:"min-h-screen",style:{background:f,color:d,fontFamily:"'Inter', sans-serif"},children:[e.jsx("header",{style:{borderBottom:`1px solid ${O}`},children:e.jsxs("div",{className:"mx-auto max-w-3xl px-8 py-5 flex items-center justify-between",children:[e.jsxs(E,{to:"/books/admin",className:"inline-flex items-center gap-2 text-sm",style:{color:s},children:[e.jsx(G,{className:"h-4 w-4","aria-hidden":!0})," Admin"]}),e.jsx("span",{style:{fontFamily:"'Playfair Display', serif",color:s},children:"Ingest manuscript"})]})}),e.jsxs("main",{className:"mx-auto max-w-3xl px-8 py-16",children:[e.jsx("h1",{className:"mb-2",style:{fontFamily:"'Playfair Display', serif",color:s,fontSize:32,fontWeight:500},children:c?.book.title??"Loading..."}),e.jsx("p",{className:"mb-10 text-sm",style:{color:`${P}`},children:c?e.jsxs(e.Fragment,{children:["by ",c.book.author," · ",c.chunk_count," chunks indexed"]}):""}),e.jsxs("div",{className:"p-4 mb-8 text-sm",style:{background:`${q}`,border:`1px solid ${U}`,color:`${C}`},children:[e.jsx("strong",{style:{color:s},children:"How it works."})," Paste a section of the manuscript (a chapter is ideal) and label it. The text is split into ~1,200 character chunks, each is embedded, and stored for retrieval. Repeat for each chapter. Larger files: split them up and ingest piece by piece."]}),e.jsxs("form",{onSubmit:t=>{if(t.preventDefault(),o.trim().length<20){n.error("Paste more text to ingest.");return}g.mutate()},className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(p,{label:"Chapter label",hint:"e.g. Chapter 3 · The Garden",children:e.jsx("input",{value:h,onChange:t=>y(t.target.value),maxLength:255,placeholder:"Chapter 1",className:"w-full px-4 py-3 text-base",style:{background:"#FBF8F1",border:`1px solid ${b}`,color:d}})}),e.jsx(p,{label:"Page label",hint:"e.g. pp. 12–34",children:e.jsx("input",{value:j,onChange:t=>S(t.target.value),maxLength:64,placeholder:"pp. 1–20",className:"w-full px-4 py-3 text-base",style:{background:"#FBF8F1",border:`1px solid ${b}`,color:d}})})]}),e.jsx(p,{label:"Upload a file (optional)",hint:"PDF, DOCX, EPUB, TXT, or MD. Extracted in your browser. Scanned PDFs without text won't work · re-export with OCR first.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"inline-flex items-center gap-2 px-4 py-2 text-xs cursor-pointer",style:{background:s,color:f,letterSpacing:"0.04em",textTransform:"uppercase"},children:[e.jsx(X,{className:"h-3.5 w-3.5","aria-hidden":!0}),F?`Reading... ${I}%`:"Choose file",e.jsx("input",{type:"file",accept:".pdf,.docx,.epub,.txt,.md,application/pdf,application/epub+zip,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/plain,text/markdown",className:"hidden",disabled:F,onChange:t=>{const a=t.target.files?.[0];a&&B(a),t.target.value=""}})]}),o&&e.jsxs("span",{className:"text-xs",style:{color:`${P}`}
1,children:[o.length.toLocaleString()," chars loaded"]})]})}),e.jsx(p,{label:"Manuscript text",required:!0,hint:`${o.length.toLocaleString()} characters`,children:e.jsx("textarea",{value:o,onChange:t=>u(t.target.value),rows:18,required:!0,minLength:20,maxLength:2e6,placeholder:"Paste the chapter text here...",className:"w-full px-4 py-3 text-base font-mono",style:{background:"#FBF8F1",border:`1px solid ${b}`,color:d}})}),e.jsxs("label",{className:"flex items-start gap-3 text-sm",style:{color:`${C}`},children:[e.jsx("input",{type:"checkbox",checked:N,onChange:t=>k(t.target.checked),className:"mt-1"}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:s},children:"Replace all existing chunks for this book."})," Use this only if you want to start over."]})]}),e.jsxs("div",{className:"pt-2 flex items-center gap-4",children:[e.jsxs("button",{type:"submit",disabled:g.isPending,className:"inline-flex items-center gap-2 px-6 py-3 text-sm",style:{background:s,color:f,letterSpacing:"0.04em",textTransform:"uppercase"},children:[e.jsx(H,{className:"h-4 w-4","aria-hidden":!0}),g.isPending?"Embedding...":"Ingest this section"]}),e.jsx("button",{type:"button",onClick:()=>m({to:"/books/$bookId",params:{bookId:r}}),className:"text-sm underline-offset-4 hover:underline",style:{color:s},children:"Open in reader →"})]})]})]})]})}function p({label:r,required:m,hint:i,children:x}){return e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"block mb-2 text-sm",style:{color:s},children:[r,m&&e.jsx("span",{style:{color:"#8B1A1A"},children:" *"})]}),x,i&&e.jsx("span",{className:"block mt-1 text-xs",style:{color:`${z}`},children:i})]})}export{re as component};

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.