"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6697],{43380:function(e,t){t.Z={src:"/_next/static/media/calendar.98fb210d.svg",height:16,width:16,blurWidth:0,blurHeight:0}},26697:function(e,t,l){l.d(t,{hG:function(){return h},Uk:function(){return f},IT:function(){return g},Gl:function(){return C},xs:function(){return k},oH:function(){return j.Z},Bg:function(){return M},zR:function(){return L},lq:function(){return G}});var r=l(85893),a=l(25675),n=l.n(a),s=l(43380),i=l(30381),o=l.n(i),d=l(19216),c=l(13282),u=l(67294),m=l(90512),x=l(55678),h=e=>{let[t,l]=(0,u.useState)(!1),a=(0,u.useRef)(null),[i,h]=(0,u.useState)(!1);(0,u.useEffect)(()=>{b({start:e.dateFrom,end:e.dateTo})},[e.minStay]),(0,u.useEffect)(()=>(document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}),[]);let p=e=>{a.current&&!a.current.contains(e.target)&&h(!1)};function f(){return(0,c.Lg)((0,c.iT)()).add({days:4})}function g(){return(0,c.Lg)((0,c.iT)()).add({days:o()().hour()>=16?2:1})}function b(t){o()(t.end.toDate((0,c.iT)())).diff(o()(t.start.toDate((0,c.iT)())),"days")>=(e.minStay||2)?(l(()=>!1),e.onChange(t,!1)):(l(()=>!0),e.onChange(t,!0),e.minStay?x.Am.info("Selecione ao menos ".concat(e.minStay," noites")):x.Am.info("Selecione ao menos 2 noites."))}return(0,r.jsxs)("div",{className:"relative w-full group flex justify-center flex-col items-center",ref:a,children:[!e.customSelector&&(0,r.jsxs)("div",{className:(0,m.Z)("bg-white border-1 hover:bg-neutral-light-3 gap-4 rounded-full p-3 flex w-full justify-between relative cursor-pointer",t?"border-error-light-9":"border-neutral-light-6"),onClick:()=>h(!i),children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 border-neutral-light-6 w-full justify-center",children:[(0,r.jsx)(n(),{alt:"",src:s.Z}),(0,r.jsx)("p",{className:"text-[14px] medium",children:"Entrada"}),(0,r.jsx)("p",{className:(0,m.Z)("bold text-[14px]",t?"text-error-light-9":"text-neutral-light-12"),children:o()(e.dateFrom.toDate((0,c.iT)())).format("DD/MM/YYYY")})]}),(0,r.jsx)("div",{className:"h-[20px] w-[3px] bg-neutral-light-6"}),(0,r.jsxs)("div",{className:"flex items-center gap-1 w-full justify-center",children:[(0,r.jsx)(n(),{alt:"",src:s.Z}),(0,r.jsx)("p",{className:"text-[14px] medium",children:"Sa\xedda"}),(0,r.jsx)("p",{className:(0,m.Z)("bold text-[14px]",t?"text-error-light-9":"text-neutral-light-12"),children:o()(e.dateTo.toDate((0,c.iT)())).format("DD/MM/YYYY")})]})]}),e.customSelector&&(0,r.jsx)("div",{onClick:()=>h(!i),children:e.customSelector({start:e.dateFrom,end:e.dateTo})}),i&&(0,r.jsxs)("div",{className:(0,m.Z)("absolute z-40",!e.disabled&&"flex",e.positionTop?"right-0 bottom-[100%]":"top-[45px]"),onBlur:e.onBlur,children:[(0,r.jsx)(d.o,{isDateUnavailable:e.isDateUnavailable,value:{start:e.dateFrom,end:e.dateTo},onChange:b,visibleMonths:g().day>=27?2:1,maxValue:f(),minValue:g(),errorMessage:"Im\xf3vel indispon\xedvel para o dia selecionado",className:"max-md:hidden"}),(0,r.jsx)(d.o,{isDateUnavailable:e.isDateUnavailable,value:{start:e.dateFrom,end:e.dateTo},onChange:b,visibleMonths:1,maxValue:f(),minValue:g(),errorMessage:"Im\xf3vel indispon\xedvel para o dia selecionado",className:"md:hidden"})]})]})},p=l(65890),f=e=>{let[t,l]=(0,u.useState)(!1);return(0,r.jsxs)("div",{className:"relative border-1 rounded-[14px] w-full h-[45px] p-2 flex items-center justify-between group hover:cursor-pointer",onClick:function(){navigator.clipboard.writeText(e.textToCopy).then(()=>{l(!0),setTimeout(()=>{l(!1)},3e3)})},children:[e.children,(0,r.jsx)("div",{className:"border-1 p-2 w-fit h-fit rounded-[14px] group-hover:bg-neutral-light-4 group-active:scale-95",children:(0,r.jsx)(p.EZF,{})}),t&&(0,r.jsx)("div",{className:"absolute right-0 top-[-20px] bg-neutral-light-12 text-white p-1 rounded-[14px]",children:e.textMessage||"Copiado!"})]})},g=e=>{let{targetDate:t,finishedComponent:l}=e,a=()=>{let e=+new Date(t)-+new Date,l={};return e>0&&(l={days:Math.floor(e/864e5),hours:Math.floor(e/36e5%24),minutes:Math.floor(e/1e3/60%60),segundos:Math.floor(e/1e3%60)}),l},[n,s]=(0,u.useState)(a());(0,u.useEffect)(()=>{let e=setTimeout(()=>{s(a())},1e3);return()=>clearTimeout(e)});let i=[];return Object.keys(n).forEach(e=>{n[e]&&i.push((0,r.jsxs)("span",{className:"w-full text-nowrap text-center text-[14px]",children:[n.segundos," segundos"]},e))}),(0,r.jsx)("div",{className:"w-full flex items-center justify-center",children:(0,r.jsx)("span",{className:"text-nowrap text-center",children:i.length?i:l})})},b=l(87362),v=l(78773),j=l(7442),w=l(87536),N=l(19222);let y=e=>{e.includes("-");let t=(0,N.Ch)(e);return(0,N.Qo)(t)};var C=e=>{let t;let{control:l,formState:{errors:a},setValue:n}=(0,w.cI)();(0,u.useEffect)(()=>{n("numberOfGuests",e.currentNumberSelected)},[]);let s=(0,u.useCallback)(l=>{clearTimeout(t),t=setTimeout(async()=>{Number(l)>e.maxGuests?(n("numberOfGuests",e.maxGuests),e.onChange(e.maxGuests)):0>=Number(l)?(n("numberOfGuests",1),e.onChange(1)):(n("numberOfGuests",l),e.onChange(Number(l)))},500)},[]);return(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-neutral-light-12 medium text-[18px]",children:"Adicione o n\xfamero de h\xf3spedes"}),(0,r.jsxs)("div",{className:"flex border-[1.5px] border-primary justify-between p-2 rounded-[12px] h-[52px]",children:[(0,r.jsx)("div",{className:"w-1/3 flex justify-center items-center relative",children:(0,r.jsx)(j.Z,{control:l,errors:a,name:"numberOfGuests",maskFunction:y,onChangeText:e=>s(Number(e)),overwriteClassName:"w-full border-0 h-[44px] rounded-[32px] rounded-full flex justify-center items-center mt-4",contentClassName:"bg-transparent ring-0 w-full flex justify-center items-center border-0",inputClassname:"text-[18px] text-neutral-light-12 w-full ring-0 border-0 text-center"})}),(0,r.jsxs)("div",{className:"w-full flex px-4 border-l-1 justify-end pl-20 items-center",children:[(0,r.jsx)(b.A,{className:"rounded-r-[0px] border-r-0 w-full rounded-l-[8px] h-[36px] border-[1px]",variant:"bordered",isDisabled:1===e.currentNumberSelected,onClick:()=>{e.currentNumberSelected>1&&s(e.currentNumberSelected-1)},children:(0,r.jsx)(v.iFH,{})}),(0,r.jsx)(b.A,{className:"rounded-l-[0px] w-full rounded-r-[8px] h-[36px] border-[1px] border-l-0",variant:"bordered",isDisabled:e.currentNumberSelected===e.maxGuests,onClick:()=>{e.currentNumberSelectednew Promise((t,l)=>{let r=new Image;r.addEventListener("load",()=>t(r)),r.addEventListener("error",e=>l(e)),r.setAttribute("crossOrigin","anonymous"),r.src=e}),E=async(e,t)=>{let l=await D(e),r=document.createElement("canvas"),a=r.getContext("2d");if(!a)throw Error("No 2d context");let n=Math.max(l.width,l.height)/2*Math.sqrt(2)*2;r.width=n,r.height=n,a.translate(n/2,n/2),a.translate(-n/2,-n/2),a.drawImage(l,n/2-.5*l.width,n/2-.5*l.height);let s=a.getImageData(0,0,n,n);return r.width=t.width,r.height=t.height,a.putImageData(s,Math.round(0-n/2+.5*l.width-t.x),Math.round(0-n/2+.5*l.height-t.y)),r.toDataURL("image/png")};var k=e=>{let{onSaveImage:t}=e,[l,a]=(0,u.useState)({x:0,y:0}),[n,s]=(0,u.useState)(1),i=(0,u.useRef)(null),[o,d]=(0,u.useState)(""),[c,m]=(0,u.useState)(null),x=(0,u.useCallback)((e,t)=>{m(t)},[]),h=(0,u.useCallback)(e=>{if(e.target.files&&e.target.files.length>0){let t=new FileReader;t.addEventListener("load",()=>{var e;return d((null===(e=t.result)||void 0===e?void 0:e.toString())||"")}),t.readAsDataURL(e.target.files[0])}},[]),p=(0,u.useCallback)(e=>{if(e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files.length>0){let t=new FileReader;t.addEventListener("load",()=>{var e;return d((null===(e=t.result)||void 0===e?void 0:e.toString())||"")}),t.readAsDataURL(e.dataTransfer.files[0])}},[]),f=(0,u.useCallback)(async()=>{try{let e=await E(o,c),l=await fetch(e),r=await l.blob(),a=new File([r],"cropped_image.png",{type:"image/png"});t(a)}catch(e){console.error(e)}},[o,c,t]);return(0,r.jsxs)("div",{className:"h-[400px] bg-white relative",onDragOver:e=>e.preventDefault(),onDrop:p,children:[(0,r.jsx)("div",{className:"h-[340px] w-full bg-white absolute top-0 left-0 bottom-0",children:o?(0,r.jsx)(S.ZP,{image:o,crop:l,zoom:n,aspect:1,onCropChange:a,onCropComplete:x,onZoomChange:s,maxZoom:10,cropShape:"round"}):(0,r.jsxs)("div",{className:"flex flex-col w-full h-full items-center justify-center",children:[(0,r.jsx)("p",{children:"Arraste e solte uma imagem."}),(0,r.jsx)("p",{children:"O tamanho m\xe1ximo permitido \xe9 de 1mb"})]})}),(0,r.jsxs)("div",{className:"flex justify-between gap-4 bg-white absolute bottom-0 left-0 w-full right-0",children:[(0,r.jsx)("input",{ref:i,className:"hidden",type:"file",accept:"image/png, image/jpeg",onChange:h}),(0,r.jsx)(b.A,{className:"semibold flex-grow",onPress:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.click()},children:"Selecionar imagem"}),(0,r.jsx)(b.A,{isDisabled:""===o,className:"semibold flex-grow bg-[#FF7B2E] disabled:bg-[#3d3d3d]",onPress:f,children:"Salvar altera\xe7\xf5es"})]})]})},T=l(93093),M=e=>{let{abstractGet:t}=(0,T.Z)(),[l,a]=(0,u.useState)(!1),n=(0,u.useRef)(null),[s,i]=(0,u.useState)();function o(t){let l=e.availableKeys.find(e=>e===t);l&&(i(()=>l),e.setSelectedKey(l))}(0,u.useEffect)(()=>{t("/collections").then(t=>{if(200===t.status){let t=e.availableKeys.find(t=>{var l;return t.collection_id===(null===(l=e.selectedKey)||void 0===l?void 0:l.collection_id)});t&&i(()=>t)}})},[e.availableKeys]),(0,u.useEffect)(()=>{let e=e=>{n.current&&!n.current.contains(e.target)&&a(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);let d=e=>(0,r.jsxs)("div",{className:"flex gap-2 cursor-pointer p-[12px] w-full select-none active:bg-neutral-dark-6",children:[e&&(0,r.jsx)("img",{alt:"",src:e.icon,className:"w-[48px] h-[48px] rounded-[4px]"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-[18px] bold",children:null==e?void 0:e.title}),(0,r.jsx)("p",{className:"",children:e.subtitle})]})]});return(0,r.jsxs)("div",{className:"relative w-full",ref:n,children:[(0,r.jsxs)("div",{className:"border-1 rounded-[8px] mb-[8px] hidden md:flex justify-between items-center active:bg-neutral-dark-6 overflow-hidden hover:bg-neutral-light-3 w-full",onClick:()=>a(!l),children:[(0,r.jsx)(d,{icon:null==s?void 0:s.collection_image,title:null==s?void 0:s.collection_name,subtitle:null==s?void 0:s.short_description}),(0,r.jsx)("p",{className:"medium text-primary-light-11 cursor-pointer select-none text-nowrap mr-2 max-sm:text-center",children:"Mudar Key"})]}),(0,r.jsx)("div",{className:"border-1 rounded-[8px] hidden max-sm:flex flex-col justify-between w-full border-y-2 my-4 overflow-y-auto max-h-[400px]",children:e.availableKeys.map((t,l)=>(0,r.jsx)("div",{className:(0,m.Z)(e.selectedKey===t&&"bg-neutral-dark-6 text-white",l!==e.availableKeys.length-1&&"border-b-1"),onClick:()=>{o(t),a(!1)},children:(0,r.jsx)(d,{icon:null==t?void 0:t.collection_image,title:null==t?void 0:t.collection_name,subtitle:null==t?void 0:t.short_description})},l))}),l&&(0,r.jsx)("div",{className:"flex flex-col absolute md:top-[90px] max-sm:bottom-[90px] z-[100] max-h-[300px] overflow-y-auto w-full border-1 rounded-[8px] bg-white",onBlur:()=>a(!1),tabIndex:0,children:e.availableKeys.map((t,l)=>(0,r.jsx)("div",{className:(0,m.Z)("hover:bg-neutral-light-3",l!==e.availableKeys.length-1&&"border-b-1"),onClick:()=>{o(t),a(!1)},children:(0,r.jsx)(d,{icon:null==t?void 0:t.collection_image,title:null==t?void 0:t.collection_name,subtitle:null==t?void 0:t.short_description})},l))})]})};l(25645);var Z=l(49559),F=l(47873),_=l(21974),I=l(20694),L=e=>(0,r.jsx)("div",{children:(0,r.jsx)(Z.R,{size:"lg",isOpen:e.isOpen,onClose:e.onClose,children:(0,r.jsx)(F.A,{className:"bg-white self-center h-[50vh]",children:()=>(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(_.I,{className:"border-t-[12px] border-[#FF7B2E]",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-4 p-4",children:[(0,r.jsx)(I.ZY,{onScan:t=>{t[0]&&e.onScan(t[0].rawValue)}}),e.resultError&&(0,r.jsx)("p",{className:"text-red-500",children:e.resultError})]})})})})})}),A=l(57395),G=e=>(0,r.jsxs)("div",{className:(0,m.Z)("flex flex-col text-[14px] relative",e.className,e.titleInsideComponent&&"pt-3 px-2"),children:[(0,r.jsx)("p",{className:(0,m.Z)(e.titleInsideComponent&&"pl-2 absolute top-0",e.titleClass),children:e.title}),(0,r.jsx)(w.Qr,{name:e.name,rules:e.validators,control:e.control,defaultValue:e.defaultValue||"",render:t=>{let{field:{onBlur:l,onChange:a,value:n,ref:s}}=t;return(0,r.jsx)(A.ZP,{placeholder:e.placeholder,styles:{control:()=>({border:e.titleInsideComponent?"":"1px solid gray",borderRadius:"18px",display:"flex",height:e.titleInsideComponent?"30px":"40px"}),option:(e,t)=>{let{isFocused:l}=t;return{backgroundColor:l?"#FF7B2E":"white",fontFamily:"sans-serif",padding:"8px"}}},options:e.options,onBlur:l,onChange:t=>{a(t),e.onChange&&e.onChange(t)},value:n,ref:s,maxMenuHeight:null==e?void 0:e.maxMenuHeight,isDisabled:e.disabled,isMulti:e.isMulti})}}),e.errors[e.name]&&(0,r.jsx)("span",{style:{fontSize:"12px",color:"#eb4034"},children:e.errors[e.name].message.toString()})]})}}]);