import{s as e}from"./stockStructures-DrcVCf6W.js";const t=(t,s=3)=>{if(!t)return[];return e.filter(e=>e.id!==t.id&&!e.soldOut).map(e=>{let s=0;e.category===t.category&&("Equestrian"===e.category?s+=120:s+=80),e.type===t.type&&(s+=100),"Equestrian"!==t.category&&"barn"!==t.type&&"runinshed"!==t.type||"Equestrian"!==e.category&&"barn"!==e.type&&"runinshed"!==e.type||(s+=90),t.style&&e.style&&(t.style.includes("horse")&&e.style.includes("run-in")||t.style.includes("run-in")&&e.style.includes("horse")||t.style.includes("quaker")&&e.style.includes("quaker"))&&(s+=70);const n=r(t.dimensions),i=r(e.dimensions);if(n&&i){const e=Math.abs(n.area-i.area);e<=50?s+=60:e<=100?s+=40:e<=200&&(s+=20)}if(t.price&&e.price){const r=Math.abs(t.price-e.price)/t.price;r<=.2?s+=30:r<=.4&&(s+=15)}return{structure:e,score:s}}).sort((e,t)=>t.score-e.score).slice(0,s).map(e=>e.structure)};function r(e){if(!e)return null;const t=e.match(/(\d+)['"]?\s*[xX]\s*(\d+)['"]?/);if(!t)return null;const r=parseInt(t[1],10),s=parseInt(t[2],10);return{width:r,depth:s,area:r*s}}export{t as f};