@feedmepos/mf-connect 0.1.119-prod → 0.1.120-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{App-BN2LKM3u.js → App-Dw3rnEq4.js} +147 -135
- package/dist/AuditLogs-DhXCWAPt.js +2016 -0
- package/dist/{Bin-DpQ1atb7.js → Bin-CUr1xsO9.js} +8 -8
- package/dist/{Broadcast-c1ZyYClI.js → Broadcast-_XJq6IJN.js} +22 -21
- package/dist/{CampaignAnalytic-w1hIlc2r.js → CampaignAnalytic-DqaUuRKr.js} +7 -7
- package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-D7U6evm1.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-VIKZyXYe.js} +8 -9
- package/dist/{Card-De53Xgbe.js → Card-D-jdr-yk.js} +22 -22
- package/dist/{Collections-BL2RD3FU.js → Collections-BkD4tNm-.js} +197 -185
- package/dist/{Credit-2KvFFcwR.js → Credit-BetxSEVi.js} +21 -20
- package/dist/{DateRangeChip.vue_vue_type_script_setup_true_lang-CKSs2nYE.js → DateRangeChip.vue_vue_type_script_setup_true_lang-B38KWvjh.js} +1 -1
- package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-DjrUbq3p.js +4439 -0
- package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-Jy7HkK5Z.js → EffectSheet.vue_vue_type_style_index_0_lang-ZUyAIXG8.js} +30 -30
- package/dist/{Experience-Cb0jHtVo.js → Experience-BFA5Z-vR.js} +32 -31
- package/dist/{FileSaver.min-UDgZF_Cv.js → FileSaver.min-8JbG2mJ3.js} +1 -1
- package/dist/{Game-BnysxSMs.js → Game-U5KLh4hO.js} +19 -18
- package/dist/{GiftCardSetup-s1OR6xQq.js → GiftCardSetup-Co-IZAGp.js} +31 -31
- package/dist/{GoalPickerPanel.vue_vue_type_script_setup_true_lang-D108r20x.js → GoalPickerPanel.vue_vue_type_script_setup_true_lang-BEpn_v0p.js} +7 -7
- package/dist/{Goals-BAieLPzR.js → Goals-BjfIo1eJ.js} +4 -4
- package/dist/Grab-BqMAyeT4.js +301 -0
- package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-B9Jgq5Bp.js → ImageInput.vue_vue_type_script_setup_true_lang-BS_4suKR.js} +1 -1
- package/dist/{Index-DnX16GAE.js → Index-B6vsJrc1.js} +10 -10
- package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-DeM-WG6m.js → LocationPicker.vue_vue_type_script_setup_true_lang-BnKkTFya.js} +1 -1
- package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-BAN69FOS.js → LottieAnimation.vue_vue_type_script_setup_true_lang-BekFDJxs.js} +1 -1
- package/dist/{LoyaltyDashboard-D8g6OSbC.js → LoyaltyDashboard-0jJUfdtM.js} +15 -15
- package/dist/{MainLayout-DWABjpQn.js → MainLayout-DCJfGVVF.js} +1 -1
- package/dist/{MainLayout.vue_vue_type_script_setup_true_lang-COp7iulq.js → MainLayout.vue_vue_type_script_setup_true_lang-CRkbPnQq.js} +16 -16
- package/dist/{Marketing-Dagatr0y.js → Marketing-DsZoY2Ef.js} +4 -4
- package/dist/{MarketingMaterialEdit-DYVzNDpM.js → MarketingMaterialEdit-BMJ2yjL0.js} +214 -211
- package/dist/{Member-DAxdEF_Z.js → Member-Bi7EuVUS.js} +7 -7
- package/dist/{MemberDetailSheet.vue_vue_type_script_setup_true_lang-nBg7Hckj.js → MemberDetailSheet.vue_vue_type_script_setup_true_lang-CXXKlmiR.js} +39 -47
- package/dist/{MemberImportHistory-2gx6FnLh.js → MemberImportHistory-CXnIaEaw.js} +7 -7
- package/dist/{MemberList-By_gGl-J.js → MemberList-C1CdR6m8.js} +103 -105
- package/dist/{MemberTransactions-BEF-4ZNp.js → MemberTransactions-BhSWE28t.js} +1 -1
- package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-Bs8wKx9B.js → MessageInput.vue_vue_type_script_setup_true_lang-DqkkAHPc.js} +12 -12
- package/dist/{MetricInfoTooltip.vue_vue_type_script_setup_true_lang-DN3mWfKj.js → MetricInfoTooltip.vue_vue_type_script_setup_true_lang-D6h_DlFU.js} +1 -1
- package/dist/{Mission-jg15lBxo.js → Mission-DZgMAkA4.js} +22 -21
- package/dist/{Overview-BFKLTAk1.js → Overview-BtV1gIgD.js} +145 -144
- package/dist/{Overview-C7WfdzfV.js → Overview-o0WZa6xE.js} +20 -20
- package/dist/{Point-dv9WgWTQ.js → Point-BdeI3vOp.js} +22 -21
- package/dist/{Promotion-mFPF_8jO.js → Promotion-eYwTP1qU.js} +137 -131
- package/dist/{Queue-BQoR_M5H.js → Queue-C72lnZ0G.js} +45 -45
- package/dist/{Record-1JZ1N5iX.js → Record-D1lHOQjk.js} +9 -9
- package/dist/{Review-B52AxCeT.js → Review-CbXC2Up5.js} +2 -2
- package/dist/ReviewFacebookCallback-BckFN6Dh.js +225 -0
- package/dist/{ReviewGoogleCallback-DO6SVFIC.js → ReviewGoogleCallback-CdBzIoTM.js} +5 -5
- package/dist/{Reward-Cp4jPAB0.js → Reward-hov1NEKT.js} +16 -16
- package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-DLD6X13Z.js → RewardGroup.vue_vue_type_script_setup_true_lang-C65e4Bjf.js} +13 -13
- package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-04yLkHZC.js +1923 -0
- package/dist/{Segment-DaKw0YXF.js → Segment-CLl-iQEV.js} +303 -306
- package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-Bj3OQ_JJ.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-cNl8HWu7.js} +14 -14
- package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-B1Otak97.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-DW40ulZz.js} +4 -4
- package/dist/{Setting-DveUrt8J.js → Setting-DUQnhLNq.js} +159 -148
- package/dist/{SettingAdvertisements-QRXOMNnM.js → SettingAdvertisements-BSn0-F2x.js} +12 -12
- package/dist/Settings-D_YrG-1N.js +286 -0
- package/dist/{Store-DjdXRw3V.js → Store-CDYO-NC0.js} +28 -28
- package/dist/{StoreRewards-CjlGrc9E.js → StoreRewards-DJh59Fob.js} +15 -15
- package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-DZGywP7T.js +1319 -0
- package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-YIWh91VO.js +7007 -0
- package/dist/{Tier-D74Oh2np.js → Tier-BW6W3yBu.js} +2575 -687
- package/dist/{Title-CeeviOW8.js → Title-B2eCIHuR.js} +95 -94
- package/dist/{Transaction-CWdw0ITl.js → Transaction-DPoCHqkz.js} +2 -2
- package/dist/Upselling-Bc8sJPTF.js +1013 -0
- package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-B9nf-9s0.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-B5aLnMyK.js} +26 -26
- package/dist/{Voucher-C0nNXMtv.js → Voucher-B6nQmBiS.js} +19 -19
- package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-DxZLsQq9.js → VoucherEditor.vue_vue_type_script_setup_true_lang-BdPZ41yo.js} +12 -12
- package/dist/{WhatsappAccount-CoLSjCQ2.js → WhatsappAccount-Ciq2u7nb.js} +6 -6
- package/dist/{WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-DkHPlGgT.js → WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-tkb0lN-h.js} +1 -1
- package/dist/{WhatsappBot-kLb3kUav.js → WhatsappBot-BYpVe09e.js} +6 -6
- package/dist/{WhatsappBotLogs-jcYaHs0t.js → WhatsappBotLogs-CgHw2yge.js} +6 -6
- package/dist/{WhatsappBotSettings-B6jJD61h.js → WhatsappBotSettings-BwpFbl7Z.js} +4 -4
- package/dist/{WhatsappLayout-C24bIjI2.js → WhatsappLayout-CwpwPh6N.js} +3 -3
- package/dist/{WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-9a_grP76.js → WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-DO9SPgkB.js} +3 -3
- package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-i8Wc2mCr.js → ZodTextField.vue_vue_type_script_setup_true_lang-C2jWAGpk.js} +2 -2
- package/dist/{app-C06bAZj3.js → app-vKvoaMkb.js} +4181 -3401
- package/dist/app.js +4 -3
- package/dist/{base.export-CgNRhKu8.js → base.export-ohC--hGH.js} +2 -2
- package/dist/{business-D23Dt1x4.js → business-28bym_1L.js} +1 -1
- package/dist/{campaign-DfEvGigm.js → campaign-DMboDbth.js} +121 -94
- package/dist/{campaign-FVcbXtrP.js → campaign-DgPBKJb-.js} +34 -28
- package/dist/{campaign.enum-BqekIiiN.js → campaign.enum-Dx-Zo68Q.js} +2 -1
- package/dist/campaign.fn-CFGvGCnh.js +776 -0
- package/dist/{collection.fn-DC1AMI9o.js → collection.fn-D1_zLTmc.js} +2 -2
- package/dist/{currency-Bra2RJK4.js → currency-DMOuxF-S.js} +1 -1
- package/dist/duplicateCampaign-DUktLBHE.js +51 -0
- package/dist/{effect-EL4V3pAu.js → effect-B5u1fe_H.js} +1 -1
- package/dist/{email-addresses-Ddtf1x_y.js → email-addresses-DlCCiXKC.js} +2 -2
- package/dist/{feature-flag-umACX47C.js → feature-flag-CjzcqKbW.js} +70 -70
- package/dist/google-BQK68wbe.js +5 -0
- package/dist/{helper-DqDOnLCf.js → helper-B6jcRgk4.js} +1 -1
- package/dist/{index-ByVPdKdB.js → index-B2wPJtZQ.js} +682 -581
- package/dist/{index-B2lqC_hH.js → index-Bf8aQe9s.js} +1 -1
- package/dist/{index-C6p9Lsvf.js → index-BoxhFA0T.js} +1 -1
- package/dist/{index-TDCPGtW3.js → index-BuuNZzmf.js} +389 -232
- package/dist/{index-C3hAzzS2.js → index-CNc35JQ-.js} +29 -15
- package/dist/{index-C3lk4GHF.js → index-CQJRkES4.js} +4 -4
- package/dist/{index-BTjhdlN_.js → index-CYyJd65t.js} +1 -1
- package/dist/{index-CEh6ryp2.js → index-CuqYl8B1.js} +19 -6
- package/dist/{index-BroF2fC8.js → index-CxKq67I1.js} +608 -251
- package/dist/{index-DK9zxpDu.js → index-D2ZgTMnz.js} +3 -3
- package/dist/{index-Bvk61_w_.js → index-DAJ0XegF.js} +1 -1
- package/dist/{index-pfmx-Gor.js → index-DCKK1jWV.js} +2 -2
- package/dist/{index-B3U3KZl0.js → index-DEixqEZl.js} +2 -2
- package/dist/{index-iVbjwKxc.js → index-DLxrYNl3.js} +10 -10
- package/dist/{index-LjoAs_nX.js → index-DPwp9uUi.js} +10 -10
- package/dist/{index-rcfcslIC.js → index-DYkwpfhH.js} +197 -197
- package/dist/{index-BkKu2G2c.js → index-DfRs6Yvh.js} +2 -2
- package/dist/{index-BzwwXWpZ.js → index-EJ2519DL.js} +1 -1
- package/dist/{index-B_BmgKrh.js → index-hbfWGXN8.js} +2699 -2613
- package/dist/{index-DuCJtx1m.js → index-wOCVa2Eh.js} +1 -1
- package/dist/{index.esm2017-DCuQPCX2.js → index.esm2017-C3o6d_kv.js} +111 -111
- package/dist/{loading-CQm1DKWE.js → loading-Dbol8f8F.js} +1 -1
- package/dist/{lodash-C2wVbAap.js → lodash-FYmuGFr2.js} +1 -1
- package/dist/{member-import-BLEmTRso.js → member-import-FmqKKCXM.js} +1 -1
- package/dist/{membership-XycnxPEW.js → membership-CMsYIvf9.js} +2 -2
- package/dist/{money-DY_QGzd1.js → money-DMsQ8s71.js} +1 -1
- package/dist/{number-BHthf4qF.js → number-D_xzX-4k.js} +1 -1
- package/dist/objectid-Wc5m2Orq.js +145 -0
- package/dist/{onboarding-BOJw54Fn.js → onboarding-k2Qm1tTl.js} +36 -36
- package/dist/{onboardingSetup-Cf2u1tXu.js → onboardingSetup-DJeJJn0h.js} +2 -2
- package/dist/{plugins-DKQeoL_e.js → plugins-lVdrZkVB.js} +3 -3
- package/dist/{reward-D4RIYSpl.js → reward-BoH6x-Iu.js} +1 -1
- package/dist/{rule-Ba-s0L_w.js → rule-4QLYlkQ-.js} +572 -492
- package/dist/style.css +1 -1
- package/dist/template-DLUzJbvo.js +224 -0
- package/dist/{timezone-CAc8xi1h.js → timezone-BV11O4o0.js} +1 -1
- package/dist/{transaction.fn-Cp2hnhyU.js → transaction.fn-5ws2MHHG.js} +2 -2
- package/dist/{trigger-3ebhNBX7.js → trigger-DHq8ksaN.js} +9 -9
- package/dist/{useMarketingMaterialActions-6URv8neP.js → useMarketingMaterialActions-DhBVUMSG.js} +4 -4
- package/dist/{usePagination-C-fyMmiy.js → usePagination-t6nU2p5V.js} +1 -1
- package/dist/{user-T-iXTrYV.js → user-KJLOr9ee.js} +1 -1
- package/dist/vue-i18n-DCq2tYAx.js +2365 -0
- package/dist/{xlsx-B8OqaJfb.js → xlsx-BkxKl6H8.js} +224 -224
- package/dist/{zod-DZkNj425.js → zod-CLLw9flE.js} +1 -1
- package/package.json +8 -3
- package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-BXb7v7wc.js +0 -3493
- package/dist/ReviewFacebookCallback-ihTdiI8V.js +0 -238
- package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-pdHRjCt8.js +0 -1884
- package/dist/Settings-D9D-mkBa.js +0 -179
- package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-DnwMpqzf.js +0 -1265
- package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-I5-5BV4h.js +0 -142
- package/dist/campaign.fn-0MNUj1fZ.js +0 -776
- package/dist/google-C3S8u0mT.js +0 -4
- package/dist/objectid-CPCAqIiC.js +0 -145
- package/dist/rule-builder-D0B0DPao.js +0 -102
- package/dist/template-B40I16Yg.js +0 -236
- package/dist/vue-i18n-DzsxJorb.js +0 -2365
|
@@ -0,0 +1,1013 @@
|
|
|
1
|
+
import { defineComponent as ce, computed as B, ref as $, watch as G, reactive as fe, onMounted as be, onBeforeUnmount as ue, openBlock as v, createElementBlock as w, unref as u, createElementVNode as h, toDisplayString as y, createCommentVNode as L, createBlock as ae, createVNode as te, createTextVNode as Oe, Fragment as se, renderList as ne, withCtx as Ie, normalizeClass as ke, normalizeStyle as Ue, shallowRef as Ae, TransitionGroup as $e } from "vue";
|
|
2
|
+
import { onBeforeRouteLeave as Me } from "vue-router";
|
|
3
|
+
import { useCoreStore as pe } from "@feedmepos/mf-common";
|
|
4
|
+
import { components as Ce } from "@feedmepos/ui-library";
|
|
5
|
+
import { z as c } from "./app-vKvoaMkb.js";
|
|
6
|
+
import { S as Te, a as Re } from "./index-DLxrYNl3.js";
|
|
7
|
+
import { f as Ne } from "./currency-DMOuxF-S.js";
|
|
8
|
+
const Le = {
|
|
9
|
+
title: "Upselling settings",
|
|
10
|
+
description: "Adjust product weight. Higher weight gives a product more priority in recommendations.",
|
|
11
|
+
businessDefault: "Business defaults",
|
|
12
|
+
restaurantOverride: "Restaurant override",
|
|
13
|
+
inherited: "Using business defaults. Saving creates a restaurant override.",
|
|
14
|
+
reset: "Use business defaults",
|
|
15
|
+
save: "Save",
|
|
16
|
+
apply: "Apply",
|
|
17
|
+
applyTo: "Apply changes to",
|
|
18
|
+
applyBusiness: "Business default",
|
|
19
|
+
applyOutlets: "Selected outlets",
|
|
20
|
+
selectAll: "Select all outlets",
|
|
21
|
+
cancel: "Cancel",
|
|
22
|
+
close: "Close",
|
|
23
|
+
applyHint: "Only matching product IDs will be applied. Existing outlet overrides are not removed when you update the business default.",
|
|
24
|
+
skippedHint: "These products are not in this outlet’s catalog, so they will not be applied here. Open that outlet’s upselling settings and apply weights separately to products from its own catalog. Existing settings are not deleted.",
|
|
25
|
+
product: "product",
|
|
26
|
+
productPlural: "products",
|
|
27
|
+
matched: "will be applied",
|
|
28
|
+
skipped: "will not be applied",
|
|
29
|
+
applyFailed: "Could not apply. Reload and review this destination before retrying.",
|
|
30
|
+
applyLoadFailed: "Could not load destinations and catalogs. Nothing has been applied.",
|
|
31
|
+
applyDone: "Applied",
|
|
32
|
+
saving: "Saving...",
|
|
33
|
+
discard: "Discard",
|
|
34
|
+
search: "Search products",
|
|
35
|
+
products: "Products",
|
|
36
|
+
editingScope: "Editing scope",
|
|
37
|
+
editingBusinessHint: "Apply updates business defaults. Existing outlet overrides are kept.",
|
|
38
|
+
editingOutletHint: "Only this outlet’s catalog is shown. Apply saves its settings.",
|
|
39
|
+
adjust: "Adjust weight",
|
|
40
|
+
weight: "Weight",
|
|
41
|
+
automatic: "AI ranking",
|
|
42
|
+
strongest: "Strongest recommendation",
|
|
43
|
+
excluded: "Do not recommend",
|
|
44
|
+
weak: "Weak",
|
|
45
|
+
normal: "Normal",
|
|
46
|
+
strong: "Strong",
|
|
47
|
+
custom: "Custom weight",
|
|
48
|
+
hint: "Turn on the switch to adjust a product. 0% excludes it. 100% gives it the strongest preference, not a guaranteed place.",
|
|
49
|
+
loading: "Loading products and settings...",
|
|
50
|
+
loadError: "Could not load upselling settings. Please try again.",
|
|
51
|
+
saveError: "Could not save. Your changes are still here. Please try again.",
|
|
52
|
+
saved: "Changes saved successfully",
|
|
53
|
+
dirty: "You have unsaved changes",
|
|
54
|
+
retry: "Try again",
|
|
55
|
+
empty: "No products available for this location.",
|
|
56
|
+
noMatches: "No products match your search.",
|
|
57
|
+
missingPhoto: "No photo",
|
|
58
|
+
unavailable: "Unavailable product",
|
|
59
|
+
unavailableHint: "Not in the current product list. Saved settings are kept.",
|
|
60
|
+
leave: "Discard unsaved upselling changes and leave?",
|
|
61
|
+
chooseRestaurant: "Select a business to edit upselling settings.",
|
|
62
|
+
preview: "Customer preview",
|
|
63
|
+
previewOutlet: "Preview outlet",
|
|
64
|
+
previewRestaurant: "Restaurant recommendations",
|
|
65
|
+
previewTopSelling: "Top-selling items",
|
|
66
|
+
previewWeightOnly: "Weight-based suggestions — no matching sales history",
|
|
67
|
+
previewWeightsOn: "Weight on",
|
|
68
|
+
previewWeightsOff: "Weight off",
|
|
69
|
+
previewRelevanceOn: "Relevance available",
|
|
70
|
+
previewRelevanceOff: "No relevance",
|
|
71
|
+
previewNoData: "No historical recommendations or positive weights are available.",
|
|
72
|
+
previewCartQuantities: "Recommendations use products in the cart, not quantities.",
|
|
73
|
+
previewCartBased: "Cart recommendations",
|
|
74
|
+
previewAdd: "Add to test cart",
|
|
75
|
+
previewRemove: "Remove",
|
|
76
|
+
previewQuantity: "Quantity",
|
|
77
|
+
previewCartEmpty: "Add one or more items to the test cart to preview cart recommendations.",
|
|
78
|
+
previewUnavailable: "Live recommendation preview is not connected yet.",
|
|
79
|
+
previewLoadError: "Could not load this preview. Try again.",
|
|
80
|
+
previewChooseOutlet: "Select an available outlet to preview recommendations.",
|
|
81
|
+
previewLoading: "Loading recommendations...",
|
|
82
|
+
previewSaved: "Before (current)",
|
|
83
|
+
previewDraft: "After",
|
|
84
|
+
previewItem: "After adding an item",
|
|
85
|
+
previewCart: "Before checkout",
|
|
86
|
+
previewOrder: "Add products to test cart",
|
|
87
|
+
previewTogether: "Always purchase together",
|
|
88
|
+
previewMeal: "Picked for you",
|
|
89
|
+
previewEmpty: "No recommendations returned."
|
|
90
|
+
}, Z = (e) => e.map((t) => ({ ...t })), oe = (e) => JSON.stringify(
|
|
91
|
+
[...e].sort((t, s) => t.productId.localeCompare(s.productId))
|
|
92
|
+
);
|
|
93
|
+
function _e(e) {
|
|
94
|
+
const t = Ae([]), s = $([]), r = $([]), g = $(!1), I = $(!1), k = $(!1), l = $(null), S = $(!1), a = $(!1), U = B(() => oe(s.value) !== oe(r.value)), A = fe(/* @__PURE__ */ new Map()), P = B(() => U.value || A.size > 0), _ = (x) => JSON.stringify([x.businessId, x.restaurantId]);
|
|
95
|
+
let N = "", T = 0;
|
|
96
|
+
const j = B(() => new Map(s.value.map((x) => [x.productId, x]))), J = B(() => {
|
|
97
|
+
const x = new Set(t.value.map((f) => f.productId));
|
|
98
|
+
return [
|
|
99
|
+
...t.value.map((f) => ({ ...f, unavailable: !1 })),
|
|
100
|
+
...s.value.filter((f) => !x.has(f.productId)).map((f) => ({
|
|
101
|
+
productId: f.productId,
|
|
102
|
+
name: f.productId,
|
|
103
|
+
unavailable: !0
|
|
104
|
+
}))
|
|
105
|
+
];
|
|
106
|
+
});
|
|
107
|
+
function F() {
|
|
108
|
+
N && k.value && (U.value ? A.set(N, { items: Z(s.value), baseline: Z(r.value) }) : A.delete(N));
|
|
109
|
+
}
|
|
110
|
+
async function D() {
|
|
111
|
+
F();
|
|
112
|
+
const x = ++T, f = { businessId: e.businessId, restaurantId: e.restaurantId || void 0 };
|
|
113
|
+
if (N = _(f), s.value = [], r.value = [], t.value = [], k.value = !1, I.value = !1, l.value = null, S.value = !1, a.value = !1, g.value = !!f.businessId, !!g.value)
|
|
114
|
+
try {
|
|
115
|
+
const [M, V] = await Promise.all([e.api.get(f), e.loadProducts(f)]);
|
|
116
|
+
if (x !== T) return;
|
|
117
|
+
if (M.businessId !== f.businessId || (M.restaurantId || void 0) !== f.restaurantId)
|
|
118
|
+
throw new Error("Settings scope mismatch");
|
|
119
|
+
const H = A.get(N);
|
|
120
|
+
r.value = Z((H == null ? void 0 : H.baseline) ?? M.items), s.value = Z((H == null ? void 0 : H.items) ?? M.items), a.value = M.inherited === !0, t.value = V, k.value = !0;
|
|
121
|
+
} catch {
|
|
122
|
+
x === T && (l.value = "load");
|
|
123
|
+
} finally {
|
|
124
|
+
x === T && (g.value = !1);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function O(x, f) {
|
|
128
|
+
if (!k.value || I.value) return;
|
|
129
|
+
const M = j.value.get(x);
|
|
130
|
+
M ? Object.assign(M, f) : s.value.push({ productId: x, adjustWeight: !1, weight: 0.5, ...f }), l.value = null, S.value = !1;
|
|
131
|
+
}
|
|
132
|
+
function X() {
|
|
133
|
+
I.value || (s.value = Z(r.value), A.delete(N), l.value = null, S.value = !1);
|
|
134
|
+
}
|
|
135
|
+
async function z(x = !1) {
|
|
136
|
+
if (!k.value || I.value || !x && !U.value) return;
|
|
137
|
+
const f = T, M = N, V = { businessId: e.businessId, restaurantId: e.restaurantId || void 0 };
|
|
138
|
+
if (x && (!V.restaurantId || !e.api.reset) || _(V) !== M) return;
|
|
139
|
+
const H = Z(s.value);
|
|
140
|
+
I.value = !0, S.value = !1, l.value = null;
|
|
141
|
+
try {
|
|
142
|
+
const Y = x ? await e.api.reset(V) : await e.api.save(V, H);
|
|
143
|
+
if (Y.businessId !== V.businessId || (Y.restaurantId || void 0) !== V.restaurantId)
|
|
144
|
+
throw new Error("Settings scope mismatch");
|
|
145
|
+
if (f !== T) {
|
|
146
|
+
const p = A.get(M);
|
|
147
|
+
M !== N && p && oe(p.items) === oe(H) && A.delete(M);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
return s.value = Z(Y.items), r.value = Z(Y.items), a.value = Y.inherited === !0, A.delete(M), S.value = !0, Y;
|
|
151
|
+
} catch {
|
|
152
|
+
f === T && (l.value = "save");
|
|
153
|
+
} finally {
|
|
154
|
+
f === T && (I.value = !1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return G(() => [e.businessId, e.restaurantId, e.api, e.loadProducts], D, { immediate: !0, flush: "sync" }), ue(() => {
|
|
158
|
+
T++;
|
|
159
|
+
}), { hasUnsaved: P, items: s, baseline: r, itemMap: j, rows: J, loaded: k, loading: g, saving: I, dirty: U, error: l, saved: S, inherited: a, load: D, save: () => z(), reset: () => z(!0), change: O, discard: X };
|
|
160
|
+
}
|
|
161
|
+
function de(e, t = 5) {
|
|
162
|
+
const s = e.filter((g) => !g.unit && !g.perXUnit && !g.isOutOfStocked), r = Math.min(s.length, 5, Math.max(0, Math.floor(t)));
|
|
163
|
+
return s.slice(0, r % 2 === 0 ? Math.max(0, r - 1) : r);
|
|
164
|
+
}
|
|
165
|
+
const he = (e) => JSON.stringify([e.businessId, e.restaurantId || void 0]), je = (e, t) => (e == null ? void 0 : e.adjustWeight) === t.adjustWeight && (e == null ? void 0 : e.weight) === t.weight;
|
|
166
|
+
function We(e, t) {
|
|
167
|
+
const s = new Map(e.map((r) => [r.productId, r]));
|
|
168
|
+
return t.filter((r) => !je(s.get(r.productId), r)).map((r) => ({ ...r }));
|
|
169
|
+
}
|
|
170
|
+
function Be(e, t) {
|
|
171
|
+
const s = new Map(e.map((r) => [r.productId, { ...r }]));
|
|
172
|
+
for (const r of t) s.set(r.productId, { ...r });
|
|
173
|
+
return [...s.values()];
|
|
174
|
+
}
|
|
175
|
+
const Fe = ["aria-label"], De = { class: "upsell-preview-header" }, Ve = { class: "fm-typo-en-body-lg-600" }, He = ["aria-label"], qe = ["aria-pressed", "onClick"], ze = {
|
|
176
|
+
key: 0,
|
|
177
|
+
class: "upsell-preview-context"
|
|
178
|
+
}, Je = { class: "upsell-preview-cart" }, Xe = ["data-cart-product"], Ye = { class: "upsell-preview-quantity" }, Ke = { class: "upsell-sr-only" }, Ge = ["value", "onChange"], Qe = ["aria-label", "title", "onClick"], Ze = { class: "upsell-preview-cart-note" }, et = {
|
|
179
|
+
key: 1,
|
|
180
|
+
class: "upsell-sr-only",
|
|
181
|
+
role: "status"
|
|
182
|
+
}, tt = ["aria-busy"], at = ["data-preview"], rt = { class: "upsell-preview-panel-label" }, lt = { class: "fm-typo-en-body-md-600" }, st = { class: "upsell-preview-touchpoint" }, nt = {
|
|
183
|
+
key: 0,
|
|
184
|
+
class: "upsell-preview-signals"
|
|
185
|
+
}, ot = ["data-active"], ut = ["data-active"], it = ["role"], dt = {
|
|
186
|
+
key: 2,
|
|
187
|
+
class: "upsell-preview-none"
|
|
188
|
+
}, ct = ["data-preview-product"], pt = ["src", "onError"], vt = {
|
|
189
|
+
key: 1,
|
|
190
|
+
class: "upsell-preview-photo"
|
|
191
|
+
}, mt = { key: 0 }, gt = /* @__PURE__ */ ce({
|
|
192
|
+
__name: "UpsellPreview",
|
|
193
|
+
props: {
|
|
194
|
+
host: {},
|
|
195
|
+
products: {},
|
|
196
|
+
savedItems: {},
|
|
197
|
+
draftItems: {},
|
|
198
|
+
text: {},
|
|
199
|
+
touchpoints: {}
|
|
200
|
+
},
|
|
201
|
+
setup(e) {
|
|
202
|
+
const t = e, { FmSelect: s, FmButton: r } = Ce, g = $([]), I = $(""), k = $("restaurant"), l = $([]), S = $(!1), a = $(!1), U = $(!1), A = $(/* @__PURE__ */ new Set()), P = $(null);
|
|
203
|
+
let _ = 0, N = "", T = !1, j;
|
|
204
|
+
ue(() => {
|
|
205
|
+
T = !0, _++, clearTimeout(j);
|
|
206
|
+
});
|
|
207
|
+
const J = B(() => g.value.find((p) => p.scope.restaurantId === I.value)), F = B(() => {
|
|
208
|
+
var p;
|
|
209
|
+
return ((p = J.value) == null ? void 0 : p.products) ?? [];
|
|
210
|
+
}), D = B(() => F.value.filter((p) => !l.value.some((C) => C.productId === p.productId)).map((p) => ({ value: p.productId, label: p.name }))), O = B(() => g.value.map((p) => ({ value: p.scope.restaurantId, label: p.name }))), X = B(() => [
|
|
211
|
+
{ value: "restaurant", label: t.text.previewRestaurant },
|
|
212
|
+
{ value: "cart", label: t.text.previewCartBased }
|
|
213
|
+
]), z = B(() => {
|
|
214
|
+
var p, C, i, E, o, R;
|
|
215
|
+
return [
|
|
216
|
+
{ id: "saved", title: t.text.previewSaved, products: ((p = P.value) == null ? void 0 : p.saved.products) ?? [], source: (C = P.value) == null ? void 0 : C.saved.source, weightsEnabled: (i = P.value) == null ? void 0 : i.saved.weightsEnabled },
|
|
217
|
+
{ id: "draft", title: t.text.previewDraft, products: ((E = P.value) == null ? void 0 : E.draft.products) ?? [], source: (o = P.value) == null ? void 0 : o.draft.source, weightsEnabled: (R = P.value) == null ? void 0 : R.draft.weightsEnabled }
|
|
218
|
+
];
|
|
219
|
+
}), x = B(() => {
|
|
220
|
+
var p;
|
|
221
|
+
return U.value || a.value ? t.text.previewLoadError : J.value ? k.value === "cart" && !l.value.length ? t.text.previewCartEmpty : (p = t.host) != null && p.loadPreview ? S.value && !P.value ? t.text.previewLoading : "" : t.text.previewUnavailable : t.text.previewChooseOutlet;
|
|
222
|
+
});
|
|
223
|
+
async function f() {
|
|
224
|
+
var p, C;
|
|
225
|
+
U.value = !1;
|
|
226
|
+
try {
|
|
227
|
+
const i = t.host;
|
|
228
|
+
let E = [];
|
|
229
|
+
if (i != null && i.loadApplyTargets ? E = await i.loadApplyTargets(i.businessId) : i != null && i.restaurantId && (E = [{ scope: { businessId: i.businessId, restaurantId: i.restaurantId }, name: i.restaurantName ?? i.restaurantId, products: t.products }]), T) return;
|
|
230
|
+
g.value = E.filter((o) => (!(i != null && i.restaurantId) || o.scope.restaurantId === i.restaurantId) && o.scope.restaurantId && o.scope.businessId === (i == null ? void 0 : i.businessId) && !o.unavailableReason), I.value = ((p = g.value.find((o) => o.scope.restaurantId === (i == null ? void 0 : i.restaurantId))) == null ? void 0 : p.scope.restaurantId) ?? ((C = g.value[0]) == null ? void 0 : C.scope.restaurantId) ?? "";
|
|
231
|
+
} catch {
|
|
232
|
+
T || (U.value = !0);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
be(f), G(I, () => {
|
|
236
|
+
l.value = [], A.value = /* @__PURE__ */ new Set();
|
|
237
|
+
});
|
|
238
|
+
function M(p) {
|
|
239
|
+
D.value.some((C) => C.value === p) && (l.value = [...l.value, { productId: p, quantity: 1 }]);
|
|
240
|
+
}
|
|
241
|
+
function V(p, C) {
|
|
242
|
+
const i = Number(C.target.value), E = l.value.find((o) => o.productId === p);
|
|
243
|
+
E && (E.quantity = Number.isInteger(i) && i >= 1 && i <= 99 ? i : 1), C.target.value = String((E == null ? void 0 : E.quantity) ?? 1);
|
|
244
|
+
}
|
|
245
|
+
function H(p, C) {
|
|
246
|
+
if (!p || !["historical", "weight_only", "no_data", "unknown"].includes(p.source) || !Array.isArray(p.products)) throw new Error("Invalid preview products");
|
|
247
|
+
const i = p.products.map((E) => E.productId);
|
|
248
|
+
if (i.some((E) => !C.has(E)) || new Set(i).size !== i.length) throw new Error("Invalid preview products");
|
|
249
|
+
}
|
|
250
|
+
async function Y() {
|
|
251
|
+
clearTimeout(j);
|
|
252
|
+
const p = ++_;
|
|
253
|
+
a.value = !1, S.value = !1;
|
|
254
|
+
const C = t.host, i = J.value, E = `${C == null ? void 0 : C.businessId}:${i == null ? void 0 : i.scope.restaurantId}:${k.value}`;
|
|
255
|
+
if (E !== N && (P.value = null), N = E, !(C != null && C.loadPreview) || !(i != null && i.scope.restaurantId) || k.value === "cart" && !l.value.length) {
|
|
256
|
+
P.value = null;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const o = { businessId: C.businessId, restaurantId: i.scope.restaurantId }, R = k.value, K = R === "cart" ? l.value.map((q) => ({ ...q })) : [], Q = new Set(i.products.map((q) => q.productId)), re = We(t.savedItems, t.draftItems).filter((q) => Q.has(q.productId)), W = C.loadPreview;
|
|
260
|
+
S.value = !0;
|
|
261
|
+
try {
|
|
262
|
+
const q = await C.api.get(o);
|
|
263
|
+
if (p !== _) return;
|
|
264
|
+
if (he(q) !== he(o)) throw new Error("Preview scope mismatch");
|
|
265
|
+
const le = (b) => ({ ...o, recommendationType: R, cart: K.map((ee) => ({ ...ee })), items: b.filter((ee) => Q.has(ee.productId)).map((ee) => ({ ...ee })), limit: 5 }), d = C.restaurantId || q.inherited === !0 ? re : [], m = [{ ...le(q.items), mode: "current" }, { ...le(Be(q.items, d)), mode: "preview" }], n = await Promise.all(m.map((b) => W(b)));
|
|
266
|
+
if (p !== _) return;
|
|
267
|
+
n.forEach((b) => H(b, Q)), P.value = { saved: { ...n[0], weightsEnabled: m[0].items.some((b) => b.adjustWeight), products: de(n[0].products) }, draft: { ...n[1], weightsEnabled: m[1].items.some((b) => b.adjustWeight), products: de(n[1].products) } };
|
|
268
|
+
} catch {
|
|
269
|
+
p === _ && (P.value = null, a.value = !0);
|
|
270
|
+
} finally {
|
|
271
|
+
p === _ && (S.value = !1);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return G(() => {
|
|
275
|
+
var p;
|
|
276
|
+
return [J.value, k.value, l.value, t.savedItems, (p = t.host) == null ? void 0 : p.loadPreview];
|
|
277
|
+
}, Y, { deep: !0 }), G(() => t.draftItems, () => {
|
|
278
|
+
var p;
|
|
279
|
+
_++, a.value = !1, S.value = !!((p = t.host) != null && p.loadPreview), clearTimeout(j), j = setTimeout(Y, 250);
|
|
280
|
+
}, { deep: !0 }), (p, C) => {
|
|
281
|
+
var i, E;
|
|
282
|
+
return ((i = e.touchpoints) == null ? void 0 : i.length) !== 0 ? (v(), w("section", {
|
|
283
|
+
key: 0,
|
|
284
|
+
class: "upsell-preview",
|
|
285
|
+
"aria-label": e.text.preview
|
|
286
|
+
}, [
|
|
287
|
+
h("header", De, [
|
|
288
|
+
h("h2", Ve, y(e.text.preview), 1),
|
|
289
|
+
(E = e.host) != null && E.restaurantId ? L("", !0) : (v(), ae(u(s), {
|
|
290
|
+
key: 0,
|
|
291
|
+
modelValue: I.value,
|
|
292
|
+
"onUpdate:modelValue": C[0] || (C[0] = (o) => I.value = o),
|
|
293
|
+
label: e.text.previewOutlet,
|
|
294
|
+
items: O.value
|
|
295
|
+
}, null, 8, ["modelValue", "label", "items"])),
|
|
296
|
+
h("div", {
|
|
297
|
+
class: "upsell-preview-tabs",
|
|
298
|
+
role: "group",
|
|
299
|
+
"aria-label": e.text.preview
|
|
300
|
+
}, [
|
|
301
|
+
(v(!0), w(se, null, ne(X.value, (o) => (v(), w("button", {
|
|
302
|
+
key: o.value,
|
|
303
|
+
type: "button",
|
|
304
|
+
"aria-pressed": k.value === o.value,
|
|
305
|
+
onClick: (R) => k.value = o.value
|
|
306
|
+
}, y(o.label), 9, qe))), 128))
|
|
307
|
+
], 8, He)
|
|
308
|
+
]),
|
|
309
|
+
k.value === "cart" ? (v(), w("div", ze, [
|
|
310
|
+
te(u(s), {
|
|
311
|
+
"model-value": "",
|
|
312
|
+
label: e.text.previewOrder,
|
|
313
|
+
items: D.value,
|
|
314
|
+
"onUpdate:modelValue": M
|
|
315
|
+
}, null, 8, ["label", "items"]),
|
|
316
|
+
h("ul", Je, [
|
|
317
|
+
(v(!0), w(se, null, ne(l.value, (o) => {
|
|
318
|
+
var R, K, Q, re;
|
|
319
|
+
return v(), w("li", {
|
|
320
|
+
key: o.productId,
|
|
321
|
+
"data-cart-product": o.productId
|
|
322
|
+
}, [
|
|
323
|
+
h("span", null, y((R = F.value.find((W) => W.productId === o.productId)) == null ? void 0 : R.name), 1),
|
|
324
|
+
h("label", Ye, [
|
|
325
|
+
h("span", Ke, y(e.text.previewQuantity) + ": " + y((K = F.value.find((W) => W.productId === o.productId)) == null ? void 0 : K.name), 1),
|
|
326
|
+
C[2] || (C[2] = h("span", { "aria-hidden": "true" }, "×", -1)),
|
|
327
|
+
h("input", {
|
|
328
|
+
type: "number",
|
|
329
|
+
min: "1",
|
|
330
|
+
max: "99",
|
|
331
|
+
value: o.quantity,
|
|
332
|
+
onChange: (W) => V(o.productId, W)
|
|
333
|
+
}, null, 40, Ge)
|
|
334
|
+
]),
|
|
335
|
+
h("button", {
|
|
336
|
+
type: "button",
|
|
337
|
+
class: "upsell-preview-remove",
|
|
338
|
+
"aria-label": `${e.text.previewRemove} ${(Q = F.value.find((W) => W.productId === o.productId)) == null ? void 0 : Q.name}`,
|
|
339
|
+
title: `${e.text.previewRemove} ${(re = F.value.find((W) => W.productId === o.productId)) == null ? void 0 : re.name}`,
|
|
340
|
+
onClick: (W) => l.value = l.value.filter((q) => q.productId !== o.productId)
|
|
341
|
+
}, [...C[3] || (C[3] = [
|
|
342
|
+
h("svg", {
|
|
343
|
+
width: "16",
|
|
344
|
+
height: "16",
|
|
345
|
+
viewBox: "0 0 24 24",
|
|
346
|
+
fill: "none",
|
|
347
|
+
"aria-hidden": "true"
|
|
348
|
+
}, [
|
|
349
|
+
h("path", {
|
|
350
|
+
d: "m6 6 12 12M18 6 6 18",
|
|
351
|
+
stroke: "currentColor",
|
|
352
|
+
"stroke-width": "1.8",
|
|
353
|
+
"stroke-linecap": "round"
|
|
354
|
+
})
|
|
355
|
+
], -1)
|
|
356
|
+
])], 8, Qe)
|
|
357
|
+
], 8, Xe);
|
|
358
|
+
}), 128))
|
|
359
|
+
]),
|
|
360
|
+
h("p", Ze, y(e.text.previewCartQuantities), 1)
|
|
361
|
+
])) : L("", !0),
|
|
362
|
+
S.value && P.value ? (v(), w("p", et, y(e.text.previewLoading), 1)) : L("", !0),
|
|
363
|
+
h("div", {
|
|
364
|
+
class: "upsell-preview-panels",
|
|
365
|
+
"aria-busy": S.value
|
|
366
|
+
}, [
|
|
367
|
+
(v(!0), w(se, null, ne(z.value, (o) => (v(), w("article", {
|
|
368
|
+
key: o.id,
|
|
369
|
+
"data-preview": o.id,
|
|
370
|
+
class: "upsell-preview-panel"
|
|
371
|
+
}, [
|
|
372
|
+
h("div", rt, [
|
|
373
|
+
h("h3", lt, y(o.title), 1)
|
|
374
|
+
]),
|
|
375
|
+
h("div", st, [
|
|
376
|
+
o.source && o.source !== "unknown" ? (v(), w("div", nt, [
|
|
377
|
+
h("span", {
|
|
378
|
+
"data-active": o.weightsEnabled
|
|
379
|
+
}, y(o.weightsEnabled ? e.text.previewWeightsOn : e.text.previewWeightsOff), 9, ot),
|
|
380
|
+
h("span", {
|
|
381
|
+
"data-active": o.source === "historical"
|
|
382
|
+
}, y(o.source === "historical" ? e.text.previewRelevanceOn : e.text.previewRelevanceOff), 9, ut)
|
|
383
|
+
])) : L("", !0),
|
|
384
|
+
x.value ? (v(), w("p", {
|
|
385
|
+
key: 1,
|
|
386
|
+
class: ke(["upsell-preview-none", { "upsell-error": a.value || U.value }]),
|
|
387
|
+
role: a.value || U.value ? "alert" : "status"
|
|
388
|
+
}, y(x.value), 11, it)) : P.value && !o.products.length ? (v(), w("p", dt, y(o.source === "no_data" ? e.text.previewNoData : e.text.previewEmpty), 1)) : (v(), ae($e, {
|
|
389
|
+
key: 3,
|
|
390
|
+
tag: "ul",
|
|
391
|
+
name: "upsell-suggestion",
|
|
392
|
+
"aria-label": o.source === "unknown" ? o.title : `${o.title}: ${o.weightsEnabled ? e.text.previewWeightsOn : e.text.previewWeightsOff}, ${o.source === "historical" ? e.text.previewRelevanceOn : e.text.previewRelevanceOff}`
|
|
393
|
+
}, {
|
|
394
|
+
default: Ie(() => [
|
|
395
|
+
(v(!0), w(se, null, ne(o.products, (R) => (v(), w("li", {
|
|
396
|
+
key: R.productId,
|
|
397
|
+
"data-preview-product": R.productId
|
|
398
|
+
}, [
|
|
399
|
+
R.imageUrl && !A.value.has(R.productId) ? (v(), w("img", {
|
|
400
|
+
key: 0,
|
|
401
|
+
src: R.imageUrl,
|
|
402
|
+
alt: "",
|
|
403
|
+
loading: "lazy",
|
|
404
|
+
onError: (K) => A.value.add(R.productId)
|
|
405
|
+
}, null, 40, pt)) : (v(), w("span", vt, y(e.text.missingPhoto), 1)),
|
|
406
|
+
h("div", null, [
|
|
407
|
+
h("h4", null, y(R.name), 1),
|
|
408
|
+
R.priceLabel ? (v(), w("p", mt, y(R.priceLabel), 1)) : L("", !0)
|
|
409
|
+
])
|
|
410
|
+
], 8, ct))), 128))
|
|
411
|
+
]),
|
|
412
|
+
_: 2
|
|
413
|
+
}, 1032, ["aria-label"]))
|
|
414
|
+
])
|
|
415
|
+
], 8, at))), 128))
|
|
416
|
+
], 8, tt),
|
|
417
|
+
a.value || U.value ? (v(), ae(u(r), {
|
|
418
|
+
key: 2,
|
|
419
|
+
label: e.text.retry,
|
|
420
|
+
variant: "secondary",
|
|
421
|
+
onClick: C[1] || (C[1] = (o) => U.value ? f() : Y())
|
|
422
|
+
}, null, 8, ["label"])) : L("", !0)
|
|
423
|
+
], 8, Fe)) : L("", !0);
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
}), ht = ["aria-label", "aria-busy"], wt = { class: "upsell-header" }, yt = {
|
|
427
|
+
key: 0,
|
|
428
|
+
class: "upsell-eyebrow"
|
|
429
|
+
}, ft = {
|
|
430
|
+
key: 1,
|
|
431
|
+
class: "upsell-eyebrow"
|
|
432
|
+
}, bt = { class: "upsell-actions" }, It = { class: "upsell-note" }, kt = {
|
|
433
|
+
key: 0,
|
|
434
|
+
class: "upsell-scope"
|
|
435
|
+
}, Ct = { class: "upsell-description" }, Tt = {
|
|
436
|
+
key: 0,
|
|
437
|
+
class: "upsell-error",
|
|
438
|
+
role: "alert"
|
|
439
|
+
}, xt = {
|
|
440
|
+
key: 1,
|
|
441
|
+
class: "upsell-description"
|
|
442
|
+
}, Et = {
|
|
443
|
+
class: "upsell-feedback",
|
|
444
|
+
"aria-live": "polite"
|
|
445
|
+
}, Pt = {
|
|
446
|
+
key: 0,
|
|
447
|
+
role: "alert",
|
|
448
|
+
class: "upsell-error"
|
|
449
|
+
}, St = {
|
|
450
|
+
key: 1,
|
|
451
|
+
class: "upsell-success"
|
|
452
|
+
}, Ot = { key: 2 }, Ut = {
|
|
453
|
+
key: 2,
|
|
454
|
+
class: "upsell-empty"
|
|
455
|
+
}, At = {
|
|
456
|
+
key: 3,
|
|
457
|
+
class: "upsell-empty",
|
|
458
|
+
role: "status"
|
|
459
|
+
}, $t = {
|
|
460
|
+
key: 4,
|
|
461
|
+
class: "upsell-empty"
|
|
462
|
+
}, Mt = {
|
|
463
|
+
key: 5,
|
|
464
|
+
class: "upsell-editor"
|
|
465
|
+
}, Rt = { class: "upsell-editor-products" }, Nt = { class: "upsell-toolbar" }, Lt = { class: "upsell-search" }, _t = {
|
|
466
|
+
key: 0,
|
|
467
|
+
class: "upsell-empty"
|
|
468
|
+
}, jt = {
|
|
469
|
+
key: 1,
|
|
470
|
+
class: "upsell-empty"
|
|
471
|
+
}, Wt = {
|
|
472
|
+
key: 2,
|
|
473
|
+
class: "upsell-products"
|
|
474
|
+
}, Bt = ["data-product-id"], Ft = { class: "upsell-product" }, Dt = ["src", "onError"], Vt = {
|
|
475
|
+
key: 1,
|
|
476
|
+
class: "upsell-photo upsell-no-photo"
|
|
477
|
+
}, Ht = { key: 0 }, qt = { key: 1 }, zt = {
|
|
478
|
+
key: 2,
|
|
479
|
+
class: "upsell-unavailable"
|
|
480
|
+
}, Jt = { class: "upsell-switch" }, Xt = { class: "upsell-sr-only" }, Yt = { class: "upsell-weight-heading" }, Kt = { key: 0 }, Gt = ["aria-label"], Qt = ["value", "aria-label", "aria-valuetext", "disabled", "data-boosted", "onInput", "onPointermove", "onPointerup", "onPointercancel", "onLostpointercapture"], Zt = /* @__PURE__ */ ce({
|
|
481
|
+
__name: "UpsellingSettings",
|
|
482
|
+
props: {
|
|
483
|
+
loadPreview: { type: Function },
|
|
484
|
+
loadApplyTargets: { type: Function },
|
|
485
|
+
restaurantName: {},
|
|
486
|
+
messages: {},
|
|
487
|
+
previewTouchpoints: {},
|
|
488
|
+
api: {},
|
|
489
|
+
loadProducts: { type: Function },
|
|
490
|
+
businessId: {},
|
|
491
|
+
restaurantId: {}
|
|
492
|
+
},
|
|
493
|
+
emits: ["dirty-change", "busy-change", "saved"],
|
|
494
|
+
setup(e, { expose: t, emit: s }) {
|
|
495
|
+
const { FmButton: r, FmSwitch: g, FmTextField: I, FmSelect: k } = Ce, l = e, S = s, a = B(() => ({ ...Le, ...l.messages })), U = $(""), A = $(/* @__PURE__ */ new Set()), P = $(l.restaurantId ?? ""), _ = $([]), N = $(!1), T = $(!1);
|
|
496
|
+
let j = 0;
|
|
497
|
+
G(() => [l.businessId, l.restaurantId], () => {
|
|
498
|
+
P.value = l.restaurantId ?? "";
|
|
499
|
+
}, { flush: "sync" });
|
|
500
|
+
async function J() {
|
|
501
|
+
var d;
|
|
502
|
+
const m = ++j;
|
|
503
|
+
_.value = [], T.value = !1, N.value = !!l.loadApplyTargets;
|
|
504
|
+
try {
|
|
505
|
+
const n = await ((d = l.loadApplyTargets) == null ? void 0 : d.call(l, l.businessId)) ?? [];
|
|
506
|
+
m === j && (_.value = n.filter((b) => b.scope.businessId === l.businessId));
|
|
507
|
+
} catch {
|
|
508
|
+
m === j && (T.value = !0);
|
|
509
|
+
} finally {
|
|
510
|
+
m === j && (N.value = !1);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
G(() => [l.businessId, l.loadApplyTargets], J, { immediate: !0 });
|
|
514
|
+
const F = B(() => [
|
|
515
|
+
{ value: "", label: a.value.businessDefault },
|
|
516
|
+
..._.value.filter((d) => d.scope.restaurantId && !d.unavailableReason).map((d) => ({ value: d.scope.restaurantId, label: d.name }))
|
|
517
|
+
]), D = fe({
|
|
518
|
+
get businessId() {
|
|
519
|
+
return l.businessId;
|
|
520
|
+
},
|
|
521
|
+
get restaurantId() {
|
|
522
|
+
return P.value || void 0;
|
|
523
|
+
},
|
|
524
|
+
get restaurantName() {
|
|
525
|
+
var d;
|
|
526
|
+
return ((d = _.value.find((m) => m.scope.restaurantId === P.value)) == null ? void 0 : d.name) ?? l.restaurantName;
|
|
527
|
+
},
|
|
528
|
+
get api() {
|
|
529
|
+
return l.api;
|
|
530
|
+
},
|
|
531
|
+
get loadProducts() {
|
|
532
|
+
return l.loadProducts;
|
|
533
|
+
},
|
|
534
|
+
get loadApplyTargets() {
|
|
535
|
+
return l.loadApplyTargets;
|
|
536
|
+
},
|
|
537
|
+
get loadPreview() {
|
|
538
|
+
return l.loadPreview;
|
|
539
|
+
}
|
|
540
|
+
}), O = _e(D), { hasUnsaved: X } = O, { itemMap: z, loading: x, saving: f, loaded: M, error: V, dirty: H, saved: Y, inherited: p } = O, C = B(() => {
|
|
541
|
+
const d = U.value.trim().toLocaleLowerCase();
|
|
542
|
+
return O.rows.value.filter((m) => !m.unavailable).filter((m) => `${m.name} ${m.category ?? ""} ${m.productId}`.toLocaleLowerCase().includes(d));
|
|
543
|
+
});
|
|
544
|
+
function i(d) {
|
|
545
|
+
var m;
|
|
546
|
+
return ((m = z.value.get(d)) == null ? void 0 : m.weight) ?? 0.5;
|
|
547
|
+
}
|
|
548
|
+
function E(d) {
|
|
549
|
+
var m;
|
|
550
|
+
return ((m = z.value.get(d)) == null ? void 0 : m.adjustWeight) ?? !1;
|
|
551
|
+
}
|
|
552
|
+
function o(d) {
|
|
553
|
+
return E(d) ? i(d) === 0 ? a.value.excluded : i(d) < 0.4 ? a.value.weak : i(d) < 0.6 ? a.value.normal : i(d) < 0.8 ? a.value.strong : a.value.strongest : a.value.automatic;
|
|
554
|
+
}
|
|
555
|
+
function R(d, m) {
|
|
556
|
+
const n = Number(m.target.value);
|
|
557
|
+
O.change(d, { weight: n / 100 });
|
|
558
|
+
}
|
|
559
|
+
const K = /* @__PURE__ */ new WeakMap();
|
|
560
|
+
function Q(d) {
|
|
561
|
+
const m = d.currentTarget;
|
|
562
|
+
m.disabled || d.button !== 0 || (d.preventDefault(), m.focus({ preventScroll: !0 }), K.set(m, { pointerId: d.pointerId, x: d.clientX, value: Number(m.value), width: m.clientWidth || 1 }), m.setPointerCapture(d.pointerId), m.dataset.dragging = "true");
|
|
563
|
+
}
|
|
564
|
+
function re(d, m) {
|
|
565
|
+
const n = m.currentTarget, b = K.get(n);
|
|
566
|
+
if (!b || b.pointerId !== m.pointerId) return;
|
|
567
|
+
const ee = m.clientX - b.x, me = b.value + ee / b.width * 100, ge = Math.max(0, Math.min(100, me)), Se = Math.round(ge);
|
|
568
|
+
O.change(d, { weight: Se / 100 });
|
|
569
|
+
const ie = (me - ge) / 100 * b.width;
|
|
570
|
+
ie !== 0 && n.style.setProperty("--upsell-origin", ie > 0 ? "left center" : "right center"), n.style.setProperty("--upsell-stretch", `${1 + 10 * Math.tanh(Math.abs(ie) / 90) / b.width}`);
|
|
571
|
+
}
|
|
572
|
+
function W(d, m) {
|
|
573
|
+
var n;
|
|
574
|
+
const b = m.currentTarget;
|
|
575
|
+
((n = K.get(b)) == null ? void 0 : n.pointerId) === m.pointerId && (K.delete(b), delete b.dataset.dragging, m.type === "pointerup" && O.change(d, { weight: Math.round(i(d) * 20) / 20 }), b.style.removeProperty("--upsell-stretch"), b.hasPointerCapture(m.pointerId) && b.releasePointerCapture(m.pointerId));
|
|
576
|
+
}
|
|
577
|
+
async function q() {
|
|
578
|
+
const d = await O.save();
|
|
579
|
+
d && S("saved", d);
|
|
580
|
+
}
|
|
581
|
+
function le(d) {
|
|
582
|
+
(X.value || f.value) && (d.preventDefault(), d.returnValue = "");
|
|
583
|
+
}
|
|
584
|
+
return G(X, (d) => S("dirty-change", d), { immediate: !0 }), G(() => f.value, (d) => S("busy-change", d), { immediate: !0 }), G(() => [l.businessId, P.value], () => {
|
|
585
|
+
U.value = "", A.value = /* @__PURE__ */ new Set();
|
|
586
|
+
}), be(() => window.addEventListener("beforeunload", le)), ue(() => {
|
|
587
|
+
j++;
|
|
588
|
+
}), ue(() => window.removeEventListener("beforeunload", le)), t({ dirty: X, saving: f, discard: O.discard }), (d, m) => (v(), w("section", {
|
|
589
|
+
class: "fm-upselling",
|
|
590
|
+
"aria-label": a.value.title,
|
|
591
|
+
"aria-busy": u(x) || u(f)
|
|
592
|
+
}, [
|
|
593
|
+
h("header", wt, [
|
|
594
|
+
h("div", null, [
|
|
595
|
+
!e.loadApplyTargets && e.restaurantName ? (v(), w("p", yt, y(e.restaurantName), 1)) : L("", !0),
|
|
596
|
+
e.loadApplyTargets ? L("", !0) : (v(), w("p", ft, y(e.restaurantId ? a.value.restaurantOverride : a.value.businessDefault), 1)),
|
|
597
|
+
h("h1", null, y(a.value.title), 1)
|
|
598
|
+
]),
|
|
599
|
+
h("div", bt, [
|
|
600
|
+
P.value && e.api.reset ? (v(), ae(u(r), {
|
|
601
|
+
key: 0,
|
|
602
|
+
variant: "secondary",
|
|
603
|
+
label: a.value.reset,
|
|
604
|
+
disabled: u(f) || !u(M) || u(p) && !u(H),
|
|
605
|
+
onClick: u(O).reset
|
|
606
|
+
}, null, 8, ["label", "disabled", "onClick"])) : L("", !0),
|
|
607
|
+
te(u(r), {
|
|
608
|
+
variant: "secondary",
|
|
609
|
+
label: a.value.discard,
|
|
610
|
+
disabled: !u(H) || u(f) || !u(M),
|
|
611
|
+
onClick: u(O).discard
|
|
612
|
+
}, null, 8, ["label", "disabled", "onClick"]),
|
|
613
|
+
te(u(r), {
|
|
614
|
+
label: u(f) ? a.value.saving : e.loadApplyTargets ? a.value.apply : a.value.save,
|
|
615
|
+
loading: u(f),
|
|
616
|
+
disabled: !u(H) || u(f) || N.value || T.value || !u(M),
|
|
617
|
+
onClick: q
|
|
618
|
+
}, null, 8, ["label", "loading", "disabled"])
|
|
619
|
+
])
|
|
620
|
+
]),
|
|
621
|
+
h("p", It, y(a.value.hint), 1),
|
|
622
|
+
e.loadApplyTargets ? (v(), w("div", kt, [
|
|
623
|
+
te(u(k), {
|
|
624
|
+
modelValue: P.value,
|
|
625
|
+
"onUpdate:modelValue": m[0] || (m[0] = (n) => P.value = n),
|
|
626
|
+
label: a.value.editingScope,
|
|
627
|
+
items: F.value,
|
|
628
|
+
disabled: u(f) || N.value || T.value
|
|
629
|
+
}, null, 8, ["modelValue", "label", "items", "disabled"]),
|
|
630
|
+
h("p", Ct, y(P.value ? a.value.editingOutletHint : a.value.editingBusinessHint), 1),
|
|
631
|
+
T.value ? (v(), w("p", Tt, y(a.value.loadError), 1)) : L("", !0),
|
|
632
|
+
T.value ? (v(), ae(u(r), {
|
|
633
|
+
key: 1,
|
|
634
|
+
variant: "secondary",
|
|
635
|
+
label: a.value.retry,
|
|
636
|
+
onClick: J
|
|
637
|
+
}, null, 8, ["label"])) : L("", !0)
|
|
638
|
+
])) : L("", !0),
|
|
639
|
+
P.value && u(p) ? (v(), w("p", xt, y(a.value.inherited), 1)) : L("", !0),
|
|
640
|
+
h("div", Et, [
|
|
641
|
+
u(V) ? (v(), w("p", Pt, y(u(V) === "load" ? a.value.loadError : a.value.saveError), 1)) : u(Y) ? (v(), w("p", St, y(a.value.saved), 1)) : u(H) ? (v(), w("p", Ot, y(a.value.dirty), 1)) : L("", !0)
|
|
642
|
+
]),
|
|
643
|
+
e.businessId ? u(x) ? (v(), w("p", At, y(a.value.loading), 1)) : u(V) === "load" ? (v(), w("div", $t, [
|
|
644
|
+
te(u(r), {
|
|
645
|
+
variant: "secondary",
|
|
646
|
+
label: a.value.retry,
|
|
647
|
+
onClick: u(O).load
|
|
648
|
+
}, null, 8, ["label", "onClick"])
|
|
649
|
+
])) : u(M) ? (v(), w("div", Mt, [
|
|
650
|
+
h("div", Rt, [
|
|
651
|
+
h("div", Nt, [
|
|
652
|
+
h("h2", null, [
|
|
653
|
+
Oe(y(a.value.products) + " ", 1),
|
|
654
|
+
h("span", null, y(u(O).rows.value.filter((n) => !n.unavailable).length), 1)
|
|
655
|
+
]),
|
|
656
|
+
h("div", Lt, [
|
|
657
|
+
te(u(I), {
|
|
658
|
+
modelValue: U.value,
|
|
659
|
+
"onUpdate:modelValue": m[1] || (m[1] = (n) => U.value = n),
|
|
660
|
+
label: a.value.search,
|
|
661
|
+
placeholder: a.value.search
|
|
662
|
+
}, null, 8, ["modelValue", "label", "placeholder"])
|
|
663
|
+
])
|
|
664
|
+
]),
|
|
665
|
+
u(O).rows.value.some((n) => !n.unavailable) ? C.value.length ? (v(), w("ul", Wt, [
|
|
666
|
+
(v(!0), w(se, null, ne(C.value, (n) => (v(), w("li", {
|
|
667
|
+
key: n.productId,
|
|
668
|
+
class: "upsell-row",
|
|
669
|
+
"data-product-id": n.productId
|
|
670
|
+
}, [
|
|
671
|
+
h("div", Ft, [
|
|
672
|
+
n.imageUrl && !A.value.has(n.productId) ? (v(), w("img", {
|
|
673
|
+
key: 0,
|
|
674
|
+
src: n.imageUrl,
|
|
675
|
+
alt: "",
|
|
676
|
+
class: "upsell-photo",
|
|
677
|
+
loading: "lazy",
|
|
678
|
+
onError: (b) => A.value.add(n.productId)
|
|
679
|
+
}, null, 40, Dt)) : (v(), w("span", Vt, y(a.value.missingPhoto), 1)),
|
|
680
|
+
h("div", null, [
|
|
681
|
+
h("h3", null, y(n.unavailable ? a.value.unavailable : n.name), 1),
|
|
682
|
+
n.unavailable ? (v(), w("p", Ht, y(n.productId), 1)) : (v(), w("p", qt, y([n.category, n.priceLabel].filter(Boolean).join(" · ")), 1)),
|
|
683
|
+
n.unavailable ? (v(), w("p", zt, y(a.value.unavailableHint), 1)) : L("", !0)
|
|
684
|
+
])
|
|
685
|
+
]),
|
|
686
|
+
h("div", Jt, [
|
|
687
|
+
te(u(g), {
|
|
688
|
+
"model-value": E(n.productId),
|
|
689
|
+
disabled: u(f),
|
|
690
|
+
"onUpdate:modelValue": (b) => u(O).change(n.productId, { adjustWeight: b })
|
|
691
|
+
}, {
|
|
692
|
+
label: Ie(() => [
|
|
693
|
+
h("span", Xt, y(a.value.adjust) + ": " + y(n.name), 1)
|
|
694
|
+
]),
|
|
695
|
+
_: 2
|
|
696
|
+
}, 1032, ["model-value", "disabled", "onUpdate:modelValue"])
|
|
697
|
+
]),
|
|
698
|
+
h("div", {
|
|
699
|
+
class: ke(["upsell-weight", { "upsell-weight-auto": !E(n.productId) }])
|
|
700
|
+
}, [
|
|
701
|
+
h("div", Yt, [
|
|
702
|
+
E(n.productId) ? (v(), w("span", Kt, y(o(n.productId)), 1)) : L("", !0),
|
|
703
|
+
h("output", {
|
|
704
|
+
"aria-label": `${a.value.weight}: ${n.name}`
|
|
705
|
+
}, y(E(n.productId) ? `${Math.round(i(n.productId) * 100)}%` : a.value.automatic), 9, Gt)
|
|
706
|
+
]),
|
|
707
|
+
h("input", {
|
|
708
|
+
type: "range",
|
|
709
|
+
min: "0",
|
|
710
|
+
max: "100",
|
|
711
|
+
step: "1",
|
|
712
|
+
value: Math.round(i(n.productId) * 100),
|
|
713
|
+
"aria-label": `${a.value.weight}: ${n.name}`,
|
|
714
|
+
"aria-valuetext": `${Math.round(i(n.productId) * 100)}% — ${o(n.productId)}`,
|
|
715
|
+
disabled: !E(n.productId) || u(f),
|
|
716
|
+
"data-boosted": E(n.productId) && i(n.productId) >= 0.8,
|
|
717
|
+
style: Ue({ "--upsell-fill": `${E(n.productId) ? i(n.productId) * 100 : 0}%` }),
|
|
718
|
+
onInput: (b) => R(n.productId, b),
|
|
719
|
+
onPointerdown: Q,
|
|
720
|
+
onPointermove: (b) => re(n.productId, b),
|
|
721
|
+
onPointerup: (b) => W(n.productId, b),
|
|
722
|
+
onPointercancel: (b) => W(n.productId, b),
|
|
723
|
+
onLostpointercapture: (b) => W(n.productId, b)
|
|
724
|
+
}, null, 44, Qt)
|
|
725
|
+
], 2)
|
|
726
|
+
], 8, Bt))), 128))
|
|
727
|
+
])) : (v(), w("p", jt, y(a.value.noMatches), 1)) : (v(), w("p", _t, y(a.value.empty), 1))
|
|
728
|
+
]),
|
|
729
|
+
(v(), ae(gt, {
|
|
730
|
+
host: D,
|
|
731
|
+
key: JSON.stringify([e.businessId, P.value]),
|
|
732
|
+
products: u(O).rows.value.filter((n) => !n.unavailable),
|
|
733
|
+
"saved-items": u(O).baseline.value,
|
|
734
|
+
"draft-items": u(O).items.value,
|
|
735
|
+
text: a.value,
|
|
736
|
+
touchpoints: e.previewTouchpoints
|
|
737
|
+
}, null, 8, ["host", "products", "saved-items", "draft-items", "text", "touchpoints"]))
|
|
738
|
+
])) : L("", !0) : (v(), w("p", Ut, y(a.value.chooseRestaurant), 1))
|
|
739
|
+
], 8, ht));
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
function ea(e) {
|
|
743
|
+
const t = new URL(e.baseUrl);
|
|
744
|
+
if (t.protocol !== "https:" && !(t.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(t.hostname)))
|
|
745
|
+
throw new Error("Use HTTPS for report-service, or HTTP on localhost.");
|
|
746
|
+
if (t.username || t.password || t.search || t.hash)
|
|
747
|
+
throw new Error("Report-service URL must not contain credentials, query parameters or a fragment.");
|
|
748
|
+
async function s(r, g, I = g === void 0 ? "GET" : "PUT") {
|
|
749
|
+
const k = await e.getToken();
|
|
750
|
+
if (!k) throw new Error("Sign in to Portal to load upselling settings.");
|
|
751
|
+
const l = await fetch(`${t.href.replace(/\/$/, "")}${r}`, {
|
|
752
|
+
method: I,
|
|
753
|
+
headers: { Authorization: `Bearer ${k}`, ...g === void 0 ? {} : { "Content-Type": "application/json" } },
|
|
754
|
+
body: g === void 0 ? void 0 : JSON.stringify(g),
|
|
755
|
+
cache: "no-store",
|
|
756
|
+
redirect: "error"
|
|
757
|
+
});
|
|
758
|
+
if (!l.ok) throw new Error(`Unable to ${g === void 0 ? "load" : "save"} upselling settings (${l.status}).`);
|
|
759
|
+
return { data: await l.json() };
|
|
760
|
+
}
|
|
761
|
+
return ta({ get: (r) => s(r), put: (r, g) => s(r, g), delete: (r) => s(r, void 0, "DELETE") });
|
|
762
|
+
}
|
|
763
|
+
function ta(e) {
|
|
764
|
+
const t = ({ businessId: s, restaurantId: r }) => `/${encodeURIComponent(s)}${r ? `/${encodeURIComponent(r)}` : ""}/upsell-settings`;
|
|
765
|
+
return {
|
|
766
|
+
async get(s) {
|
|
767
|
+
return (await e.get(t(s))).data;
|
|
768
|
+
},
|
|
769
|
+
async save(s, r) {
|
|
770
|
+
const g = { items: r.map(({ productId: I, adjustWeight: k, weight: l }) => ({ productId: I, adjustWeight: k, weight: l })) };
|
|
771
|
+
return (await e.put(t(s), g)).data;
|
|
772
|
+
},
|
|
773
|
+
...e.delete ? { async reset(s) {
|
|
774
|
+
if (!s.restaurantId) throw new Error("Only restaurant overrides can be reset");
|
|
775
|
+
return (await e.delete(t(s))).data;
|
|
776
|
+
} } : {}
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function aa(e) {
|
|
780
|
+
const t = new URL(e), s = ["localhost", "127.0.0.1", "[::1]"].includes(t.hostname);
|
|
781
|
+
if (t.protocol !== "https:" && !(t.protocol === "http:" && s))
|
|
782
|
+
throw new Error("Use HTTPS for recommendations, or HTTP on localhost.");
|
|
783
|
+
if (t.username || t.password || t.search || t.hash)
|
|
784
|
+
throw new Error("Recommendation URL must not contain credentials, query parameters or a fragment.");
|
|
785
|
+
return t.href.replace(/\/$/, "");
|
|
786
|
+
}
|
|
787
|
+
function ra(e, t) {
|
|
788
|
+
if (!e || typeof e != "object") return !1;
|
|
789
|
+
const s = e;
|
|
790
|
+
if (s.restaurant_id !== t.restaurantId || t.mode === "current" && !["restaurant", "business", "none"].includes(s.source ?? "")) return !1;
|
|
791
|
+
const r = s.product_id, g = s.score;
|
|
792
|
+
return Array.isArray(r) && Array.isArray(g) && r.length === g.length && r.every((I) => typeof I == "string" && I.length > 0) && g.every((I) => typeof I == "number" && Number.isFinite(I)) && new Set(r).size === r.length;
|
|
793
|
+
}
|
|
794
|
+
function la(e) {
|
|
795
|
+
const t = aa(e.baseUrl);
|
|
796
|
+
return async (s) => {
|
|
797
|
+
const r = await e.getToken();
|
|
798
|
+
if (!r) throw new Error("Authentication required for preview");
|
|
799
|
+
const g = e.fetch ?? fetch, I = s.mode ?? "preview", k = await g(`${t}/recommendation/${encodeURIComponent(s.businessId)}/${I}`, {
|
|
800
|
+
method: "POST",
|
|
801
|
+
cache: "no-store",
|
|
802
|
+
redirect: "error",
|
|
803
|
+
signal: AbortSignal.timeout(15e3),
|
|
804
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${r}` },
|
|
805
|
+
body: JSON.stringify({
|
|
806
|
+
restaurant_id: s.restaurantId,
|
|
807
|
+
type: s.recommendationType === "cart" ? "cart" : "whats_hot",
|
|
808
|
+
...s.recommendationType === "cart" ? { cart_item: [...new Set(s.cart.map((a) => a.productId))] } : {},
|
|
809
|
+
...I === "preview" ? { items: s.items.map(({ productId: a, adjustWeight: U, weight: A }) => ({ productId: a, adjustWeight: U, weight: A })) } : {}
|
|
810
|
+
})
|
|
811
|
+
});
|
|
812
|
+
if (!k.ok) throw new Error(`Recommendation preview failed (${k.status})`);
|
|
813
|
+
const l = await k.json();
|
|
814
|
+
if (!ra(l, s)) throw new Error("Preview response is not supported");
|
|
815
|
+
const S = new Map((await e.loadProducts({ businessId: s.businessId, restaurantId: s.restaurantId })).map((a) => [a.productId, a]));
|
|
816
|
+
return { products: de(l.product_id.flatMap((a) => S.has(a) ? [S.get(a)] : []), s.limit), source: "unknown" };
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
const we = c.object({
|
|
820
|
+
catalog: c.array(
|
|
821
|
+
c.object({
|
|
822
|
+
_id: c.string(),
|
|
823
|
+
override: c.object({
|
|
824
|
+
items: c.record(
|
|
825
|
+
c.array(
|
|
826
|
+
c.object({
|
|
827
|
+
combinationKey: c.string().nullish(),
|
|
828
|
+
orderFrom: c.string().nullish(),
|
|
829
|
+
category: c.string().nullish()
|
|
830
|
+
})
|
|
831
|
+
)
|
|
832
|
+
).optional()
|
|
833
|
+
}).passthrough()
|
|
834
|
+
})
|
|
835
|
+
).default([]),
|
|
836
|
+
category: c.array(c.object({ _id: c.string(), name: c.string() })),
|
|
837
|
+
item: c.array(
|
|
838
|
+
c.object({
|
|
839
|
+
_id: c.string().min(1),
|
|
840
|
+
name: c.string(),
|
|
841
|
+
orderFrom: c.string().nullish(),
|
|
842
|
+
unit: c.string().nullish(),
|
|
843
|
+
perXUnit: c.coerce.number().nullish(),
|
|
844
|
+
isOutOfStocked: c.boolean().optional(),
|
|
845
|
+
thumbnail: c.string().nullish(),
|
|
846
|
+
category: c.string().nullish(),
|
|
847
|
+
price: c.object({
|
|
848
|
+
currency: c.string(),
|
|
849
|
+
amount: c.number(),
|
|
850
|
+
precision: c.number()
|
|
851
|
+
}).nullish()
|
|
852
|
+
})
|
|
853
|
+
)
|
|
854
|
+
}), xe = c.object({
|
|
855
|
+
_id: c.string().min(1),
|
|
856
|
+
menuMode: c.enum(["businessLevel", "restaurantLevel"]).optional(),
|
|
857
|
+
modules: we.nullish(),
|
|
858
|
+
restaurants: c.array(
|
|
859
|
+
c.object({
|
|
860
|
+
restaurantId: c.string(),
|
|
861
|
+
modules: we.nullish()
|
|
862
|
+
})
|
|
863
|
+
).nullish()
|
|
864
|
+
});
|
|
865
|
+
function ve() {
|
|
866
|
+
const e = pe();
|
|
867
|
+
if (e.namespace.value !== "dev" || e.currentCountry.value !== "MY")
|
|
868
|
+
throw new Error("Upselling is available in MY dev only.");
|
|
869
|
+
}
|
|
870
|
+
function sa() {
|
|
871
|
+
return ea({
|
|
872
|
+
baseUrl: "https://query-engine.feedmeapidev.com",
|
|
873
|
+
getToken: () => (ve(), Te.getIdToken() ?? "")
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
function na(e) {
|
|
877
|
+
const t = new URL(e), s = t.protocol === "http:" && ["127.0.0.1", "localhost"].includes(t.hostname), r = t.origin === "https://public-query-engine.feedmeapidev.com";
|
|
878
|
+
if (!s && !r || t.username || t.password || t.search || t.hash || t.pathname !== "/")
|
|
879
|
+
throw new Error(
|
|
880
|
+
"Use a local or MY dev recommendation backend for preview."
|
|
881
|
+
);
|
|
882
|
+
return la({
|
|
883
|
+
baseUrl: t.origin,
|
|
884
|
+
getToken: () => (ve(), Te.getIdToken() ?? ""),
|
|
885
|
+
loadProducts: Ee
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
function ye(e, t) {
|
|
889
|
+
var I, k;
|
|
890
|
+
const s = xe.parse(e), r = s.restaurants || s.menuMode === "restaurantLevel" ? (k = (I = s.restaurants) == null ? void 0 : I.find((l) => l.restaurantId === t)) == null ? void 0 : k.modules : s.modules;
|
|
891
|
+
if (!r) return [];
|
|
892
|
+
const g = new Map(
|
|
893
|
+
r.category.map((l) => [l._id, l.name])
|
|
894
|
+
);
|
|
895
|
+
return r.item.map((l) => ({
|
|
896
|
+
productId: l._id,
|
|
897
|
+
name: l.name,
|
|
898
|
+
...l.unit != null ? { unit: l.unit } : {},
|
|
899
|
+
...l.perXUnit != null ? { perXUnit: l.perXUnit } : {},
|
|
900
|
+
...l.isOutOfStocked != null ? { isOutOfStocked: l.isOutOfStocked } : {},
|
|
901
|
+
imageUrl: l.thumbnail ?? void 0,
|
|
902
|
+
category: g.get(l.category ?? ""),
|
|
903
|
+
priceLabel: l.price ? Ne(l.price) : void 0
|
|
904
|
+
}));
|
|
905
|
+
}
|
|
906
|
+
const Ee = async ({
|
|
907
|
+
businessId: e,
|
|
908
|
+
restaurantId: t
|
|
909
|
+
}) => {
|
|
910
|
+
const r = (await Pe(e)).find((g) => g.scope.restaurantId === t);
|
|
911
|
+
if (!r)
|
|
912
|
+
throw new Error("This outlet is not available in the current business.");
|
|
913
|
+
if (r.unavailableReason) throw new Error(r.unavailableReason);
|
|
914
|
+
return r.products;
|
|
915
|
+
}, oa = c.array(
|
|
916
|
+
c.object({
|
|
917
|
+
_id: c.string(),
|
|
918
|
+
businessId: c.string(),
|
|
919
|
+
profile: c.object({ name: c.string().optional() }).passthrough().optional(),
|
|
920
|
+
catalogId: c.string().nullish(),
|
|
921
|
+
additionalCatalogs: c.array(c.string()).nullish(),
|
|
922
|
+
takeaway: c.object({ catalogId: c.string().nullish() }).passthrough().nullish(),
|
|
923
|
+
pickup: c.object({ catalogId: c.string().nullish() }).passthrough().nullish()
|
|
924
|
+
}).passthrough()
|
|
925
|
+
), Pe = async (e) => {
|
|
926
|
+
var S, a, U, A, P, _, N;
|
|
927
|
+
ve();
|
|
928
|
+
const t = pe(), s = oa.parse(t.restaurants.value).filter((T) => T.businessId === e), r = c.object({ menuVersion: c.enum(["v3", "v4"]).nullish() }).parse(t.currentBusiness.value).menuVersion, g = await Re(
|
|
929
|
+
`menu-v4/businesses/${encodeURIComponent(
|
|
930
|
+
e
|
|
931
|
+
)}/menu-v4/effective-menu?modules=item,category,catalog`
|
|
932
|
+
).get(""), I = xe.parse(g.data), k = I.menuMode === "restaurantLevel", l = [
|
|
933
|
+
{
|
|
934
|
+
name: "Business default",
|
|
935
|
+
scope: { businessId: e },
|
|
936
|
+
products: k ? [] : ye(g.data),
|
|
937
|
+
...k ? {
|
|
938
|
+
unavailableReason: "This business uses separate outlet menus. Apply to selected outlets instead; product IDs cannot be combined into one shared catalog."
|
|
939
|
+
} : {}
|
|
940
|
+
}
|
|
941
|
+
];
|
|
942
|
+
for (const T of s) {
|
|
943
|
+
const j = k ? (a = (S = I.restaurants) == null ? void 0 : S.find((D) => D.restaurantId === T._id)) == null ? void 0 : a.modules : I.modules, J = /* @__PURE__ */ new Set();
|
|
944
|
+
let F;
|
|
945
|
+
if (!j) F = "No menu is available for this outlet.";
|
|
946
|
+
else if (r !== "v3" && r !== "v4")
|
|
947
|
+
F = "Menu version could not be verified. Nothing will be applied.";
|
|
948
|
+
else {
|
|
949
|
+
const D = [
|
|
950
|
+
T.catalogId ?? null,
|
|
951
|
+
...T.additionalCatalogs ?? [],
|
|
952
|
+
(U = T.takeaway) == null ? void 0 : U.catalogId,
|
|
953
|
+
(A = T.pickup) == null ? void 0 : A.catalogId
|
|
954
|
+
].filter((O) => O !== void 0);
|
|
955
|
+
for (const O of D) {
|
|
956
|
+
const X = O ? j.catalog.find((z) => z._id === O) : void 0;
|
|
957
|
+
if (O && !X) {
|
|
958
|
+
F = "An assigned catalog is unavailable. Reload this outlet’s menu before applying.";
|
|
959
|
+
break;
|
|
960
|
+
}
|
|
961
|
+
for (const z of j.item) {
|
|
962
|
+
const x = (_ = (P = X == null ? void 0 : X.override.items) == null ? void 0 : P[z._id]) == null ? void 0 : _.find(
|
|
963
|
+
(M) => !M.combinationKey
|
|
964
|
+
);
|
|
965
|
+
((x == null ? void 0 : x.orderFrom) ?? z.orderFrom) !== "NONE" && (r === "v4" || (x == null ? void 0 : x.category) !== "") && J.add(z._id);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
l.push({
|
|
970
|
+
name: ((N = T.profile) == null ? void 0 : N.name) ?? T._id,
|
|
971
|
+
scope: { businessId: e, restaurantId: T._id },
|
|
972
|
+
products: ye(g.data, T._id).filter(
|
|
973
|
+
(D) => J.has(D.productId)
|
|
974
|
+
),
|
|
975
|
+
unavailableReason: F
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
return l;
|
|
979
|
+
};
|
|
980
|
+
var ua = { mode: "development", appMode: "mf" };
|
|
981
|
+
const ha = /* @__PURE__ */ ce({
|
|
982
|
+
__name: "Upselling",
|
|
983
|
+
setup(e) {
|
|
984
|
+
const t = pe(), s = sa(), r = na(
|
|
985
|
+
"https://public-query-engine.feedmeapidev.com"
|
|
986
|
+
), g = $(!1), I = $(!1), k = B(
|
|
987
|
+
() => ua.mode === "development" && t.namespace.value === "dev" && t.currentCountry.value === "MY"
|
|
988
|
+
), l = B(
|
|
989
|
+
() => {
|
|
990
|
+
var S;
|
|
991
|
+
return `${t.namespace.value}:${t.currentCountry.value}:${(S = t.sessionUser.value) == null ? void 0 : S.id}`;
|
|
992
|
+
}
|
|
993
|
+
);
|
|
994
|
+
return Me(
|
|
995
|
+
() => !I.value && (!g.value || window.confirm("Discard unsaved changes?"))
|
|
996
|
+
), (S, a) => {
|
|
997
|
+
var U;
|
|
998
|
+
return k.value ? (v(), ae(u(Zt), {
|
|
999
|
+
key: l.value,
|
|
1000
|
+
"business-id": ((U = u(t).currentBusiness.value) == null ? void 0 : U._id) ?? "",
|
|
1001
|
+
api: u(s),
|
|
1002
|
+
"load-products": u(Ee),
|
|
1003
|
+
"load-apply-targets": u(Pe),
|
|
1004
|
+
"load-preview": u(r),
|
|
1005
|
+
onDirtyChange: a[0] || (a[0] = (A) => g.value = A),
|
|
1006
|
+
onBusyChange: a[1] || (a[1] = (A) => I.value = A)
|
|
1007
|
+
}, null, 8, ["business-id", "api", "load-products", "load-apply-targets", "load-preview"])) : L("", !0);
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
export {
|
|
1012
|
+
ha as default
|
|
1013
|
+
};
|