@kachingappz/bundles-js 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=>r.blockVisibility==="selected-products");for(const r of s)r.selectedProductIds.map(Number).includes(t.id)&&a.push(r);const n=e.filter(r=>r.blockVisibility==="selected-collections");for(const r of n)t.collectionIds.some(m=>r.selectedCollectionIds.map(Number).includes(m))&&a.push(r);const i=e.filter(r=>r.blockVisibility==="excluded-products");for(const r of i)!r.excludedProductIds.map(Number).includes(t.id)&&!(r.excludedCollectionIds||[]).some(m=>t.collectionIds.includes(m))&&a.push(r);const o=e.filter(r=>r.blockVisibility==="all-products");for(const r of o)a.push(r);return a},R=(e,{language:t,country:a})=>{var h,g;const s=Q(t,a),n=new Intl.NumberFormat(s,{style:"currency",currency:e,currencyDisplay:"narrowSymbol"}).formatToParts(123456789e-2),i=(h=n.find(f=>f.type==="decimal"))==null?void 0:h.value,o=J((g=n.find(f=>f.type==="group"))==null?void 0:g.value),r=n.some(f=>f.type==="fraction"),m=H(o,i,r),c=n.findIndex(G),u=n.findLastIndex(G);return[...n.slice(0,c).map(N),m,...n.slice(u+1).map(N)].join("")},N=e=>x(e.value),x=e=>e.replace(/\s/g," "),G=e=>e.type==="integer"||e.type==="group"||e.type==="decimal"||e.type==="fraction",Q=(e,t)=>e&&t?`${e}-${t.toUpperCase()}`:e||(t?t.toUpperCase():"en"),J=e=>e===void 0?void 0:x(e).replace(/’/g,"'"),H=(e,t,a)=>t===","&&e==="."?a?"{{amount_with_comma_separator}}":"{{amount_no_decimals_with_comma_separator}}":t===","&&e===" "?a?"{{amount_with_space_separator}}":"{{amount_no_decimals_with_space_separator}}":t==="."&&e===" "?"{{amount_with_period_and_space_separator}}":t==="."&&e==="'"?"{{amount_with_apostrophe_separator}}":a?"{{amount}}":"{{amount_no_decimals}}",k=({country:e,language:t})=>{const a=[];return e&&a.push(`country: ${e}`),t&&a.push(`language: ${t}`),a.length>0?`@inContext(${a.join(", ")})`:""},X=async(e,{useExternalMetafieldNamespace:t,useMetaobjects:a})=>a?W(e):K(e),K=async(e,t)=>{var s;const a=(s=(await e.query(`
1
+ var BundlesJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=(e,{language:t,country:r})=>{let c=a(t,r),l=new Intl.NumberFormat(c,{style:`currency`,currency:e,currencyDisplay:`narrowSymbol`}).formatToParts(1234567.89),u=l.find(e=>e.type===`decimal`)?.value,d=s(o(l.find(e=>e.type===`group`)?.value),u,l.some(e=>e.type===`fraction`)),f=l.findIndex(i),p=l.findLastIndex(i);return[...l.slice(0,f).map(n),d,...l.slice(p+1).map(n)].join(``)},n=e=>r(e.value),r=e=>e.replace(/\s/g,` `),i=e=>e.type===`integer`||e.type===`group`||e.type===`decimal`||e.type===`fraction`,a=(e,t)=>e&&t?`${e}-${t.toUpperCase()}`:e||(t?t.toUpperCase():`en`),o=e=>e===void 0?void 0:r(e).replace(/’/g,`'`),s=(e,t,n)=>t===`,`&&e===`.`?n?`{{amount_with_comma_separator}}`:`{{amount_no_decimals_with_comma_separator}}`:t===`,`&&e===` `?n?`{{amount_with_space_separator}}`:`{{amount_no_decimals_with_space_separator}}`:t===`.`&&e===` `?`{{amount_with_period_and_space_separator}}`:t===`.`&&e===`'`?`{{amount_with_apostrophe_separator}}`:n?`{{amount}}`:`{{amount_no_decimals}}`,c=({country:e,language:t})=>{let n=[];return e&&n.push(`country: ${e}`),t&&n.push(`language: ${t}`),n.length>0?`@inContext(${n.join(`, `)})`:``},l=async(e,{useExternalMetafieldNamespace:t,useMetaobjects:n})=>n?d(e,t):u(e,t),u=async(e,t)=>{let n=(await e.query(`
2
2
  query FetchDealBlocks($metafieldNamespace: String!) {
3
3
  shop {
4
4
  metafield(namespace: $metafieldNamespace, key: "deal_blocks") {
@@ -6,7 +6,7 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
6
6
  }
7
7
  }
8
8
  }
9
- `,{variables:{metafieldNamespace:"app--2935586817--kaching_bundles"}})).shop.metafield)==null?void 0:s.value;return a?JSON.parse(a):[]},W=async(e,t)=>{const a="app--2935586817--deal_block",s=[];let n=null;for(;;){const i=await e.query(`
9
+ `,{variables:{metafieldNamespace:t?`app--2935586817--kaching_bundles`:`$app:kaching_bundles`}})).shop.metafield?.value;return n?JSON.parse(n):[]},d=async(e,t)=>{let n=t?`app--2935586817--deal_block`:`$app:deal_block`,r=[],i=null;for(;;){let t=await e.query(`
10
10
  query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
11
11
  metaobjects(type: $type, first: 250, after: $cursor) {
12
12
  nodes {
@@ -21,8 +21,8 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
21
21
  }
22
22
  }
23
23
  }
24
- `,{variables:{type:a,cursor:n}});for(const o of i.metaobjects.nodes){const r=o.fields.find(m=>m.key==="settings");r!=null&&r.value&&s.push(JSON.parse(r.value))}if(!i.metaobjects.pageInfo.hasNextPage)break;n=i.metaobjects.pageInfo.endCursor}return s},T=async(e,{country:t,language:a,blockVisibility:s,excludedProductGIDs:n,selectedProductGIDs:i,selectedCollectionGIDs:o,limit:r=1e3})=>{switch(s){case"selected-products":return i.slice(0,r);case"all-products":case"excluded-products":{const m=k({country:t,language:a});let c=[],u=null;for(;c.length<r;){const h=Math.min(r-c.length,250),g=await e.query(`
25
- query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
24
+ `,{variables:{type:n,cursor:i}});for(let e of t.metaobjects.nodes){let t=e.fields.find(e=>e.key===`settings`);t?.value&&r.push(JSON.parse(t.value))}if(!t.metaobjects.pageInfo.hasNextPage)break;i=t.metaobjects.pageInfo.endCursor}return r};[`primaryBackground`,`secondaryBackground`,`primaryText`,`secondaryText`,`border`,`overlay`,`primaryAccent`,`primaryAccentText`,`badgeBackground`,`badgeText`,`error`].map(e=>`brand_${e}`);var f=function(e){return e.QuantityBreak=`quantity-break`,e.Bxgy=`bxgy`,e.Bundle=`bundle`,e.MixAndMatch=`mix-and-match`,e.Sku=`sku`,e}({}),p=async(e,{country:t,language:n,blockVisibility:r,excludedProductGIDs:i,selectedProductGIDs:a,selectedCollectionGIDs:o,limit:s=1e3})=>{switch(r){case`selected-products`:return a.slice(0,s);case`all-products`:case`excluded-products`:{let a=c({country:t,language:n}),o=[],l=null;for(;o.length<s;){let t=Math.min(s-o.length,250),n=await e.query(`
25
+ query FetchProductGIDs($limit: Int!, $cursor: String) ${a} {
26
26
  products(first: $limit, after: $cursor) {
27
27
  nodes {
28
28
  id
@@ -33,8 +33,8 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
33
33
  }
34
34
  }
35
35
  }
36
- `,{variables:{limit:h,cursor:u}});if(c.push(...g.products.nodes.map(f=>f.id)),!g.products.pageInfo.hasNextPage)break;u=g.products.pageInfo.endCursor}if(s==="excluded-products"){const h=new Set(n);c=c.filter(g=>!h.has(g))}return c}case"selected-collections":{const m=k({country:t,language:a}),c=(await e.query(`
37
- query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
36
+ `,{variables:{limit:t,cursor:l}});if(o.push(...n.products.nodes.map(e=>e.id)),!n.products.pageInfo.hasNextPage)break;l=n.products.pageInfo.endCursor}if(r===`excluded-products`){let e=new Set(i);o=o.filter(t=>!e.has(t))}return o}case`selected-collections`:{let r=c({country:t,language:n}),i=(await e.query(`
37
+ query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${r} {
38
38
  nodes(ids: $collectionGIDs) {
39
39
  ... on Collection {
40
40
  products(first: $limit) {
@@ -45,7 +45,7 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
45
45
  }
46
46
  }
47
47
  }
48
- `,{variables:{collectionGIDs:o,limit:Math.min(r,250)}})).nodes.filter(u=>u!==null).flatMap(u=>u.products.nodes.map(h=>h.id));return Array.from(new Set(c)).slice(0,r)}}},B=`
48
+ `,{variables:{collectionGIDs:o,limit:Math.min(s,250)}})).nodes.filter(e=>e!==null).flatMap(e=>e.products.nodes.map(e=>e.id));return Array.from(new Set(i)).slice(0,s)}}},m=`
49
49
  id
50
50
  availableForSale
51
51
  price {
@@ -88,8 +88,8 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
88
88
  }
89
89
  }
90
90
  quantityAvailable @include(if: $includeAvailableQuantity)
91
- `,$=async(e,{country:t,language:a,productIds:s,includeSellingPlans:n=!0,includeAvailableQuantity:i=!0,useExternalMetafieldNamespace:o=!1,batchSize:r=250,onBatchError:m,variantImageTransform:c={maxWidth:200,maxHeight:200}})=>{if(!s.length)return[];const u=s.map(p=>typeof p=="string"&&p.startsWith("gid://")?p:`gid://shopify/Product/${p}`),h=k({country:t,language:a}),g=`
92
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
91
+ `,h=async(e,{country:t,language:n,productIds:r,includeSellingPlans:i=!0,includeAvailableQuantity:a=!0,includeProductRating:o=!1,includeProductSubtitle:s=!1,productSubtitleMetafield:l=`descriptors.subtitle`,useExternalMetafieldNamespace:u=!1,batchSize:d=250,onBatchError:f,variantImageTransform:p={maxWidth:200,maxHeight:200}})=>{if(!r.length)return[];let h=r.map(e=>typeof e==`string`&&e.startsWith(`gid://`)?e:`gid://shopify/Product/${e}`),v=c({country:t,language:n}),y=`
92
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${v} {
93
93
  shop {
94
94
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
95
95
  value
@@ -123,7 +123,7 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
123
123
  }
124
124
  variants(first: 250) {
125
125
  nodes {
126
- ${B}
126
+ ${m}
127
127
  }
128
128
  }
129
129
  collections(first: 50) {
@@ -143,6 +143,15 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
143
143
  metafield4: metafield(namespace: $metafieldNamespace, key: "text4") {
144
144
  value
145
145
  }
146
+ reviewsRating: metafield(namespace: "reviews", key: "rating") @include(if: $includeProductRating) {
147
+ value
148
+ }
149
+ reviewsRatingCount: metafield(namespace: "reviews", key: "rating_count") @include(if: $includeProductRating) {
150
+ value
151
+ }
152
+ subtitle: metafield(namespace: $subtitleNamespace, key: $subtitleKey) @include(if: $includeProductSubtitle) {
153
+ value
154
+ }
146
155
  requiresSellingPlan
147
156
  sellingPlanGroups(first: 100) @include(if: $includeSellingPlans) {
148
157
  nodes {
@@ -175,12 +184,12 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
175
184
  }
176
185
  }
177
186
  }
178
- `,f=o?"app--2935586817--kaching_bundles":"$app:kaching_bundles",v=[],l=Math.min(r,250);for(let p=0;p<u.length;p+=l)v.push(u.slice(p,p+l));let d=1;const y=async p=>{const b=await e.query(g,{variables:{productGIDs:p,includeSellingPlans:n,includeAvailableQuantity:i,metafieldNamespace:f,variantImageTransform:c}});return b.shop.currencyRateConstant&&(d=JSON.parse(b.shop.currencyRateConstant.value).amount/1e6),b};let _;if(m){const p=await Promise.allSettled(v.map(y));for(const b of p)b.status==="rejected"&&m(b.reason instanceof Error?b.reason:new Error(String(b.reason)));_=p.filter(b=>b.status==="fulfilled").flatMap(b=>b.value.nodes)}else _=(await Promise.all(v.map(y))).flatMap(p=>p.nodes);const I=_.filter(p=>p!=null);if(m){const p=await Promise.allSettled(I.map(async P=>{const Ue=await M(e,P,{includeSellingPlans:n,includeAvailableQuantity:i,variantImageTransform:c},h);return q(Ue,e.shopifyDomain,d)})),b=[];for(const P of p)P.status==="fulfilled"?b.push(P.value):m(P.reason instanceof Error?P.reason:new Error(String(P.reason)));return b}return(await Promise.all(I.map(p=>M(e,p,{includeSellingPlans:n,includeAvailableQuantity:i,variantImageTransform:c},h)))).map(p=>q(p,e.shopifyDomain,d))},M=async(e,t,a,s="")=>{if(t.variants.nodes.length<250)return t;const n=new Set,i=[],o=[],r=async m=>{let c=!0,u=null;for(;c;){const h=await e.query(`
179
- query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${s} {
187
+ `,b=u?`app--2935586817--kaching_bundles`:`$app:kaching_bundles`,x=l.indexOf(`.`),S=l.slice(0,x),C=l.slice(x+1),w=[],T=Math.min(d,250);for(let e=0;e<h.length;e+=T)w.push(h.slice(e,e+T));let E=1,D=async t=>{let n=await e.query(y,{variables:{productGIDs:t,includeSellingPlans:i,includeAvailableQuantity:a,includeProductRating:o,includeProductSubtitle:s,subtitleNamespace:S,subtitleKey:C,metafieldNamespace:b,variantImageTransform:p}});return n.shop.currencyRateConstant&&(E=JSON.parse(n.shop.currencyRateConstant.value).amount/1e6),n},O;if(f){let e=await Promise.allSettled(w.map(D));for(let t of e)t.status===`rejected`&&f(t.reason instanceof Error?t.reason:Error(String(t.reason)));O=e.filter(e=>e.status===`fulfilled`).flatMap(e=>e.value.nodes)}else O=(await Promise.all(w.map(D))).flatMap(e=>e.nodes);let k=O.filter(e=>e!=null);if(f){let t=await Promise.allSettled(k.map(async t=>_(await g(e,t,{includeSellingPlans:i,includeAvailableQuantity:a,variantImageTransform:p},v),e.shopifyDomain,E))),n=[];for(let e of t)e.status===`fulfilled`?n.push(e.value):f(e.reason instanceof Error?e.reason:Error(String(e.reason)));return n}return(await Promise.all(k.map(t=>g(e,t,{includeSellingPlans:i,includeAvailableQuantity:a,variantImageTransform:p},v)))).map(t=>_(t,e.shopifyDomain,E))},g=async(e,t,n,r=``)=>{if(t.variants.nodes.length<250)return t;let i=new Set,a=[],o=[],s=async s=>{let c=!0,l=null;for(;c;){let{nodes:u,pageInfo:d}=(await e.query(`
188
+ query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${r} {
180
189
  product(id: $productGID) {
181
190
  variants(first: 250, after: $cursor, reverse: $reverse) {
182
191
  nodes {
183
- ${B}
192
+ ${m}
184
193
  }
185
194
  pageInfo {
186
195
  endCursor
@@ -189,8 +198,8 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
189
198
  }
190
199
  }
191
200
  }
192
- `,{variables:{productGID:t.id,cursor:u,reverse:m,...a}}),{nodes:g,pageInfo:f}=h.product.variants;for(const v of g){if(n.has(v.id)){c=!1;break}n.add(v.id),m?o.push(v):i.push(v)}f.hasNextPage||(c=!1),u=f.endCursor}};return await Promise.all([r(!1),r(!0)]),t.variants.nodes=[...i,...o.reverse()],t},q=(e,t,a)=>{var c,u,h,g,f,v;const s=e.variants.nodes.map(({unitPriceMeasurement:l,...d})=>{var y,_;return{id:Number(d.id.split("/").pop()),availableForSale:d.availableForSale,price:Math.round(Number(d.price.amount)*100),compareAtPrice:d.compareAtPrice?Math.round(Number(d.compareAtPrice.amount)*100):null,options:d.selectedOptions.map(I=>I.value),imageId:d.image?Number(d.image.id.split("/").pop()):null,image:((y=d.image)==null?void 0:y.url)||null,sellingPlans:((_=d.sellingPlanAllocations)==null?void 0:_.nodes.map(I=>({id:Number(I.sellingPlan.id.split("/").pop()),price:I.priceAdjustments.length>0?Math.round(Number(I.priceAdjustments[0].price.amount)*100):Math.round(Number(d.price.amount)*100),compareAtPrice:I.priceAdjustments.length>0?Math.round(Number(I.priceAdjustments[0].compareAtPrice.amount)*100):Math.round(Number(d.price.amount)*100),perDeliveryPrice:I.priceAdjustments.length>0?Math.round(Number(I.priceAdjustments[0].perDeliveryPrice.amount)*100):Math.round(Number(d.price.amount)*100)})))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:d.quantityAvailable??null,unitPriceMeasurement:l!=null&&l.quantityUnit&&(l!=null&&l.referenceUnit)?{quantityValue:l.quantityValue,quantityUnit:l.quantityUnit.toLowerCase(),referenceValue:l.referenceValue,referenceUnit:l.referenceUnit.toLowerCase()}:null}}),n=e.options.map((l,d)=>{const y=l.optionValues.map(_=>{var I,p,b,P;return{id:Number(_.id.split("/").pop()),defaultName:_.name,name:_.name,swatch:{color:((I=_.swatch)==null?void 0:I.color)||null,image:((P=(b=(p=_.swatch)==null?void 0:p.image)==null?void 0:b.previewImage)==null?void 0:P.url)||null}}});return{defaultName:l.name,name:l.name,position:d+1,optionValues:Y(y,d,s)}}),i=l=>{const d=l.priceAdjustments[0];if(!d)return null;const y=d.adjustmentValue;switch(y.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:y.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"fixed_amount",value:o(y.adjustmentAmount.amount)};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:o(y.price.amount)};default:throw new Error(`Unknown price adjustment type: ${y.__typename}`)}},o=l=>a===1?Number(l)*100:Math.round(Number(l)*100*a),r=((c=e.sellingPlanGroups)==null?void 0:c.nodes.flatMap(l=>l.sellingPlans.nodes.map(d=>({id:Number(d.id.split("/").pop()),name:d.name,priceAdjustment:i(d)}))))||[],m=e.variants.nodes.some(l=>l.requiresComponents);return{id:Number(e.id.split("/").pop()),handle:e.handle,url:e.onlineStoreUrl||`https://${t}/products/${e.handle}`,availableForSale:e.availableForSale,createdAt:e.createdAt,title:e.title,image:((u=e.featuredImage)==null?void 0:u.url)||null,collectionIds:e.collections.nodes.map(l=>Number(l.id.split("/").pop())),options:n,selectedVariantId:Number(e.variants.nodes[0].id.split("/").pop()),variants:s,requiresSellingPlan:e.requiresSellingPlan,sellingPlans:r,isNativeBundle:m,metafields:{text:((h=e.metafield)==null?void 0:h.value)||null,text2:((g=e.metafield2)==null?void 0:g.value)||null,text3:((f=e.metafield3)==null?void 0:f.value)||null,text4:((v=e.metafield4)==null?void 0:v.value)||null}}},Y=(e,t,a)=>e.filter(s=>a.filter(n=>n.options[t]===s.name).length>0),O="app--2935586817",Z=async(e,{language:t,country:a,useExternalMetafieldNamespace:s})=>{const n=`${O}--kaching_bundles`,i=O,o=k({country:a}),{localization:{country:{currency:{isoCode:r}}},shop:{moneyFormat:m,paymentSettings:{currencyCode:c},currencyRateConstant:u,primaryDomain:h,settingsMetafield:g}}=await e.query(`
193
- query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
201
+ `,{variables:{productGID:t.id,cursor:l,reverse:s,...n}})).product.variants;for(let e of u){if(i.has(e.id)){c=!1;break}i.add(e.id),s?o.push(e):a.push(e)}d.hasNextPage||(c=!1),l=d.endCursor}};return await Promise.all([s(!1),s(!0)]),t.variants.nodes=[...a,...o.reverse()],t},_=(e,t,n)=>{let r=e.variants.nodes.map(({unitPriceMeasurement:e,...t})=>({id:Number(t.id.split(`/`).pop()),availableForSale:t.availableForSale,price:Math.round(Number(t.price.amount)*100),compareAtPrice:t.compareAtPrice?Math.round(Number(t.compareAtPrice.amount)*100):null,options:t.selectedOptions.map(e=>e.value),imageId:t.image?Number(t.image.id.split(`/`).pop()):null,image:t.image?.url||null,sellingPlans:t.sellingPlanAllocations?.nodes.map(e=>({id:Number(e.sellingPlan.id.split(`/`).pop()),price:e.priceAdjustments.length>0?Math.round(Number(e.priceAdjustments[0].price.amount)*100):Math.round(Number(t.price.amount)*100),compareAtPrice:e.priceAdjustments.length>0?Math.round(Number(e.priceAdjustments[0].compareAtPrice.amount)*100):Math.round(Number(t.price.amount)*100),perDeliveryPrice:e.priceAdjustments.length>0?Math.round(Number(e.priceAdjustments[0].perDeliveryPrice.amount)*100):Math.round(Number(t.price.amount)*100)}))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:t.quantityAvailable??null,unitPriceMeasurement:e?.quantityUnit&&e?.referenceUnit?{quantityValue:e.quantityValue,quantityUnit:e.quantityUnit.toLowerCase(),referenceValue:e.referenceValue,referenceUnit:e.referenceUnit.toLowerCase()}:null})),i=e.options.map((e,t)=>{let n=e.optionValues.map(e=>({id:Number(e.id.split(`/`).pop()),defaultName:e.name,name:e.name,swatch:{color:e.swatch?.color||null,image:e.swatch?.image?.previewImage?.url||null}}));return{defaultName:e.name,name:e.name,position:t+1,optionValues:b(n,t,r)}}),a=e=>{let t=e.priceAdjustments[0];if(!t)return null;let n=t.adjustmentValue;switch(n.__typename){case`SellingPlanPercentagePriceAdjustment`:return{type:`percentage`,value:n.adjustmentPercentage};case`SellingPlanFixedAmountPriceAdjustment`:return{type:`fixed_amount`,value:o(n.adjustmentAmount.amount)};case`SellingPlanFixedPriceAdjustment`:return{type:`price`,value:o(n.price.amount)};default:throw Error(`Unknown price adjustment type: ${n.__typename}`)}},o=e=>n===1?Number(e)*100:Math.round(Number(e)*100*n),s=e.sellingPlanGroups?.nodes.flatMap(e=>e.sellingPlans.nodes.map(e=>({id:Number(e.id.split(`/`).pop()),name:e.name,priceAdjustment:a(e)})))||[],c=e.variants.nodes.some(e=>e.requiresComponents);return{id:Number(e.id.split(`/`).pop()),handle:e.handle,url:e.onlineStoreUrl||`https://${t}/products/${e.handle}`,availableForSale:e.availableForSale,createdAt:e.createdAt,title:e.title,image:e.featuredImage?.url||null,collectionIds:e.collections.nodes.map(e=>Number(e.id.split(`/`).pop())),options:i,selectedVariantId:Number(e.variants.nodes[0].id.split(`/`).pop()),variants:r,requiresSellingPlan:e.requiresSellingPlan,sellingPlans:s,isNativeBundle:c,metafields:{text:e.metafield?.value||null,text2:e.metafield2?.value||null,text3:e.metafield3?.value||null,text4:e.metafield4?.value||null},rating:v(e.reviewsRating,e.reviewsRatingCount),subtitle:e.subtitle?.value||null}},v=(e,t)=>{if(!e)return null;let n=y(e.value);if(n===null)return null;let r=Number(t?.value);return{value:n,count:Number.isInteger(r)&&r>0?r:null}},y=e=>{try{let{value:t,scale_max:n}=JSON.parse(e),r=Number(t)/Number(n)*5;return Number.isFinite(r)&&r>0?Math.min(5,r):null}catch{return null}},b=(e,t,n)=>e.filter(e=>n.filter(n=>n.options[t]===e.name).length>0),x=`app--2935586817`,S=async(e,{language:n,country:r,useExternalMetafieldNamespace:i})=>{let a=i?`${x}--kaching_bundles`:`$app:kaching_bundles`,o=i?x:`$app`,s=c({country:r}),{localization:{country:{currency:{isoCode:l}}},shop:{moneyFormat:u,paymentSettings:{currencyCode:d},currencyRateConstant:f,primaryDomain:p,settingsMetafield:m}}=await e.query(`
202
+ query config($metafieldNamespace: String!, $settingsNamespace: String!) ${s} {
194
203
  localization {
195
204
  country {
196
205
  currency {
@@ -214,7 +223,7 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
214
223
  }
215
224
  }
216
225
  }
217
- `,{variables:{metafieldNamespace:n,settingsNamespace:i}}),f=r===c?m:R(r,{language:t,country:a}),v=u?ee(u.value):1,l=g?JSON.parse(g.value):null,d=(l==null?void 0:l.feature_flags)??{},y=(l==null?void 0:l.custom_selectors)??{};return{shopifyDomain:h.host,moneyFormat:f,locale:(t==null?void 0:t.toLowerCase())||"en",liquidLocale:(t==null?void 0:t.toLowerCase())||"en",country:a??"US",currencyRate:v,marketId:0,productId:null,storefrontAccessToken:(l==null?void 0:l.storefront_access_token)??null,includeSellingPlans:(l==null?void 0:l.include_selling_plans)??!1,includeAvailableQuantity:(l==null?void 0:l.include_available_quantity)??!1,customApiHost:(l==null?void 0:l.custom_api_host)??null,keepQuantityInput:(l==null?void 0:l.keep_quantity_input)??!1,ignoreDeselect:(l==null?void 0:l.ignore_deselect)??!1,ignoreUnitPrice:(l==null?void 0:l.ignore_unit_price)??!1,requireCustomerLogin:(l==null?void 0:l.require_customer_login)??!1,abTestsRunning:(l==null?void 0:l.ab_tests_running)??!1,webPixel:(l==null?void 0:l.web_pixel)??!1,b2bCustomer:!1,isLoggedIn:!1,preview:!1,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":"Out of stock","system.invalid_variant":"Invalid variant","system.unavailable_option_value":"Unavailable option value","system.confirm":"Confirm","system.cancel":"Cancel","system.free":"FREE","system.search":"Search","system.quantity":"Quantity","system.subscription_plan":"Subscription plan","system.remove":"Remove","system.sort_by":"Sort by","system.sort_relevance":"Relevance","system.sort_newest_first":"Newest first","system.sort_price_low_to_high":"Price: Low → High","system.sort_price_high_to_low":"Price: High → Low","system.no_results_found":"No results found","system.no_results_description":"We can't find any item matching your search.","system.clear_search":"Clear search","system.no_products_available":"No products available","system.original_price":"Original price:","system.price":"Price:","system.letters_only":"Only letters are allowed.","system.numbers_only":"Only numbers are allowed."},customSelectors:{quantity:y.quantity??null,addToCartButton:y.add_to_cart_button??null,variantPicker:y.variant_picker??null,price:y.price??null,priceCompare:y.price_compare??null},shopCustomStyles:(l==null?void 0:l.shop_custom_styles)??"",featureFlags:d,brandColors:(l==null?void 0:l.brand_colors)??null}},ee=e=>JSON.parse(e).amount/1e6,te=async(e,t,a=200)=>{const s=[...new Set(t.filter(Boolean).filter(i=>!i.startsWith("placeholder")))];if(s.length===0)return[];const n=[];for(let i=0;i<s.length;i+=250)n.push(s.slice(i,i+250));return(await Promise.all(n.map(i=>e.query(`
226
+ `,{variables:{metafieldNamespace:a,settingsNamespace:o}}),h=l===d?u:t(l,{language:n,country:r}),g=f?C(f.value):1,_=m?JSON.parse(m.value):null,v=_?.feature_flags??{},y=_?.custom_selectors??{};return{shopifyDomain:p.host,moneyFormat:h,locale:n?.toLowerCase()||`en`,liquidLocale:n?.toLowerCase()||`en`,country:r??`US`,currencyRate:g,marketId:0,productId:null,storefrontAccessToken:_?.storefront_access_token??null,includeSellingPlans:_?.include_selling_plans??!1,includeAvailableQuantity:_?.include_available_quantity??!1,customApiHost:_?.custom_api_host??null,keepQuantityInput:_?.keep_quantity_input??!1,ignoreDeselect:_?.ignore_deselect??!1,ignoreUnitPrice:_?.ignore_unit_price??!1,requireCustomerLogin:_?.require_customer_login??!1,abTestsRunning:_?.ab_tests_running??!1,webPixel:_?.web_pixel??!1,b2bCustomer:!1,isLoggedIn:!1,preview:!1,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":`Out of stock`,"system.invalid_variant":`Invalid variant`,"system.unavailable_option_value":`Unavailable option value`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`},customSelectors:{quantity:y.quantity??null,addToCartButton:y.add_to_cart_button??null,variantPicker:y.variant_picker??null,price:y.price??null,priceCompare:y.price_compare??null},shopCustomStyles:_?.shop_custom_styles??``,featureFlags:v,brandColors:_?.brand_colors??null}},C=e=>JSON.parse(e).amount/1e6,w=async(e,t,n=200)=>{let r=[...new Set(t.filter(Boolean).filter(e=>!e.startsWith(`placeholder`)))];if(r.length===0)return[];let i=[];for(let e=0;e<r.length;e+=250)i.push(r.slice(e,e+250));return(await Promise.all(i.map(t=>e.query(`
218
227
  query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
219
228
  nodes(ids: $mediaImageIds) {
220
229
  ... on MediaImage {
@@ -225,5 +234,5 @@ var BundlesJs=(function(A){"use strict";const z=(e,t)=>{const a=[],s=e.filter(r=
225
234
  }
226
235
  }
227
236
  }
228
- `,{variables:{mediaImageIds:i,size:a}})))).flatMap(i=>i.nodes).flatMap(i=>i!=null&&i.image?[{gid:i.id,url:i.image.url}]:[])};var S=(e=>(e.QuantityBreak="quantity-break",e.Bxgy="bxgy",e.Bundle="bundle",e.MixAndMatch="mix-and-match",e.Sku="sku",e))(S||{});const ae=e=>[...se(e),...ne(e),...le(e),...re(e),...ie(e),...oe(e),...ce(e),...ue(e),...de(e),...me(e),...pe(e),...fe(e),...he(e)].filter(t=>t!=null&&!t.includes("placeholder")),se=e=>e.dealBars.flatMap(t=>[t.mediaImageGID,t.badgeImageGID]).filter(t=>t!=null),ne=e=>e.dealBars.flatMap(t=>t.dealBarType===S.Bundle?t.bundleProducts.map(a=>a.mediaImageGID):[]).filter(t=>t!=null),le=e=>e.dealBars.map(({freeGifts:t})=>(t||[]).map(a=>a.mediaImageGID)).reduce((t,a)=>t.concat(a),[]).filter(t=>t!=null),re=e=>e.dealBars.flatMap(({multipleGiftsSelectors:t})=>(t||[]).map(a=>a.mediaImageGID)).filter(t=>t!=null),ie=e=>e.dealBars.map(({upsells:t})=>(t||[]).map(a=>a.mediaImageGID)).reduce((t,a)=>t.concat(a),[]).filter(t=>t!=null),oe=e=>e.swatchOptions?e.swatchOptions.reduce((t,a)=>{const s=a.images.map(n=>n.mediaImageGID).filter(n=>n!=null);return[...t,...s]},[]):[],ce=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];const t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},ue=e=>{var t,a,s;return e.progressiveGifts?[...((t=e.progressiveGifts.gifts)==null?void 0:t.map(n=>n.mediaImageGID))||[],(a=e.progressiveGifts.style)==null?void 0:a.lockedMediaImageGID,(s=e.progressiveGifts.dealBarStyle)==null?void 0:s.lockedMediaImageGID].filter(n=>n!=null):[]},de=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(t=>[t.mediaImageGID,t.badgeImageGID]).filter(t=>t!=null),me=e=>e.dealBars.map(t=>{var a;return(a=t.productPersonalisation)==null?void 0:a.mediaImageGID}).filter(t=>t!=null),pe=e=>{var s,n;const t=e.dealBars.map(i=>{var o;return(o=i.highlights)==null?void 0:o.customIconGID}).filter(i=>i!=null),a=(n=(s=e.subscriptions)==null?void 0:s.highlights)==null?void 0:n.customIconGID;return a?[...t,a]:t},fe=e=>(e.badges||[]).flatMap(t=>t.badgeType==="custom"&&t.imageGID?[t.imageGID]:[]),he=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],ge=e=>{const t=[...ye(e),...be(e),...ve(e),...Ie(e),..._e(e),...Pe(e),...Se(e),...ke(e)];return Array.from(new Set(t.filter(a=>a!=null)))},ye=e=>e.dealBars.flatMap(({freeGifts:t})=>t?t.map(a=>a.productGID):[]).filter(t=>t!=null),be=e=>e.dealBars.flatMap(({multipleGiftsSelectors:t})=>t?t.flatMap(a=>a.products?a.products.map(s=>s.id):[]):[]).filter(t=>t!=null),ve=e=>{var t;return e.progressiveGiftsEnabled?((t=e.progressiveGifts)==null?void 0:t.gifts.map(a=>a.productGID).filter(a=>a!=null))||[]:[]},Ie=e=>e.dealBars.flatMap(({upsells:t})=>t?t.map(a=>a.productGID):[]).filter(t=>t!=null),_e=e=>e.dealBars.filter(t=>t.dealBarType===S.Bundle).flatMap(({bundleProducts:t})=>t?t.map(a=>a.productGID):[]).filter(t=>t!=null).filter(t=>t!=="default"),Pe=e=>e.dealBars.filter(t=>t.dealBarType===S.MixAndMatch).flatMap(({bundleProducts:t})=>t?t.flatMap(a=>{var s;return[a.productGID,...((s=a.selectedProducts)==null?void 0:s.map(n=>n.id))??[]]}):[]).filter(t=>t!=null).filter(t=>t!=="default"),Se=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(t=>t.productGID).filter(t=>t!=null),ke=e=>e.dealBars.filter(t=>t.dealBarType===S.Sku).flatMap(({productGID:t})=>t?[t]:[]);class j extends Error{constructor({status:t,operationName:a,graphqlErrors:s}){const n=s.length?`: ${s.join("; ")}`:"";super(`Storefront API ${a??"query"} failed (HTTP ${t})${n}`),this.name="StorefrontApiError",this.status=t,this.operationName=a,this.graphqlErrors=s}}const we=async(e,t)=>{const a=await e.text();if(!a)throw new Error("Empty graphql response");let s;try{s=JSON.parse(a)}catch(n){throw e.ok?n:new j({status:e.status,operationName:t,graphqlErrors:[]})}if(!e.ok||s.data===null||s.data===void 0)throw new j({status:e.status,operationName:t,graphqlErrors:(s.errors??[]).map(({message:n})=>n).filter(Boolean)});return s.data};class Ee{constructor(t,a){this.storefrontApiVersion="2026-07",this.storefrontAccessToken=a,this.shopifyDomain=t}async query(t,a){var r;const s=(a==null?void 0:a.variables)??{};let n=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;const i=(r=t.match(/query\s+(\w+)/))==null?void 0:r[1];i&&(n+=`?operation_name=${i}`);const o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:t,variables:s})});return we(o,i)}}const Ae=async(e,t,{country:a,language:s})=>{const n=t.collectionBreaks;if(!t.collectionBreaksEnabled||!n)return;let i;n.visibility==="deal-products"?i=await T(e,{country:a,language:s,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(r=>`gid://shopify/Product/${r}`),selectedProductGIDs:(t.selectedProductIds||[]).map(r=>`gid://shopify/Product/${r}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(r=>`gid://shopify/Collection/${r}`)}):i=await T(e,{country:a,language:s,blockVisibility:n.visibility,excludedProductGIDs:(n.excludedProducts||[]).map(({id:r})=>r),selectedProductGIDs:(n.selectedProducts||[]).map(({id:r})=>r),selectedCollectionGIDs:(n.selectedCollections||[]).map(({id:r})=>r)});let o=await $(e,{country:a,language:s,productIds:i.map(r=>Number(r.split("/").pop())),useExternalMetafieldNamespace:!0});return o=o.filter(r=>r.availableForSale),o},$e=({language:e,dealBlockId:t})=>{const a={"system.out_of_stock":"There's not enough items in our stock, please select smaller bundle.","system.invalid_variant":"Sorry, this is not currently available.","system.unavailable_option_value":"Unavailable","system.confirm":"Confirm","system.cancel":"Cancel","system.free":"FREE","system.search":"Search","system.quantity":"Quantity","system.subscription_plan":"Subscription plan","system.remove":"Remove","system.sort_by":"Sort by","system.sort_relevance":"Relevance","system.sort_newest_first":"Newest first","system.sort_price_low_to_high":"Price: Low → High","system.sort_price_high_to_low":"Price: High → Low","system.no_results_found":"No results found","system.no_results_description":"We can't find any item matching your search.","system.clear_search":"Clear search","system.no_products_available":"No products available","system.original_price":"Original price:","system.price":"Price:","system.letters_only":"Only letters are allowed.","system.numbers_only":"Only numbers are allowed.","system.personalisation_required_alert":"Please add personalisation for every item to continue."},s=e?De(e):void 0;return{...a,...s==null?void 0:s.system,...s==null?void 0:s.dealBlocks[t]}},De=e=>{var n;if(typeof document>"u")return;const t=document.querySelector("script#kaching-bundles-translations");if(!(t!=null&&t.textContent))return;let a;try{a=JSON.parse(t.textContent)}catch{return}const s=L(e);return(n=a.find(i=>L(i.locale)===s))==null?void 0:n.translations},L=e=>e.toLowerCase().replace(/_/g,"-"),Ce="2026-07",U=async(e,{productId:t,dealBlockId:a,country:s=void 0,language:n=void 0})=>{var i,o;try{const r=[Number(t.split("/").pop())],m=new Ne(e);s=s||((i=m.i18n)==null?void 0:i.country),n=n||((o=m.i18n)==null?void 0:o.language);const c=await Z(m,{language:n,country:s,useExternalMetafieldNamespace:!0});m.shopifyDomain=c.shopifyDomain;const u=c.storefrontAccessToken?new Ee(c.shopifyDomain,c.storefrontAccessToken):m,[h,g]=await Promise.all([$(u,{country:s,language:n,productIds:r,useExternalMetafieldNamespace:!0}),X(u,{useExternalMetafieldNamespace:!0,useMetaobjects:c.featureFlags.storefront_metaobjects})]),f=h[0];if(!f)return null;const v=z(g,f);let l;if(a?(l=v.find(P=>P.id===a||P.nanoId===a),l||(l=v[0])):l=v[0],!l)return null;const d=ae(l),y=ge(l),[_,I,p,b]=await Promise.all([$(u,{country:s,language:n,productIds:y,useExternalMetafieldNamespace:!0}),te(u,d,300),Ae(u,l,{country:s,language:n}),$e({language:n,dealBlockId:l.id})]);return{product:f,dealBlock:l,config:c,otherProducts:_,mediaImages:I,collectionBreaksProducts:p??[],translations:b}}catch(r){return console.error(r),null}};class Ne{constructor(t){this.storefront=t,this.shopifyDomain=""}async query(t,a){var s;if("query"in this.storefront&&"i18n"in this.storefront)return await this.storefront.query(t,a);if("graphql"in this.storefront){const n=await this.storefront.graphql(t,a);if((s=n.errors)!=null&&s.length)throw new Error(n.errors.map(i=>i.message).join(`
229
- `));return n.data}if("request"in this.storefront)return(await this.storefront.request(t,a)).data;if("shopifyDomain"in this.storefront&&"storefrontAccessToken"in this.storefront){const n=await fetch(`https://${this.storefront.shopifyDomain}/api/${Ce}/graphql.json`,{body:JSON.stringify({query:t,variables:a==null?void 0:a.variables}),headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:"POST"});if(!n.ok)throw new Error(n.statusText);return(await n.json()).data}else{const n=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:t,variables:a==null?void 0:a.variables}),headers:this.storefront.getPublicTokenHeaders(),method:"POST"});if(!n.ok)throw new Error(n.statusText);return(await n.json()).data}}get i18n(){if("i18n"in this.storefront)return this.storefront.i18n}}const w="kaching-bundles-block",V=1e4,xe="https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js",Ge="https://bundles-integrations.kachingappz.app/kaching-bundles-block.js",D=new WeakSet,F=async e=>{const t=e.document;if(!e.customElements.get(w)){if(D.has(t))return C(e,w);D.add(t);try{await Me(e)}catch(a){throw D.delete(t),a}}},Te=()=>typeof window<"u"&&typeof window.__KACHING_DEV__<"u",Be=()=>Te()?xe:Ge,Me=e=>{const t=e.document;return new Promise((a,s)=>{const n=Be();if(t.querySelector(`script[src="${n}"]`)){C(e,w).then(a).catch(s);return}const o=t.createElement("script");o.src=n,o.onload=()=>C(e,w).then(a).catch(s),o.onerror=()=>s(new Error("Failed to load script")),t.head.appendChild(o)})},C=(e,t)=>new Promise((a,s)=>{if(e.customElements.get(t)){a();return}Promise.race([e.customElements.whenDefined(t),new Promise((n,i)=>setTimeout(()=>i(new Error(`Custom element "${t}" failed to register within ${V}ms`)),V))]).then(()=>a()).catch(s)});var E=(e=>(e.QuantityBreak="quantity-break",e.Bxgy="bxgy",e.Bundle="bundle",e.MixAndMatch="mix-and-match",e.Sku="sku",e))(E||{});const qe={id:1,handle:"example-product",url:null,availableForSale:!0,title:"Example product",image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:["Default Title"],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},Oe={id:"example",nanoId:"example",blockName:"Bundle",discountName:"",blockTitle:"BUNDLE & SAVE",blockLayout:"vertical",blockVisibility:"all-products",marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:"",useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:".00",updateNativePrice:!1,updateNativePriceType:"item",skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:"duo",cornerRadius:16,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:245,green:245,blue:245,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:171,green:239,blue:198,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:0,green:0,blue:0,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:"14",style:"bold"},title:{size:"20",style:"bold"},subtitle:{size:"14",style:"regular"},label:{size:"12",style:"bold"},freeGift:{size:"13",style:"bold"},upsell:{size:"13",style:"bold"},unitLabel:{size:"14",style:"regular"}},dealBars:[{id:"single",dealBarType:E.QuantityBreak,quantitySelector:!1,title:"Single",subtitle:"Standard price",label:"",quantity:1,discountType:"default",discountValue:"",badgeStyle:"simple",badgeText:"",badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:"customer-choice"},{id:"duo",dealBarType:E.QuantityBreak,quantitySelector:!1,title:"Duo",subtitle:"You save 20%",label:"SAVE $32",quantity:2,discountType:"percentage",discountValue:"20",badgeStyle:"most-popular",badgeText:"",badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:"customer-choice"},{id:"trio",dealBarType:E.QuantityBreak,quantitySelector:!1,title:"Trio",subtitle:"You save 25%",label:"SAVE $60",quantity:3,discountType:"percentage",discountValue:"25",badgeStyle:"simple",badgeText:"",badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:"customer-choice"}],badgesEnabled:!0,badges:[{id:"bdg1",attachedTo:{type:"dealBar",dealBarId:"duo"},text:"MOST POPULAR",colors:null,badgeType:"most-popular",size:90}],swatchOptions:[],swatchSize:18,swatchShape:"circle",imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:"",customStyles:"",lowStockAlertEnabled:!1,lowStockAlert:null},je={config:{shopifyDomain:"",moneyFormat:"${{amount}}",locale:"en",country:"US",currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,includeSellingPlans:!1,includeAvailableQuantity:!1,customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":"There's not enough items in our stock, please select smaller bundle.","system.invalid_variant":"Sorry, this is not currently available.","system.unavailable_option_value":"Unavailable","system.confirm":"Confirm","system.cancel":"Cancel","system.free":"FREE","system.search":"Search","system.quantity":"Quantity","system.subscription_plan":"Subscription plan","system.remove":"Remove","system.sort_by":"Sort by","system.sort_relevance":"Relevance","system.sort_newest_first":"Newest first","system.sort_price_low_to_high":"Price: Low → High","system.sort_price_high_to_low":"Price: High → Low","system.no_results_found":"No results found","system.no_results_description":"We can't find any item matching your search.","system.clear_search":"Clear search","system.no_products_available":"No products available","system.original_price":"Original price:","system.price":"Price:","system.letters_only":"Only letters are allowed.","system.numbers_only":"Only numbers are allowed."},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:""},dealBlock:Oe,product:qe,otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}};class Le extends HTMLElement{constructor(){super(...arguments),this.innerElement=null,this.handleItemsChanged=null,this.initializeId=0}static get observedAttributes(){return["selected-variant-id","product-id","country","language"]}async connectedCallback(){await this.initialize()}async initialize(){var o,r;const t=++this.initializeId;if(this.cleanup(),this.hasAttribute("demo")){if(await F(window),t!==this.initializeId)return;this.renderInnerElement(je);return}const a=this.getAttribute("shop-domain"),s=this.getAttribute("storefront-token"),n=this.getAttribute("product-id");if(!a||!s||!n)return;const[i]=await Promise.all([U({shopifyDomain:a,storefrontAccessToken:s},{productId:n,dealBlockId:this.getAttribute("deal-block-id")??void 0,country:((o=this.getAttribute("country"))==null?void 0:o.toUpperCase())??void 0,language:((r=this.getAttribute("language"))==null?void 0:r.toUpperCase())??void 0}),F(window)]);!i||t!==this.initializeId||this.renderInnerElement(i)}renderInnerElement(t){const{config:a,dealBlock:s,product:n,otherProducts:i,mediaImages:o,collectionBreaksProducts:r,translations:m}=t;this.innerElement=document.createElement("kaching-bundles-block"),this.innerElement.setAttribute("deal-block-id",s.id),this.innerElement.setAttribute("config",JSON.stringify(a)),this.innerElement.setAttribute("deal-block",JSON.stringify(s)),this.innerElement.setAttribute("media-images",JSON.stringify(o??[])),this.innerElement.setAttribute("product",JSON.stringify(n)),this.innerElement.setAttribute("other-products",JSON.stringify(i??[])),this.innerElement.setAttribute("collection-breaks-products",JSON.stringify(r??[])),this.innerElement.setAttribute("translations",JSON.stringify(m??{}));const c=this.getAttribute("selected-variant-id");this.innerElement.setAttribute("current-variant-id",String(c?c.split("/").pop():n.variants[0].id)),this.hasAttribute("compact")&&this.innerElement.setAttribute("compact","");const u=this.innerElement,h=()=>{if(this.innerElement!==u)return;const f=u.items();f&&this.dispatchEvent(new CustomEvent("items-changed",{detail:{items:f},bubbles:!0}))};this.handleItemsChanged=f=>{f.stopPropagation(),h()};const g=this.handleItemsChanged;u.addEventListener("kaching-bundles-block-loaded",()=>{this.innerElement===u&&(u.addEventListener("items-changed",g),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0})))},{once:!0}),this.appendChild(this.innerElement)}cleanup(){this.handleItemsChanged&&this.innerElement&&(this.innerElement.removeEventListener("items-changed",this.handleItemsChanged),this.handleItemsChanged=null),this.innerElement&&(this.innerElement.remove(),this.innerElement=null)}attributeChangedCallback(t,a,s){a!==s&&this.isConnected&&(t==="product-id"||t==="country"||t==="language"?this.initialize():t==="selected-variant-id"&&this.innerElement&&s&&this.innerElement.setAttribute("current-variant-id",s.includes("/")?String(s.split("/").pop()):s))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}}return customElements.define("kaching-bundle-component",Le),A.fetchKachingBundlesData=U,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),A})({});
237
+ `,{variables:{mediaImageIds:t,size:n}})))).flatMap(e=>e.nodes).flatMap(e=>e?.image?[{gid:e.id,url:e.image.url}]:[])},T=e=>[...E(e),...D(e),...O(e),...k(e),...A(e),...ee(e),...te(e),...ne(e),...re(e),...ie(e),...ae(e),...oe(e),...se(e)].filter(e=>e!=null&&!e.includes(`placeholder`)),E=e=>e.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),D=e=>e.dealBars.flatMap(e=>e.dealBarType===f.Bundle?e.bundleProducts.map(e=>e.mediaImageGID):[]).filter(e=>e!=null),O=e=>e.dealBars.map(({freeGifts:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),k=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(e=>e.mediaImageGID)).filter(e=>e!=null),A=e=>e.dealBars.map(({upsells:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),ee=e=>e.swatchOptions?e.swatchOptions.reduce((e,t)=>{let n=t.images.map(e=>e.mediaImageGID).filter(e=>e!=null);return[...e,...n]},[]):[],te=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];let t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},ne=e=>e.progressiveGifts?[...e.progressiveGifts.gifts?.map(e=>e.mediaImageGID)||[],e.progressiveGifts.style?.lockedMediaImageGID,e.progressiveGifts.dealBarStyle?.lockedMediaImageGID].filter(e=>e!=null):[],re=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ie=e=>e.dealBars.map(e=>e.productPersonalisation?.mediaImageGID).filter(e=>e!=null),ae=e=>{let t=e.dealBars.map(e=>e.highlights?.customIconGID).filter(e=>e!=null),n=e.subscriptions?.highlights?.customIconGID;return n?[...t,n]:t},oe=e=>(e.badges||[]).flatMap(e=>e.badgeType===`custom`&&e.imageGID?[e.imageGID]:[]),se=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],ce=e=>{let t=[...j(e),...M(e),...N(e),...P(e),...F(e),...I(e),...L(e),...R(e)];return Array.from(new Set(t.filter(e=>e!=null)))},j=e=>e.dealBars.flatMap(({freeGifts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),M=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(e=>e.products?e.products.map(e=>e.id):[]):[]).filter(e=>e!=null),N=e=>e.progressiveGiftsEnabled&&e.progressiveGifts?.gifts.map(e=>e.productGID).filter(e=>e!=null)||[],P=e=>e.dealBars.flatMap(({upsells:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),F=e=>e.dealBars.filter(e=>e.dealBarType===f.Bundle).flatMap(({bundleProducts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),I=e=>e.dealBars.filter(e=>e.dealBarType===f.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(e=>[e.productGID,...e.selectedProducts?.map(e=>e.id)??[]]):[]).filter(e=>e!=null).filter(e=>e!=="default"),L=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),R=e=>e.dealBars.filter(e=>e.dealBarType===f.Sku).flatMap(({productGID:e})=>e?[e]:[]),z=class extends Error{constructor({status:e,operationName:t,graphqlErrors:n}){let r=n.length?`: ${n.join(`; `)}`:``;super(`Storefront API ${t??`query`} failed (HTTP ${e})${r}`),this.name=`StorefrontApiError`,this.status=e,this.operationName=t,this.graphqlErrors=n}},B=async(e,t)=>{let n=await e.text();if(!n)throw Error(`Empty graphql response`);let r;try{r=JSON.parse(n)}catch(n){throw e.ok?n:new z({status:e.status,operationName:t,graphqlErrors:[]})}if(!e.ok||r.data===null||r.data===void 0)throw new z({status:e.status,operationName:t,graphqlErrors:(r.errors??[]).map(({message:e})=>e).filter(Boolean)});return r.data},V=class{constructor(e,t){this.storefrontApiVersion=`2026-07`,this.storefrontAccessToken=t,this.shopifyDomain=e}async query(e,t){let n=t?.variables??{},r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`,i=e.match(/query\s+(\w+)/)?.[1];return i&&(r+=`?operation_name=${i}`),B(await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:n})}),i)}},H=(e,t)=>{let n=[],r=e.filter(e=>e.blockVisibility===`selected-products`);for(let e of r)e.selectedProductIds.map(Number).includes(t.id)&&n.push(e);let i=e.filter(e=>e.blockVisibility===`selected-collections`);for(let e of i)t.collectionIds.some(t=>e.selectedCollectionIds.map(Number).includes(t))&&n.push(e);let a=e.filter(e=>e.blockVisibility===`excluded-products`);for(let e of a)!e.excludedProductIds.map(Number).includes(t.id)&&!(e.excludedCollectionIds||[]).some(e=>t.collectionIds.includes(e))&&n.push(e);let o=e.filter(e=>e.blockVisibility===`all-products`);for(let e of o)n.push(e);return n},U=async(e,t,{country:n,language:r})=>{let i=t.collectionBreaks;if(!t.collectionBreaksEnabled||!i)return;let a;a=i.visibility===`deal-products`?await p(e,{country:n,language:r,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedProductGIDs:(t.selectedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(e=>`gid://shopify/Collection/${e}`)}):await p(e,{country:n,language:r,blockVisibility:i.visibility,excludedProductGIDs:(i.excludedProducts||[]).map(({id:e})=>e),selectedProductGIDs:(i.selectedProducts||[]).map(({id:e})=>e),selectedCollectionGIDs:(i.selectedCollections||[]).map(({id:e})=>e)});let o=await h(e,{country:n,language:r,productIds:a.map(e=>Number(e.split(`/`).pop())),useExternalMetafieldNamespace:!0});return o=o.filter(e=>e.availableForSale),o},W=({language:e,dealBlockId:t})=>{let n={"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`,"system.personalisation_required_alert":`Please add personalisation for every item to continue.`},r=e?le(e):void 0;return{...n,...r?.system,...r?.dealBlocks[t]}},le=e=>{if(typeof document>`u`)return;let t=document.querySelector(`script#kaching-bundles-translations`);if(!t?.textContent)return;let n;try{n=JSON.parse(t.textContent)}catch{return}let r=G(e);return n.find(e=>G(e.locale)===r)?.translations},G=e=>e.toLowerCase().replace(/_/g,`-`),ue=`2026-07`,K=async(e,{productId:t,dealBlockId:n,country:r=void 0,language:i=void 0})=>{try{let a=[Number(t.split(`/`).pop())],o=new de(e);r||=o.i18n?.country,i||=o.i18n?.language;let s=await S(o,{language:i,country:r,useExternalMetafieldNamespace:!0});o.shopifyDomain=s.shopifyDomain;let c=s.storefrontAccessToken?new V(s.shopifyDomain,s.storefrontAccessToken):o,[u,d]=await Promise.all([h(c,{country:r,language:i,productIds:a,useExternalMetafieldNamespace:!0}),l(c,{useExternalMetafieldNamespace:!0,useMetaobjects:s.featureFlags.storefront_metaobjects})]),f=u[0];if(!f)return null;let p=H(d,f),m;if(n?(m=p.find(e=>e.id===n||e.nanoId===n),m||=p[0]):m=p[0],!m)return null;let g=T(m),_=ce(m),[v,y,b,x]=await Promise.all([h(c,{country:r,language:i,productIds:_,useExternalMetafieldNamespace:!0}),w(c,g,300),U(c,m,{country:r,language:i}),W({language:i,dealBlockId:m.id})]);return{product:f,dealBlock:m,config:s,otherProducts:v,mediaImages:y,collectionBreaksProducts:b??[],translations:x}}catch(e){return console.error(e),null}},de=class{constructor(e){this.storefront=e,this.shopifyDomain=``}async query(e,t){if(`query`in this.storefront&&`i18n`in this.storefront)return await this.storefront.query(e,t);if(`graphql`in this.storefront){let n=await this.storefront.graphql(e,t);if(n.errors?.length)throw Error(n.errors.map(e=>e.message).join(`
238
+ `));return n.data}if(`request`in this.storefront)return(await this.storefront.request(e,t)).data;if(`shopifyDomain`in this.storefront&&`storefrontAccessToken`in this.storefront){let n=await fetch(`https://${this.storefront.shopifyDomain}/api/${ue}/graphql.json`,{body:JSON.stringify({query:e,variables:t?.variables}),headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}{let n=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:e,variables:t?.variables}),headers:this.storefront.getPublicTokenHeaders(),method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}}get i18n(){if(`i18n`in this.storefront)return this.storefront.i18n}},q=`kaching-bundles-block`,J=1e4,fe=`https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js`,pe=`https://bundles-integrations.kachingappz.app/kaching-bundles-block.js`,Y=new WeakSet,X=async e=>{let t=e.document;if(!e.customElements.get(q)){if(Y.has(t))return Z(e,q);Y.add(t);try{await ge(e)}catch(e){throw Y.delete(t),e}}},me=()=>typeof window<`u`&&window.__KACHING_DEV__!==void 0,he=()=>me()?fe:pe,ge=e=>{let t=e.document;return new Promise((n,r)=>{let i=he();if(t.querySelector(`script[src="${i}"]`)){Z(e,q).then(n).catch(r);return}let a=t.createElement(`script`);a.src=i,a.onload=()=>Z(e,q).then(n).catch(r),a.onerror=()=>r(Error(`Failed to load script`)),t.head.appendChild(a)})},Z=(e,t)=>new Promise((n,r)=>{e.customElements.get(t)?n():Promise.race([e.customElements.whenDefined(t),new Promise((e,n)=>setTimeout(()=>n(Error(`Custom element "${t}" failed to register within ${J}ms`)),J))]).then(()=>n()).catch(r)});[`primaryBackground`,`secondaryBackground`,`primaryText`,`secondaryText`,`border`,`overlay`,`primaryAccent`,`primaryAccentText`,`badgeBackground`,`badgeText`,`error`].map(e=>`brand_${e}`);var Q=function(e){return e.QuantityBreak=`quantity-break`,e.Bxgy=`bxgy`,e.Bundle=`bundle`,e.MixAndMatch=`mix-and-match`,e.Sku=`sku`,e}({}),$={config:{shopifyDomain:``,moneyFormat:"${{amount}}",locale:`en`,country:`US`,currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,includeSellingPlans:!1,includeAvailableQuantity:!1,customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:``},dealBlock:{id:`example`,nanoId:`example`,blockName:`Bundle`,discountName:``,blockTitle:`BUNDLE & SAVE`,blockLayout:`vertical`,blockVisibility:`all-products`,marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:``,useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:`.00`,updateNativePrice:!1,updateNativePriceType:`item`,skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:`duo`,cornerRadius:16,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:245,green:245,blue:245,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:171,green:239,blue:198,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:0,green:0,blue:0,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:`14`,style:`bold`},title:{size:`20`,style:`bold`},subtitle:{size:`14`,style:`regular`},label:{size:`12`,style:`bold`},freeGift:{size:`13`,style:`bold`},upsell:{size:`13`,style:`bold`},unitLabel:{size:`14`,style:`regular`}},dealBars:[{id:`single`,dealBarType:Q.QuantityBreak,quantitySelector:!1,title:`Single`,subtitle:`Standard price`,label:``,quantity:1,discountType:`default`,discountValue:``,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`duo`,dealBarType:Q.QuantityBreak,quantitySelector:!1,title:`Duo`,subtitle:`You save 20%`,label:`SAVE $32`,quantity:2,discountType:`percentage`,discountValue:`20`,badgeStyle:`most-popular`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`trio`,dealBarType:Q.QuantityBreak,quantitySelector:!1,title:`Trio`,subtitle:`You save 25%`,label:`SAVE $60`,quantity:3,discountType:`percentage`,discountValue:`25`,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`}],badgesEnabled:!0,badges:[{id:`bdg1`,attachedTo:{type:`dealBar`,dealBarId:`duo`},text:`MOST POPULAR`,colors:null,badgeType:`most-popular`,size:90}],swatchOptions:[],swatchSize:18,swatchShape:`circle`,imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:``,customStyles:``,lowStockAlertEnabled:!1,lowStockAlert:null},product:{id:1,handle:`example-product`,url:null,availableForSale:!0,title:`Example product`,image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:[`Default Title`],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}},_e=class extends HTMLElement{constructor(...e){super(...e),this.innerElement=null,this.handleItemsChanged=null,this.initializeId=0}static get observedAttributes(){return[`selected-variant-id`,`product-id`,`country`,`language`]}async connectedCallback(){await this.initialize()}async initialize(){let e=++this.initializeId;if(this.cleanup(),this.hasAttribute(`demo`)){if(await X(window),e!==this.initializeId)return;this.renderInnerElement($);return}let t=this.getAttribute(`shop-domain`),n=this.getAttribute(`storefront-token`),r=this.getAttribute(`product-id`);if(!t||!n||!r)return;let[i]=await Promise.all([K({shopifyDomain:t,storefrontAccessToken:n},{productId:r,dealBlockId:this.getAttribute(`deal-block-id`)??void 0,country:this.getAttribute(`country`)?.toUpperCase()??void 0,language:this.getAttribute(`language`)?.toUpperCase()??void 0}),X(window)]);i&&e===this.initializeId&&this.renderInnerElement(i)}renderInnerElement(e){let{config:t,dealBlock:n,product:r,otherProducts:i,mediaImages:a,collectionBreaksProducts:o,translations:s}=e;this.innerElement=document.createElement(`kaching-bundles-block`),this.innerElement.setAttribute(`deal-block-id`,n.id),this.innerElement.setAttribute(`config`,JSON.stringify(t)),this.innerElement.setAttribute(`deal-block`,JSON.stringify(n)),this.innerElement.setAttribute(`media-images`,JSON.stringify(a??[])),this.innerElement.setAttribute(`product`,JSON.stringify(r)),this.innerElement.setAttribute(`other-products`,JSON.stringify(i??[])),this.innerElement.setAttribute(`collection-breaks-products`,JSON.stringify(o??[])),this.innerElement.setAttribute(`translations`,JSON.stringify(s??{}));let c=this.getAttribute(`selected-variant-id`);this.innerElement.setAttribute(`current-variant-id`,String(c?c.split(`/`).pop():r.variants[0].id)),this.hasAttribute(`compact`)&&this.innerElement.setAttribute(`compact`,``);let l=this.innerElement,u=()=>{if(this.innerElement!==l)return;let e=l.items();e&&this.dispatchEvent(new CustomEvent(`items-changed`,{detail:{items:e},bubbles:!0}))};this.handleItemsChanged=e=>{e.stopPropagation(),u()};let d=this.handleItemsChanged;l.addEventListener(`kaching-bundles-block-loaded`,()=>{this.innerElement===l&&(l.addEventListener(`items-changed`,d),this.dispatchEvent(new CustomEvent(`loaded`,{bubbles:!0})))},{once:!0}),this.appendChild(this.innerElement)}cleanup(){this.handleItemsChanged&&this.innerElement&&(this.innerElement.removeEventListener(`items-changed`,this.handleItemsChanged),this.handleItemsChanged=null),this.innerElement&&=(this.innerElement.remove(),null)}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`product-id`||e===`country`||e===`language`?this.initialize():e===`selected-variant-id`&&this.innerElement&&n&&this.innerElement.setAttribute(`current-variant-id`,n.includes(`/`)?String(n.split(`/`).pop()):n))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}};return customElements.define(`kaching-bundle-component`,_e),e.fetchKachingBundlesData=K,e})({});
package/dist/index.d.ts CHANGED
@@ -64,6 +64,7 @@ declare interface BaseDealBar {
64
64
  freeGiftsSummary?: FreeGiftsSummary | null;
65
65
  multipleGiftsSelectors?: MultipleGiftsSelector[];
66
66
  upsells: Upsell[];
67
+ sectionsOrder?: DealBarSection[];
67
68
  productPersonalisation: ProductPersonalisation | null;
68
69
  highlights?: Highlights | null;
69
70
  sellingPlanEnabled?: boolean;
@@ -96,7 +97,7 @@ declare type BrandColorKey = (typeof BRAND_COLOR_KEYS)[number];
96
97
 
97
98
  declare type BrandColors = Record<BrandColorKey, string>;
98
99
 
99
- declare interface BundleDealBar extends BaseDealBar, ShowAsSoldOutFeature, RequireVariantSelectionFeature {
100
+ declare interface BundleDealBar extends BaseDealBar, ShowAsSoldOutFeature {
100
101
  dealBarType: DealBarType.Bundle;
101
102
  layout?: "horizontal" | "vertical";
102
103
  quantitySelector: boolean;
@@ -117,7 +118,7 @@ declare interface BundleProduct {
117
118
  hidePrice?: boolean;
118
119
  }
119
120
 
120
- declare interface BxgyDealBar extends BaseDealBar, ShowAsSoldOutFeature, RequireVariantSelectionFeature {
121
+ declare interface BxgyDealBar extends BaseDealBar, ShowAsSoldOutFeature {
121
122
  dealBarType: DealBarType.Bxgy;
122
123
  buyQuantity: number;
123
124
  buyDiscountType?: DiscountType;
@@ -258,6 +259,8 @@ declare type DealBarProgressiveGiftStyle = {
258
259
  lockedMediaImageGID: string | null;
259
260
  };
260
261
 
262
+ declare type DealBarSection = (typeof DEFAULT_DEAL_BAR_SECTIONS_ORDER)[number];
263
+
261
264
  declare enum DealBarType {
262
265
  QuantityBreak = "quantity-break",
263
266
  Bxgy = "bxgy",
@@ -295,6 +298,7 @@ declare type DealBlock = {
295
298
  startTimestamp: number;
296
299
  endTimestamp: number | null;
297
300
  differentVariantsEnabled: boolean;
301
+ requireVariantSelectionEnabled?: boolean;
298
302
  hideVariantPicker: boolean;
299
303
  disableVariantOptionSync?: boolean;
300
304
  hideUnavailableOptions?: boolean;
@@ -402,6 +406,8 @@ declare type DealBlock = {
402
406
  lowStockAlert: LowStockAlert | null;
403
407
  };
404
408
 
409
+ declare const DEFAULT_DEAL_BAR_SECTIONS_ORDER: readonly ["upsells", "freeGifts", "multipleGiftsSelectors"];
410
+
405
411
  declare type DefaultSortOption = "relevance" | "newest-first" | "price-low-to-high" | "price-high-to-low";
406
412
 
407
413
  declare type DiscountType = "default" | "percentage" | "amount" | "specific";
@@ -429,6 +435,7 @@ declare type FreeGift = {
429
435
  text: string;
430
436
  imageSize: number;
431
437
  quantity: number;
438
+ matchQuantityWithDealBar?: boolean;
432
439
  showPrice: boolean;
433
440
  includeInCompareAt?: boolean;
434
441
  applyOnlyForSubscriptions: boolean;
@@ -462,6 +469,7 @@ declare interface GlobalConfig {
462
469
  ignoreUnitPrice: boolean;
463
470
  requireCustomerLogin: boolean;
464
471
  abTestsRunning: boolean;
472
+ cartKachingSessionId?: string | null;
465
473
  webPixel: boolean;
466
474
  b2bCustomer: boolean;
467
475
  isLoggedIn: boolean;
@@ -555,6 +563,7 @@ declare interface GlobalConfig {
555
563
  "system.deal_page_line_quantity"?: string;
556
564
  "system.deal_page_view_box"?: string;
557
565
  "system.deal_page_close"?: string;
566
+ "system.deal_page_view_full_details"?: string;
558
567
  "system.deal_page_back_to_products"?: string;
559
568
  "system.deal_page_items_still_to_add_one"?: string;
560
569
  "system.deal_page_items_still_to_add_other"?: string;
@@ -571,6 +580,53 @@ declare interface GlobalConfig {
571
580
  "system.deal_page_items_range"?: string;
572
581
  "system.deal_page_tip_box_size"?: string;
573
582
  "system.deal_page_about_this_price"?: string;
583
+ "system.deal_page_rating"?: string;
584
+ "system.deal_page_rating_count_one"?: string;
585
+ "system.deal_page_rating_count_other"?: string;
586
+ "system.deal_page_rating_count_few"?: string;
587
+ "system.deal_page_rating_count_many"?: string;
588
+ "system.deal_page_gift_badge_shipping"?: string;
589
+ "system.deal_page_gift_badge_one"?: string;
590
+ "system.deal_page_gift_badge_other"?: string;
591
+ "system.deal_page_gift_badge_few"?: string;
592
+ "system.deal_page_gift_badge_many"?: string;
593
+ "system.deal_page_gifts_title"?: string;
594
+ "system.deal_page_your_gifts_title"?: string;
595
+ "system.deal_page_free_shipping"?: string;
596
+ "system.deal_page_gift_unlocks_at_one"?: string;
597
+ "system.deal_page_gift_unlocks_at_other"?: string;
598
+ "system.deal_page_gift_unlocks_at_few"?: string;
599
+ "system.deal_page_gift_unlocks_at_many"?: string;
600
+ "system.deal_page_choose_option"?: string;
601
+ "system.deal_page_change"?: string;
602
+ "system.deal_page_choose_gift_option"?: string;
603
+ "system.deal_page_your_gifts_row_one"?: string;
604
+ "system.deal_page_your_gifts_row_other"?: string;
605
+ "system.deal_page_your_gifts_row_few"?: string;
606
+ "system.deal_page_your_gifts_row_many"?: string;
607
+ "system.deal_page_free"?: string;
608
+ "system.deal_page_gift_count_one"?: string;
609
+ "system.deal_page_gift_count_other"?: string;
610
+ "system.deal_page_gift_count_few"?: string;
611
+ "system.deal_page_gift_count_many"?: string;
612
+ "system.deal_page_percentage_gifts_unlocked"?: string;
613
+ "system.deal_page_box_of_gifts"?: string;
614
+ "system.deal_page_gifts_unlocked"?: string;
615
+ "system.deal_page_gift_phrase_shipping"?: string;
616
+ "system.deal_page_gift_phrase_one"?: string;
617
+ "system.deal_page_gift_phrase_other"?: string;
618
+ "system.deal_page_gift_phrase_few"?: string;
619
+ "system.deal_page_gift_phrase_many"?: string;
620
+ "system.deal_page_nudge_start_offer_one"?: string;
621
+ "system.deal_page_nudge_start_offer_other"?: string;
622
+ "system.deal_page_nudge_start_offer_few"?: string;
623
+ "system.deal_page_nudge_start_offer_many"?: string;
624
+ "system.deal_page_nudge_more_offer_one"?: string;
625
+ "system.deal_page_nudge_more_offer_other"?: string;
626
+ "system.deal_page_nudge_more_offer_few"?: string;
627
+ "system.deal_page_nudge_more_offer_many"?: string;
628
+ "system.deal_page_offer_with_gifts"?: string;
629
+ "system.deal_page_promotion_percentage"?: string;
574
630
  };
575
631
  customSelectors: {
576
632
  quantity: string | null;
@@ -581,16 +637,16 @@ declare interface GlobalConfig {
581
637
  label?: string | null;
582
638
  };
583
639
  featureFlags: {
584
- accelerated_checkout_additional_items?: boolean;
585
640
  atc_total_price?: boolean;
586
641
  cart_change_response_rewrite?: boolean;
587
642
  cart_interceptor_dedupe_disabled?: boolean;
588
643
  debug_cart_add?: boolean;
589
644
  disable_nested_cart_lines?: boolean;
590
- early_fetch_override?: boolean;
645
+ early_xhr_wrapper?: boolean;
591
646
  hide_missing_variants?: boolean;
592
647
  initialize_with_form_variant?: boolean;
593
648
  intercept_cart_request?: boolean;
649
+ klaviyo_integration?: boolean;
594
650
  legacy_saved_percentage?: boolean;
595
651
  low_priority_scripts?: boolean;
596
652
  native_swatches_disabled?: boolean;
@@ -610,6 +666,7 @@ declare interface GlobalConfig {
610
666
  storefront_metaobjects?: boolean;
611
667
  pos_extension?: boolean;
612
668
  variant_images?: boolean;
669
+ widget_scroll_guard?: boolean;
613
670
  };
614
671
  shopCustomStyles: string;
615
672
  brandColors?: BrandColors | null;
@@ -687,7 +744,7 @@ declare interface MixAndMatchChooseProductModal {
687
744
  buttonText: string;
688
745
  }
689
746
 
690
- declare interface MixAndMatchDealBar extends BaseDealBar, ShowAsSoldOutFeature, RequireVariantSelectionFeature {
747
+ declare interface MixAndMatchDealBar extends BaseDealBar, ShowAsSoldOutFeature {
691
748
  dealBarType: DealBarType.MixAndMatch;
692
749
  discountType: DiscountType;
693
750
  discountValue: string | number;
@@ -753,6 +810,8 @@ declare interface Product {
753
810
  text3: string | null;
754
811
  text4: string | null;
755
812
  };
813
+ rating?: ProductRating | null;
814
+ subtitle?: string | null;
756
815
  }
757
816
 
758
817
  declare interface ProductOption {
@@ -785,6 +844,11 @@ declare type ProductPersonalisation = {
785
844
  required: boolean;
786
845
  };
787
846
 
847
+ declare interface ProductRating {
848
+ value: number;
849
+ count: number | null;
850
+ }
851
+
788
852
  declare type ProgressiveGift = {
789
853
  id: string;
790
854
  giftType: "product" | "shipping";
@@ -793,6 +857,8 @@ declare type ProgressiveGift = {
793
857
  mediaImageGID: string | null;
794
858
  unlockAtBar: number;
795
859
  unlockAtBarOnly?: boolean;
860
+ unlockAtScope?: "and-higher" | "only" | "custom";
861
+ unlockDealBarIds?: string[];
796
862
  label: string;
797
863
  labelCrossedOut: string;
798
864
  title: string;
@@ -844,7 +910,7 @@ declare type ProgressiveGiftsStyle = {
844
910
  lockedMediaImageGID: string | null;
845
911
  };
846
912
 
847
- declare interface QuantityBreakDealBar extends BaseDealBar, ShowAsSoldOutFeature, RequireVariantSelectionFeature {
913
+ declare interface QuantityBreakDealBar extends BaseDealBar, ShowAsSoldOutFeature {
848
914
  dealBarType?: DealBarType.QuantityBreak;
849
915
  quantity: number | string;
850
916
  discountType: DiscountType;
@@ -863,10 +929,6 @@ declare type RequireItemSelectionAlert = {
863
929
  backgroundColor: Color;
864
930
  };
865
931
 
866
- declare interface RequireVariantSelectionFeature {
867
- requireVariantSelectionEnabled?: boolean;
868
- }
869
-
870
932
  declare type SavingsSummary = {
871
933
  title: string;
872
934
  backgroundColor: Color;
@@ -1039,6 +1101,7 @@ declare type Upsell = {
1039
1101
  quantity: number;
1040
1102
  preselected: boolean;
1041
1103
  visibleOnlyWhenDealBarSelected: boolean;
1104
+ matchQuantityWithDealBar?: boolean;
1042
1105
  subscriptionEnabled?: boolean;
1043
1106
  subscriptionType?: "deal" | "always";
1044
1107
  };