@kachingappz/bundles-js 1.0.1 → 1.1.1

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 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(`
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: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(`
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: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
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: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
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(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=`
49
49
  id
50
50
  availableForSale
51
51
  price {
@@ -60,7 +60,7 @@ var BundlesJs=(function(A){"use strict";const V=(t,e)=>{const s=[],n=t.filter(l=
60
60
  }
61
61
  image {
62
62
  id
63
- url(transform: { maxWidth: 200, maxHeight: 200 })
63
+ url(transform: $variantImageTransform)
64
64
  }
65
65
  unitPriceMeasurement {
66
66
  quantityUnit
@@ -88,8 +88,8 @@ 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=`
92
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${u} {
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} {
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 V=(t,e)=>{const s=[],n=t.filter(l=
123
123
  }
124
124
  variants(first: 250) {
125
125
  nodes {
126
- ${T}
126
+ ${B}
127
127
  }
128
128
  }
129
129
  collections(first: 50) {
@@ -175,12 +175,12 @@ 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
+ `,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} {
180
180
  product(id: $productGID) {
181
181
  variants(first: 250, after: $cursor, reverse: $reverse) {
182
182
  nodes {
183
- ${T}
183
+ ${B}
184
184
  }
185
185
  pageInfo {
186
186
  endCursor
@@ -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: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
193
  query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
194
194
  localization {
195
195
  country {
@@ -214,15 +214,16 @@ 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(`
218
- query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
219
- nodes(ids: $mediaImageIds) {
220
- ... on MediaImage {
221
- id
222
- image {
223
- url(transform: { maxWidth: $size, maxHeight: $size })
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(`
218
+ query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
219
+ nodes(ids: $mediaImageIds) {
220
+ ... on MediaImage {
221
+ id
222
+ image {
223
+ url(transform: { maxWidth: $size, maxHeight: $size })
224
+ }
225
+ }
224
226
  }
225
227
  }
226
- }
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:i,size:a}})))).flatMap(i=>i.nodes).filter(Boolean).map(i=>({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},{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},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})({});
package/dist/index.d.ts CHANGED
@@ -301,12 +301,14 @@ declare type DealBlock = {
301
301
  showBothPrices: boolean;
302
302
  unitLabel?: string;
303
303
  useProductCompareAtPrice: boolean;
304
+ hideFullPrice?: boolean;
304
305
  showPricesWithoutDecimals?: boolean;
305
306
  priceRounding: boolean;
306
307
  priceRoundingPrecision: PriceRoundingPrecision;
307
308
  updateNativePrice?: boolean;
308
309
  updateNativePriceType?: "item" | "bundle";
309
310
  showTotalPriceInAddToCartButton?: boolean;
311
+ includeUpsellsInDealBarPrice?: boolean;
310
312
  skipCart: boolean;
311
313
  showVariantsForSingleQuantity: boolean;
312
314
  preselectedDealBarId: string | null;
@@ -403,7 +405,7 @@ declare type DefaultSortOption = "relevance" | "newest-first" | "price-low-to-hi
403
405
 
404
406
  declare type DiscountType = "default" | "percentage" | "amount" | "specific";
405
407
 
406
- export declare const fetchKachingBundlesData: (storefront: HydrogenV2Storefront | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, country, language, }: {
408
+ export declare const fetchKachingBundlesData: (storefront: HydrogenV2Storefront | HydrogenStorefrontClient | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, country, language, }: {
407
409
  productId: string;
408
410
  dealBlockId?: string;
409
411
  country?: string;
@@ -453,6 +455,7 @@ declare interface GlobalConfig {
453
455
  includeSellingPlans: boolean;
454
456
  includeAvailableQuantity: boolean;
455
457
  customApiHost: string | null;
458
+ appEmbedCheckToken?: string | null;
456
459
  keepQuantityInput: boolean;
457
460
  ignoreDeselect: boolean;
458
461
  ignoreUnitPrice: boolean;
@@ -507,7 +510,6 @@ declare interface GlobalConfig {
507
510
  "system.deal_page_percentage_off"?: string;
508
511
  "system.deal_page_price_each"?: string;
509
512
  "system.deal_page_quantity_for_price"?: string;
510
- "system.deal_page_save_up_to"?: string;
511
513
  "system.deal_page_in_your_box"?: string;
512
514
  "system.deal_page_in_your_box_count"?: string;
513
515
  "system.deal_page_in_box_count"?: string;
@@ -516,11 +518,10 @@ declare interface GlobalConfig {
516
518
  "system.deal_page_box_full"?: string;
517
519
  "system.deal_page_sold_out"?: string;
518
520
  "system.deal_page_start_your_box"?: string;
519
- "system.deal_page_not_a_full_box"?: string;
521
+ "system.deal_page_not_a_box_size"?: string;
520
522
  "system.deal_page_full_price_for_now"?: string;
521
523
  "system.deal_page_percentage_unlocked"?: string;
522
524
  "system.deal_page_box_of"?: string;
523
- "system.deal_page_no_box_price"?: string;
524
525
  "system.deal_page_track_box_full"?: string;
525
526
  "system.deal_page_nudge_start_percentage_one"?: string;
526
527
  "system.deal_page_nudge_start_percentage_other"?: string;
@@ -538,12 +539,10 @@ declare interface GlobalConfig {
538
539
  "system.deal_page_nudge_more_fixed_other"?: string;
539
540
  "system.deal_page_nudge_more_fixed_few"?: string;
540
541
  "system.deal_page_nudge_more_fixed_many"?: string;
541
- "system.deal_page_nudge_best_price"?: string;
542
- "system.deal_page_nudge_box_full"?: string;
543
- "system.deal_page_nudge_below_minimum_one"?: string;
544
- "system.deal_page_nudge_below_minimum_other"?: string;
545
- "system.deal_page_nudge_below_minimum_few"?: string;
546
- "system.deal_page_nudge_below_minimum_many"?: string;
542
+ "system.deal_page_nudge_not_a_box_size_one"?: string;
543
+ "system.deal_page_nudge_not_a_box_size_other"?: string;
544
+ "system.deal_page_nudge_not_a_box_size_few"?: string;
545
+ "system.deal_page_nudge_not_a_box_size_many"?: string;
547
546
  "system.deal_page_subtotal"?: string;
548
547
  "system.deal_page_box_discount"?: string;
549
548
  "system.deal_page_box_price_saving"?: string;
@@ -571,7 +570,6 @@ declare interface GlobalConfig {
571
570
  "system.deal_page_default_add_to_box"?: string;
572
571
  "system.deal_page_default_add_box_to_cart"?: string;
573
572
  "system.deal_page_items_range"?: string;
574
- "system.deal_page_minimum"?: string;
575
573
  "system.deal_page_tip_box_size"?: string;
576
574
  "system.deal_page_tip_on_its_own"?: string;
577
575
  "system.deal_page_about_this_price"?: string;
@@ -585,6 +583,7 @@ declare interface GlobalConfig {
585
583
  label?: string | null;
586
584
  };
587
585
  featureFlags: {
586
+ accelerated_checkout_additional_items?: boolean;
588
587
  atc_total_price?: boolean;
589
588
  cart_change_response_rewrite?: boolean;
590
589
  cart_interceptor_dedupe_disabled?: boolean;
@@ -630,6 +629,21 @@ declare type Highlights = {
630
629
  customIconGID?: string | null;
631
630
  };
632
631
 
632
+ declare interface HydrogenStorefrontClient {
633
+ graphql(query: string, options?: {
634
+ variables?: Record<string, unknown>;
635
+ }): Promise<{
636
+ data: unknown;
637
+ errors?: readonly {
638
+ message: string;
639
+ }[];
640
+ }>;
641
+ i18n: {
642
+ country: string;
643
+ language: string;
644
+ };
645
+ }
646
+
633
647
  declare interface HydrogenV2Storefront {
634
648
  query: (query: string, options?: {
635
649
  variables?: Record<string, unknown>;
@@ -800,6 +814,7 @@ declare type ProgressiveGifts = {
800
814
  hideLockedGifts: boolean;
801
815
  showLockedGiftLabels: boolean;
802
816
  showLockedGiftProducts: boolean;
817
+ includeInCompareAt?: boolean;
803
818
  gifts: ProgressiveGift[];
804
819
  titleColor: Color;
805
820
  titleAlignment: "start" | "center" | "end";