File size: 4,575 Bytes
95fc2fa
 
1
2
3
import{r as n,j as s}from"./index-DVHLcSXM.js";const v=["Disappointed with the battery life! The phone barely lasts half a day with regular use. Considering how much I paid for it, I expected better performance in this department.","I bought this phone a week ago, and I'm already frustrated with the battery life. It barely lasts half a day with normal usage. I expected more from a supposedly high-end device","The charging port is so finicky. Sometimes it takes forever to charge, and other times it doesn't even recognize the charger. Frustrating experience!","This phone heats up way too quickly, especially when using demanding apps. It's uncomfortable to hold, and I'm concerned it might damage the internal components over time. Not what I expected","This phone is like holding a hot potato. Video calls turn it into a scalding nightmare. Seriously, can't it keep its cool?","Forget about a heatwave outside; my phone's got its own. It's like a little portable heater. Not what I signed up for.","I dropped the phone from a short distance, and the screen cracked easily. Not as durable as I expected from a flagship device.","Took a slight bump in my bag, and the frame got dinged. Are we back in the flip phone era?","So, my phone's been in my pocket with just keys – no ninja moves or anything. Still, it managed to get some scratches. Disappointed with the build quality.","The software updates are a nightmare. Each update seems to introduce new bugs, and it takes forever for them to be fixed.","Constant crashes and freezes make me want to throw it into a black hole.","Every time I open Instagram, my phone freezes and crashes. It's so frustrating!","I'm not sure what to make of this phone. It's not bad, but it's not great either. I'm on the fence about it.","I hate the color of this phone. It's so ugly!","This phone sucks! I'm returning it."].sort(()=>Math.random()-.5),k=["Battery and charging problems","Overheating","Poor build quality","Software issues","Other"];function j(){const[u,b]=n.useState(v.join(`
`)),[o,r]=n.useState(k.map(t=>({title:t,items:[]}))),[g,c]=n.useState("idle"),i=n.useRef(null);n.useEffect(()=>{i.current||(i.current=new Worker(new URL("/assets/worker-DB01epKE.js",import.meta.url),{type:"module"}));const t=a=>{const e=a.data.status;if(e==="initiate")c("loading");else if(e==="ready")c("ready");else if(e==="output"){const{sequence:l,labels:d,scores:w}=a.data.output,y=w[0]>.5?d[0]:"Other",m=o.map(p=>p.title).indexOf(y)??o.length-1;r(p=>{const h=[...p];return h[m]={...h[m],items:[...h[m].items,l]},h})}else e==="complete"&&c("idle")};return i.current.addEventListener("message",t),()=>i.current.removeEventListener("message",t)},[o]);const x=n.useCallback(()=>{c("processing"),i.current.postMessage({text:u,labels:o.slice(0,o.length-1).map(t=>t.title)})},[u,o]),f=g!=="idle";return s.jsxs("div",{className:"flex flex-col h-screen w-screen p-1",children:[s.jsx("textarea",{className:"border w-full p-1 h-1/2",value:u,onChange:t=>b(t.target.value)}),s.jsxs("div",{className:"flex flex-col justify-center items-center m-2 gap-1",children:[s.jsx("button",{className:"border py-1 px-2 bg-blue-400 rounded text-white text-lg font-medium disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",disabled:f,onClick:x,children:f?g==="loading"?"Model loading...":"Processing":"Categorize"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{className:"border py-1 px-2 bg-green-400 rounded text-white text-sm font-medium cursor-pointer",onClick:t=>{r(a=>{const e=[...a];return e.splice(e.length-1,0,{title:"New Category",items:[]}),e})},children:"Add category"}),s.jsx("button",{className:"border py-1 px-2 bg-red-400 rounded text-white text-sm font-medium cursor-pointer",disabled:o.length<=1,onClick:t=>{r(a=>{const e=[...a];return e.splice(e.length-2,1),e})},children:"Remove category"}),s.jsx("button",{className:"border py-1 px-2 bg-orange-400 rounded text-white text-sm font-medium cursor-pointer",onClick:t=>{r(a=>a.map(e=>({...e,items:[]})))},children:"Clear"})]})]}),s.jsx("div",{className:"flex justify-between flex-grow overflow-x-auto max-h-[40%]",children:o.map((t,a)=>s.jsxs("div",{className:"flex flex-col w-full",children:[s.jsx("input",{disabled:t.title==="Other",className:"w-full border px-1 text-center",value:t.title,onChange:e=>{r(l=>{const d=[...l];return d[a].title=e.target.value,d})}}),s.jsx("div",{className:"overflow-y-auto h-full border",children:t.items.map((e,l)=>s.jsx("div",{className:"m-2 border bg-red-50 rounded p-1 text-sm",children:e},l))})]},a))})]})}export{j as default};