1import{d as K,I as X,j as F,o as i,c as n,y as o,W as C,N as c,a as _,M as h,F as b,P as w,Q as u,J as E,ae as N,a3 as Z,an as ee,ag as L,m as te,V as T,b as x,r as se}from"./vue-vendor-D0krlAb0.js";import{a as le}from"./inertia-vendor-B1UleJax.js";import{a as ae}from"./axios-vendor-D8QQWGbA.js";import{u as re}from"./vue-i18n-D1druVO5.js";import{c as v,T as q,d as y,q as oe,f as ie}from"./app-BfyP88rG.js";import{_ as ne}from"./Checkbox-DKe_Came.js";import{ar as ue,aY as de,be as me}from"./vendor-By_xewFp.js";import"./echo-vendor-BBfRIm2m.js";import"./lodash-vendor-C9X7AA5U.js";import"./tel-input-vendor-Dsa4Ey81.js";import"./stripe-vendor-CPICCz1r.js";import"./pinia-vendor-BDcgz45G.js";const ce={key:0,class:"rounded-lg bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:bg-rose-900/30 dark:text-rose-200"},pe={key:1,class:"rounded-lg bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:bg-rose-900/30 dark:text-rose-200"},_e={key:0},he={key:0,class:"mt-1 text-xs text-slate-500"},ge={key:1},fe={key:0,class:"mt-1 text-xs text-slate-500"},be={key:2},xe={key:0,class:"mt-1 text-xs text-slate-500"},ve={key:3},ye=["placeholder","required"],ke={key:0,class:"mt-1 text-xs text-slate-500"},we={key:4},qe={key:0,class:"mt-1 text-xs text-slate-500"},$e=["onClick"],Ve={key:5},Ce=["id","onUpdate:modelValue","placeholder","minlength","maxlength","required"],Ue=["id","onUpdate:modelValue","required"],Ae={value:""},Ee=["value"],Me={key:3,class:"relative mt-1","data-choice-field":""},Se=["id","aria-expanded","onClick"],je=["aria-label","onClick"],ze={key:0,class:"px-1 text-sm text-slate-400"},Oe=["aria-label"],Pe=["aria-selected","onClick"],Be={key:4,class:"mt-1 flex items-center gap-2 text-sm text-slate-700 dark:text-slate-200"},Fe={class:"inline-flex shrink-0 items-center"},Ne={key:5,class:"mt-1 text-xs text-slate-500"},Le={class:"flex flex-wrap items-center gap-2"},Ze={__name:"Form",props:{slot:{type:Object,required:!0},timezone:{type:String,required:!0},link:{type:Object,required:!0},prefill:{type:Object,default:()=>({name:"",email:"",phone:""})},submitUrl:{type:String,required:!0},previewMode:{type:Boolean,default:!1},submitVia:{type:String,default:"inertia",validator:U=>["inertia","axios"].includes(U)}},emits:["reselect","would-submit","booked"],setup(U,{emit:D}){const d=U,M=D,{t:S}=re(),$=x(()=>d.link.questions??[]),I=x(()=>d.link.ask_phone!==!1),W=x(()=>d.link.ask_notes!==!1),Y=x(()=>d.link.ask_guests!==!1),k=(s,r)=>{var l;const e=((l=d.link.builtin_question_settings)==null?void 0:l[s])??{};return{placeholder:e.placeholder||S(r),help_text:e.help_text??"",required:!!e.required}},m=x(()=>({name:k("name","Jane Doe"),email:k("email","[email protected]"),phone:k("phone","+1 234 567 8900"),notes:k("notes","Anything you'd like to share before the meeting?"),guests:k("guests","[email protected]")})),j=s=>s.field_type==="checkbox"?!1:s.field_type==="multiple_choice"?[]:"",J=()=>Object.fromEntries($.value.map(s=>[s.id,j(s)])),V=s=>{const r=t.custom_answers[s.id];return Array.isArray(r)?r:r?[r]:[]},z=(s,r)=>V(s).includes(r),g=se(null),Q=s=>{g.value=g.value===s.id?null:s.id},O=s=>{var r,e;(e=(r=s.target).closest)!=null&&e.call(r,"[data-choice-field]")||(g.value=null)},P=s=>{s.key==="Escape"&&(g.value=null)};K(()=>{document.addEventListener("click",O),document.addEventListener("keydown",P)}),X(()=>{document.removeEventListener("click",O),document.removeEventListener("keydown",P)});const B=(s,r)=>{const e=V(s);t.custom_answers[s.id]=e.includes(r)?e.filter(l=>l!==r):[...e,r]},R=x(()=>{var s;return(s=d.link.question_order)!=null&&s.length?d.link.question_order:["builtin:name","builtin:email","builtin:phone","builtin:notes","builtin:guests",...$.value.map(r=>`custom:${r.id}`)]}),a=s=>{if(!s.startsWith("custom:"))return null;const r=s.slice(7);return $.value.find(e=>String(e.id)===r)??null},t=le({starts_at:d.slot.start,ends_at:d.slot.end,timezone:d.timezone,guest_name:d.prefill.name??"",guest_email:d.prefill.email??"",guest_phone:d.prefill.phone??"",notes:"",additional_guest_emails:[],custom_answers:J()});F($,s=>{const r={};for(const e of s){const l=t.custom_answers[e.id],p=j(e),f=Array.isArray(p)?Array.isArray(l):typeof l==typeof p;
1r[e.id]=l!==void 0&&f?l:p}t.custom_answers=r,t.defaults({...t.data(),custom_answers:{...r}})},{deep:!0}),F(()=>({...t.data(),custom_answers:{...t.custom_answers}}),()=>{Object.keys(t.errors).length&&t.clearErrors()},{deep:!0});const G=()=>{if(d.previewMode){M("would-submit",{guest_name:t.guest_name,guest_email:t.guest_email,additional_guest_emails:t.additional_guest_emails.filter(r=>r.trim()!=="")});return}const s={...t.data(),starts_at:d.slot.start,ends_at:d.slot.end,timezone:d.timezone,additional_guest_emails:t.additional_guest_emails.filter(r=>r.trim()!=="")};if(d.submitVia==="axios"){H(s);return}t.transform(()=>s).post(d.submitUrl,{preserveScroll:!0})},H=async s=>{var r,e;t.processing=!0,t.clearErrors();try{const{data:l}=await ae.post(d.submitUrl,s);M("booked",l.booking)}catch(l){const p=(e=(r=l==null?void 0:l.response)==null?void 0:r.data)==null?void 0:e.errors;p?t.setError(Object.fromEntries(Object.entries(p).map(([f,A])=>[f,Array.isArray(A)?A[0]:A]))):t.setError("slot",S("We could not create the booking. Please try again."))}finally{t.processing=!1}};return(s,r)=>(i(),n("form",{class:"space-y-4",onSubmit:L(G,["prevent"])},[o(t).errors.slot?(i(),n("div",ce,[C(c(o(t).errors.slot)+" ",1),_("button",{type:"button",class:"ml-1 font-semibold underline",onClick:r[0]||(r[0]=e=>s.$emit("reselect"))},c(s.$t("Pick another time")),1)])):h("",!0),o(t).errors.timezone?(i(),n("div",pe,c(o(t).errors.timezone),1)):h("",!0),(i(!0),n(b,null,w(R.value,e=>(i(),n(b,{key:e},[e==="builtin:name"?(i(),n("div",_e,[u(v,{for:"guest_name",value:s.$t("Your name"),required:""},null,8,["value"]),u(q,{id:"guest_name",modelValue:o(t).guest_name,"onUpdate:modelValue":r[1]||(r[1]=l=>o(t).guest_name=l),type:"text",class:"mt-1 block w-full",placeholder:m.value.name.placeholder,required:""},null,8,["modelValue","placeholder"]),m.value.name.help_text?(i(),n("p",he,c(m.value.name.help_text),1)):h("",!0),u(y,{message:o(t).errors.guest_name,class:"mt-1"},null,8,["message"])])):e==="builtin:email"?(i(),n("div",ge,[u(v,{for:"guest_email",value:s.$t("Your email"),required:""},null,8,["value"]),u(q,{id:"guest_email",modelValue:o(t).guest_email,"onUpdate:modelValue":r[2]||(r[2]=l=>o(t).guest_email=l),type:"email",class:"mt-1 block w-full",placeholder:m.value.email.placeholder,required:""},null,8,["modelValue","placeholder"]),m.value.email.help_text?(i(),n("p",fe,c(m.value.email.help_text),1)):h("",!0),u(y,{message:o(t).errors.guest_email,class:"mt-1"},null,8,["message"])])):e==="builtin:phone"&&I.value?(i(),n("div",be,[u(v,{for:"guest_phone",value:s.$t("Phone number"),required:m.value.phone.required},null,8,["value","required"]),u(q,{id:"guest_phone",modelValue:o(t).guest_phone,"onUpdate:modelValue":r[3]||(r[3]=l=>o(t).guest_phone=l),type:"tel",class:"mt-1 block w-full",placeholder:m.value.phone.placeholder,required:m.value.phone.required},null,8,["modelValue","placeholder","required"]),m.value.phone.help_text?(i(),n("p",xe,c(m.value.phone.help_text),1)):h("",!0),u(y,{message:o(t).errors.guest_phone,class:"mt-1"},null,8,["message"])])):e==="builtin:notes"&&W.value?(i(),n("div",ve,[u(v,{for:"notes",value:s.$t("Anything we should know?"),required:m.value.notes.required},null,8,["value","required"]),E(_("textarea",{id:"notes","onUpdate:modelValue":r[4]||(r[4]=l=>o(t).notes=l),rows:"3",class:"mt-1 block w-full rounded-md border-slate-300 text-sm shadow-sm focus:border-sky-400 focus:ring focus:ring-sky-200/50 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-100",placeholder:m.value.notes.placeholder,required:m.value.notes.required},null,8,ye),[[N,o(t).notes]]),m.value.notes.help_text?(i(),n("p",ke,c(m.value.notes.help_text),1)):h("",!0),u(y,{message:o(t).errors.notes,class:"mt-1"},null,8,["message"])])):e==="builtin:guests"&&Y.value?(i(),n("div",we,[u(v,{value:s.$t("Additional guests"),required:m.value.guests.required},null,8,["value","required"]),m.value.guests.help_text?(i(),n("p",qe,c(m.value.guests.help_text),1)):h("",!0),(i(!0),n(b,null,w(o(t).additional_guest_emails,(l,p)=>(i(),n("div",{key:p,class:"mt-1 flex items-center gap-2"},[u(q,{modelValue:o(t).additional_guest_emails[p],"onUpdate:modelValue":f=>o(t).additional_guest_emails[p]=f,type:"email",class:"block w-full",placeholder:m.value.guests.placeholder},null,8,["modelValue","onUpdate:modelValue","placeholder"]),_("button",{type:"button",class:"text-xs font-semibold text-rose-600 hover:underline",onClick:f=>o(t).additional_guest_emails.splice(p,1)},c(s.$t("Remove")),9,$e)]))),128)),u(y,{message:o(t).errors.additional_guest_emails,class:"mt-1"},null,8,["message"]),_("button",{type:"button",class:"mt-1 text-xs font-semibold text-sky-600 hover:underline",onClick:r[5]||
1(r[5]=l=>o(t).additional_guest_emails.push(""))},c(s.$t("Add another guest")),1)])):a(e)?(i(),n("div",Ve,[u(v,{for:`q-${a(e).id}`,value:a(e).label,required:a(e).is_required},null,8,["for","value","required"]),a(e).field_type==="text"?(i(),Z(q,{key:0,id:`q-${a(e).id}`,modelValue:o(t).custom_answers[a(e).id],"onUpdate:modelValue":l=>o(t).custom_answers[a(e).id]=l,type:"text",class:"mt-1 block w-full",placeholder:a(e).placeholder??"",required:a(e).is_required},null,8,["id","modelValue","onUpdate:modelValue","placeholder","required"])):a(e).field_type==="textarea"?E((i(),n("textarea",{key:1,id:`q-${a(e).id}`,"onUpdate:modelValue":l=>o(t).custom_answers[a(e).id]=l,rows:"3",class:"mt-1 block w-full rounded-md border-slate-300 text-sm shadow-sm focus:border-sky-400 focus:ring focus:ring-sky-200/50 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-100",placeholder:a(e).placeholder??"",minlength:a(e).min_length??void 0,maxlength:a(e).max_length??void 0,required:a(e).is_required},null,8,Ce)),[[N,o(t).custom_answers[a(e).id]]]):a(e).field_type==="select"?E((i(),n("select",{key:2,id:`q-${a(e).id}`,"onUpdate:modelValue":l=>o(t).custom_answers[a(e).id]=l,class:"mt-1 block w-full rounded-md border-slate-300 text-sm shadow-sm focus:border-sky-400 focus:ring focus:ring-sky-200/50 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-100",required:a(e).is_required},[_("option",Ae,c(s.$t("Please choose...")),1),(i(!0),n(b,null,w(a(e).options,l=>(i(),n("option",{key:l,value:l},c(l),9,Ee))),128))],8,Ue)),[[ee,o(t).custom_answers[a(e).id]]]):a(e).field_type==="multiple_choice"?(i(),n("div",Me,[_("button",{id:`q-${a(e).id}`,type:"button",class:"flex min-h-[2.5rem] w-full flex-wrap items-center gap-1.5 rounded-md border border-slate-300 bg-white px-2 py-1.5 text-left transition focus:border-sky-400 focus:outline-none focus:ring focus:ring-sky-200/50 dark:border-slate-600 dark:bg-slate-800","aria-haspopup":"listbox","aria-expanded":g.value===a(e).id,onClick:l=>Q(a(e))},[(i(!0),n(b,null,w(V(a(e)),l=>(i(),n("span",{key:l,class:"inline-flex items-center gap-1 rounded bg-slate-100 px-2 py-0.5 text-xs font-medium text-slate-700 dark:bg-slate-700 dark:text-slate-200"},[C(c(l)+" ",1),_("span",{class:"cursor-pointer text-slate-400 transition hover:text-slate-700 dark:hover:text-slate-100",role:"button","aria-label":s.$t("Remove option"),onClick:L(p=>B(a(e),l),["stop"])},[u(o(ue),{class:"h-3 w-3"})],8,je)]))),128)),V(a(e)).length===0?(i(),n("span",ze,c(a(e).placeholder||s.$t("Please choose...")),1)):h("",!0),u(o(de),{class:"ml-auto h-4 w-4 shrink-0 text-slate-400"})],8,Se),g.value===a(e).id?(i(),n("div",{key:0,class:"absolute z-20 mt-1 max-h-56 w-full overflow-y-auto rounded-md border border-slate-200 bg-white shadow-lg dark:border-slate-700 dark:bg-slate-800",role:"listbox","aria-label":a(e).label},[(i(!0),n(b,null,w(a(e).options,l=>(i(),n("button",{key:l,type:"button",role:"option",class:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm text-slate-700 transition hover:bg-slate-50 dark:text-slate-200 dark:hover:bg-slate-700","aria-selected":z(a(e),l),onClick:p=>B(a(e),l)},[u(o(me),{class:te(["h-4 w-4 shrink-0",z(a(e),l)?"text-slate-700 dark:text-slate-200":"invisible"])},null,8,["class"]),_("span",null,c(l),1)],8,Pe))),128))],8,Oe)):h("",!0)])):(i(),n("label",Be,[_("span",Fe,[u(ne,{checked:o(t).custom_answers[a(e).id],"onUpdate:checked":l=>o(t).custom_answers[a(e).id]=l},null,8,["checked","onUpdate:checked"])]),_("span",null,c(a(e).help_text||a(e).label),1)])),a(e).help_text&&a(e).field_type!=="checkbox"?(i(),n("p",Ne,c(a(e).help_text),1)):h("",!0),u(y,{message:o(t).errors[`custom_answers.${a(e).id}`],class:"mt-1"},null,8,["message"])])):h("",!0)],64))),128)),_("div",Le,[u(oe,{type:"submit",disabled:o(t).processing},{default:T(()=>[C(c(o(t).processing?s.$t("Submitting..."):s.$t("Confirm booking")),1)]),_:1},8,["disabled"]),u(ie,{type:"button",onClick:r[6]||(r[6]=e=>s.$emit("reselect"))},{default:T(()=>[C(c(s.$t("Change time")),1)]),_:1})])],32))}};export{Ze 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.