@v-office/website-sdk 1.0.0 → 1.1.0

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.
@@ -1,6 +1,6 @@
1
1
  import { t as CMSError } from "./errors-2cuUGSvi.mjs";
2
- import { a as toNightCount, c as localeToLanguage, d as daysBetweenLocalDates, i as firstString$1, l as toIsoDateFromPeriodQueryDate, n as asRecord, o as toCountry, r as firstNumber, s as makeTranslate, t as asArray, u as toYearMonthFromPeriodQueryMonth } from "./parser-D6UAf8Ld.mjs";
3
- import { n as formatLabeledDistance, r as isDistanceAttributeKey, t as renderCustomAttributeHighlight } from "./custom-attribute-ChCbJKf_.mjs";
2
+ import { C as daysBetweenLocalDates, O as UnresolvableMultiRate, S as toYearMonthFromPeriodQueryMonth, T as AmbiguousMultiRate, _ as toFormattedSearchPrice, a as selectGuestQuoteCancellationPolicySelection, b as localeToLanguage, c as getGuestQuoteCancellationPolicySelection, d as formatCurrency, f as asArray, h as firstString$1, i as removeGuestQuoteAdditionalServiceSelection, l as getGuestQuoteInput, m as firstNumber, n as addGuestQuoteAdditionalServiceSelection, o as withGuestQuoteInsurance, p as asRecord, r as clearGuestQuoteAdditionalServiceSelections, s as getGuestQuoteBackendContext, u as getGuestQuoteMultiRateContext, v as toCountry, x as toIsoDateFromPeriodQueryDate, y as makeTranslate } from "./quote-CRjV_lf-.mjs";
3
+ import { n as formatLabeledDistance, r as isDistanceAttributeKey, t as renderCustomAttributeHighlight } from "./custom-attribute-D5Kb1YHA.mjs";
4
4
  import { Cache, Clock, Context, Data, DateTime, Duration, Effect, Layer, ManagedRuntime, Option, Ref, Schema, SchemaIssue, SchemaTransformation, Semaphore } from "effect";
5
5
  import { print } from "graphql";
6
6
  import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/unstable/http";
@@ -15449,547 +15449,6 @@ Schema.Literals(["de-DE", "en-US"]);
15449
15449
  Schema.String.pipe(Schema.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/)));
15450
15450
  Schema.String.check(Schema.isPattern(/^[A-Z]{2}$/)).annotate({ description: "ISO 3166-1 alpha-2 country code, e.g. DE for Germany" });
15451
15451
  //#endregion
15452
- //#region src/domain/quote/error.ts
15453
- var InvalidAdditionalServiceQuantity = class extends Data.TaggedError("InvalidAdditionalServiceQuantity") {};
15454
- var UnknownAdditionalService = class extends Data.TaggedError("UnknownAdditionalService") {};
15455
- var AdditionalServiceLimitExceeded = class extends Data.TaggedError("AdditionalServiceLimitExceeded") {};
15456
- var UnknownCancellationPolicy = class extends Data.TaggedError("UnknownCancellationPolicy") {};
15457
- var UnavailableCancellationPolicyQuote = class extends Data.TaggedError("UnavailableCancellationPolicyQuote") {};
15458
- var UnresolvableMultiRate = class extends Data.TaggedError("UnresolvableMultiRate") {};
15459
- var AmbiguousMultiRate = class extends Data.TaggedError("AmbiguousMultiRate") {};
15460
- //#endregion
15461
- //#region src/domain/insurance/index.ts
15462
- const InsuranceOptionKindNone = Schema.Literal("none");
15463
- const InsuranceOptionKindInsurance = Schema.Literal("insurance");
15464
- const InsurancePaymentOptionSEPA = Schema.Literal("sepa_debit");
15465
- const InsurancePaymentOptionExternalURL = Schema.Literal("external_url");
15466
- const NoInsuranceOptionOutputSchema = Schema.Struct({
15467
- kind: InsuranceOptionKindNone,
15468
- label: Schema.String,
15469
- description: Schema.optionalKey(Schema.String)
15470
- });
15471
- const InsuranceRequiredInformationNone = Schema.Literal("none");
15472
- const InsuranceRequiredInformationTravelers = Schema.Literal("travelers");
15473
- const InsuranceRequiredInformationSchema = Schema.Union([Schema.Struct({ kind: InsuranceRequiredInformationNone }), Schema.Struct({ kind: InsuranceRequiredInformationTravelers })]);
15474
- const InsuranceResourceSchema = Schema.Struct({
15475
- label: Schema.String,
15476
- url: Schema.String
15477
- });
15478
- const InsuranceOptionOutputSchema = Schema.Struct({
15479
- kind: InsuranceOptionKindInsurance,
15480
- id: Schema.String,
15481
- formattedPrice: Schema.String,
15482
- label: Schema.String,
15483
- requiredInformation: InsuranceRequiredInformationSchema,
15484
- description: Schema.optionalKey(Schema.String),
15485
- logoUrl: Schema.optionalKey(Schema.String),
15486
- features: Schema.optionalKey(Schema.Array(Schema.String)),
15487
- resources: Schema.optionalKey(Schema.Array(InsuranceResourceSchema))
15488
- });
15489
- const SelectableInsuranceOptionOutputSchema = Schema.Union([NoInsuranceOptionOutputSchema, InsuranceOptionOutputSchema]);
15490
- const InsuranceTravelerSchema = Schema.Struct({
15491
- salutation: Schema.String,
15492
- forename: Schema.String,
15493
- surname: Schema.String,
15494
- title: Schema.optionalKey(Schema.String),
15495
- birthday: Schema.optionalKey(Schema.String)
15496
- });
15497
- const SelectedInsuranceInformationInputSchema = Schema.Union([Schema.Struct({ kind: InsuranceOptionKindNone }), Schema.Struct({
15498
- kind: InsuranceOptionKindInsurance,
15499
- id: Schema.String,
15500
- travelers: Schema.optionalKey(Schema.Array(InsuranceTravelerSchema))
15501
- })]);
15502
- const InsuranceCustomerInformationInputSchema = Schema.Struct({
15503
- destinationCountryCode: Schema.String,
15504
- address: Schema.Struct({
15505
- street: Schema.String,
15506
- housenumber: Schema.optionalKey(Schema.String),
15507
- postalcode: Schema.String,
15508
- city: Schema.String,
15509
- countryCode: Schema.String
15510
- }),
15511
- email: Schema.String,
15512
- mobile: Schema.String
15513
- });
15514
- const InsuranceDocumentSchema = Schema.Struct({
15515
- label: Schema.String,
15516
- url: Schema.String
15517
- });
15518
- const InsurancePreContractOutputSchema = Schema.Union([
15519
- Schema.Struct({ kind: Schema.Literal("none_selected") }),
15520
- Schema.Struct({ kind: Schema.Literal("not_required") }),
15521
- Schema.Struct({
15522
- kind: Schema.Literal("created"),
15523
- id: Schema.String,
15524
- documents: Schema.optionalKey(Schema.Array(InsuranceDocumentSchema))
15525
- })
15526
- ]);
15527
- const InsurancePaymentOptionOutputSchema = Schema.Union([Schema.Struct({
15528
- kind: InsurancePaymentOptionSEPA,
15529
- label: Schema.String,
15530
- description: Schema.optionalKey(Schema.String)
15531
- }), Schema.Struct({
15532
- kind: InsurancePaymentOptionExternalURL,
15533
- label: Schema.String,
15534
- url: Schema.String,
15535
- description: Schema.optionalKey(Schema.String)
15536
- })]);
15537
- const InsurancePaymentInformationInputSchema = Schema.Union([Schema.Struct({
15538
- kind: InsurancePaymentOptionSEPA,
15539
- iban: Schema.String,
15540
- bic: Schema.optionalKey(Schema.String)
15541
- }), Schema.Struct({ kind: InsurancePaymentOptionExternalURL })]);
15542
- const GuestQuoteInsuranceSchema = Schema.Struct({
15543
- options: Schema.Array(SelectableInsuranceOptionOutputSchema),
15544
- selected: SelectedInsuranceInformationInputSchema,
15545
- preContract: InsurancePreContractOutputSchema,
15546
- paymentOptions: Schema.Array(InsurancePaymentOptionOutputSchema),
15547
- destinationCountryCode: Schema.optionalKey(Schema.String),
15548
- customerInformation: Schema.optionalKey(InsuranceCustomerInformationInputSchema),
15549
- paymentInformation: Schema.optionalKey(InsurancePaymentInformationInputSchema)
15550
- });
15551
- Schema.Union([
15552
- Schema.Struct({ kind: Schema.Literal("none_selected") }),
15553
- Schema.Struct({ kind: Schema.Literal("not_required") }),
15554
- Schema.Struct({
15555
- kind: Schema.Literal("booked"),
15556
- policyNumber: Schema.String,
15557
- documents: Schema.optionalKey(Schema.Array(InsuranceDocumentSchema))
15558
- })
15559
- ]);
15560
- //#endregion
15561
- //#region src/domain/quote/amount.ts
15562
- const NonNegativeAmountSchema = Schema.Number.check(Schema.isGreaterThanOrEqualTo(0));
15563
- const PositiveQuantitySchema = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
15564
- Schema.Union([
15565
- Schema.Literal("FLAT"),
15566
- Schema.Literal("PER_NIGHT"),
15567
- Schema.Literal("PER_DAY"),
15568
- Schema.Literal("PER_USAGE")
15569
- ]);
15570
- const AdditionalServiceSchema = Schema.Struct({
15571
- id: Schema.String,
15572
- label: Schema.String,
15573
- charge: Schema.String,
15574
- preSelectedQuantity: Schema.optionalKey(PositiveQuantitySchema),
15575
- maxPerBooking: Schema.optionalKey(PositiveQuantitySchema),
15576
- description: Schema.optionalKey(Schema.String),
15577
- images: Schema.optionalKey(Schema.Array(Schema.Struct({
15578
- src: Schema.String,
15579
- alt: Schema.String
15580
- })))
15581
- });
15582
- const toPublicAdditionalService = ({ chargeAmount: _chargeAmount, calculation: _calculation, leadTimeDays: _leadTimeDays, ...service }) => service;
15583
- //#endregion
15584
- //#region src/domain/quote/backend-context.ts
15585
- const withQuoteBackendContextSelections = (context, updateContext, selections) => {
15586
- if (context === void 0 || updateContext === void 0) return context;
15587
- return updateContext(context, selections);
15588
- };
15589
- //#endregion
15590
- //#region src/domain/quote/format-currency.ts
15591
- const formatCurrency = (amount, locale, currency) => new Intl.NumberFormat(locale, {
15592
- style: "currency",
15593
- currency
15594
- }).format(amount / 100);
15595
- //#endregion
15596
- //#region src/domain/quote/booking-card.ts
15597
- const GuestQuoteBookingCardModifierSchema = Schema.Struct({
15598
- label: Schema.String,
15599
- amount: Schema.String
15600
- });
15601
- const GuestQuoteBookingCardItemSchema = Schema.Struct({
15602
- position: Schema.String,
15603
- appliedCharge: Schema.String,
15604
- modifiers: Schema.optionalKey(Schema.Array(GuestQuoteBookingCardModifierSchema)),
15605
- totalBeforeModifiers: Schema.optionalKey(Schema.String)
15606
- });
15607
- const GuestQuoteBookingCardLineSchema = Schema.Struct({
15608
- item: GuestQuoteBookingCardItemSchema,
15609
- subItems: Schema.optionalKey(Schema.Array(GuestQuoteBookingCardItemSchema))
15610
- });
15611
- const GuestQuoteBookingCardSectionSchema = Schema.Struct({ lines: Schema.Array(GuestQuoteBookingCardLineSchema) });
15612
- const GuestQuoteBookingCardSchema = Schema.Struct({
15613
- sections: Schema.Array(GuestQuoteBookingCardSectionSchema),
15614
- total: Schema.String,
15615
- totalBeforeModifiers: Schema.optionalKey(Schema.String)
15616
- });
15617
- const InternalGuestQuoteBookingCardModifierSchema = Schema.Struct({
15618
- label: Schema.String,
15619
- amount: Schema.Number
15620
- });
15621
- const InternalGuestQuoteBookingCardItemSchema = Schema.Struct({
15622
- position: Schema.String,
15623
- appliedCharge: Schema.Union([Schema.Number, Schema.String]),
15624
- modifiers: Schema.optionalKey(Schema.Array(InternalGuestQuoteBookingCardModifierSchema)),
15625
- totalBeforeModifiers: Schema.optionalKey(Schema.Number)
15626
- });
15627
- const InternalGuestQuoteBookingCardLineSchema = Schema.Struct({
15628
- item: InternalGuestQuoteBookingCardItemSchema,
15629
- subItems: Schema.optionalKey(Schema.Array(InternalGuestQuoteBookingCardItemSchema))
15630
- });
15631
- const InternalGuestQuoteBookingCardSectionSchema = Schema.Struct({ lines: Schema.Array(InternalGuestQuoteBookingCardLineSchema) });
15632
- const InternalGuestQuoteBookingCardSchema = Schema.Struct({
15633
- sections: Schema.Array(InternalGuestQuoteBookingCardSectionSchema),
15634
- total: NonNegativeAmountSchema,
15635
- totalBeforeModifiers: Schema.optionalKey(NonNegativeAmountSchema)
15636
- });
15637
- const toModifierDifference = (modifiers) => (modifiers ?? []).reduce((total, modifier) => total - modifier.amount, 0);
15638
- const toDerivedItemTotalBeforeModifiers = (item) => {
15639
- if (typeof item.appliedCharge === "string") return void 0;
15640
- const modifierDifference = toModifierDifference(item.modifiers);
15641
- if (modifierDifference === 0) return void 0;
15642
- return item.appliedCharge + modifierDifference;
15643
- };
15644
- const toDerivedTotalBeforeModifiers = (bookingCardInformation) => {
15645
- const modifierDifference = bookingCardInformation.sections.reduce((sectionTotal, section) => sectionTotal + section.lines.reduce((lineTotal, line) => lineTotal + toModifierDifference(line.item.modifiers) + (line.subItems ?? []).reduce((subItemTotal, item) => subItemTotal + toModifierDifference(item.modifiers), 0), 0), 0);
15646
- if (modifierDifference === 0) return void 0;
15647
- return bookingCardInformation.total + modifierDifference;
15648
- };
15649
- const toPublicModifiers = (modifiers, locale, currency) => {
15650
- if (modifiers === void 0) return void 0;
15651
- const modifiersByLabel = /* @__PURE__ */ new Map();
15652
- for (const modifier of modifiers) modifiersByLabel.set(modifier.label, (modifiersByLabel.get(modifier.label) ?? 0) + modifier.amount);
15653
- return Array.from(modifiersByLabel, ([label, amount]) => ({
15654
- label,
15655
- amount: formatCurrency(amount, locale, currency)
15656
- }));
15657
- };
15658
- const toPublicBookingCardItem = (item, locale, currency) => {
15659
- const totalBeforeModifiers = item.totalBeforeModifiers ?? toDerivedItemTotalBeforeModifiers(item);
15660
- const modifiers = toPublicModifiers(item.modifiers, locale, currency);
15661
- if (typeof item.appliedCharge === "string") return {
15662
- position: item.position,
15663
- appliedCharge: item.appliedCharge,
15664
- ...modifiers === void 0 ? {} : { modifiers },
15665
- ...totalBeforeModifiers === void 0 ? {} : { totalBeforeModifiers: formatCurrency(totalBeforeModifiers, locale, currency) }
15666
- };
15667
- return {
15668
- position: item.position,
15669
- appliedCharge: formatCurrency(item.appliedCharge, locale, currency),
15670
- ...modifiers === void 0 ? {} : { modifiers },
15671
- ...totalBeforeModifiers === void 0 ? {} : { totalBeforeModifiers: formatCurrency(totalBeforeModifiers, locale, currency) }
15672
- };
15673
- };
15674
- const toPublicBookingCardInformation = (bookingCardInformation, locale, currency) => {
15675
- const totalBeforeModifiers = bookingCardInformation.totalBeforeModifiers ?? toDerivedTotalBeforeModifiers(bookingCardInformation);
15676
- return {
15677
- sections: bookingCardInformation.sections.map((section) => ({ lines: section.lines.map((line) => ({
15678
- item: toPublicBookingCardItem(line.item, locale, currency),
15679
- ...line.subItems === void 0 ? {} : { subItems: line.subItems.map((item) => toPublicBookingCardItem(item, locale, currency)) }
15680
- })) })),
15681
- total: formatCurrency(bookingCardInformation.total, locale, currency),
15682
- ...totalBeforeModifiers === void 0 ? {} : { totalBeforeModifiers: formatCurrency(totalBeforeModifiers, locale, currency) }
15683
- };
15684
- };
15685
- //#endregion
15686
- //#region src/domain/quote/format-percentage.ts
15687
- const formatPercentage = (value, locale) => `${new Intl.NumberFormat(locale, { maximumFractionDigits: 2 }).format(value / 100)}%`;
15688
- //#endregion
15689
- //#region src/domain/quote/cancellation-policy.ts
15690
- Schema.Literals(["default", "alternative"]);
15691
- const CancellationRuleSchema = Schema.Struct({
15692
- daysBeforeArrival: Schema.Number,
15693
- refundPercentage: Schema.String
15694
- });
15695
- const CancellationPolicyOptionSchema = Schema.Struct({
15696
- id: Schema.String,
15697
- label: Schema.String,
15698
- description: Schema.optionalKey(Schema.String),
15699
- selected: Schema.Boolean,
15700
- rules: Schema.optionalKey(Schema.Array(CancellationRuleSchema)),
15701
- markUpPercentage: Schema.optionalKey(Schema.String),
15702
- processingFee: Schema.optionalKey(Schema.String)
15703
- });
15704
- const toPublicCancellationPolicyOption = ({ option, selection, locale, currency }) => ({
15705
- id: option.id,
15706
- label: option.label,
15707
- ...option.description === void 0 ? {} : { description: option.description },
15708
- selected: selection?.policyId === option.id,
15709
- ...option.rules === void 0 ? {} : { rules: option.rules.map((rule) => ({
15710
- daysBeforeArrival: rule.daysBeforeArrival,
15711
- refundPercentage: formatPercentage(rule.valuePercentage, locale)
15712
- })) },
15713
- ...option.markUpPercentage === void 0 ? {} : { markUpPercentage: formatPercentage(option.markUpPercentage, locale) },
15714
- ...option.processingFee === void 0 ? {} : { processingFee: formatCurrency(option.processingFee, locale, currency) }
15715
- });
15716
- //#endregion
15717
- //#region src/domain/quote/internal-state.ts
15718
- const GuestQuoteInternalState = Symbol("@v-office/cms-sdk/GuestQuoteInternalState");
15719
- const getGuestQuoteBackendContext = (quote) => quote[GuestQuoteInternalState].backendContext;
15720
- const getGuestQuoteInput = (quote) => quote[GuestQuoteInternalState].input;
15721
- const getGuestQuoteCancellationPolicySelection = (quote) => quote[GuestQuoteInternalState].cancellationPolicySelection;
15722
- const getGuestQuoteMultiRateContext = (quote) => quote[GuestQuoteInternalState].multiRateContext;
15723
- //#endregion
15724
- //#region src/domain/quote/selection.ts
15725
- const QuoteSelectionSchema = Schema.Struct({
15726
- id: Schema.String,
15727
- quantity: PositiveQuantitySchema
15728
- });
15729
- const parsePositiveQuantity = (quantity) => Schema.decodeUnknownEffect(PositiveQuantitySchema)(quantity).pipe(Effect.mapError((cause) => new InvalidAdditionalServiceQuantity({
15730
- quantity,
15731
- cause
15732
- })));
15733
- //#endregion
15734
- //#region src/domain/quote/guest-quote.ts
15735
- const GuestQuoteSelectionMutations = Symbol("@v-office/cms-sdk/GuestQuoteSelectionMutations");
15736
- const runGuestQuoteSelection = (effect) => Effect.runSync(effect.pipe(Effect.match({
15737
- onFailure: (error) => ({
15738
- ok: false,
15739
- error
15740
- }),
15741
- onSuccess: (quote) => ({
15742
- ok: true,
15743
- quote
15744
- })
15745
- })));
15746
- const addGuestQuoteAdditionalServiceSelection = ({ quote, id }) => quote[GuestQuoteSelectionMutations].addAdditionalService({ id });
15747
- const removeGuestQuoteAdditionalServiceSelection = ({ quote, id }) => quote[GuestQuoteSelectionMutations].removeAdditionalService({ id });
15748
- const clearGuestQuoteAdditionalServiceSelections = ({ quote }) => quote[GuestQuoteSelectionMutations].clearAdditionalServices();
15749
- const selectGuestQuoteCancellationPolicySelection = ({ quote, id }) => quote[GuestQuoteSelectionMutations].selectCancellationPolicy({ id });
15750
- const withGuestQuoteInsurance = ({ quote, insurance }) => quote[GuestQuoteSelectionMutations].withInsurance(insurance);
15751
- const toSelectedAdditionalServiceTotal = ({ input, selection, service }) => {
15752
- const chargeAmount = service.chargeAmount * selection.quantity;
15753
- switch (service.calculation) {
15754
- case "FLAT": return chargeAmount;
15755
- case "PER_USAGE": return chargeAmount;
15756
- case "PER_NIGHT": return chargeAmount * toNightCount(input);
15757
- case "PER_DAY": return chargeAmount * toNightCount(input);
15758
- }
15759
- };
15760
- const toAdditionalServicesTotal = (input, selections, additionalServices) => {
15761
- let total = 0;
15762
- for (const selection of selections) {
15763
- const service = additionalServices.find((additionalService) => additionalService.id === selection.id);
15764
- if (service !== void 0) total += toSelectedAdditionalServiceTotal({
15765
- input,
15766
- selection,
15767
- service
15768
- });
15769
- }
15770
- return total;
15771
- };
15772
- const toBookingCardInformation = ({ additionalServices, bookingCardInformation, additionalServicesTotal, input, selections, total }) => {
15773
- const lines = selections.flatMap((selection) => {
15774
- const service = additionalServices.find((additionalService) => additionalService.id === selection.id);
15775
- if (service === void 0) return [];
15776
- return [{ item: {
15777
- position: service.label,
15778
- appliedCharge: toSelectedAdditionalServiceTotal({
15779
- input,
15780
- selection,
15781
- service
15782
- })
15783
- } }];
15784
- });
15785
- return {
15786
- sections: lines.length === 0 ? bookingCardInformation.sections : [...bookingCardInformation.sections, { lines }],
15787
- total,
15788
- ...bookingCardInformation.totalBeforeModifiers === void 0 ? {} : { totalBeforeModifiers: bookingCardInformation.totalBeforeModifiers + additionalServicesTotal }
15789
- };
15790
- };
15791
- var GuestQuote = class GuestQuote extends Schema.Class("@v-office/cms-sdk/GuestQuote")({
15792
- bookingCardInformation: GuestQuoteBookingCardSchema,
15793
- additionalServices: Schema.Array(AdditionalServiceSchema),
15794
- cancellationPolicies: Schema.optionalKey(Schema.Array(CancellationPolicyOptionSchema)),
15795
- insurance: Schema.optionalKey(GuestQuoteInsuranceSchema)
15796
- }) {
15797
- #input;
15798
- #currency;
15799
- #baseTotal;
15800
- #bookingCardInformation;
15801
- #additionalServices;
15802
- #selections;
15803
- #cancellationPolicies;
15804
- #cancellationPolicySelection;
15805
- #cancellationPolicyQuoteVariants;
15806
- #multiRateContext;
15807
- constructor(props) {
15808
- const baseTotal = Schema.decodeUnknownSync(NonNegativeAmountSchema)(props.baseTotal);
15809
- const bookingCardInformation = Schema.decodeUnknownSync(InternalGuestQuoteBookingCardSchema)(props.bookingCardInformation);
15810
- const additionalServices = props.additionalServices.map((service) => ({
15811
- ...service,
15812
- chargeAmount: Schema.decodeUnknownSync(NonNegativeAmountSchema)(service.chargeAmount)
15813
- }));
15814
- const decodeSelection = Schema.decodeUnknownSync(QuoteSelectionSchema);
15815
- const selections = (props.selections ?? []).map((selection) => decodeSelection(selection));
15816
- const cancellationPolicies = props.cancellationPolicies ?? [];
15817
- const cancellationPolicySelection = props.cancellationPolicySelection ?? (cancellationPolicies[0] === void 0 ? void 0 : {
15818
- policyId: cancellationPolicies[0].id,
15819
- kind: cancellationPolicies[0].kind,
15820
- withAlternativeCancellationPolicy: cancellationPolicies[0].withAlternativeCancellationPolicy
15821
- });
15822
- const additionalServicesTotal = toAdditionalServicesTotal(props.input, selections, additionalServices);
15823
- const total = Schema.decodeUnknownSync(NonNegativeAmountSchema)(baseTotal + additionalServicesTotal);
15824
- const publicBookingCardInformation = toPublicBookingCardInformation(toBookingCardInformation({
15825
- additionalServices,
15826
- bookingCardInformation,
15827
- additionalServicesTotal,
15828
- input: props.input,
15829
- selections,
15830
- total
15831
- }), props.input.locale, props.currency);
15832
- super({
15833
- bookingCardInformation: publicBookingCardInformation,
15834
- additionalServices: additionalServices.map(toPublicAdditionalService),
15835
- ...cancellationPolicies.length === 0 ? {} : { cancellationPolicies: cancellationPolicies.map((option) => toPublicCancellationPolicyOption({
15836
- option,
15837
- locale: props.input.locale,
15838
- currency: props.currency,
15839
- ...cancellationPolicySelection === void 0 ? {} : { selection: cancellationPolicySelection }
15840
- })) },
15841
- ...props.insurance === void 0 ? {} : { insurance: props.insurance }
15842
- });
15843
- this.#input = props.input;
15844
- this.#currency = props.currency;
15845
- this.#baseTotal = baseTotal;
15846
- this.#bookingCardInformation = bookingCardInformation;
15847
- this.#additionalServices = additionalServices;
15848
- this.#selections = selections;
15849
- this.#cancellationPolicies = cancellationPolicies;
15850
- this.#cancellationPolicySelection = cancellationPolicySelection;
15851
- this.#cancellationPolicyQuoteVariants = props.cancellationPolicyQuoteVariants ?? [];
15852
- this.#multiRateContext = props.multiRateContext;
15853
- Object.defineProperty(this, GuestQuoteInternalState, { value: {
15854
- input: props.input,
15855
- ...props.backendContext === void 0 ? {} : { backendContext: props.backendContext },
15856
- ...props.updateBackendContext === void 0 ? {} : { updateBackendContext: props.updateBackendContext },
15857
- selections,
15858
- ...cancellationPolicySelection === void 0 ? {} : { cancellationPolicySelection },
15859
- ...props.multiRateContext === void 0 ? {} : { multiRateContext: props.multiRateContext }
15860
- } });
15861
- Object.defineProperty(this, GuestQuoteSelectionMutations, { value: {
15862
- addAdditionalService: (input) => runGuestQuoteSelection(this.addAdditionalServiceEffect(input.id, 1)),
15863
- removeAdditionalService: (input) => runGuestQuoteSelection(this.removeAdditionalServiceEffect(input.id, 1)),
15864
- clearAdditionalServices: () => this.clearAdditionalServicesSelection(),
15865
- selectCancellationPolicy: (input) => runGuestQuoteSelection(this.selectCancellationPolicyEffect(input.id)),
15866
- withInsurance: (insurance) => this.rebuild({ insurance })
15867
- } });
15868
- }
15869
- rebuild(props = {}) {
15870
- const backendContext = props.backendContext ?? this[GuestQuoteInternalState].backendContext;
15871
- const updateBackendContext = props.updateBackendContext ?? this[GuestQuoteInternalState].updateBackendContext;
15872
- const cancellationPolicySelection = props.cancellationPolicySelection ?? this.#cancellationPolicySelection;
15873
- const multiRateContext = props.multiRateContext ?? this.#multiRateContext;
15874
- return new GuestQuote({
15875
- input: props.input ?? this.#input,
15876
- bookingCardInformation: props.bookingCardInformation ?? this.#bookingCardInformation,
15877
- baseTotal: props.baseTotal ?? this.#baseTotal,
15878
- currency: props.currency ?? this.#currency,
15879
- additionalServices: props.additionalServices ?? this.#additionalServices,
15880
- selections: props.selections ?? this.#selections,
15881
- cancellationPolicies: props.cancellationPolicies ?? this.#cancellationPolicies,
15882
- cancellationPolicyQuoteVariants: props.cancellationPolicyQuoteVariants ?? this.#cancellationPolicyQuoteVariants,
15883
- ...backendContext === void 0 ? {} : { backendContext },
15884
- ...updateBackendContext === void 0 ? {} : { updateBackendContext },
15885
- ...cancellationPolicySelection === void 0 ? {} : { cancellationPolicySelection },
15886
- ...multiRateContext === void 0 ? {} : { multiRateContext },
15887
- ...props.insurance === void 0 ? this.insurance === void 0 ? {} : { insurance: this.insurance } : { insurance: props.insurance }
15888
- });
15889
- }
15890
- addAdditionalServiceEffect(id, quantity = 1) {
15891
- const selections = this.#selections;
15892
- const additionalServices = () => this.#additionalServices;
15893
- const withAdditionalServiceSelections = (nextSelections) => this.withAdditionalServiceSelections(nextSelections);
15894
- return Effect.gen(function* () {
15895
- const additionalQuantity = yield* parsePositiveQuantity(quantity);
15896
- const service = additionalServices().find((additionalService) => additionalService.id === id);
15897
- if (service === void 0) return yield* Effect.fail(new UnknownAdditionalService({ id }));
15898
- const nextQuantity = (selections.find((selection) => selection.id === id)?.quantity ?? 0) + additionalQuantity;
15899
- if (service.maxPerBooking !== void 0 && nextQuantity > service.maxPerBooking) return yield* Effect.fail(new AdditionalServiceLimitExceeded({
15900
- id,
15901
- label: service.label,
15902
- maxPerBooking: service.maxPerBooking,
15903
- requestedQuantity: nextQuantity
15904
- }));
15905
- return yield* withAdditionalServiceSelections([...selections.filter((selection) => selection.id !== id), {
15906
- id,
15907
- quantity: nextQuantity
15908
- }]);
15909
- });
15910
- }
15911
- removeAdditionalServiceEffect(id, quantity = 1) {
15912
- const selections = this.#selections;
15913
- const currentQuote = () => this;
15914
- const withAdditionalServiceSelections = (nextSelections) => this.withAdditionalServiceSelections(nextSelections);
15915
- return Effect.gen(function* () {
15916
- const quantityToRemove = yield* parsePositiveQuantity(quantity);
15917
- const existingSelection = selections.find((selection) => selection.id === id);
15918
- if (existingSelection === void 0) return currentQuote();
15919
- const nextQuantity = existingSelection.quantity - quantityToRemove;
15920
- const remainingSelections = selections.filter((selection) => selection.id !== id);
15921
- return yield* withAdditionalServiceSelections(nextQuantity <= 0 ? remainingSelections : [...remainingSelections, {
15922
- ...existingSelection,
15923
- quantity: nextQuantity
15924
- }]);
15925
- });
15926
- }
15927
- clearAdditionalServicesSelection() {
15928
- if (this.#selections.length === 0) return {
15929
- ok: true,
15930
- quote: this
15931
- };
15932
- const backendContext = withQuoteBackendContextSelections(this[GuestQuoteInternalState].backendContext, this[GuestQuoteInternalState].updateBackendContext, []);
15933
- return {
15934
- ok: true,
15935
- quote: this.rebuild({
15936
- selections: [],
15937
- ...backendContext === void 0 ? {} : { backendContext }
15938
- })
15939
- };
15940
- }
15941
- selectCancellationPolicyEffect(id) {
15942
- const option = this.#cancellationPolicies.find((policy) => policy.id === id);
15943
- if (option === void 0) return Effect.fail(new UnknownCancellationPolicy({ id }));
15944
- if (this.#cancellationPolicySelection?.policyId === id) return Effect.succeed(this);
15945
- const variant = this.#cancellationPolicyQuoteVariants.find((quoteVariant) => quoteVariant.policyId === id);
15946
- if (variant === void 0) return Effect.fail(new UnavailableCancellationPolicyQuote({ id }));
15947
- const selection = {
15948
- policyId: option.id,
15949
- kind: option.kind,
15950
- withAlternativeCancellationPolicy: option.withAlternativeCancellationPolicy
15951
- };
15952
- const backendContext = withQuoteBackendContextSelections(variant.backendContext, this[GuestQuoteInternalState].updateBackendContext, this.#selections);
15953
- return this.validateAdditionalServiceSelections({
15954
- additionalServices: variant.additionalServices,
15955
- selections: this.#selections
15956
- }).pipe(Effect.as(this.rebuild({
15957
- bookingCardInformation: variant.bookingCardInformation,
15958
- baseTotal: variant.baseTotal,
15959
- currency: variant.currency,
15960
- additionalServices: variant.additionalServices,
15961
- cancellationPolicySelection: selection,
15962
- ...backendContext === void 0 ? {} : { backendContext }
15963
- })));
15964
- }
15965
- withAdditionalServiceSelections(selections) {
15966
- return this.validateAdditionalServiceSelections({
15967
- additionalServices: this.#additionalServices,
15968
- selections
15969
- }).pipe(Effect.flatMap(() => this.withValidatedAdditionalServiceSelections(selections)));
15970
- }
15971
- validateAdditionalServiceSelections({ additionalServices, selections }) {
15972
- for (const selection of selections) {
15973
- const service = additionalServices.find((additionalService) => additionalService.id === selection.id);
15974
- if (service === void 0) return Effect.fail(new UnknownAdditionalService({ id: selection.id }));
15975
- if (service.maxPerBooking !== void 0 && selection.quantity > service.maxPerBooking) return Effect.fail(new AdditionalServiceLimitExceeded({
15976
- id: selection.id,
15977
- label: service.label,
15978
- maxPerBooking: service.maxPerBooking,
15979
- requestedQuantity: selection.quantity
15980
- }));
15981
- }
15982
- return Effect.void;
15983
- }
15984
- withValidatedAdditionalServiceSelections(selections) {
15985
- const backendContext = withQuoteBackendContextSelections(this[GuestQuoteInternalState].backendContext, this[GuestQuoteInternalState].updateBackendContext, selections);
15986
- return Effect.succeed(this.rebuild({
15987
- selections: [...selections],
15988
- ...backendContext === void 0 ? {} : { backendContext }
15989
- }));
15990
- }
15991
- };
15992
- //#endregion
15993
15452
  //#region src/services/live/availability.ts
15994
15453
  var LiveAvailabilityService = class extends Context.Service()("@v-office/cms-sdk/LiveAvailabilityService") {};
15995
15454
  //#endregion
@@ -19914,7 +19373,7 @@ const bookV9Insurance = ({ quote, bookingNumber, guestToken, v1Client }) => Effe
19914
19373
  //#region src/adapters/v9/live/quote.ts
19915
19374
  const loadQuoteRuntime$1 = Effect.tryPromise({
19916
19375
  try: async () => {
19917
- return { toGuestQuote: (await import("./quote-C3HZsFua.mjs")).toGuestQuote };
19376
+ return { toGuestQuote: (await import("./quote-xpSX3Z58.mjs")).toGuestQuote };
19918
19377
  },
19919
19378
  catch: (cause) => new CMSError({
19920
19379
  backend: "v9",
@@ -23609,9 +23068,50 @@ new Set([
23609
23068
  ]);
23610
23069
  const isCustomAttributeDefinition = (definition) => definition.source === "customAttribute" && (!definition.searchable || definition.internal);
23611
23070
  //#endregion
23071
+ //#region src/adapters/v9/parser/search/output/to-alternative-periods.ts
23072
+ const DEFAULT_V9_SEARCH_CURRENCY = "EUR";
23073
+ const toAlternativePeriods$1 = ({ locale, alternatives }) => Effect.succeed((alternatives ?? []).flatMap((alternative) => {
23074
+ if (alternative.fromdate == null || alternative.tilldate == null) return [];
23075
+ return [{
23076
+ start: alternative.fromdate,
23077
+ end: alternative.tilldate,
23078
+ ...alternative.calc?.total == null ? {} : { formattedTotal: toFormattedSearchPrice({
23079
+ amount: alternative.calc.total,
23080
+ currency: DEFAULT_V9_SEARCH_CURRENCY,
23081
+ locale
23082
+ }) }
23083
+ }];
23084
+ }));
23085
+ //#endregion
23612
23086
  //#region src/adapters/v9/parser/to-custom-attribute-rental-data-attributes.ts
23613
23087
  const toCustomAttributeRentalDataAttributes = (definitions) => definitions.flatMap((definition) => definition.source === "customAttribute" && definition.key.startsWith("p_") ? [definition.key] : []);
23614
23088
  //#endregion
23089
+ //#region src/adapters/v9/rental-scope.ts
23090
+ const toV9PropertyId = (scope) => {
23091
+ if (scope.propertyId == null) return void 0;
23092
+ const propertyId = Number(scope.propertyId);
23093
+ return Number.isInteger(propertyId) ? propertyId : void 0;
23094
+ };
23095
+ const filterV9RentalsByScope = (rentals, scope) => {
23096
+ const propertyId = toV9PropertyId(scope);
23097
+ if (propertyId == null) return rentals;
23098
+ return rentals.filter((rental) => rental.voffice_facility_id === propertyId);
23099
+ };
23100
+ const applyV9RentalScopeToSearchQueryInput = (input, scope) => {
23101
+ const propertyId = toV9PropertyId(scope);
23102
+ if (propertyId == null) return input;
23103
+ return {
23104
+ ...input,
23105
+ vofficeData: {
23106
+ ...input.vofficeData,
23107
+ filter: {
23108
+ ...input.vofficeData?.filter,
23109
+ falicityid: propertyId
23110
+ }
23111
+ }
23112
+ };
23113
+ };
23114
+ //#endregion
23615
23115
  //#region src/adapters/v9/live/search.ts
23616
23116
  const DEFAULT_SEARCH_DATA_ATTRIBUTES = Object.keys(VofficeUnitDataFieldSchemas);
23617
23117
  const DEFAULT_SEARCH_LIMIT$1 = 20;
@@ -23633,7 +23133,7 @@ const parseV9SearchCursor = (cursor) => Effect.gen(function* () {
23633
23133
  });
23634
23134
  const loadLiveSearchRuntime$1 = Effect.tryPromise({
23635
23135
  try: async () => {
23636
- const [operations, parser] = await Promise.all([import("./operations-CHxEQ3jG.mjs"), import("./search-JqA3v_Fx.mjs")]);
23136
+ const [operations, parser] = await Promise.all([import("./operations-Bxhb0jmN.mjs"), import("./search-D-OKND5S.mjs")]);
23637
23137
  return {
23638
23138
  searchQuery: operations.searchQuery,
23639
23139
  toQueryInput: parser.toQueryInput,
@@ -23674,22 +23174,51 @@ const makeV9LiveSearchLive = (config, options) => Layer.effect(LiveSearchService
23674
23174
  customAttributeFilterDefinitions: options.customAttributeFilterDefinitions,
23675
23175
  query: input.query
23676
23176
  });
23177
+ const scopedQueryInput = applyV9RentalScopeToSearchQueryInput(queryInput, options.rentalScope);
23677
23178
  const page = input.cursor === void 0 ? 1 : yield* parseV9SearchCursor(input.cursor);
23678
23179
  const data = yield* graphql.execute(searchQuery, {
23679
23180
  first: input.limit ?? DEFAULT_SEARCH_LIMIT$1,
23680
23181
  page,
23681
23182
  language: localeToLanguage(input.locale),
23682
23183
  dataAttributes,
23683
- ...queryInput
23184
+ ...scopedQueryInput
23684
23185
  });
23685
- return {
23686
- items: yield* Effect.all(data.search.data.map((rental) => toSearchOutputItem({
23186
+ const entries = yield* Effect.all(data.search.data.map((rental) => Effect.gen(function* () {
23187
+ const alternatives = rental.additional_voffice_data?.alternatives;
23188
+ const isExactPeriodMatch = alternatives === null;
23189
+ const item = yield* toSearchOutputItem({
23687
23190
  locale: input.locale,
23688
23191
  rentalHighlightPrioritization,
23689
23192
  customAttributeFilterDefinitions: customAttributeDefinitions,
23690
23193
  rental,
23194
+ includeFormattedTotal: isExactPeriodMatch,
23691
23195
  translations
23692
- }))),
23196
+ });
23197
+ if (isExactPeriodMatch || alternatives === void 0) return {
23198
+ type: "item",
23199
+ item
23200
+ };
23201
+ const alternativePeriods = yield* toAlternativePeriods$1({
23202
+ locale: input.locale,
23203
+ alternatives
23204
+ });
23205
+ if (alternativePeriods.length === 0) return {
23206
+ type: "item",
23207
+ item
23208
+ };
23209
+ return {
23210
+ type: "alternative",
23211
+ alternative: {
23212
+ item,
23213
+ alternativePeriods
23214
+ }
23215
+ };
23216
+ })));
23217
+ const items = entries.flatMap((entry) => entry.type === "item" ? [entry.item] : []);
23218
+ const alternatives = entries.flatMap((entry) => entry.type === "alternative" ? [entry.alternative] : []);
23219
+ return {
23220
+ items,
23221
+ ...alternatives.length > 0 ? { alternatives } : {},
23693
23222
  appliedFilters,
23694
23223
  unusedFilterKeys,
23695
23224
  pageInfo: {
@@ -24000,7 +23529,7 @@ const DEFAULT_RENTAL_FEEDBACK_DATA_ATTRIBUTES = [
24000
23529
  ];
24001
23530
  const loadStaticRentalsRuntime$1 = Effect.tryPromise({
24002
23531
  try: async () => {
24003
- const [operations, parser] = await Promise.all([import("./operations-CHxEQ3jG.mjs"), import("./rentals-cQAg5TTW.mjs")]);
23532
+ const [operations, parser] = await Promise.all([import("./operations-Bxhb0jmN.mjs"), import("./rentals-CSp5vdZh.mjs")]);
24004
23533
  return {
24005
23534
  rentalsAllQuery: operations.rentalsAllQuery,
24006
23535
  toRentalRentalsOutput: parser.toRentalRentalsOutput
@@ -24024,14 +23553,14 @@ const makeV9StaticRentalsLive = (config, options) => Layer.effect(StaticRentalsS
24024
23553
  const customAttributeDefinitions = options.customAttributeFilterDefinitions.filter(isCustomAttributeDefinition);
24025
23554
  return StaticRentalsService.of({ getRentals: (input) => Effect.gen(function* () {
24026
23555
  const { rentalsAllQuery, toRentalRentalsOutput } = yield* loadStaticRentalsRuntime$1;
24027
- const data = yield* graphql.execute(rentalsAllQuery, {
23556
+ const scopedRentals = filterV9RentalsByScope((yield* graphql.execute(rentalsAllQuery, {
24028
23557
  language: localeToLanguage(input.locale),
24029
23558
  rentalDataAttributes,
24030
23559
  rentalFacilityDataAttributes: [...DEFAULT_RENTAL_FACILITY_DATA_ATTRIBUTES],
24031
23560
  rentalRatingDataAttributes: [...DEFAULT_RENTAL_RATING_DATA_ATTRIBUTES],
24032
23561
  rentalFeedbackDataAttributes: [...DEFAULT_RENTAL_FEEDBACK_DATA_ATTRIBUTES]
24033
- });
24034
- return yield* Effect.all(data.all.map((rental) => toRentalRentalsOutput({
23562
+ })).all, options.rentalScope);
23563
+ return yield* Effect.all(scopedRentals.map((rental) => toRentalRentalsOutput({
24035
23564
  rental,
24036
23565
  locale: input.locale,
24037
23566
  translations,
@@ -24157,7 +23686,7 @@ const validateRentalId = (rentalId) => {
24157
23686
  };
24158
23687
  const loadAvailabilityRuntime = Effect.tryPromise({
24159
23688
  try: async () => {
24160
- return { bookingsGetAvailabilityQuery: (await import("./operations-BanW36PK.mjs")).bookingsGetAvailabilityQuery };
23689
+ return { bookingsGetAvailabilityQuery: (await import("./operations-B4IgNB3E.mjs")).bookingsGetAvailabilityQuery };
24161
23690
  },
24162
23691
  catch: (cause) => new CMSError({
24163
23692
  backend: "v10",
@@ -24447,7 +23976,7 @@ const toPaymentSchedules = ({ locale, translations, documentSettings, paymentSch
24447
23976
  //#region src/adapters/v10/live/booking.ts
24448
23977
  const loadBookingRuntime = Effect.tryPromise({
24449
23978
  try: async () => {
24450
- const operations = await import("./operations-BanW36PK.mjs");
23979
+ const operations = await import("./operations-B4IgNB3E.mjs");
24451
23980
  return {
24452
23981
  bookingsBookMutation: operations.bookingsBookMutation,
24453
23982
  documentsListDocumentSettingsBankAccountQuery: operations.documentsListDocumentSettingsBankAccountQuery,
@@ -24522,7 +24051,7 @@ const V10LiveContactLive = Layer.effect(LiveContactService, Effect.gen(function*
24522
24051
  //#region src/adapters/v10/live/quote.ts
24523
24052
  const loadQuoteRuntime = Effect.tryPromise({
24524
24053
  try: async () => {
24525
- const [operations, parser] = await Promise.all([import("./operations-BanW36PK.mjs"), import("./quote-Vl6Nutaa.mjs")]);
24054
+ const [operations, parser] = await Promise.all([import("./operations-B4IgNB3E.mjs"), import("./quote-Duya7n8v.mjs")]);
24526
24055
  return {
24527
24056
  bookingsGuestQuoteQuery: operations.bookingsGuestQuoteQuery,
24528
24057
  bookingsMultiRateContextQuery: operations.bookingsMultiRateContextQuery,
@@ -24834,7 +24363,7 @@ const getSearchFiltersByQueryKey = () => Effect.tryPromise({
24834
24363
  });
24835
24364
  //#endregion
24836
24365
  //#region src/adapters/v10/parser/search/input/filter/to-rental-summary-filter-output.ts
24837
- const hasFilterValues = (filter) => Object.keys(filter).length > 0;
24366
+ const hasFilterValues$1 = (filter) => Object.keys(filter).length > 0;
24838
24367
  const makeRentalSummaryFilterContainers = () => ({
24839
24368
  attributes: {},
24840
24369
  rentalSummary: {},
@@ -24844,9 +24373,9 @@ const makeRentalSummaryFilterContainers = () => ({
24844
24373
  const toRentalSummaryFilterOutput = ({ filtersByGroup, rentalIdsIn }) => ({
24845
24374
  ...filtersByGroup.rentalSummary,
24846
24375
  ...rentalIdsIn !== void 0 && rentalIdsIn.length > 0 ? { id: { _in: [...rentalIdsIn] } } : {},
24847
- ...hasFilterValues(filtersByGroup.attributes) ? { attributes: filtersByGroup.attributes } : {},
24848
- ...hasFilterValues(filtersByGroup.vicinity) ? { vicinity: filtersByGroup.vicinity } : {},
24849
- ...hasFilterValues(filtersByGroup.roomSummary) ? { roomSummary: filtersByGroup.roomSummary } : {}
24376
+ ...hasFilterValues$1(filtersByGroup.attributes) ? { attributes: filtersByGroup.attributes } : {},
24377
+ ...hasFilterValues$1(filtersByGroup.vicinity) ? { vicinity: filtersByGroup.vicinity } : {},
24378
+ ...hasFilterValues$1(filtersByGroup.roomSummary) ? { roomSummary: filtersByGroup.roomSummary } : {}
24850
24379
  });
24851
24380
  //#endregion
24852
24381
  //#region src/adapters/v10/parser/search/input/filter/to-rental-summary-filter.ts
@@ -33170,54 +32699,19 @@ const toRentalType = ({ translations, locale, rentalType }) => makeTranslate(tra
33170
32699
  //#region src/adapters/v10/parser/rentals/to-scope.ts
33171
32700
  const toScope = ({ translations, locale, scope }) => makeTranslate(translations, locale)(`Rental.scope.option.${scope}`, scope);
33172
32701
  //#endregion
33173
- //#region src/adapters/v10/parser/search/output/to-alternative-periods.ts
33174
- const toDateTime = (date) => DateTime.removeTime(DateTime.makeUnsafe(date));
33175
- const formatDatePart = ({ date, formatter, includeYear }) => {
33176
- const parts = Object.fromEntries(formatter.formatToParts(DateTime.toDate(date)).map(({ type, value }) => [type, value.replace(/\.$/, "")]));
33177
- return `${parts.weekday}, ${parts.day}. ${parts.month}${includeYear ? ` ${parts.year}` : ""}`;
33178
- };
33179
- const formatPeriod = ({ locale, period }) => {
33180
- const formatter = new Intl.DateTimeFormat(locale, {
33181
- timeZone: "UTC",
33182
- weekday: "short",
33183
- day: "2-digit",
33184
- month: "short",
33185
- year: "numeric"
33186
- });
33187
- const startDate = toDateTime(period[0]);
33188
- const endDate = toDateTime(period[1]);
33189
- return `${formatDatePart({
33190
- date: startDate,
33191
- formatter,
33192
- includeYear: DateTime.formatIsoDateUtc(startDate).slice(0, 4) !== DateTime.formatIsoDateUtc(endDate).slice(0, 4)
33193
- })} – ${formatDatePart({
33194
- date: endDate,
33195
- formatter,
33196
- includeYear: true
33197
- })}`;
33198
- };
33199
- const periodsMatch = (left, right) => left?.[0] === right?.[0] && left?.[1] === right?.[1];
33200
- const toAlternativePeriods = ({ locale, queryInput, alternatives }) => {
33201
- if (periodsMatch(alternatives.at(0)?.period, queryInput.periodQuery?.period)) return Effect.succeed(null);
33202
- return Effect.succeed(alternatives.flatMap((alternative) => alternative == null ? [] : [formatPeriod({
33203
- locale,
33204
- period: alternative.period
33205
- })]));
33206
- };
33207
- //#endregion
33208
32702
  //#region src/adapters/v10/parser/search/output/to-formatted-price.ts
33209
- const toFormattedPrice = ({ locale, queryInput, alternatives }) => {
33210
- const period = queryInput.periodQuery?.period;
32703
+ const toFormattedPrice = ({ locale, currency, alternatives }) => {
33211
32704
  const alternative = alternatives.at(0);
33212
- if (period === void 0 || alternative?.total == null) return Effect.succeed(null);
33213
- const [requestedStart, requestedEnd] = period;
33214
- const [alternativeStart, alternativeEnd] = alternative.period;
33215
- if (requestedStart !== alternativeStart || requestedEnd !== alternativeEnd) return Effect.succeed(null);
33216
- return Effect.succeed(formatCurrency(alternative.total, locale, queryInput.currency ?? "EUR"));
32705
+ if (alternative?.total == null) return Effect.succeed(null);
32706
+ return Effect.succeed(toFormattedSearchPrice({
32707
+ amount: alternative.total,
32708
+ currency,
32709
+ locale
32710
+ }));
33217
32711
  };
33218
32712
  //#endregion
33219
32713
  //#region src/adapters/v10/parser/search/to-search-output-item.ts
33220
- const toSearchOutputItem = ({ locale, imageBaseUrl, rentalHighlightPrioritization, customAttributeFilterDefinitions, customAttributes, translations, rental, queryInput, alternatives }) => Effect.gen(function* () {
32714
+ const toSearchOutputItem = ({ locale, imageBaseUrl, rentalHighlightPrioritization, customAttributeFilterDefinitions, customAttributes, translations, rental, queryInput, alternatives, includeFormattedTotal }) => Effect.gen(function* () {
33221
32715
  const rentalType = rental.rentalType != null ? yield* toRentalType({
33222
32716
  locale,
33223
32717
  translations,
@@ -33251,12 +32745,7 @@ const toSearchOutputItem = ({ locale, imageBaseUrl, rentalHighlightPrioritizatio
33251
32745
  }) : void 0;
33252
32746
  const formattedPrice = yield* toFormattedPrice({
33253
32747
  locale,
33254
- queryInput,
33255
- alternatives
33256
- });
33257
- const alternativePeriods = yield* toAlternativePeriods({
33258
- locale,
33259
- queryInput,
32748
+ currency: queryInput.currency ?? "EUR",
33260
32749
  alternatives
33261
32750
  });
33262
32751
  if (rentalType != null) item.rentalType = rentalType;
@@ -33267,11 +32756,42 @@ const toSearchOutputItem = ({ locale, imageBaseUrl, rentalHighlightPrioritizatio
33267
32756
  if (rental.address != null) item.address = toAddress(rental.address, locale);
33268
32757
  if (property != null) item.property = property;
33269
32758
  if (highlights != null) item.highlights = highlights;
33270
- if (alternativePeriods != null) item.alternatives = alternativePeriods;
33271
- if (formattedPrice != null) item.formattedTotal = formattedPrice;
32759
+ if (includeFormattedTotal && formattedPrice != null) item.formattedTotal = formattedPrice;
33272
32760
  return item;
33273
32761
  });
33274
32762
  //#endregion
32763
+ //#region src/adapters/v10/parser/search/output/to-alternative-periods.ts
32764
+ const periodsMatch = (left, right) => left?.[0] === right?.[0] && left?.[1] === right?.[1];
32765
+ const toAlternativePeriods = ({ locale, currency, alternatives }) => Effect.succeed(alternatives.flatMap((alternative) => {
32766
+ if (alternative == null) return [];
32767
+ const [start, end] = alternative.period;
32768
+ return [{
32769
+ start,
32770
+ end,
32771
+ ...alternative.total == null ? {} : { formattedTotal: toFormattedSearchPrice({
32772
+ amount: alternative.total,
32773
+ currency,
32774
+ locale
32775
+ }) }
32776
+ }];
32777
+ }));
32778
+ //#endregion
32779
+ //#region src/adapters/v10/rental-scope.ts
32780
+ const hasFilterValues = (filter) => filter != null && Object.keys(filter).length > 0;
32781
+ const toV10RentalSummaryFilter = (scope) => {
32782
+ if (scope.propertyId == null) return {};
32783
+ return { propertyId: { _eq: String(scope.propertyId) } };
32784
+ };
32785
+ const mergeV10RentalSummaryFilters = ({ base, scope }) => {
32786
+ const scopeFilter = toV10RentalSummaryFilter(scope);
32787
+ if (!hasFilterValues(scopeFilter)) return base ?? {};
32788
+ if (!hasFilterValues(base)) return scopeFilter;
32789
+ return {
32790
+ ...scopeFilter,
32791
+ _and: base
32792
+ };
32793
+ };
32794
+ //#endregion
33275
32795
  //#region src/adapters/v10/live/search.ts
33276
32796
  const DEFAULT_SEARCH_LIMIT = 20;
33277
32797
  const TEMPORARY_SEARCH_CACHE_CAPACITY = 100;
@@ -33294,10 +32814,15 @@ const toTemporaryV10SearchCacheKey = (input) => JSON.stringify({
33294
32814
  const parseTemporaryV10SearchCacheKey = (key) => JSON.parse(key);
33295
32815
  const paginateTemporaryV10SearchResult = ({ result, offset, limit }) => {
33296
32816
  const nextOffset = offset + limit;
33297
- const hasNextPage = nextOffset < result.items.length;
32817
+ const hasNextPage = nextOffset < result.entries.length;
32818
+ const entries = result.entries.slice(offset, nextOffset);
32819
+ const items = entries.flatMap((entry) => entry.type === "item" ? [entry.item] : []);
32820
+ const alternatives = entries.flatMap((entry) => entry.type === "alternative" ? [entry.alternative] : []);
33298
32821
  return {
33299
- ...result,
33300
- items: result.items.slice(offset, nextOffset),
32822
+ items,
32823
+ ...alternatives.length > 0 ? { alternatives } : {},
32824
+ appliedFilters: result.appliedFilters,
32825
+ unusedFilterKeys: result.unusedFilterKeys,
33301
32826
  pageInfo: {
33302
32827
  hasNextPage,
33303
32828
  ...hasNextPage ? { nextCursor: toTemporaryV10SearchCursor(nextOffset) } : {}
@@ -33306,7 +32831,7 @@ const paginateTemporaryV10SearchResult = ({ result, offset, limit }) => {
33306
32831
  };
33307
32832
  const loadLiveSearchRuntime = Effect.tryPromise({
33308
32833
  try: async () => {
33309
- const operations = await import("./operations-BanW36PK.mjs");
32834
+ const operations = await import("./operations-B4IgNB3E.mjs");
33310
32835
  return {
33311
32836
  customAttributesListCustomAttributesQuery: operations.customAttributesListCustomAttributesQuery,
33312
32837
  rentalsSearchQuery: operations.rentalsSearchQuery
@@ -33350,7 +32875,14 @@ const makeV10LiveSearchLive = ({ config, options }) => Layer.effect(LiveSearchSe
33350
32875
  query,
33351
32876
  rentalIdsIn
33352
32877
  });
33353
- const searchResults = ((yield* graphql.execute(rentalsSearchQuery, { input: queryInput })).rentals_search?.list ?? []).flatMap((rental) => rental?.rentalSummary != null ? [{
32878
+ const scopedQueryInput = {
32879
+ ...queryInput,
32880
+ rentalSummaryFilter: mergeV10RentalSummaryFilters({
32881
+ base: queryInput.rentalSummaryFilter,
32882
+ scope: options.rentalScope
32883
+ })
32884
+ };
32885
+ const searchResults = ((yield* graphql.execute(rentalsSearchQuery, { input: scopedQueryInput })).rentals_search?.list ?? []).flatMap((rental) => rental?.rentalSummary != null ? [{
33354
32886
  rental: rental.rentalSummary,
33355
32887
  alternatives: rental.alternatives ?? []
33356
32888
  }] : []);
@@ -33360,16 +32892,36 @@ const makeV10LiveSearchLive = ({ config, options }) => Layer.effect(LiveSearchSe
33360
32892
  rentalIds: searchResults.map(({ rental }) => rental.id)
33361
32893
  });
33362
32894
  return {
33363
- items: yield* Effect.all(searchResults.map(({ rental, alternatives }) => toSearchOutputItem({
33364
- locale,
33365
- imageBaseUrl: config.imageBaseUrl,
33366
- rentalHighlightPrioritization,
33367
- customAttributeFilterDefinitions: customAttributeDefinitions,
33368
- customAttributes: toCustomAttributeValues(customAttributeData[rental.id]),
33369
- rental,
33370
- queryInput,
33371
- alternatives,
33372
- translations
32895
+ entries: yield* Effect.all(searchResults.map(({ rental, alternatives }) => Effect.gen(function* () {
32896
+ const isExactPeriodMatch = periodsMatch(alternatives.at(0)?.period, queryInput.periodQuery?.period);
32897
+ const hasAlternativePeriods = alternatives.some((alternative) => alternative != null);
32898
+ const item = yield* toSearchOutputItem({
32899
+ locale,
32900
+ imageBaseUrl: config.imageBaseUrl,
32901
+ rentalHighlightPrioritization,
32902
+ customAttributeFilterDefinitions: customAttributeDefinitions,
32903
+ customAttributes: toCustomAttributeValues(customAttributeData[rental.id]),
32904
+ rental,
32905
+ queryInput: scopedQueryInput,
32906
+ alternatives,
32907
+ includeFormattedTotal: isExactPeriodMatch,
32908
+ translations
32909
+ });
32910
+ if (isExactPeriodMatch || !hasAlternativePeriods) return {
32911
+ type: "item",
32912
+ item
32913
+ };
32914
+ return {
32915
+ type: "alternative",
32916
+ alternative: {
32917
+ item,
32918
+ alternativePeriods: yield* toAlternativePeriods({
32919
+ locale,
32920
+ currency: scopedQueryInput.currency ?? "EUR",
32921
+ alternatives
32922
+ })
32923
+ }
32924
+ };
33373
32925
  }))),
33374
32926
  appliedFilters,
33375
32927
  unusedFilterKeys
@@ -33484,9 +33036,10 @@ const makeV10StaticFilterLive = ({ options }) => Layer.effect(StaticFilterServic
33484
33036
  }));
33485
33037
  //#endregion
33486
33038
  //#region src/adapters/v10/static/rentals.ts
33039
+ const ONLINE_RENTALS_FILTER = { status: { _eq: "ONLINE" } };
33487
33040
  const loadStaticRentalsRuntime = Effect.tryPromise({
33488
33041
  try: async () => {
33489
- const [operations, parser] = await Promise.all([import("./operations-BanW36PK.mjs"), import("./rentals-BFmmp26v.mjs")]);
33042
+ const [operations, parser] = await Promise.all([import("./operations-B4IgNB3E.mjs"), import("./rentals-DM-qBlym.mjs")]);
33490
33043
  return {
33491
33044
  customAttributesListCustomAttributesQuery: operations.customAttributesListCustomAttributesQuery,
33492
33045
  rentalsListRentalSummaryQuery: operations.rentalsListRentalSummaryQuery,
@@ -33506,7 +33059,10 @@ const makeV10StaticRentalsLive = ({ config, options }) => Layer.effect(StaticRen
33506
33059
  const customAttributeDefinitions = options.customAttributeFilterDefinitions.filter(isCustomAttributeDefinition);
33507
33060
  return StaticRentalsService.of({ getRentals: (input) => Effect.gen(function* () {
33508
33061
  const { customAttributesListCustomAttributesQuery, rentalsListRentalSummaryQuery, toRentalRentalsOutput } = yield* loadStaticRentalsRuntime;
33509
- const data = yield* graphql.execute(rentalsListRentalSummaryQuery, {});
33062
+ const data = yield* graphql.execute(rentalsListRentalSummaryQuery, { where: mergeV10RentalSummaryFilters({
33063
+ base: ONLINE_RENTALS_FILTER,
33064
+ scope: options.rentalScope
33065
+ }) });
33510
33066
  const customAttributeData = yield* listCustomAttributesByRentalId({
33511
33067
  graphql,
33512
33068
  customAttributesListCustomAttributesQuery,
@@ -33620,7 +33176,8 @@ const defineCMSSDKOptions = (options) => options;
33620
33176
  const normalizeCMSOptions = (options) => ({
33621
33177
  ...options,
33622
33178
  customAttributeFilterDefinitions: options?.customAttributeFilterDefinitions ?? [],
33623
- rentalHighlightPrioritization: options?.rentalHighlightPrioritization ?? DEFAULT_RENTAL_HIGHLIGHT_PRIORITIZATION
33179
+ rentalHighlightPrioritization: options?.rentalHighlightPrioritization ?? DEFAULT_RENTAL_HIGHLIGHT_PRIORITIZATION,
33180
+ rentalScope: options?.rentalScope ?? {}
33624
33181
  });
33625
33182
  const normalizeV10Options = (options) => ({
33626
33183
  ...normalizeCMSOptions(options),
@@ -33669,4 +33226,4 @@ const createCMSSDKFromParsedConfig = (config) => {
33669
33226
  };
33670
33227
  };
33671
33228
  //#endregion
33672
- export { DocumentResourceSchema as $, AdditionalServiceLimitExceeded as $t, toUnusedFilterKeys as A, ServiceImageSchema as At, makeV0OpenApiClientFetchLive as B, UnitIdsResponseSchema as Bt, parseChildrenAges as C, QuoteServiceSchema as Ct, parseQueryParameters as D, RoomImageSchema as Dt, collectQueryParameters as E, RegionListResponseSchema as Et, parseVofficeFacilityData as F, TileCollectionResponseSchema as Ft, makeV1OpenApiClientLive as G, UnitServicePriceSchema as Gt, V1OpenApiClient as H, UnitListResponseSchema as Ht, parseVofficeFeedbackData as I, TileSchema as It, CalendarResponseSchema$1 as J, VideoResponseSchema as Jt, ApiEnvelopeBaseSchema as K, V1_BASE_URL as Kt, parseVofficeUnitData as L, TileTagSchema as Lt, VofficeUnitDataPropertyCategoryLabelKeys as M, ServiceListResponseSchema as Mt, VofficeUnitDataPropertyCategoryValues as N, SetupDataSchema as Nt, expandCustomAttributeFilterCompositions as O, SearchPropertiesResponseSchema as Ot, VofficeUnitDataPropertyMetadata as P, SetupResponseSchema as Pt, DocumentResourceResponseSchema as Q, formatCurrency as Qt, V0OpenApiClient as R, TravelInsuranceBookingSchema as Rt, toAddress as S, QuoteSchema as St, toQueryString as T, RawVofficeObjectSchema as Tt, V1OpenApiClientError as U, UnitOfferSchema as Ut, makeV0OpenApiClientLive as V, UnitListItemSchema as Vt, makeV1OpenApiClientFetchLive as W, UnitResponseSchema as Wt, CustomerUnitSummarySchema as X, GuestQuote as Xt, CurrentMemberResponseSchema as Y, decodeV1OperationResponse as Yt, DocumentCollectionResponseSchema as Z, addGuestQuoteAdditionalServiceSelection as Zt, GENERATED_RENTAL_METADATA_CATALOG as _, PaymentScheduleItemSchema as _t, defineVofficeFacilityDataAttributes as a, toStableSearchInputParameterValues as an, ErgoBankSchema as at, toLocation as b, QuotePricesPayloadSchema as bt, defineVofficeOfferDataAttributes as c, ErgoCreatePreContractRequestSchema as ct, defineVofficeServiceDataAttributes as d, ErgoPolicyNumberRequestSchema as dt, InvalidAdditionalServiceQuantity as en, DocumentStatusSchema as et, defineVofficeTotalRatingDataAttributes as f, ErgoReadPreContractRequestSchema as ft, toRentalHighlights as g, OnOfficeUnitSchema as gt, toRentalType as h, OnOfficeUnitCollectionResponseSchema as ht, defineDataAttributes as i, toStableSearchInputBackendQueryKeys as in, ErgoAddressSchema as it, stable_filters_default as j, ServiceLimitSchema as jt, toCustomAttributeFilterLabel as k, ServiceBeonDataSchema as kt, defineVofficePriceDataAttributes as l, ErgoPersonSchema as lt, toScope as m, FacilityListResponseSchema as mt, defineCMSSDKOptions as n, STABLE_SEARCH_INPUTS as nn, DocumentSummarySchema as nt, defineVofficeFeedbackDataAttributes as o, toStableSearchInputQueryKeys as on, ErgoBookRequestSchema as ot, defineVofficeUnitDataAttributes as p, ErgoTripAndCustomerRequestSchema as pt, CalendarDaySchema as q, V1_OPERATIONS as qt, customDataAttribute as r, defineStableSearchInputGroup as rn, DocumentTypeSchema as rt, defineVofficeImageDataAttributes as s, ErgoCommonFieldsSchema as st, createCMSSDKFromParsedConfig as t, UnknownAdditionalService as tn, DocumentStatusUpdateRequestSchema as tt, defineVofficeRatingDataAttributes as u, ErgoPlanSearchRequestSchema as ut, toProperty as v, PaymentScheduleSchema$1 as vt, parseOccupancyCount as w, RawObjectResponseSchema as wt, toImages as x, QuotePricesResponseSchema$1 as xt, toDescription as y, QuoteLineSchema$1 as yt, V0OpenApiClientError as z, TravelInsuranceBookingStoreRequestSchema as zt };
33229
+ export { DocumentResourceSchema as $, toStableSearchInputParameterValues as $t, toUnusedFilterKeys as A, ServiceImageSchema as At, makeV0OpenApiClientFetchLive as B, UnitIdsResponseSchema as Bt, parseChildrenAges as C, QuoteServiceSchema as Ct, parseQueryParameters as D, RoomImageSchema as Dt, collectQueryParameters as E, RegionListResponseSchema as Et, parseVofficeFacilityData as F, TileCollectionResponseSchema as Ft, makeV1OpenApiClientLive as G, UnitServicePriceSchema as Gt, V1OpenApiClient as H, UnitListResponseSchema as Ht, parseVofficeFeedbackData as I, TileSchema as It, CalendarResponseSchema$1 as J, VideoResponseSchema as Jt, ApiEnvelopeBaseSchema as K, V1_BASE_URL as Kt, parseVofficeUnitData as L, TileTagSchema as Lt, VofficeUnitDataPropertyCategoryLabelKeys as M, ServiceListResponseSchema as Mt, VofficeUnitDataPropertyCategoryValues as N, SetupDataSchema as Nt, expandCustomAttributeFilterCompositions as O, SearchPropertiesResponseSchema as Ot, VofficeUnitDataPropertyMetadata as P, SetupResponseSchema as Pt, DocumentResourceResponseSchema as Q, toStableSearchInputBackendQueryKeys as Qt, V0OpenApiClient as R, TravelInsuranceBookingSchema as Rt, toAddress as S, QuoteSchema as St, toQueryString as T, RawVofficeObjectSchema as Tt, V1OpenApiClientError as U, UnitOfferSchema as Ut, makeV0OpenApiClientLive as V, UnitListItemSchema as Vt, makeV1OpenApiClientFetchLive as W, UnitResponseSchema as Wt, CustomerUnitSummarySchema as X, STABLE_SEARCH_INPUTS as Xt, CurrentMemberResponseSchema as Y, decodeV1OperationResponse as Yt, DocumentCollectionResponseSchema as Z, defineStableSearchInputGroup as Zt, GENERATED_RENTAL_METADATA_CATALOG as _, PaymentScheduleItemSchema as _t, defineVofficeFacilityDataAttributes as a, ErgoBankSchema as at, toLocation as b, QuotePricesPayloadSchema as bt, defineVofficeOfferDataAttributes as c, ErgoCreatePreContractRequestSchema as ct, defineVofficeServiceDataAttributes as d, ErgoPolicyNumberRequestSchema as dt, toStableSearchInputQueryKeys as en, DocumentStatusSchema as et, defineVofficeTotalRatingDataAttributes as f, ErgoReadPreContractRequestSchema as ft, toRentalHighlights as g, OnOfficeUnitSchema as gt, toRentalType as h, OnOfficeUnitCollectionResponseSchema as ht, defineDataAttributes as i, ErgoAddressSchema as it, stable_filters_default as j, ServiceLimitSchema as jt, toCustomAttributeFilterLabel as k, ServiceBeonDataSchema as kt, defineVofficePriceDataAttributes as l, ErgoPersonSchema as lt, toScope as m, FacilityListResponseSchema as mt, defineCMSSDKOptions as n, DocumentSummarySchema as nt, defineVofficeFeedbackDataAttributes as o, ErgoBookRequestSchema as ot, defineVofficeUnitDataAttributes as p, ErgoTripAndCustomerRequestSchema as pt, CalendarDaySchema as q, V1_OPERATIONS as qt, customDataAttribute as r, DocumentTypeSchema as rt, defineVofficeImageDataAttributes as s, ErgoCommonFieldsSchema as st, createCMSSDKFromParsedConfig as t, DocumentStatusUpdateRequestSchema as tt, defineVofficeRatingDataAttributes as u, ErgoPlanSearchRequestSchema as ut, toProperty as v, PaymentScheduleSchema$1 as vt, parseOccupancyCount as w, RawObjectResponseSchema as wt, toImages as x, QuotePricesResponseSchema$1 as xt, toDescription as y, QuoteLineSchema$1 as yt, V0OpenApiClientError as z, TravelInsuranceBookingStoreRequestSchema as zt };