PageSourceSearch

https://petwellhk.com/assets/useLodging-CMVGJT1Q.js

js petwellhk.com collected 2026-10-06 05:23:53 UTC 4,536 bytes, 63 lines download raw bytes

1import{u as k,b as x}from"./query-7-WHkg5t.js";import"./main-m_sUF2N4.js";import{g as N}from"./hongKongDistricts--r8_jlh4.js";import{H as S,a as T,n as A,r as b,s as L,i as F,P as y,b as E,g as v,d as q,h as z,c as C}from"./placeSearchConfig-BfT0dFXT.js";import{g as D}from"./serviceOfferings-40B0fv7X.js";import{r as w}from"./react-vendor-BDHNqS4B.js";function I(e){return N(e)}function p(e,t){var o,a;if(!e)return"";const i=t==="en"?"zh":"en";return((o=e[t])==null?void 0:o.trim())||((a=e[i])==null?void 0:a.trim())||""}function _(e,t="zh"){const i=t==="en"?"en":"zh";return{id:e.id,name:p(e.name,i),region:I(e.district),district:e.district,address:p(e.address,i),location:e.location||null,phone:e.phoneNo,rating:e.totalRating,totalReviews:e.numReviews,services:e.serviceOfferings?e.serviceOfferings.split(",").map(o=>o.trim()):[],availableHours:e.availableHours,image:e.coverPhoto,hasData:!0,is247:e.is247,verified:e.verified,ownerSub:e.ownerSub??null,partnerPlan:e.partnerPlan??null,partnerPlanExpiresAt:e.partnerPlanExpiresAt??null,isPremium:F({ownerSub:e.ownerSub,partnerPlan:e.partnerPlan,partnerPlanExpiresAt:e.partnerPlanExpiresAt})}}async function R(e={},t="zh"){const{region:i,district:o,districts:a,keyword:d,is247:r,limit:u=y,nextToken:h,sortMethod:f="rating-desc"}=e;try{const s={location:e.location??S,limit:u,sortMethod:f};T(s,{region:i,district:o,districts:a}),d&&(s.keyword=d),r!==void 0&&(s.is247=r);const m=A(h);m&&(s.nextToken=m);const{items:P,total:n,nextToken:g}=await b("lodging",s,{fallback:"Failed to search lodgings"}),c=P.filter(l=>!!(l!=null&&l.id)).map(l=>_(l,t));return{lodgings:f==="location"?c:L(c),total:n,nextToken:g}}catch(s){throw console.error("Error searching lodgings:",s),s instanceof Error?s:new Error("Failed to search lodgings")}}const H=`
2  query GetLodging($id: ID!) {
3    getLodging(id: $id) {
4      id
5      ownerSub
6      name { zh en }
7      district
8      address { zh en }
9      phoneNo
10      serviceOfferings
11      availableHours {
12        mon { start end }
13        tue { start end }
14        wed { start end }
15        thu { start end }
16        fri { start end }
17        sat { start end }
18        sun { start end }
19        otherConditions
20      }
21      coverPhoto
22      gallery
23      verified
24      photoSource
25      website
26      email
27      totalRating
28      numReviews
29      is247
30      partnerPlan
31      partnerPlanExpiresAt
32      reservationSettings
33      reviews {
34        items {
35          id
36          reviewerId
37          title
38          description
39          totalRating
40          environmentRating
41          personnelRating
42          serviceRating
43          valueRating
44          waitingRating
45          fileAttachments
46          source
47          anonymous
48          partnerReply
49          partnerReplyAt
50          updatedAt
51          reviewer {
52            id
53            displayName
54            firstName
55            profileImage
56          }
57        }
58      }
59      createdAt
60      updatedAt
61    }
62  }
63`;async function M(e){var i;const t=await D(H,{id:e});return(i=t.getLodging.reviews)!=null&&i.items&&(t.getLodging.reviews.items=t.getLodging.reviews.items.slice(0,3)),t.getLodging}function U(e="zh"){return x({queryKey:["lodgings","home",E,e],queryFn:async()=>{const{lodgings:t}=await R({limit:y,sortMethod:"rating-desc"},e);return t},staleTime:5*60*1e3})}function V(e,t="zh"){var s,m,P;const i=C(e.region),o=((s=e.keyword)==null?void 0:s.trim())||void 0,a=e.location,d=e.sortMethod??"rating-desc",r=k({queryKey:["lodgings","search",E,t,i,o,e.is247,d,a==null?void 0:a.lat,a==null?void 0:a.lon],queryFn:({pageParam:n})=>R({region:i,keyword:o,is247:e.is247,location:a,sortMethod:d,limit:y,nextToken:n},t),initialPageParam:void 0,getNextPageParam:n=>v(n.nextToken),staleTime:5*60*1e3}),u=w.useMemo(()=>{var g;const n=((g=r.data)==null?void 0:g.pages)??[];return q(n.map(c=>c.lodgings))},[r.data]),h=w.useMemo(()=>{var c;const n=(c=r.data)==null?void 0:c.pages;if(!(n!=null&&n.length))return!1;const g=n[n.length-1];return!v(g==null?void 0:g.nextToken)||z(n.map(l=>({items:l.lodgings,nextToken:l.nextToken})))?!1:r.hasNextPage},[r.data,r.hasNextPage]),f=h?u.length:((P=(m=r.data)==null?void 0:m.pages[0])==null?void 0:P.total)??u.length;return{lodgings:u,totalCount:f,isLoading:r.isLoading,error:r.error,hasNextPage:h,fetchNextPage:r.fetchNextPage,isFetchingNextPage:r.isFetchingNextPage}}function W(e){return x({queryKey:["lodging",e],queryFn:()=>
63{if(!e)throw new Error("Lodging ID is required");return M(e)},enabled:!!e,staleTime:5*60*1e3})}export{V as a,W as b,U as u};

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.