@mapfirst.ai/react 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -8
- package/dist/index.d.ts +1 -8
- package/dist/index.js +2 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import L from"react";import{MapFirstCore as ut}from"@mapfirst.ai/core";import{processApiFilters as tn,convertToApiFilters as rn}from"@mapfirst.ai/core";import{useCallback as ue,useState as rt}from"react";import ve from"react";import Le from"react";import{jsx as H,jsxs as X}from"react/jsx-runtime";var me=({className:e,style:t})=>X("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[H("circle",{cx:"11",cy:"11",r:"8"}),H("path",{d:"m21 21-4.35-4.35"})]}),ge=({className:e,style:t})=>X("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[H("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),H("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Q=({className:e,style:t})=>X("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[H("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),H("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),j=({className:e,style:t})=>H("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:H("polyline",{points:"9 18 15 12 9 6"})}),ye=({className:e,style:t,fill:p="none"})=>H("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:p,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:H("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})});import{jsx as fe}from"react/jsx-runtime";var we={position:"absolute",top:"-8px",right:"-8px",padding:"2px",borderRadius:"50%",backgroundColor:"white",border:"1px solid #03852e",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"},Ee={width:"17px",height:"17px"},D=({onClick:e,style:t})=>{let[p,n]=Le.useState(!1);return fe("button",{style:{...we,backgroundColor:p?"#e5e5e5":"white",...t},onClick:e,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),"aria-label":"Remove filter",children:fe(ge,{style:Ee})})};import{jsx as J,jsxs as Ie}from"react/jsx-runtime";var Me={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},ee=({label:e,icon:t,remove:p,style:n})=>Ie("div",{style:{...Me,...n},children:[t&&J("span",{style:{display:"flex",alignItems:"center"},children:t}),J("span",{style:{whiteSpace:"nowrap"},children:e}),J(D,{onClick:p})]});import{useState as Ae}from"react";import{useCallback as he,useState as Te}from"react";var Be={"smartFilter.typingPrompt":"Search for hotels, restaurants, or attractions...","smartFilter.nav.previous":"Previous filters","smartFilter.nav.next":"Next filters","smartFilter.toast.locationRequired":"Please select a location first","smartFilter.clearAll":"Clear all","smartFilter.minRating.suffix":"+","smartFilter.minRating.label":"{{value}}+","smartFilter.minRating.remove":"Remove rating filter","smartFilter.minRating.setTo":"Set rating to {{rating}}","smartFilter.priceRange.label":"Price Range","smartFilter.priceRange.remove":"Remove price filter","smartFilter.priceRange.edit":"Edit price","smartFilter.transformedQuery.remove":"Remove search query","smartFilter.transformedQuery.edit":"Edit search query","smartFilter.restaurantPriceLevel.label":"Price Level","smartFilter.restaurantPriceLevel.remove":"Remove price level filter","smartFilter.restaurantPriceLevel.none":"Any","smartFilter.restaurantPriceLevel.options.cheapEats":"Cheap Eats","smartFilter.restaurantPriceLevel.options.midRange":"Mid Range","smartFilter.restaurantPriceLevel.options.fineDining":"Fine Dining"},Ne=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),N=(e,t)=>{let[p,n]=Te("en"),l=he((f,s)=>{let d={...Be,...e}[f]||f;return s&&Object.keys(s).forEach(u=>{d=d.replace(new RegExp(`{{${u}}}`,"g"),String(s[u]))}),d},[e]),m=he((f,s)=>t?t(f,s):Ne(f,s),[t]);return{t:l,locale:p,setLocale:n,formatCurrency:m}};import{jsx as K,jsxs as De}from"react/jsx-runtime";var He=e=>{let t=[],p=Math.floor(e),n=e%1!==0,l={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},m={...l,backgroundColor:"#03852e"},f={...l,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};for(let i=0;i<p;i+=1)t.push(K("span",{style:m},`full-${i}`));n&&t.push(K("span",{style:f},"half"));let s=Math.max(0,5-Math.ceil(e));for(let i=0;i<s;i+=1)t.push(K("span",{style:l},`empty-${i}`));return t},Ft=(e,t)=>De("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[K("span",{style:{display:"flex",gap:"1px",userSelect:"none"},children:He(e)})," ",t]}),te=e=>e.toFixed(1),Pt=(e,t,p,n)=>`${n(e,p)} - ${n(t!=null?t:0,p)}`;import{jsx as z,jsxs as G}from"react/jsx-runtime";var ze={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",gap:"8px",alignItems:"center",justifyContent:"center",flexShrink:0,height:"34px"},Oe={display:"flex",gap:"1px",userSelect:"none"},re={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},$={position:"absolute",top:0,height:"100%",cursor:"pointer",backgroundColor:"transparent",border:"none",padding:0},U=({rating:e,onChange:t,onRemove:p,star:n=!1})=>{let[l,m]=Ae(null),{t:f}=N(),s=l!=null?l:e,i=C=>n&&C?C.toString():f("smartFilter.minRating.label",{value:te(C)}),d=f("smartFilter.minRating.remove"),u=C=>f("smartFilter.minRating.setTo",{rating:te(C)}),P=C=>{let x=C+1;return s>=x?"full":s>=x-.5?"half":"empty"},h=C=>{m(null),C!==e&&t(C)},w=C=>{var v;let x=C.relatedTarget;(!x||!((v=C.currentTarget.closest("[data-min-rating-chip]"))!=null&&v.contains(x)))&&m(null)};return G("div",{style:ze,"data-min-rating-chip":!0,children:[G("div",{style:{display:"flex",alignItems:"center",gap:"4px"},onMouseLeave:()=>m(null),children:[z("div",{style:Oe,children:Array.from({length:5}).map((C,x)=>{let v=P(x),R=x+1,r=R-.5;if(n)return G("div",{style:{position:"relative",width:"16px",height:"16px"},children:[z(ye,{fill:s>=R?"#03852e":"none",style:{width:"16px",height:"16px",pointerEvents:"none"}}),z("button",{type:"button",style:{...$,left:0,width:"50%",borderRadius:"50% 0 0 50%"},onMouseEnter:()=>m(r),onFocus:()=>m(r),onBlur:w,onClick:()=>h(r),"aria-label":u(r),title:i(r)}),z("button",{type:"button",style:{...$,left:"50%",width:"50%",borderRadius:"0 50% 50% 0"},onMouseEnter:()=>m(R),onFocus:()=>m(R),onBlur:w,onClick:()=>h(R),"aria-label":u(R),title:i(R)})]},x);let I=v==="full"?{...re,backgroundColor:"#03852e"}:re,B={...re,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};return G("div",{style:{position:"relative",width:"12px",height:"12px"},children:[z("span",{style:v==="half"?B:I}),z("button",{type:"button",style:{...$,left:0,width:"50%",borderRadius:"50% 0 0 50%",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>m(r),onFocus:()=>m(r),onBlur:w,onClick:()=>h(r),"aria-label":u(r),title:i(r)}),z("button",{type:"button",style:{...$,left:"50%",width:"50%",borderRadius:"0 50% 50% 0",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>m(R),onFocus:()=>m(R),onBlur:w,onClick:()=>h(R),"aria-label":u(R),title:i(R)})]},x)})}),z("span",{style:{whiteSpace:"nowrap"},children:i(s)})]}),z(D,{onClick:p})]})};import{useEffect as Ve,useState as ne}from"react";import{Fragment as Qe,jsx as A,jsxs as oe}from"react/jsx-runtime";var _e={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},We={outline:"none",fontSize:"16px",backgroundColor:"transparent",borderRadius:"2px",padding:"2px 8px",width:"64px",textAlign:"center",border:"none"},qe={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",border:"none",backgroundColor:"transparent",color:"#737373",display:"flex",alignItems:"center",justifyContent:"center"},be=({boundary:e,label:t,value:p,placeholder:n,currency:l,isOptional:m=!1,showRemoveButton:f=!1,removeLabel:s,editLabel:i,showAddWhenEmpty:d=!1,onCommit:u,onRemove:P})=>{let[h,w]=ne(p!==void 0?String(p):""),[C,x]=ne(!1),[v,R]=ne(!1),r=p!==void 0;Ve(()=>{w(p!==void 0?String(p):""),x(!1)},[p]);let I=()=>{w(p!==void 0?String(p):"")},B=()=>{if(h.trim()===""){if(m){u(void 0),w("");return}I();return}let a=Number(h);if(!Number.isFinite(a)){I();return}let k=Math.max(0,a);if(k===p){I();return}u(k)};return oe("div",{style:_e,children:[A("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:t}),C?A("input",{value:h,onChange:a=>{let k=a.target.value.replace(/[^\d]/g,"");w(k)},onBlur:()=>{B(),x(!1)},onKeyDown:a=>{if(a.key==="Enter"){a.preventDefault(),a.currentTarget.blur(),x(!1);return}if(a.key==="Escape"){a.preventDefault(),I(),a.currentTarget.blur(),x(!1);return}a.key.length===1&&/[0-9]/.test(a.key)||a.key==="Backspace"||a.key==="Delete"||a.key==="Tab"||a.key==="ArrowLeft"||a.key==="ArrowRight"||a.key==="Home"||a.key==="End"||a.preventDefault()},placeholder:n,inputMode:"numeric",pattern:"[0-9]*","aria-label":t,style:We,autoFocus:!0}):r?oe("span",{style:{fontSize:"16px"},children:[l,p]}):d?A("button",{type:"button",style:{fontSize:"16px",color:"#737373",cursor:"pointer",border:"none",backgroundColor:"transparent",padding:0},onClick:()=>x(!0),"aria-label":i,children:"+"}):A("span",{style:{fontSize:"16px",color:"#737373"},children:"-"}),(!d||d&&C)&&A("span",{style:{color:"#737373",fontSize:"12px"},children:l}),!C&&(!d||r)&&A("button",{type:"button",style:{...qe,backgroundColor:v?"#e5e5e5":"transparent"},"aria-label":i,title:i,onClick:()=>x(!0),onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),children:A(Q,{})}),f&&A(D,{onClick:P})]})},ie=({priceRange:e,currency:t,onChange:p,onRemove:n})=>{let{t:l}=N(),m="Min",f="Max",s=l("smartFilter.priceRange.remove"),i=l("smartFilter.priceRange.edit"),d=(u,P)=>{let h={min:e.min,max:e.max};u==="min"?(h.min=P,P!==void 0&&e.max!==void 0&&P>e.max&&(h.max=P)):(h.max=P,P!==void 0&&e.min!==void 0&&P<e.min&&(h.min=P)),(h.min!==e.min||h.max!==e.max)&&p(h)};return oe(Qe,{children:[A(be,{boundary:"min",label:m,value:e.min,currency:t,editLabel:i,showRemoveButton:e.min!==void 0&&e.min!==0,onCommit:u=>d("min",u),onRemove:n}),A(be,{boundary:"max",label:f,value:e.max,currency:t,isOptional:!0,showRemoveButton:e.max!==void 0,removeLabel:s,editLabel:i,showAddWhenEmpty:!0,onCommit:u=>d("max",u),onRemove:n})]})};import{jsx as q,jsxs as Y}from"react/jsx-runtime";var Ke={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"16px",flexShrink:0,height:"34px"},Se=[{value:"Cheap Eats",key:"cheapEats"},{value:"Mid Range",key:"midRange"},{value:"Fine Dining",key:"fineDining"}],ae=({values:e,onChange:t,onRemove:p})=>{let{t:n}=N(),l=n("smartFilter.restaurantPriceLevel.label"),m=n("smartFilter.restaurantPriceLevel.remove"),f=n("smartFilter.restaurantPriceLevel.none"),s=i=>{let{value:d,checked:u}=i.target,P=d,h=new Set(e);u?h.add(P):h.delete(P);let w=Se.filter(C=>h.has(C.value)).map(C=>C.value);t(w)};return Y("div",{style:Ke,children:[Y("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[q("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:l}),Y("div",{style:{display:"flex",gap:"12px"},children:[Se.map(i=>{let d=n(`smartFilter.restaurantPriceLevel.options.${i.key}`),u=`price-level-${i.key}`;return Y("label",{htmlFor:u,style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",cursor:"pointer"},children:[q("input",{id:u,type:"checkbox",value:i.value,checked:e.includes(i.value),onChange:s,style:{accentColor:"#03852e",cursor:"pointer"}}),q("span",{children:d})]},i.value)}),e.length===0&&q("span",{style:{fontSize:"12px",color:"#737373"},children:f})]})]}),q(D,{onClick:p})]})};import{useEffect as $e,useRef as Ge,useState as se}from"react";import{jsx as W,jsxs as je}from"react/jsx-runtime";var Ue={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,userSelect:"none",height:"34px"},Ye={backgroundColor:"#ececec",borderRadius:"2px",padding:"2px 8px",outline:"none",fontSize:"16px",minWidth:"8ch",border:"none"},Ze={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",color:"#737373",border:"none",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},le=({value:e,onChange:t,onRemove:p})=>{let n=Ge(null),[l,m]=se(e),[f,s]=se(!1),[i,d]=se(!1),{t:u}=N(),P=u("smartFilter.transformedQuery.remove"),h=u("smartFilter.transformedQuery.edit");$e(()=>{m(e),s(!1)},[e]);let w=()=>{let v=l.trim();if(!v.length){m(e);return}v!==e&&t(v)};return je("div",{style:Ue,children:[W(me,{style:{width:"16px",height:"16px",color:"#03852e"}}),f?W("input",{ref:n,value:l,onChange:v=>{m(v.target.value)},onBlur:()=>{w(),s(!1)},onKeyDown:v=>{if(v.key==="Enter"){v.preventDefault(),v.currentTarget.blur();return}if(v.key==="Escape"){v.preventDefault(),m(e),v.currentTarget.blur();return}},"aria-label":h,style:Ye,autoFocus:!0}):W("span",{style:{fontSize:"16px"},children:e}),!f&&W("button",{type:"button",style:{...Ze,backgroundColor:i?"#e5e5e5":"transparent"},"aria-label":h,title:h,onClick:()=>s(!0),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:W(Q,{})}),W(D,{onClick:p})]})};import{useCallback as Ce,useEffect as Xe,useRef as Je,useState as xe}from"react";var ce=e=>{let t=Je(null),[p,n]=xe(!0),[l,m]=xe(!0),f=Ce(()=>{let i=t.current;if(!i){n(!0),m(!0);return}let{scrollLeft:d,scrollWidth:u,clientWidth:P}=i;n(d<=0),m(d+P>=u-1)},[]);Xe(()=>{let i=t.current;if(f(),!i)return;let d=()=>f();return i.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",f),()=>{i.removeEventListener("scroll",d),window.removeEventListener("resize",f)}},[e,f]);let s=Ce(i=>{let d=t.current;if(!d)return;let u=d.clientWidth*.7;d.scrollBy({left:i==="next"?u:-u,behavior:"smooth"})},[]);return{scrollerRef:t,atStart:p,atEnd:l,scrollByDir:s}};import{jsx as T,jsxs as Pe}from"react/jsx-runtime";var et={position:"relative",width:"100%"},tt={display:"flex",gap:"8px",overflowX:"auto",alignItems:"center",width:"100%",scrollbarWidth:"none",msOverflowStyle:"none"},ke={pointerEvents:"none",position:"absolute",top:0,bottom:0,width:"40px"},Fe={position:"absolute",top:"50%",transform:"translateY(-50%)",backgroundColor:"white",color:"#003c30",border:"1px solid #003c30",padding:"4px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",cursor:"pointer"},pe=({filters:e,currency:t,minRatingSuffix:p,clearAllLabel:n,previousFiltersLabel:l,nextFiltersLabel:m,formatCurrency:f,onFilterChange:s,onResetFilters:i,onClearAll:d})=>{let{scrollerRef:u,atStart:P,atEnd:h,scrollByDir:w}=ce(e.length),[C,x]=ve.useState(null),[v,R]=ve.useState(!1);return Pe("div",{style:et,children:[Pe("div",{ref:u,style:{...tt,padding:"8px",WebkitOverflowScrolling:"touch"},children:[T("style",{children:`
|
|
1
|
+
import w from"react";import{MapFirstCore as nt}from"@mapfirst.ai/core";import{processApiFilters as Kr,convertToApiFilters as $r}from"@mapfirst.ai/core";import{useCallback as ce}from"react";import Ce from"react";import Pe from"react";import{jsx as N,jsxs as Z}from"react/jsx-runtime";var ue=({className:e,style:t})=>Z("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[N("circle",{cx:"11",cy:"11",r:"8"}),N("path",{d:"m21 21-4.35-4.35"})]}),de=({className:e,style:t})=>Z("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[N("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),N("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),V=({className:e,style:t})=>Z("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[N("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),N("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),Y=({className:e,style:t})=>N("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:N("polyline",{points:"9 18 15 12 9 6"})}),me=({className:e,style:t,fill:c="none"})=>N("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:c,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:N("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})});import{jsx as ge}from"react/jsx-runtime";var Le={position:"absolute",top:"-8px",right:"-8px",padding:"2px",borderRadius:"50%",backgroundColor:"white",border:"1px solid #03852e",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"},we={width:"17px",height:"17px"},D=({onClick:e,style:t})=>{let[c,o]=Pe.useState(!1);return ge("button",{style:{...Le,backgroundColor:c?"#e5e5e5":"white",...t},onClick:e,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),"aria-label":"Remove filter",children:ge(de,{style:we})})};import{jsx as j,jsxs as Me}from"react/jsx-runtime";var Ee={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},X=({label:e,icon:t,remove:c,style:o})=>Me("div",{style:{...Ee,...o},children:[t&&j("span",{style:{display:"flex",alignItems:"center"},children:t}),j("span",{style:{whiteSpace:"nowrap"},children:e}),j(D,{onClick:c})]});import{useState as He}from"react";import{useCallback as ye,useState as Be}from"react";var Ie={"smartFilter.typingPrompt":"Search for hotels, restaurants, or attractions...","smartFilter.nav.previous":"Previous filters","smartFilter.nav.next":"Next filters","smartFilter.toast.locationRequired":"Please select a location first","smartFilter.clearAll":"Clear all","smartFilter.minRating.suffix":"+","smartFilter.minRating.label":"{{value}}+","smartFilter.minRating.remove":"Remove rating filter","smartFilter.minRating.setTo":"Set rating to {{rating}}","smartFilter.priceRange.label":"Price Range","smartFilter.priceRange.remove":"Remove price filter","smartFilter.priceRange.edit":"Edit price","smartFilter.transformedQuery.remove":"Remove search query","smartFilter.transformedQuery.edit":"Edit search query","smartFilter.restaurantPriceLevel.label":"Price Level","smartFilter.restaurantPriceLevel.remove":"Remove price level filter","smartFilter.restaurantPriceLevel.none":"Any","smartFilter.restaurantPriceLevel.options.cheapEats":"Cheap Eats","smartFilter.restaurantPriceLevel.options.midRange":"Mid Range","smartFilter.restaurantPriceLevel.options.fineDining":"Fine Dining"},Te=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),I=(e,t)=>{let[c,o]=Be("en"),l=ye((b,a)=>{let u={...Ie,...e}[b]||b;return a&&Object.keys(a).forEach(p=>{u=u.replace(new RegExp(`{{${p}}}`,"g"),String(a[p]))}),u},[e]),m=ye((b,a)=>t?t(b,a):Te(b,a),[t]);return{t:l,locale:c,setLocale:o,formatCurrency:m}};import{jsx as q,jsxs as De}from"react/jsx-runtime";var Ne=e=>{let t=[],c=Math.floor(e),o=e%1!==0,l={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},m={...l,backgroundColor:"#03852e"},b={...l,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};for(let i=0;i<c;i+=1)t.push(q("span",{style:m},`full-${i}`));o&&t.push(q("span",{style:b},"half"));let a=Math.max(0,5-Math.ceil(e));for(let i=0;i<a;i+=1)t.push(q("span",{style:l},`empty-${i}`));return t},ft=(e,t)=>De("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[q("span",{style:{display:"flex",gap:"1px",userSelect:"none"},children:Ne(e)})," ",t]}),J=e=>e.toFixed(1),ht=(e,t,c,o)=>`${o(e,c)} - ${o(t!=null?t:0,c)}`;import{jsx as z,jsxs as $}from"react/jsx-runtime";var Ae={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",gap:"8px",alignItems:"center",justifyContent:"center",flexShrink:0,height:"34px"},ze={display:"flex",gap:"1px",userSelect:"none"},ee={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},K={position:"absolute",top:0,height:"100%",cursor:"pointer",backgroundColor:"transparent",border:"none",padding:0},G=({rating:e,onChange:t,onRemove:c,star:o=!1})=>{let[l,m]=He(null),{t:b}=I(),a=l!=null?l:e,i=h=>o&&h?h.toString():b("smartFilter.minRating.label",{value:J(h)}),u=b("smartFilter.minRating.remove"),p=h=>b("smartFilter.minRating.setTo",{rating:J(h)}),k=h=>{let S=h+1;return a>=S?"full":a>=S-.5?"half":"empty"},y=h=>{m(null),h!==e&&t(h)},F=h=>{var x;let S=h.relatedTarget;(!S||!((x=h.currentTarget.closest("[data-min-rating-chip]"))!=null&&x.contains(S)))&&m(null)};return $("div",{style:Ae,"data-min-rating-chip":!0,children:[$("div",{style:{display:"flex",alignItems:"center",gap:"4px"},onMouseLeave:()=>m(null),children:[z("div",{style:ze,children:Array.from({length:5}).map((h,S)=>{let x=k(S),L=S+1,n=L-.5;if(o)return $("div",{style:{position:"relative",width:"16px",height:"16px"},children:[z(me,{fill:a>=L?"#03852e":"none",style:{width:"16px",height:"16px",pointerEvents:"none"}}),z("button",{type:"button",style:{...K,left:0,width:"50%",borderRadius:"50% 0 0 50%"},onMouseEnter:()=>m(n),onFocus:()=>m(n),onBlur:F,onClick:()=>y(n),"aria-label":p(n),title:i(n)}),z("button",{type:"button",style:{...K,left:"50%",width:"50%",borderRadius:"0 50% 50% 0"},onMouseEnter:()=>m(L),onFocus:()=>m(L),onBlur:F,onClick:()=>y(L),"aria-label":p(L),title:i(L)})]},S);let B=x==="full"?{...ee,backgroundColor:"#03852e"}:ee,A={...ee,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};return $("div",{style:{position:"relative",width:"12px",height:"12px"},children:[z("span",{style:x==="half"?A:B}),z("button",{type:"button",style:{...K,left:0,width:"50%",borderRadius:"50% 0 0 50%",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>m(n),onFocus:()=>m(n),onBlur:F,onClick:()=>y(n),"aria-label":p(n),title:i(n)}),z("button",{type:"button",style:{...K,left:"50%",width:"50%",borderRadius:"0 50% 50% 0",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>m(L),onFocus:()=>m(L),onBlur:F,onClick:()=>y(L),"aria-label":p(L),title:i(L)})]},S)})}),z("span",{style:{whiteSpace:"nowrap"},children:i(a)})]}),z(D,{onClick:c})]})};import{useEffect as Oe,useState as te}from"react";import{Fragment as Ve,jsx as H,jsxs as re}from"react/jsx-runtime";var _e={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},We={outline:"none",fontSize:"16px",backgroundColor:"transparent",borderRadius:"2px",padding:"2px 8px",width:"64px",textAlign:"center",border:"none"},Qe={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",border:"none",backgroundColor:"transparent",color:"#737373",display:"flex",alignItems:"center",justifyContent:"center"},fe=({boundary:e,label:t,value:c,placeholder:o,currency:l,isOptional:m=!1,showRemoveButton:b=!1,removeLabel:a,editLabel:i,showAddWhenEmpty:u=!1,onCommit:p,onRemove:k})=>{let[y,F]=te(c!==void 0?String(c):""),[h,S]=te(!1),[x,L]=te(!1),n=c!==void 0;Oe(()=>{F(c!==void 0?String(c):""),S(!1)},[c]);let B=()=>{F(c!==void 0?String(c):"")},A=()=>{if(y.trim()===""){if(m){p(void 0),F("");return}B();return}let s=Number(y);if(!Number.isFinite(s)){B();return}let R=Math.max(0,s);if(R===c){B();return}p(R)};return re("div",{style:_e,children:[H("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:t}),h?H("input",{value:y,onChange:s=>{let R=s.target.value.replace(/[^\d]/g,"");F(R)},onBlur:()=>{A(),S(!1)},onKeyDown:s=>{if(s.key==="Enter"){s.preventDefault(),s.currentTarget.blur(),S(!1);return}if(s.key==="Escape"){s.preventDefault(),B(),s.currentTarget.blur(),S(!1);return}s.key.length===1&&/[0-9]/.test(s.key)||s.key==="Backspace"||s.key==="Delete"||s.key==="Tab"||s.key==="ArrowLeft"||s.key==="ArrowRight"||s.key==="Home"||s.key==="End"||s.preventDefault()},placeholder:o,inputMode:"numeric",pattern:"[0-9]*","aria-label":t,style:We,autoFocus:!0}):n?re("span",{style:{fontSize:"16px"},children:[l,c]}):u?H("button",{type:"button",style:{fontSize:"16px",color:"#737373",cursor:"pointer",border:"none",backgroundColor:"transparent",padding:0},onClick:()=>S(!0),"aria-label":i,children:"+"}):H("span",{style:{fontSize:"16px",color:"#737373"},children:"-"}),(!u||u&&h)&&H("span",{style:{color:"#737373",fontSize:"12px"},children:l}),!h&&(!u||n)&&H("button",{type:"button",style:{...Qe,backgroundColor:x?"#e5e5e5":"transparent"},"aria-label":i,title:i,onClick:()=>S(!0),onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),children:H(V,{})}),b&&H(D,{onClick:k})]})},ne=({priceRange:e,currency:t,onChange:c,onRemove:o})=>{let{t:l}=I(),m="Min",b="Max",a=l("smartFilter.priceRange.remove"),i=l("smartFilter.priceRange.edit"),u=(p,k)=>{let y={min:e.min,max:e.max};p==="min"?(y.min=k,k!==void 0&&e.max!==void 0&&k>e.max&&(y.max=k)):(y.max=k,k!==void 0&&e.min!==void 0&&k<e.min&&(y.min=k)),(y.min!==e.min||y.max!==e.max)&&c(y)};return re(Ve,{children:[H(fe,{boundary:"min",label:m,value:e.min,currency:t,editLabel:i,showRemoveButton:e.min!==void 0&&e.min!==0,onCommit:p=>u("min",p),onRemove:o}),H(fe,{boundary:"max",label:b,value:e.max,currency:t,isOptional:!0,showRemoveButton:e.max!==void 0,removeLabel:a,editLabel:i,showAddWhenEmpty:!0,onCommit:p=>u("max",p),onRemove:o})]})};import{jsx as Q,jsxs as U}from"react/jsx-runtime";var qe={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"16px",flexShrink:0,height:"34px"},he=[{value:"Cheap Eats",key:"cheapEats"},{value:"Mid Range",key:"midRange"},{value:"Fine Dining",key:"fineDining"}],oe=({values:e,onChange:t,onRemove:c})=>{let{t:o}=I(),l=o("smartFilter.restaurantPriceLevel.label"),m=o("smartFilter.restaurantPriceLevel.remove"),b=o("smartFilter.restaurantPriceLevel.none"),a=i=>{let{value:u,checked:p}=i.target,k=u,y=new Set(e);p?y.add(k):y.delete(k);let F=he.filter(h=>y.has(h.value)).map(h=>h.value);t(F)};return U("div",{style:qe,children:[U("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[Q("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:l}),U("div",{style:{display:"flex",gap:"12px"},children:[he.map(i=>{let u=o(`smartFilter.restaurantPriceLevel.options.${i.key}`),p=`price-level-${i.key}`;return U("label",{htmlFor:p,style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",cursor:"pointer"},children:[Q("input",{id:p,type:"checkbox",value:i.value,checked:e.includes(i.value),onChange:a,style:{accentColor:"#03852e",cursor:"pointer"}}),Q("span",{children:u})]},i.value)}),e.length===0&&Q("span",{style:{fontSize:"12px",color:"#737373"},children:b})]})]}),Q(D,{onClick:c})]})};import{useEffect as Ke,useRef as $e,useState as ie}from"react";import{jsx as _,jsxs as Ze}from"react/jsx-runtime";var Ge={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,userSelect:"none",height:"34px"},Ue={backgroundColor:"#ececec",borderRadius:"2px",padding:"2px 8px",outline:"none",fontSize:"16px",minWidth:"8ch",border:"none"},Ye={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",color:"#737373",border:"none",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},ae=({value:e,onChange:t,onRemove:c})=>{let o=$e(null),[l,m]=ie(e),[b,a]=ie(!1),[i,u]=ie(!1),{t:p}=I(),k=p("smartFilter.transformedQuery.remove"),y=p("smartFilter.transformedQuery.edit");Ke(()=>{m(e),a(!1)},[e]);let F=()=>{let x=l.trim();if(!x.length){m(e);return}x!==e&&t(x)};return Ze("div",{style:Ge,children:[_(ue,{style:{width:"16px",height:"16px",color:"#03852e"}}),b?_("input",{ref:o,value:l,onChange:x=>{m(x.target.value)},onBlur:()=>{F(),a(!1)},onKeyDown:x=>{if(x.key==="Enter"){x.preventDefault(),x.currentTarget.blur();return}if(x.key==="Escape"){x.preventDefault(),m(e),x.currentTarget.blur();return}},"aria-label":y,style:Ue,autoFocus:!0}):_("span",{style:{fontSize:"16px"},children:e}),!b&&_("button",{type:"button",style:{...Ye,backgroundColor:i?"#e5e5e5":"transparent"},"aria-label":y,title:y,onClick:()=>a(!0),onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),children:_(V,{})}),_(D,{onClick:c})]})};import{useCallback as be,useEffect as je,useRef as Xe,useState as Se}from"react";var se=e=>{let t=Xe(null),[c,o]=Se(!0),[l,m]=Se(!0),b=be(()=>{let i=t.current;if(!i){o(!0),m(!0);return}let{scrollLeft:u,scrollWidth:p,clientWidth:k}=i;o(u<=0),m(u+k>=p-1)},[]);je(()=>{let i=t.current;if(b(),!i)return;let u=()=>b();return i.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",b),()=>{i.removeEventListener("scroll",u),window.removeEventListener("resize",b)}},[e,b]);let a=be(i=>{let u=t.current;if(!u)return;let p=u.clientWidth*.7;u.scrollBy({left:i==="next"?p:-p,behavior:"smooth"})},[]);return{scrollerRef:t,atStart:c,atEnd:l,scrollByDir:a}};import{jsx as M,jsxs as ke}from"react/jsx-runtime";var Je={position:"relative",width:"100%"},et={display:"flex",gap:"8px",overflowX:"auto",alignItems:"center",width:"100%",scrollbarWidth:"none",msOverflowStyle:"none"},xe={pointerEvents:"none",position:"absolute",top:0,bottom:0,width:"40px"},ve={position:"absolute",top:"50%",transform:"translateY(-50%)",backgroundColor:"white",color:"#003c30",border:"1px solid #003c30",padding:"4px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",cursor:"pointer"},le=({filters:e,currency:t,minRatingSuffix:c,clearAllLabel:o,previousFiltersLabel:l,nextFiltersLabel:m,formatCurrency:b,onFilterChange:a,onResetFilters:i,onClearAll:u})=>{let{scrollerRef:p,atStart:k,atEnd:y,scrollByDir:F}=se(e.length),[h,S]=Ce.useState(null),[x,L]=Ce.useState(!1);return ke("div",{style:Je,children:[ke("div",{ref:p,style:{...et,padding:"8px",WebkitOverflowScrolling:"touch"},children:[M("style",{children:`
|
|
2
2
|
div::-webkit-scrollbar {
|
|
3
3
|
display: none;
|
|
4
4
|
}
|
|
5
|
-
`}),e.map(
|
|
6
|
-
@keyframes spin {
|
|
7
|
-
0% { transform: rotate(0deg); }
|
|
8
|
-
100% { transform: rotate(360deg); }
|
|
9
|
-
}
|
|
10
|
-
`}),t.length===0&&_("form",{onSubmit:E,style:{...ot,...P},children:Re("div",{style:it,children:[_("input",{type:"text",value:v,onChange:b=>R(b.target.value),disabled:n,style:{...at,...h},autoComplete:"off","aria-label":"Smart search"}),i&&v.length===0&&!n&&_("span",{style:ct,children:V}),n&&_("div",{style:st,children:_("div",{style:lt})})]})}),t.length>0&&_(pe,{filters:t,currency:u,minRatingSuffix:B,clearAllLabel:k,previousFiltersLabel:O,nextFiltersLabel:a,formatCurrency:I,onFilterChange:M,onResetFilters:Z,onClearAll:F})]})};function Xr(e){let t=L.useRef(null),[p,n]=L.useState(null),l=L.useRef(e);L.useEffect(()=>{l.current=e}),L.useEffect(()=>{let F=l.current,b={adapter:null,...F,callbacks:{...F.callbacks,onPropertiesChange:c=>{var o,g;n(S=>S?{...S,properties:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onPropertiesChange)==null||g.call(o,c)},onSelectedPropertyChange:c=>{var o,g;n(S=>S?{...S,selectedPropertyId:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onSelectedPropertyChange)==null||g.call(o,c)},onPrimaryTypeChange:c=>{var o,g;n(S=>S?{...S,primary:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onPrimaryTypeChange)==null||g.call(o,c)},onFiltersChange:c=>{var o,g;n(S=>S?{...S,filters:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onFiltersChange)==null||g.call(o,c)},onBoundsChange:c=>{var o,g;n(S=>S?{...S,bounds:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onBoundsChange)==null||g.call(o,c)},onPendingBoundsChange:c=>{var o,g;n(S=>S?{...S,pendingBounds:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onPendingBoundsChange)==null||g.call(o,c)},onCenterChange:(c,o)=>{var g,S;n(de=>de?{...de,center:c,zoom:o}:null),(S=(g=l.current.callbacks)==null?void 0:g.onCenterChange)==null||S.call(g,c,o)},onZoomChange:c=>{var o,g;n(S=>S?{...S,zoom:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onZoomChange)==null||g.call(o,c)},onActiveLocationChange:c=>{var o,g;n(S=>S?{...S,activeLocation:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onActiveLocationChange)==null||g.call(o,c)},onLoadingStateChange:c=>{var o,g;n(S=>S?{...S,initialLoading:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onLoadingStateChange)==null||g.call(o,c)},onSearchingStateChange:c=>{var o,g;n(S=>S?{...S,isSearching:c}:null),(g=(o=l.current.callbacks)==null?void 0:o.onSearchingStateChange)==null||g.call(o,c)}}},y=new ut(b);return t.current=y,n(y.getState()),()=>{y.destroy(),t.current=null,n(null)}},[]);let m=L.useCallback(F=>{t.current&&t.current.setPrimaryType(F)},[]),f=L.useCallback(F=>{t.current&&t.current.setSelectedMarker(F)},[]),[s,i]=L.useState(!1),[d,u]=L.useState(null),P=L.useMemo(()=>({search:async F=>{if(!t.current){let b=new Error("MapFirst instance not available");throw u(b),b}i(!0),u(null);try{return await t.current.runPropertiesSearch({...F,onError:y=>{let c=y instanceof Error?y:new Error(String(y));u(c)}})}catch(b){let y=b instanceof Error?b:new Error(String(b));throw u(y),y}finally{i(!1)}},isLoading:s,error:d}),[s,d]),[h,w]=L.useState(!1),[C,x]=L.useState(null),v=L.useMemo(()=>({search:async F=>{if(!t.current){let b=new Error("MapFirst instance not available");throw x(b),b}w(!0),x(null);try{return await t.current.runSmartFilterSearch({...F,onError:y=>{let c=y instanceof Error?y:new Error(String(y));x(c)}})}catch(b){let y=b instanceof Error?b:new Error(String(b));throw x(y),y}finally{w(!1)}},isLoading:h,error:C}),[h,C]),[R,r]=L.useState(!1),[I,B]=L.useState(null),V=L.useMemo(()=>({perform:async()=>{if(!t.current)return null;r(!0),B(null);try{return await t.current.performBoundsSearch()}catch(F){let b=F instanceof Error?F:new Error(String(F));throw B(b),b}finally{r(!1)}},isSearching:R,error:I}),[R,I]),O=L.useRef(!1),a=L.useCallback((F,b,y)=>{t.current&&F&&!O.current&&(t.current.attachMap(F,{platform:"maplibre",maplibregl:b,onMarkerClick:y==null?void 0:y.onMarkerClick}),O.current=!0)},[]),k=L.useRef(!1),E=L.useCallback((F,b,y)=>{t.current&&F&&!k.current&&(t.current.attachMap(F,{platform:"google",google:b,onMarkerClick:y==null?void 0:y.onMarkerClick}),k.current=!0)},[]),M=L.useRef(!1),Z=L.useCallback((F,b,y)=>{t.current&&F&&!M.current&&(t.current.attachMap(F,{platform:"mapbox",mapboxgl:b,onMarkerClick:y==null?void 0:y.onMarkerClick}),M.current=!0)},[]);return{instance:t.current,state:p,setPrimaryType:m,setSelectedMarker:f,propertiesSearch:P,smartFilterSearch:v,boundsSearch:V,attachMapLibre:a,attachGoogle:E,attachMapbox:Z}}export{ee as Chip,ge as CloseIcon,Q as EditIcon,pe as FilterChips,U as MinRatingFilterChip,j as NextIcon,ie as PriceRangeFilterChip,ae as RestaurantPriceLevelChip,me as SearchIcon,pt as SmartFilter,ye as StarIcon,le as TransformedQueryChip,rn as convertToApiFilters,Ft as createMinRatingFilterLabel,Pt as createPriceRangeFilterLabel,te as formatRatingValue,tn as processApiFilters,He as renderStars,ce as useFilterScroll,Xr as useMapFirst,N as useTranslation};
|
|
5
|
+
`}),e.map(n=>{var A,W,O;let B=()=>M(X,{label:n.label,icon:n.icon,remove:()=>{a(e.filter(s=>s.id!==n.id))}},n.id);if(n.type==="minRating"){let s=(A=n.numericValue)!=null?A:Number(n.value);return Number.isFinite(s)?M(G,{rating:s,onChange:R=>{let E=e.map(T=>T.id===n.id?{...T,numericValue:R,value:String(R)}:T);a(E)},onRemove:()=>void a(e.filter(R=>R.id!==n.id))},n.id):B()}if(n.type==="starRating"){let s=(W=n.numericValue)!=null?W:Number(n.value);return Number.isFinite(s)?M(G,{star:!0,rating:s,onChange:R=>{let E=e.map(T=>T.id===n.id?{...T,numericValue:R,value:String(R)}:T);a(E)},onRemove:()=>void a(e.filter(R=>R.id!==n.id))},n.id):B()}return n.type==="priceRange"&&n.priceRange?M(ne,{priceRange:n.priceRange,currency:t,onChange:s=>{let R=e.map(E=>E.id===n.id?{...E,priceRange:s}:E);a(R)},onRemove:()=>void a(e.filter(s=>s.id!==n.id))},n.id):n.type==="transformed_query"?M(ae,{value:n.value,onChange:s=>{let R=e.map(E=>E.id===n.id?{...E,value:s}:E);a(R)},onRemove:()=>void a(e.filter(s=>s.id!==n.id))},n.id):n.type==="selected_restaurant_price_levels"?M(oe,{values:(O=n.priceLevels)!=null?O:[],onChange:s=>{let R=e.map(E=>E.id===n.id?{...E,priceLevels:s}:E);a(R)},onRemove:()=>void a(e.filter(s=>s.id!==n.id))},n.id):B()}),M("button",{style:{flexShrink:0,padding:"4px 16px",borderRadius:"9999px",cursor:"pointer",fontSize:"14px",userSelect:"none",backgroundColor:x?"#eee":"white",color:"black",border:"1px solid #03852e"},onClick:u,onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),children:o})]}),!k&&M("div",{"aria-hidden":"true",style:{...xe,left:0,background:"linear-gradient(to right, white, transparent)"}}),!y&&M("div",{"aria-hidden":"true",style:{...xe,right:0,background:"linear-gradient(to left, white, transparent)"}}),!k&&M("button",{type:"button","aria-label":l,style:{...ve,left:"4px",transform:"translateY(-50%) rotate(180deg)",backgroundColor:h==="prev"?"#e5e5e5":"white"},onClick:()=>F("prev"),onMouseEnter:()=>S("prev"),onMouseLeave:()=>S(null),children:M(Y,{style:{width:"20px",height:"20px"}})}),!y&&M("button",{type:"button","aria-label":m,style:{...ve,right:"4px",backgroundColor:h==="next"?"#e5e5e5":"white"},onClick:()=>F("next"),onMouseEnter:()=>S("next"),onMouseLeave:()=>S(null),children:M(Y,{style:{width:"20px",height:"20px"}})})]})};import{jsx as Fe}from"react/jsx-runtime";var tt={position:"relative",display:"flex",flexDirection:"column",gap:"8px",width:"100%"},rt=({filters:e,isSearching:t=!1,onFilterChange:c,customTranslations:o,currency:l="USD",containerStyle:m,style:b})=>{let{t:a,formatCurrency:i}=I(o),u=a("smartFilter.minRating.suffix"),p=a("smartFilter.nav.previous"),k=a("smartFilter.nav.next"),y=a("smartFilter.clearAll"),F=ce(async(x,L)=>{if(!t)try{await c(x)}catch(n){console.error("Filter change error:",n)}},[t,c]),h=ce(()=>{F([])},[F]),S=ce(()=>{F([],!0)},[F]);return Fe("div",{style:{...tt,...m},children:Fe(le,{filters:e,currency:l,minRatingSuffix:u,clearAllLabel:y,previousFiltersLabel:p,nextFiltersLabel:k,formatCurrency:i,onFilterChange:F,onResetFilters:h,onClearAll:S})})};function Qr(e){let t=w.useRef(null),[c,o]=w.useState(null),l=w.useRef(e);w.useEffect(()=>{l.current=e}),w.useEffect(()=>{let P=l.current,v={adapter:null,...P,callbacks:{...P.callbacks,onPropertiesChange:d=>{var r,g;o(f=>f?{...f,properties:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onPropertiesChange)==null||g.call(r,d)},onSelectedPropertyChange:d=>{var r,g;o(f=>f?{...f,selectedPropertyId:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onSelectedPropertyChange)==null||g.call(r,d)},onPrimaryTypeChange:d=>{var r,g;o(f=>f?{...f,primary:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onPrimaryTypeChange)==null||g.call(r,d)},onFiltersChange:d=>{var r,g;o(f=>f?{...f,filters:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onFiltersChange)==null||g.call(r,d)},onBoundsChange:d=>{var r,g;o(f=>f?{...f,bounds:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onBoundsChange)==null||g.call(r,d)},onPendingBoundsChange:d=>{var r,g;o(f=>f?{...f,pendingBounds:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onPendingBoundsChange)==null||g.call(r,d)},onCenterChange:(d,r)=>{var g,f;o(pe=>pe?{...pe,center:d,zoom:r}:null),(f=(g=l.current.callbacks)==null?void 0:g.onCenterChange)==null||f.call(g,d,r)},onZoomChange:d=>{var r,g;o(f=>f?{...f,zoom:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onZoomChange)==null||g.call(r,d)},onActiveLocationChange:d=>{var r,g;o(f=>f?{...f,activeLocation:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onActiveLocationChange)==null||g.call(r,d)},onLoadingStateChange:d=>{var r,g;o(f=>f?{...f,initialLoading:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onLoadingStateChange)==null||g.call(r,d)},onSearchingStateChange:d=>{var r,g;o(f=>f?{...f,isSearching:d}:null),(g=(r=l.current.callbacks)==null?void 0:r.onSearchingStateChange)==null||g.call(r,d)}}},C=new nt(v);return t.current=C,o(C.getState()),()=>{C.destroy(),t.current=null,o(null)}},[]);let m=w.useCallback(P=>{t.current&&t.current.setPrimaryType(P)},[]),b=w.useCallback(P=>{t.current&&t.current.setSelectedMarker(P)},[]),[a,i]=w.useState(!1),[u,p]=w.useState(null),k=w.useMemo(()=>({search:async P=>{if(!t.current){let v=new Error("MapFirst instance not available");throw p(v),v}i(!0),p(null);try{return await t.current.runPropertiesSearch({...P,onError:C=>{let d=C instanceof Error?C:new Error(String(C));p(d)}})}catch(v){let C=v instanceof Error?v:new Error(String(v));throw p(C),C}finally{i(!1)}},isLoading:a,error:u}),[a,u]),[y,F]=w.useState(!1),[h,S]=w.useState(null),x=w.useMemo(()=>({search:async P=>{if(!t.current){let v=new Error("MapFirst instance not available");throw S(v),v}F(!0),S(null);try{return await t.current.runSmartFilterSearch({...P,onError:C=>{let d=C instanceof Error?C:new Error(String(C));S(d)}})}catch(v){let C=v instanceof Error?v:new Error(String(v));throw S(C),C}finally{F(!1)}},isLoading:y,error:h}),[y,h]),[L,n]=w.useState(!1),[B,A]=w.useState(null),W=w.useMemo(()=>({perform:async()=>{if(!t.current)return null;n(!0),A(null);try{return await t.current.performBoundsSearch()}catch(P){let v=P instanceof Error?P:new Error(String(P));throw A(v),v}finally{n(!1)}},isSearching:L,error:B}),[L,B]),O=w.useRef(!1),s=w.useCallback((P,v,C)=>{t.current&&P&&!O.current&&(t.current.attachMap(P,{platform:"maplibre",maplibregl:v,onMarkerClick:C==null?void 0:C.onMarkerClick}),O.current=!0)},[]),R=w.useRef(!1),E=w.useCallback((P,v,C)=>{t.current&&P&&!R.current&&(t.current.attachMap(P,{platform:"google",google:v,onMarkerClick:C==null?void 0:C.onMarkerClick}),R.current=!0)},[]),T=w.useRef(!1),Re=w.useCallback((P,v,C)=>{t.current&&P&&!T.current&&(t.current.attachMap(P,{platform:"mapbox",mapboxgl:v,onMarkerClick:C==null?void 0:C.onMarkerClick}),T.current=!0)},[]);return{instance:t.current,state:c,setPrimaryType:m,setSelectedMarker:b,propertiesSearch:k,smartFilterSearch:x,boundsSearch:W,attachMapLibre:s,attachGoogle:E,attachMapbox:Re}}export{X as Chip,de as CloseIcon,V as EditIcon,le as FilterChips,G as MinRatingFilterChip,Y as NextIcon,ne as PriceRangeFilterChip,oe as RestaurantPriceLevelChip,ue as SearchIcon,rt as SmartFilter,me as StarIcon,ae as TransformedQueryChip,$r as convertToApiFilters,ft as createMinRatingFilterLabel,ht as createPriceRangeFilterLabel,J as formatRatingValue,Kr as processApiFilters,Ne as renderStars,se as useFilterScroll,Qr as useMapFirst,I as useTranslation};
|
|
11
6
|
//# sourceMappingURL=index.mjs.map
|