@kachingappz/bundles-js 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(){"use strict";const N={config:{shopifyDomain:"",moneyFormat:"${{amount}}",locale:"en",country:"US",currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,accessScopes:[],customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!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.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"},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:""},dealBlock:{id:"example",nanoId:"example",blockName:"Bundle",discountName:"",blockTitle:"BUNDLE & SAVE",blockLayout:"vertical",blockVisibility:"all-products",marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:"",useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:".00",updateNativePrice:!1,updateNativePriceType:"item",skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:"duo",cornerRadius:8,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:255,green:255,blue:255,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:238,green:238,blue:238,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:"medium"},subtitle:{size:"14",style:"regular"},label:{size:"12",style:"regular"},freeGift:{size:"13",style:"bold"},upsell:{size:"13",style:"bold"},unitLabel:{size:"14",style:"regular"}},dealBars:[{id:"single",dealBarType:"quantity-break",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:"quantity-break",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:"quantity-break",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}],swatchOptions:[],swatchSize:18,swatchShape:"circle",imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:"",customStyles:"",lowStockAlertEnabled:!1,lowStockAlert:null},product:{id:1,handle:"example-product",url:null,availableForSale:!0,title:"Example product",image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:["Default Title"],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}},P=({country:t,language:e})=>{const l=[];return t&&l.push(`country: ${t}`),e&&l.push(`language: ${e}`),l.length>0?`@inContext(${l.join(", ")})`:""},x=async(t,{useExternalMetafieldNamespace:e,useMetaobjects:l})=>l?T(t):B(t),B=async(t,e)=>{var a;const l=(a=(await t.query(`
1
+ (function(){"use strict";const N={config:{shopifyDomain:"",moneyFormat:"${{amount}}",locale:"en",country:"US",currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,accessScopes:[],customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!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.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"},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:""},dealBlock:{id:"example",nanoId:"example",blockName:"Bundle",discountName:"",blockTitle:"BUNDLE & SAVE",blockLayout:"vertical",blockVisibility:"all-products",marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:"",useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:".00",updateNativePrice:!1,updateNativePriceType:"item",skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:"duo",cornerRadius:16,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:245,green:245,blue:245,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:171,green:239,blue:198,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:0,green:0,blue:0,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:"14",style:"bold"},title:{size:"20",style:"medium"},subtitle:{size:"14",style:"regular"},label:{size:"12",style:"regular"},freeGift:{size:"13",style:"bold"},upsell:{size:"13",style:"bold"},unitLabel:{size:"14",style:"regular"}},dealBars:[{id:"single",dealBarType:"quantity-break",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:"quantity-break",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:"quantity-break",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}],swatchOptions:[],swatchSize:18,swatchShape:"circle",imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:"",customStyles:"",lowStockAlertEnabled:!1,lowStockAlert:null},product:{id:1,handle:"example-product",url:null,availableForSale:!0,title:"Example product",image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:["Default Title"],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}},P=({country:t,language:e})=>{const l=[];return t&&l.push(`country: ${t}`),e&&l.push(`language: ${e}`),l.length>0?`@inContext(${l.join(", ")})`:""},x=async(t,{useExternalMetafieldNamespace:e,useMetaobjects:l})=>l?T(t):B(t),B=async(t,e)=>{var a;const l=(a=(await t.query(`
2
2
  query FetchDealBlocks($metafieldNamespace: String!) {
3
3
  shop {
4
4
  metafield(namespace: $metafieldNamespace, key: "deal_blocks") {
@@ -200,4 +200,4 @@
200
200
  }
201
201
  }
202
202
  }
203
- `,{variables:{productGID:e.id,cursor:p,reverse:s,...l}}),{nodes:i,pageInfo:u}=d.product.variants;for(const r of i){if(a.has(r.id)){m=!1;break}a.add(r.id),s?o.push(r):n.push(r)}u.hasNextPage||(m=!1),p=u.endCursor}};return await Promise.all([c(!1),c(!0)]),e.variants.nodes=[...n,...o.reverse()],e},U=t=>{var c,s,m,p,d,i;const e=t.variants.nodes.map(({unitPriceMeasurement:u,...r})=>{var f,h;return{id:Number(r.id.split("/").pop()),availableForSale:r.availableForSale,price:Math.round(Number(r.price.amount)*100),compareAtPrice:r.compareAtPrice?Math.round(Number(r.compareAtPrice.amount)*100):null,options:r.selectedOptions.map(g=>g.value),imageId:r.image?Number(r.image.id.split("/").pop()):null,image:((f=r.image)==null?void 0:f.url)||null,sellingPlans:((h=r.sellingPlanAllocations)==null?void 0:h.nodes.map(g=>({id:Number(g.sellingPlan.id.split("/").pop()),price:g.priceAdjustments.length>0?Math.round(Number(g.priceAdjustments[0].price.amount)*100):Math.round(Number(r.price.amount)*100)})))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:r.quantityAvailable??null,unitPriceMeasurement:u!=null&&u.quantityUnit&&(u!=null&&u.referenceUnit)?{quantityValue:u.quantityValue,quantityUnit:u.quantityUnit.toLowerCase(),referenceValue:u.referenceValue,referenceUnit:u.referenceUnit.toLowerCase()}:null}}),l=t.options.map((u,r)=>{const f=u.optionValues.map(h=>{var g,y,I,v;return{id:Number(h.id.split("/").pop()),defaultName:h.name,name:h.name,swatch:{color:((g=h.swatch)==null?void 0:g.color)||null,image:((v=(I=(y=h.swatch)==null?void 0:y.image)==null?void 0:I.previewImage)==null?void 0:v.url)||null}}});return{defaultName:u.name,name:u.name,position:r+1,optionValues:V(f,r,e)}}),a=u=>{const r=u.priceAdjustments[0];if(!r)return null;const f=r.adjustmentValue;switch(f.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:f.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"fixed_amount",value:Number(f.adjustmentAmount.amount)*100};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:Number(f.price.amount)*100};default:throw new Error(`Unknown price adjustment type: ${f.__typename}`)}},n=((c=t.sellingPlanGroups)==null?void 0:c.nodes.flatMap(u=>u.sellingPlans.nodes.map(r=>({id:Number(r.id.split("/").pop()),name:r.name,priceAdjustment:a(r)}))))||[],o=t.variants.nodes.some(u=>u.requiresComponents);return{id:Number(t.id.split("/").pop()),handle:t.handle,url:t.onlineStoreUrl,availableForSale:t.availableForSale,createdAt:t.createdAt,title:t.title,image:((s=t.featuredImage)==null?void 0:s.url)||null,collectionIds:t.collections.nodes.map(u=>Number(u.id.split("/").pop())),options:l,selectedVariantId:Number(t.variants.nodes[0].id.split("/").pop()),variants:e,requiresSellingPlan:t.requiresSellingPlan,sellingPlans:n,isNativeBundle:o,metafields:{text:((m=t.metafield)==null?void 0:m.value)||null,text2:((p=t.metafield2)==null?void 0:p.value)||null,text3:((d=t.metafield3)==null?void 0:d.value)||null,text4:((i=t.metafield4)==null?void 0:i.value)||null}}},V=(t,e,l)=>t.filter(a=>l.filter(n=>n.options[e]===a.name).length>0),F=(t,e)=>{const l=[],a=t.filter(s=>s.blockVisibility==="selected-products");for(const s of a)s.selectedProductIds.map(Number).includes(e.id)&&l.push(s);const n=t.filter(s=>s.blockVisibility==="selected-collections");for(const s of n)e.collectionIds.some(m=>s.selectedCollectionIds.map(Number).includes(m))&&l.push(s);const o=t.filter(s=>s.blockVisibility==="excluded-products");for(const s of o)!s.excludedProductIds.map(Number).includes(e.id)&&!(s.excludedCollectionIds||[]).some(m=>e.collectionIds.includes(m))&&l.push(s);const c=t.filter(s=>s.blockVisibility==="all-products");for(const s of c)l.push(s);return l},j=t=>[...z(t),...R(t),...H(t),...J(t),...Q(t),...X(t),...K(t),...W(t),...Y(t),...Z(t)].filter(e=>e!=null&&!e.includes("placeholder")),z=t=>t.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),R=t=>t.dealBars.map(({freeGifts:e})=>(e||[]).map(l=>l.mediaImageGID)).reduce((e,l)=>e.concat(l),[]).filter(e=>e!=null),H=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(l=>l.mediaImageGID)).filter(e=>e!=null),J=t=>t.dealBars.map(({upsells:e})=>(e||[]).map(l=>l.mediaImageGID)).reduce((e,l)=>e.concat(l),[]).filter(e=>e!=null),Q=t=>t.swatchOptions?t.swatchOptions.reduce((e,l)=>{const a=l.images.map(n=>n.mediaImageGID).filter(n=>n!=null);return[...e,...a]},[]):[],X=t=>{if(!t.collectionBreaksEnabled||!t.collectionBreaks)return[];const e=t.collectionBreaks.mediaImageGID;return e?[e]:[]},K=t=>{var e,l,a;return t.progressiveGifts?[...((e=t.progressiveGifts.gifts)==null?void 0:e.map(n=>n.mediaImageGID))||[],(l=t.progressiveGifts.style)==null?void 0:l.lockedMediaImageGID,(a=t.progressiveGifts.dealBarStyle)==null?void 0:a.lockedMediaImageGID].filter(n=>n!=null):[]},W=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.map(e=>e.mediaImageGID).filter(e=>e!=null),Y=t=>t.dealBars.map(e=>{var l;return(l=e.productPersonalisation)==null?void 0:l.mediaImageGID}).filter(e=>e!=null),Z=t=>t.dealBars.map(e=>{var l;return(l=e.highlights)==null?void 0:l.customIconGID}).filter(e=>e!=null),ee=t=>{const e=[...te(t),...le(t),...se(t),...ae(t),...ne(t),...ie(t),...re(t)];return Array.from(new Set(e.filter(l=>l!=null)))},te=t=>t.dealBars.flatMap(({freeGifts:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null),le=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(l=>l.products?l.products.map(a=>a.id):[]):[]).filter(e=>e!=null),se=t=>{var e;return t.progressiveGiftsEnabled?((e=t.progressiveGifts)==null?void 0:e.gifts.map(l=>l.productGID).filter(l=>l!=null))||[]:[]},ae=t=>t.dealBars.flatMap(({upsells:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null),ne=t=>t.dealBars.filter(e=>e.dealBarType==="bundle").flatMap(({bundleProducts:e})=>e?e.map(l=>l.productGID):[]).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),re=t=>t.dealBars.filter(e=>e.dealBarType==="sku").flatMap(({productGID:e})=>e?[e]:[]);class D{constructor(e,l){this.storefrontApiVersion="2025-10",this.storefrontAccessToken=l,this.shopifyDomain=e}async query(e,l){var s;const a=(l==null?void 0:l.variables)??{};let n=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;const o=(s=e.match(/query\s+(\w+)/))==null?void 0:s[1];o&&(n+=`?operation_name=${o}`);const c=await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:a})})).text();if(!c)throw new Error("Empty graphql response");return JSON.parse(c).data}}const oe=async(t,e,{country:l,language:a})=>{const n=e.collectionBreaks;if(!e.collectionBreaksEnabled||!n)return;let o;n.visibility==="deal-products"?o=await A(t,{country:l,language:a,blockVisibility:e.blockVisibility,excludedProductGIDs:(e.excludedProductIds||[]).map(s=>`gid://shopify/Product/${s}`),selectedProductGIDs:(e.selectedProductIds||[]).map(s=>`gid://shopify/Product/${s}`),selectedCollectionGIDs:(e.selectedCollectionIds||[]).map(s=>`gid://shopify/Collection/${s}`)}):o=await A(t,{country:l,language:a,blockVisibility:n.visibility,excludedProductGIDs:(n.excludedProducts||[]).map(({id:s})=>s),selectedProductGIDs:(n.selectedProducts||[]).map(({id:s})=>s),selectedCollectionGIDs:(n.selectedCollections||[]).map(({id:s})=>s)}),o=o.slice(0,250);let c=await _(t,{country:l,language:a,productIds:o.map(s=>Number(s.split("/").pop())),useExternalMetafieldNamespace:!0});return c=c.filter(s=>s.availableForSale),c},ce=()=>({"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.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"}),ue=async(t,{productId:e,dealBlockId:l,country:a,language:n})=>{try{const o=[Number(e.split("/").pop())],c=new D(t.shopifyDomain,t.storefrontAccessToken),s=await q(c,{language:n,country:a,useExternalMetafieldNamespace:!0}),m=s.storefrontAccessToken?new D(s.shopifyDomain,s.storefrontAccessToken):c,[p,d]=await Promise.all([_(m,{country:a,language:n,productIds:o,useExternalMetafieldNamespace:!0}),x(m,{useExternalMetafieldNamespace:!0,useMetaobjects:s.featureFlags.storefront_metaobjects})]),i=p[0];if(!i)return null;const u=F(d,i);let r;if(l?(r=u.find($=>$.id===l||$.nanoId===l),r||(r=u[0])):r=u[0],!r)return null;const f=j(r),h=ee(r),[g,y,I,v]=await Promise.all([_(m,{country:a,language:n,productIds:h,useExternalMetafieldNamespace:!0}),L(m,f,300),oe(m,r,{country:a,language:n}),ce()]);return{product:i,dealBlock:r,config:s,otherProducts:g,mediaImages:y,collectionBreaksProducts:I??[],translations:v}}catch(o){return console.error(o),null}},b="kaching-bundles-block",C=1e4,de="https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js",me="https://bundles-integrations.kachingappz.app/kaching-bundles-block.js",k=new WeakSet,G=async t=>{const e=t.document;if(!t.customElements.get(b)){if(k.has(e))return S(t,b);k.add(e);try{await he(t)}catch(l){throw k.delete(e),l}}},pe=()=>typeof window<"u"&&typeof window.__KACHING_DEV__<"u",fe=()=>pe()?de:me,he=t=>{const e=t.document;return new Promise((l,a)=>{const n=fe();if(e.querySelector(`script[src="${n}"]`)){S(t,b).then(l).catch(a);return}const c=e.createElement("script");c.src=n,c.onload=()=>S(t,b).then(l).catch(a),c.onerror=()=>a(new Error("Failed to load script")),e.head.appendChild(c)})},S=(t,e)=>new Promise((l,a)=>{if(t.customElements.get(e)){l();return}Promise.race([t.customElements.whenDefined(e),new Promise((n,o)=>setTimeout(()=>o(new Error(`Custom element "${e}" failed to register within ${C}ms`)),C))]).then(()=>l()).catch(a)});class ge extends HTMLElement{constructor(){super(...arguments),this.innerElement=null,this.handleItemsChanged=null,this.initializeId=0}static get observedAttributes(){return["selected-variant-id","product-id"]}async connectedCallback(){await this.initialize()}async initialize(){var c,s;const e=++this.initializeId;if(this.cleanup(),this.hasAttribute("demo")){if(await G(window),e!==this.initializeId)return;this.renderInnerElement(N);return}const l=this.getAttribute("shop-domain"),a=this.getAttribute("storefront-token"),n=this.getAttribute("product-id");if(!l||!a||!n)return;const[o]=await Promise.all([ue({shopifyDomain:l,storefrontAccessToken:a},{productId:n,dealBlockId:this.getAttribute("deal-block-id")??void 0,country:((c=this.getAttribute("country"))==null?void 0:c.toUpperCase())??void 0,language:((s=this.getAttribute("language"))==null?void 0:s.toUpperCase())??void 0}),G(window)]);!o||e!==this.initializeId||this.renderInnerElement(o)}renderInnerElement(e){const{config:l,dealBlock:a,product:n,otherProducts:o,mediaImages:c,collectionBreaksProducts:s,translations:m}=e;this.innerElement=document.createElement("kaching-bundles-block"),this.innerElement.setAttribute("deal-block-id",a.id),this.innerElement.setAttribute("config",JSON.stringify(l)),this.innerElement.setAttribute("deal-block",JSON.stringify(a)),this.innerElement.setAttribute("media-images",JSON.stringify(c??[])),this.innerElement.setAttribute("product",JSON.stringify(n)),this.innerElement.setAttribute("other-products",JSON.stringify(o??[])),this.innerElement.setAttribute("collection-breaks-products",JSON.stringify(s??[])),this.innerElement.setAttribute("translations",JSON.stringify(m??{}));const p=this.getAttribute("selected-variant-id");this.innerElement.setAttribute("current-variant-id",String(p?p.split("/").pop():n.variants[0].id)),this.hasAttribute("compact")&&this.innerElement.setAttribute("compact","");const d=this.innerElement,i=()=>{if(this.innerElement!==d)return;const r=d.items();r&&this.dispatchEvent(new CustomEvent("items-changed",{detail:{items:r},bubbles:!0}))};this.handleItemsChanged=r=>{r.stopPropagation(),i()};const u=this.handleItemsChanged;d.addEventListener("kaching-bundles-block-loaded",()=>{this.innerElement===d&&(d.addEventListener("items-changed",u),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,l,a){l!==a&&this.isConnected&&(e==="product-id"?this.initialize():e==="selected-variant-id"&&this.innerElement&&a&&this.innerElement.setAttribute("current-variant-id",a.includes("/")?String(a.split("/").pop()):a))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}}customElements.define("kaching-bundle-component",ge)})();
203
+ `,{variables:{productGID:e.id,cursor:p,reverse:s,...l}}),{nodes:i,pageInfo:u}=d.product.variants;for(const r of i){if(a.has(r.id)){m=!1;break}a.add(r.id),s?o.push(r):n.push(r)}u.hasNextPage||(m=!1),p=u.endCursor}};return await Promise.all([c(!1),c(!0)]),e.variants.nodes=[...n,...o.reverse()],e},U=t=>{var c,s,m,p,d,i;const e=t.variants.nodes.map(({unitPriceMeasurement:u,...r})=>{var f,g;return{id:Number(r.id.split("/").pop()),availableForSale:r.availableForSale,price:Math.round(Number(r.price.amount)*100),compareAtPrice:r.compareAtPrice?Math.round(Number(r.compareAtPrice.amount)*100):null,options:r.selectedOptions.map(h=>h.value),imageId:r.image?Number(r.image.id.split("/").pop()):null,image:((f=r.image)==null?void 0:f.url)||null,sellingPlans:((g=r.sellingPlanAllocations)==null?void 0:g.nodes.map(h=>({id:Number(h.sellingPlan.id.split("/").pop()),price:h.priceAdjustments.length>0?Math.round(Number(h.priceAdjustments[0].price.amount)*100):Math.round(Number(r.price.amount)*100)})))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:r.quantityAvailable??null,unitPriceMeasurement:u!=null&&u.quantityUnit&&(u!=null&&u.referenceUnit)?{quantityValue:u.quantityValue,quantityUnit:u.quantityUnit.toLowerCase(),referenceValue:u.referenceValue,referenceUnit:u.referenceUnit.toLowerCase()}:null}}),l=t.options.map((u,r)=>{const f=u.optionValues.map(g=>{var h,y,I,v;return{id:Number(g.id.split("/").pop()),defaultName:g.name,name:g.name,swatch:{color:((h=g.swatch)==null?void 0:h.color)||null,image:((v=(I=(y=g.swatch)==null?void 0:y.image)==null?void 0:I.previewImage)==null?void 0:v.url)||null}}});return{defaultName:u.name,name:u.name,position:r+1,optionValues:V(f,r,e)}}),a=u=>{const r=u.priceAdjustments[0];if(!r)return null;const f=r.adjustmentValue;switch(f.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:f.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"fixed_amount",value:Number(f.adjustmentAmount.amount)*100};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:Number(f.price.amount)*100};default:throw new Error(`Unknown price adjustment type: ${f.__typename}`)}},n=((c=t.sellingPlanGroups)==null?void 0:c.nodes.flatMap(u=>u.sellingPlans.nodes.map(r=>({id:Number(r.id.split("/").pop()),name:r.name,priceAdjustment:a(r)}))))||[],o=t.variants.nodes.some(u=>u.requiresComponents);return{id:Number(t.id.split("/").pop()),handle:t.handle,url:t.onlineStoreUrl,availableForSale:t.availableForSale,createdAt:t.createdAt,title:t.title,image:((s=t.featuredImage)==null?void 0:s.url)||null,collectionIds:t.collections.nodes.map(u=>Number(u.id.split("/").pop())),options:l,selectedVariantId:Number(t.variants.nodes[0].id.split("/").pop()),variants:e,requiresSellingPlan:t.requiresSellingPlan,sellingPlans:n,isNativeBundle:o,metafields:{text:((m=t.metafield)==null?void 0:m.value)||null,text2:((p=t.metafield2)==null?void 0:p.value)||null,text3:((d=t.metafield3)==null?void 0:d.value)||null,text4:((i=t.metafield4)==null?void 0:i.value)||null}}},V=(t,e,l)=>t.filter(a=>l.filter(n=>n.options[e]===a.name).length>0),F=(t,e)=>{const l=[],a=t.filter(s=>s.blockVisibility==="selected-products");for(const s of a)s.selectedProductIds.map(Number).includes(e.id)&&l.push(s);const n=t.filter(s=>s.blockVisibility==="selected-collections");for(const s of n)e.collectionIds.some(m=>s.selectedCollectionIds.map(Number).includes(m))&&l.push(s);const o=t.filter(s=>s.blockVisibility==="excluded-products");for(const s of o)!s.excludedProductIds.map(Number).includes(e.id)&&!(s.excludedCollectionIds||[]).some(m=>e.collectionIds.includes(m))&&l.push(s);const c=t.filter(s=>s.blockVisibility==="all-products");for(const s of c)l.push(s);return l},j=t=>[...z(t),...R(t),...H(t),...J(t),...Q(t),...X(t),...K(t),...W(t),...Y(t),...Z(t)].filter(e=>e!=null&&!e.includes("placeholder")),z=t=>t.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),R=t=>t.dealBars.map(({freeGifts:e})=>(e||[]).map(l=>l.mediaImageGID)).reduce((e,l)=>e.concat(l),[]).filter(e=>e!=null),H=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(l=>l.mediaImageGID)).filter(e=>e!=null),J=t=>t.dealBars.map(({upsells:e})=>(e||[]).map(l=>l.mediaImageGID)).reduce((e,l)=>e.concat(l),[]).filter(e=>e!=null),Q=t=>t.swatchOptions?t.swatchOptions.reduce((e,l)=>{const a=l.images.map(n=>n.mediaImageGID).filter(n=>n!=null);return[...e,...a]},[]):[],X=t=>{if(!t.collectionBreaksEnabled||!t.collectionBreaks)return[];const e=t.collectionBreaks.mediaImageGID;return e?[e]:[]},K=t=>{var e,l,a;return t.progressiveGifts?[...((e=t.progressiveGifts.gifts)==null?void 0:e.map(n=>n.mediaImageGID))||[],(l=t.progressiveGifts.style)==null?void 0:l.lockedMediaImageGID,(a=t.progressiveGifts.dealBarStyle)==null?void 0:a.lockedMediaImageGID].filter(n=>n!=null):[]},W=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.map(e=>e.mediaImageGID).filter(e=>e!=null),Y=t=>t.dealBars.map(e=>{var l;return(l=e.productPersonalisation)==null?void 0:l.mediaImageGID}).filter(e=>e!=null),Z=t=>t.dealBars.map(e=>{var l;return(l=e.highlights)==null?void 0:l.customIconGID}).filter(e=>e!=null),ee=t=>{const e=[...te(t),...le(t),...se(t),...ae(t),...ne(t),...ie(t),...re(t)];return Array.from(new Set(e.filter(l=>l!=null)))},te=t=>t.dealBars.flatMap(({freeGifts:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null),le=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(l=>l.products?l.products.map(a=>a.id):[]):[]).filter(e=>e!=null),se=t=>{var e;return t.progressiveGiftsEnabled?((e=t.progressiveGifts)==null?void 0:e.gifts.map(l=>l.productGID).filter(l=>l!=null))||[]:[]},ae=t=>t.dealBars.flatMap(({upsells:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null),ne=t=>t.dealBars.filter(e=>e.dealBarType==="bundle").flatMap(({bundleProducts:e})=>e?e.map(l=>l.productGID):[]).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),re=t=>t.dealBars.filter(e=>e.dealBarType==="sku").flatMap(({productGID:e})=>e?[e]:[]);class D{constructor(e,l){this.storefrontApiVersion="2025-10",this.storefrontAccessToken=l,this.shopifyDomain=e}async query(e,l){var s;const a=(l==null?void 0:l.variables)??{};let n=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;const o=(s=e.match(/query\s+(\w+)/))==null?void 0:s[1];o&&(n+=`?operation_name=${o}`);const c=await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:a})})).text();if(!c)throw new Error("Empty graphql response");return JSON.parse(c).data}}const oe=async(t,e,{country:l,language:a})=>{const n=e.collectionBreaks;if(!e.collectionBreaksEnabled||!n)return;let o;n.visibility==="deal-products"?o=await A(t,{country:l,language:a,blockVisibility:e.blockVisibility,excludedProductGIDs:(e.excludedProductIds||[]).map(s=>`gid://shopify/Product/${s}`),selectedProductGIDs:(e.selectedProductIds||[]).map(s=>`gid://shopify/Product/${s}`),selectedCollectionGIDs:(e.selectedCollectionIds||[]).map(s=>`gid://shopify/Collection/${s}`)}):o=await A(t,{country:l,language:a,blockVisibility:n.visibility,excludedProductGIDs:(n.excludedProducts||[]).map(({id:s})=>s),selectedProductGIDs:(n.selectedProducts||[]).map(({id:s})=>s),selectedCollectionGIDs:(n.selectedCollections||[]).map(({id:s})=>s)}),o=o.slice(0,250);let c=await _(t,{country:l,language:a,productIds:o.map(s=>Number(s.split("/").pop())),useExternalMetafieldNamespace:!0});return c=c.filter(s=>s.availableForSale),c},ce=()=>({"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.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"}),ue=async(t,{productId:e,dealBlockId:l,country:a,language:n})=>{try{const o=[Number(e.split("/").pop())],c=new D(t.shopifyDomain,t.storefrontAccessToken),s=await q(c,{language:n,country:a,useExternalMetafieldNamespace:!0}),m=s.storefrontAccessToken?new D(s.shopifyDomain,s.storefrontAccessToken):c,[p,d]=await Promise.all([_(m,{country:a,language:n,productIds:o,useExternalMetafieldNamespace:!0}),x(m,{useExternalMetafieldNamespace:!0,useMetaobjects:s.featureFlags.storefront_metaobjects})]),i=p[0];if(!i)return null;const u=F(d,i);let r;if(l?(r=u.find($=>$.id===l||$.nanoId===l),r||(r=u[0])):r=u[0],!r)return null;const f=j(r),g=ee(r),[h,y,I,v]=await Promise.all([_(m,{country:a,language:n,productIds:g,useExternalMetafieldNamespace:!0}),L(m,f,300),oe(m,r,{country:a,language:n}),ce()]);return{product:i,dealBlock:r,config:s,otherProducts:h,mediaImages:y,collectionBreaksProducts:I??[],translations:v}}catch(o){return console.error(o),null}},b="kaching-bundles-block",C=1e4,de="https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js",me="https://bundles-integrations.kachingappz.app/kaching-bundles-block.js",k=new WeakSet,G=async t=>{const e=t.document;if(!t.customElements.get(b)){if(k.has(e))return S(t,b);k.add(e);try{await ge(t)}catch(l){throw k.delete(e),l}}},pe=()=>typeof window<"u"&&typeof window.__KACHING_DEV__<"u",fe=()=>pe()?de:me,ge=t=>{const e=t.document;return new Promise((l,a)=>{const n=fe();if(e.querySelector(`script[src="${n}"]`)){S(t,b).then(l).catch(a);return}const c=e.createElement("script");c.src=n,c.onload=()=>S(t,b).then(l).catch(a),c.onerror=()=>a(new Error("Failed to load script")),e.head.appendChild(c)})},S=(t,e)=>new Promise((l,a)=>{if(t.customElements.get(e)){l();return}Promise.race([t.customElements.whenDefined(e),new Promise((n,o)=>setTimeout(()=>o(new Error(`Custom element "${e}" failed to register within ${C}ms`)),C))]).then(()=>l()).catch(a)});class he 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 c,s;const e=++this.initializeId;if(this.cleanup(),this.hasAttribute("demo")){if(await G(window),e!==this.initializeId)return;this.renderInnerElement(N);return}const l=this.getAttribute("shop-domain"),a=this.getAttribute("storefront-token"),n=this.getAttribute("product-id");if(!l||!a||!n)return;const[o]=await Promise.all([ue({shopifyDomain:l,storefrontAccessToken:a},{productId:n,dealBlockId:this.getAttribute("deal-block-id")??void 0,country:((c=this.getAttribute("country"))==null?void 0:c.toUpperCase())??void 0,language:((s=this.getAttribute("language"))==null?void 0:s.toUpperCase())??void 0}),G(window)]);!o||e!==this.initializeId||this.renderInnerElement(o)}renderInnerElement(e){const{config:l,dealBlock:a,product:n,otherProducts:o,mediaImages:c,collectionBreaksProducts:s,translations:m}=e;this.innerElement=document.createElement("kaching-bundles-block"),this.innerElement.setAttribute("deal-block-id",a.id),this.innerElement.setAttribute("config",JSON.stringify(l)),this.innerElement.setAttribute("deal-block",JSON.stringify(a)),this.innerElement.setAttribute("media-images",JSON.stringify(c??[])),this.innerElement.setAttribute("product",JSON.stringify(n)),this.innerElement.setAttribute("other-products",JSON.stringify(o??[])),this.innerElement.setAttribute("collection-breaks-products",JSON.stringify(s??[])),this.innerElement.setAttribute("translations",JSON.stringify(m??{}));const p=this.getAttribute("selected-variant-id");this.innerElement.setAttribute("current-variant-id",String(p?p.split("/").pop():n.variants[0].id)),this.hasAttribute("compact")&&this.innerElement.setAttribute("compact","");const d=this.innerElement,i=()=>{if(this.innerElement!==d)return;const r=d.items();r&&this.dispatchEvent(new CustomEvent("items-changed",{detail:{items:r},bubbles:!0}))};this.handleItemsChanged=r=>{r.stopPropagation(),i()};const u=this.handleItemsChanged;d.addEventListener("kaching-bundles-block-loaded",()=>{this.innerElement===d&&(d.addEventListener("items-changed",u),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,l,a){l!==a&&this.isConnected&&(e==="product-id"||e==="country"||e==="language"?this.initialize():e==="selected-variant-id"&&this.innerElement&&a&&this.innerElement.setAttribute("current-variant-id",a.includes("/")?String(a.split("/").pop()):a))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}}customElements.define("kaching-bundle-component",he)})();
@@ -58,14 +58,14 @@ const N = {
58
58
  skipCart: !1,
59
59
  showVariantsForSingleQuantity: !1,
60
60
  preselectedDealBarId: "duo",
61
- cornerRadius: 8,
61
+ cornerRadius: 16,
62
62
  spacing: 1,
63
63
  selectedProductIds: [],
64
64
  selectedCollectionIds: [],
65
65
  excludedProductIds: [],
66
66
  excludedCollectionIds: [],
67
67
  colors: {
68
- background: { red: 255, green: 255, blue: 255, alpha: 1 },
68
+ background: { red: 245, green: 245, blue: 245, alpha: 1 },
69
69
  selectedBackground: { red: 255, green: 255, blue: 255, alpha: 1 },
70
70
  border: { red: 0, green: 0, blue: 0, alpha: 1 },
71
71
  blockTitle: { red: 0, green: 0, blue: 0, alpha: 1 },
@@ -73,7 +73,7 @@ const N = {
73
73
  subtitle: { red: 85, green: 85, blue: 85, alpha: 1 },
74
74
  price: { red: 0, green: 0, blue: 0, alpha: 1 },
75
75
  fullPrice: { red: 85, green: 85, blue: 85, alpha: 1 },
76
- labelBackground: { red: 238, green: 238, blue: 238, alpha: 1 },
76
+ labelBackground: { red: 171, green: 239, blue: 198, alpha: 1 },
77
77
  label: { red: 0, green: 0, blue: 0, alpha: 1 },
78
78
  badgeBackground: { red: 0, green: 0, blue: 0, alpha: 1 },
79
79
  badgeText: { red: 255, green: 255, blue: 255, alpha: 1 },
@@ -688,18 +688,18 @@ const N = {
688
688
  var c, s, m, p, d, i;
689
689
  const e = t.variants.nodes.map(
690
690
  ({ unitPriceMeasurement: u, ...r }) => {
691
- var f, h;
691
+ var f, g;
692
692
  return {
693
693
  id: Number(r.id.split("/").pop()),
694
694
  availableForSale: r.availableForSale,
695
695
  price: Math.round(Number(r.price.amount) * 100),
696
696
  compareAtPrice: r.compareAtPrice ? Math.round(Number(r.compareAtPrice.amount) * 100) : null,
697
- options: r.selectedOptions.map((g) => g.value),
697
+ options: r.selectedOptions.map((h) => h.value),
698
698
  imageId: r.image ? Number(r.image.id.split("/").pop()) : null,
699
699
  image: ((f = r.image) == null ? void 0 : f.url) || null,
700
- sellingPlans: ((h = r.sellingPlanAllocations) == null ? void 0 : h.nodes.map((g) => ({
701
- id: Number(g.sellingPlan.id.split("/").pop()),
702
- price: g.priceAdjustments.length > 0 ? Math.round(Number(g.priceAdjustments[0].price.amount) * 100) : Math.round(Number(r.price.amount) * 100)
700
+ sellingPlans: ((g = r.sellingPlanAllocations) == null ? void 0 : g.nodes.map((h) => ({
701
+ id: Number(h.sellingPlan.id.split("/").pop()),
702
+ price: h.priceAdjustments.length > 0 ? Math.round(Number(h.priceAdjustments[0].price.amount) * 100) : Math.round(Number(r.price.amount) * 100)
703
703
  }))) || [],
704
704
  inventoryManagement: null,
705
705
  // Storefront API does not return inventory management, only available in liquid
@@ -715,15 +715,15 @@ const N = {
715
715
  };
716
716
  }
717
717
  ), l = t.options.map((u, r) => {
718
- const f = u.optionValues.map((h) => {
719
- var g, b, y, I;
718
+ const f = u.optionValues.map((g) => {
719
+ var h, b, y, I;
720
720
  return {
721
- id: Number(h.id.split("/").pop()),
722
- defaultName: h.name,
723
- name: h.name,
721
+ id: Number(g.id.split("/").pop()),
722
+ defaultName: g.name,
723
+ name: g.name,
724
724
  swatch: {
725
- color: ((g = h.swatch) == null ? void 0 : g.color) || null,
726
- image: ((I = (y = (b = h.swatch) == null ? void 0 : b.image) == null ? void 0 : y.previewImage) == null ? void 0 : I.url) || null
725
+ color: ((h = g.swatch) == null ? void 0 : h.color) || null,
726
+ image: ((I = (y = (b = g.swatch) == null ? void 0 : b.image) == null ? void 0 : y.previewImage) == null ? void 0 : I.url) || null
727
727
  }
728
728
  };
729
729
  });
@@ -1001,11 +1001,11 @@ const de = async (t, e, { country: l, language: a }) => {
1001
1001
  (E) => E.id === l || E.nanoId === l
1002
1002
  ), r || (r = u[0])) : r = u[0], !r)
1003
1003
  return null;
1004
- const f = H(r), h = se(r), [g, b, y, I] = await Promise.all([
1004
+ const f = H(r), g = se(r), [h, b, y, I] = await Promise.all([
1005
1005
  k(m, {
1006
1006
  country: a,
1007
1007
  language: n,
1008
- productIds: h,
1008
+ productIds: g,
1009
1009
  useExternalMetafieldNamespace: !0
1010
1010
  }),
1011
1011
  V(m, f, 300),
@@ -1019,7 +1019,7 @@ const de = async (t, e, { country: l, language: a }) => {
1019
1019
  product: i,
1020
1020
  dealBlock: r,
1021
1021
  config: s,
1022
- otherProducts: g,
1022
+ otherProducts: h,
1023
1023
  mediaImages: b,
1024
1024
  collectionBreaksProducts: y ?? [],
1025
1025
  translations: I
@@ -1027,7 +1027,7 @@ const de = async (t, e, { country: l, language: a }) => {
1027
1027
  } catch (o) {
1028
1028
  return console.error(o), null;
1029
1029
  }
1030
- }, v = "kaching-bundles-block", C = 1e4, fe = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", he = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", P = /* @__PURE__ */ new WeakSet(), $ = async (t) => {
1030
+ }, v = "kaching-bundles-block", C = 1e4, fe = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", ge = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", P = /* @__PURE__ */ new WeakSet(), $ = async (t) => {
1031
1031
  const e = t.document;
1032
1032
  if (!t.customElements.get(v)) {
1033
1033
  if (P.has(e))
@@ -1039,7 +1039,7 @@ const de = async (t, e, { country: l, language: a }) => {
1039
1039
  throw P.delete(e), l;
1040
1040
  }
1041
1041
  }
1042
- }, ge = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", be = () => ge() ? fe : he, ye = (t) => {
1042
+ }, he = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", be = () => he() ? fe : ge, ye = (t) => {
1043
1043
  const e = t.document;
1044
1044
  return new Promise((l, a) => {
1045
1045
  const n = be();
@@ -1076,7 +1076,7 @@ class Ie extends HTMLElement {
1076
1076
  super(...arguments), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
1077
1077
  }
1078
1078
  static get observedAttributes() {
1079
- return ["selected-variant-id", "product-id"];
1079
+ return ["selected-variant-id", "product-id", "country", "language"];
1080
1080
  }
1081
1081
  async connectedCallback() {
1082
1082
  await this.initialize();
@@ -1167,7 +1167,7 @@ class Ie extends HTMLElement {
1167
1167
  ), this.handleItemsChanged = null), this.innerElement && (this.innerElement.remove(), this.innerElement = null);
1168
1168
  }
1169
1169
  attributeChangedCallback(e, l, a) {
1170
- l !== a && this.isConnected && (e === "product-id" ? this.initialize() : e === "selected-variant-id" && this.innerElement && a && this.innerElement.setAttribute(
1170
+ l !== a && this.isConnected && (e === "product-id" || e === "country" || e === "language" ? this.initialize() : e === "selected-variant-id" && this.innerElement && a && this.innerElement.setAttribute(
1171
1171
  "current-variant-id",
1172
1172
  a.includes("/") ? String(a.split("/").pop()) : a
1173
1173
  ));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kachingappz/bundles-js",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "main": "./dist/bundles-js.js",
6
6
  "module": "./dist/bundles-js.js",
@@ -16,30 +16,30 @@
16
16
  "dist",
17
17
  "README.md"
18
18
  ],
19
- "scripts": {
20
- "dev": "vite",
21
- "build": "vite build",
22
- "watch": "vite build --watch",
23
- "lint": "eslint .",
24
- "typecheck": "tsc --noEmit",
25
- "prettier:check": "prettier --check . --ignore-path ../.prettierignore",
26
- "prettier:fix": "prettier --write . --ignore-path ../.prettierignore"
27
- },
28
19
  "devDependencies": {
29
20
  "@eslint/js": "^9.21.0",
30
- "@kachingappz/bundles-storefront-api": "workspace:^",
31
- "@kachingappz/bundles-types": "workspace:^",
32
- "@kachingappz/kaching-bundles-block": "workspace:^",
33
21
  "@types/node": "^20.11.24",
34
22
  "eslint": "^9.21.0",
35
23
  "globals": "^15.15.0",
36
24
  "typescript": "~5.7.2",
37
25
  "typescript-eslint": "^8.24.1",
38
26
  "vite": "^6.2.0",
39
- "vite-plugin-dts": "^4.5.3"
27
+ "vite-plugin-dts": "^4.5.3",
28
+ "@kachingappz/bundles-storefront-api": "^0.1.0",
29
+ "@kachingappz/kaching-bundles-block": "^1.0.0",
30
+ "@kachingappz/bundles-types": "^0.1.0"
40
31
  },
41
32
  "description": "A vanilla JavaScript web component for integrating Kaching Bundles into any Shopify storefront.",
42
33
  "author": "Donatas Stundys",
43
34
  "license": "ISC",
44
- "homepage": "https://apps.shopify.com/bundle-deals?utm_source=npm&utm_medium=bundles-js"
45
- }
35
+ "homepage": "https://apps.shopify.com/bundle-deals?utm_source=npm&utm_medium=bundles-js",
36
+ "scripts": {
37
+ "dev": "vite",
38
+ "build": "vite build",
39
+ "watch": "vite build --watch",
40
+ "lint": "eslint .",
41
+ "typecheck": "tsc --noEmit",
42
+ "prettier:check": "prettier --check . --ignore-path ../.prettierignore",
43
+ "prettier:fix": "prettier --write . --ignore-path ../.prettierignore"
44
+ }
45
+ }