@v-office/website-sdk 1.0.1 → 1.2.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-BHAU7meW.mjs")).toGuestQuote };
19376
+ return { toGuestQuote: (await import("./quote-Bo-gBDkQ.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-CWlFDque.mjs")]);
23136
+ const [operations, parser] = await Promise.all([import("./operations-Bxhb0jmN.mjs"), import("./search-BofxXqF0.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: {
@@ -23864,6 +23393,7 @@ const toOutputType = (definition) => {
23864
23393
  switch (definition.type) {
23865
23394
  case "boolean": return "BooleanFilter";
23866
23395
  case "int": return "IntFilter";
23396
+ case "string": return "StringFilter";
23867
23397
  case "option": return "OptionFilter";
23868
23398
  case "complex": return "BooleanFilter";
23869
23399
  }
@@ -23900,6 +23430,10 @@ const toCustomAttributeFilterOutputItem = ({ definition, locale }) => {
23900
23430
  ...numericBounds ? { numericBounds } : {}
23901
23431
  };
23902
23432
  }
23433
+ if (type === "StringFilter") return {
23434
+ ...baseFilter,
23435
+ type
23436
+ };
23903
23437
  return {
23904
23438
  ...baseFilter,
23905
23439
  type
@@ -24000,7 +23534,7 @@ const DEFAULT_RENTAL_FEEDBACK_DATA_ATTRIBUTES = [
24000
23534
  ];
24001
23535
  const loadStaticRentalsRuntime$1 = Effect.tryPromise({
24002
23536
  try: async () => {
24003
- const [operations, parser] = await Promise.all([import("./operations-CHxEQ3jG.mjs"), import("./rentals-BoPt4aXU.mjs")]);
23537
+ const [operations, parser] = await Promise.all([import("./operations-Bxhb0jmN.mjs"), import("./rentals-Ba6ZO6bX.mjs")]);
24004
23538
  return {
24005
23539
  rentalsAllQuery: operations.rentalsAllQuery,
24006
23540
  toRentalRentalsOutput: parser.toRentalRentalsOutput
@@ -24024,14 +23558,14 @@ const makeV9StaticRentalsLive = (config, options) => Layer.effect(StaticRentalsS
24024
23558
  const customAttributeDefinitions = options.customAttributeFilterDefinitions.filter(isCustomAttributeDefinition);
24025
23559
  return StaticRentalsService.of({ getRentals: (input) => Effect.gen(function* () {
24026
23560
  const { rentalsAllQuery, toRentalRentalsOutput } = yield* loadStaticRentalsRuntime$1;
24027
- const data = yield* graphql.execute(rentalsAllQuery, {
23561
+ const scopedRentals = filterV9RentalsByScope((yield* graphql.execute(rentalsAllQuery, {
24028
23562
  language: localeToLanguage(input.locale),
24029
23563
  rentalDataAttributes,
24030
23564
  rentalFacilityDataAttributes: [...DEFAULT_RENTAL_FACILITY_DATA_ATTRIBUTES],
24031
23565
  rentalRatingDataAttributes: [...DEFAULT_RENTAL_RATING_DATA_ATTRIBUTES],
24032
23566
  rentalFeedbackDataAttributes: [...DEFAULT_RENTAL_FEEDBACK_DATA_ATTRIBUTES]
24033
- });
24034
- return yield* Effect.all(data.all.map((rental) => toRentalRentalsOutput({
23567
+ })).all, options.rentalScope);
23568
+ return yield* Effect.all(scopedRentals.map((rental) => toRentalRentalsOutput({
24035
23569
  rental,
24036
23570
  locale: input.locale,
24037
23571
  translations,
@@ -24157,7 +23691,7 @@ const validateRentalId = (rentalId) => {
24157
23691
  };
24158
23692
  const loadAvailabilityRuntime = Effect.tryPromise({
24159
23693
  try: async () => {
24160
- return { bookingsGetAvailabilityQuery: (await import("./operations-BanW36PK.mjs")).bookingsGetAvailabilityQuery };
23694
+ return { bookingsGetAvailabilityQuery: (await import("./operations-B4IgNB3E.mjs")).bookingsGetAvailabilityQuery };
24161
23695
  },
24162
23696
  catch: (cause) => new CMSError({
24163
23697
  backend: "v10",
@@ -24447,7 +23981,7 @@ const toPaymentSchedules = ({ locale, translations, documentSettings, paymentSch
24447
23981
  //#region src/adapters/v10/live/booking.ts
24448
23982
  const loadBookingRuntime = Effect.tryPromise({
24449
23983
  try: async () => {
24450
- const operations = await import("./operations-BanW36PK.mjs");
23984
+ const operations = await import("./operations-B4IgNB3E.mjs");
24451
23985
  return {
24452
23986
  bookingsBookMutation: operations.bookingsBookMutation,
24453
23987
  documentsListDocumentSettingsBankAccountQuery: operations.documentsListDocumentSettingsBankAccountQuery,
@@ -24522,7 +24056,7 @@ const V10LiveContactLive = Layer.effect(LiveContactService, Effect.gen(function*
24522
24056
  //#region src/adapters/v10/live/quote.ts
24523
24057
  const loadQuoteRuntime = Effect.tryPromise({
24524
24058
  try: async () => {
24525
- const [operations, parser] = await Promise.all([import("./operations-BanW36PK.mjs"), import("./quote-jlnlQBDS.mjs")]);
24059
+ const [operations, parser] = await Promise.all([import("./operations-B4IgNB3E.mjs"), import("./quote-BKcAIFuH.mjs")]);
24526
24060
  return {
24527
24061
  bookingsGuestQuoteQuery: operations.bookingsGuestQuoteQuery,
24528
24062
  bookingsMultiRateContextQuery: operations.bookingsMultiRateContextQuery,
@@ -24663,7 +24197,8 @@ const isEnabledBooleanFilter = (value) => {
24663
24197
  return normalizedValue === "" || normalizedValue === "true" || normalizedValue === "1";
24664
24198
  };
24665
24199
  const toCustomAttributeFilterLabel = ({ definition, locale, value }) => {
24666
- if (definition.type !== "option" || value == null) return definition.label[locale];
24200
+ if (definition.type !== "option" && definition.type !== "string" || value == null) return definition.label[locale];
24201
+ if (definition.type === "string") return `${definition.label[locale]}: ${value}`;
24667
24202
  const option = definition.options.find((entry) => entry.value === value);
24668
24203
  return option == null ? definition.label[locale] : `${definition.label[locale]}: ${option.label[locale]}`;
24669
24204
  };
@@ -24834,7 +24369,7 @@ const getSearchFiltersByQueryKey = () => Effect.tryPromise({
24834
24369
  });
24835
24370
  //#endregion
24836
24371
  //#region src/adapters/v10/parser/search/input/filter/to-rental-summary-filter-output.ts
24837
- const hasFilterValues = (filter) => Object.keys(filter).length > 0;
24372
+ const hasFilterValues$1 = (filter) => Object.keys(filter).length > 0;
24838
24373
  const makeRentalSummaryFilterContainers = () => ({
24839
24374
  attributes: {},
24840
24375
  rentalSummary: {},
@@ -24844,9 +24379,9 @@ const makeRentalSummaryFilterContainers = () => ({
24844
24379
  const toRentalSummaryFilterOutput = ({ filtersByGroup, rentalIdsIn }) => ({
24845
24380
  ...filtersByGroup.rentalSummary,
24846
24381
  ...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 } : {}
24382
+ ...hasFilterValues$1(filtersByGroup.attributes) ? { attributes: filtersByGroup.attributes } : {},
24383
+ ...hasFilterValues$1(filtersByGroup.vicinity) ? { vicinity: filtersByGroup.vicinity } : {},
24384
+ ...hasFilterValues$1(filtersByGroup.roomSummary) ? { roomSummary: filtersByGroup.roomSummary } : {}
24850
24385
  });
24851
24386
  //#endregion
24852
24387
  //#region src/adapters/v10/parser/search/input/filter/to-rental-summary-filter.ts
@@ -25167,6 +24702,7 @@ const parseCustomAttributeValue = ({ definition, value }) => {
25167
24702
  switch (definition.type) {
25168
24703
  case "boolean": return parseBooleanValue(value);
25169
24704
  case "int": return Number.isInteger(Number(value)) ? value : void 0;
24705
+ case "string": return value.length > 0 ? value : void 0;
25170
24706
  case "option": return definition.options.some((option) => option.value === value) ? value : void 0;
25171
24707
  }
25172
24708
  };
@@ -33170,50 +32706,19 @@ const toRentalType = ({ translations, locale, rentalType }) => makeTranslate(tra
33170
32706
  //#region src/adapters/v10/parser/rentals/to-scope.ts
33171
32707
  const toScope = ({ translations, locale, scope }) => makeTranslate(translations, locale)(`Rental.scope.option.${scope}`, scope);
33172
32708
  //#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
32709
  //#region src/adapters/v10/parser/search/output/to-formatted-price.ts
33209
- const toFormattedPrice = ({ locale, queryInput, alternatives }) => {
32710
+ const toFormattedPrice = ({ locale, currency, alternatives }) => {
33210
32711
  const alternative = alternatives.at(0);
33211
32712
  if (alternative?.total == null) return Effect.succeed(null);
33212
- return Effect.succeed(formatCurrency(alternative.total, locale, queryInput.currency ?? "EUR"));
32713
+ return Effect.succeed(toFormattedSearchPrice({
32714
+ amount: alternative.total,
32715
+ currency,
32716
+ locale
32717
+ }));
33213
32718
  };
33214
32719
  //#endregion
33215
32720
  //#region src/adapters/v10/parser/search/to-search-output-item.ts
33216
- const toSearchOutputItem = ({ locale, imageBaseUrl, rentalHighlightPrioritization, customAttributeFilterDefinitions, customAttributes, translations, rental, queryInput, alternatives }) => Effect.gen(function* () {
32721
+ const toSearchOutputItem = ({ locale, imageBaseUrl, rentalHighlightPrioritization, customAttributeFilterDefinitions, customAttributes, translations, rental, queryInput, alternatives, includeFormattedTotal }) => Effect.gen(function* () {
33217
32722
  const rentalType = rental.rentalType != null ? yield* toRentalType({
33218
32723
  locale,
33219
32724
  translations,
@@ -33247,12 +32752,7 @@ const toSearchOutputItem = ({ locale, imageBaseUrl, rentalHighlightPrioritizatio
33247
32752
  }) : void 0;
33248
32753
  const formattedPrice = yield* toFormattedPrice({
33249
32754
  locale,
33250
- queryInput,
33251
- alternatives
33252
- });
33253
- const alternativePeriods = yield* toAlternativePeriods({
33254
- locale,
33255
- queryInput,
32755
+ currency: queryInput.currency ?? "EUR",
33256
32756
  alternatives
33257
32757
  });
33258
32758
  if (rentalType != null) item.rentalType = rentalType;
@@ -33263,11 +32763,42 @@ const toSearchOutputItem = ({ locale, imageBaseUrl, rentalHighlightPrioritizatio
33263
32763
  if (rental.address != null) item.address = toAddress(rental.address, locale);
33264
32764
  if (property != null) item.property = property;
33265
32765
  if (highlights != null) item.highlights = highlights;
33266
- if (alternativePeriods != null) item.alternatives = alternativePeriods;
33267
- if (formattedPrice != null) item.formattedTotal = formattedPrice;
32766
+ if (includeFormattedTotal && formattedPrice != null) item.formattedTotal = formattedPrice;
33268
32767
  return item;
33269
32768
  });
33270
32769
  //#endregion
32770
+ //#region src/adapters/v10/parser/search/output/to-alternative-periods.ts
32771
+ const periodsMatch = (left, right) => left?.[0] === right?.[0] && left?.[1] === right?.[1];
32772
+ const toAlternativePeriods = ({ locale, currency, alternatives }) => Effect.succeed(alternatives.flatMap((alternative) => {
32773
+ if (alternative == null) return [];
32774
+ const [start, end] = alternative.period;
32775
+ return [{
32776
+ start,
32777
+ end,
32778
+ ...alternative.total == null ? {} : { formattedTotal: toFormattedSearchPrice({
32779
+ amount: alternative.total,
32780
+ currency,
32781
+ locale
32782
+ }) }
32783
+ }];
32784
+ }));
32785
+ //#endregion
32786
+ //#region src/adapters/v10/rental-scope.ts
32787
+ const hasFilterValues = (filter) => filter != null && Object.keys(filter).length > 0;
32788
+ const toV10RentalSummaryFilter = (scope) => {
32789
+ if (scope.propertyId == null) return {};
32790
+ return { propertyId: { _eq: String(scope.propertyId) } };
32791
+ };
32792
+ const mergeV10RentalSummaryFilters = ({ base, scope }) => {
32793
+ const scopeFilter = toV10RentalSummaryFilter(scope);
32794
+ if (!hasFilterValues(scopeFilter)) return base ?? {};
32795
+ if (!hasFilterValues(base)) return scopeFilter;
32796
+ return {
32797
+ ...scopeFilter,
32798
+ _and: base
32799
+ };
32800
+ };
32801
+ //#endregion
33271
32802
  //#region src/adapters/v10/live/search.ts
33272
32803
  const DEFAULT_SEARCH_LIMIT = 20;
33273
32804
  const TEMPORARY_SEARCH_CACHE_CAPACITY = 100;
@@ -33290,10 +32821,15 @@ const toTemporaryV10SearchCacheKey = (input) => JSON.stringify({
33290
32821
  const parseTemporaryV10SearchCacheKey = (key) => JSON.parse(key);
33291
32822
  const paginateTemporaryV10SearchResult = ({ result, offset, limit }) => {
33292
32823
  const nextOffset = offset + limit;
33293
- const hasNextPage = nextOffset < result.items.length;
32824
+ const hasNextPage = nextOffset < result.entries.length;
32825
+ const entries = result.entries.slice(offset, nextOffset);
32826
+ const items = entries.flatMap((entry) => entry.type === "item" ? [entry.item] : []);
32827
+ const alternatives = entries.flatMap((entry) => entry.type === "alternative" ? [entry.alternative] : []);
33294
32828
  return {
33295
- ...result,
33296
- items: result.items.slice(offset, nextOffset),
32829
+ items,
32830
+ ...alternatives.length > 0 ? { alternatives } : {},
32831
+ appliedFilters: result.appliedFilters,
32832
+ unusedFilterKeys: result.unusedFilterKeys,
33297
32833
  pageInfo: {
33298
32834
  hasNextPage,
33299
32835
  ...hasNextPage ? { nextCursor: toTemporaryV10SearchCursor(nextOffset) } : {}
@@ -33302,7 +32838,7 @@ const paginateTemporaryV10SearchResult = ({ result, offset, limit }) => {
33302
32838
  };
33303
32839
  const loadLiveSearchRuntime = Effect.tryPromise({
33304
32840
  try: async () => {
33305
- const operations = await import("./operations-BanW36PK.mjs");
32841
+ const operations = await import("./operations-B4IgNB3E.mjs");
33306
32842
  return {
33307
32843
  customAttributesListCustomAttributesQuery: operations.customAttributesListCustomAttributesQuery,
33308
32844
  rentalsSearchQuery: operations.rentalsSearchQuery
@@ -33346,7 +32882,14 @@ const makeV10LiveSearchLive = ({ config, options }) => Layer.effect(LiveSearchSe
33346
32882
  query,
33347
32883
  rentalIdsIn
33348
32884
  });
33349
- const searchResults = ((yield* graphql.execute(rentalsSearchQuery, { input: queryInput })).rentals_search?.list ?? []).flatMap((rental) => rental?.rentalSummary != null ? [{
32885
+ const scopedQueryInput = {
32886
+ ...queryInput,
32887
+ rentalSummaryFilter: mergeV10RentalSummaryFilters({
32888
+ base: queryInput.rentalSummaryFilter,
32889
+ scope: options.rentalScope
32890
+ })
32891
+ };
32892
+ const searchResults = ((yield* graphql.execute(rentalsSearchQuery, { input: scopedQueryInput })).rentals_search?.list ?? []).flatMap((rental) => rental?.rentalSummary != null ? [{
33350
32893
  rental: rental.rentalSummary,
33351
32894
  alternatives: rental.alternatives ?? []
33352
32895
  }] : []);
@@ -33356,16 +32899,36 @@ const makeV10LiveSearchLive = ({ config, options }) => Layer.effect(LiveSearchSe
33356
32899
  rentalIds: searchResults.map(({ rental }) => rental.id)
33357
32900
  });
33358
32901
  return {
33359
- items: yield* Effect.all(searchResults.map(({ rental, alternatives }) => toSearchOutputItem({
33360
- locale,
33361
- imageBaseUrl: config.imageBaseUrl,
33362
- rentalHighlightPrioritization,
33363
- customAttributeFilterDefinitions: customAttributeDefinitions,
33364
- customAttributes: toCustomAttributeValues(customAttributeData[rental.id]),
33365
- rental,
33366
- queryInput,
33367
- alternatives,
33368
- translations
32902
+ entries: yield* Effect.all(searchResults.map(({ rental, alternatives }) => Effect.gen(function* () {
32903
+ const isExactPeriodMatch = periodsMatch(alternatives.at(0)?.period, queryInput.periodQuery?.period);
32904
+ const hasAlternativePeriods = alternatives.some((alternative) => alternative != null);
32905
+ const item = yield* toSearchOutputItem({
32906
+ locale,
32907
+ imageBaseUrl: config.imageBaseUrl,
32908
+ rentalHighlightPrioritization,
32909
+ customAttributeFilterDefinitions: customAttributeDefinitions,
32910
+ customAttributes: toCustomAttributeValues(customAttributeData[rental.id]),
32911
+ rental,
32912
+ queryInput: scopedQueryInput,
32913
+ alternatives,
32914
+ includeFormattedTotal: isExactPeriodMatch,
32915
+ translations
32916
+ });
32917
+ if (isExactPeriodMatch || !hasAlternativePeriods) return {
32918
+ type: "item",
32919
+ item
32920
+ };
32921
+ return {
32922
+ type: "alternative",
32923
+ alternative: {
32924
+ item,
32925
+ alternativePeriods: yield* toAlternativePeriods({
32926
+ locale,
32927
+ currency: scopedQueryInput.currency ?? "EUR",
32928
+ alternatives
32929
+ })
32930
+ }
32931
+ };
33369
32932
  }))),
33370
32933
  appliedFilters,
33371
32934
  unusedFilterKeys
@@ -33480,9 +33043,10 @@ const makeV10StaticFilterLive = ({ options }) => Layer.effect(StaticFilterServic
33480
33043
  }));
33481
33044
  //#endregion
33482
33045
  //#region src/adapters/v10/static/rentals.ts
33046
+ const ONLINE_RENTALS_FILTER = { status: { _eq: "ONLINE" } };
33483
33047
  const loadStaticRentalsRuntime = Effect.tryPromise({
33484
33048
  try: async () => {
33485
- const [operations, parser] = await Promise.all([import("./operations-BanW36PK.mjs"), import("./rentals-BWs_fBtf.mjs")]);
33049
+ const [operations, parser] = await Promise.all([import("./operations-B4IgNB3E.mjs"), import("./rentals-DBTPlC6X.mjs")]);
33486
33050
  return {
33487
33051
  customAttributesListCustomAttributesQuery: operations.customAttributesListCustomAttributesQuery,
33488
33052
  rentalsListRentalSummaryQuery: operations.rentalsListRentalSummaryQuery,
@@ -33502,7 +33066,10 @@ const makeV10StaticRentalsLive = ({ config, options }) => Layer.effect(StaticRen
33502
33066
  const customAttributeDefinitions = options.customAttributeFilterDefinitions.filter(isCustomAttributeDefinition);
33503
33067
  return StaticRentalsService.of({ getRentals: (input) => Effect.gen(function* () {
33504
33068
  const { customAttributesListCustomAttributesQuery, rentalsListRentalSummaryQuery, toRentalRentalsOutput } = yield* loadStaticRentalsRuntime;
33505
- const data = yield* graphql.execute(rentalsListRentalSummaryQuery, {});
33069
+ const data = yield* graphql.execute(rentalsListRentalSummaryQuery, { where: mergeV10RentalSummaryFilters({
33070
+ base: ONLINE_RENTALS_FILTER,
33071
+ scope: options.rentalScope
33072
+ }) });
33506
33073
  const customAttributeData = yield* listCustomAttributesByRentalId({
33507
33074
  graphql,
33508
33075
  customAttributesListCustomAttributesQuery,
@@ -33616,7 +33183,8 @@ const defineCMSSDKOptions = (options) => options;
33616
33183
  const normalizeCMSOptions = (options) => ({
33617
33184
  ...options,
33618
33185
  customAttributeFilterDefinitions: options?.customAttributeFilterDefinitions ?? [],
33619
- rentalHighlightPrioritization: options?.rentalHighlightPrioritization ?? DEFAULT_RENTAL_HIGHLIGHT_PRIORITIZATION
33186
+ rentalHighlightPrioritization: options?.rentalHighlightPrioritization ?? DEFAULT_RENTAL_HIGHLIGHT_PRIORITIZATION,
33187
+ rentalScope: options?.rentalScope ?? {}
33620
33188
  });
33621
33189
  const normalizeV10Options = (options) => ({
33622
33190
  ...normalizeCMSOptions(options),
@@ -33665,4 +33233,4 @@ const createCMSSDKFromParsedConfig = (config) => {
33665
33233
  };
33666
33234
  };
33667
33235
  //#endregion
33668
- 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 };
33236
+ 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 };