import{e as U,r as t,j as e}from"./vendor-react-DgEFbQIi.js";import{f as R}from"./timeUtils-J6UVSYhu.js";import{aN as J,aw as K,ax as X,aM as Z,aP as _,ah as G,ai as ee,bi as se,L as r,I as A,b2 as te,aL as ae,b9 as ie,B as I,f as k,bh as re}from"./index-DFVuS8SP.js";import{D as ne,T as Q}from"./time-picker-CVBYk6mZ.js";import{E as oe}from"./EventAddressAutocomplete-BzvAP_c0.js";import{i as ce}from"./serviceEventLocation-BFeOjzcJ.js";import{p as W}from"./parse-DWUfxhsp.js";import{C as le}from"./calendar-days-CNTt1Q2P.js";function je({open:z,onClose:B,listingId:g,packageId:j,packageName:c,pricingMode:y,negotiatedFrom:f,defaultEventDate:l,defaultGuestCount:a,defaultStartTime:N,defaultEndTime:q,askEventAddress:S=!1,defaultEventLocation:w=null}){const H=U(),{toast:O}=re(),x=J(),[d,C]=t.useState(c?`Quote request: ${c}`:""),[m,b]=t.useState(""),[n,D]=t.useState(()=>{if(!l)return null;try{return W(l,"yyyy-MM-dd",new Date)}catch{return null}}),[T,M]=t.useState(a&&a>0?String(a):""),[o,L]=t.useState(N??""),[h,$]=t.useState(q??""),[p,F]=t.useState(w),E=d.trim().length>0,P=()=>{C(c?`Quote request: ${c}`:""),b(""),D(l?W(l,"yyyy-MM-dd",new Date):null),M(a&&a>0?String(a):""),L(N??""),$(q??""),F(w),B()},V=async()=>{if(!E)return;const s=parseInt(T,10),v=[`Hi! I'd like to request a custom quote: ${d.trim()}`];m.trim()&&v.push(m.trim());const i=[];n&&i.push(`Date: ${k(n,"MMM d, yyyy")}`),!isNaN(s)&&s>0&&i.push(`Guests: ${s}`),o&&i.push(`Time: ${R(o)}${h?` – ${R(h)}`:""}`);const u=S&&ce(p)?p:null;u&&i.push(`Where: ${u.formattedAddress}`),i.length>0&&v.push(i.join(" · "));try{const Y=await x.mutateAsync({listingId:g,initialMessage:v.join(`

`),customRequestContext:{title:d.trim(),description:m.trim()||void 0,eventDate:n?k(n,"yyyy-MM-dd"):void 0,eventTime:o||void 0,eventEndTime:h||void 0,guestCount:!isNaN(s)&&s>0?s:void 0,sourceListingId:g,...j?{packageId:j}:{},...y?{pricingMode:y}:{},...f?{negotiatedFrom:f}:{},...u?{eventLocation:u}:{}}});H(`/messages?conversationId=${Y.conversation.conversationId}`)}catch{O({title:"Failed to send request",variant:"destructive"})}};return e.jsx(K,{open:z,onOpenChange:s=>!s&&P(),children:e.jsxs(X,{className:"sm:max-w-lg",children:[e.jsx(Z,{className:"pb-1",children:e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-brand/10 shrink-0",children:e.jsx(_,{className:"h-4.5 w-4.5 text-brand"})}),e.jsxs("div",{children:[e.jsx(G,{className:"text-base",children:"Request a Custom Quote"}),e.jsx(ee,{className:"mt-0.5 text-xs text-muted-foreground",children:"Describe what you need and start a conversation with the host."})]})]})}),e.jsxs("div",{className:"space-y-5 py-1",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Your Request"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"cqr-title",children:"What do you need?"}),e.jsx(A,{id:"cqr-title",placeholder:"e.g. Full event coordination for 80 guests",maxLength:200,value:d,onChange:s=>C(s.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(r,{htmlFor:"cqr-description",children:["Details"," ",e.jsx("span",{className:"text-muted-foreground text-xs font-normal",children:"(optional)"})]}),e.jsx(te,{id:"cqr-description",placeholder:"Special requirements, theme, setup preferences…",maxLength:2e3,rows:3,value:m,onChange:s=>b(s.target.value)})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Event Details"," ",e.jsx("span",{className:"normal-case font-normal",children:"(optional)"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"cqr-event-date",children:"Event date"}),e.jsx(ne,{id:"cqr-event-date",value:n,onChange:D,placeholder:"Select date"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ie,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(r,{htmlFor:"cqr-guests",children:"Guests"})]}),e.jsx(A,{id:"cqr-guests",type:"number",min:1,placeholder:"50",value:T,onChange:s=>M(s.target.value)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"cqr-start-time",children:"Start time"}),e.jsx(Q,{value:o,onChange:L,placeholder:"Add time"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"cqr-end-time",children:"End time"}),e.jsx(Q,{value:h,onChange:$,placeholder:"Add time",minTime:o||void 0})]})]}),S&&e.jsx(oe,{label:"Where will the event take place?",eventLocation:p,onEventLocationChange:F,inOverlay:!0})]}),e.jsx("p",{className:"text-xs text-muted-foreground bg-muted/50 rounded-lg px-3 py-2.5",children:"Your request starts a conversation with the host, who will review your details and send you a custom quote."})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(I,{variant:"outline",size:"sm",className:"flex-1",onClick:P,children:"Cancel"}),e.jsx(I,{size:"sm",className:"flex-1",onClick:V,disabled:!E||x.isPending,children:x.isPending?"Sending…":"Send Request"})]})]})})}export{je as C};