@kachingappz/bundles-js 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -157,4 +157,42 @@ useEffect(() => {
157
157
  }
158
158
  ```
159
159
 
160
- `fetchKachingBundlesData` also accepts a Hydrogen `context.storefront`, a `@shopify/hydrogen-react` storefront client or a `@shopify/storefront-api-client` client in place of the credentials. Pass `preview={{ price, color, cornerRadius }}` instead of `data` to render placeholder data, and `targetWindow` to render inside an iframe. The [`@kachingappz/bundles-react` README](https://www.npmjs.com/package/@kachingappz/bundles-react) has Hydrogen and iframe examples.
160
+ `fetchKachingBundlesData` also accepts a Hydrogen `context.storefront`, a Hydrogen 2026-10 `createStorefrontClient` client, a `@shopify/hydrogen-react` storefront client or a `@shopify/storefront-api-client` client in place of the credentials.
161
+
162
+ On Hydrogen 2026-10, pass the Storefront client that your app puts in the router context, and add the lines with Shopify's standard `updateCart` action, which the Hydrogen cart store listens to:
163
+
164
+ ```jsx
165
+ import { storefrontClientContext } from "~/lib/storefront"
166
+
167
+ export const loader = async ({ context, params }) => {
168
+ const storefrontClient = context.get(storefrontClientContext)
169
+ const product = await fetchProduct(storefrontClient, params.handle)
170
+
171
+ return {
172
+ product,
173
+ kachingBundlesData: await fetchKachingBundlesData(storefrontClient, {
174
+ productId: product.id,
175
+ }),
176
+ }
177
+ }
178
+
179
+ export default function Product({ loaderData }) {
180
+ const [lines, setLines] = useState([])
181
+
182
+ return (
183
+ <>
184
+ <KachingBundle
185
+ data={loaderData.kachingBundlesData}
186
+ onLinesChange={setLines}
187
+ />
188
+ <button onClick={() => window.Shopify.actions.updateCart({ lines })}>
189
+ Add to cart
190
+ </button>
191
+ </>
192
+ )
193
+ }
194
+ ```
195
+
196
+ `lines` already has the `updateCart` line shape (`merchandiseId`, `quantity`, `attributes`, optional `sellingPlanId`).
197
+
198
+ Pass `preview={{ price, color, cornerRadius }}` instead of `data` to render placeholder data, and `targetWindow` to render inside an iframe.
@@ -1,4 +1,4 @@
1
- var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=>l.blockVisibility==="selected-products");for(const l of n)l.selectedProductIds.map(Number).includes(e.id)&&s.push(l);const i=t.filter(l=>l.blockVisibility==="selected-collections");for(const l of i)e.collectionIds.some(m=>l.selectedCollectionIds.map(Number).includes(m))&&s.push(l);const r=t.filter(l=>l.blockVisibility==="excluded-products");for(const l of r)!l.excludedProductIds.map(Number).includes(e.id)&&!(l.excludedCollectionIds||[]).some(m=>e.collectionIds.includes(m))&&s.push(l);const o=t.filter(l=>l.blockVisibility==="all-products");for(const l of o)s.push(l);return s},F=(t,{language:e,country:s})=>{var y,h;const n=R(e,s),i=new Intl.NumberFormat(n,{style:"currency",currency:t,currencyDisplay:"narrowSymbol"}).formatToParts(123456789e-2),r=(y=i.find(f=>f.type==="decimal"))==null?void 0:y.value,o=z((h=i.find(f=>f.type==="group"))==null?void 0:h.value),l=i.some(f=>f.type==="fraction"),m=Q(o,r,l),d=i.findIndex(G),u=i.findLastIndex(G);return[...i.slice(0,d).map(N),m,...i.slice(u+1).map(N)].join("")},N=t=>x(t.value),x=t=>t.replace(/\s/g," "),G=t=>t.type==="integer"||t.type==="group"||t.type==="decimal"||t.type==="fraction",R=(t,e)=>t&&e?`${t}-${e.toUpperCase()}`:t||(e?e.toUpperCase():"en"),z=t=>t===void 0?void 0:x(t).replace(/’/g,"'"),Q=(t,e,s)=>e===","&&t==="."?s?"{{amount_with_comma_separator}}":"{{amount_no_decimals_with_comma_separator}}":e===","&&t===" "?s?"{{amount_with_space_separator}}":"{{amount_no_decimals_with_space_separator}}":e==="."&&t===" "?"{{amount_with_period_and_space_separator}}":e==="."&&t==="'"?"{{amount_with_apostrophe_separator}}":s?"{{amount}}":"{{amount_no_decimals}}",k=({country:t,language:e})=>{const s=[];return t&&s.push(`country: ${t}`),e&&s.push(`language: ${e}`),s.length>0?`@inContext(${s.join(", ")})`:""},J=async(t,{useExternalMetafieldNamespace:e,useMetaobjects:s})=>s?X(t):H(t),H=async(t,e)=>{var n;const s=(n=(await t.query(`
1
+ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],l=t.filter(i=>i.blockVisibility==="selected-products");for(const i of l)i.selectedProductIds.map(Number).includes(e.id)&&s.push(i);const n=t.filter(i=>i.blockVisibility==="selected-collections");for(const i of n)e.collectionIds.some(m=>i.selectedCollectionIds.map(Number).includes(m))&&s.push(i);const r=t.filter(i=>i.blockVisibility==="excluded-products");for(const i of r)!i.excludedProductIds.map(Number).includes(e.id)&&!(i.excludedCollectionIds||[]).some(m=>e.collectionIds.includes(m))&&s.push(i);const o=t.filter(i=>i.blockVisibility==="all-products");for(const i of o)s.push(i);return s},F=(t,{language:e,country:s})=>{var y,h;const l=R(e,s),n=new Intl.NumberFormat(l,{style:"currency",currency:t,currencyDisplay:"narrowSymbol"}).formatToParts(123456789e-2),r=(y=n.find(f=>f.type==="decimal"))==null?void 0:y.value,o=z((h=n.find(f=>f.type==="group"))==null?void 0:h.value),i=n.some(f=>f.type==="fraction"),m=Q(o,r,i),d=n.findIndex(G),u=n.findLastIndex(G);return[...n.slice(0,d).map(N),m,...n.slice(u+1).map(N)].join("")},N=t=>x(t.value),x=t=>t.replace(/\s/g," "),G=t=>t.type==="integer"||t.type==="group"||t.type==="decimal"||t.type==="fraction",R=(t,e)=>t&&e?`${t}-${e.toUpperCase()}`:t||(e?e.toUpperCase():"en"),z=t=>t===void 0?void 0:x(t).replace(/’/g,"'"),Q=(t,e,s)=>e===","&&t==="."?s?"{{amount_with_comma_separator}}":"{{amount_no_decimals_with_comma_separator}}":e===","&&t===" "?s?"{{amount_with_space_separator}}":"{{amount_no_decimals_with_space_separator}}":e==="."&&t===" "?"{{amount_with_period_and_space_separator}}":e==="."&&t==="'"?"{{amount_with_apostrophe_separator}}":s?"{{amount}}":"{{amount_no_decimals}}",k=({country:t,language:e})=>{const s=[];return t&&s.push(`country: ${t}`),e&&s.push(`language: ${e}`),s.length>0?`@inContext(${s.join(", ")})`:""},J=async(t,{useExternalMetafieldNamespace:e,useMetaobjects:s})=>s?X(t):H(t),H=async(t,e)=>{var l;const s=(l=(await t.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 V=(t,e)=>{const s=[],n=t.filter(l=
6
6
  }
7
7
  }
8
8
  }
9
- `,{variables:{metafieldNamespace:"app--2935586817--kaching_bundles"}})).shop.metafield)==null?void 0:n.value;return s?JSON.parse(s):[]},X=async(t,e)=>{const s="app--2935586817--deal_block",n=[];let i=null;for(;;){const r=await t.query(`
9
+ `,{variables:{metafieldNamespace:"app--2935586817--kaching_bundles"}})).shop.metafield)==null?void 0:l.value;return s?JSON.parse(s):[]},X=async(t,e)=>{const s="app--2935586817--deal_block",l=[];let n=null;for(;;){const r=await t.query(`
10
10
  query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
11
11
  metaobjects(type: $type, first: 250, after: $cursor) {
12
12
  nodes {
@@ -21,7 +21,7 @@ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=
21
21
  }
22
22
  }
23
23
  }
24
- `,{variables:{type:s,cursor:i}});for(const o of r.metaobjects.nodes){const l=o.fields.find(m=>m.key==="settings");l!=null&&l.value&&n.push(JSON.parse(l.value))}if(!r.metaobjects.pageInfo.hasNextPage)break;i=r.metaobjects.pageInfo.endCursor}return n},B=async(t,{country:e,language:s,blockVisibility:n,excludedProductGIDs:i,selectedProductGIDs:r,selectedCollectionGIDs:o,limit:l=1e3})=>{switch(n){case"selected-products":return r.slice(0,l);case"all-products":case"excluded-products":{const m=k({country:e,language:s});let d=[],u=null;for(;d.length<l;){const y=Math.min(l-d.length,250),h=await t.query(`
24
+ `,{variables:{type:s,cursor:n}});for(const o of r.metaobjects.nodes){const i=o.fields.find(m=>m.key==="settings");i!=null&&i.value&&l.push(JSON.parse(i.value))}if(!r.metaobjects.pageInfo.hasNextPage)break;n=r.metaobjects.pageInfo.endCursor}return l},B=async(t,{country:e,language:s,blockVisibility:l,excludedProductGIDs:n,selectedProductGIDs:r,selectedCollectionGIDs:o,limit:i=1e3})=>{switch(l){case"selected-products":return r.slice(0,i);case"all-products":case"excluded-products":{const m=k({country:e,language:s});let d=[],u=null;for(;d.length<i;){const y=Math.min(i-d.length,250),h=await t.query(`
25
25
  query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
26
26
  products(first: $limit, after: $cursor) {
27
27
  nodes {
@@ -33,7 +33,7 @@ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=
33
33
  }
34
34
  }
35
35
  }
36
- `,{variables:{limit:y,cursor:u}});if(d.push(...h.products.nodes.map(f=>f.id)),!h.products.pageInfo.hasNextPage)break;u=h.products.pageInfo.endCursor}if(n==="excluded-products"){const y=new Set(i);d=d.filter(h=>!y.has(h))}return d}case"selected-collections":{const m=k({country:e,language:s}),d=(await t.query(`
36
+ `,{variables:{limit:y,cursor:u}});if(d.push(...h.products.nodes.map(f=>f.id)),!h.products.pageInfo.hasNextPage)break;u=h.products.pageInfo.endCursor}if(l==="excluded-products"){const y=new Set(n);d=d.filter(h=>!y.has(h))}return d}case"selected-collections":{const m=k({country:e,language:s}),d=(await t.query(`
37
37
  query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
38
38
  nodes(ids: $collectionGIDs) {
39
39
  ... on Collection {
@@ -45,7 +45,7 @@ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=
45
45
  }
46
46
  }
47
47
  }
48
- `,{variables:{collectionGIDs:o,limit:Math.min(l,250)}})).nodes.filter(u=>u!==null).flatMap(u=>u.products.nodes.map(y=>y.id));return Array.from(new Set(d)).slice(0,l)}}},T=`
48
+ `,{variables:{collectionGIDs:o,limit:Math.min(i,250)}})).nodes.filter(u=>u!==null).flatMap(u=>u.products.nodes.map(y=>y.id));return Array.from(new Set(d)).slice(0,i)}}},T=`
49
49
  id
50
50
  availableForSale
51
51
  price {
@@ -88,7 +88,7 @@ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=
88
88
  }
89
89
  }
90
90
  quantityAvailable @include(if: $includeAvailableQuantity)
91
- `,D=async(t,{country:e,language:s,productIds:n,includeSellingPlans:i=!0,includeAvailableQuantity:r=!0,useExternalMetafieldNamespace:o=!1,batchSize:l=250,onBatchError:m})=>{if(!n.length)return[];const d=n.map(c=>typeof c=="string"&&c.startsWith("gid://")?c:`gid://shopify/Product/${c}`),u=k({country:e,language:s}),y=`
91
+ `,D=async(t,{country:e,language:s,productIds:l,includeSellingPlans:n=!0,includeAvailableQuantity:r=!0,useExternalMetafieldNamespace:o=!1,batchSize:i=250,onBatchError:m})=>{if(!l.length)return[];const d=l.map(c=>typeof c=="string"&&c.startsWith("gid://")?c:`gid://shopify/Product/${c}`),u=k({country:e,language:s}),y=`
92
92
  query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${u} {
93
93
  shop {
94
94
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
@@ -175,8 +175,8 @@ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=
175
175
  }
176
176
  }
177
177
  }
178
- `,h=o?"app--2935586817--kaching_bundles":"$app:kaching_bundles",f=[],v=Math.min(l,250);for(let c=0;c<d.length;c+=v)f.push(d.slice(c,c+v));let a=1;const p=async c=>{const b=await t.query(y,{variables:{productGIDs:c,includeSellingPlans:i,includeAvailableQuantity:r,metafieldNamespace:h}});return b.shop.currencyRateConstant&&(a=JSON.parse(b.shop.currencyRateConstant.value).amount/1e6),b};let g;if(m){const c=await Promise.allSettled(f.map(p));for(const b of c)b.status==="rejected"&&m(b.reason instanceof Error?b.reason:new Error(String(b.reason)));g=c.filter(b=>b.status==="fulfilled").flatMap(b=>b.value.nodes)}else g=(await Promise.all(f.map(p))).flatMap(c=>c.nodes);const _=g.filter(c=>c!=null);if(m){const c=await Promise.allSettled(_.map(async I=>{const P=await M(t,I,{includeSellingPlans:i,includeAvailableQuantity:r},u);return q(P,t.shopifyDomain,a)})),b=[];for(const I of c)I.status==="fulfilled"?b.push(I.value):m(I.reason instanceof Error?I.reason:new Error(String(I.reason)));return b}return(await Promise.all(_.map(c=>M(t,c,{includeSellingPlans:i,includeAvailableQuantity:r},u)))).map(c=>q(c,t.shopifyDomain,a))},M=async(t,e,s,n="")=>{if(e.variants.nodes.length<250)return e;const i=new Set,r=[],o=[],l=async m=>{let d=!0,u=null;for(;d;){const y=await t.query(`
179
- query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${n} {
178
+ `,h=o?"app--2935586817--kaching_bundles":"$app:kaching_bundles",f=[],v=Math.min(i,250);for(let c=0;c<d.length;c+=v)f.push(d.slice(c,c+v));let a=1;const p=async c=>{const b=await t.query(y,{variables:{productGIDs:c,includeSellingPlans:n,includeAvailableQuantity:r,metafieldNamespace:h}});return b.shop.currencyRateConstant&&(a=JSON.parse(b.shop.currencyRateConstant.value).amount/1e6),b};let g;if(m){const c=await Promise.allSettled(f.map(p));for(const b of c)b.status==="rejected"&&m(b.reason instanceof Error?b.reason:new Error(String(b.reason)));g=c.filter(b=>b.status==="fulfilled").flatMap(b=>b.value.nodes)}else g=(await Promise.all(f.map(p))).flatMap(c=>c.nodes);const _=g.filter(c=>c!=null);if(m){const c=await Promise.allSettled(_.map(async I=>{const P=await M(t,I,{includeSellingPlans:n,includeAvailableQuantity:r},u);return q(P,t.shopifyDomain,a)})),b=[];for(const I of c)I.status==="fulfilled"?b.push(I.value):m(I.reason instanceof Error?I.reason:new Error(String(I.reason)));return b}return(await Promise.all(_.map(c=>M(t,c,{includeSellingPlans:n,includeAvailableQuantity:r},u)))).map(c=>q(c,t.shopifyDomain,a))},M=async(t,e,s,l="")=>{if(e.variants.nodes.length<250)return e;const n=new Set,r=[],o=[],i=async m=>{let d=!0,u=null;for(;d;){const y=await t.query(`
179
+ query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${l} {
180
180
  product(id: $productGID) {
181
181
  variants(first: 250, after: $cursor, reverse: $reverse) {
182
182
  nodes {
@@ -189,7 +189,7 @@ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=
189
189
  }
190
190
  }
191
191
  }
192
- `,{variables:{productGID:e.id,cursor:u,reverse:m,...s}}),{nodes:h,pageInfo:f}=y.product.variants;for(const v of h){if(i.has(v.id)){d=!1;break}i.add(v.id),m?o.push(v):r.push(v)}f.hasNextPage||(d=!1),u=f.endCursor}};return await Promise.all([l(!1),l(!0)]),e.variants.nodes=[...r,...o.reverse()],e},q=(t,e,s)=>{var d,u,y,h,f,v;const n=t.variants.nodes.map(({unitPriceMeasurement:a,...p})=>{var g,_;return{id:Number(p.id.split("/").pop()),availableForSale:p.availableForSale,price:Math.round(Number(p.price.amount)*100),compareAtPrice:p.compareAtPrice?Math.round(Number(p.compareAtPrice.amount)*100):null,options:p.selectedOptions.map(c=>c.value),imageId:p.image?Number(p.image.id.split("/").pop()):null,image:((g=p.image)==null?void 0:g.url)||null,sellingPlans:((_=p.sellingPlanAllocations)==null?void 0:_.nodes.map(c=>({id:Number(c.sellingPlan.id.split("/").pop()),price:c.priceAdjustments.length>0?Math.round(Number(c.priceAdjustments[0].price.amount)*100):Math.round(Number(p.price.amount)*100),compareAtPrice:c.priceAdjustments.length>0?Math.round(Number(c.priceAdjustments[0].compareAtPrice.amount)*100):Math.round(Number(p.price.amount)*100),perDeliveryPrice:c.priceAdjustments.length>0?Math.round(Number(c.priceAdjustments[0].perDeliveryPrice.amount)*100):Math.round(Number(p.price.amount)*100)})))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:p.quantityAvailable??null,unitPriceMeasurement:a!=null&&a.quantityUnit&&(a!=null&&a.referenceUnit)?{quantityValue:a.quantityValue,quantityUnit:a.quantityUnit.toLowerCase(),referenceValue:a.referenceValue,referenceUnit:a.referenceUnit.toLowerCase()}:null}}),i=t.options.map((a,p)=>{const g=a.optionValues.map(_=>{var c,b,I,P;return{id:Number(_.id.split("/").pop()),defaultName:_.name,name:_.name,swatch:{color:((c=_.swatch)==null?void 0:c.color)||null,image:((P=(I=(b=_.swatch)==null?void 0:b.image)==null?void 0:I.previewImage)==null?void 0:P.url)||null}}});return{defaultName:a.name,name:a.name,position:p+1,optionValues:K(g,p,n)}}),r=a=>{const p=a.priceAdjustments[0];if(!p)return null;const g=p.adjustmentValue;switch(g.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:g.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"fixed_amount",value:o(g.adjustmentAmount.amount)};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:o(g.price.amount)};default:throw new Error(`Unknown price adjustment type: ${g.__typename}`)}},o=a=>s===1?Number(a)*100:Math.round(Number(a)*100*s),l=((d=t.sellingPlanGroups)==null?void 0:d.nodes.flatMap(a=>a.sellingPlans.nodes.map(p=>({id:Number(p.id.split("/").pop()),name:p.name,priceAdjustment:r(p)}))))||[],m=t.variants.nodes.some(a=>a.requiresComponents);return{id:Number(t.id.split("/").pop()),handle:t.handle,url:t.onlineStoreUrl||`https://${e}/products/${t.handle}`,availableForSale:t.availableForSale,createdAt:t.createdAt,title:t.title,image:((u=t.featuredImage)==null?void 0:u.url)||null,collectionIds:t.collections.nodes.map(a=>Number(a.id.split("/").pop())),options:i,selectedVariantId:Number(t.variants.nodes[0].id.split("/").pop()),variants:n,requiresSellingPlan:t.requiresSellingPlan,sellingPlans:l,isNativeBundle:m,metafields:{text:((y=t.metafield)==null?void 0:y.value)||null,text2:((h=t.metafield2)==null?void 0:h.value)||null,text3:((f=t.metafield3)==null?void 0:f.value)||null,text4:((v=t.metafield4)==null?void 0:v.value)||null}}},K=(t,e,s)=>t.filter(n=>s.filter(i=>i.options[e]===n.name).length>0),O="app--2935586817",W=async(t,{language:e,country:s,useExternalMetafieldNamespace:n})=>{const i=`${O}--kaching_bundles`,r=O,o=k({country:s}),{localization:{country:{currency:{isoCode:l}}},shop:{moneyFormat:m,paymentSettings:{currencyCode:d},currencyRateConstant:u,primaryDomain:y,settingsMetafield:h}}=await t.query(`
192
+ `,{variables:{productGID:e.id,cursor:u,reverse:m,...s}}),{nodes:h,pageInfo:f}=y.product.variants;for(const v of h){if(n.has(v.id)){d=!1;break}n.add(v.id),m?o.push(v):r.push(v)}f.hasNextPage||(d=!1),u=f.endCursor}};return await Promise.all([i(!1),i(!0)]),e.variants.nodes=[...r,...o.reverse()],e},q=(t,e,s)=>{var d,u,y,h,f,v;const l=t.variants.nodes.map(({unitPriceMeasurement:a,...p})=>{var g,_;return{id:Number(p.id.split("/").pop()),availableForSale:p.availableForSale,price:Math.round(Number(p.price.amount)*100),compareAtPrice:p.compareAtPrice?Math.round(Number(p.compareAtPrice.amount)*100):null,options:p.selectedOptions.map(c=>c.value),imageId:p.image?Number(p.image.id.split("/").pop()):null,image:((g=p.image)==null?void 0:g.url)||null,sellingPlans:((_=p.sellingPlanAllocations)==null?void 0:_.nodes.map(c=>({id:Number(c.sellingPlan.id.split("/").pop()),price:c.priceAdjustments.length>0?Math.round(Number(c.priceAdjustments[0].price.amount)*100):Math.round(Number(p.price.amount)*100),compareAtPrice:c.priceAdjustments.length>0?Math.round(Number(c.priceAdjustments[0].compareAtPrice.amount)*100):Math.round(Number(p.price.amount)*100),perDeliveryPrice:c.priceAdjustments.length>0?Math.round(Number(c.priceAdjustments[0].perDeliveryPrice.amount)*100):Math.round(Number(p.price.amount)*100)})))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:p.quantityAvailable??null,unitPriceMeasurement:a!=null&&a.quantityUnit&&(a!=null&&a.referenceUnit)?{quantityValue:a.quantityValue,quantityUnit:a.quantityUnit.toLowerCase(),referenceValue:a.referenceValue,referenceUnit:a.referenceUnit.toLowerCase()}:null}}),n=t.options.map((a,p)=>{const g=a.optionValues.map(_=>{var c,b,I,P;return{id:Number(_.id.split("/").pop()),defaultName:_.name,name:_.name,swatch:{color:((c=_.swatch)==null?void 0:c.color)||null,image:((P=(I=(b=_.swatch)==null?void 0:b.image)==null?void 0:I.previewImage)==null?void 0:P.url)||null}}});return{defaultName:a.name,name:a.name,position:p+1,optionValues:K(g,p,l)}}),r=a=>{const p=a.priceAdjustments[0];if(!p)return null;const g=p.adjustmentValue;switch(g.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:g.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"fixed_amount",value:o(g.adjustmentAmount.amount)};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:o(g.price.amount)};default:throw new Error(`Unknown price adjustment type: ${g.__typename}`)}},o=a=>s===1?Number(a)*100:Math.round(Number(a)*100*s),i=((d=t.sellingPlanGroups)==null?void 0:d.nodes.flatMap(a=>a.sellingPlans.nodes.map(p=>({id:Number(p.id.split("/").pop()),name:p.name,priceAdjustment:r(p)}))))||[],m=t.variants.nodes.some(a=>a.requiresComponents);return{id:Number(t.id.split("/").pop()),handle:t.handle,url:t.onlineStoreUrl||`https://${e}/products/${t.handle}`,availableForSale:t.availableForSale,createdAt:t.createdAt,title:t.title,image:((u=t.featuredImage)==null?void 0:u.url)||null,collectionIds:t.collections.nodes.map(a=>Number(a.id.split("/").pop())),options:n,selectedVariantId:Number(t.variants.nodes[0].id.split("/").pop()),variants:l,requiresSellingPlan:t.requiresSellingPlan,sellingPlans:i,isNativeBundle:m,metafields:{text:((y=t.metafield)==null?void 0:y.value)||null,text2:((h=t.metafield2)==null?void 0:h.value)||null,text3:((f=t.metafield3)==null?void 0:f.value)||null,text4:((v=t.metafield4)==null?void 0:v.value)||null}}},K=(t,e,s)=>t.filter(l=>s.filter(n=>n.options[e]===l.name).length>0),O="app--2935586817",W=async(t,{language:e,country:s,useExternalMetafieldNamespace:l})=>{const n=`${O}--kaching_bundles`,r=O,o=k({country:s}),{localization:{country:{currency:{isoCode:i}}},shop:{moneyFormat:m,paymentSettings:{currencyCode:d},currencyRateConstant:u,primaryDomain:y,settingsMetafield:h}}=await t.query(`
193
193
  query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
194
194
  localization {
195
195
  country {
@@ -214,7 +214,7 @@ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=
214
214
  }
215
215
  }
216
216
  }
217
- `,{variables:{metafieldNamespace:i,settingsNamespace:r}}),f=l===d?m:F(l,{language:e,country:s}),v=u?Y(u.value):1,a=h?JSON.parse(h.value):null,p=(a==null?void 0:a.feature_flags)??{},g=(a==null?void 0:a.custom_selectors)??{};return{shopifyDomain:y.host,moneyFormat:f,locale:(e==null?void 0:e.toLowerCase())||"en",liquidLocale:(e==null?void 0:e.toLowerCase())||"en",country:s??"US",currencyRate:v,marketId:0,productId:null,storefrontAccessToken:(a==null?void 0:a.storefront_access_token)??null,includeSellingPlans:(a==null?void 0:a.include_selling_plans)??!1,includeAvailableQuantity:(a==null?void 0:a.include_available_quantity)??!1,customApiHost:(a==null?void 0:a.custom_api_host)??null,keepQuantityInput:(a==null?void 0:a.keep_quantity_input)??!1,ignoreDeselect:(a==null?void 0:a.ignore_deselect)??!1,ignoreUnitPrice:(a==null?void 0:a.ignore_unit_price)??!1,requireCustomerLogin:(a==null?void 0:a.require_customer_login)??!1,abTestsRunning:(a==null?void 0:a.ab_tests_running)??!1,webPixel:(a==null?void 0:a.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:g.quantity??null,addToCartButton:g.add_to_cart_button??null,variantPicker:g.variant_picker??null,price:g.price??null,priceCompare:g.price_compare??null},shopCustomStyles:(a==null?void 0:a.shop_custom_styles)??"",featureFlags:p,brandColors:(a==null?void 0:a.brand_colors)??null}},Y=t=>JSON.parse(t).amount/1e6,Z=async(t,e,s=200)=>(e=e.filter(Boolean).filter(n=>!n.startsWith("placeholder")),e.length===0?[]:(await t.query(`
217
+ `,{variables:{metafieldNamespace:n,settingsNamespace:r}}),f=i===d?m:F(i,{language:e,country:s}),v=u?Y(u.value):1,a=h?JSON.parse(h.value):null,p=(a==null?void 0:a.feature_flags)??{},g=(a==null?void 0:a.custom_selectors)??{};return{shopifyDomain:y.host,moneyFormat:f,locale:(e==null?void 0:e.toLowerCase())||"en",liquidLocale:(e==null?void 0:e.toLowerCase())||"en",country:s??"US",currencyRate:v,marketId:0,productId:null,storefrontAccessToken:(a==null?void 0:a.storefront_access_token)??null,includeSellingPlans:(a==null?void 0:a.include_selling_plans)??!1,includeAvailableQuantity:(a==null?void 0:a.include_available_quantity)??!1,customApiHost:(a==null?void 0:a.custom_api_host)??null,keepQuantityInput:(a==null?void 0:a.keep_quantity_input)??!1,ignoreDeselect:(a==null?void 0:a.ignore_deselect)??!1,ignoreUnitPrice:(a==null?void 0:a.ignore_unit_price)??!1,requireCustomerLogin:(a==null?void 0:a.require_customer_login)??!1,abTestsRunning:(a==null?void 0:a.ab_tests_running)??!1,webPixel:(a==null?void 0:a.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:g.quantity??null,addToCartButton:g.add_to_cart_button??null,variantPicker:g.variant_picker??null,price:g.price??null,priceCompare:g.price_compare??null},shopCustomStyles:(a==null?void 0:a.shop_custom_styles)??"",featureFlags:p,brandColors:(a==null?void 0:a.brand_colors)??null}},Y=t=>JSON.parse(t).amount/1e6,Z=async(t,e,s=200)=>(e=e.filter(Boolean).filter(l=>!l.startsWith("placeholder")),e.length===0?[]:(await t.query(`
218
218
  query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
219
219
  nodes(ids: $mediaImageIds) {
220
220
  ... on MediaImage {
@@ -225,4 +225,5 @@ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=
225
225
  }
226
226
  }
227
227
  }
228
- `,{variables:{mediaImageIds:e,size:s}})).nodes.filter(Boolean).map(n=>({gid:n.id,url:n.image.url})));var S=(t=>(t.QuantityBreak="quantity-break",t.Bxgy="bxgy",t.Bundle="bundle",t.MixAndMatch="mix-and-match",t.Sku="sku",t))(S||{});const ee=t=>[...te(t),...se(t),...ae(t),...ne(t),...le(t),...ie(t),...re(t),...oe(t),...ce(t),...ue(t),...de(t),...me(t),...pe(t)].filter(e=>e!=null&&!e.includes("placeholder")),te=t=>t.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),se=t=>t.dealBars.flatMap(e=>e.dealBarType===S.Bundle?e.bundleProducts.map(s=>s.mediaImageGID):[]).filter(e=>e!=null),ae=t=>t.dealBars.map(({freeGifts:e})=>(e||[]).map(s=>s.mediaImageGID)).reduce((e,s)=>e.concat(s),[]).filter(e=>e!=null),ne=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(s=>s.mediaImageGID)).filter(e=>e!=null),le=t=>t.dealBars.map(({upsells:e})=>(e||[]).map(s=>s.mediaImageGID)).reduce((e,s)=>e.concat(s),[]).filter(e=>e!=null),ie=t=>t.swatchOptions?t.swatchOptions.reduce((e,s)=>{const n=s.images.map(i=>i.mediaImageGID).filter(i=>i!=null);return[...e,...n]},[]):[],re=t=>{if(!t.collectionBreaksEnabled||!t.collectionBreaks)return[];const e=t.collectionBreaks.mediaImageGID;return e?[e]:[]},oe=t=>{var e,s,n;return t.progressiveGifts?[...((e=t.progressiveGifts.gifts)==null?void 0:e.map(i=>i.mediaImageGID))||[],(s=t.progressiveGifts.style)==null?void 0:s.lockedMediaImageGID,(n=t.progressiveGifts.dealBarStyle)==null?void 0:n.lockedMediaImageGID].filter(i=>i!=null):[]},ce=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ue=t=>t.dealBars.map(e=>{var s;return(s=e.productPersonalisation)==null?void 0:s.mediaImageGID}).filter(e=>e!=null),de=t=>{var n,i;const e=t.dealBars.map(r=>{var o;return(o=r.highlights)==null?void 0:o.customIconGID}).filter(r=>r!=null),s=(i=(n=t.subscriptions)==null?void 0:n.highlights)==null?void 0:i.customIconGID;return s?[...e,s]:e},me=t=>(t.badges||[]).flatMap(e=>e.badgeType==="custom"&&e.imageGID?[e.imageGID]:[]),pe=t=>!t.savingsSummaryEnabled||!t.savingsSummary?[]:t.savingsSummary.customIconGID?[t.savingsSummary.customIconGID]:[],fe=t=>{const e=[...he(t),...ge(t),...ye(t),...be(t),...ve(t),..._e(t),...Ie(t),...Pe(t)];return Array.from(new Set(e.filter(s=>s!=null)))},he=t=>t.dealBars.flatMap(({freeGifts:e})=>e?e.map(s=>s.productGID):[]).filter(e=>e!=null),ge=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(s=>s.products?s.products.map(n=>n.id):[]):[]).filter(e=>e!=null),ye=t=>{var e;return t.progressiveGiftsEnabled?((e=t.progressiveGifts)==null?void 0:e.gifts.map(s=>s.productGID).filter(s=>s!=null))||[]:[]},be=t=>t.dealBars.flatMap(({upsells:e})=>e?e.map(s=>s.productGID):[]).filter(e=>e!=null),ve=t=>t.dealBars.filter(e=>e.dealBarType===S.Bundle).flatMap(({bundleProducts:e})=>e?e.map(s=>s.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),_e=t=>t.dealBars.filter(e=>e.dealBarType===S.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(s=>{var n;return[s.productGID,...((n=s.selectedProducts)==null?void 0:n.map(i=>i.id))??[]]}):[]).filter(e=>e!=null).filter(e=>e!=="default"),Ie=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),Pe=t=>t.dealBars.filter(e=>e.dealBarType===S.Sku).flatMap(({productGID:e})=>e?[e]:[]);class Se{constructor(e,s){this.storefrontApiVersion="2026-07",this.storefrontAccessToken=s,this.shopifyDomain=e}async query(e,s){var l;const n=(s==null?void 0:s.variables)??{};let i=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;const r=(l=e.match(/query\s+(\w+)/))==null?void 0:l[1];r&&(i+=`?operation_name=${r}`);const o=await(await fetch(i,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:n})})).text();if(!o)throw new Error("Empty graphql response");return JSON.parse(o).data}}const ke=async(t,e,{country:s,language:n})=>{const i=e.collectionBreaks;if(!e.collectionBreaksEnabled||!i)return;let r;i.visibility==="deal-products"?r=await B(t,{country:s,language:n,blockVisibility:e.blockVisibility,excludedProductGIDs:(e.excludedProductIds||[]).map(l=>`gid://shopify/Product/${l}`),selectedProductGIDs:(e.selectedProductIds||[]).map(l=>`gid://shopify/Product/${l}`),selectedCollectionGIDs:(e.selectedCollectionIds||[]).map(l=>`gid://shopify/Collection/${l}`)}):r=await B(t,{country:s,language:n,blockVisibility:i.visibility,excludedProductGIDs:(i.excludedProducts||[]).map(({id:l})=>l),selectedProductGIDs:(i.selectedProducts||[]).map(({id:l})=>l),selectedCollectionGIDs:(i.selectedCollections||[]).map(({id:l})=>l)});let o=await D(t,{country:s,language:n,productIds:r.map(l=>Number(l.split("/").pop())),useExternalMetafieldNamespace:!0});return o=o.filter(l=>l.availableForSale),o},we=()=>({"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."}),Ee="2026-07",j=async(t,{productId:e,dealBlockId:s,country:n=void 0,language:i=void 0})=>{var r,o;try{const l=[Number(e.split("/").pop())],m=new Ae(t);n=n||((r=m.i18n)==null?void 0:r.country),i=i||((o=m.i18n)==null?void 0:o.language);const d=await W(m,{language:i,country:n,useExternalMetafieldNamespace:!0});m.shopifyDomain=d.shopifyDomain;const u=d.storefrontAccessToken?new Se(d.shopifyDomain,d.storefrontAccessToken):m,[y,h]=await Promise.all([D(u,{country:n,language:i,productIds:l,useExternalMetafieldNamespace:!0}),J(u,{useExternalMetafieldNamespace:!0,useMetaobjects:d.featureFlags.storefront_metaobjects})]),f=y[0];if(!f)return null;const v=V(h,f);let a;if(s?(a=v.find(P=>P.id===s||P.nanoId===s),a||(a=v[0])):a=v[0],!a)return null;const p=ee(a),g=fe(a),[_,c,b,I]=await Promise.all([D(u,{country:n,language:i,productIds:g,useExternalMetafieldNamespace:!0}),Z(u,p,300),ke(u,a,{country:n,language:i}),we()]);return{product:f,dealBlock:a,config:d,otherProducts:_,mediaImages:c,collectionBreaksProducts:b??[],translations:I}}catch(l){return console.error(l),null}};class Ae{constructor(e){this.storefront=e,this.shopifyDomain=""}async query(e,s){if("query"in this.storefront&&"i18n"in this.storefront)return await this.storefront.query(e,s);if("request"in this.storefront)return(await this.storefront.request(e,s)).data;if("shopifyDomain"in this.storefront&&"storefrontAccessToken"in this.storefront){const n=await fetch(`https://${this.storefront.shopifyDomain}/api/${Ee}/graphql.json`,{body:JSON.stringify({query:e,variables:s==null?void 0:s.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:e,variables:s==null?void 0:s.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",U=1e4,De="https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js",$e="https://bundles-integrations.kachingappz.app/kaching-bundles-block.js",$=new WeakSet,L=async t=>{const e=t.document;if(!t.customElements.get(w)){if($.has(e))return C(t,w);$.add(e);try{await xe(t)}catch(s){throw $.delete(e),s}}},Ce=()=>typeof window<"u"&&typeof window.__KACHING_DEV__<"u",Ne=()=>Ce()?De:$e,xe=t=>{const e=t.document;return new Promise((s,n)=>{const i=Ne();if(e.querySelector(`script[src="${i}"]`)){C(t,w).then(s).catch(n);return}const o=e.createElement("script");o.src=i,o.onload=()=>C(t,w).then(s).catch(n),o.onerror=()=>n(new Error("Failed to load script")),e.head.appendChild(o)})},C=(t,e)=>new Promise((s,n)=>{if(t.customElements.get(e)){s();return}Promise.race([t.customElements.whenDefined(e),new Promise((i,r)=>setTimeout(()=>r(new Error(`Custom element "${e}" failed to register within ${U}ms`)),U))]).then(()=>s()).catch(n)});var E=(t=>(t.QuantityBreak="quantity-break",t.Bxgy="bxgy",t.Bundle="bundle",t.MixAndMatch="mix-and-match",t.Sku="sku",t))(E||{});const Ge={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},Be={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},{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},{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}],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},Te={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:Be,product:Ge,otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}};class Me 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,l;const e=++this.initializeId;if(this.cleanup(),this.hasAttribute("demo")){if(await L(window),e!==this.initializeId)return;this.renderInnerElement(Te);return}const s=this.getAttribute("shop-domain"),n=this.getAttribute("storefront-token"),i=this.getAttribute("product-id");if(!s||!n||!i)return;const[r]=await Promise.all([j({shopifyDomain:s,storefrontAccessToken:n},{productId:i,dealBlockId:this.getAttribute("deal-block-id")??void 0,country:((o=this.getAttribute("country"))==null?void 0:o.toUpperCase())??void 0,language:((l=this.getAttribute("language"))==null?void 0:l.toUpperCase())??void 0}),L(window)]);!r||e!==this.initializeId||this.renderInnerElement(r)}renderInnerElement(e){const{config:s,dealBlock:n,product:i,otherProducts:r,mediaImages:o,collectionBreaksProducts:l,translations:m}=e;this.innerElement=document.createElement("kaching-bundles-block"),this.innerElement.setAttribute("deal-block-id",n.id),this.innerElement.setAttribute("config",JSON.stringify(s)),this.innerElement.setAttribute("deal-block",JSON.stringify(n)),this.innerElement.setAttribute("media-images",JSON.stringify(o??[])),this.innerElement.setAttribute("product",JSON.stringify(i)),this.innerElement.setAttribute("other-products",JSON.stringify(r??[])),this.innerElement.setAttribute("collection-breaks-products",JSON.stringify(l??[])),this.innerElement.setAttribute("translations",JSON.stringify(m??{}));const d=this.getAttribute("selected-variant-id");this.innerElement.setAttribute("current-variant-id",String(d?d.split("/").pop():i.variants[0].id)),this.hasAttribute("compact")&&this.innerElement.setAttribute("compact","");const u=this.innerElement,y=()=>{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(),y()};const h=this.handleItemsChanged;u.addEventListener("kaching-bundles-block-loaded",()=>{this.innerElement===u&&(u.addEventListener("items-changed",h),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(e,s,n){s!==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",Me),A.fetchKachingBundlesData=j,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),A})({});
228
+ `,{variables:{mediaImageIds:e,size:s}})).nodes.filter(Boolean).map(l=>({gid:l.id,url:l.image.url})));var S=(t=>(t.QuantityBreak="quantity-break",t.Bxgy="bxgy",t.Bundle="bundle",t.MixAndMatch="mix-and-match",t.Sku="sku",t))(S||{});const ee=t=>[...te(t),...se(t),...ae(t),...ne(t),...le(t),...ie(t),...re(t),...oe(t),...ce(t),...ue(t),...de(t),...me(t),...pe(t)].filter(e=>e!=null&&!e.includes("placeholder")),te=t=>t.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),se=t=>t.dealBars.flatMap(e=>e.dealBarType===S.Bundle?e.bundleProducts.map(s=>s.mediaImageGID):[]).filter(e=>e!=null),ae=t=>t.dealBars.map(({freeGifts:e})=>(e||[]).map(s=>s.mediaImageGID)).reduce((e,s)=>e.concat(s),[]).filter(e=>e!=null),ne=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(s=>s.mediaImageGID)).filter(e=>e!=null),le=t=>t.dealBars.map(({upsells:e})=>(e||[]).map(s=>s.mediaImageGID)).reduce((e,s)=>e.concat(s),[]).filter(e=>e!=null),ie=t=>t.swatchOptions?t.swatchOptions.reduce((e,s)=>{const l=s.images.map(n=>n.mediaImageGID).filter(n=>n!=null);return[...e,...l]},[]):[],re=t=>{if(!t.collectionBreaksEnabled||!t.collectionBreaks)return[];const e=t.collectionBreaks.mediaImageGID;return e?[e]:[]},oe=t=>{var e,s,l;return t.progressiveGifts?[...((e=t.progressiveGifts.gifts)==null?void 0:e.map(n=>n.mediaImageGID))||[],(s=t.progressiveGifts.style)==null?void 0:s.lockedMediaImageGID,(l=t.progressiveGifts.dealBarStyle)==null?void 0:l.lockedMediaImageGID].filter(n=>n!=null):[]},ce=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ue=t=>t.dealBars.map(e=>{var s;return(s=e.productPersonalisation)==null?void 0:s.mediaImageGID}).filter(e=>e!=null),de=t=>{var l,n;const e=t.dealBars.map(r=>{var o;return(o=r.highlights)==null?void 0:o.customIconGID}).filter(r=>r!=null),s=(n=(l=t.subscriptions)==null?void 0:l.highlights)==null?void 0:n.customIconGID;return s?[...e,s]:e},me=t=>(t.badges||[]).flatMap(e=>e.badgeType==="custom"&&e.imageGID?[e.imageGID]:[]),pe=t=>!t.savingsSummaryEnabled||!t.savingsSummary?[]:t.savingsSummary.customIconGID?[t.savingsSummary.customIconGID]:[],fe=t=>{const e=[...he(t),...ge(t),...ye(t),...be(t),...ve(t),..._e(t),...Ie(t),...Pe(t)];return Array.from(new Set(e.filter(s=>s!=null)))},he=t=>t.dealBars.flatMap(({freeGifts:e})=>e?e.map(s=>s.productGID):[]).filter(e=>e!=null),ge=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(s=>s.products?s.products.map(l=>l.id):[]):[]).filter(e=>e!=null),ye=t=>{var e;return t.progressiveGiftsEnabled?((e=t.progressiveGifts)==null?void 0:e.gifts.map(s=>s.productGID).filter(s=>s!=null))||[]:[]},be=t=>t.dealBars.flatMap(({upsells:e})=>e?e.map(s=>s.productGID):[]).filter(e=>e!=null),ve=t=>t.dealBars.filter(e=>e.dealBarType===S.Bundle).flatMap(({bundleProducts:e})=>e?e.map(s=>s.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),_e=t=>t.dealBars.filter(e=>e.dealBarType===S.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(s=>{var l;return[s.productGID,...((l=s.selectedProducts)==null?void 0:l.map(n=>n.id))??[]]}):[]).filter(e=>e!=null).filter(e=>e!=="default"),Ie=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),Pe=t=>t.dealBars.filter(e=>e.dealBarType===S.Sku).flatMap(({productGID:e})=>e?[e]:[]);class Se{constructor(e,s){this.storefrontApiVersion="2026-07",this.storefrontAccessToken=s,this.shopifyDomain=e}async query(e,s){var i;const l=(s==null?void 0:s.variables)??{};let n=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;const r=(i=e.match(/query\s+(\w+)/))==null?void 0:i[1];r&&(n+=`?operation_name=${r}`);const o=await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:l})})).text();if(!o)throw new Error("Empty graphql response");return JSON.parse(o).data}}const ke=async(t,e,{country:s,language:l})=>{const n=e.collectionBreaks;if(!e.collectionBreaksEnabled||!n)return;let r;n.visibility==="deal-products"?r=await B(t,{country:s,language:l,blockVisibility:e.blockVisibility,excludedProductGIDs:(e.excludedProductIds||[]).map(i=>`gid://shopify/Product/${i}`),selectedProductGIDs:(e.selectedProductIds||[]).map(i=>`gid://shopify/Product/${i}`),selectedCollectionGIDs:(e.selectedCollectionIds||[]).map(i=>`gid://shopify/Collection/${i}`)}):r=await B(t,{country:s,language:l,blockVisibility:n.visibility,excludedProductGIDs:(n.excludedProducts||[]).map(({id:i})=>i),selectedProductGIDs:(n.selectedProducts||[]).map(({id:i})=>i),selectedCollectionGIDs:(n.selectedCollections||[]).map(({id:i})=>i)});let o=await D(t,{country:s,language:l,productIds:r.map(i=>Number(i.split("/").pop())),useExternalMetafieldNamespace:!0});return o=o.filter(i=>i.availableForSale),o},we=()=>({"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."}),Ee="2026-07",j=async(t,{productId:e,dealBlockId:s,country:l=void 0,language:n=void 0})=>{var r,o;try{const i=[Number(e.split("/").pop())],m=new Ae(t);l=l||((r=m.i18n)==null?void 0:r.country),n=n||((o=m.i18n)==null?void 0:o.language);const d=await W(m,{language:n,country:l,useExternalMetafieldNamespace:!0});m.shopifyDomain=d.shopifyDomain;const u=d.storefrontAccessToken?new Se(d.shopifyDomain,d.storefrontAccessToken):m,[y,h]=await Promise.all([D(u,{country:l,language:n,productIds:i,useExternalMetafieldNamespace:!0}),J(u,{useExternalMetafieldNamespace:!0,useMetaobjects:d.featureFlags.storefront_metaobjects})]),f=y[0];if(!f)return null;const v=V(h,f);let a;if(s?(a=v.find(P=>P.id===s||P.nanoId===s),a||(a=v[0])):a=v[0],!a)return null;const p=ee(a),g=fe(a),[_,c,b,I]=await Promise.all([D(u,{country:l,language:n,productIds:g,useExternalMetafieldNamespace:!0}),Z(u,p,300),ke(u,a,{country:l,language:n}),we()]);return{product:f,dealBlock:a,config:d,otherProducts:_,mediaImages:c,collectionBreaksProducts:b??[],translations:I}}catch(i){return console.error(i),null}};class Ae{constructor(e){this.storefront=e,this.shopifyDomain=""}async query(e,s){var l;if("query"in this.storefront&&"i18n"in this.storefront)return await this.storefront.query(e,s);if("graphql"in this.storefront){const n=await this.storefront.graphql(e,s);if((l=n.errors)!=null&&l.length)throw new Error(n.errors.map(r=>r.message).join(`
229
+ `));return n.data}if("request"in this.storefront)return(await this.storefront.request(e,s)).data;if("shopifyDomain"in this.storefront&&"storefrontAccessToken"in this.storefront){const n=await fetch(`https://${this.storefront.shopifyDomain}/api/${Ee}/graphql.json`,{body:JSON.stringify({query:e,variables:s==null?void 0:s.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:e,variables:s==null?void 0:s.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",U=1e4,De="https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js",$e="https://bundles-integrations.kachingappz.app/kaching-bundles-block.js",$=new WeakSet,L=async t=>{const e=t.document;if(!t.customElements.get(w)){if($.has(e))return C(t,w);$.add(e);try{await xe(t)}catch(s){throw $.delete(e),s}}},Ce=()=>typeof window<"u"&&typeof window.__KACHING_DEV__<"u",Ne=()=>Ce()?De:$e,xe=t=>{const e=t.document;return new Promise((s,l)=>{const n=Ne();if(e.querySelector(`script[src="${n}"]`)){C(t,w).then(s).catch(l);return}const o=e.createElement("script");o.src=n,o.onload=()=>C(t,w).then(s).catch(l),o.onerror=()=>l(new Error("Failed to load script")),e.head.appendChild(o)})},C=(t,e)=>new Promise((s,l)=>{if(t.customElements.get(e)){s();return}Promise.race([t.customElements.whenDefined(e),new Promise((n,r)=>setTimeout(()=>r(new Error(`Custom element "${e}" failed to register within ${U}ms`)),U))]).then(()=>s()).catch(l)});var E=(t=>(t.QuantityBreak="quantity-break",t.Bxgy="bxgy",t.Bundle="bundle",t.MixAndMatch="mix-and-match",t.Sku="sku",t))(E||{});const Ge={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},Be={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},{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},{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}],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},Te={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:Be,product:Ge,otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}};class Me 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,i;const e=++this.initializeId;if(this.cleanup(),this.hasAttribute("demo")){if(await L(window),e!==this.initializeId)return;this.renderInnerElement(Te);return}const s=this.getAttribute("shop-domain"),l=this.getAttribute("storefront-token"),n=this.getAttribute("product-id");if(!s||!l||!n)return;const[r]=await Promise.all([j({shopifyDomain:s,storefrontAccessToken:l},{productId:n,dealBlockId:this.getAttribute("deal-block-id")??void 0,country:((o=this.getAttribute("country"))==null?void 0:o.toUpperCase())??void 0,language:((i=this.getAttribute("language"))==null?void 0:i.toUpperCase())??void 0}),L(window)]);!r||e!==this.initializeId||this.renderInnerElement(r)}renderInnerElement(e){const{config:s,dealBlock:l,product:n,otherProducts:r,mediaImages:o,collectionBreaksProducts:i,translations:m}=e;this.innerElement=document.createElement("kaching-bundles-block"),this.innerElement.setAttribute("deal-block-id",l.id),this.innerElement.setAttribute("config",JSON.stringify(s)),this.innerElement.setAttribute("deal-block",JSON.stringify(l)),this.innerElement.setAttribute("media-images",JSON.stringify(o??[])),this.innerElement.setAttribute("product",JSON.stringify(n)),this.innerElement.setAttribute("other-products",JSON.stringify(r??[])),this.innerElement.setAttribute("collection-breaks-products",JSON.stringify(i??[])),this.innerElement.setAttribute("translations",JSON.stringify(m??{}));const d=this.getAttribute("selected-variant-id");this.innerElement.setAttribute("current-variant-id",String(d?d.split("/").pop():n.variants[0].id)),this.hasAttribute("compact")&&this.innerElement.setAttribute("compact","");const u=this.innerElement,y=()=>{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(),y()};const h=this.handleItemsChanged;u.addEventListener("kaching-bundles-block-loaded",()=>{this.innerElement===u&&(u.addEventListener("items-changed",h),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(e,s,l){s!==l&&this.isConnected&&(e==="product-id"||e==="country"||e==="language"?this.initialize():e==="selected-variant-id"&&this.innerElement&&l&&this.innerElement.setAttribute("current-variant-id",l.includes("/")?String(l.split("/").pop()):l))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}}return customElements.define("kaching-bundle-component",Me),A.fetchKachingBundlesData=j,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),A})({});
package/dist/index.d.ts CHANGED
@@ -243,6 +243,8 @@ declare type DealBarProgressiveGiftStyle = {
243
243
  labelBackgroundColor: Color;
244
244
  labelTextColor: Color;
245
245
  labelTextSize: number;
246
+ backgroundColor?: Color | null;
247
+ selectedBackgroundColor?: Color | null;
246
248
  textColor: Color;
247
249
  selectedTextColor: Color;
248
250
  textSize: number;
@@ -401,7 +403,7 @@ declare type DefaultSortOption = "relevance" | "newest-first" | "price-low-to-hi
401
403
 
402
404
  declare type DiscountType = "default" | "percentage" | "amount" | "specific";
403
405
 
404
- export declare const fetchKachingBundlesData: (storefront: HydrogenV2Storefront | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, country, language, }: {
406
+ export declare const fetchKachingBundlesData: (storefront: HydrogenV2Storefront | HydrogenStorefrontClient | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, country, language, }: {
405
407
  productId: string;
406
408
  dealBlockId?: string;
407
409
  country?: string;
@@ -505,7 +507,6 @@ declare interface GlobalConfig {
505
507
  "system.deal_page_percentage_off"?: string;
506
508
  "system.deal_page_price_each"?: string;
507
509
  "system.deal_page_quantity_for_price"?: string;
508
- "system.deal_page_save_up_to"?: string;
509
510
  "system.deal_page_in_your_box"?: string;
510
511
  "system.deal_page_in_your_box_count"?: string;
511
512
  "system.deal_page_in_box_count"?: string;
@@ -583,6 +584,7 @@ declare interface GlobalConfig {
583
584
  label?: string | null;
584
585
  };
585
586
  featureFlags: {
587
+ accelerated_checkout_additional_items?: boolean;
586
588
  atc_total_price?: boolean;
587
589
  cart_change_response_rewrite?: boolean;
588
590
  cart_interceptor_dedupe_disabled?: boolean;
@@ -628,6 +630,21 @@ declare type Highlights = {
628
630
  customIconGID?: string | null;
629
631
  };
630
632
 
633
+ declare interface HydrogenStorefrontClient {
634
+ graphql(query: string, options?: {
635
+ variables?: Record<string, unknown>;
636
+ }): Promise<{
637
+ data: unknown;
638
+ errors?: readonly {
639
+ message: string;
640
+ }[];
641
+ }>;
642
+ i18n: {
643
+ country: string;
644
+ language: string;
645
+ };
646
+ }
647
+
631
648
  declare interface HydrogenV2Storefront {
632
649
  query: (query: string, options?: {
633
650
  variables?: Record<string, unknown>;
@@ -798,6 +815,7 @@ declare type ProgressiveGifts = {
798
815
  hideLockedGifts: boolean;
799
816
  showLockedGiftLabels: boolean;
800
817
  showLockedGiftProducts: boolean;
818
+ includeInCompareAt?: boolean;
801
819
  gifts: ProgressiveGift[];
802
820
  titleColor: Color;
803
821
  titleAlignment: "start" | "center" | "end";