@travories/frontend-sdk 0.1.1 → 0.1.3

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.js CHANGED
@@ -216,15 +216,158 @@ var PackagesResource = class {
216
216
  }
217
217
  };
218
218
 
219
+ // src/api/agencies.ts
220
+ var normalizeImage2 = (img) => ({
221
+ id: img?.id ?? "",
222
+ key: img?.key ?? "",
223
+ type: img?.type ?? "image",
224
+ alt: img?.alt ?? "",
225
+ preview: img?.preview ?? null,
226
+ url: {
227
+ original: img?.url?.original ?? null,
228
+ hero: img?.url?.hero ?? null,
229
+ hero_fit: img?.url?.hero_fit ?? null,
230
+ section: img?.url?.section ?? null,
231
+ portrait: img?.url?.portrait ?? null,
232
+ general: img?.url?.general ?? null,
233
+ jpeg: img?.url?.jpeg ?? null
234
+ }
235
+ });
236
+ var normalizeAgencyCard = (raw) => ({
237
+ id: raw?.id ?? "",
238
+ title: raw?.title ?? "",
239
+ slug: raw?.slug ?? "",
240
+ agencySlug: raw?.agencySlug ?? "",
241
+ totalDays: Number(raw?.totalDays ?? 0),
242
+ minPrice: Number(raw?.minPrice ?? 0),
243
+ maxPrice: Number(raw?.maxPrice ?? 0),
244
+ rating: Number(raw?.rating ?? 0),
245
+ packageCategory: raw?.packageCategory ?? "",
246
+ thumbnail: normalizeImage2(raw?.thumbnail)
247
+ });
248
+ var AgenciesResource = class {
249
+ constructor(http) {
250
+ this.http = http;
251
+ }
252
+ /** Public profile of an agency by its slug. Null on 404. */
253
+ async getBySlug(slug, options) {
254
+ if (!slug) throw new Error("[TravoriesClient] agencies.getBySlug requires a slug");
255
+ const raw = await this.http.request(`/agency-info/by-slug/${slug}`, {
256
+ silent: true,
257
+ ...options
258
+ });
259
+ if (!raw?.hostDetails) return null;
260
+ return {
261
+ success: raw.success,
262
+ message: raw.message,
263
+ hostDetails: {
264
+ ...raw.hostDetails,
265
+ logo: raw.hostDetails.logo ? normalizeImage2(raw.hostDetails.logo) : null
266
+ }
267
+ };
268
+ }
269
+ /** Partner / association badges shown on the agency profile. */
270
+ async getAssociations(slug, options) {
271
+ if (!slug) throw new Error("[TravoriesClient] agencies.getAssociations requires a slug");
272
+ const raw = await this.http.request(
273
+ `/agency-association/agency/slug/${slug}`,
274
+ { silent: true, ...options }
275
+ );
276
+ if (!Array.isArray(raw)) return [];
277
+ return raw.map((a) => ({
278
+ id: a.id,
279
+ name: a.name,
280
+ url: a.url,
281
+ image: a.image ? normalizeImage2(a.image) : null
282
+ }));
283
+ }
284
+ /**
285
+ * Packages published by this agency. Returns the same card shape as the home
286
+ * sections so `<PackagesCarousel>` / `<PackageCard>` render them directly.
287
+ */
288
+ async getPackages(slug, params, options) {
289
+ if (!slug) throw new Error("[TravoriesClient] agencies.getPackages requires a slug");
290
+ const limit = params?.limit ?? 10;
291
+ const page = params?.page ?? 1;
292
+ const raw = await this.http.request(
293
+ `/agency-package/by-agency/${slug}?limit=${limit}&page=${page}`,
294
+ { silent: true, ...options }
295
+ );
296
+ if (!raw) return [];
297
+ const list = Array.isArray(raw) ? raw : Array.isArray(raw.packages) ? raw.packages : [];
298
+ return list.map(normalizeAgencyCard);
299
+ }
300
+ /**
301
+ * Convenience: fetch the full agency bundle (profile + associations + their
302
+ * packages) in parallel. Drives `<AgencyDetailView />`.
303
+ */
304
+ async getBundle(slug, params, options) {
305
+ const [agency, associations, packages] = await Promise.all([
306
+ this.getBySlug(slug, options),
307
+ this.getAssociations(slug, options),
308
+ this.getPackages(slug, { limit: params?.packagesLimit ?? 12 }, options)
309
+ ]);
310
+ if (!agency?.hostDetails) return null;
311
+ return {
312
+ agency: agency.hostDetails,
313
+ associations,
314
+ packages
315
+ };
316
+ }
317
+ };
318
+
319
+ // src/api/bookings.ts
320
+ var BookingsResource = class {
321
+ constructor(http) {
322
+ this.http = http;
323
+ }
324
+ /**
325
+ * Open a booking. The BE returns a booking UUID — combine it with
326
+ * `https://travories.com/package/<id>/payment`
327
+ * to send the user into the existing payment flow.
328
+ *
329
+ * Throws (not silent) so the consumer can surface errors to the user. Wrap
330
+ * in try/catch in your `onReserve` handler.
331
+ */
332
+ async initiate(payload, options) {
333
+ if (!payload?.packageId) {
334
+ throw new Error("[TravoriesClient] bookings.initiate requires packageId");
335
+ }
336
+ if (!payload?.arrivalDate) {
337
+ throw new Error("[TravoriesClient] bookings.initiate requires arrivalDate");
338
+ }
339
+ if (!payload?.travelers?.length) {
340
+ throw new Error("[TravoriesClient] bookings.initiate requires at least one traveler");
341
+ }
342
+ const res = await this.http.request(
343
+ `/booking/initiate`,
344
+ {
345
+ method: "POST",
346
+ body: payload,
347
+ silent: false,
348
+ ...options
349
+ }
350
+ );
351
+ if (!res?.data) {
352
+ throw new Error("[TravoriesClient] bookings.initiate returned no booking id");
353
+ }
354
+ return res;
355
+ }
356
+ };
357
+
219
358
  // src/client/TravoriesClient.ts
220
359
  var TravoriesClient = class {
221
360
  constructor(config) {
222
- /** Shortcut for `client.packages.getBySlug(slug)`. */
361
+ // ---- Convenience shortcuts on the client itself (no need to remember the
362
+ // resource name for the common one-shot lookups). -------------------
223
363
  this.getPackageBySlug = (slug) => this.packages.getBySlug(slug);
224
- /** Shortcut for `client.packages.getBundle(slug)` — package + host + attractions in one call. */
225
364
  this.getPackageBundle = (slug) => this.packages.getBundle(slug);
365
+ this.getAgencyBySlug = (slug) => this.agencies.getBySlug(slug);
366
+ this.getAgencyBundle = (slug) => this.agencies.getBundle(slug);
226
367
  this.http = new HttpClient(config);
227
368
  this.packages = new PackagesResource(this.http);
369
+ this.agencies = new AgenciesResource(this.http);
370
+ this.bookings = new BookingsResource(this.http);
228
371
  }
229
372
  };
230
373
  function createTravoriesClient(config) {
@@ -332,6 +475,40 @@ function useHomeSections(client) {
332
475
  }, [client]);
333
476
  return { data, loading, error, refetch: run };
334
477
  }
478
+ function useAgencyBundle(client, slug) {
479
+ const [data, setData] = react.useState(null);
480
+ const [loading, setLoading] = react.useState(Boolean(client && slug));
481
+ const [error, setError] = react.useState(null);
482
+ const reqId = react.useRef(0);
483
+ const run = () => {
484
+ if (!client || !slug) {
485
+ setData(null);
486
+ setLoading(false);
487
+ setError(null);
488
+ return;
489
+ }
490
+ const myReq = ++reqId.current;
491
+ setLoading(true);
492
+ setError(null);
493
+ client.agencies.getBundle(slug).then((res) => {
494
+ if (myReq !== reqId.current) return;
495
+ setData(res);
496
+ }).catch((err) => {
497
+ if (myReq !== reqId.current) return;
498
+ setError(err instanceof Error ? err : new Error(String(err)));
499
+ }).finally(() => {
500
+ if (myReq !== reqId.current) return;
501
+ setLoading(false);
502
+ });
503
+ };
504
+ react.useEffect(() => {
505
+ run();
506
+ return () => {
507
+ reqId.current++;
508
+ };
509
+ }, [client, slug]);
510
+ return { data, loading, error, refetch: run };
511
+ }
335
512
 
336
513
  // src/utils/format.ts
337
514
  function pickImageUrl(img) {
@@ -366,7 +543,7 @@ var PackageCard = ({
366
543
  onSelect,
367
544
  href,
368
545
  openInNewTab = false,
369
- showHeart = true,
546
+ showHeart = false,
370
547
  liked,
371
548
  onLike
372
549
  }) => {
@@ -820,16 +997,21 @@ var BookingCardLite = ({
820
997
  (o) => o.id === id ? { ...o, count: Math.max(0, o.count + (inc ? 1 : -1)) } : o
821
998
  )
822
999
  );
1000
+ const [isSubmitting, setIsSubmitting] = react.useState(false);
823
1001
  const handleReserve = () => {
824
1002
  if (!onReserve) return;
825
1003
  if (allPeopleCount === 0) return;
826
- onReserve({
1004
+ const result = onReserve({
827
1005
  arrival,
828
1006
  departure,
829
1007
  travelers: options.filter((o) => o.count > 0),
830
1008
  totalCost,
831
1009
  pricePerPerson: currentPrice
832
1010
  });
1011
+ if (result && typeof result.then === "function") {
1012
+ setIsSubmitting(true);
1013
+ result.finally(() => setIsSubmitting(false));
1014
+ }
833
1015
  };
834
1016
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full sm:w-full lg:w-[520px] h-fit border rounded-xl shadow-md px-4 sm:px-6 bg-white flex flex-col gap-6 py-8 sm:py-10", children: [
835
1017
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
@@ -989,9 +1171,9 @@ var BookingCardLite = ({
989
1171
  {
990
1172
  type: "button",
991
1173
  onClick: handleReserve,
992
- disabled: allPeopleCount === 0 || !onReserve,
1174
+ disabled: allPeopleCount === 0 || !onReserve || isSubmitting,
993
1175
  className: "w-full py-2 md:py-3 bg-primary-normal text-white font-semibold rounded-lg hover:bg-primary-normal-hover transition text-sm md:text-base disabled:opacity-60 disabled:cursor-not-allowed",
994
- children: allPeopleCount === 0 ? "Reserve Now" : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1176
+ children: isSubmitting ? "Initiating\u2026" : allPeopleCount === 0 ? "Reserve Now" : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
995
1177
  "Book Now - ",
996
1178
  formatCurrency(totalCost, currency)
997
1179
  ] })
@@ -1951,44 +2133,90 @@ var getMonthsHosting = (createdDate) => {
1951
2133
  );
1952
2134
  return Math.max(1, monthsDiff);
1953
2135
  };
1954
- var HostCard = ({ hostData, className = "" }) => {
1955
- const logoUrl = pickImageUrl(hostData?.logo);
1956
- return /* @__PURE__ */ jsxRuntime.jsxs(
1957
- "div",
1958
- {
1959
- className: `w-full sm:min-w-[320px] rounded-2xl border border-[#E0E4E8] bg-white flex flex-col gap-6 p-6 lg:p-8 shadow-md ${className}`,
1960
- children: [
1961
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
1962
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative rounded-full h-20 w-20 bg-gray-200 flex items-center justify-center text-xl text-primary-normal overflow-hidden", children: logoUrl ? /* @__PURE__ */ jsxRuntime.jsx(
1963
- "img",
1964
- {
1965
- src: logoUrl,
1966
- alt: `${hostData?.username}'s logo`,
1967
- className: "object-cover w-full h-full"
1968
- }
1969
- ) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: getUserInitials(hostData?.username) }) }),
1970
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[18px] tracking-[-0.02em] font-medium text-primary-normal whitespace-normal break-words", children: hostData?.username })
1971
- ] }),
1972
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between text-center mt-2", children: [
1973
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1974
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: hostData?.review ?? 0 }),
1975
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Reviews" })
1976
- ] }),
1977
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1978
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: (hostData?.rating ?? 0).toFixed(2) }),
1979
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Rating" })
1980
- ] }),
1981
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1982
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: [
1983
- getMonthsHosting(hostData?.agencyCreatedDate),
1984
- " mth"
1985
- ] }),
1986
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Hosting" })
1987
- ] })
1988
- ] })
1989
- ]
2136
+ var HostCard = ({
2137
+ hostData,
2138
+ onAgencyClick,
2139
+ href,
2140
+ openInNewTab,
2141
+ className = ""
2142
+ }) => {
2143
+ const data = hostData;
2144
+ const displayName = data.agencyName || data.username;
2145
+ const logoUrl = pickImageUrl(data?.logo);
2146
+ const isClickable = Boolean(onAgencyClick || href);
2147
+ const handleAnchorClick = (e) => {
2148
+ if (e.metaKey || e.ctrlKey || e.button === 1) return;
2149
+ if (openInNewTab) return;
2150
+ if (onAgencyClick) {
2151
+ e.preventDefault();
2152
+ onAgencyClick(data.slug);
1990
2153
  }
1991
- );
2154
+ };
2155
+ const body = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
2156
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
2157
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative rounded-full h-20 w-20 bg-gray-200 flex items-center justify-center text-xl text-primary-normal overflow-hidden", children: logoUrl ? /* @__PURE__ */ jsxRuntime.jsx(
2158
+ "img",
2159
+ {
2160
+ src: logoUrl,
2161
+ alt: `${displayName}'s logo`,
2162
+ className: "object-cover w-full h-full"
2163
+ }
2164
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: getUserInitials(displayName) }) }),
2165
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[18px] tracking-[-0.02em] font-medium text-primary-normal whitespace-normal break-words", children: displayName })
2166
+ ] }),
2167
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between text-center mt-2", children: [
2168
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2169
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: data?.review ?? 0 }),
2170
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Reviews" })
2171
+ ] }),
2172
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2173
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: (data?.rating ?? 0).toFixed(2) }),
2174
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Rating" })
2175
+ ] }),
2176
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2177
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: [
2178
+ getMonthsHosting(data?.agencyCreatedDate),
2179
+ " mth"
2180
+ ] }),
2181
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Hosting" })
2182
+ ] })
2183
+ ] })
2184
+ ] });
2185
+ const wrapperClass = `w-full sm:min-w-[320px] rounded-2xl border border-[#E0E4E8] bg-white p-6 lg:p-8 shadow-md ${isClickable ? "cursor-pointer transition-shadow hover:shadow-lg" : ""} ${className}`.trim();
2186
+ if (href) {
2187
+ return /* @__PURE__ */ jsxRuntime.jsx(
2188
+ "a",
2189
+ {
2190
+ href,
2191
+ target: openInNewTab ? "_blank" : void 0,
2192
+ rel: openInNewTab ? "noopener noreferrer" : void 0,
2193
+ onClick: handleAnchorClick,
2194
+ className: `${wrapperClass} block no-underline text-inherit`,
2195
+ "aria-label": openInNewTab ? `View ${displayName} (opens in a new tab)` : `View ${displayName}`,
2196
+ children: body
2197
+ }
2198
+ );
2199
+ }
2200
+ if (onAgencyClick) {
2201
+ return /* @__PURE__ */ jsxRuntime.jsx(
2202
+ "div",
2203
+ {
2204
+ role: "button",
2205
+ tabIndex: 0,
2206
+ onClick: () => onAgencyClick(data.slug),
2207
+ onKeyDown: (e) => {
2208
+ if (e.key === "Enter" || e.key === " ") {
2209
+ e.preventDefault();
2210
+ onAgencyClick(data.slug);
2211
+ }
2212
+ },
2213
+ className: wrapperClass,
2214
+ "aria-label": `View ${displayName}`,
2215
+ children: body
2216
+ }
2217
+ );
2218
+ }
2219
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: wrapperClass, children: body });
1992
2220
  };
1993
2221
  var HostCard_default = HostCard;
1994
2222
  var GalleryImg = ({
@@ -2278,6 +2506,9 @@ function PackageDetailView({
2278
2506
  initialBundle,
2279
2507
  currency = "USD",
2280
2508
  onReserve,
2509
+ onSelectHost,
2510
+ agencyHrefFor,
2511
+ openAgencyInNewTab,
2281
2512
  className,
2282
2513
  renderLoading,
2283
2514
  renderNotFound
@@ -2311,6 +2542,9 @@ function PackageDetailView({
2311
2542
  routes: bundle.routes ?? [],
2312
2543
  currency,
2313
2544
  onReserve,
2545
+ onSelectHost,
2546
+ agencyHrefFor,
2547
+ openAgencyInNewTab,
2314
2548
  className
2315
2549
  }
2316
2550
  );
@@ -2321,6 +2555,9 @@ function DetailContent({
2321
2555
  routes,
2322
2556
  currency,
2323
2557
  onReserve,
2558
+ onSelectHost,
2559
+ agencyHrefFor,
2560
+ openAgencyInNewTab,
2324
2561
  className
2325
2562
  }) {
2326
2563
  const topData = buildTopData(pkg, host);
@@ -2341,7 +2578,16 @@ function DetailContent({
2341
2578
  host && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-6 sm:py-8 border-b-2 border-gray-200 flex flex-col gap-6", children: [
2342
2579
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-primary-normal text-xl md:text-2xl font-medium tracking-[-0.04em]", children: "Host Details" }),
2343
2580
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col lg:flex-row gap-8 lg:gap-10 h-full items-start lg:items-center", children: [
2344
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-6 sm:gap-8 w-full sm:w-[320px]", children: /* @__PURE__ */ jsxRuntime.jsx(HostCard_default, { hostData: host, className: "w-full" }) }),
2581
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-6 sm:gap-8 w-full sm:w-[320px]", children: /* @__PURE__ */ jsxRuntime.jsx(
2582
+ HostCard_default,
2583
+ {
2584
+ hostData: host,
2585
+ onAgencyClick: onSelectHost ? () => onSelectHost(host) : void 0,
2586
+ href: agencyHrefFor ? agencyHrefFor(host) : void 0,
2587
+ openInNewTab: openAgencyInNewTab,
2588
+ className: "w-full"
2589
+ }
2590
+ ) }),
2345
2591
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full lg:w-4/5 h-full flex flex-col justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
2346
2592
  HostAbout_default,
2347
2593
  {
@@ -2369,8 +2615,182 @@ function DefaultLoading() {
2369
2615
  ] })
2370
2616
  ] });
2371
2617
  }
2618
+ var AgencyAssociations = ({
2619
+ associations,
2620
+ title = "We are associated with",
2621
+ className
2622
+ }) => {
2623
+ if (!associations?.length) return null;
2624
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: `flex flex-col gap-4 mt-2 ${className ?? ""}`.trim(), children: [
2625
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl md:text-2xl font-medium tracking-[-0.04em] text-primary-normal", children: title }),
2626
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-wrap gap-6 items-center justify-start list-none p-0 m-0", children: associations.map((assoc) => {
2627
+ const img = pickImageUrl(assoc.image);
2628
+ return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(
2629
+ "a",
2630
+ {
2631
+ href: assoc.url,
2632
+ target: "_blank",
2633
+ rel: "noopener noreferrer",
2634
+ title: assoc.name,
2635
+ "aria-label": assoc.name,
2636
+ className: "relative w-32 h-20 flex items-center justify-center hover:opacity-80 transition-opacity rounded-lg p-2 bg-white border border-[#E0E4E8]",
2637
+ children: img ? /* @__PURE__ */ jsxRuntime.jsx(
2638
+ "img",
2639
+ {
2640
+ src: img,
2641
+ alt: assoc.image?.alt || assoc.name,
2642
+ loading: "lazy",
2643
+ className: "max-w-full max-h-full object-contain"
2644
+ }
2645
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[#47586E] text-xs text-center leading-tight", children: assoc.name })
2646
+ }
2647
+ ) }, assoc.id);
2648
+ }) })
2649
+ ] });
2650
+ };
2651
+ var AgencyAssociations_default = AgencyAssociations;
2652
+ function AgencyDetailView({
2653
+ client,
2654
+ slug,
2655
+ initialBundle,
2656
+ currency = "USD",
2657
+ onSelectPackage,
2658
+ packageHrefFor,
2659
+ openPackagesInNewTab,
2660
+ className,
2661
+ renderLoading,
2662
+ renderNotFound
2663
+ }) {
2664
+ if (!initialBundle && (!client || !slug)) {
2665
+ throw new Error(
2666
+ "[AgencyDetailView] Provide either `initialBundle` or both `client` and `slug`."
2667
+ );
2668
+ }
2669
+ const remote = useAgencyBundle(
2670
+ initialBundle ? null : client ?? null,
2671
+ initialBundle ? null : slug ?? null
2672
+ );
2673
+ const bundle = initialBundle ?? remote.data;
2674
+ const loading = !initialBundle && remote.loading;
2675
+ const error = !initialBundle && remote.error;
2676
+ if (loading) {
2677
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `tvr-package-detail ${className ?? ""}`.trim(), children: renderLoading ? renderLoading() : /* @__PURE__ */ jsxRuntime.jsx(DefaultLoading2, {}) });
2678
+ }
2679
+ if (error) {
2680
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `tvr-package-detail ${className ?? ""}`.trim(), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-screen-xl mx-auto px-6 py-16 text-center text-red-600 text-sm", children: [
2681
+ "Failed to load agency: ",
2682
+ error.message
2683
+ ] }) });
2684
+ }
2685
+ if (!bundle?.agency) {
2686
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `tvr-package-detail ${className ?? ""}`.trim(), children: renderNotFound ? renderNotFound() : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-screen-xl mx-auto px-6 py-16 text-center text-secondary-normal-hover text-sm", children: "Agency not found." }) });
2687
+ }
2688
+ return /* @__PURE__ */ jsxRuntime.jsx(
2689
+ DetailContent2,
2690
+ {
2691
+ agency: bundle.agency,
2692
+ associations: bundle.associations,
2693
+ packages: bundle.packages,
2694
+ currency,
2695
+ onSelectPackage,
2696
+ packageHrefFor,
2697
+ openPackagesInNewTab,
2698
+ className
2699
+ }
2700
+ );
2701
+ }
2702
+ function DetailContent2({
2703
+ agency,
2704
+ associations,
2705
+ packages,
2706
+ currency,
2707
+ onSelectPackage,
2708
+ packageHrefFor,
2709
+ openPackagesInNewTab,
2710
+ className
2711
+ }) {
2712
+ const displayName = agency.agencyName || agency.username;
2713
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `tvr-package-detail ${className ?? ""}`.trim(), children: /* @__PURE__ */ jsxRuntime.jsxs("article", { className: "mx-auto max-w-[1440px] flex flex-col gap-8 md:px-12 px-6 lg:py-10 py-6", children: [
2714
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-2", children: [
2715
+ /* @__PURE__ */ jsxRuntime.jsxs(
2716
+ "nav",
2717
+ {
2718
+ "aria-label": "Breadcrumb",
2719
+ className: "flex items-center gap-2 text-sm",
2720
+ children: [
2721
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: "/", className: "text-secondary hover:underline", children: "Home" }),
2722
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "text-secondary", children: "\u203A" }),
2723
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-secondary underline font-medium", children: displayName })
2724
+ ]
2725
+ }
2726
+ ),
2727
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl md:text-2xl font-medium text-primary-normal leading-tight", children: displayName })
2728
+ ] }),
2729
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "flex flex-col lg:flex-row items-stretch gap-8 pb-8 border-b border-[#E0E4E8]", children: [
2730
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full lg:w-[320px] flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(HostCard_default, { hostData: agency, className: "w-full" }) }),
2731
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col gap-5 pt-2", children: [
2732
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2733
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "lg:text-2xl text-xl tracking-[-0.04em] font-medium text-primary-normal", children: "Overview" }),
2734
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-secondary font-medium md:text-lg text-sm", children: [
2735
+ /* @__PURE__ */ jsxRuntime.jsx(
2736
+ react$1.Icon,
2737
+ {
2738
+ icon: "material-symbols:verified-rounded",
2739
+ className: "lg:w-6 lg:h-6 w-4 h-4"
2740
+ }
2741
+ ),
2742
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Verified Agency" })
2743
+ ] })
2744
+ ] }),
2745
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lg:text-lg text-sm text-[#47586E] leading-relaxed", children: agency.description || `Verified Nepal travel agency on Travories.` })
2746
+ ] })
2747
+ ] }),
2748
+ associations.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2749
+ /* @__PURE__ */ jsxRuntime.jsx(AgencyAssociations_default, { associations }),
2750
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-[#E0E4E8]" })
2751
+ ] }),
2752
+ packages.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("section", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxRuntime.jsx(
2753
+ PackagesCarousel_default,
2754
+ {
2755
+ title: `Popular Packages from ${displayName}`,
2756
+ packages,
2757
+ currency,
2758
+ onSelect: onSelectPackage,
2759
+ hrefFor: packageHrefFor,
2760
+ openInNewTab: openPackagesInNewTab
2761
+ }
2762
+ ) })
2763
+ ] }) });
2764
+ }
2765
+ function DefaultLoading2() {
2766
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto max-w-[1440px] px-6 md:px-12 py-8 animate-pulse", children: [
2767
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-32 bg-gray-200 rounded mb-3" }),
2768
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 w-72 bg-gray-200 rounded mb-8" }),
2769
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col lg:flex-row gap-8 mb-10", children: [
2770
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full lg:w-[320px] h-48 bg-gray-100 rounded-2xl" }),
2771
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 space-y-3", children: [
2772
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-6 w-40 bg-gray-200 rounded" }),
2773
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-full bg-gray-100 rounded" }),
2774
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-5/6 bg-gray-100 rounded" }),
2775
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-2/3 bg-gray-100 rounded" })
2776
+ ] })
2777
+ ] }),
2778
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-4 overflow-hidden", children: Array.from({ length: 4 }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(
2779
+ "div",
2780
+ {
2781
+ className: "w-[300px] shrink-0 rounded-xl bg-gray-100",
2782
+ style: { height: 280 }
2783
+ },
2784
+ i
2785
+ )) })
2786
+ ] });
2787
+ }
2372
2788
 
2789
+ exports.AgenciesResource = AgenciesResource;
2790
+ exports.AgencyAssociations = AgencyAssociations_default;
2791
+ exports.AgencyDetailView = AgencyDetailView;
2373
2792
  exports.BookingCardLite = BookingCardLite_default;
2793
+ exports.BookingsResource = BookingsResource;
2374
2794
  exports.DescriptionSection = DescriptionSection_default;
2375
2795
  exports.GallerySection = GallerySection_default;
2376
2796
  exports.HomeSections = HomeSections;
@@ -2398,6 +2818,7 @@ exports.formatCurrency = formatCurrency;
2398
2818
  exports.formatRating = formatRating;
2399
2819
  exports.pickImageUrl = pickImageUrl;
2400
2820
  exports.startingPrice = startingPrice;
2821
+ exports.useAgencyBundle = useAgencyBundle;
2401
2822
  exports.useHomeSections = useHomeSections;
2402
2823
  exports.useHomeSectionsContext = useHomeSectionsContext;
2403
2824
  exports.usePackageBundle = usePackageBundle;