1import{r as o,j as e,a as L}from"./react-DlBquRhq.js";import{u as w,s as N,C as P,j as D,a as A,P as F,e as R,S as O,f as B,t as Q,b as E}from"./index-CVeKy3HG.js";import{u as M}from"./useHotelTheme-Bem151vp.js";import{a as $}from"./HiddenHeading-CCMg9Xf7.js";import{m as H}from"./animation-B0WpSdC-.js";import"./supabase-CpRTRdvQ.js";function J(s){return"tel:"+s.replace(/[^\d+]/g,"")}function z(){const s=w(),[t,l]=o.useState(null);return o.useEffect(()=>{let c=!1;return N.from("site_settings").select("value").eq("key","footer_contact").maybeSingle().then(({data:d})=>{if(c)return;const r=d?.value??null;r&&l({email:"",phone:"",address:"",...r})}),()=>{c=!0}},[]),!t||!(t.email||t.phone||t.address)?null:e.jsxs("section",{className:"contact-block",children:[e.jsx("h2",{className:"t-condensed t-uppercase faq-page-title",children:s("faq.contact.heading")}),e.jsxs("div",{className:"contact-block__details",children:[t.email&&e.jsx("a",{href:`mailto:${t.email}`,className:"t-body t-uppercase t-condensed",children:t.email}),t.phone&&e.jsx("a",{href:J(t.phone),className:"t-body t-uppercase t-condensed",children:t.phone}),t.address&&e.jsx("p",{className:"t-body t-uppercase t-condensed contact-block__address",children:t.address})]})]})}function G({hotelSlug:s}){const t=w(),[l,c]=o.useState(!1),[d,r]=o.useState("idle"),[x,u]=o.useState(""),p=o.useRef(null),q=o.useRef(null);if(o.useEffect(()=>{let m=!1;return fetch(`/api/contact/available?hotel=${encodeURIComponent(s)}`).then(a=>a.ok?a.json():{available:!1}).then(a=>{m||c(!!a.available)}).catch(()=>{}),()=>{m=!0}},[s]),!l)return null;function y(){r("idle"),u(""),p.current?.showModal()}function g(){p.current?.close()}function _(m){m.target===p.current&&g()}async function j(m){if(m.preventDefault(),d==="sending")return;r("sending"),u("");const a=new FormData(m.currentTarget);try{const n=await fetch("/api/contact",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({hotel:s,name:a.get("name"),email:a.get("email"),subject:a.get("subject"),message:a.get("message"),company:a.get("company")})});if(!n.ok)throw new Error(String(n.status));r("sent"),P("contact"),q.current?.reset()}catch{r("error"),u(t("faq.contact.form.error"))}}return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:y,className:"button --dark --hover t-body t-uppercase t-condensed contact-open",children:t("faq.contact.form.heading")}),e.jsx("dialog",{ref:p,className:"contact-dialog",onClick:_,"aria-labelledby":"contact-dialog-title",children:e.jsxs("div",{className:"contact-dialog__panel",children:[e.jsxs("div",{className:"contact-dialog__head",children:[e.jsx("h2",{id:"contact-dialog-title",className:"t-medium t-uppercase t-condensed t-500",children:t("faq.contact.form.heading")}),e.jsx("button",{type:"button",onClick:g,className:"contact-dialog__close t-medium t-condensed","aria-label":t("common.close"),children:"Ã"})]}),d==="sent"?e.jsxs("div",{className:"contact-dialog__done",children:[e.jsx("p",{className:"t-body t-uppercase t-condensed",role:"status",children:t("faq.contact.form.sent")}),e.jsx("button",{type:"button",onClick:g,className:"button --dark --hover t-body t-uppercase t-condensed",children:t("common.close")})]}):e.jsxs("form",{ref:q,onSubmit:j,className:"contact-form",noValidate:!0,children:[e.jsx("input",{type:"text",name:"company",tabIndex:-1,autoComplete:"off","aria-hidden":"true",className:"contact-form__trap"}),e.jsxs("div",{className:"contact-form__row",children:[e.jsx("label",{className:"t-xsmall t-uppercase t-condensed",htmlFor:"cf-name",children:t("faq.contact.form.name")}),e.jsx("input",{id:"cf-name",name:"name",required:!0,maxLength:120,autoComplete:"name",autoFocus:!0})]}),e.jsxs("div",{className:"contact-form__row",children:[e.jsx("label",{className:"t-xsmall t-uppercase t-condensed",htmlFor:"cf-email",children:t("faq.contact.form.email")}),e.jsx("input",{id:"cf-email",name:"email",type:"email",required:!0,maxLength:254,autoComplete:"email"})]}),e.jsxs("div",{className:"contact-form__row",children:[e.jsx("label",{className:"t-xsmall t-uppercase t-condensed",htmlFor:"cf-subject",children:t("faq.contact.form.subject")}),e.jsx("input",{id:"cf-subject",name:"subject",maxLength:200})]}),e.jsxs("div",{className:"contact-form__row",children:[e.jsx("label",{className:"t-xsmall t-uppercase t-condensed",htmlFor:"cf-message",children:t("faq.contact.form.message")}),e.jsx("textarea",{id:"cf-message",name:"message",required:!0,rows:5,maxLength:4e3})]}),e.jsx("button",{type:"submit",disabled:d==="sending",className:"button --dark --hover t-body t-uppercase t-condensed contact-form__submit",children:t(d==="sending"?"faq.contact.form.sending":"faq.contact.form.send")}),e.jsx("p",{className:"t-xsmall t-uppercase t-condensed contact-form__error",role:"alert","aria-live":"polite","data-shown":x?"true":"false",children:x})]})]})})]})}function U(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function ee(){const{hotel:s}=L(),{data:t}=D(s),l=t,c=w(),{locale:d}=A();M(l?.color,l?.textColor);
1const[r,x]=o.useState([]),[u,p]=o.useState(null),[q,y]=o.useState(null),[g,_]=o.useState(!1);o.useEffect(()=>{if(!s)return;let a=!1;async function n(){const[{data:f},b]=await Promise.all([N.from("hotels").select("id, faq_page_title").eq("slug",s).maybeSingle(),B(d,["hotels","faq_topics","faq_questions"])]);if(!f||a)return;const k=Q(f,"hotels",b);p(k.faq_page_title||"");const{data:C}=await N.from("faq_topics").select("*").eq("hotel_id",k.id).eq("published",!0).order("sort_order");if(!C||a)return;const S=E(C,"faq_topics",b),T=S.map(i=>i.id);if(T.length===0){x([]),_(!0);return}const{data:I}=await N.from("faq_questions").select("*").in("topic_id",T).eq("published",!0).order("sort_order");if(a)return;const v=new Map;E(I??[],"faq_questions",b).forEach(i=>{const h=v.get(i.topic_id)??[];h.push(i),v.set(i.topic_id,h)}),x(S.map(i=>({id:i.id,slug:U(i.name),name:i.name,questions:(v.get(i.id)??[]).map(h=>({id:h.id,question:h.question,answer:h.answer}))})).filter(i=>i.questions.length>0)),_(!0)}return n(),()=>{a=!0}},[s,d]);const j=u===null?"":u||c("faq.title.default");if(!l)return e.jsx(H.main,{id:"faq-page",initial:R(),animate:{opacity:1},exit:{opacity:0},transition:F,style:{minHeight:"100dvh"}});const m={"@context":"https://schema.org","@type":"FAQPage",mainEntity:r.flatMap(a=>a.questions).map(a=>({"@type":"Question",name:a.question,acceptedAnswer:{"@type":"Answer",text:a.answer}}))};return e.jsxs(e.Fragment,{children:[e.jsx(O,{title:c("faq.seo.title",{vars:{title:j||c("faq.seo.titleFallback"),hotelName:l.name}}),description:c("faq.seo.description",{vars:{title:j||c("faq.seo.descriptionFallback"),hotelName:l.name,city:l.city}}),schemaJsonLd:m,authoredTitle:!!u,authoredDescription:!!u}),e.jsxs(H.main,{id:"faq-page",initial:R(),animate:{opacity:1},exit:{opacity:0},transition:F,style:{minHeight:"100dvh"},children:[e.jsx("div",{className:"page-header stop",style:{background:l.color}}),e.jsxs("article",{id:"faq_p--container",className:"p-relative pad bg-white","data-logo-dark":!0,children:[e.jsx(z,{}),s&&e.jsx(G,{hotelSlug:s}),e.jsx("h1",{className:"t-condensed t-uppercase faq-page-title",children:j||c("faq.title.default")}),e.jsx($,{children:c("faq.heading.byTopic")}),!g&&e.jsx("div",{className:"faq-shimmer","aria-hidden":"true",children:[0,1].map(a=>e.jsxs("div",{className:"faq_p-topic faq-shimmer-block",children:[e.jsx("div",{className:"faq-shimmer-line faq-shimmer-line--title"}),[0,1,2].map(n=>e.jsx("div",{className:"faq-shimmer-line faq-shimmer-line--row"},n))]},a))}),r.map(a=>e.jsxs("dl",{className:"faq_p-topic",id:a.slug,"data-status":"active",children:[e.jsx("dt",{className:"faq_p-topic-title",children:e.jsx("h3",{className:"t-uppercase t-condensed faq-topic-title",children:a.name})}),a.questions.map(n=>{const f=q===n.id;return e.jsxs("dd",{className:"faq_p-topic-faq t-body","data-status":f?"open":"close",children:[e.jsxs("button",{type:"button",onClick:()=>y(b=>b===n.id?null:n.id),className:"faq_p-question flex j-between","aria-expanded":f,children:[e.jsx("h4",{className:"t-body t-uppercase t-condensed",children:n.question}),e.jsx("p",{className:"t-body t-uppercase t-condensed",children:f?"â":"+"})]}),e.jsx("div",{className:"faq_p-answer stop",children:e.jsx("p",{className:"t-body t-uppercase t-condensed",children:n.answer})})]},n.id)})]},a.id))]})]})]})}export{ee 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.