import{B as d}from"./layers-widget-CglxezVK.js";class u extends d{async getSimilarProducts(o,e={}){this.cancelRequest(),this.abortController=new AbortController;const n=this.abortController.signal;try{const r=this.getApiKey();if(!r)throw{code:"NO_API_KEY",message:"No API key provided. Please set an API key using Layers.widgetManager.setApiKey()."};const t={product_id:o,pagination:{page:e.page||1,limit:e.limit||24}};e.attributes&&e.attributes.length>0&&(t.attributes=e.attributes),e.filterGroup&&Object.keys(e.filterGroup).length>0&&(t.filter_group=e.filterGroup),e.facets&&e.facets.length>0&&(t.facets=e.facets),window.Layers?.widgetManager?.config?.debug&&console.debug("[Layers] API request payload:",t);const l=`${this.baseUrl}/search/product/${o}`,i=this.generateCacheKey(l,t);if(i){const a=this.getCachedResponse(i);if(a)return a}const s=await fetch(`${this.baseUrl}/search/product/${o}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-Storefront-Access-Token":r},signal:n,body:JSON.stringify(t)});if(!s.ok){const a=await s.json().catch(()=>({}));throw{code:a.code||`HTTP_ERROR_${s.status}`,message:a.message||`Failed to get similar products: ${s.statusText}`,status:s.status}}const h=await s.json(),c=this.transformResponse(h);return i&&this.setCachedResponse(i,c),c}catch(r){throw this.handleApiError(r)}}}export{u as S};