1import{K as _,bx as O,r as n,j as e,S as F,b0 as L,aj as q,b1 as I,a as W,aC as A,by as z,bz as B,b3 as G,bA as M,bB as Y,bC as H,bD as D}from"./index-Mfw5D6Uk.js";import{u as K,P as Q}from"./posts-scroller--b7QDlaI.js";import{S as V}from"./shield-check-BZShLnkP.js";import{W as Z}from"./wrench-1FtJGazM.js";import"./warranty-badge-DkSwUJyk.js";const X=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],J=_("badge-check",X);const U=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],ee=_("paperclip",U);const te=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],R=_("shopping-cart",te);function re(a,c){return c?`${a}::${c.label}`:a}function w(a){return a===null||Number.isNaN(a)?"POA":`$${Number(a).toLocaleString("en-NZ",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function me(){const{categories:a,accessories:c}=O.useLoaderData(),[g,m]=n.useState(null),[y,x]=n.useState(!1),[b,i]=n.useState(null),[f,j]=n.useState([]),[S,u]=n.useState(!1);function d(t,s){const o=re(t.id,s);j(l=>l.find(r=>r.key===o)?l.map(r=>r.key===o?{...r,qty:r.qty+1}:r):[...l,{key:o,item:t,qty:1,optionLabel:s?.label??null,unitPrice:s?s.price:t.price}])}const k=f.reduce((t,s)=>t+s.qty,0),p=n.useRef(null);K(p,[a.length]);const C=a.find(t=>t.slug===g)??null,h=C?c.filter(t=>t.category_id===C.id):[];function N(t){const s=p.current;s&&s.scrollBy({left:t==="left"?-s.clientWidth*.8:s.clientWidth*.8,behavior:"smooth"})}return e.jsxs("div",{className:"flex min-h-screen flex-col bg-background",children:[e.jsx(F,{}),e.jsxs("main",{className:"w-full flex-1",children:[e.jsxs("section",{className:"mx-auto w-full max-w-7xl px-4 pt-10 sm:px-8 lg:px-12",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-foreground md:text-4xl",children:"Mitsubishi Parts & Accessories in Tauranga"}),e.jsx("p",{className:"mt-3 max-w-3xl text-lg text-muted-foreground",children:"Genuine Mitsubishi parts and accessories, supplied and fitted in Tauranga by our factory-trained team. Every genuine part is designed for your vehicle and backed by the Mitsubishi Genuine Parts guarantee."})]}),e.jsxs("section",{className:"mx-auto w-full max-w-7xl px-4 pt-12 sm:px-8 lg:px-12",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Browse accessories by model"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Choose your Mitsubishi to see the range of popular genuine accessories."}),e.jsxs("div",{className:"relative mt-6 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>N("left"),"aria-label":"Scroll models left",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-red-600 p-2 text-white shadow-lg transition hover:scale-105 hover:bg-red-700 sm:h-12 sm:w-12 md:h-14 md:w-14",children:e.jsx(L,{className:"h-7 w-7 md:h-8 md:w-8"})}),e.jsx("div",{ref:p,className:"scrollbar-hide flex min-w-0 flex-1 cursor-grab snap-x snap-mandatory select-none gap-4 overflow-x-auto overscroll-x-contain sm:gap-5 md:gap-6",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:a.map(t=>{const s=t.slug===g;return e.jsx("button",{type:"button",onClick:()=>m(s?null:t.slug),className:"group w-[calc((100%_-_1rem)/2)] shrink-0 snap-start text-left sm:w-[220px] md:w-[240px]","aria-pressed":s,children:e.jsxs("div",{className:`relative overflow-hidden rounded-2xl bg-background shadow-sm ring-1 transition ${s?"ring-2 ring-primary":"ring-border group-hover:shadow-md"}`,children:[e.jsx("div",{className:"aspect-[4/3] w-full overflow-hidden",children:e.jsx(q,{src:t.image_url,alt:`${t.name} accessories`,width:300,height:300,loading:"lazy",decoding:"async",draggable:!1,
1className:"pointer-events-none h-full w-full object-cover transition duration-500 group-hover:scale-[1.03]"})}),e.jsxs("p",{className:`absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/75 to-transparent px-3 pb-2 pt-8 text-base font-semibold text-white ${s?"text-white":"text-white/90"}`,children:[t.name," Accessories"]})]})},t.id)})}),e.jsx("button",{type:"button",onClick:()=>N("right"),"aria-label":"Scroll models right",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-red-600 p-2 text-white shadow-lg transition hover:scale-105 hover:bg-red-700 sm:h-12 sm:w-12 md:h-14 md:w-14",children:e.jsx(I,{className:"h-7 w-7 md:h-8 md:w-8"})})]})]}),C&&e.jsxs("section",{className:"mx-auto w-full max-w-7xl px-4 pt-8 sm:px-8 lg:px-12",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-border pt-8",children:[e.jsxs("h2",{className:"text-2xl font-bold tracking-tight text-foreground",children:[C.name," Accessories",e.jsxs("span",{className:"ml-2 text-base font-medium text-muted-foreground",children:[h.length," ",h.length===1?"product":"products"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>u(!0),className:"inline-flex items-center gap-2 rounded-full bg-primary px-4 py-2 text-sm font-semibold text-primary-foreground shadow-sm transition hover:brightness-110",children:[e.jsx(R,{className:"h-4 w-4","aria-hidden":!0}),"View Cart",k>0?` (${k})`:""]}),e.jsx("button",{type:"button",onClick:()=>m(null),className:"rounded-full border border-border px-4 py-2 text-sm font-semibold text-foreground transition hover:border-primary hover:text-primary",children:"Close"})]})]}),e.jsxs("ul",{className:"mt-6 grid grid-cols-2 gap-4 sm:gap-6 md:grid-cols-3 lg:grid-cols-4",children:[h.map(t=>e.jsxs("li",{role:"button",tabIndex:0,onClick:()=>i(t),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),i(t))},className:"flex cursor-pointer flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-sm transition hover:shadow-md focus:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:[e.jsx("div",{className:"aspect-square w-full overflow-hidden bg-muted",children:t.image_url?e.jsx(q,{src:t.image_url,alt:t.name,width:300,height:300,loading:"lazy",decoding:"async",className:"h-full w-full object-cover"}):null}),e.jsxs("div",{className:"flex flex-1 flex-col p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:t.name}),t.part_code&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Part ",t.part_code]}),e.jsxs("div",{className:"mt-auto pt-3",children:[t.price_options.length>1?e.jsx("ul",{className:"space-y-1",children:t.price_options.map((s,o)=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:s.label}),e.jsx("span",{className:"text-sm font-bold text-primary",children:w(s.price)})]},`${s.label}-${o}`))}):e.jsxs(e.Fragment,{children:[t.was_price&&e.jsx("p",{className:"text-xs text-muted-foreground line-through",children:w(t.was_price)}),e.jsx("p",{className:"text-lg font-bold text-primary",children:w(t.price_options.length===1?t.price_options[0].price:t.price)})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Price includes GST, fitting extra"})]})]})]},t.id)),h.length===0&&e.jsx("li",{className:"col-span-full rounded-2xl border border-dashed border-border p-8 text-center text-muted-foreground",children:"No accessories listed for this model yet. Request a quote and we'll help."})]})]}),e.jsx("section",{className:"mx-auto w-full max-w-7xl px-4 pt-12 sm:px-8 lg:px-12",children:e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border bg-primary/5 p-6 sm:p-8",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-foreground sm:text-2xl",children:"Looking for a specific part?"}),e.jsx("p",{className:"mt-2 max-w-2xl text-muted-foreground",children:"Tell us your number plate and what you need. Our parts team will c
1ome back to you with pricing and availability."})]}),e.jsx("button",{type:"button",onClick:()=>x(t=>!t),className:"shrink-0 rounded-full bg-primary px-6 py-3 text-base font-semibold text-primary-foreground shadow-md transition hover:brightness-110","aria-expanded":y,children:y?"Close quote form":"Request a parts quote"})]}),y&&e.jsx(oe,{onClose:()=>x(!1)})]})}),e.jsxs("section",{className:"mx-auto w-full max-w-7xl px-4 py-14 sm:px-8 lg:px-12",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Why genuine Mitsubishi parts?"}),e.jsx("div",{className:"mt-6 grid gap-6 md:grid-cols-3",children:[{icon:V,title:"Fully guaranteed",body:"Every genuine Mitsubishi part and accessory is covered by a Mitsubishi Motors New Zealand parts warranty, so you are protected long after the fitting is done."},{icon:J,title:"Made for your Mitsubishi",body:"Genuine parts are engineered and tested for your exact model, so fit, finish and safety systems perform exactly as the factory
1intended. And your new-vehicle warranty stays intact."},{icon:Z,title:"Fitted by our technicians",body:"Our factory-trained technicians fit accessories in-house using the correct tools and procedures, and can add them to a service booking so you only visit once."}].map(t=>e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6 shadow-sm",children:[e.jsx(t.icon,{className:"h-8 w-8 text-primary","aria-hidden":!0}),e.jsx("h3",{className:"mt-4 text-lg font-bold text-foreground",children:t.title}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:t.body})]},t.title))}),e.jsxs("div",{className:"mt-10 rounded-2xl border border-border bg-muted/40 p-6 sm:p-8",children:[e.jsx("h2",{className:"text-xl font-bold text-foreground sm:text-2xl",children:"Parts and Service in Tauranga"}),e.jsx("p",{className:"mt-3 max-w-3xl text-muted-foreground",children:"Alongside accessories, our parts department stocks genuine servicing items, including filters, brake components, wiper blades, batteries, globes and more. And can order anything we don't hold. We also supply parts for older Mitsubishi models, so talk to us before you settle for an aftermarket alternative."}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{x(!0),window.scrollTo({top:0,behavior:"smooth"})},className:"rounded-full bg-primary px-6 py-3 text-sm font-semibold text-primary-foreground shadow-md transition hover:brightness-110",children:"Request a parts quote"}),e.jsx("a",{href:"tel:075779577",className:"rounded-full border border-border px-6 py-3 text-sm font-semibold text-foreground transition hover:border-primary hover:text-primary",children:"Call the parts team. (07) 577 9577"}),e.jsx("a",{href:"/service-centre-booking-request",className:"rounded-full bg-primary px-6 py-3 text-sm font-semibold text-primary-foreground shadow-md transition hover:brightness-110",children:"Book Repairs or Service"})]})]})]})]}),e.jsx(Q,{category:"parts-service",title:"Parts and Service News",subtitle:"Tips, specials and updates from our workshop"}),e.jsx(W,{}),b&&e.jsx(se,{item:b,cartCount:k,onAdd:t=>d(b,t),onViewCart:()=>{i(null),u(!0)},onClose:()=>i(null)}),S&&e.jsx(ae,{lines:f,onClose:()=>u(!1),onRemove:t=>j(s=>s.filter(o=>o.key!==t)),onQtyChange:(t,s)=>j(o=>s<1?o.filter(l=>l.key!==t):o.map(l=>l.key===t?{...l,qty:s}:l))})]})}function T({title:a,onClose:c,children:g}){return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-start justify-center overflow-y-auto bg-foreground
1/60 p-4 backdrop-blur-sm sm:items-center",onClick:c,role:"dialog","aria-modal":"true","aria-label":a,children:e.jsxs("div",{className:"relative my-8 w-full max-w-3xl rounded-2xl border border-border bg-card p-6 shadow-xl sm:p-8",onClick:m=>m.stopPropagation(),children:[e.jsx("button",{type:"button",onClick:c,"aria-label":"Close",className:"absolute right-4 top-4 rounded-full border border-border p-2 text-foreground transition hover:border-primary hover:text-primary",children:e.jsx(A,{className:"h-4 w-4"})}),g]})})}function se({item:a,cartCount:c,onAdd:g,onViewCart:m,onClose:y}){const[x,b]=n.useState(!1),i=a.price_options??[],[f,j]=n.useState(0),S=i.length>1?i[f]??i[0]:null;return e.jsx(T,{title:a.name,onClose:y,children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsx("div",{className:"aspect-square w-full overflow-hidden rounded-xl bg-muted",children:a.image_url?e.jsx(q,{src:a.image_url,alt:a.name,width:600,height:600,className:"h-full w-full object-cover"}):null}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h2",{className:"pr-8 text-xl font-bold text-foreground",children:a.name}),a.part_code&&e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Part ",a.part_code]}),a.description&&e.jsx("p",{className:"mt-4 whitespace-pre-line text-sm text-muted-foreground",children:a.description}),e.jsx("div",{className:"mt-4",children:i.length>1?e.jsxs("fieldset",{children:[e.jsx("legend",{className:"text-sm font-semibold text-foreground",children:"Choose your version"}),e.jsx("div",{className:"mt-2 space-y-2",children:i.map((u,d)=>e.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-4 rounded-xl border px-4 py-3 transition ${d===f?"border-primary bg-primary/5":"border-border hover:border-primary"}`,children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"radio",name:`option-${a.id}`,checked:d===f,onChange:()=>{j(d),b(!1)},className:"h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:u.label})]}),e.jsx("span",{className:"text-base font-bold text-primary",children:w(u.price)})]},`${u.label}-${d}`))}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Price includes GST, fitting extra"})]}):e.jsxs(e.Fragment,{children:[a.was_price&&e.jsx("p",{className:"text-sm text-muted-foreground line-through",children:w(a.was_price)}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:w(i.length===1?i[0].price:a.price)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Price includes GST, fitting extra"})]})}),e.jsxs("div",{className:"mt-6 flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",disabled:x,onClick:()=>{g(S),b(!0)},className:"rounded-full bg-primary px-6 py-3 text-sm font-semibold text-primary-foreground shadow-md transition hover:brightness-110 disabled:opacity-60",children:x?"Added to cart":"Add to Cart"}),e.jsxs("button",{type:"button",onClick:m,className:"inline-flex items-center gap-2 rounded-full border border-border px-6 py-3 text-sm font-semibold text-foreground transition hover:border-primary hover:text-primary",children:[e.jsx(R,{className:"h-4 w-4","aria-hidden":!0}),"View Cart",c+0>0?` (${c})`:""]})]})]})]})})}function ae({lines:a,onClose:c,onRemove:g,onQtyChange:m}){const[y,x]=n.useState(""),[b,i]=n.useState(""),[f,j]=n.useState(""),[S,u]=n.useState(""),[d,k]=n.useState(void 0),[p,C]=n.useState(""),[h,N]=n.useState("idle"),[t,s]=n.useState(""),o=a.reduce((r,P)=>r+(P.unitPrice??0)*P.qty,0),l="w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary";async function $(r){r.preventDefault(),N("sending"),s("");const P=a.map(v=>`${v.qty} x ${v.item.name}${v.optionLabel?` [${v.optionLabel}]`:""}${v.item.part_code?` (${v.item.part_code})`:""} · ${w(v.unitPrice)}`),E=["Cart: confirm pricing for my vehicle",...P,P.length?`Estimated total: ${w(o)}`:"",d?`Preferred installation date: ${M(d,"PPP")}`:"",p?` 2${p}`:""].filter(Boolean).join(` 3`);try{const v=await D({data:{name:y,phone:b,email:f,plate:S,partDescription:E,imageNames:[]}});if(!v.ok){N("error"),s(v.error??"Something went wrong.");return}N("sent")}catch{N("error"),s("Please check the form and try again.")}}return e.jsxs(T,{title:"Your cart",onClose:c,children:[e.jsx("h2",{className:"pr-8 text-2xl font-bold text-foreground",children:"Your cart"}),a.length===0?e.jsx("p",{className:"mt-4 text-muted-foreground",children:"Your cart is empty. Choose a product to add it here."}
3):e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"mt-5 divide-y divide-border rounded-xl border border-border",children:a.map(r=>e.jsxs("li",{className:"flex items-center gap-4 p-3",children:[e.jsx("div",{className:"h-16 w-16 shrink-0 overflow-hidden rounded-lg bg-muted",children:r.item.image_url?e.jsx(q,{src:r.item.image_url,alt:r.item.name,width:64,height:64,className:"h-full w-full object-cover"}):null}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:r.item.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.optionLabel?e.jsx("span",{className:"mr-2 rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:r.optionLabel}):null,w(r.unitPrice)]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-muted-foreground",htmlFor:`qty-${r.key}`,children:"Qty"}),e.jsx("button",{type:"button","aria-label":`Decrease quantity of ${r.item.name}`,onClick:()=>m(r.key,r.qty-1),className:"h-7 w-7 rounded-full border border-border text-sm font-semibold text-foreground transition hover:border-primary hover:text-primary",children:"â"}),e.jsx("input",{id:`qty-${r.key}`,type:"number",min:1,value:r.qty,onChange:P=>m(r.key,Number(P.target.value)),className:"w-14 rounded-lg border border-border bg-background px-2 py-1 text-center text-sm text-foreground outline-none focus:border-primary"}),e.jsx("button",{type:"button","aria-label":`Increase quantity of ${r.item.name}`,onClick:()=>m(r.key,r.qty+1),className:"h-7 w-7 rounded-full border border-border text-sm font-semibold text-foreground transition hover:border-primary hover:text-primary",children:"+"})]})]}),e.jsx("button",{type:"button",onClick:()=>g(r.key),"aria-label":`Remove ${r.item.name}`,className:"rounded-full border border-border p-2 text-muted-foreground transition hover:border-primary hover:text-primary",children:e.jsx(A,{className:"h-4 w-4"})})]},r.key))}),e.jsxs("p",{className:"mt-3 text-right text-sm font-semibold text-foreground",children:["Estimated total: ",e.jsx("span",{className:"text-primary",children:w(o)})]})]}),h==="sent"?e.jsxs("div",{className:"mt-6 rounded-xl border border-border bg-muted/40 p-6",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"Thanks. We've got your request."}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Our parts team will confirm pricing and fitting for your vehicle shortly."})]}):e.jsxs("form",{onSubmit:$,className:"mt-6 rounded-xl border border-border p-5 sm:p-6",children:[e.jsx("h3",{className:"text-lg font-bold text-foreground",children:"Confirm pricing for my vehicle"}),e.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground",children:["Name",e.jsx("input",{required:!0,value:y,onChange:r=>x(r.target.value),className:`mt-1 ${l}`})]}),e.jsxs("label",{className:"block text-sm font-medium text-foreground",children:["Phone",e.jsx("input",{required:!0,value:b,onChange:r=>i(r.target.value),className:`mt-1 ${l}`})]}),e.jsxs("label",{className:"block text-sm font-medium text-foreground",children:["Email",e.jsx("input",{required:!0,type:"email",value:f,onChange:r=>j(r.target.value),className:`mt-1 ${l}`})]}),e.jsxs("label",{className:"block text-sm font-medium text-foreground",children:["Number plate",e.jsx("input",{value:S,onChange:r=>u(r.target.value),className:`mt-1 ${l}`})]}),e.jsxs("div",{className:"block text-sm font-medium text-foreground",children:["Preferred installation date",e.jsxs(z,{children:[e.jsx(B,{asChild:!0,children:e.jsxs("button",{type:"button",className:`mt-1 flex items-center gap-2 text-left font-normal ${l} ${d?"":"text-muted-foreground"}`,children:[e.jsx(G,{className:"h-4 w-4","aria-hidden":!0}),d?M(d,"PPP"):"Pick a date"]})}),e.jsx(Y,{className:"w-auto p-0",align:"start",children:e.jsx(H,{mode:"single",selected:d,onSelect:k,disabled:r=>r<new Date(new Date().setHours(0,0,0,0)),initialFocus:!0,className:"pointer-events-auto p-3"})})]})]})]}),e.jsxs("label",{className:"mt-4 block text-sm font-medium text-foreground",children:["Message",e.jsx("textarea",{rows:4,value:p,onChange:r=>C(r.target.value),className:`mt-1 ${l}`,placeholder:"Anything else we should know?"})]}),t&&e.jsx("p",{className:"mt-4 text-sm text-destructive",children:t}),e.jsx("button",{type:"submit",disabled:h==="sending",className:"mt-5 rounded-full bg-primary px-6 py-3 text-sm font-semibold text-primary-foreground shadow-md transition hover:brightness-110 disabled:opacity-60",children:h==="sending"?"Sendingâ¦":"Send request"})]})]})}function oe({onClose:a}){const[c,g]=n.useState(""),[m,y]=n.useState(""),[x,b]=n.useState(""),[i,f]=n.useState(""),[j,S]=n.useState(""),[u,d]=n.useState([]),[k,p]=n.useState("idle"),[C,h]=n.useState(""),N=n.useRef(null);async function t(o){o.preventDefault(),p("sending"),h("");try{const l=await D({data:{name:c,phone:m,email:x,plate:i,partDescription:j,imageNames:u}});if(!l.ok){p("error"),h(l.error??"Something went wrong.");return}p("sent")}catch{p("error"),h("Please check the form and try again.")}}if(k==="sent")return e.jsxs("div",{className:"mt-6 rounded-xl border border-border bg-card p-6",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"Thanks. Your quote request is on its way."}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Our parts team will be in touch shortly. If you have photos of the part, reply to our email and attach them."}),e.jsx("button",{type:"button",onClick:a,className:"mt-4 rounded-full border border-border px-5 py-2 text-sm font-semibold text-foreground transition hover:border-primary hover:text-primary",children:"Close"})]});const s="w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary";return e.jsxs("form",{onSubmit:t,className:"mt-6 rounded-xl border border-border bg-card p-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground",children:["Name",e.jsx("input",{required:!0,value:c,onChange:o=>g(o.target.value),className:`mt-1 ${s}`})]}),e.jsxs("label",{className:"block text-sm font-medium text-foreground",children:["Phone",e.jsx("input",{required:!0,value:m,onChange:o=>y(o.target.value),className:`mt-1 ${s}`})]}),e.jsxs("label",{className:"block text-sm font-medium text-foreground",children:["Email",e.jsx("input",{required:!0,type:"email",value:x,onChange:o=>b(o.target.value),className:`mt-1 ${s}`})]}),e.jsxs("label",{className:"block text-sm font-medium text-foreground",children:["Number plate",e.jsx("input",{value:i,onChange:o=>f(o.target.value),className:`mt-1 ${s}`})]})]}),e.jsxs("label",{className:"mt-4 block text-sm font-medium text-foreground",children:["Part description",e.jsx("textarea",{required:!0,rows:4,value:j,onChange:o=>S(o.target.value),className:`mt-1 ${s}`,placeholder:"Tell us the part you need, and anything that helps us identify it."})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("input",{ref:N,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:o=>
3d(Array.from(o.target.files??[]).slice(0,10).map(l=>l.name))}),e.jsxs("button",{type:"button",onClick:()=>N.current?.click(),className:"inline-flex items-center gap-2 rounded-full border border-border px-4 py-2 text-sm font-semibold text-foreground transition hover:border-primary hover:text-primary",children:[e.jsx(ee,{className:"h-4 w-4","aria-hidden":!0}),"Add images"]}),u.length>0&&e.jsx("ul",{className:"mt-3 flex flex-wrap gap-2",children:u.map(o=>e.jsxs("li",{className:"inline-flex items-center gap-1 rounded-full bg-primary/10 px-3 py-1 text-xs font-medium text-primary",children:[o,e.jsx("button",{type:"button","aria-label":`Remove ${o}`,onClick:()=>d(l=>l.filter($=>$!==o)),children:e.jsx(A,{className:"h-3 w-3"})})]},o))})]}),C&&e.jsx("p",{className:"mt-4 text-sm text-destructive",children:C}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-3",children:[e.jsx("button",{type:"submit",disabled:k==="sending",className:"rounded-full bg-primary px-6 py-3 text-sm font-semibold text-primary-foreground shadow-md transition hover:brightness-110 disabled:opacity-60",children:k==="sending"?"Sendingâ¦":"Send quote request"}),e.jsx("button",{type:"button",onClick:a,className:"rounded-full border border-border px-6 py-3 text-sm font-semibold text-foreground transition hover:border-primary hover:text-primary",children:"Cancel"})]})]})}export{me 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.