@gomusdev/web-components 2.1.1 → 3.0.0-next.2
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/README.md +942 -12
- package/dist-js/components/cart/components/CartCoupons.svelte.d.ts +1 -0
- package/dist-js/components/cart/components/CartDiscountedAmount.svelte.d.ts +1 -0
- package/dist-js/components/cart/components/CartItems.svelte.d.ts +1 -0
- package/dist-js/components/cart/components/CartSubtotalAmount.svelte.d.ts +1 -0
- package/dist-js/components/cart/components/CartTotalAmount.svelte.d.ts +1 -0
- package/dist-js/gomus-webcomponents.css +52 -15
- package/dist-js/gomus-webcomponents.iife.js +407 -277
- package/dist-js/gomus-webcomponents.js +407 -277
- package/dist-js/gomus-webcomponents.min.css +1 -1
- package/dist-js/gomus-webcomponents.min.iife.js +12 -12
- package/dist-js/gomus-webcomponents.min.js +7130 -7028
- package/dist-js/src/components/cart/components/CartCounter.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/CartCoupons.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/CartDetails.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/CartDetails.svelte.d.ts +15 -0
- package/dist-js/src/components/cart/components/CartDiscountedAmount.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/CartItems.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/CartSubtotalAmount.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/CartTotalAmount.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/Item.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/itemTitles/Event.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/itemTitles/Ticket.spec.d.ts +1 -0
- package/dist-js/src/components/cart/components/utils.spec.d.ts +1 -0
- package/dist-js/src/factories/CartItemFactories.d.ts +173 -0
- package/dist-js/src/lib/stores/shop.svelte.d.ts +0 -1
- package/dist-js/src/test-helpers/resetShop.d.ts +1 -0
- package/package.json +4 -2
|
@@ -11453,17 +11453,17 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
11453
11453
|
console.warn(`Failed to remove from localStorage (${key}):`, e);
|
|
11454
11454
|
}
|
|
11455
11455
|
}
|
|
11456
|
-
const KEY$
|
|
11456
|
+
const KEY$6 = "go-capacity";
|
|
11457
11457
|
function saveCapacityToLocalStorage(allSeats, allQuotas) {
|
|
11458
|
-
const existing = loadFromLocalStorage(KEY$
|
|
11458
|
+
const existing = loadFromLocalStorage(KEY$6);
|
|
11459
11459
|
const merged = {
|
|
11460
11460
|
allSeats: { ...existing?.allSeats || {}, ...allSeats },
|
|
11461
11461
|
allQuotas: { ...existing?.allQuotas || {}, ...allQuotas }
|
|
11462
11462
|
};
|
|
11463
|
-
saveToLocalStorage(KEY$
|
|
11463
|
+
saveToLocalStorage(KEY$6, merged);
|
|
11464
11464
|
}
|
|
11465
11465
|
function loadCapacityFromLocalStorage(manager) {
|
|
11466
|
-
const data = loadFromLocalStorage(KEY$
|
|
11466
|
+
const data = loadFromLocalStorage(KEY$6);
|
|
11467
11467
|
if (!data) return;
|
|
11468
11468
|
if (data.allSeats) {
|
|
11469
11469
|
for (const dateId in data.allSeats) {
|
|
@@ -11478,13 +11478,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
11478
11478
|
function syncCapacityAcrossTabs(manager) {
|
|
11479
11479
|
if (!isLocalStorageAvailable()) return;
|
|
11480
11480
|
window.addEventListener("storage", (event2) => {
|
|
11481
|
-
if (event2.key === KEY$
|
|
11481
|
+
if (event2.key === KEY$6) {
|
|
11482
11482
|
loadCapacityFromLocalStorage(manager);
|
|
11483
11483
|
}
|
|
11484
11484
|
if (event2.key === "go-cart") {
|
|
11485
11485
|
const cart = loadFromLocalStorage("go-cart");
|
|
11486
11486
|
const cartEmpty = !cart || !cart.items || cart.items.length === 0;
|
|
11487
|
-
if (cartEmpty) removeFromLocalStorage(KEY$
|
|
11487
|
+
if (cartEmpty) removeFromLocalStorage(KEY$6);
|
|
11488
11488
|
}
|
|
11489
11489
|
});
|
|
11490
11490
|
}
|
|
@@ -12610,21 +12610,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
12610
12610
|
checkout(params) {
|
|
12611
12611
|
return this.apiPost(`/api/v4/orders`, { body: params, requiredFields: ["items", "total"] });
|
|
12612
12612
|
}
|
|
12613
|
-
|
|
12614
|
-
|
|
12615
|
-
// limit is not hit by a page that mounts several cart views.
|
|
12616
|
-
#cartProjectionCache = null;
|
|
12617
|
-
createCart(params) {
|
|
12613
|
+
#lastCart = null;
|
|
12614
|
+
async createCart(params) {
|
|
12618
12615
|
const key = JSON.stringify({ items: params.items ?? [], coupons: params.coupons ?? [] });
|
|
12619
|
-
if (this.#
|
|
12620
|
-
|
|
12621
|
-
}
|
|
12622
|
-
|
|
12623
|
-
if (this.#cartProjectionCache?.key === key) this.#cartProjectionCache = null;
|
|
12624
|
-
throw err2;
|
|
12625
|
-
});
|
|
12626
|
-
this.#cartProjectionCache = { key, promise };
|
|
12627
|
-
return promise;
|
|
12616
|
+
if (this.#lastCart?.key === key) return this.#lastCart.result;
|
|
12617
|
+
const result = await this.apiPost(`/api/v4/cart`, { body: params, requiredFields: ["items"] });
|
|
12618
|
+
this.#lastCart = { key, result };
|
|
12619
|
+
return result;
|
|
12628
12620
|
}
|
|
12629
12621
|
order(token) {
|
|
12630
12622
|
return this.fetchAndCache("/api/v4/orders/{id}", `order-${token}`, "order", { path: { id: token } });
|
|
@@ -12674,10 +12666,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
12674
12666
|
}
|
|
12675
12667
|
return get$2(this.#data)[dataKey];
|
|
12676
12668
|
}
|
|
12677
|
-
clearCache() {
|
|
12678
|
-
this.#fetchStatus = {};
|
|
12679
|
-
set(this.#data, {}, true);
|
|
12680
|
-
}
|
|
12681
12669
|
get museums() {
|
|
12682
12670
|
return this.fetchAndCache("/api/v4/museums", "museums", "museums");
|
|
12683
12671
|
}
|
|
@@ -12967,11 +12955,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
12967
12955
|
}
|
|
12968
12956
|
}
|
|
12969
12957
|
}
|
|
12970
|
-
const KEY$
|
|
12971
|
-
const setPersonalizationDetails = createSetDetails(KEY$
|
|
12972
|
-
const getPersonalizationDetails = createGetDetails(KEY$
|
|
12973
|
-
var root_3$
|
|
12974
|
-
var root_2$
|
|
12958
|
+
const KEY$5 = "go-annual-ticket-personalization";
|
|
12959
|
+
const setPersonalizationDetails = createSetDetails(KEY$5);
|
|
12960
|
+
const getPersonalizationDetails = createGetDetails(KEY$5);
|
|
12961
|
+
var root_3$a = /* @__PURE__ */ from_html(`<li><a> </a></li>`);
|
|
12962
|
+
var root_2$s = /* @__PURE__ */ from_html(`<ul class="go-annual-ticket"><li class="go-annual-ticket-title"> </li> <li class="go-annual-ticket-personalization-count"> </li> <!></ul>`);
|
|
12975
12963
|
function AnnualTicketPersonalization($$anchor, $$props) {
|
|
12976
12964
|
push($$props, true);
|
|
12977
12965
|
let token = prop($$props, "token", 7);
|
|
@@ -12998,7 +12986,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
12998
12986
|
var fragment_1 = comment();
|
|
12999
12987
|
var node_1 = first_child(fragment_1);
|
|
13000
12988
|
each(node_1, 17, () => get$2(order).ticket_sales, (ticketSale) => ticketSale.id, ($$anchor3, ticketSale) => {
|
|
13001
|
-
var ul = root_2$
|
|
12989
|
+
var ul = root_2$s();
|
|
13002
12990
|
var li = child(ul);
|
|
13003
12991
|
var text2 = child(li, true);
|
|
13004
12992
|
reset(li);
|
|
@@ -13008,7 +12996,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
13008
12996
|
var node_2 = sibling(li_1, 2);
|
|
13009
12997
|
{
|
|
13010
12998
|
var consequent = ($$anchor4) => {
|
|
13011
|
-
var li_2 = root_3$
|
|
12999
|
+
var li_2 = root_3$a();
|
|
13012
13000
|
var a2 = child(li_2);
|
|
13013
13001
|
var text_2 = child(a2, true);
|
|
13014
13002
|
reset(a2);
|
|
@@ -16670,9 +16658,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16670
16658
|
});
|
|
16671
16659
|
}
|
|
16672
16660
|
}
|
|
16673
|
-
const KEY$
|
|
16674
|
-
const setDetails$1 = createSetDetails(KEY$
|
|
16675
|
-
const getDetails$1 = createGetDetails(KEY$
|
|
16661
|
+
const KEY$4 = "go-form-details";
|
|
16662
|
+
const setDetails$1 = createSetDetails(KEY$4);
|
|
16663
|
+
const getDetails$1 = createGetDetails(KEY$4);
|
|
16676
16664
|
function wrapInElement(host, tag, props) {
|
|
16677
16665
|
const first = host.firstElementChild || void 0;
|
|
16678
16666
|
if (host.children?.length === 1 && first?.tagName.toLowerCase() === tag) {
|
|
@@ -16696,7 +16684,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16696
16684
|
host.replaceChildren(element);
|
|
16697
16685
|
return element;
|
|
16698
16686
|
}
|
|
16699
|
-
var root_1$
|
|
16687
|
+
var root_1$q = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit> </go-submit>`, 3);
|
|
16700
16688
|
function Form($$anchor, $$props) {
|
|
16701
16689
|
push($$props, true);
|
|
16702
16690
|
let formId = prop($$props, "formId", 7), custom2 = prop($$props, "custom", 7);
|
|
@@ -16739,7 +16727,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16739
16727
|
var node = first_child(fragment);
|
|
16740
16728
|
{
|
|
16741
16729
|
var consequent = ($$anchor2) => {
|
|
16742
|
-
var fragment_1 = root_1$
|
|
16730
|
+
var fragment_1 = root_1$q();
|
|
16743
16731
|
var go_all_fields = first_child(fragment_1);
|
|
16744
16732
|
var go_form_feedback = sibling(go_all_fields, 2);
|
|
16745
16733
|
var go_submit = sibling(go_form_feedback, 2);
|
|
@@ -16900,7 +16888,128 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16900
16888
|
[],
|
|
16901
16889
|
[]
|
|
16902
16890
|
));
|
|
16903
|
-
|
|
16891
|
+
function getQuantity(value, fallback) {
|
|
16892
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
16893
|
+
if (value && typeof value === "object") {
|
|
16894
|
+
const total = Object.values(value).reduce((sum2, num) => {
|
|
16895
|
+
return typeof num === "number" && Number.isFinite(num) ? sum2 + num : sum2;
|
|
16896
|
+
}, 0);
|
|
16897
|
+
if (total > 0) return total;
|
|
16898
|
+
}
|
|
16899
|
+
return fallback;
|
|
16900
|
+
}
|
|
16901
|
+
function resolveQuantitySource(attrs) {
|
|
16902
|
+
return "quantity" in attrs && attrs.quantity !== void 0 ? attrs.quantity : attrs.quantities;
|
|
16903
|
+
}
|
|
16904
|
+
function resolveApiQuantity(attrs) {
|
|
16905
|
+
return getQuantity(resolveQuantitySource(attrs), 0);
|
|
16906
|
+
}
|
|
16907
|
+
function getScalePriceId(attrs) {
|
|
16908
|
+
const source2 = resolveQuantitySource(attrs);
|
|
16909
|
+
if (source2 && typeof source2 === "object") {
|
|
16910
|
+
const keys = Object.keys(source2);
|
|
16911
|
+
if (keys.length > 0) return Number(keys[0]);
|
|
16912
|
+
}
|
|
16913
|
+
return void 0;
|
|
16914
|
+
}
|
|
16915
|
+
function createDisplayCart(baseCart, apiItems) {
|
|
16916
|
+
const displayCart = createCart();
|
|
16917
|
+
const appliedCoupons = /* @__PURE__ */ new Set();
|
|
16918
|
+
baseCart.coupons.forEach((coupon) => displayCart.addCoupon(coupon));
|
|
16919
|
+
apiItems.forEach((apiItem) => {
|
|
16920
|
+
const attrs = apiItem.attributes;
|
|
16921
|
+
const scalePriceId = getScalePriceId(attrs);
|
|
16922
|
+
const itemInBaseCart = baseCart.items.find(
|
|
16923
|
+
(i) => i.type.toLowerCase() === apiItem.type.toLowerCase() && i.product.id === attrs.id && (!attrs.time || i.time === attrs.time) && (scalePriceId === void 0 || isEventTicket(i.product) && i.product.scale_price_id === scalePriceId)
|
|
16924
|
+
);
|
|
16925
|
+
if (!itemInBaseCart) {
|
|
16926
|
+
console.error("(go-cart) Ignoring unmatched cart line", { type: apiItem.type, attrs });
|
|
16927
|
+
return;
|
|
16928
|
+
}
|
|
16929
|
+
if (attrs.coupon) {
|
|
16930
|
+
displayCart.addCoupon(attrs.coupon);
|
|
16931
|
+
appliedCoupons.add(attrs.coupon);
|
|
16932
|
+
}
|
|
16933
|
+
displayCart.addItem(createDisplayCartItem(itemInBaseCart, attrs));
|
|
16934
|
+
});
|
|
16935
|
+
return { cart: displayCart, appliedCoupons };
|
|
16936
|
+
}
|
|
16937
|
+
function createDisplayCartItem(cartItem, attrs) {
|
|
16938
|
+
const quantity = resolveApiQuantity(attrs);
|
|
16939
|
+
const displayPrice = attrs.price_cents ?? cartItem.product.price_cents;
|
|
16940
|
+
const originalPrice = cartItem.product.price_cents;
|
|
16941
|
+
const discounted = displayPrice < originalPrice;
|
|
16942
|
+
const product = { ...cartItem.product, price_cents: displayPrice };
|
|
16943
|
+
return createCartItem(product, {
|
|
16944
|
+
quantity,
|
|
16945
|
+
time: cartItem.time,
|
|
16946
|
+
display: {
|
|
16947
|
+
discounted,
|
|
16948
|
+
reference_uuid: cartItem.uuid,
|
|
16949
|
+
originalPrice
|
|
16950
|
+
}
|
|
16951
|
+
});
|
|
16952
|
+
}
|
|
16953
|
+
class CartDetails {
|
|
16954
|
+
#displayCart = /* @__PURE__ */ state();
|
|
16955
|
+
get displayCart() {
|
|
16956
|
+
return get$2(this.#displayCart);
|
|
16957
|
+
}
|
|
16958
|
+
set displayCart(value) {
|
|
16959
|
+
set(this.#displayCart, value, true);
|
|
16960
|
+
}
|
|
16961
|
+
#appliedCoupons = /* @__PURE__ */ state(proxy(/* @__PURE__ */ new Set()));
|
|
16962
|
+
get appliedCoupons() {
|
|
16963
|
+
return get$2(this.#appliedCoupons);
|
|
16964
|
+
}
|
|
16965
|
+
set appliedCoupons(value) {
|
|
16966
|
+
set(this.#appliedCoupons, value, true);
|
|
16967
|
+
}
|
|
16968
|
+
#preview = /* @__PURE__ */ state(false);
|
|
16969
|
+
get preview() {
|
|
16970
|
+
return get$2(this.#preview);
|
|
16971
|
+
}
|
|
16972
|
+
set preview(value) {
|
|
16973
|
+
set(this.#preview, value, true);
|
|
16974
|
+
}
|
|
16975
|
+
get totalPriceCents() {
|
|
16976
|
+
return this.displayCart?.totalPriceCents ?? 0;
|
|
16977
|
+
}
|
|
16978
|
+
get subtotalPriceCents() {
|
|
16979
|
+
return shop.cart?.totalPriceCents ?? 0;
|
|
16980
|
+
}
|
|
16981
|
+
get discountedAmountCents() {
|
|
16982
|
+
return Math.max(0, this.subtotalPriceCents - this.totalPriceCents);
|
|
16983
|
+
}
|
|
16984
|
+
get isDiscounted() {
|
|
16985
|
+
return this.discountedAmountCents > 0;
|
|
16986
|
+
}
|
|
16987
|
+
async calculateDisplayCart() {
|
|
16988
|
+
const mc = shop.cart;
|
|
16989
|
+
if (!mc) return;
|
|
16990
|
+
try {
|
|
16991
|
+
const { items, coupons } = mc.orderData();
|
|
16992
|
+
const response = await shop.createCart({ items, coupons });
|
|
16993
|
+
if (!response || "error" in response) {
|
|
16994
|
+
if (response && "error" in response) {
|
|
16995
|
+
console.error("(go-cart) Unable to fetch discounted cart data", response.error);
|
|
16996
|
+
}
|
|
16997
|
+
this.displayCart = mc;
|
|
16998
|
+
return;
|
|
16999
|
+
}
|
|
17000
|
+
const result = createDisplayCart(mc, response.data.items ?? []);
|
|
17001
|
+
this.displayCart = result.cart;
|
|
17002
|
+
this.appliedCoupons = result.appliedCoupons;
|
|
17003
|
+
} catch (error) {
|
|
17004
|
+
console.error("(go-cart) Unable to fetch discounted cart data", error);
|
|
17005
|
+
this.displayCart = mc;
|
|
17006
|
+
}
|
|
17007
|
+
}
|
|
17008
|
+
}
|
|
17009
|
+
const KEY$3 = "go-cart-details";
|
|
17010
|
+
const setCartDetails = createSetDetails(KEY$3);
|
|
17011
|
+
const getCartDetails = createGetDetails(KEY$3);
|
|
17012
|
+
var root_1$p = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span><span class="go-cart-item-time" data-testid="cart-item-time"> </span>`, 1);
|
|
16904
17013
|
var root$c = /* @__PURE__ */ from_html(`<span class="go-cart-item-title" data-testid="cart-item-title"><span class="go-cart-item-title-event-title"> </span><span class="go-cart-item-title-ticket-title"> </span></span><!>`, 1);
|
|
16905
17014
|
function Event$2($$anchor, $$props) {
|
|
16906
17015
|
push($$props, true);
|
|
@@ -16928,7 +17037,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16928
17037
|
var node = sibling(span);
|
|
16929
17038
|
{
|
|
16930
17039
|
var consequent = ($$anchor2) => {
|
|
16931
|
-
var fragment_1 = root_1$
|
|
17040
|
+
var fragment_1 = root_1$p();
|
|
16932
17041
|
var span_3 = first_child(fragment_1);
|
|
16933
17042
|
var text_2 = child(span_3, true);
|
|
16934
17043
|
reset(span_3);
|
|
@@ -16959,8 +17068,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16959
17068
|
return pop($$exports);
|
|
16960
17069
|
}
|
|
16961
17070
|
create_custom_element(Event$2, { cartItem: {} }, [], [], { mode: "open" });
|
|
16962
|
-
var root_2$
|
|
16963
|
-
var root_1$
|
|
17071
|
+
var root_2$r = /* @__PURE__ */ from_html(`<span class="go-cart-item-time" data-testid="cart-item-time"> </span>`);
|
|
17072
|
+
var root_1$o = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span> <!>`, 1);
|
|
16964
17073
|
var root$b = /* @__PURE__ */ from_html(`<span class="go-cart-item-title" data-testid="cart-item-title"> </span> <!>`, 1);
|
|
16965
17074
|
function Ticket($$anchor, $$props) {
|
|
16966
17075
|
push($$props, true);
|
|
@@ -16981,14 +17090,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16981
17090
|
var node = sibling(span, 2);
|
|
16982
17091
|
{
|
|
16983
17092
|
var consequent_1 = ($$anchor2) => {
|
|
16984
|
-
var fragment_1 = root_1$
|
|
17093
|
+
var fragment_1 = root_1$o();
|
|
16985
17094
|
var span_1 = first_child(fragment_1);
|
|
16986
17095
|
var text_1 = child(span_1, true);
|
|
16987
17096
|
reset(span_1);
|
|
16988
17097
|
var node_1 = sibling(span_1, 2);
|
|
16989
17098
|
{
|
|
16990
17099
|
var consequent = ($$anchor3) => {
|
|
16991
|
-
var span_2 = root_2$
|
|
17100
|
+
var span_2 = root_2$r();
|
|
16992
17101
|
var text_2 = child(span_2, true);
|
|
16993
17102
|
reset(span_2);
|
|
16994
17103
|
template_effect(($0) => set_text(text_2, $0), [() => formatTime(cartItem().time)]);
|
|
@@ -17031,21 +17140,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17031
17140
|
function option(value) {
|
|
17032
17141
|
return { value, label: value.toString() };
|
|
17033
17142
|
}
|
|
17034
|
-
var root_5$
|
|
17035
|
-
var root_6$
|
|
17036
|
-
var root_7$
|
|
17143
|
+
var root_5$1 = /* @__PURE__ */ from_html(`<s class="go-cart-item-price-original"> </s> <span class="go-cart-item-price-discounted"> </span>`, 1);
|
|
17144
|
+
var root_6$2 = /* @__PURE__ */ from_html(`<span class="go-cart-item-price-discounted"> </span>`);
|
|
17145
|
+
var root_7$3 = /* @__PURE__ */ from_html(`<span> </span>`);
|
|
17037
17146
|
var root_9$4 = /* @__PURE__ */ from_html(`<option> </option>`);
|
|
17038
17147
|
var root_8$3 = /* @__PURE__ */ from_html(`<select class="go-cart-item-select"></select>`);
|
|
17039
|
-
var root_10$1 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button>⨉</button></li>`);
|
|
17040
|
-
var root_1$
|
|
17148
|
+
var root_10$1 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button class="go-cart-remove">⨉</button></li>`);
|
|
17149
|
+
var root_1$n = /* @__PURE__ */ from_html(`<article class="go-cart-item-content"><ul><li class="go-cart-item-title-container"><!></li> <li class="go-cart-item-price"><!></li> <li class="go-cart-item-count"><!></li> <!> <li class="go-cart-item-sum"> </li></ul></article>`);
|
|
17041
17150
|
function Item$1($$anchor, $$props) {
|
|
17042
17151
|
push($$props, true);
|
|
17043
|
-
let displayItem = prop($$props, "displayItem", 7), displayCart = prop($$props, "displayCart", 7),
|
|
17152
|
+
let displayItem = prop($$props, "displayItem", 7), displayCart = prop($$props, "displayCart", 7), preview = prop($$props, "preview", 7);
|
|
17044
17153
|
let capacity = /* @__PURE__ */ state(void 0);
|
|
17045
|
-
const itemInMaincart = /* @__PURE__ */ user_derived(() =>
|
|
17154
|
+
const itemInMaincart = /* @__PURE__ */ user_derived(() => shop.cart?.items.find((item) => item.uuid === (displayItem().display?.reference_uuid ?? displayItem().uuid)));
|
|
17046
17155
|
const emptyCart = createCart();
|
|
17047
17156
|
user_effect(() => {
|
|
17048
|
-
|
|
17157
|
+
shop.cart?.items.map((i) => i.quantity);
|
|
17049
17158
|
untrack(() => {
|
|
17050
17159
|
set(capacity, shop.capacityManager.capacity(displayCart(), displayItem(), emptyCart), true);
|
|
17051
17160
|
});
|
|
@@ -17066,7 +17175,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17066
17175
|
}
|
|
17067
17176
|
const newQuantity = Math.max(0, get$2(itemInMaincart).quantity - displayItem().quantity);
|
|
17068
17177
|
if (newQuantity === 0) {
|
|
17069
|
-
|
|
17178
|
+
shop.cart?.deleteItem(get$2(itemInMaincart));
|
|
17070
17179
|
} else {
|
|
17071
17180
|
get$2(itemInMaincart).quantity = newQuantity;
|
|
17072
17181
|
}
|
|
@@ -17086,13 +17195,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17086
17195
|
displayCart($$value);
|
|
17087
17196
|
flushSync();
|
|
17088
17197
|
},
|
|
17089
|
-
get mainCart() {
|
|
17090
|
-
return mainCart();
|
|
17091
|
-
},
|
|
17092
|
-
set mainCart($$value) {
|
|
17093
|
-
mainCart($$value);
|
|
17094
|
-
flushSync();
|
|
17095
|
-
},
|
|
17096
17198
|
get preview() {
|
|
17097
17199
|
return preview();
|
|
17098
17200
|
},
|
|
@@ -17105,7 +17207,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17105
17207
|
var node = first_child(fragment);
|
|
17106
17208
|
{
|
|
17107
17209
|
var consequent_5 = ($$anchor2) => {
|
|
17108
|
-
var article = root_1$
|
|
17210
|
+
var article = root_1$n();
|
|
17109
17211
|
var ul = child(article);
|
|
17110
17212
|
var li = child(ul);
|
|
17111
17213
|
var node_1 = child(li);
|
|
@@ -17148,7 +17250,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17148
17250
|
var node_3 = child(li_1);
|
|
17149
17251
|
{
|
|
17150
17252
|
var consequent_2 = ($$anchor3) => {
|
|
17151
|
-
var fragment_4 = root_5$
|
|
17253
|
+
var fragment_4 = root_5$1();
|
|
17152
17254
|
var s = first_child(fragment_4);
|
|
17153
17255
|
var text2 = child(s, true);
|
|
17154
17256
|
reset(s);
|
|
@@ -17168,7 +17270,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17168
17270
|
append($$anchor3, fragment_4);
|
|
17169
17271
|
};
|
|
17170
17272
|
var alternate_1 = ($$anchor3) => {
|
|
17171
|
-
var span_1 = root_6$
|
|
17273
|
+
var span_1 = root_6$2();
|
|
17172
17274
|
var text_2 = child(span_1, true);
|
|
17173
17275
|
reset(span_1);
|
|
17174
17276
|
template_effect(($0) => set_text(text_2, $0), [() => formatCurrency(displayItem().final_price_cents)]);
|
|
@@ -17184,7 +17286,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17184
17286
|
var node_4 = child(li_2);
|
|
17185
17287
|
{
|
|
17186
17288
|
var consequent_3 = ($$anchor3) => {
|
|
17187
|
-
var span_2 = root_7$
|
|
17289
|
+
var span_2 = root_7$3();
|
|
17188
17290
|
var text_3 = child(span_2, true);
|
|
17189
17291
|
reset(span_2);
|
|
17190
17292
|
template_effect(() => set_text(text_3, displayItem().quantity));
|
|
@@ -17224,6 +17326,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17224
17326
|
var button = child(li_3);
|
|
17225
17327
|
button.__click = del;
|
|
17226
17328
|
reset(li_3);
|
|
17329
|
+
template_effect(($0) => set_attribute(button, "aria-label", $0), [() => shop.t("cart.item.remove")]);
|
|
17227
17330
|
append($$anchor3, li_3);
|
|
17228
17331
|
};
|
|
17229
17332
|
if_block(node_5, ($$render) => {
|
|
@@ -17246,131 +17349,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17246
17349
|
return pop($$exports);
|
|
17247
17350
|
}
|
|
17248
17351
|
delegate(["change", "click"]);
|
|
17249
|
-
create_custom_element(Item$1, { displayItem: {}, displayCart: {},
|
|
17250
|
-
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
|
|
17254
|
-
return typeof num === "number" && Number.isFinite(num) ? sum2 + num : sum2;
|
|
17255
|
-
}, 0);
|
|
17256
|
-
if (total > 0) return total;
|
|
17257
|
-
}
|
|
17258
|
-
return fallback;
|
|
17259
|
-
}
|
|
17260
|
-
function resolveQuantitySource(attrs) {
|
|
17261
|
-
return "quantity" in attrs && attrs.quantity !== void 0 ? attrs.quantity : attrs.quantities;
|
|
17262
|
-
}
|
|
17263
|
-
function resolveApiQuantity(attrs) {
|
|
17264
|
-
return getQuantity(resolveQuantitySource(attrs), 0);
|
|
17265
|
-
}
|
|
17266
|
-
function getScalePriceId(attrs) {
|
|
17267
|
-
const source2 = resolveQuantitySource(attrs);
|
|
17268
|
-
if (source2 && typeof source2 === "object") {
|
|
17269
|
-
const keys = Object.keys(source2);
|
|
17270
|
-
if (keys.length > 0) return Number(keys[0]);
|
|
17271
|
-
}
|
|
17272
|
-
return void 0;
|
|
17273
|
-
}
|
|
17274
|
-
function createDisplayCart(baseCart, apiItems) {
|
|
17275
|
-
const displayCart = createCart();
|
|
17276
|
-
const appliedCoupons = /* @__PURE__ */ new Set();
|
|
17277
|
-
baseCart.coupons.forEach((coupon) => displayCart.addCoupon(coupon));
|
|
17278
|
-
apiItems.forEach((apiItem) => {
|
|
17279
|
-
const attrs = apiItem.attributes;
|
|
17280
|
-
const scalePriceId = getScalePriceId(attrs);
|
|
17281
|
-
const itemInBaseCart = baseCart.items.find(
|
|
17282
|
-
(i) => i.type.toLowerCase() === apiItem.type.toLowerCase() && i.product.id === attrs.id && (!attrs.time || i.time === attrs.time) && (scalePriceId === void 0 || isEventTicket(i.product) && i.product.scale_price_id === scalePriceId)
|
|
17283
|
-
);
|
|
17284
|
-
if (!itemInBaseCart) {
|
|
17285
|
-
console.error("(go-cart) Ignoring unmatched cart line", { type: apiItem.type, attrs });
|
|
17286
|
-
return;
|
|
17287
|
-
}
|
|
17288
|
-
if (attrs.coupon) {
|
|
17289
|
-
displayCart.addCoupon(attrs.coupon);
|
|
17290
|
-
appliedCoupons.add(attrs.coupon);
|
|
17291
|
-
}
|
|
17292
|
-
displayCart.addItem(createDisplayCartItem(itemInBaseCart, attrs));
|
|
17293
|
-
});
|
|
17294
|
-
return { cart: displayCart, appliedCoupons };
|
|
17295
|
-
}
|
|
17296
|
-
function createDisplayCartItem(cartItem, attrs) {
|
|
17297
|
-
const quantity = resolveApiQuantity(attrs);
|
|
17298
|
-
const displayPrice = attrs.price_cents ?? cartItem.product.price_cents;
|
|
17299
|
-
const originalPrice = cartItem.product.price_cents;
|
|
17300
|
-
const discounted = displayPrice < originalPrice;
|
|
17301
|
-
const product = { ...cartItem.product, price_cents: displayPrice };
|
|
17302
|
-
return createCartItem(product, {
|
|
17303
|
-
quantity,
|
|
17304
|
-
time: cartItem.time,
|
|
17305
|
-
display: {
|
|
17306
|
-
discounted,
|
|
17307
|
-
reference_uuid: cartItem.uuid,
|
|
17308
|
-
originalPrice
|
|
17309
|
-
}
|
|
17310
|
-
});
|
|
17311
|
-
}
|
|
17312
|
-
var root_2$p = /* @__PURE__ */ from_html(`<li class="go-cart-header-remove"></li>`);
|
|
17313
|
-
var root_3$8 = /* @__PURE__ */ from_html(`<li class="go-cart-item"><!></li>`);
|
|
17314
|
-
var root_6$2 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button>⨉</button></li>`);
|
|
17315
|
-
var root_5$1 = /* @__PURE__ */ from_html(`<li><article class="go-cart-item-content"><ul><li class="go-cart-item-title"> </li> <li class="go-cart-item-price"></li> <li class="go-cart-item-count"></li> <!> <li class="go-cart-item-sum"></li></ul></article></li>`);
|
|
17316
|
-
var root_7$3 = /* @__PURE__ */ from_html(`<li class="go-cart-footer-remove"></li>`);
|
|
17317
|
-
var root_1$h = /* @__PURE__ */ from_html(`<ol data-testid="cart"><li class="go-cart-header"><ul><li class="go-cart-header-title"> </li> <li class="go-cart-header-price"> </li> <li class="go-cart-header-count"> </li> <!> <li class="go-cart-header-sum"> </li></ul></li> <!> <!> <li class="go-cart-footer"><ul><li class="go-cart-footer-title"></li> <li class="go-cart-footer-price"></li> <li class="go-cart-footer-count"></li> <!> <li class="go-cart-footer-sum"> </li></ul></li></ol>`);
|
|
17318
|
-
function Cart($$anchor, $$props) {
|
|
17352
|
+
create_custom_element(Item$1, { displayItem: {}, displayCart: {}, preview: {} }, [], [], { mode: "open" });
|
|
17353
|
+
var root_2$q = /* @__PURE__ */ from_html(`<li class="go-cart-header-remove"></li>`);
|
|
17354
|
+
var root_3$9 = /* @__PURE__ */ from_html(`<li class="go-cart-item"><!></li>`);
|
|
17355
|
+
var root_1$m = /* @__PURE__ */ from_html(`<ol data-testid="cart-items"><li class="go-cart-header"><ul><li class="go-cart-header-title"> </li> <li class="go-cart-header-price"> </li> <li class="go-cart-header-count"> </li> <!> <li class="go-cart-header-sum"> </li></ul></li> <!></ol>`);
|
|
17356
|
+
function CartItems($$anchor, $$props) {
|
|
17319
17357
|
push($$props, true);
|
|
17320
|
-
const
|
|
17321
|
-
|
|
17322
|
-
let displayCart = /* @__PURE__ */ state(proxy(get$2(cart)));
|
|
17323
|
-
let appliedCoupons = /* @__PURE__ */ state(proxy(/* @__PURE__ */ new Set()));
|
|
17324
|
-
let requestId = 0;
|
|
17325
|
-
const displayTotalCents = /* @__PURE__ */ user_derived(() => get$2(displayCart)?.totalPriceCents ?? 0);
|
|
17326
|
-
user_effect(() => {
|
|
17327
|
-
if (!get$2(cart)) {
|
|
17328
|
-
return;
|
|
17329
|
-
}
|
|
17330
|
-
get$2(cart).items.map((i) => i.uuid + ":" + i.quantity + ":" + i.time);
|
|
17331
|
-
get$2(cart).coupons.join("|");
|
|
17332
|
-
const currentRequest = ++requestId;
|
|
17333
|
-
if (get$2(cart).items.length === 0 || get$2(cart).coupons.length === 0) {
|
|
17334
|
-
set(displayCart, get$2(cart), true);
|
|
17335
|
-
set(appliedCoupons, /* @__PURE__ */ new Set(), true);
|
|
17336
|
-
return;
|
|
17337
|
-
}
|
|
17338
|
-
void (async () => {
|
|
17339
|
-
try {
|
|
17340
|
-
const { items, coupons } = get$2(cart).orderData();
|
|
17341
|
-
const response = await shop.createCart({ items, coupons });
|
|
17342
|
-
if (currentRequest !== requestId || !get$2(cart)) return;
|
|
17343
|
-
if (!response || "error" in response) {
|
|
17344
|
-
if (response && "error" in response) {
|
|
17345
|
-
console.error("(go-cart) Unable to fetch discounted cart data", response.error);
|
|
17346
|
-
}
|
|
17347
|
-
set(displayCart, get$2(cart), true);
|
|
17348
|
-
return;
|
|
17349
|
-
}
|
|
17350
|
-
const result = createDisplayCart(get$2(cart), response.data.items ?? []);
|
|
17351
|
-
set(displayCart, result.cart, true);
|
|
17352
|
-
set(appliedCoupons, result.appliedCoupons, true);
|
|
17353
|
-
} catch (error) {
|
|
17354
|
-
console.error("(go-cart) Unable to fetch discounted cart data", error);
|
|
17355
|
-
if (currentRequest !== requestId || !get$2(cart)) return;
|
|
17356
|
-
set(displayCart, get$2(cart), true);
|
|
17357
|
-
}
|
|
17358
|
-
})();
|
|
17359
|
-
});
|
|
17360
|
-
var $$exports = {
|
|
17361
|
-
get preview() {
|
|
17362
|
-
return preview();
|
|
17363
|
-
},
|
|
17364
|
-
set preview($$value = false) {
|
|
17365
|
-
preview($$value);
|
|
17366
|
-
flushSync();
|
|
17367
|
-
}
|
|
17368
|
-
};
|
|
17358
|
+
const _details = getCartDetails($$props.$$host);
|
|
17359
|
+
const details = /* @__PURE__ */ user_derived(() => _details.value);
|
|
17369
17360
|
var fragment = comment();
|
|
17370
17361
|
var node = first_child(fragment);
|
|
17371
17362
|
{
|
|
17372
|
-
var
|
|
17373
|
-
var ol = root_1$
|
|
17363
|
+
var consequent_1 = ($$anchor2) => {
|
|
17364
|
+
var ol = root_1$m();
|
|
17374
17365
|
var li = child(ol);
|
|
17375
17366
|
var ul = child(li);
|
|
17376
17367
|
var li_1 = child(ul);
|
|
@@ -17385,11 +17376,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17385
17376
|
var node_1 = sibling(li_3, 2);
|
|
17386
17377
|
{
|
|
17387
17378
|
var consequent = ($$anchor3) => {
|
|
17388
|
-
var li_4 = root_2$
|
|
17379
|
+
var li_4 = root_2$q();
|
|
17389
17380
|
append($$anchor3, li_4);
|
|
17390
17381
|
};
|
|
17391
17382
|
if_block(node_1, ($$render) => {
|
|
17392
|
-
if (!
|
|
17383
|
+
if (!get$2(details).preview) $$render(consequent);
|
|
17393
17384
|
});
|
|
17394
17385
|
}
|
|
17395
17386
|
var li_5 = sibling(node_1, 2);
|
|
@@ -17398,120 +17389,236 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17398
17389
|
reset(ul);
|
|
17399
17390
|
reset(li);
|
|
17400
17391
|
var node_2 = sibling(li, 2);
|
|
17401
|
-
each(node_2, 17, () => get$2(
|
|
17402
|
-
var li_6 = root_3$
|
|
17392
|
+
each(node_2, 17, () => get$2(details).displayCart.items, (item) => item.uuid, ($$anchor3, item) => {
|
|
17393
|
+
var li_6 = root_3$9();
|
|
17403
17394
|
var node_3 = child(li_6);
|
|
17404
17395
|
Item$1(node_3, {
|
|
17405
17396
|
get displayItem() {
|
|
17406
17397
|
return get$2(item);
|
|
17407
17398
|
},
|
|
17408
17399
|
get displayCart() {
|
|
17409
|
-
return get$2(displayCart
|
|
17410
|
-
},
|
|
17411
|
-
get mainCart() {
|
|
17412
|
-
return get$2(cart);
|
|
17400
|
+
return get$2(details).displayCart;
|
|
17413
17401
|
},
|
|
17414
17402
|
get preview() {
|
|
17415
|
-
return
|
|
17403
|
+
return get$2(details).preview;
|
|
17416
17404
|
}
|
|
17417
17405
|
});
|
|
17418
17406
|
reset(li_6);
|
|
17419
17407
|
append($$anchor3, li_6);
|
|
17420
17408
|
});
|
|
17421
|
-
var node_4 = sibling(node_2, 2);
|
|
17422
|
-
{
|
|
17423
|
-
var consequent_2 = ($$anchor3) => {
|
|
17424
|
-
var fragment_1 = comment();
|
|
17425
|
-
var node_5 = first_child(fragment_1);
|
|
17426
|
-
each(node_5, 16, () => get$2(displayCart).coupons, (coupon) => coupon, ($$anchor4, coupon) => {
|
|
17427
|
-
var li_7 = root_5$1();
|
|
17428
|
-
let classes;
|
|
17429
|
-
var article = child(li_7);
|
|
17430
|
-
var ul_1 = child(article);
|
|
17431
|
-
var li_8 = child(ul_1);
|
|
17432
|
-
var text_4 = child(li_8, true);
|
|
17433
|
-
reset(li_8);
|
|
17434
|
-
var node_6 = sibling(li_8, 6);
|
|
17435
|
-
{
|
|
17436
|
-
var consequent_1 = ($$anchor5) => {
|
|
17437
|
-
var li_9 = root_6$2();
|
|
17438
|
-
var button = child(li_9);
|
|
17439
|
-
button.__click = () => get$2(cart)?.removeCoupon(coupon);
|
|
17440
|
-
reset(li_9);
|
|
17441
|
-
append($$anchor5, li_9);
|
|
17442
|
-
};
|
|
17443
|
-
if_block(node_6, ($$render) => {
|
|
17444
|
-
if (!preview()) $$render(consequent_1);
|
|
17445
|
-
});
|
|
17446
|
-
}
|
|
17447
|
-
next(2);
|
|
17448
|
-
reset(ul_1);
|
|
17449
|
-
reset(article);
|
|
17450
|
-
reset(li_7);
|
|
17451
|
-
template_effect(
|
|
17452
|
-
($0) => {
|
|
17453
|
-
classes = set_class(li_7, 1, "go-cart-item", null, classes, $0);
|
|
17454
|
-
set_text(text_4, coupon);
|
|
17455
|
-
},
|
|
17456
|
-
[
|
|
17457
|
-
() => ({
|
|
17458
|
-
"go-cart-coupon-inactive": !get$2(appliedCoupons).has(coupon)
|
|
17459
|
-
})
|
|
17460
|
-
]
|
|
17461
|
-
);
|
|
17462
|
-
append($$anchor4, li_7);
|
|
17463
|
-
});
|
|
17464
|
-
append($$anchor3, fragment_1);
|
|
17465
|
-
};
|
|
17466
|
-
if_block(node_4, ($$render) => {
|
|
17467
|
-
if (get$2(displayCart).coupons.length > 0) $$render(consequent_2);
|
|
17468
|
-
});
|
|
17469
|
-
}
|
|
17470
|
-
var li_10 = sibling(node_4, 2);
|
|
17471
|
-
var ul_2 = child(li_10);
|
|
17472
|
-
var node_7 = sibling(child(ul_2), 6);
|
|
17473
|
-
{
|
|
17474
|
-
var consequent_3 = ($$anchor3) => {
|
|
17475
|
-
var li_11 = root_7$3();
|
|
17476
|
-
append($$anchor3, li_11);
|
|
17477
|
-
};
|
|
17478
|
-
if_block(node_7, ($$render) => {
|
|
17479
|
-
if (!preview()) $$render(consequent_3);
|
|
17480
|
-
});
|
|
17481
|
-
}
|
|
17482
|
-
var li_12 = sibling(node_7, 2);
|
|
17483
|
-
var text_5 = child(li_12, true);
|
|
17484
|
-
reset(li_12);
|
|
17485
|
-
reset(ul_2);
|
|
17486
|
-
reset(li_10);
|
|
17487
17409
|
reset(ol);
|
|
17488
17410
|
template_effect(
|
|
17489
|
-
($0, $1, $2, $3
|
|
17411
|
+
($0, $1, $2, $3) => {
|
|
17490
17412
|
set_text(text2, $0);
|
|
17491
17413
|
set_text(text_1, $1);
|
|
17492
17414
|
set_text(text_2, $2);
|
|
17493
17415
|
set_text(text_3, $3);
|
|
17494
|
-
set_text(text_5, $4);
|
|
17495
17416
|
},
|
|
17496
17417
|
[
|
|
17497
17418
|
() => shop.t("cart.content.table.desc"),
|
|
17498
17419
|
() => shop.t("cart.content.table.price"),
|
|
17499
17420
|
() => shop.t("cart.content.table.quantity"),
|
|
17500
|
-
() => shop.t("cart.content.table.total")
|
|
17501
|
-
() => formatCurrency(get$2(displayTotalCents))
|
|
17421
|
+
() => shop.t("cart.content.table.total")
|
|
17502
17422
|
]
|
|
17503
17423
|
);
|
|
17504
17424
|
append($$anchor2, ol);
|
|
17505
17425
|
};
|
|
17506
17426
|
if_block(node, ($$render) => {
|
|
17507
|
-
if (get$2(
|
|
17427
|
+
if (get$2(details) && get$2(details).displayCart && get$2(details).displayCart.items.length) $$render(consequent_1);
|
|
17508
17428
|
});
|
|
17509
17429
|
}
|
|
17510
17430
|
append($$anchor, fragment);
|
|
17511
|
-
|
|
17431
|
+
pop();
|
|
17432
|
+
}
|
|
17433
|
+
customElements.define("go-cart-items", create_custom_element(CartItems, {}, [], []));
|
|
17434
|
+
var root_3$8 = /* @__PURE__ */ from_html(`<li class="go-cart-coupon-remove-cell"><button class="go-cart-remove go-cart-coupon-remove">⨉</button></li>`);
|
|
17435
|
+
var root_2$p = /* @__PURE__ */ from_html(`<li><article class="go-cart-coupon-content"><ul><li class="go-cart-coupon-code"> </li> <!></ul></article></li>`);
|
|
17436
|
+
var root_1$l = /* @__PURE__ */ from_html(`<ol data-testid="cart-coupons"></ol>`);
|
|
17437
|
+
function CartCoupons($$anchor, $$props) {
|
|
17438
|
+
push($$props, true);
|
|
17439
|
+
const _details = getCartDetails($$props.$$host);
|
|
17440
|
+
const details = /* @__PURE__ */ user_derived(() => _details.value);
|
|
17441
|
+
var fragment = comment();
|
|
17442
|
+
var node = first_child(fragment);
|
|
17443
|
+
{
|
|
17444
|
+
var consequent_1 = ($$anchor2) => {
|
|
17445
|
+
var ol = root_1$l();
|
|
17446
|
+
each(ol, 20, () => get$2(details).displayCart.coupons, (coupon) => coupon, ($$anchor3, coupon) => {
|
|
17447
|
+
var li = root_2$p();
|
|
17448
|
+
let classes;
|
|
17449
|
+
var article = child(li);
|
|
17450
|
+
var ul = child(article);
|
|
17451
|
+
var li_1 = child(ul);
|
|
17452
|
+
var text2 = child(li_1, true);
|
|
17453
|
+
reset(li_1);
|
|
17454
|
+
var node_1 = sibling(li_1, 2);
|
|
17455
|
+
{
|
|
17456
|
+
var consequent = ($$anchor4) => {
|
|
17457
|
+
var li_2 = root_3$8();
|
|
17458
|
+
var button = child(li_2);
|
|
17459
|
+
button.__click = () => shop.cart?.removeCoupon(coupon);
|
|
17460
|
+
reset(li_2);
|
|
17461
|
+
template_effect(($0) => set_attribute(button, "aria-label", $0), [() => shop.t("cart.coupons.remove")]);
|
|
17462
|
+
append($$anchor4, li_2);
|
|
17463
|
+
};
|
|
17464
|
+
if_block(node_1, ($$render) => {
|
|
17465
|
+
if (!get$2(details).preview) $$render(consequent);
|
|
17466
|
+
});
|
|
17467
|
+
}
|
|
17468
|
+
reset(ul);
|
|
17469
|
+
reset(article);
|
|
17470
|
+
reset(li);
|
|
17471
|
+
template_effect(
|
|
17472
|
+
($0) => {
|
|
17473
|
+
classes = set_class(li, 1, "go-cart-coupon", null, classes, $0);
|
|
17474
|
+
set_text(text2, coupon);
|
|
17475
|
+
},
|
|
17476
|
+
[
|
|
17477
|
+
() => ({
|
|
17478
|
+
"go-cart-coupon-inactive": !get$2(details).appliedCoupons.has(coupon)
|
|
17479
|
+
})
|
|
17480
|
+
]
|
|
17481
|
+
);
|
|
17482
|
+
append($$anchor3, li);
|
|
17483
|
+
});
|
|
17484
|
+
reset(ol);
|
|
17485
|
+
append($$anchor2, ol);
|
|
17486
|
+
};
|
|
17487
|
+
if_block(node, ($$render) => {
|
|
17488
|
+
if (get$2(details) && get$2(details).displayCart && get$2(details).displayCart.coupons.length > 0) $$render(consequent_1);
|
|
17489
|
+
});
|
|
17490
|
+
}
|
|
17491
|
+
append($$anchor, fragment);
|
|
17492
|
+
pop();
|
|
17512
17493
|
}
|
|
17513
17494
|
delegate(["click"]);
|
|
17514
|
-
customElements.define("go-cart", create_custom_element(
|
|
17495
|
+
customElements.define("go-cart-coupons", create_custom_element(CartCoupons, {}, [], []));
|
|
17496
|
+
var root_1$k = /* @__PURE__ */ from_html(`<span class="go-cart-total-amount" data-testid="cart-total-amount"> </span>`);
|
|
17497
|
+
function CartTotalAmount($$anchor, $$props) {
|
|
17498
|
+
push($$props, true);
|
|
17499
|
+
const _details = getCartDetails($$props.$$host);
|
|
17500
|
+
const details = /* @__PURE__ */ user_derived(() => _details.value);
|
|
17501
|
+
var fragment = comment();
|
|
17502
|
+
var node = first_child(fragment);
|
|
17503
|
+
{
|
|
17504
|
+
var consequent = ($$anchor2) => {
|
|
17505
|
+
var span = root_1$k();
|
|
17506
|
+
var text2 = child(span, true);
|
|
17507
|
+
reset(span);
|
|
17508
|
+
template_effect(($0) => set_text(text2, $0), [() => formatCurrency(get$2(details).totalPriceCents)]);
|
|
17509
|
+
append($$anchor2, span);
|
|
17510
|
+
};
|
|
17511
|
+
if_block(node, ($$render) => {
|
|
17512
|
+
if (get$2(details) && get$2(details).displayCart && get$2(details).displayCart.items.length) $$render(consequent);
|
|
17513
|
+
});
|
|
17514
|
+
}
|
|
17515
|
+
append($$anchor, fragment);
|
|
17516
|
+
pop();
|
|
17517
|
+
}
|
|
17518
|
+
customElements.define("go-cart-total-amount", create_custom_element(CartTotalAmount, {}, [], []));
|
|
17519
|
+
var root_1$j = /* @__PURE__ */ from_html(`<go-cart-items></go-cart-items> <go-cart-coupons></go-cart-coupons> <go-cart-total-amount></go-cart-total-amount>`, 3);
|
|
17520
|
+
function Cart($$anchor, $$props) {
|
|
17521
|
+
push($$props, true);
|
|
17522
|
+
const preview = prop($$props, "preview", 7, false), useDefault = prop($$props, "default", 7, false);
|
|
17523
|
+
const details = new CartDetails();
|
|
17524
|
+
setCartDetails($$props.$$host, details);
|
|
17525
|
+
user_effect(() => {
|
|
17526
|
+
details.preview = preview();
|
|
17527
|
+
});
|
|
17528
|
+
user_effect(() => {
|
|
17529
|
+
if (!shop.cart) return;
|
|
17530
|
+
shop.cart.items.map((i) => i.uuid + ":" + i.quantity + ":" + i.time);
|
|
17531
|
+
shop.cart.coupons.join("|");
|
|
17532
|
+
untrack(() => details.calculateDisplayCart());
|
|
17533
|
+
});
|
|
17534
|
+
var $$exports = {
|
|
17535
|
+
get preview() {
|
|
17536
|
+
return preview();
|
|
17537
|
+
},
|
|
17538
|
+
set preview($$value = false) {
|
|
17539
|
+
preview($$value);
|
|
17540
|
+
flushSync();
|
|
17541
|
+
},
|
|
17542
|
+
get default() {
|
|
17543
|
+
return useDefault();
|
|
17544
|
+
},
|
|
17545
|
+
set default($$value = false) {
|
|
17546
|
+
useDefault($$value);
|
|
17547
|
+
flushSync();
|
|
17548
|
+
}
|
|
17549
|
+
};
|
|
17550
|
+
var fragment = comment();
|
|
17551
|
+
var node = first_child(fragment);
|
|
17552
|
+
{
|
|
17553
|
+
var consequent = ($$anchor2) => {
|
|
17554
|
+
var fragment_1 = root_1$j();
|
|
17555
|
+
var go_cart_items = first_child(fragment_1);
|
|
17556
|
+
var go_cart_coupons = sibling(go_cart_items, 2);
|
|
17557
|
+
sibling(go_cart_coupons, 2);
|
|
17558
|
+
append($$anchor2, fragment_1);
|
|
17559
|
+
};
|
|
17560
|
+
if_block(node, ($$render) => {
|
|
17561
|
+
if (useDefault()) $$render(consequent);
|
|
17562
|
+
});
|
|
17563
|
+
}
|
|
17564
|
+
append($$anchor, fragment);
|
|
17565
|
+
return pop($$exports);
|
|
17566
|
+
}
|
|
17567
|
+
customElements.define("go-cart", create_custom_element(
|
|
17568
|
+
Cart,
|
|
17569
|
+
{
|
|
17570
|
+
preview: { attribute: "preview", reflect: true, type: "Boolean" },
|
|
17571
|
+
default: { attribute: "default", reflect: true, type: "Boolean" }
|
|
17572
|
+
},
|
|
17573
|
+
[],
|
|
17574
|
+
[]
|
|
17575
|
+
));
|
|
17576
|
+
var root_1$i = /* @__PURE__ */ from_html(`<span class="go-cart-subtotal-amount" data-testid="cart-subtotal-amount"> </span>`);
|
|
17577
|
+
function CartSubtotalAmount($$anchor, $$props) {
|
|
17578
|
+
push($$props, true);
|
|
17579
|
+
const _details = getCartDetails($$props.$$host);
|
|
17580
|
+
const details = /* @__PURE__ */ user_derived(() => _details.value);
|
|
17581
|
+
var fragment = comment();
|
|
17582
|
+
var node = first_child(fragment);
|
|
17583
|
+
{
|
|
17584
|
+
var consequent = ($$anchor2) => {
|
|
17585
|
+
var span = root_1$i();
|
|
17586
|
+
var text2 = child(span, true);
|
|
17587
|
+
reset(span);
|
|
17588
|
+
template_effect(($0) => set_text(text2, $0), [() => formatCurrency(get$2(details).subtotalPriceCents)]);
|
|
17589
|
+
append($$anchor2, span);
|
|
17590
|
+
};
|
|
17591
|
+
if_block(node, ($$render) => {
|
|
17592
|
+
if (get$2(details) && shop.cart?.items.length) $$render(consequent);
|
|
17593
|
+
});
|
|
17594
|
+
}
|
|
17595
|
+
append($$anchor, fragment);
|
|
17596
|
+
pop();
|
|
17597
|
+
}
|
|
17598
|
+
customElements.define("go-cart-subtotal-amount", create_custom_element(CartSubtotalAmount, {}, [], []));
|
|
17599
|
+
var root_1$h = /* @__PURE__ */ from_html(`<span class="go-cart-discounted-amount" data-testid="cart-discounted-amount"><span class="go-cart-discounted-amount-sign">−</span> </span>`);
|
|
17600
|
+
function CartDiscountedAmount($$anchor, $$props) {
|
|
17601
|
+
push($$props, true);
|
|
17602
|
+
const _details = getCartDetails($$props.$$host);
|
|
17603
|
+
const details = /* @__PURE__ */ user_derived(() => _details.value);
|
|
17604
|
+
var fragment = comment();
|
|
17605
|
+
var node = first_child(fragment);
|
|
17606
|
+
{
|
|
17607
|
+
var consequent = ($$anchor2) => {
|
|
17608
|
+
var span = root_1$h();
|
|
17609
|
+
var text2 = sibling(child(span), 1, true);
|
|
17610
|
+
reset(span);
|
|
17611
|
+
template_effect(($0) => set_text(text2, $0), [() => formatCurrency(get$2(details).discountedAmountCents)]);
|
|
17612
|
+
append($$anchor2, span);
|
|
17613
|
+
};
|
|
17614
|
+
if_block(node, ($$render) => {
|
|
17615
|
+
if (get$2(details) && get$2(details).discountedAmountCents > 0) $$render(consequent);
|
|
17616
|
+
});
|
|
17617
|
+
}
|
|
17618
|
+
append($$anchor, fragment);
|
|
17619
|
+
pop();
|
|
17620
|
+
}
|
|
17621
|
+
customElements.define("go-cart-discounted-amount", create_custom_element(CartDiscountedAmount, {}, [], []));
|
|
17515
17622
|
function CartEmpty($$anchor, $$props) {
|
|
17516
17623
|
push($$props, true);
|
|
17517
17624
|
wrapInElement($$props.$$host, "go-if", { when: "data.cart.items.length === 0" });
|
|
@@ -17545,9 +17652,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17545
17652
|
]
|
|
17546
17653
|
});
|
|
17547
17654
|
wrapInElement($$props.$$host, "go-form", { "form-id": "checkoutGuest", custom: custom2() });
|
|
17655
|
+
async function flushCoupons() {
|
|
17656
|
+
const couponEls = document.querySelectorAll("go-coupon-redemption");
|
|
17657
|
+
let allOk = true;
|
|
17658
|
+
for (const el of couponEls) {
|
|
17659
|
+
const result = await el.flush?.();
|
|
17660
|
+
if (result && !result.success) allOk = false;
|
|
17661
|
+
}
|
|
17662
|
+
return allOk;
|
|
17663
|
+
}
|
|
17664
|
+
$$props.$$host.addEventListener("go-after-validation", flushCoupons);
|
|
17548
17665
|
$$props.$$host.addEventListener("submit", async (e) => {
|
|
17549
17666
|
const form = e.target;
|
|
17550
17667
|
if (!get$2(cart)) return;
|
|
17668
|
+
if (!await flushCoupons()) return;
|
|
17551
17669
|
const auth = await shop.signUp(form.details.formData, true);
|
|
17552
17670
|
if (auth.error) {
|
|
17553
17671
|
form.details.apiErrors = auth.error.errors;
|
|
@@ -17579,7 +17697,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17579
17697
|
return pop($$exports);
|
|
17580
17698
|
}
|
|
17581
17699
|
customElements.define("go-checkout-form", create_custom_element(CheckoutForm, { custom: {} }, [], []));
|
|
17582
|
-
enable_legacy_mode_flag();
|
|
17583
17700
|
const APPLY_ORDER_DISCOUNT = "TokenActions::ApplyOrderDiscount";
|
|
17584
17701
|
async function redeem(token) {
|
|
17585
17702
|
if (!shop.cart) {
|
|
@@ -17619,32 +17736,42 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17619
17736
|
}
|
|
17620
17737
|
var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
|
|
17621
17738
|
function CouponRedemption($$anchor, $$props) {
|
|
17622
|
-
push($$props,
|
|
17739
|
+
push($$props, true);
|
|
17623
17740
|
Forms.defineForm({
|
|
17624
17741
|
id: "couponRedemption",
|
|
17625
17742
|
submitLabel: "cart.coupon.form.submit",
|
|
17626
17743
|
fields: [{ key: "token", required: true }]
|
|
17627
17744
|
});
|
|
17628
|
-
async function
|
|
17629
|
-
const form = event2.target;
|
|
17745
|
+
async function runRedeem(form) {
|
|
17630
17746
|
const field = form.details.fields.find((f) => f.key === "token");
|
|
17631
|
-
const token = form.details.fieldValue("token").trim();
|
|
17747
|
+
const token = (form.details.fieldValue("token") ?? "").trim();
|
|
17748
|
+
if (!token) return { success: true };
|
|
17632
17749
|
const result = await redeem(token);
|
|
17633
17750
|
if (!result.success) {
|
|
17634
17751
|
form.details.apiErrors = result.errors;
|
|
17635
|
-
return;
|
|
17752
|
+
return result;
|
|
17636
17753
|
}
|
|
17637
|
-
field.value = "";
|
|
17754
|
+
if (field) field.value = "";
|
|
17638
17755
|
form.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
|
|
17756
|
+
return result;
|
|
17639
17757
|
}
|
|
17640
|
-
|
|
17758
|
+
async function redeem$1(event2) {
|
|
17759
|
+
await runRedeem(event2.target);
|
|
17760
|
+
}
|
|
17761
|
+
async function flush() {
|
|
17762
|
+
const form = $$props.$$host.querySelector("go-form");
|
|
17763
|
+
if (!form?.details) return { success: true };
|
|
17764
|
+
return runRedeem(form);
|
|
17765
|
+
}
|
|
17766
|
+
var $$exports = { flush };
|
|
17641
17767
|
var go_form = root$a();
|
|
17642
17768
|
set_custom_element_data(go_form, "formId", "couponRedemption");
|
|
17643
17769
|
event("submit", go_form, redeem$1);
|
|
17644
17770
|
append($$anchor, go_form);
|
|
17645
|
-
pop();
|
|
17771
|
+
return pop($$exports);
|
|
17646
17772
|
}
|
|
17647
|
-
customElements.define("go-coupon-redemption", create_custom_element(CouponRedemption, {}, [], []));
|
|
17773
|
+
customElements.define("go-coupon-redemption", create_custom_element(CouponRedemption, {}, [], ["flush"]));
|
|
17774
|
+
enable_legacy_mode_flag();
|
|
17648
17775
|
class GoDonation {
|
|
17649
17776
|
#campaign = /* @__PURE__ */ state();
|
|
17650
17777
|
get campaign() {
|
|
@@ -34582,11 +34709,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
34582
34709
|
const personalizationDetails = /* @__PURE__ */ user_derived(() => _personalizationDetails.value);
|
|
34583
34710
|
const _formDetails = getDetails$1($$props.$$host);
|
|
34584
34711
|
const formDetails = /* @__PURE__ */ user_derived(() => _formDetails.value);
|
|
34712
|
+
const _cartView = getCartDetails($$props.$$host);
|
|
34713
|
+
const cartView = /* @__PURE__ */ user_derived(() => _cartView.value);
|
|
34585
34714
|
let data = /* @__PURE__ */ user_derived(() => ({
|
|
34586
34715
|
ticketSelection: get$2(ticketSelectionDetails),
|
|
34587
34716
|
personalizationDetails: get$2(personalizationDetails),
|
|
34588
34717
|
formData: get$2(formDetails)?.formData,
|
|
34589
|
-
cart: shop.cart
|
|
34718
|
+
cart: shop.cart,
|
|
34719
|
+
cartView: get$2(cartView)
|
|
34590
34720
|
}));
|
|
34591
34721
|
const _setData = (_data) => {
|
|
34592
34722
|
set(data, _data);
|
|
@@ -34992,7 +35122,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
34992
35122
|
var node_2 = sibling(span, 2);
|
|
34993
35123
|
{
|
|
34994
35124
|
var consequent_2 = ($$anchor4) => {
|
|
34995
|
-
const barcodeId = /* @__PURE__ */ user_derived(() => item().attributes.barcodes[index2]
|
|
35125
|
+
const barcodeId = /* @__PURE__ */ user_derived(() => item().attributes.barcodes[index2].id);
|
|
34996
35126
|
var fragment_2 = root_3$2();
|
|
34997
35127
|
var node_3 = first_child(fragment_2);
|
|
34998
35128
|
{
|