@metron-labs/quote-react 0.1.27 → 0.1.28
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/dist/embed/quote.js +20 -2
- package/dist/styles.css +19 -1
- package/package.json +1 -1
package/dist/embed/quote.js
CHANGED
|
@@ -6304,6 +6304,7 @@ Error generating stack: `+r.message+`
|
|
|
6304
6304
|
|
|
6305
6305
|
:where(.app-wrapper) .review-gate-item {
|
|
6306
6306
|
display: flex;
|
|
6307
|
+
flex-wrap: wrap;
|
|
6307
6308
|
align-items: center;
|
|
6308
6309
|
justify-content: space-between;
|
|
6309
6310
|
gap: 16px;
|
|
@@ -6332,6 +6333,7 @@ Error generating stack: `+r.message+`
|
|
|
6332
6333
|
|
|
6333
6334
|
:where(.app-wrapper) .review-gate-item__review {
|
|
6334
6335
|
display: flex;
|
|
6336
|
+
flex-wrap: wrap;
|
|
6335
6337
|
align-items: center;
|
|
6336
6338
|
justify-content: space-between;
|
|
6337
6339
|
gap: 16px;
|
|
@@ -6350,6 +6352,8 @@ Error generating stack: `+r.message+`
|
|
|
6350
6352
|
display: grid;
|
|
6351
6353
|
gap: 4px;
|
|
6352
6354
|
min-width: 0;
|
|
6355
|
+
/* Drops the action button below the copy when the row gets too narrow. */
|
|
6356
|
+
flex: 1 1 220px;
|
|
6353
6357
|
}
|
|
6354
6358
|
|
|
6355
6359
|
:where(.app-wrapper) .review-gate-item__copy strong {
|
|
@@ -6419,8 +6423,22 @@ Error generating stack: `+r.message+`
|
|
|
6419
6423
|
}
|
|
6420
6424
|
|
|
6421
6425
|
@media (max-width: 600px) {
|
|
6426
|
+
:where(.app-wrapper) .review-gate-modal-backdrop {
|
|
6427
|
+
padding: 12px;
|
|
6428
|
+
}
|
|
6429
|
+
|
|
6422
6430
|
:where(.app-wrapper) .review-gate-modal {
|
|
6423
|
-
padding:
|
|
6431
|
+
padding: 20px;
|
|
6432
|
+
border-radius: 20px;
|
|
6433
|
+
}
|
|
6434
|
+
|
|
6435
|
+
:where(.app-wrapper) .review-gate-modal__header h2 {
|
|
6436
|
+
font-size: 21px;
|
|
6437
|
+
}
|
|
6438
|
+
|
|
6439
|
+
:where(.app-wrapper) .review-gate-item,
|
|
6440
|
+
:where(.app-wrapper) .review-gate-item__review {
|
|
6441
|
+
gap: 12px;
|
|
6424
6442
|
}
|
|
6425
6443
|
}
|
|
6426
6444
|
|
|
@@ -6777,7 +6795,7 @@ C24 timber 4.8m`,value:o,onChange:Q=>l(Q.target.value),"aria-label":"Paste sched
|
|
|
6777
6795
|
<rect x="168" y="188" width="250" height="24" rx="12" fill="#aab5c0"/>
|
|
6778
6796
|
<rect x="168" y="232" width="220" height="24" rx="12" fill="#aab5c0"/>
|
|
6779
6797
|
</svg>
|
|
6780
|
-
`)}function Kr(e,t){return{lineId:t.lineId,description:e?.description||t.description||"(no description)",requestedDescription:t.description,productId:e?.product_id??"-",price:e?.price??null,priceBasis:e?.price_basis??null,unit:t.unit,uoi:e?.uoi??t.unit,uoiCount:e?.uoi_count??null,saleUnit:e?.conversion?.sale_unit??null,saleUnitQuantity:e?.conversion?.sale_unit_quantity??null,unitConversions:e?.conversion?.unit_conversions?.map(a=>({requestUom:a.request_uom,quantityPerSaleUnit:a.quantity_per_sale_unit,evidence:a.evidence,confidence:a.confidence})),pdpPhotoUrl:e?.pdp_photo_url??null,measurementsMm:e?.measurements_mm??[],conversionType:e?.conversion?.conversion_type??null,requestUomsSupported:e?.conversion?.request_uoms_supported??null,salesUomNormalised:e?.conversion?.sales_uom_normalised??null,salesUnitSize:e?.conversion?.sales_unit_size??null,salesUnitSizeUom:e?.conversion?.sales_unit_size_uom??null,coverageQty:e?.conversion?.coverage_qty??null,coverageUom:e?.conversion?.coverage_uom??null,itemsPerPallet:e?.conversion?.items_per_pallet??null,itemsPerPack:e?.conversion?.items_per_pack??null,itemsPerBox:e?.conversion?.items_per_box??null,itemsPerM2:e?.conversion?.items_per_m2??null,wasteFactorDefault:e?.conversion?.waste_factor_default??null,roundingRule:e?.conversion?.rounding_rule??null,derivedCoverageM2:e?.conversion?.derived_coverage_m2??null,derivedLengthM:e?.conversion?.derived_length_m??null,quoteQtyFormulaType:e?.conversion?.quote_qty_formula_type??null,conversionConfidence:e?.conversion?.conversion_confidence??null,conversionNotes:e?.conversion?.conversion_notes??null,calculatorWasteIncluded:t.calculatorWasteIncluded,qty:t.qty}}var Pv=e=>(e??"").trim().toLowerCase(),Z1={sqm:"m2","sq m":"m2","m\xB2":"m2",cbm:"m3","cu m":"m3",lm:"m","lin m":"m",metre:"m",meter:"m",each:"each",ea:"each",nr:"each",no:"each",item:"each",unit:"each",units:"each",pc:"each",pcs:"each",board:"sheet",bags:"bag",length:"length",lengths:"length",pallet:"pallet",pallets:"pallet"},K1=new Set(["sheet","length","box","bag","pack","roll","set","tub","each"]),Xv=new Set(["box","bag","pack","pallet","roll","set","tub"]),$v=(e,t)=>t==="ml"?e:["l","litre","litres"].includes(t)?e*1e3:null,Zv=(e,t)=>t==="g"?e:["kg","kilogram","kilograms"].includes(t)?e*1e3:["t","tonne","tonnes"].includes(t)?e*1e6:null,xi=e=>{let t=Pv(e);return Z1[t]??t},st=(e,t)=>{let a=xi(e),r=xi(t);return a.length>0&&a===r},P1=(e,t)=>{let a=Pv(t);return a?a.includes("round_up_1000")?Math.ceil(e):a.includes("allow_decimal")?Math.round(e*1e3)/1e3:a.includes("round_up")?Math.ceil(e):e:e},J1=e=>(e??"").split(",").map(t=>xi(t)).filter(Boolean),F1=(e,t)=>{let a=J1(e.requestUomsSupported);return!!(a.length===0||a.includes(t)||st(t,"pallet")&&e.itemsPerPallet!=null&&e.itemsPerPallet>0||st(t,"pack")&&e.itemsPerPack!=null&&e.itemsPerPack>0||st(t,"box")&&e.itemsPerBox!=null&&e.itemsPerBox>0)},Kv=(e,t)=>st(t,"pallet")?e.itemsPerPallet??null:st(t,"pack")?e.itemsPerPack??null:st(t,"box")?e.itemsPerBox??null:null,I1=(e,t,a)=>{if(!st(t,"m2"))return null;let r=e.description.match(/(\d+(?:[.,]\d+)?)\s*(m2|m²|sqm|sq\.?\s*m)\s*(?:\/|per)\s*([a-z]+)/i);if(!r||!st(r[3],a))return null;let n=Number.parseFloat(r[1].replace(",","."));return Number.isFinite(n)&&n>0?n:null};function ua(e,t){let a=e.qty,r=xi(e.unit)||"-",n=xi(e.saleUnit??e.salesUnitSizeUom??e.uoi??e.salesUomNormalised)||"-",i=e.saleUnitQuantity??e.salesUnitSize??e.uoiCount??1,o=t?.wasteFactorEnabled===!1?0:t?.wasteFactorOverride??e.wasteFactorOverride??e.wasteFactorDefault??0,l=e.sellUnitsOverride!=null&&Number.isFinite(e.sellUnitsOverride)&&e.sellUnitsOverride>0,c=l?e.sellUnitsOverride??null:null,p=v=>({requestedAmount:a,requestedUnit:r,salesUnitSize:e.salesUnitSize??e.uoiCount??null,sellUnit:n,calculatedSellUnits:null,requiredSellUnits:c,unitPrice:e.price,lineTotal:e.price!=null&&c!=null?e.price*c:null,calculation:c!=null?`${v} Manually set to ${c} ${n}.`:v,costingMode:"review"});if(!F1(e,r))return p("Requested unit is not supported by this catalogue conversion.");let f=null,b="review",d=e.roundingRule,h=`Quantity review required, initial request needed ${a} ${r}.`,w=1+o,M=I1(e,r,n),D=e.unitConversions?.find(v=>st(v.requestUom,r));if(!!e.saleUnit&&(st(r,n)||!!D||st(r,"each")&&!Xv.has(n)))if(st(r,n))f=a*w/i,b="direct",h=`${a} ${r}${o>0?` x ${w}`:""}`;else if(D){f=a*w/D.quantityPerSaleUnit,b="derived";let v=1/D.quantityPerSaleUnit,N=Math.round(v);h=st(n,"each")&&D.quantityPerSaleUnit<1&&Math.abs(v-N)<1e-9?`${a} ${r}${o>0?` x ${w}`:""} x ${N} per ${r}`:`${a} ${r}${o>0?` x ${w}`:""} / ${D.quantityPerSaleUnit} ${r} per ${n}`}else st(r,"each")&&!Xv.has(n)&&(f=a*w/i,b="derived",h=`${a} ${n}${o>0?` x ${w}`:""}`);else if(st(r,n)&&i>0)f=a*w/i,b="direct",h=o>0?`${a} ${r} x ${w} / ${i} ${n} per sell unit`:`${a} ${r} / ${i} ${n} per sell unit`;else if(st(r,"each")&&i>0&&K1.has(n))f=a*w/i,b="derived",h=o>0?`${a} each x ${w} / ${i} each per ${n}`:`${a} each / ${i} each per ${n}`;else if(Kv(e,r)!=null&&i>0){let v=Kv(e,r)??0;f=a*v*w/i,b="derived";let N=`${a} ${r} x ${v} each${o>0?` x ${w}`:""}`;h=i===1&&st(n,"each")?N:`${N} / ${i} each per ${n}`}else if(M!=null)f=a*w/M,b="derived",d??(d="round_up_each"),h=`${a} m2 x ${w} / ${M} m2 per ${n} (from product description)`;else if(e.conversionType==="basket_line_unit")i>0&&(f=a*w/i,b="derived",h=`${a} ${r}${o>0?` x ${w}`:""} / ${i} ${r} per ${n}`);else{if(e.conversionType==="count_only")return p(`Quantity review required, initial request needed ${a} ${r}.`);if(["area_from_dims","explicit_coverage_area","roll_area"].includes(e.conversionType??"")){let v=e.coverageQty??e.derivedCoverageM2??null;st(r,"m2")&&v!=null&&v>0&&(f=a*w/v,b="derived",h=`${a} m2 x ${w} / ${v} m2 per ${n}`)}else if(e.conversionType==="count_per_area"){let v=e.coverageQty??null;st(r,"m2")&&v!=null&&v>0?(f=a/v,b="derived",h=`${a} m2 / ${v} m2 per sell unit`):st(r,"m2")&&e.itemsPerM2!=null&&e.itemsPerM2>0&&i>0&&(f=a*e.itemsPerM2*w/i,b="derived",h=`${a} m2 x ${e.itemsPerM2} ${n}/m2 x ${w} / ${i}`)}else if(e.conversionType==="length_from_dims"){let v=e.coverageQty??e.derivedLengthM??null;st(r,"m")&&v!=null&&v>0&&(f=a*w/v,b="derived",h=`${a} m x ${w} / ${v} m per ${n}`)}else if(e.conversionType==="volume_from_description"){let v=$v(a,r),N=$v(e.coverageQty??0,xi(e.coverageUom));v!=null&&N!=null&&N>0&&(f=v*w/N,b="derived",h=`${a} ${r} x ${w} / ${e.coverageQty} ${e.coverageUom} per ${n}`)}else if(e.conversionType==="weight_from_description"){let v=Zv(a,r),N=Zv(e.coverageQty??0,xi(e.coverageUom));v!=null&&N!=null&&N>0&&(f=v*w/N,b="derived",h=`${a} ${r} x ${w} / ${e.coverageQty} ${e.coverageUom} per ${n}`)}else if(e.conversionType==="same_unit_volume"){let v=e.coverageQty??null;st(r,"m3")&&v!=null&&v>0&&(f=a/v,b="derived",h=`${a} m3 / ${v} m3 per ${n}`)}}if(f==null||!Number.isFinite(f)||f<0)return p(`Quantity review required, initial request needed ${a} ${r}.`);let u=P1(f,d),g=l?e.sellUnitsOverride??null:u;return{requestedAmount:a,requestedUnit:r,salesUnitSize:i,sellUnit:n,calculatedSellUnits:u,requiredSellUnits:g,unitPrice:e.price,lineTotal:e.price!=null&&g!=null?e.price*g:null,calculation:l?`${h} = ${u} ${n} (manually set to ${g})`:`${h} = ${g} ${n}`,costingMode:b}}var Jv=()=>import("./xlsx-K4MOA2QM.js"),Wo=["Source Line ID","Split Line ID","Description","Section","Qty","Unit","Procurement intent","Procurement aliases","Build-up type","Layer count","Total thickness (mm)","Installation clues","System clues","Component requirements","Technical classification","Include in quote","Approval required","Approval type","Missing information","Adjudicator confidence","Decision reason","Selected candidate ID","Selected candidate description","Price basis","Price","Line total","Confidence","Status"],W1=Wo.indexOf("Line total");function e_(e){return e.unmatchable?"Not matched (labour/plant/referential)":e.decision?.include_in_quote===!0&&e.decision.approval_required===!0?"Approval required":e.decision?.include_in_quote===!0?"Quoted":e.decision?.technical_classification==="no_suitable_candidate"?"No suitable candidate":(e.best,"No match")}async function Fv(e){let t=await Jv(),a=t.utils.book_new(),r=new Date().toISOString().slice(0,10),n=[Wo],i=0;for(let c of e){let{item:p,best:f,qty:b,band:d,unmatchable:h,decision:w}=c,M=[p.section,p.subsection,p.subheading].filter(Boolean).join(" / "),D=!h&&f?.price!=null?f.price*b:null;D!=null&&(i+=D),n.push([p.source_line_id,p.line_id,p.description_original||"(no description)",M,b,p.unit,p.procurement_intent||"-",p.procurement_aliases.join(", "),p.build_up_type,p.layer_count,p.total_required_thickness_mm,p.installation_clues.join(", "),p.system_clues.join(", "),p.component_requirements.join(", "),w?.technical_classification??"",w?.include_in_quote==null?"":w.include_in_quote?"yes":"no",w?.approval_required==null?"":w.approval_required?"yes":"no",w?.approval_type??"",w?.missing_information.join(", ")??"",w?.confidence??"",w?.reason??"",h?"-":f?.product_id??w?.selected_candidate_id??"-",h?"-":f?.description??"-",h?"-":f?.price_basis??"-",h?null:f?.price??null,D,h?"-":d,e_(c)])}n.push(Array(Wo.length).fill(null));let o=Array(Wo.length).fill(null);o[0]="Estimated total",o[W1]=i,n.push(o),n.push(["DISCLAIMER: These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence.",...Array(Wo.length-1).fill(null)]);let l=t.utils.aoa_to_sheet(n);l["!cols"]=[{wch:12},{wch:12},{wch:44},{wch:24},{wch:8},{wch:8},{wch:28},{wch:28},{wch:16},{wch:10},{wch:12},{wch:24},{wch:24},{wch:24},{wch:22},{wch:14},{wch:14},{wch:18},{wch:24},{wch:16},{wch:48},{wch:16},{wch:40},{wch:10},{wch:10},{wch:12},{wch:11},{wch:26}],t.utils.book_append_sheet(a,l,"Schedule match"),t.writeFile(a,`schedule-quote-${r}.xlsx`)}var Io=["Product ID","Description","Costing mode","Required amount","Req unit","Sell unit size","Sell unit","Required sell units","Unit price","Line total"];async function Iv(e,t){let a=await Jv(),r=a.utils.book_new(),n=new Date().toISOString().slice(0,10),i=t?[["Account",t.name+" ("+t.id+")"],[],Io]:[Io],o=0;for(let p of e){let f=ua(p),b=f.lineTotal;b!=null&&(o+=b),i.push([p.productId,p.description,f.costingMode,f.requestedAmount,xa(f.requestedUnit),f.salesUnitSize,xa(f.sellUnit),f.requiredSellUnits,f.unitPrice,b])}i.push(Array(Io.length).fill(null));let l=Array(Io.length).fill(null);l[0]="Estimated total",l[Io.length-1]=o,i.push(l);let c=a.utils.aoa_to_sheet(i);c["!cols"]=[{wch:14},{wch:48},{wch:12},{wch:14},{wch:10},{wch:14},{wch:10},{wch:16},{wch:12},{wch:14}],a.utils.book_append_sheet(r,c,"Basket"),a.writeFile(r,t?`basket-${t.id}-${n}.xlsx`:`basket-${n}.xlsx`)}var s=Y(ae()),fd="__none__",el=24,t_=[{dir:"asc",label:"Description (A-Z)"},{dir:"desc",label:"Description (Z-A)"}];function aw(e){return e==null?"low":e>=.7?"high":e>=.5?"medium":"low"}var a_=e=>e.attrs.supply_nature==="labour_only"||e.attrs.supply_nature==="plant"||e.flags.includes("referential");function r_(e,t){if(t!==fd){if(t)return e?.candidates.find(a=>a.product_id===t);if(e?.decision?.selected_candidate_id!=null)return e.candidates.find(a=>a.product_id===e.decision.selected_candidate_id)}}function Wv(e){return{product_id:e.productId,description:e.description,source_list:null,price:e.price,price_basis:e.priceBasis,uoi_count:e.uoiCount??null,uoi:e.uoi,pdp_photo_url:e.pdpPhotoUrl??null,measurements_mm:e.measurementsMm??[],conversion:{sale_unit:e.saleUnit,sale_unit_quantity:e.saleUnitQuantity,unit_conversions:e.unitConversions?.map(t=>({request_uom:t.requestUom,quantity_per_sale_unit:t.quantityPerSaleUnit,evidence:t.evidence,confidence:t.confidence})),sales_uom_normalised:e.salesUomNormalised,conversion_type:e.conversionType,request_uoms_supported:e.requestUomsSupported,sales_unit_size:e.salesUnitSize,sales_unit_size_uom:e.salesUnitSizeUom,coverage_qty:e.coverageQty,coverage_uom:e.coverageUom,items_per_pallet:e.itemsPerPallet,items_per_pack:e.itemsPerPack,items_per_box:e.itemsPerBox,items_per_m2:e.itemsPerM2,waste_factor_default:e.wasteFactorDefault,rounding_rule:e.roundingRule,derived_coverage_m2:e.derivedCoverageM2,derived_length_m:e.derivedLengthM,quote_qty_formula_type:e.quoteQtyFormulaType,conversion_confidence:e.conversionConfidence,conversion_notes:e.conversionNotes},scores:{dimension:0,grade:0,brand:0,fuzzy:0,bm25:0,overall:0},method:"manual_cart_selection"}}function i_(e,t){let a={...e,qty:t.qty,sellUnitsOverride:t.sellUnitsOverride??null};return t.productId!==e.productId||t.conversionType!=="basket_line_unit"?a:{...a,saleUnit:t.saleUnit,saleUnitQuantity:t.saleUnitQuantity,unitConversions:t.unitConversions,conversionType:t.conversionType,requestUomsSupported:t.requestUomsSupported,salesUomNormalised:t.salesUomNormalised,salesUnitSize:t.salesUnitSize,salesUnitSizeUom:t.salesUnitSizeUom,coverageQty:t.coverageQty,coverageUom:t.coverageUom,itemsPerPallet:t.itemsPerPallet,itemsPerPack:t.itemsPerPack,itemsPerBox:t.itemsPerBox,itemsPerM2:t.itemsPerM2,wasteFactorDefault:t.wasteFactorDefault,roundingRule:t.roundingRule,derivedCoverageM2:t.derivedCoverageM2,derivedLengthM:t.derivedLengthM,quoteQtyFormulaType:t.quoteQtyFormulaType,conversionConfidence:t.conversionConfidence,conversionNotes:t.conversionNotes}}function n_(e){return e?e.replace(/_/g," "):"not stated"}function o_({band:e}){return(0,s.jsx)("span",{className:`status-dot status-dot--${e}`,title:e,children:(0,s.jsx)("span",{className:"status-dot__mark"})})}function Tn(e,t){if(e==null)return"-";let a=Fo(t);return a?`${e.toFixed(2)} ${a}`:e.toFixed(2)}function gd(e){return e&&e.length>0?e.join(" x "):"-"}function l_(e){return e==null?"-":Number.isInteger(e/1e3)?`${e/1e3}m`:`${(e/1e3).toFixed(1)}m`}function Mn(e){let t=(e??[]).map(a=>a.trim()).filter(Boolean);return t.length>0?t.join(", "):"-"}function Pr(e,t){return e.customer_display_label?.trim()||e.description_original||"(no description)"}var ew=[{background:"#fff7ed",borderColor:"#fdba74",color:"#9a3412"},{background:"#eff6ff",borderColor:"#93c5fd",color:"#1d4ed8"},{background:"#ecfeff",borderColor:"#67e8f9",color:"#0f766e"},{background:"#f0fdf4",borderColor:"#86efac",color:"#166534"},{background:"#fdf4ff",borderColor:"#f0abfc",color:"#a21caf"}];function s_(e){let t=new Map;return[...new Set(e.filter(mr).map(r=>r.linked_group_id))].forEach((r,n)=>{let i=n%26;t.set(r,{token:String.fromCharCode(65+i),bubbleStyle:ew[n%ew.length]})}),t}function mr(e){return!1}function zn(e){if(!e.linked_group_id)return null;let t=e.linked_group_label||"Linked group",a=e.linked_group_role==="anchor"?"anchor":e.linked_group_role==="dependent"?"dependent":"member",r=e.linked_group_shared_width_mm!=null?`, ${e.linked_group_shared_width_mm}mm family`:"";return`${t} (${a}${r})`}function md({meta:e}){return e?(0,s.jsx)("span",{className:"results-linked-pill",style:e.bubbleStyle,children:`Link ${e.token}`}):null}function c_(e,t,a){let r=t?.rerank?.recommendedCandidateIds??[];if(r.length===0){let o=e.slice(0,5),l=o.some(c=>c.product_id===a)?void 0:e.find(c=>c.product_id===a);return l?[...o,l]:o}let n=new Map(e.map(o=>[o.product_id,o])),i=r.map(o=>n.get(o)).filter(o=>o!=null);if(a&&!i.some(o=>o.product_id===a)){let o=n.get(a);o&&i.unshift(o)}return[...new Map(i.map(o=>[o.product_id,o])).values()].slice(0,5)}function Zs(e){let t=e?.rerank?.recommendedCandidateIds??[];if(t.length===0||!e)return[];let a=new Map(e.candidates.map(r=>[r.product_id,r]));return t.map(r=>a.get(r)).filter(r=>r!=null)}function Ks(e){if(e>=6e4){let t=Math.floor(e/6e4),a=Math.round(e%6e4/1e3);return a===60?`${t+1}m`:`${t}m ${a}s`}return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}s`:`${e}ms`}function u_({processStages:e,llmCalls:t,totalDurationMs:a,llmDurationMs:r,llmCallCount:n}){let i=[...t].sort((l,c)=>c.durationMs-l.durationMs).slice(0,12),o=Math.max(0,t.length-i.length);return(0,s.jsxs)("div",{className:"results-detail-block",style:{marginBottom:18},children:[(0,s.jsx)("h3",{style:{margin:"0 0 12px"},children:"Pipeline timings"}),(0,s.jsxs)("div",{className:"results-summary",style:{marginBottom:12},children:[(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:Ks(a)})," total"]}),(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:n})," LLM calls"]}),(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:Ks(r)})," LLM time"]})]}),(0,s.jsxs)("table",{className:"score-breakdown-table",style:{marginBottom:14},children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Process stage"}),(0,s.jsx)("th",{children:"Duration"})]})}),(0,s.jsx)("tbody",{children:e.map((l,c)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:l.label}),(0,s.jsx)("td",{children:Ks(l.durationMs)})]},`${l.key}-${c}`))})]}),t.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h4",{style:{margin:"0 0 10px"},children:"LLM calls"}),(0,s.jsxs)("table",{className:"score-breakdown-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Call"}),(0,s.jsx)("th",{children:"Duration"})]})}),(0,s.jsx)("tbody",{children:i.map((l,c)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:l.label}),(0,s.jsx)("td",{children:Ks(l.durationMs)})]},`${l.key}-${c}`))})]}),o>0&&(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Showing slowest ",i.length," of ",t.length," LLM calls."]})]})]})}function p_({queries:e}){return e.length===0?null:(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsx)("h4",{style:{margin:"0 0 12px"},children:"Retrieval by procurement query"}),e.map((t,a)=>(0,s.jsxs)("div",{style:{marginBottom:16},children:[(0,s.jsxs)("div",{className:"results-row-meta",style:{marginBottom:6},children:["Query: ",(0,s.jsx)("strong",{children:t.query})]}),t.candidates.length===0?(0,s.jsx)("p",{className:"results-empty-hint",children:"No candidates returned for this query."}):(0,s.jsxs)("table",{className:"score-breakdown-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Product"}),(0,s.jsx)("th",{children:"Dims (mm)"}),(0,s.jsx)("th",{children:"Unit"}),(0,s.jsx)("th",{children:"bm25"})]})}),(0,s.jsx)("tbody",{children:t.candidates.slice(0,5).map((r,n)=>(0,s.jsxs)("tr",{children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("div",{children:r.description}),(0,s.jsx)("div",{className:"results-row-meta",children:r.product_id})]}),(0,s.jsx)("td",{children:gd(r.measurements_mm)}),(0,s.jsx)("td",{children:Fo(r.price_basis)||"-"}),(0,s.jsx)("td",{children:r.bm25.toFixed(2)})]},`${r.product_id}-${n}`))})]})]},`${t.query}-${a}`))]})}function tw({item:e,result:t}){let a=t?.retrieval_debug.map(n=>n.query).filter(Boolean)??[],r=[["Procurement intent",e.procurement_intent||"-"],["Procurement aliases",Mn(e.procurement_aliases)],["Retrieval queries",Mn(a)],["Category",e.attrs.category||"-"],["Fine category",e.attrs.category_fine||"-"],["Brand",e.attrs.brand||"-"],["Material",e.attrs.material||"-"],["Grade / standard",e.attrs.grade_standard||"-"],["Treatment",e.attrs.treatment||"-"],["Supply nature",e.attrs.supply_nature||"-"],["Measurements (mm)",gd(e.attrs.measurements_mm)],["Stock length",l_(e.attrs.stock_length_mm)],["Matching mode",e.matching_mode||"-"],["Build-up type",e.build_up_type||"-"],["Layer count",e.layer_count!=null?String(e.layer_count):"-"],["Required thickness (mm)",e.total_required_thickness_mm!=null?String(e.total_required_thickness_mm):"-"],["Allowed layer thicknesses (mm)",e.acceptable_layer_thicknesses_mm.length>0?e.acceptable_layer_thicknesses_mm.join(", "):"-"],["Installation clues",Mn(e.installation_clues)],["System clues",Mn(e.system_clues)],["Component requirements",Mn(e.component_requirements)],["Linked group",zn(e)||"-"],["Flags",Mn(e.flags)]];return(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsx)("h4",{style:{margin:"0 0 12px"},children:"Search context"}),(0,s.jsx)("dl",{className:"results-detail-grid",children:r.map(([n,i])=>(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:n}),(0,s.jsx)("dd",{children:i})]},n))})]})}function d_({item:e}){let t=e.decomposition_debug;return t?(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsx)("h4",{style:{margin:"0 0 12px"},children:"Decomposition"}),(0,s.jsxs)("dl",{className:"results-detail-grid",children:[(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Attempted"}),(0,s.jsx)("dd",{children:t.attempted?"yes":"no"})]}),(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Applied"}),(0,s.jsx)("dd",{children:t.applied?"yes":"no"})]}),(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Returned items"}),(0,s.jsx)("dd",{children:t.returned_item_count??"-"})]}),(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Reason"}),(0,s.jsx)("dd",{children:t.reason||"-"})]}),(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Returned intents"}),(0,s.jsx)("dd",{children:t.items.length>0?t.items.map(a=>`${a.intent}${a.inherits_quantity?" (inherits qty)":""}`).join(", "):"-"})]})]})]}):null}function m_({result:e}){let t=e?.adjudication_debug;if(!t)return null;let a=[["Dependent rerank applied",t.dependent_rerank_applied?"yes":"no"],["Linked parent selected product",t.linked_parent_selected_candidate_description||t.linked_parent_selected_candidate_id||"-"],["Dimension reason overridden",t.dimension_reason_overridden?"yes":"no"]];return(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsx)("h4",{style:{margin:"0 0 12px"},children:"Adjudication context"}),(0,s.jsx)("dl",{className:"results-detail-grid",children:a.map(([r,n])=>(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:r}),(0,s.jsx)("dd",{children:n})]},r))}),t.rerank_line_item_input?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h5",{style:{margin:"12px 0 8px"},children:"Rerank input"}),(0,s.jsx)("pre",{className:"results-pre",children:JSON.stringify(t.rerank_line_item_input,null,2)})]}):null]})}function f_({item:e,decision:t,result:a,showRetrievalDebug:r,reviewOnly:n=!1,linkedGroupMeta:i}){if(!t)return null;let o=t.technical_classification==="no_suitable_candidate"?"Exact match not found:":`AI review (${t.confidence??"confidence not stated"}):`;return n?t.reason?(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsxs)("p",{className:"basket-calc-text basket-calc-text--review",children:[(0,s.jsx)("strong",{children:o}),"\xA0",t.reason]}),mr(e)?(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Linked context: ",i?`Link ${i.token} - `:"",zn(e)]}):null]}):null:!t.reason&&!r?(0,s.jsx)(tw,{item:e,result:a}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tw,{item:e,result:a}),r&&(0,s.jsx)(d_,{item:e}),r&&(0,s.jsx)(m_,{result:a}),t.reason&&(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsxs)("p",{className:"basket-calc-text basket-calc-text--review",children:[(0,s.jsx)("strong",{children:o}),"\xA0",t.reason]}),mr(e)?(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Linked context: ",i?`Link ${i.token} - `:"",zn(e)]}):null]}),r&&(0,s.jsx)(p_,{queries:a?.retrieval_debug??[]})]})}function g_({item:e,candidates:t,result:a,decision:r,unmatchable:n,selectedProductId:i,detailMode:o,onPick:l,onClear:c,showAll:p=!1,internal:f=!1,debugEnabled:b=!1,forceReviewNote:d=!1,linkedGroupMeta:h}){let w=f||o==="detailed",M=b&&o==="detailed",D=w||d?(0,s.jsx)(f_,{item:e,decision:r,result:a,showRetrievalDebug:M,reviewOnly:d&&!w,linkedGroupMeta:h}):null;if(n)return(0,s.jsxs)(s.Fragment,{children:[D,(0,s.jsx)("p",{className:"results-empty-hint",children:"Classified as labour/plant or referencing another line item - skipped by design."})]});if(t.length===0)return(0,s.jsxs)(s.Fragment,{children:[D,(0,s.jsx)("p",{className:"results-empty-hint",children:"No candidates were returned for this line item."})]});let m=p||f||o==="detailed"?t:c_(t,a,i);return(0,s.jsxs)(s.Fragment,{children:[D,(0,s.jsxs)("table",{className:"score-breakdown-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Product"}),(0,s.jsx)("th",{children:"Dims (mm)"}),(0,s.jsx)("th",{children:"Price"}),M&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("th",{children:"dimension"}),(0,s.jsx)("th",{children:"grade"}),(0,s.jsx)("th",{children:"brand"}),(0,s.jsx)("th",{children:"fuzzy"}),(0,s.jsx)("th",{children:"bm25"}),(0,s.jsx)("th",{children:"overall"})]}),(0,s.jsx)("th",{"aria-label":"Actions"})]})}),(0,s.jsx)("tbody",{children:m.map((u,g)=>{let v=u.product_id===i;return(0,s.jsxs)("tr",{className:v?"score-breakdown-row--best":"",children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("div",{children:u.description}),(0,s.jsx)("div",{className:"results-row-meta",children:u.product_id})]}),(0,s.jsx)("td",{children:(0,s.jsx)("span",{className:"unit-badge",children:gd(u.measurements_mm??u.debug?.candidate.measurements_mm)})}),(0,s.jsx)("td",{children:Tn(u.price,u.price_basis)}),M&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{children:(u.scores?.dimension??0).toFixed(2)}),(0,s.jsx)("td",{children:(u.scores?.grade??0).toFixed(2)}),(0,s.jsx)("td",{children:(u.scores?.brand??0).toFixed(2)}),(0,s.jsx)("td",{children:(u.scores?.fuzzy??0).toFixed(2)}),(0,s.jsx)("td",{children:(u.scores?.bm25??0).toFixed(2)}),(0,s.jsx)("td",{children:(0,s.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,s.jsx)(o_,{band:aw(u.scores?.overall)}),(0,s.jsx)("span",{className:"results-overall-cell",children:(u.scores?.overall??0).toFixed(2)})]})})]}),(0,s.jsx)("td",{children:(0,s.jsxs)("label",{className:"switch-toggle",title:v?"Currently selected":"Use this candidate",children:[(0,s.jsx)("input",{type:"checkbox",checked:v,onChange:()=>{v?c?.():l(u)},"aria-label":v?`${u.description} selected`:`Use ${u.description}`}),(0,s.jsx)("span",{className:"switch-toggle-track","aria-hidden":"true"})]})})]},`${u.product_id}-${g}`)})})]})]})}function hd({scheduleResult:e,onStartOver:t,cart:a,onAddToCart:r,onRemoveFromCart:n,onGoToBasket:i,cartSeeded:o,onCartSeeded:l,reviewGateComplete:c,onReviewGateComplete:p,internal:f=!1}){let b=!f&&Qs()==="QZA6-MRA4",d=b?"quote":"basket",{results:h,lineItems:w,parseReport:M,timings:D}=e,[m,u]=(0,we.useState)({}),g=Cn(),[v,N]=(0,we.useState)({}),[A,T]=(0,we.useState)({}),[z,G]=(0,we.useState)(""),[K,fe]=(0,we.useState)(null),[Te,Ye]=(0,we.useState)(1),[Ve,it]=(0,we.useState)(!1);(0,we.useEffect)(()=>{it(new URLSearchParams(window.location.search).get("debug")==="1")},[]);let[pe,Q]=(0,we.useState)("simple"),[ce,xe]=(0,we.useState)(f?"list":"tile"),[ye,ee]=(0,we.useState)(!1),[se,Me]=(0,we.useState)(null),[_e,et]=(0,we.useState)(""),[Ht,Tt]=(0,we.useState)([]),[tt,ct]=(0,we.useState)(!1),[He,E]=(0,we.useState)(null),[x,R]=(0,we.useState)(!1),[I,ue]=(0,we.useState)(null),ve=(0,we.useRef)(null),[Se,k]=(0,we.useState)(new Set),[j,O]=(0,we.useState)(new Set),[ne,W]=(0,we.useState)(!1);(0,we.useEffect)(()=>{Ye(1)},[z,K,ce]);let C=new Map(h.map(_=>[_.line_id,_])),V=s_(w),X=w.map(_=>{let L=C.get(_.line_id),ze=L?.decision,zt=a_(_),Ze=m[_.line_id],It=r_(L,Ze),zi=a[_.line_id],Ow=Ze===fd?void 0:v[_.line_id]??(zi&&zi.productId!==It?.product_id?Wv(zi):It),Wd=zt?void 0:Ow,Lw=_.qty??0;return{item:_,result:L,decision:ze,unmatchable:zt,best:Wd,qty:Lw,band:aw(Wd?.scores?.overall)}}),me=0,Ce=0;for(let _ of X)_.unmatchable||_.decision?.include_in_quote!==!0||!_.best||(_.best.price!=null?me+=_.best.price*_.qty:Ce+=1);let dt=_=>!_.unmatchable&&!_.best&&_.decision?.technical_classification!=="no_suitable_candidate"&&Zs(_.result).length>0,je=_=>_.best??Zs(_.result)[0],Ir=X.filter(_=>!_.unmatchable&&!_.best).filter(_=>!j.has(_.item.line_id)),ll=X.filter(_=>j.has(_.item.line_id)),Ea=X;if(z.trim()){let _=z.trim().toLowerCase();Ea=Ea.filter(L=>L.item.description_original?.toLowerCase().includes(_)||je(L)?.description?.toLowerCase().includes(_))}if(K){let _=K==="asc"?1:-1;Ea=[...Ea].sort((L,ze)=>_*(L.item.description_original||"").localeCompare(ze.item.description_original||""))}let hr=Math.max(1,Math.ceil(Ea.length/el)),Jt=Math.min(Te,hr),Ft=Ea.slice((Jt-1)*el,Jt*el),Yd=Ft.filter(_=>!_.unmatchable&&_.best),Vd=Ft.filter(_=>dt(_)),gc=Ft.filter(_=>!_.unmatchable&&(_.best||dt(_))),Xd=Ft.filter(_=>_.unmatchable||!_.best&&!dt(_)),J=se?X.find(_=>_.item.line_id===se)??null:null,Tw=!f&&!c&&!J&&Ir.length>0,Gn=(0,we.useRef)(null),Qn=()=>{let _=ve.current;if(!_)return;let{top:L,left:ze,width:zt,height:Ze}=_.getBoundingClientRect(),zi=_.querySelector(".bom-toolbar-btn")?.closest("td")?.getBoundingClientRect().left;ue({top:L,left:ze,width:zi?zi-ze:zt,height:Ze})};(0,we.useEffect)(()=>(window.addEventListener("scroll",Qn,!0),window.addEventListener("resize",Qn),()=>{window.removeEventListener("scroll",Qn,!0),window.removeEventListener("resize",Qn)})),(0,we.useEffect)(()=>{let _=L=>{Gn.current&&!L.composedPath().includes(Gn.current)&&Gn.current.removeAttribute("open")};return document.addEventListener("click",_),()=>document.removeEventListener("click",_)},[]);let Ei=_=>{Me(_),et("")},zw=()=>{if(!se)return;let _=a[se];if(_){u(L=>({...L,[se]:_.productId})),N(L=>({...L,[se]:Wv(_)}));return}u(L=>{let ze={...L};return delete ze[se],ze}),N(L=>{let ze={...L};return delete ze[se],ze})},br=(_=!1)=>{let L=se?a[se]:void 0;!_&&L&&J?.best&&L.productId!==J.best.product_id&&!window.confirm("You have selected a new product. Leave without updating it?")||(_||zw(),Me(null),W(!1))},Aw=_=>{if(k(L=>new Set(L).add(_)),Ir.some(L=>L.item.line_id!==_)){br(!0);return}p(),br(!0)},Rw=_=>{if(hc(_),O(L=>new Set(L).add(_)),Ir.some(L=>L.item.line_id!==_)){br(!0);return}p(),br(!0)},Uw=()=>{O(_=>new Set([..._,...Ir.map(L=>L.item.line_id)])),p()},$d=()=>{J?.best&&(Kd(J.item.line_id,J.best),r(Mi(J)),ne?Aw(J.item.line_id):br(!0))},Zd=Xd.length>0?(0,s.jsxs)("section",{className:"results-tile-section results-tile-section--unmatched","aria-label":"Items requiring matching",children:[(0,s.jsxs)("div",{className:"results-tile-section__head",children:[(0,s.jsx)("h3",{children:"Require Matching"}),(0,s.jsx)("p",{children:"We couldn\u2019t confidently match these to a product. Open one to pick from the closest options."})]}),(0,s.jsx)("div",{className:"results-unmatched-list",children:Xd.map(_=>{let{item:L,qty:ze}=_;return(0,s.jsxs)("button",{type:"button",className:"results-unmatched-card",onClick:()=>Ei(L.line_id),children:[(0,s.jsx)("span",{className:"results-unmatched-card__main",children:(0,s.jsx)("span",{className:"results-unmatched-card__title",children:Pr(L,w)})}),(0,s.jsx)("span",{className:"bom-toolbar-btn results-unmatched-card__prompt",children:"Review"})]},L.line_id)})})]}):null,hc=_=>{u(L=>({...L,[_]:fd})),N(L=>({...L,[_]:void 0})),T(L=>({...L,[_]:void 0})),n(_)},bc=(_,L)=>{u(ze=>({...ze,[_]:L.product_id})),N(ze=>({...ze,[_]:L}))},Kd=(_,L)=>{L.method==="catalogue_search"&&T(ze=>({...ze,[_]:L}))};function ax(){g("downloaded",{type:"schedule",lines:X.length}),Fv(X.map(({item:_,best:L,qty:ze,band:zt,unmatchable:Ze,decision:It})=>({item:_,best:L,qty:ze,band:zt,unmatchable:Ze,decision:It})))}function Mi(_){let L=_.best??Zs(_.result)[0];return Kr(L,{lineId:_.item.line_id,description:_.item.description_original,unit:_.item.unit,qty:_.qty})}(0,we.useEffect)(()=>{if(!o){for(let _ of X)!_.unmatchable&&_.best&&r(Mi(_));l()}},[o]),(0,we.useEffect)(()=>{for(let _ of X){let L=a[_.item.line_id];if(!L)continue;let ze=Mi(_);r(i_(ze,L))}},[e]),(0,we.useEffect)(()=>{if(!se){Tt([]),E(null),ct(!1);return}let _=_e.trim();if(!_){Tt([]),E(null),ct(!1);return}let L=!1,ze=window.setTimeout(async()=>{try{ct(!0),E(null);let zt=await fetch(Bt(`/api/catalogue/search?q=${encodeURIComponent(_)}`),{headers:wi()}),Ze=await Zt(zt);if(!zt.ok)throw new Error(Ze?.error||Ze?.message||"Failed to search catalogue");L||Tt(Array.isArray(Ze?.items)?Ze.items:[])}catch(zt){L||(Tt([]),E(zt?.message||"Failed to search catalogue"))}finally{L||ct(!1)}},250);return()=>{L=!0,window.clearTimeout(ze)}},[_e,se]);let vc=Object.keys(a).length,Ma=_e.trim(),Pd=Zs(J?.result),sl=J?.decision?.technical_classification==="no_suitable_candidate"||!!J&&!J.best,Jd=J?.decision?.technical_classification!=null,Fd=J?.decision?.reason??(sl?"No catalogue candidate found. Refine the request or search the catalogue.":null),Dw=Ht.map(_=>({product_id:_.product_id,description:_.description,source_list:_.source_list,price:_.price,price_basis:_.price_basis,uoi_count:_.uoi_count??null,uoi:_.uoi,pdp_photo_url:_.pdp_photo_url??null,conversion:_.conversion,measurements_mm:_.measurements_mm??[],scores:{dimension:0,grade:0,brand:0,fuzzy:0,bm25:0,overall:0},method:"catalogue_search"})),Yn=Ma?Dw:Pd,Ti=J?A[J.item.line_id]:void 0,Vn=!Ma&&Ti&&!Yn.some(_=>_.product_id===Ti.product_id)?[...Yn,Ti]:Yn,Id=(()=>{let _=Vn.slice(0,Ma?12:3);return Ma||!Ti||_.some(L=>L.product_id===Ti.product_id)?_:[..._,Ti]})(),cl=!!J?.best&&a[J.item.line_id]?.productId===J.best.product_id,Bw=!!J?.best&&!!a[J.item.line_id]&&!cl;return(0,s.jsxs)("div",{className:"wizard-step entry-stage",children:[(0,s.jsxs)("div",{className:`quick-order-card${f?"":" quick-order-card--customer"}`,children:[(0,s.jsx)("div",{className:`quick-order-hero${f?"":" quick-order-hero--customer"}`,children:f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,s.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,s.jsx)("h1",{children:"Your Results"}),(0,s.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,s.jsx)("strong",{children:nt(me)})," Est. total"]})]}),(0,s.jsx)("p",{children:"Each line item from your schedule matched against your catalogue, ranked by confidence."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{children:"Review your matched products"}),(0,s.jsxs)("p",{children:["Check you're happy with these items, then click ",b?"View Quote":"View Basket"," to continue."]})]}),(0,s.jsxs)("button",{type:"button",className:"results-total-action",onClick:i,"aria-label":b?"View quote":"View basket",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:b?"View Quote":"View Basket"}),(0,s.jsx)("strong",{children:nt(me)})]}),(0,s.jsx)("span",{className:"arrow",children:(0,s.jsx)(Ot,{})})]})]})}),(0,s.jsxs)("div",{className:"quick-order-panel",style:{paddingTop:16},children:[Ve&&(0,s.jsx)("div",{className:"results-summary",style:{marginBottom:12},children:(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn","aria-pressed":ye,onClick:()=>ee(_=>!_),children:ye?"Hide timings":"Show timings"})}),Ve&&ye&&(0,s.jsx)(u_,{...D}),!b&&(0,s.jsx)("div",{className:"results-toolbar-row",children:!J&&(0,s.jsxs)("div",{className:"results-summary",style:{marginBottom:0},children:[Ce>0&&(0,s.jsxs)("span",{className:"summary-chip summary-chip--neutral",children:[(0,s.jsx)("strong",{children:Ce})," need pricing"]}),(0,s.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[(0,s.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search description...",value:z,onChange:_=>G(_.target.value),"aria-label":"Search line items"}),!f&&(0,s.jsxs)("div",{className:"results-view-toggle","aria-label":"Results view",children:[(0,s.jsx)("button",{type:"button",className:`results-view-toggle__btn${ce==="tile"?" is-active":""}`,"aria-pressed":ce==="tile","aria-label":"Tile view",title:"Tile view",onClick:()=>xe("tile"),children:(0,s.jsxs)("svg",{width:"18",height:"12",viewBox:"0 0 15 10",fill:"currentColor",children:[(0,s.jsx)("rect",{x:"0.5",y:"0.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"5.5",y:"0.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"10.5",y:"0.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"0.5",y:"5.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"5.5",y:"5.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"10.5",y:"5.5",width:"4",height:"4"})]})}),(0,s.jsx)("button",{type:"button",className:`results-view-toggle__btn${ce==="list"?" is-active":""}`,"aria-pressed":ce==="list","aria-label":"List view",title:"List view",onClick:()=>xe("list"),children:(0,s.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 15 15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,s.jsx)("line",{x1:"0.5",y1:"2.5",x2:"14.5",y2:"2.5"}),(0,s.jsx)("line",{x1:"0.5",y1:"7.5",x2:"14.5",y2:"7.5"}),(0,s.jsx)("line",{x1:"0.5",y1:"12.5",x2:"14.5",y2:"12.5"})]})})]}),Ve&&(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Q(_=>_==="simple"?"detailed":"simple"),children:pe==="detailed"?"Hide detailed view":"Show detailed view"}),(0,s.jsxs)("details",{ref:Gn,style:{position:"relative"},children:[(0,s.jsx)("summary",{className:"bom-toolbar-btn sort-menu-summary","aria-label":"Sort line items",style:{fontSize:16},children:"\u21C5"}),(0,s.jsx)("div",{className:"sort-menu-panel",children:t_.map(_=>{let L=K===_.dir;return(0,s.jsxs)("button",{type:"button",className:`sort-menu-item${L?" is-active":""}`,onClick:()=>{fe(L?null:_.dir),Gn.current?.removeAttribute("open")},children:[(0,s.jsx)("span",{className:"sort-menu-item__check",children:L?"\u2713":""}),_.label]},_.dir)})})]})]})]})}),ce==="tile"||J?(0,s.jsxs)(s.Fragment,{children:[J?(0,s.jsx)("div",{className:"modal-backdrop quick-order-modal-backdrop",role:"dialog","aria-modal":"true","aria-label":"Product options",onClick:()=>br(),children:(0,s.jsxs)("section",{className:"quick-order-workflow-modal results-review-modal",onClick:_=>_.stopPropagation(),children:[(0,s.jsx)("button",{type:"button",className:"quick-order-workflow-close results-review-modal__close",onClick:()=>br(),"aria-label":"Close product options",children:(0,s.jsx)(Ko,{})}),(0,s.jsx)("div",{className:"results-review-page",children:f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"results-review-page__top",children:[(0,s.jsxs)("button",{type:"button",className:"bom-toolbar-btn bom-toolbar-btn--accent",onClick:()=>br(),children:[(0,s.jsx)(Zr,{}),"Back to results"]}),(0,s.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[Ve&&(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Q(_=>_==="simple"?"detailed":"simple"),children:pe==="detailed"?"Hide detailed info":"Show detailed info"}),(0,s.jsx)("div",{className:"results-review-searchbar",children:(0,s.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search products in catalogue...",value:_e,onChange:_=>et(_.target.value),"aria-label":"Search database candidates"})}),(0,s.jsx)("div",{className:"results-candidate-actions",children:(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>hc(J.item.line_id),children:"Clear selected product"})})]})]}),(0,s.jsxs)("div",{className:"results-review-page__hero",children:[(0,s.jsx)("div",{className:"results-review-page__image-wrap",children:(0,s.jsx)("img",{className:"fill-img results-review-page__image",src:Qa(je(J)?.description||J.item.description_original,je(J)?.product_id,je(J)?.pdp_photo_url),alt:""})}),(0,s.jsxs)("div",{className:"results-review-page__summary",children:[(0,s.jsx)("h2",{children:Pr(J.item,w)}),(0,s.jsxs)("p",{className:"results-review-page__meta",children:[_i(J.qty)," ",ka(J.item.unit,J.qty)]}),J.best?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-review-page__product",children:J.best.description}),J.best.price!=null?(0,s.jsx)("div",{className:"results-row-meta",children:Tn(J.best.price,J.best.price_basis)}):null]}):je(J)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-review-page__product",children:je(J)?.description}),je(J)?.price!=null?(0,s.jsx)("div",{className:"results-row-meta",children:Tn(je(J)?.price??null,je(J)?.price_basis??null)}):null,(0,s.jsx)("div",{className:"results-row-meta",children:"Best reviewed alternative - not yet selected"})]}):(0,s.jsx)("div",{className:"results-empty-hint",children:"No product currently selected for this line item."}),mr(J.item)?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[(0,s.jsx)(md,{meta:V.get(J.item.linked_group_id)}),(0,s.jsx)("div",{className:"results-row-meta",style:{marginTop:0},children:zn(J.item)})]}):null,(0,s.jsx)("div",{className:"results-review-page__actions",children:(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[J.item.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>{a[J.item.line_id]?n(J.item.line_id):(J.best&&Kd(J.item.line_id,J.best),r(Mi(J)))},disabled:!J.best,"aria-label":a[J.item.line_id]?f?"Remove from selection":`Remove from ${d}`:f?"Add to selection":`Add to ${d}`,children:a[J.item.line_id]?"\u2713 Added":f?"+ Add to selection":`Add to ${d}`})})]})]}),tt?(0,s.jsx)("div",{className:"results-empty-card",children:"Searching catalogue\u2026"}):null,!tt&&He?(0,s.jsx)("div",{className:"results-empty-card",children:He}):null,!tt&&!He&&Ma&&Yn.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No candidate products match this database search."}):!tt&&!He?(0,s.jsx)(g_,{item:J.item,candidates:Yn,result:J.result,decision:J.decision,unmatchable:J.unmatchable,selectedProductId:J.best?.product_id??null,detailMode:pe,linkedGroupMeta:mr(J.item)?V.get(J.item.linked_group_id):void 0,onPick:_=>bc(J.item.line_id,_),onClear:()=>hc(J.item.line_id),showAll:f||Ve||Ma.length>0,internal:f,debugEnabled:Ve,forceReviewNote:!0}):null]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("section",{className:"customer-review-request",children:[(0,s.jsx)("span",{className:"customer-review-eyebrow",children:"Original request"}),(0,s.jsx)("strong",{children:Pr(J.item,w)||"Original request"})]}),Fd?(0,s.jsxs)("section",{className:"customer-review-ai",children:[(0,s.jsx)("strong",{children:sl?"Exact match not found:":"AI review:"})," ",Fd]}):null,(0,s.jsxs)("section",{className:"customer-review-options",children:[(0,s.jsx)("div",{className:"customer-review-options__head",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{children:sl?"We couldn't find a suitable product":Jd?"Choose a product":"We couldn't review this item"}),(0,s.jsx)("p",{children:sl?Pd.length>0?"These AI-reviewed alternatives may be useful, but need approval.":"Search the catalogue to choose an alternative.":Jd?`Select the option you want to add to your ${d}.`:"Search the catalogue to choose a product."})]})}),!Ma&&Vn.length>0?(0,s.jsx)("div",{className:"customer-review-option-grid",children:Id.map(_=>{let L=_.product_id===J.best?.product_id;return(0,s.jsxs)("button",{type:"button",className:`customer-review-option${L?" is-selected":""}`,onClick:()=>bc(J.item.line_id,_),"aria-pressed":L,children:[(0,s.jsx)("img",{className:"customer-review-option__image",src:Qa(_.description,_.product_id,_.pdp_photo_url),alt:"",width:64,height:64}),(0,s.jsx)("span",{className:"customer-review-option__copy",children:(0,s.jsx)("strong",{children:_.description})}),(0,s.jsx)("span",{className:"customer-review-option__price",children:_.price!=null?`\xA3${Tn(_.price,_.price_basis)}`:"-"}),(0,s.jsx)("span",{className:"customer-review-option__state",children:L?"Selected":"Choose"})]},_.product_id)})}):null,Vn.length>0&&(0,s.jsx)("div",{className:"customer-review-divider",children:(0,s.jsx)("span",{children:"or"})}),(0,s.jsxs)("label",{className:"customer-review-search",children:[(0,s.jsx)("span",{children:"Search our full catalogue"}),(0,s.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search products...",value:_e,onChange:_=>et(_.target.value),"aria-label":"Search catalogue"})]}),Ma&&tt?(0,s.jsx)("div",{className:"results-empty-card",children:"Searching catalogue\u2026"}):null,Ma&&!tt&&He?(0,s.jsx)("div",{className:"results-empty-card",children:He}):null,Ma&&!tt&&!He&&Vn.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No products match this search."}):null,Ma&&!tt&&!He&&Vn.length>0?(0,s.jsx)("div",{className:"customer-review-option-grid",children:Id.map(_=>{let L=_.product_id===J.best?.product_id;return(0,s.jsxs)("button",{type:"button",className:`customer-review-option${L?" is-selected":""}`,onClick:()=>bc(J.item.line_id,_),"aria-pressed":L,children:[(0,s.jsx)("img",{className:"customer-review-option__image",src:Qa(_.description,_.product_id,_.pdp_photo_url),alt:"",width:64,height:64}),(0,s.jsx)("span",{className:"customer-review-option__copy",children:(0,s.jsx)("strong",{children:_.description})}),(0,s.jsx)("span",{className:"customer-review-option__price",children:_.price!=null?`\xA3${Tn(_.price,_.price_basis)}`:"-"}),(0,s.jsx)("span",{className:"customer-review-option__state",children:L?"Selected":"Choose"})]},_.product_id)})}):null]}),J.best?Bw?(0,s.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,s.jsx)("button",{type:"button",className:"cta-btn customer-review-add",onClick:()=>{$d()},children:(0,s.jsx)("span",{children:"Update product"})}),(0,s.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary customer-review-add",onClick:()=>n(J.item.line_id),children:(0,s.jsx)("span",{children:`Remove from ${d}`})})]}):(0,s.jsx)("button",{type:"button",className:`cta-btn customer-review-add${cl?" cta-btn-secondary":""}`,onClick:()=>{cl?n(J.item.line_id):$d()},children:(0,s.jsx)("span",{children:cl?`Remove from ${d}`:`Add selected product to ${d}`})}):null,ne?(0,s.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary customer-review-skip",onClick:()=>Rw(J.item.line_id),children:"Skip this item"}):null]})})]})}):null,(0,s.jsxs)("div",{className:"results-tile-layout",children:[Ea.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No line items match the current search/filter."}):null,gc.length>0?(0,s.jsx)("section",{className:"results-tile-section","aria-label":"Matched and review items",children:(0,s.jsx)("div",{className:"results-tile-grid",children:gc.map(_=>{let{item:L,best:ze,qty:zt}=_,Ze=je(_),It=!ze&&dt(_);return(0,s.jsxs)("article",{className:"results-tile-card",children:[(0,s.jsxs)("button",{type:"button",className:"results-tile-card__surface",onClick:()=>Ei(L.line_id),"aria-label":`Review match for ${Pr(L,w)||"item"}`,children:[(0,s.jsxs)("div",{className:"results-tile-card__media",children:[It||mr(L)?(0,s.jsxs)("div",{className:"results-tile-card__badges",children:[mr(L)?(0,s.jsx)(md,{meta:V.get(L.linked_group_id)}):(0,s.jsx)("span",{}),It?(0,s.jsx)("span",{style:{padding:"6px 10px",borderRadius:999,background:"#fef3c7",color:"#92400e",fontSize:12,fontWeight:700,lineHeight:1},children:"Partially matched"}):null]}):null,(0,s.jsx)("img",{className:"fill-img results-tile-card__image",src:Qa(Ze?.description||L.description_original,Ze?.product_id,Ze?.pdp_photo_url),alt:""})]}),(0,s.jsxs)("div",{className:"results-tile-card__body",children:[Ze?(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("div",{className:"results-tile-card__heading",children:(0,s.jsx)("div",{className:"results-tile-card__title",children:Ze.description})})}):(0,s.jsx)("div",{className:"results-empty-hint",children:"No product currently selected for this line item."}),(0,s.jsx)("div",{className:"results-tile-card__match",children:Ze?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-tile-card__match-label",children:It?"\u21B3 partially matched from":"\u21B3 matched from"}),(0,s.jsx)("div",{className:"results-tile-card__match-name",children:Pr(L,w)}),mr(L)?(0,s.jsx)("div",{className:"results-row-meta",children:zn(L)}):null]}):(0,s.jsx)("span",{className:"results-empty-hint",children:"No matched product selected."})})]}),(0,s.jsx)("span",{className:"results-tile-card__hover-prompt","aria-hidden":"true",children:"Click to view options"})]}),(0,s.jsxs)("div",{className:"results-tile-card__actions",children:[f&&(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Ei(L.line_id),children:"Review"}),(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[L.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>{a[L.line_id]?n(L.line_id):r(Mi(_))},disabled:!Ze,"aria-label":a[L.line_id]?f?"Remove from selection":`Remove from ${d}`:f?"Add to selection":`Add to ${d}`,children:a[L.line_id]?"\u2713 Added":f?"+ Add":`Add to ${d}`})]})]},L.line_id)})})}):null,Zd]})]}):(0,s.jsxs)(s.Fragment,{children:[I&&(0,s.jsx)("div",{className:"results-table__hover-overlay",style:I,"aria-hidden":"true",children:"Click to view options"}),(0,s.jsx)("div",{className:"bom-table-wrap",children:(0,s.jsxs)("table",{className:"bom-table results-table","aria-label":"Matched line items",children:[(0,s.jsxs)("colgroup",{children:[(0,s.jsx)("col",{className:"col-item"}),(0,s.jsx)("col",{style:{width:"220px"}}),(0,s.jsx)("col",{style:{width:"100px"}}),pe==="simple"&&(0,s.jsx)("col",{style:{width:"110px"}})]}),(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"bom-col-header",children:[(0,s.jsx)("th",{style:{textAlign:"left"},children:"Description"}),(0,s.jsx)("th",{style:{textAlign:"center"},children:"Product Matched"}),(0,s.jsx)("th",{style:{textAlign:"center"},children:"Price"}),pe==="simple"&&(0,s.jsx)("th",{style:{textAlign:"center"},children:f?"Selection":b?"Quote":"Basket"})]})}),(0,s.jsxs)("tbody",{children:[Ea.length===0&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:pe==="simple"?4:3,className:"results-empty-hint",style:{padding:"16px 8px"},children:"No line items match the current search/filter."})}),gc.map(_=>{let{item:L,result:ze,decision:zt,best:Ze}=_;return(0,s.jsxs)("tr",{className:"bom-row results-table__review-row",onClick:()=>Ei(L.line_id),onMouseEnter:It=>{ve.current=It.currentTarget,Qn()},onMouseLeave:()=>{ve.current=null,ue(null)},children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("div",{className:"bom-component-name",children:Pr(L,w)}),mr(L)?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[(0,s.jsx)(md,{meta:V.get(L.linked_group_id)}),(0,s.jsx)("div",{className:"results-row-meta",style:{marginTop:0},children:zn(L)})]}):null]}),(0,s.jsx)("td",{children:Ze?(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"results-match-cell-text",title:Ze.description,children:Ze.description}),pe==="detailed"&&zt?.technical_classification&&(0,s.jsxs)("div",{className:"results-row-meta",children:[n_(zt.technical_classification),zt.approval_required?" - approval required":""]})]}):(0,s.jsx)("span",{className:"results-empty-hint"})}),(0,s.jsx)("td",{style:{textAlign:"center"},children:Ze?.price!=null?Tn(Ze.price,Ze.price_basis):"-"}),pe==="simple"&&(0,s.jsx)("td",{style:{textAlign:"center"},children:(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[L.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,style:{width:84,justifyContent:"center"},onClick:It=>{It.stopPropagation(),a[L.line_id]?n(L.line_id):r(Mi(_))},"aria-label":a[L.line_id]?f?"Remove from selection":`Remove from ${d}`:f?"Add to selection":`Add to ${d}`,children:a[L.line_id]?"\u2713 Added":f?"+ Add":`Add to ${d}`})})]},L.line_id)})]})]})}),Zd]}),!J&&hr>1&&(0,s.jsxs)("div",{className:"results-pagination",children:[(0,s.jsxs)("span",{className:"results-pagination-count",children:["Showing ",(Jt-1)*el+1,"\u2013",Math.min(Jt*el,Ea.length)," of ",Ea.length]}),(0,s.jsxs)("div",{className:"results-pagination-controls",children:[(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Ye(Jt-1),disabled:Jt===1,children:"Previous"}),(0,s.jsxs)("span",{className:"results-pagination-page",children:["Page ",Jt," of ",hr]}),(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Ye(Jt+1),disabled:Jt===hr,children:"Next"})]})]}),(M.itemCount!=null||M.headingCount!=null||M.skippedCount!=null)&&(0,s.jsxs)("div",{className:"results-summary",style:{marginTop:16},children:[M.itemCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:M.itemCount})," items parsed"]}),M.headingCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:M.headingCount})," headings"]}),M.skippedCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:M.skippedCount})," rows skipped"]})]}),(0,s.jsxs)("div",{className:"disclaimer-box",children:[(0,s.jsx)("span",{className:"disclaimer-icon",children:"\u26A0\uFE0F"}),(0,s.jsx)("p",{className:"disclaimer-text",children:"These matches are generated automatically and should be reviewed before purchase."})]}),!J&&(0,s.jsxs)("div",{className:"btn-row results-actions",children:[(0,s.jsxs)("button",{className:"cta-btn cta-btn-secondary",style:{flex:(vc>0,"0 1 30%"),gap:10,justifyContent:"center"},onClick:()=>R(!0),"aria-label":"Start over",children:[(0,s.jsx)(pd,{}),(0,s.jsx)("span",{children:"Start Over"})]}),vc>0&&(0,s.jsxs)("button",{className:"cta-btn",style:{flex:"0 1 70%"},onClick:i,"aria-label":f?"View selection":b?"View quote":"View basket",children:[(0,s.jsxs)("span",{children:[f?"View Selection":b?"View Quote":"View Basket"," (",vc,")"]}),(0,s.jsx)("span",{className:"arrow",children:(0,s.jsx)(Ot,{})})]})]})]})]}),Tw&&(0,s.jsx)("div",{className:"modal-backdrop quick-order-modal-backdrop review-gate-modal-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"review-gate-title",children:(0,s.jsxs)("section",{className:"quick-order-workflow-modal review-gate-modal",children:[(0,s.jsxs)("div",{className:"review-gate-modal__header",children:[(0,s.jsx)("h2",{id:"review-gate-title",children:"Choose products for these items"}),(0,s.jsx)("p",{children:"We couldn\u2019t find a clear match for these items, so we need your help. Select an option from the suggestions, search the catalogue, or leave the item out."})]}),(0,s.jsx)("div",{className:"review-gate-list",children:Ir.map(_=>{let L=Se.has(_.item.line_id),ze=dt(_);return(0,s.jsx)("div",{className:`review-gate-item${L?" is-reviewed":""}`,children:(0,s.jsxs)("button",{type:"button",className:"review-gate-item__review",onClick:()=>{W(!0),Ei(_.item.line_id)},children:[(0,s.jsxs)("span",{className:"review-gate-item__copy",children:[(0,s.jsx)("strong",{children:Pr(_.item,w)}),(0,s.jsx)("span",{children:_.decision?.reason||(ze?"A close alternative is available but needs confirmation.":"No product has been selected for this item yet.")})]}),(0,s.jsx)("span",{className:"review-gate-item__action",children:L?"Choice made":"Choose a product"})]})},_.item.line_id)})}),(0,s.jsx)("button",{type:"button",className:"review-gate-skip",onClick:Uw,children:"Skip all"}),ll.length>0?(0,s.jsxs)("div",{className:"review-gate-skipped",children:[(0,s.jsx)("strong",{children:"Skipped"}),ll.map(_=>(0,s.jsxs)("button",{type:"button",className:"review-gate-item is-skipped",onClick:()=>{O(L=>{let ze=new Set(L);return ze.delete(_.item.line_id),ze}),W(!0),Ei(_.item.line_id)},children:[(0,s.jsxs)("span",{className:"review-gate-item__copy",children:[(0,s.jsx)("strong",{children:Pr(_.item,w)}),(0,s.jsx)("span",{children:`Not added to your ${d}.`})]}),(0,s.jsx)("span",{className:"review-gate-item__action",children:"Choose a product"})]},_.item.line_id))]}):null]})}),x&&(0,s.jsx)("div",{className:"modal-backdrop quick-order-modal-backdrop start-over-modal",role:"dialog","aria-modal":"true","aria-labelledby":"start-over-modal-title",children:(0,s.jsxs)("div",{className:"modal-card start-over-modal__card",children:[(0,s.jsx)("h2",{id:"start-over-modal-title",className:"modal-title",children:"Start over?"}),(0,s.jsxs)("p",{className:"modal-body",children:["This will clear the current results and ",b?"quote":"basket"," and take you back to the start."]}),(0,s.jsxs)("div",{className:"modal-actions",children:[(0,s.jsx)("button",{type:"button",className:"modal-btn modal-btn-secondary",onClick:()=>R(!1),children:"Cancel"}),(0,s.jsx)("button",{type:"button",className:"modal-btn modal-btn-danger",onClick:()=>{R(!1),t()},autoFocus:!0,children:"Start Over"})]})]})})]})}var wt=Y(Xe());var q=Y(ae()),h_=.2,tl=10,rw="Enter a valid email address so we can send your quote.",b_=(e,t)=>{let a=`${t.requestedAmount} ${xa(t.requestedUnit,t.requestedAmount)}`,r=`${t.requiredSellUnits} ${xa(t.sellUnit,t.requiredSellUnits??0)}`,n=e.unitConversions?.find(i=>i.requestUom===t.requestedUnit);return n&&n.quantityPerSaleUnit<1?`${a} requested \u2192 order ${r} (${Math.round(1/n.quantityPerSaleUnit)} ${xa(t.sellUnit,2)} per ${xa(t.requestedUnit,1)})`:e.coverageQty&&/^m per /i.test(e.coverageUom??"")?`${a} requested \u2192 order ${r} (${e.coverageQty} ${e.coverageUom})`:`${a} requested \u2192 order ${r}`},v_=e=>["box","pack"].includes(e.requestedUnit)?"Pack size needed to calculate the order quantity.":`This product is sold by ${xa(e.sellUnit,1)}.`;function w_(){return(0,q.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,q.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,q.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,q.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,q.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function al(){return(0,q.jsx)("svg",{width:"8",height:"5",viewBox:"0 0 8 5",fill:"none",children:(0,q.jsx)("path",{d:"M1 4L4 1L7 4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function rl({cart:e,onUpdateQty:t,onUpdateSellUnits:a,onResolveConversions:r,onRemove:n,onBack:i,onStartNewQuote:o,internal:l=!1}){let c=(0,wt.useId)(),p=!l&&Qs()==="QZA6-MRA4",f=Object.values(e),[b,d]=(0,wt.useState)(""),[h,w]=(0,wt.useState)(!1),[M,D]=(0,wt.useState)(!1),m=Cn(),[u,g]=(0,wt.useState)(""),[v,N]=(0,wt.useState)({}),[A,T]=(0,wt.useState)({}),[z,G]=(0,wt.useState)(1),[K,fe]=(0,wt.useState)({}),[Te,Ye]=(0,wt.useState)(!1),[Ve,it]=(0,wt.useState)("0"),pe=(0,wt.useRef)(new Set);(0,wt.useEffect)(()=>{if(!r)return;for(let R of Object.values(e))ua(R).requiredSellUnits!=null&&pe.current.delete(R.lineId);let x=Object.values(e).filter(R=>R.productId!=="-"&&ua(R).requiredSellUnits==null&&!pe.current.has(R.lineId));x.length!==0&&(x.forEach(R=>pe.current.add(R.lineId)),fetch(Bt("/api/catalogue/resolve-conversions"),{method:"POST",headers:{"Content-Type":"application/json",...Ga()},body:JSON.stringify({lines:x.map(R=>({line_id:R.lineId,product_id:R.productId,requested_description:R.requestedDescription??R.description,requested_qty:R.qty,requested_uom:R.unit,selected_description:R.description,selected_uoi:R.uoi,selected_uoi_count:R.uoiCount,selected_conversion:{sales_uom_normalised:R.salesUomNormalised,conversion_type:R.conversionType,sales_unit_size:R.salesUnitSize,sales_unit_size_uom:R.salesUnitSizeUom,coverage_qty:R.coverageQty,coverage_uom:R.coverageUom}}))})}).then(R=>R.ok?Zt(R):null).then(R=>{let I={};for(let ue of R?.data?.items??R?.items??[]){let ve=ue?.conversion;!ve||typeof ue?.line_id!="string"||(I[ue.line_id]={conversionType:ve.conversion_type,requestUomsSupported:ve.request_uoms_supported,salesUomNormalised:ve.sales_uom_normalised,salesUnitSize:ve.sales_unit_size,salesUnitSizeUom:ve.sales_unit_size_uom,coverageQty:ve.coverage_qty,coverageUom:ve.coverage_uom,roundingRule:ve.rounding_rule,conversionConfidence:ve.conversion_confidence,conversionNotes:ve.conversion_notes})}Object.keys(I).length>0&&r(I)}).catch(()=>{}))},[e,r]);function Q(x){N(R=>{let I={...R};return delete I[x],I})}function ce(x,R){let I=parseFloat(R);!isNaN(I)&&I>=0&&t(x,I),Q(x)}function xe(x,R,I){t(x,Math.max(0,R+I)),Q(x)}function ye(x){T(R=>{let I={...R};return delete I[x],I})}function ee(x,R){let I=parseFloat(R);!isNaN(I)&&I>=0&&a(x,I),ye(x)}function se(x,R,I){a(x,Math.max(0,R+I)),ye(x)}async function Me(){let x=b.trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x)){g(rw);return}g(""),D(!0);try{let R=await fetch(Bt("/api/quote-requests"),{method:"POST",headers:{"Content-Type":"application/json",...Ga()},body:JSON.stringify({email:x,items:_e.map(({item:I,pricing:ue})=>{let ve=ue.requiredSellUnits??ue.requestedAmount,Se=ue.requiredSellUnits!=null?ue.sellUnit:ue.requestedUnit;return{product_id:I.productId,description:I.description,quantity:ve,unit:xa(Se,ve),unit_price:ue.requiredSellUnits!=null?ue.unitPrice:null,line_total:ue.lineTotal}})})});if(!R.ok){let I=await Zt(R);console.error("Quote request failed",R.status,I?.message),g(R.status===429?"You've sent a few requests already. Please try again in a few minutes.":"Your request couldn't be sent. Please try again, or contact us if it keeps happening.");return}m("quote_requested",{items:_e.length,total:Math.round(Tt*100)/100}),w(!0),window.scrollTo(0,0)}catch{g("Your request couldn't be sent. Check your connection and try again.")}finally{D(!1)}}let _e=f.map(x=>({item:x,pricing:ua(x,{wasteFactorEnabled:Te,wasteFactorOverride:Math.max(0,Number.parseFloat(Ve)||0)/100})})),et=_e.reduce((x,R)=>x+(R.pricing.lineTotal??0),0),Ht=et*h_,Tt=et+Ht,tt=(0,wt.useRef)({items:_e.length,total:Math.round(Tt*100)/100});(0,wt.useEffect)(()=>{m("basket_viewed",tt.current)},[m]);let ct=Math.max(1,Math.ceil(_e.length/tl)),He=Math.min(z,ct),E=_e.slice((He-1)*tl,He*tl);return h?(0,q.jsx)("div",{className:"wizard-step entry-stage",children:(0,q.jsxs)("div",{className:"quote-request-sent",role:"status",children:[(0,q.jsx)("div",{className:"quote-request-sent-icon","aria-hidden":"true",children:(0,q.jsx)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,q.jsx)("polyline",{points:"5 12.5 10 17.5 19 7"})})}),(0,q.jsx)("h1",{children:"Quote requested"}),(0,q.jsxs)("p",{children:["You're all done. We'll email your sharper price to ",(0,q.jsx)("strong",{children:b.trim()}),", usually within one working day."]}),(0,q.jsx)("button",{type:"button",className:"cta-btn",onClick:o,children:(0,q.jsx)("span",{children:"Start a new quote"})}),(0,q.jsx)("p",{className:"quote-request-sent-note",children:"Nothing is charged until you approve the quote."})]})}):(0,q.jsx)("div",{className:`wizard-step entry-stage${p?" basket-layout--qza6-mra4":""}`,children:(0,q.jsxs)("div",{className:`quick-order-card${l?"":" quick-order-card--customer"}`,children:[(0,q.jsxs)("div",{className:`quick-order-hero${l?"":" quick-order-hero--customer"}`,children:[l&&(0,q.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,q.jsxs)("div",{className:"basket-hero-copy",children:[p&&(0,q.jsxs)("button",{type:"button",className:"cta-btn cta-btn-secondary basket-hero-back",onClick:i,children:[(0,q.jsx)(Zr,{}),(0,q.jsx)("span",{children:"Back to results"})]}),(0,q.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,q.jsx)("h1",{children:l?"Your Selection":p?"Request a quote":"Your Basket"}),l&&(0,q.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,q.jsx)("strong",{children:f.length})," ",f.length===1?"item":"items"]})]}),(0,q.jsx)("p",{children:l?"Review the items you've added before exporting them for review.":p?"Check your items & quantities below, and we'll do our best to beat list prices.":"Review your quantities and order summary before you buy."})]})]}),(0,q.jsx)("div",{className:"quick-order-panel",style:{paddingTop:16},children:f.length===0?(0,q.jsxs)("div",{className:"quick-order-history-empty",children:[(0,q.jsx)("div",{className:"basket-empty-icon","aria-hidden":"true",children:l?"\u{1F4CB}":"\u{1F9FA}"}),(0,q.jsx)("p",{children:l?"Your selection is empty.":p?"Your quote request is empty.":"Your basket is empty."}),(0,q.jsx)("p",{className:"basket-empty-hint",children:p?"Go back to your results and add items for your quote.":"Go back to your results and add quoted items."}),(0,q.jsx)("div",{className:"btn-row",style:{marginTop:20,justifyContent:"center"},children:(0,q.jsx)("button",{className:"cta-btn",style:{width:"auto",maxWidth:280},onClick:i,"aria-label":"Back to results",children:(0,q.jsx)("span",{children:"Back to Results"})})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)("div",{className:"basket-layout",children:[(0,q.jsxs)("div",{className:"basket-main",children:[(0,q.jsx)("div",{className:"basket-list","aria-label":l?"Selection items":p?"Quote request items":"Basket items",children:E.map(({item:x,pricing:R})=>{let I=v[x.lineId]??String(R.requestedAmount),ue=R.requestedUnit===R.sellUnit||R.costingMode==="review",ve=R.requiredSellUnits==null||R.requestedAmount!==R.requiredSellUnits||R.requestedUnit!==R.sellUnit;return(0,q.jsxs)("article",{className:"basket-card",children:[(0,q.jsxs)("div",{className:"basket-card-top",children:[(0,q.jsx)("img",{className:"basket-card-thumb",src:Qa(x.description,x.productId,x.pdpPhotoUrl),alt:"",width:48,height:48}),(0,q.jsxs)("div",{className:"basket-card-info",children:[(0,q.jsx)("div",{className:"bom-component-name",children:x.description}),ve&&R.costingMode!=="review"&&(0,q.jsxs)("button",{type:"button",className:"basket-calc-toggle",onClick:()=>fe(Se=>({...Se,[x.lineId]:!Se[x.lineId]})),"aria-expanded":!!K[x.lineId],children:["How we calculated this",(0,q.jsx)("span",{className:`basket-calc-toggle-chevron${K[x.lineId]?" basket-calc-toggle-chevron--open":""}`,children:(0,q.jsx)(al,{})})]})]}),(0,q.jsx)("div",{className:"basket-card-actions",children:(0,q.jsx)("button",{type:"button",className:"mf-remove-small-btn basket-card-remove",onClick:()=>n(x.lineId),"aria-label":`Remove ${x.description}`,children:(0,q.jsx)(w_,{})})})]}),l&&(0,q.jsxs)("div",{className:"results-detail-block basket-internal-detail",children:[(0,q.jsxs)("dl",{className:"results-detail-grid",children:[(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Conversion type"}),(0,q.jsx)("dd",{children:x.conversionType??"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Conversion confidence"}),(0,q.jsx)("dd",{children:x.conversionConfidence??"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Sales unit"}),(0,q.jsx)("dd",{children:x.salesUnitSize!=null?(0,q.jsxs)(q.Fragment,{children:[x.salesUnitSize," ",ka(x.salesUnitSizeUom,x.salesUnitSize)]}):"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Coverage"}),(0,q.jsx)("dd",{children:x.coverageQty!=null?(0,q.jsxs)(q.Fragment,{children:[x.coverageQty," ",ka(x.coverageUom,x.coverageQty)]}):"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Waste factor"}),(0,q.jsx)("dd",{children:x.wasteFactorDefault??"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Rounding rule"}),(0,q.jsx)("dd",{children:x.roundingRule??"-"})]})]}),x.conversionNotes&&(0,q.jsx)("p",{className:"results-rerank-note",children:x.conversionNotes})]}),R.costingMode==="review"?(0,q.jsxs)("p",{className:"basket-calc-text basket-calc-text--review",children:[(0,q.jsx)("strong",{children:"Quantity needs confirmation."})," ",v_(R)]}):ve&&K[x.lineId]?(0,q.jsx)("p",{className:"basket-calc-text",children:b_(x,R)}):null,(0,q.jsxs)("div",{className:"basket-card-stats",children:[(0,q.jsxs)("div",{className:"basket-stat",children:[(0,q.jsx)("span",{className:"basket-stat-label",children:"Requested qty"}),(0,q.jsxs)("div",{className:"basket-stat-value",children:[(0,q.jsxs)("div",{className:"basket-qty-field",children:[(0,q.jsx)("input",{className:"bom-qty-edit",type:"number",inputMode:"decimal",min:"0",placeholder:"-",value:I,disabled:ue,onChange:Se=>N(k=>({...k,[x.lineId]:Se.target.value})),onBlur:Se=>ce(x.lineId,Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&Se.target.blur()},"aria-label":`${x.description} requested quantity`}),(0,q.jsxs)("div",{className:"basket-qty-arrows",children:[(0,q.jsx)("button",{type:"button",className:"basket-qty-arrow",disabled:ue,onClick:()=>xe(x.lineId,parseFloat(I)||0,1),"aria-label":`Increase ${x.description} quantity`,children:(0,q.jsx)(al,{})}),(0,q.jsx)("button",{type:"button",className:"basket-qty-arrow basket-qty-arrow--down",disabled:ue,onClick:()=>xe(x.lineId,parseFloat(I)||0,-1),"aria-label":`Decrease ${x.description} quantity`,children:(0,q.jsx)(al,{})})]})]}),(0,q.jsx)("span",{className:"basket-metric-unit",children:ka(R.requestedUnit,parseFloat(I)||0)})]})]}),(0,q.jsxs)("div",{className:"basket-stat basket-stat--right",children:[(0,q.jsx)("span",{className:"basket-stat-label",children:"Order qty"}),(0,q.jsxs)("div",{className:"basket-stat-value",children:[(0,q.jsxs)("div",{className:"basket-qty-field",children:[(0,q.jsx)("input",{className:"bom-qty-edit",type:"number",inputMode:"decimal",min:"0",placeholder:"-",value:A[x.lineId]??String(R.requiredSellUnits??""),onChange:Se=>T(k=>({...k,[x.lineId]:Se.target.value})),onBlur:Se=>ee(x.lineId,Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&Se.target.blur()},"aria-label":`${x.description} order quantity`}),(0,q.jsxs)("div",{className:"basket-qty-arrows",children:[(0,q.jsx)("button",{type:"button",className:"basket-qty-arrow",onClick:()=>se(x.lineId,parseFloat(A[x.lineId]??String(R.requiredSellUnits??"0"))||0,1),"aria-label":`Increase ${x.description} order quantity`,children:(0,q.jsx)(al,{})}),(0,q.jsx)("button",{type:"button",className:"basket-qty-arrow basket-qty-arrow--down",onClick:()=>se(x.lineId,parseFloat(A[x.lineId]??String(R.requiredSellUnits??"0"))||0,-1),"aria-label":`Decrease ${x.description} order quantity`,children:(0,q.jsx)(al,{})})]})]}),(0,q.jsx)("span",{className:"basket-metric-unit",children:ka(R.sellUnit,parseFloat(A[x.lineId]??String(R.requiredSellUnits??"0"))||0)})]})]}),(0,q.jsxs)("div",{className:"basket-stat basket-stat--total",children:[(0,q.jsx)("span",{className:"basket-stat-label",children:"Total"}),(0,q.jsxs)("div",{className:"basket-stat-value",children:[(0,q.jsx)("strong",{children:R.lineTotal!=null?nt(R.lineTotal):"-"}),R.lineTotal!=null&&(0,q.jsx)("span",{className:"basket-metric-unit",children:"ex. VAT"})]})]})]})]},x.lineId)})}),ct>1&&(0,q.jsxs)("div",{className:"results-pagination",children:[(0,q.jsxs)("span",{className:"results-pagination-count",children:["Showing ",(He-1)*tl+1,"\u2013",Math.min(He*tl,_e.length)," of ",_e.length]}),(0,q.jsxs)("div",{className:"results-pagination-controls",children:[(0,q.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>G(He-1),disabled:He===1,children:"Previous"}),(0,q.jsxs)("span",{className:"results-pagination-page",children:["Page ",He," of ",ct]}),(0,q.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>G(He+1),disabled:He===ct,children:"Next"})]})]})]}),(0,q.jsxs)("aside",{className:"basket-sidebar",children:[(0,q.jsx)("div",{className:"basket-sidebar-title",children:p?"Quote request summary":"Order summary"}),(0,q.jsxs)("div",{className:"basket-sidebar-row",children:[(0,q.jsx)("span",{children:p?"List price (ex. VAT)":"Subtotal (ex. VAT)"}),(0,q.jsx)("span",{children:nt(et)})]}),(0,q.jsxs)("div",{className:"basket-sidebar-row",children:[(0,q.jsx)("span",{children:"VAT (20%)"}),(0,q.jsx)("span",{children:nt(Ht)})]}),(0,q.jsxs)("div",{className:"basket-sidebar-row basket-sidebar-row--total",children:[(0,q.jsx)("span",{children:p?"List price (inc. VAT)":"Total"}),(0,q.jsx)("span",{children:nt(Tt)})]}),!p&&(0,q.jsx)("div",{className:"basket-summary-waste",children:(0,q.jsxs)("div",{className:"basket-waste-control",children:[(0,q.jsxs)("label",{className:"basket-global-waste",children:[(0,q.jsx)("input",{type:"checkbox",checked:Te,onChange:x=>Ye(x.target.checked)}),(0,q.jsx)("span",{children:"Add waste factor"})]}),(0,q.jsxs)("label",{className:"basket-global-waste-percent",children:[(0,q.jsx)("input",{type:"number",inputMode:"decimal",min:"0",step:"0.1",value:Ve,onChange:x=>it(x.target.value),disabled:!Te,"aria-label":"Waste factor percent"}),(0,q.jsx)("span",{children:"%"})]})]})}),(0,q.jsx)("label",{htmlFor:`${c}-basket-reference`,className:"basket-sidebar-label",children:p?"Enter email for your sharper quote":"Your reference (optional)"}),(0,q.jsx)("input",{id:`${c}-basket-reference`,type:p?"email":"text",className:"basket-sidebar-input",value:b,onChange:x=>{d(x.target.value),p&&g("")},placeholder:p?"you@example.com":"PO number or job reference","aria-invalid":p&&u===rw,"aria-describedby":p&&u?`${c}-basket-reference-error`:void 0}),p&&u&&(0,q.jsx)("p",{id:`${c}-basket-reference-error`,className:"basket-quote-request-error",role:"alert",children:u}),p?(0,q.jsx)("button",{type:"button",className:"cta-btn",onClick:()=>{Me()},disabled:M,"aria-busy":M,children:(0,q.jsx)("span",{children:M?"Sending\u2026":"Request our best quote"})}):(0,q.jsx)("button",{className:"cta-btn",onClick:()=>{m("downloaded",{type:"basket",items:f.length}),Iv(f)},"aria-label":l?"Download selection":"Download basket",children:(0,q.jsx)("span",{children:l?"Download Quote":"Buy Now"})}),(0,q.jsxs)("p",{className:"basket-sidebar-disclaimer",children:[(0,q.jsx)("span",{"aria-hidden":"true",children:"\u26A0\uFE0F"}),p?"This is a quote request, not an order. We'll confirm our best price, availability and delivery before you approve.":"Prices and availability are estimates and should be confirmed before procurement."]})]})]}),(0,q.jsx)("div",{className:"btn-row results-actions",children:(0,q.jsxs)("button",{className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",gap:10,justifyContent:"center"},onClick:i,"aria-label":"Back to results",children:[(0,q.jsx)(Zr,{}),(0,q.jsx)("span",{children:"Back to results"})]})})]})})]})})}var Et=Y(Xe()),iw=Y(ae()),bd=(0,Et.createContext)(null);function Ps({children:e,onOpenBasket:t}){let[a,r]=(0,Et.useState)({}),n=(0,Et.useCallback)(d=>{r(h=>({...h,[d.lineId]:d}))},[]),i=(0,Et.useCallback)(d=>{r(h=>{let w={...h};for(let M of d)w[M.lineId]=M;return w})},[]),o=(0,Et.useCallback)(d=>{r(h=>{let w={...h};return delete w[d],w})},[]),l=(0,Et.useCallback)((d,h)=>{r(w=>w[d]?{...w,[d]:{...w[d],qty:h,sellUnitsOverride:null}}:w)},[]),c=(0,Et.useCallback)((d,h)=>{r(w=>w[d]?{...w,[d]:{...w[d],sellUnitsOverride:h}}:w)},[]),p=(0,Et.useCallback)(d=>{r(h=>{let w=!1,M={...h};for(let[D,m]of Object.entries(d))M[D]&&(M[D]={...M[D],...m},w=!0);return w?M:h})},[]),f=(0,Et.useCallback)(()=>r({}),[]),b=(0,Et.useMemo)(()=>({cart:a,count:Object.keys(a).length,addToCart:n,addManyToCart:i,removeFromCart:o,updateCartQty:l,updateCartSellUnits:c,updateCartConversions:p,clearCart:f,openBasket:t??(()=>{})}),[a,n,i,o,l,c,p,f,t]);return(0,iw.jsx)(bd.Provider,{value:b,children:e})}function An(){let e=(0,Et.useContext)(bd);if(!e)throw new Error("useCart must be used inside a <CartProvider>");return e}function Js(){return(0,Et.useContext)(bd)}var Na=Y(ae());function Fs(e){return(0,Na.jsx)(Ps,{children:(0,Na.jsx)(y_,{...e})})}function y_({fullPage:e=!1,hideHeader:t=!1,internal:a=!1}){let[r,n]=(0,Pe.useState)("entry"),[i,o]=(0,Pe.useState)(null),[l,c]=(0,Pe.useState)(""),p=(0,Pe.useRef)(null),[f,b]=(0,Pe.useState)(0),[d,h]=(0,Pe.useState)(null),[w,M]=(0,Pe.useState)(!1),{cart:D,addToCart:m,removeFromCart:u,updateCartQty:g,updateCartSellUnits:v,updateCartConversions:N,clearCart:A}=An(),[T,z]=(0,Pe.useState)(!1),G=(0,Pe.useRef)(new Map),K=(0,Pe.useRef)(null),fe=Gs("quick-quote",K);(0,Pe.useEffect)(()=>{fe("viewed")},[fe]),(0,Pe.useEffect)(()=>{for(let ee of Object.values(D))ua(ee).requiredSellUnits!=null&&G.current.delete(ee.lineId);let ye=Object.values(D).filter(ee=>{if(ee.productId==="-"||ua(ee).requiredSellUnits!=null)return!1;let se=`${ee.productId}|${ee.qty}|${ee.unit}`;return G.current.get(ee.lineId)===se?!1:(G.current.set(ee.lineId,se),!0)});ye.length!==0&&fetch(Bt("/api/catalogue/resolve-conversions"),{method:"POST",headers:{"Content-Type":"application/json",...Ga()},body:JSON.stringify({lines:ye.map(ee=>({line_id:ee.lineId,product_id:ee.productId,requested_description:ee.requestedDescription??ee.description,requested_qty:ee.qty,requested_uom:ee.unit,selected_description:ee.description,selected_uoi:ee.uoi,selected_uoi_count:ee.uoiCount,selected_conversion:{sales_uom_normalised:ee.salesUomNormalised,conversion_type:ee.conversionType,sales_unit_size:ee.salesUnitSize,sales_unit_size_uom:ee.salesUnitSizeUom,coverage_qty:ee.coverageQty,coverage_uom:ee.coverageUom}}))})}).then(ee=>ee.ok?Zt(ee):null).then(ee=>{let se={};for(let Me of ee?.data?.items??ee?.items??[]){let _e=Me?.conversion;!_e||typeof Me?.line_id!="string"||(se[Me.line_id]={conversionType:_e.conversion_type,requestUomsSupported:_e.request_uoms_supported,salesUomNormalised:_e.sales_uom_normalised,salesUnitSize:_e.sales_unit_size,salesUnitSizeUom:_e.sales_unit_size_uom,coverageQty:_e.coverage_qty,coverageUom:_e.coverage_uom,roundingRule:_e.rounding_rule,conversionConfidence:_e.conversion_confidence,conversionNotes:_e.conversion_notes})}Object.keys(se).length>0&&N(se)}).catch(()=>{})},[D,N]),(0,Pe.useEffect)(()=>{if(window.location.hash!=="#matched-products"&&window.location.hash!=="#quote-request")return;let ye=new URL(window.location.href);ye.hash="",window.history.replaceState({...window.history.state??{},boqQuoteStage:"entry"},"",ye)},[]);let Te=(0,Pe.useCallback)(ye=>{if(typeof window>"u")return;let ee=new URL(window.location.href);ee.hash=ye==="basket"?"quote-request":"matched-products",window.history.pushState({boqQuoteStage:ye},"",ee)},[]);(0,Pe.useEffect)(()=>{let ye=ee=>{let se=ee.state?.boqQuoteStage;n(se==="basket"?"basket":se==="results"&&d?"results":"entry")};return window.addEventListener("popstate",ye),()=>window.removeEventListener("popstate",ye)},[d]);let Ye=(0,Pe.useCallback)(()=>{Te("basket"),n("basket")},[Te]),Ve=(0,Pe.useCallback)(()=>{window.history.state?.boqQuoteStage==="basket"?window.history.back():n(d?"results":"entry")},[d]),it=(0,Pe.useRef)(r);(0,Pe.useEffect)(()=>{it.current!==r&&(it.current=r,window.scrollTo(0,0))},[r]);let pe=()=>{n("entry"),o(null),c(""),b(0),h(null),M(!1),A(),z(!1)},Q=(0,Pe.useCallback)(async(ye,ee,se=!0)=>{c(""),b(0);let Me=0,_e=()=>{Me=Math.min(Me+1,3),b(Me)};try{let{jobId:et}=await Ib(ye,ee,se),{promise:Ht,cancel:Tt}=ev(()=>Wb(et),5e3,_e,"schedule");p.current=Tt;let tt=await Ht;if(tt.status==="failed"||!tt.result)throw new Error(tt.error||"Failed to process schedule");let ct=tt.result.lineItems.length,He=tt.result.results.filter(E=>E.candidates.length>0).length;fe("results_shown",{lines:ct,matched:He,unmatched:ct-He}),M(!1),h(tt.result),Te("results"),n("results")}catch(et){fe("error",{stage:"matching"}),c(et?.message||"Failed to process schedule"),n("entry")}finally{p.current?.(),p.current=null}},[Te,fe]),ce=(0,Pe.useCallback)(async(ye,ee,se=!0)=>{let Me=ye.trim();if(!Me)return;o("schedule");let _e=new File([Me],"pasted-schedule.txt",{type:"text/plain"});await Q(_e,ee,se)},[Q]),xe=(0,Pe.useCallback)(async ye=>{o("schedule"),await Q(ye)},[Q]);return(0,Na.jsx)(Zo.Provider,{value:fe,children:(0,Na.jsx)("div",{ref:K,className:`app-wrapper${e?"":" app-wrapper--embedded"}${t?" app-wrapper--no-header":""}${!e&&r==="processing"?" app-wrapper--loading":""}`,style:pr().theme,children:(0,Na.jsxs)("main",{className:"main-content",children:[l&&(0,Na.jsxs)("div",{className:"error-box",role:"alert",children:[(0,Na.jsx)("strong",{children:"Error:"})," ",l]}),r==="entry"&&(0,Na.jsx)(cd,{onPasteSchedule:ce,onUploadSchedule:xe,onEntryModeChange:o}),r==="results"&&i==="schedule"&&d&&(0,Na.jsx)(hd,{scheduleResult:d,onStartOver:pe,cart:D,onAddToCart:m,onRemoveFromCart:u,onGoToBasket:Ye,cartSeeded:T,onCartSeeded:()=>z(!0),reviewGateComplete:w,onReviewGateComplete:()=>M(!0),internal:a}),r==="basket"&&(0,Na.jsx)(rl,{cart:D,onUpdateQty:g,onUpdateSellUnits:v,onRemove:u,onBack:Ve,onStartNewQuote:pe,internal:a})]})})})}var Va=Y(Xe());var ki=Y(Xe()),te=Y(ae()),nw=[{id:"ogee",label:"Ogee",blurb:"Traditional curved profile"},{id:"torus",label:"Torus",blurb:"Soft rounded detail"},{id:"ovolo",label:"Ovolo",blurb:"Traditional rounded profile"},{id:"pencil-round",label:"Pencil round",blurb:"Simple softened edge"},{id:"square-edge",label:"Square edge",blurb:"Clean contemporary edge"}],Is=e=>Number.parseFloat(e)||0,ow=(e,t)=>Is(e)*(t==="m"?1:.3048),vd=(e,t)=>Is(e.quantity)*(2*ow(e.height,t)+ow(e.width,t)),__=()=>({quantity:"1",width:"",height:""});function x_({profile:e}){return(0,te.jsxs)("svg",{className:"architrave-calculator__profile-diagram",viewBox:"0 0 112 76","aria-hidden":"true",children:[(0,te.jsx)("path",{d:{ogee:"M18 62 V38 C18 28 28 22 40 22 H78 C88 22 94 28 94 38 V62",torus:"M18 62 V40 C18 27 30 20 42 20 C54 20 58 30 66 30 C74 30 78 20 90 20 C102 20 94 34 94 40 V62",ovolo:"M18 62 V38 C18 28 30 20 42 20 H70 C82 20 94 28 94 38 V62","pencil-round":"M18 62 V38 C18 28 28 20 40 20 H72 C84 20 94 28 94 38 V62","square-edge":"M18 62 V20 H94 V62"}[e]}),(0,te.jsx)("line",{x1:"12",y1:"66",x2:"100",y2:"66"})]})}function wd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,ki.useState)("m"),[i,o]=(0,ki.useState)({quantity:"1",width:"0.76",height:"1.98"}),[l,c]=(0,ki.useState)({quantity:"0",width:"1.52",height:"1.98"}),[p,f]=(0,ki.useState)([]),[b,d]=(0,ki.useState)("ogee"),[h,w]=(0,ki.useState)("2.4"),M=(N,A,T)=>{N(z=>({...z,[A]:T}))},D=vd(i,r)+vd(l,r)+p.reduce((N,A)=>N+vd(A,r),0),m=Is(h)>0?Math.ceil(D/Is(h)):0,u=nw.find(N=>N.id===b)?.label??"",g=[{key:`architrave-${b}`,label:`Architrave (${u})`,qty:D,unit:"m",query:`${u} architrave`,category:"architrave"}],v=(N,A,T,z)=>(0,te.jsxs)("div",{className:"architrave-calculator__opening-row",children:[(0,te.jsx)("span",{children:N}),(0,te.jsx)("input",{"aria-label":`${N} quantity`,type:"number",min:"0",step:"1",value:A.quantity,onChange:G=>T("quantity",G.target.value)}),(0,te.jsx)("input",{"aria-label":`${N} width`,type:"number",min:"0",step:"0.01",value:A.width,onChange:G=>T("width",G.target.value)}),(0,te.jsx)("input",{"aria-label":`${N} height`,type:"number",min:"0",step:"0.01",value:A.height,onChange:G=>T("height",G.target.value)}),z?(0,te.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:z,children:"Remove"}):null]});return(0,te.jsx)(te.Fragment,{children:(0,te.jsxs)("div",{className:"truss-estimator",children:[(0,te.jsxs)("div",{className:"quick-order-hero",children:[(0,te.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,te.jsx)("h1",{children:"Architrave Calculator"}),(0,te.jsx)("p",{children:"Estimate architrave lengths and board quantities for door openings."})]}),(0,te.jsxs)("div",{className:"truss-estimator__card architrave-calculator",children:[(0,te.jsx)("h2",{className:"truss-estimator__step-title",children:"Measure your openings"}),(0,te.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter each door or window opening. Mitred corners are allowed for, and board lengths are worked out from the net run."}),(0,te.jsxs)("div",{className:"architrave-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Door openings"}),(0,te.jsx)("p",{className:"architrave-calculator__hint",children:"Each opening is calculated as two side pieces plus one head piece."}),(0,te.jsxs)("div",{className:"architrave-calculator__unit-row",children:[(0,te.jsx)("span",{children:"Units"}),(0,te.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,te.jsx)("button",{type:"button",className:r==="m"?"is-selected":"",onClick:()=>n("m"),children:"Metres"}),(0,te.jsx)("button",{type:"button",className:r==="ft"?"is-selected":"",onClick:()=>n("ft"),children:"Feet"})]})]}),(0,te.jsxs)("div",{className:"architrave-calculator__dimensions-header",children:[(0,te.jsx)("span",{children:"Opening"}),(0,te.jsx)("span",{children:"Qty"}),(0,te.jsxs)("span",{children:["Width (",r,")"]}),(0,te.jsxs)("span",{children:["Height (",r,")"]}),(0,te.jsx)("span",{})]}),v("Single doors",i,(N,A)=>M(o,N,A)),v("Double doors",l,(N,A)=>M(c,N,A)),p.map((N,A)=>v(`Alternative door ${A+1}`,N,(T,z)=>f(G=>G.map((K,fe)=>fe===A?{...K,[T]:z}:K)),()=>f(T=>T.filter((z,G)=>G!==A)))),(0,te.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>f(N=>[...N,__()]),children:"+ Add alternative-sized door"})]}),(0,te.jsxs)("div",{className:"architrave-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Standard profile"}),(0,te.jsx)("p",{className:"architrave-calculator__hint",children:"Choose the profile you plan to use. Length calculations are the same for each profile."}),(0,te.jsx)("div",{className:"architrave-calculator__profiles",children:nw.map(N=>(0,te.jsxs)("button",{type:"button",className:`truss-estimator__option-card${b===N.id?" is-selected":""}`,onClick:()=>d(N.id),children:[(0,te.jsx)(x_,{profile:N.id}),(0,te.jsx)("div",{className:"truss-estimator__option-title",children:N.label}),(0,te.jsx)("div",{className:"truss-estimator__option-copy",children:N.blurb})]},N.id))})]}),(0,te.jsxs)("div",{className:"architrave-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Board and waste"}),(0,te.jsx)("div",{className:"architrave-calculator__options",children:(0,te.jsxs)("label",{className:"truss-estimator__field",children:[(0,te.jsx)("span",{children:"Board length (m)"}),(0,te.jsx)("input",{value:"4.40 m",disabled:!0})]})}),(0,te.jsx)("p",{className:"architrave-calculator__hint",children:"Waste allows for mitred corners, cuts and damaged lengths."})]}),(0,te.jsxs)("div",{className:"architrave-calculator__totals",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,te.jsxs)("div",{className:"architrave-calculator__result-grid",children:[(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"Architrave needed"}),(0,te.jsxs)("strong",{children:[D.toFixed(2)," m"]})]}),(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"Board lengths"}),(0,te.jsx)("strong",{children:m})]})]})]}),(0,te.jsxs)("div",{className:"architrave-calculator__actions",children:[(0,te.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,te.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(g),disabled:D<=0,children:a})]})]})]})})}var Ni=Y(Xe()),le=Y(ae()),lw=60,sw=10,k_=.02,N_=.012,S_=.01,Rn=e=>Number.parseFloat(e)||0,C_=(e,t=2)=>e.toFixed(t);function yd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,Ni.useState)("brick"),[i,o]=(0,Ni.useState)("engineering-red"),[l,c]=(0,Ni.useState)("metric"),[p,f]=(0,Ni.useState)(""),[b,d]=(0,Ni.useState)(""),[h,w]=(0,Ni.useState)(!0),M=l==="metric"?Rn(p)*Rn(b):Rn(p)*Rn(b)*.092903,m=M*(r==="brick"?lw:sw),u=Math.ceil(m),g=M*(r==="brick"?k_:N_),v=Math.ceil(g/S_),N=l==="metric"?M:M*10.7639,A=[{key:r==="brick"?`brick-${i}`:"block",label:r==="brick"?{common:"Common concrete bricks","engineering-red":"Red engineering bricks","engineering-blue":"Blue engineering bricks"}[i]:"Blocks",qty:u,unit:"each",query:r==="brick"?"facing brick":"concrete block",category:"masonry"},...h?[{key:"mortar",label:"Blue Circle Quality Assured Mortar Mix 20kg",qty:v,unit:"bag",query:"ready mixed mortar",category:"mortar"}]:[]],T=z=>{if(z===l)return;let G=z==="imperial"?3.28084:.3048;f((Rn(p)*G).toFixed(2)),d((Rn(b)*G).toFixed(2)),c(z)};return(0,le.jsx)(le.Fragment,{children:(0,le.jsxs)("div",{className:"truss-estimator",children:[(0,le.jsxs)("div",{className:"quick-order-hero",children:[(0,le.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,le.jsx)("h1",{children:"Brick & Block Calculator"}),(0,le.jsx)("p",{children:"Estimate masonry units, sand and cement for a wall."})]}),(0,le.jsxs)("div",{className:"truss-estimator__card brick-calculator",children:[(0,le.jsx)("h2",{className:"truss-estimator__step-title",children:"Wall area and masonry type"}),(0,le.jsx)("p",{className:"truss-estimator__step-sub",children:"Pick brick or block and enter the wall dimensions for unit counts plus ready-mixed mortar."}),(0,le.jsxs)("div",{className:"brick-calculator__section",children:[(0,le.jsx)("div",{className:"truss-estimator__section-heading",children:"Masonry type"}),(0,le.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[["brick","Brick"],["block","Block"]].map(([z,G])=>(0,le.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===z?" is-selected":""}`,onClick:()=>n(z),children:[(0,le.jsx)("div",{className:"truss-estimator__option-title",children:G}),(0,le.jsxs)("div",{className:"truss-estimator__option-copy",children:["Approx. ",z==="brick"?lw:sw," per m\xB2"]})]},z))})]}),r==="brick"&&(0,le.jsxs)("div",{className:"brick-calculator__section",children:[(0,le.jsx)("div",{className:"truss-estimator__section-heading",children:"Brick type"}),(0,le.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:[["common","Common concrete","General-purpose grey concrete brick"],["engineering-red","Engineering red","Class B perforated, 65mm"],["engineering-blue","Engineering blue","Class B solid, 65mm"]].map(([z,G,K])=>(0,le.jsxs)("button",{type:"button",className:`truss-estimator__option-card${i===z?" is-selected":""}`,onClick:()=>o(z),children:[(0,le.jsx)("div",{className:"truss-estimator__option-title",children:G}),(0,le.jsx)("div",{className:"truss-estimator__option-copy",children:K})]},z))})]}),(0,le.jsxs)("div",{className:"brick-calculator__section",children:[(0,le.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall dimensions"}),(0,le.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,le.jsx)("button",{type:"button",className:l==="metric"?"is-selected":"",onClick:()=>T("metric"),children:"Metric"}),(0,le.jsx)("button",{type:"button",className:l==="imperial"?"is-selected":"",onClick:()=>T("imperial"),children:"Imperial"})]}),(0,le.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,le.jsxs)("label",{className:"truss-estimator__field",children:[(0,le.jsxs)("span",{children:["Height (",l==="metric"?"m":"ft",")"]}),(0,le.jsx)("input",{type:"number",min:"0",step:"0.01",value:p,onChange:z=>f(z.target.value)})]}),(0,le.jsxs)("label",{className:"truss-estimator__field",children:[(0,le.jsxs)("span",{children:["Width (",l==="metric"?"m":"ft",")"]}),(0,le.jsx)("input",{type:"number",min:"0",step:"0.01",value:b,onChange:z=>d(z.target.value)})]})]})]}),(0,le.jsx)("div",{className:"brick-calculator__options",children:(0,le.jsxs)("label",{className:"brick-calculator__checkbox",children:[(0,le.jsx)("input",{type:"checkbox",checked:h,onChange:z=>w(z.target.checked)}),(0,le.jsx)("span",{children:"Include ready-mixed mortar"})]})}),(0,le.jsxs)("div",{className:"brick-calculator__totals",children:[(0,le.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,le.jsxs)("div",{className:"brick-calculator__result-grid",children:[(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{children:"Wall area"}),(0,le.jsxs)("strong",{children:[C_(N)," ",l==="metric"?"m\xB2":"ft\xB2"]})]}),(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{children:r==="brick"?"Bricks":"Blocks"}),(0,le.jsx)("strong",{children:u.toLocaleString("en-GB")})]}),h?(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{children:"Ready-mixed mortar"}),(0,le.jsxs)("strong",{children:[v," x 20kg bags"]})]}):null]}),(0,le.jsx)("p",{className:"brick-calculator__note",children:"Estimate based on standard nominal sizes and 10mm joints. Mortar bags are approximate; confirm the required mortar specification before ordering."})]}),(0,le.jsxs)("div",{className:"brick-calculator__actions",children:[(0,le.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,le.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(A),disabled:M<=0,children:a})]})]})]})})}var fr=Y(Xe());var cw=new Map;function q_(e){return{product_id:e.product_id,description:e.description,source_list:e.source_list??null,price:e.price??null,list_price:e.list_price,discount:e.discount,price_basis:e.price_basis??null,uoi_count:e.uoi_count??null,uoi:e.uoi??null,pdp_photo_url:e.pdp_photo_url??null,conversion:e.conversion,measurements_mm:e.measurements_mm??e.attrs?.measurements_mm??[],scores:{dimension:0,grade:0,brand:0,fuzzy:0,bm25:0,overall:0},method:"estimator_catalogue_search"}}async function Jr(e,t,a=12,r){let n=`${e}||${t??""}||${a}||${r??""}`,i=cw.get(n);if(i)return i;let o=new URLSearchParams({q:e,limit:String(a)});t&&o.set("category",t),r&&o.set("account",r);let l=await fetch(Bt(`/api/catalogue/search?${o.toString()}`),{headers:wi()}),c=await Zt(l);if(!l.ok)throw new Error(c?.error||c?.message||"Could not reach the product catalogue");let p=Array.isArray(c?.items)?c.items.map(q_):[];return cw.set(n,p),p}async function uw(e,t){return await Promise.all(e.map(async r=>{try{return{requirement:r,candidates:await Jr(r.query,r.category,void 0,t)}}catch{return{requirement:r,candidates:[]}}}))}async function pw(){let e=await fetch(Bt("/api/catalogue"),{headers:wi()});if(!e.ok)return{itemCount:0,uploadedAt:null};let t=await Zt(e);return{itemCount:Number(t?.itemCount)||0,uploadedAt:t?.uploadedAt??null}}var $=Y(ae()),E_=1.54,M_=1440,T_=25,_d=800,z_=1500,xd=e=>Number.parseFloat(e)||0,Un={mot:{label:"MOT Type 1",blurb:"Sub-base for patios and driveways",density:1.7,productId:"6001007"},"sharp-sand":{label:"Sharp sand",blurb:"Bedding and general groundwork",density:1.6,productId:"6001012"},gravel:{label:"20mm gravel",blurb:"Drainage and landscaping",density:1.6,productId:"6001004"}};function kd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let r=Js(),[n,i]=(0,fr.useState)("m"),[o,l]=(0,fr.useState)(""),[c,p]=(0,fr.useState)(""),[f,b]=(0,fr.useState)(""),[d,h]=(0,fr.useState)("concrete"),[w,M]=(0,fr.useState)("mot"),[D,m]=(0,fr.useState)(!1),[u,g]=(0,fr.useState)(null),v=n==="m"?1:.3048,N=xd(o)*v*xd(c)*v*xd(f)*(n==="m"?.01:.0254),A=Un[w],T=N*E_/7,z=T*M_,G=T*2,K=T*4,fe=Math.ceil(z/T_),Te=Math.ceil(G*Un["sharp-sand"].density*1e3/_d),Ye=Math.ceil(K*Un.gravel.density*1e3/_d),Ve=Math.ceil(N*A.density*1e3/_d),it=d==="concrete"?[{key:"cement",label:"Blue Circle General Purpose Grey Cement 25kg",qty:fe,productId:"6003004"},{key:"sharp-sand",label:"Sharp Sand Bulk Bag (800kg)",qty:Te,productId:"6001012"},{key:"gravel",label:"20mm Non Decorative Pea Shingle/Gravel Bulk Bag (800kg)",qty:Ye,productId:"6001004"}]:[{key:w,label:`${A.label} Bulk Bag (800kg)`,qty:Ve,productId:A.productId}],pe=()=>{if(t){t(it.map(ce=>({key:ce.key,label:ce.label,qty:ce.qty,unit:"each",query:ce.productId})));return}Q()},Q=async()=>{let ce=Date.now();m(!0),g(null);try{let xe=await Promise.all(it.map(async ee=>{let se=(await Jr(ee.productId)).find(Me=>Me.product_id===ee.productId);if(!se)throw new Error(`${ee.label} is no longer available in this catalogue.`);return Kr(se,{lineId:`concrete-aggregate:${ee.key}`,description:ee.label,unit:"bag",qty:ee.qty})})),ye=z_-(Date.now()-ce);ye>0&&await new Promise(ee=>window.setTimeout(ee,ye)),r?.clearCart(),r?.addManyToCart(xe),r?.openBasket()}catch(xe){g(xe instanceof Error?xe.message:"Could not add the products to your basket.")}finally{m(!1)}};return D?(0,$.jsx)($.Fragment,{children:(0,$.jsxs)("div",{className:"truss-estimator",children:[(0,$.jsxs)("div",{className:"quick-order-hero",children:[(0,$.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,$.jsx)("h1",{children:"Your Materials"}),(0,$.jsx)("p",{children:"Calculating quantities from the Concrete & Aggregate Calculator."})]}),(0,$.jsx)("div",{className:"truss-estimator__card",children:(0,$.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{flex:1,justifyContent:"center"},children:[(0,$.jsx)(dr,{}),(0,$.jsx)("p",{className:"banter-message is-visible",children:"Preparing your materials\u2026"})]})})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)("div",{className:"truss-estimator",children:[(0,$.jsxs)("div",{className:"quick-order-hero",children:[(0,$.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,$.jsx)("h1",{children:"Concrete & Aggregate Calculator"}),(0,$.jsx)("p",{children:"Calculate fixed site-mix concrete ingredients or aggregate bulk bags."})]}),(0,$.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,$.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose what you need"}),(0,$.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter the area and depth. The calculator adds the fixed Materials Market products directly to your basket."}),(0,$.jsxs)("div",{className:"materials-calculator__section",children:[(0,$.jsx)("div",{className:"truss-estimator__section-heading",children:"Material type"}),(0,$.jsxs)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[(0,$.jsxs)("button",{type:"button",className:`truss-estimator__option-card${d==="concrete"?" is-selected":""}`,onClick:()=>h("concrete"),children:[(0,$.jsx)("div",{className:"truss-estimator__option-title",children:"Site-mixed concrete"}),(0,$.jsx)("div",{className:"truss-estimator__option-copy",children:"Cement, sharp sand and 20mm aggregate"})]}),(0,$.jsxs)("button",{type:"button",className:`truss-estimator__option-card${d==="aggregate"?" is-selected":""}`,onClick:()=>h("aggregate"),children:[(0,$.jsx)("div",{className:"truss-estimator__option-title",children:"Aggregates"}),(0,$.jsx)("div",{className:"truss-estimator__option-copy",children:"MOT Type 1, sharp sand or 20mm gravel"})]})]})]}),d==="aggregate"&&(0,$.jsxs)("div",{className:"materials-calculator__section",children:[(0,$.jsx)("div",{className:"truss-estimator__section-heading",children:"Aggregate type"}),(0,$.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.keys(Un).map(ce=>(0,$.jsxs)("button",{type:"button",className:`truss-estimator__option-card${w===ce?" is-selected":""}`,onClick:()=>M(ce),children:[(0,$.jsx)("div",{className:"truss-estimator__option-title",children:Un[ce].label}),(0,$.jsx)("div",{className:"truss-estimator__option-copy",children:Un[ce].blurb})]},ce))})]}),(0,$.jsxs)("div",{className:"materials-calculator__section",children:[(0,$.jsx)("div",{className:"truss-estimator__section-heading",children:"Area and depth"}),(0,$.jsxs)("div",{className:"materials-calculator__unit-row",children:[(0,$.jsx)("span",{children:"Units"}),(0,$.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,$.jsx)("button",{type:"button",className:n==="m"?"is-selected":"",onClick:()=>i("m"),children:"Metric"}),(0,$.jsx)("button",{type:"button",className:n==="ft"?"is-selected":"",onClick:()=>i("ft"),children:"Imperial"})]})]}),(0,$.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,$.jsxs)("label",{className:"truss-estimator__field",children:[(0,$.jsxs)("span",{children:["Length (",n,")"]}),(0,$.jsx)("input",{type:"number",min:"0",step:"0.01",value:o,onChange:ce=>l(ce.target.value)})]}),(0,$.jsxs)("label",{className:"truss-estimator__field",children:[(0,$.jsxs)("span",{children:["Width (",n,")"]}),(0,$.jsx)("input",{type:"number",min:"0",step:"0.01",value:c,onChange:ce=>p(ce.target.value)})]})]}),(0,$.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,$.jsxs)("span",{children:["Depth (",n==="m"?"cm":"inches",")"]}),(0,$.jsx)("input",{type:"number",min:"0",step:"0.1",value:f,onChange:ce=>b(ce.target.value)})]})]}),(0,$.jsxs)("div",{className:"materials-calculator__totals",children:[(0,$.jsx)("div",{className:"truss-estimator__section-heading",children:"Materials required"}),(0,$.jsx)("div",{className:"materials-calculator__result-grid",children:d==="concrete"?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:"Cement"}),(0,$.jsxs)("strong",{children:[z.toFixed(0)," kg"]})]}),(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:"Sharp sand"}),(0,$.jsxs)("strong",{children:[G.toFixed(2)," m\xB3"]})]}),(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:"20mm aggregate"}),(0,$.jsxs)("strong",{children:[K.toFixed(2)," m\xB3"]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:A.label}),(0,$.jsxs)("strong",{children:[N.toFixed(2)," m\xB3"]})]}),(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:"Approx. weight"}),(0,$.jsxs)("strong",{children:[(N*A.density).toFixed(2)," t"]})]}),(0,$.jsx)("div",{})]})}),(0,$.jsx)("p",{className:"materials-calculator__note",children:d==="concrete"?"Based on a 1:2:4 mix. Confirm the mix design for structural work.":"Figures are estimates. Confirm the specification and supplier quantities before ordering."})]}),u&&(0,$.jsx)("p",{className:"results-empty-hint estimator-products__error",children:u}),(0,$.jsxs)("div",{className:"materials-calculator__actions",children:[(0,$.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,$.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:pe,disabled:N<=0||D,children:D?"Adding products\u2026":a})]})]})]})})}var Ya=Y(Xe());var U=Y(ae()),Dn=12,Bn=8,Ws=.56,dw=.21,Sa={ranges:{meridian:{label:"Standard grooved timber",blurb:"32 \xD7 125mm pressure-treated softwood boards.",boardLengthM:3.6,boardWidthM:.125},summit:{label:"Wide grooved timber",blurb:"32 \xD7 150mm pressure-treated softwood boards.",boardLengthM:3.6,boardWidthM:.15}},boardGapM:.006,wastage:{straight:.05,diagonal:.15},pictureFrame:{extraWastage:.08},joist:{lengthM:2.4,spacingOptions:[{id:"300",label:"300mm centres (heavy duty)",spacingM:.3},{id:"400",label:"400mm centres (standard)",spacingM:.4},{id:"450",label:"450mm centres (light use)",spacingM:.45}]}},Si=["range","grid","pictureFrame","substructure"],A_={range:null,colour:null,deckSizeMode:"quick",quickLengthM:"",quickWidthM:"",points:[],isOutlineClosed:!1,wallSegments:new Set,drawMode:"outline",drawError:"",pictureFrame:null,direction:null,deckHeightMode:"standard",deckHeightCm:"",joistSpacing:null,supportType:null,contact:{name:"",email:""}},ec=(e,t,a)=>(t.x-e.x)*(a.y-e.y)-(t.y-e.y)*(a.x-e.x),tc=(e,t,a)=>a.x>=Math.min(e.x,t.x)&&a.x<=Math.max(e.x,t.x)&&a.y>=Math.min(e.y,t.y)&&a.y<=Math.max(e.y,t.y),R_=(e,t,a,r)=>{let n=ec(e,t,a),i=ec(e,t,r),o=ec(a,r,e),l=ec(a,r,t);return n===0&&tc(e,t,a)||i===0&&tc(e,t,r)||o===0&&tc(a,r,e)||l===0&&tc(a,r,t)?!0:n>0!=i>0&&o>0!=l>0},Nd=(e,t)=>{let a=t?e.length:e.length-1;for(let r=0;r<a;r+=1){let n=e[(r+1)%e.length];for(let i=r+1;i<a;i+=1)if(!(i===r+1||t&&r===0&&i===a-1)&&R_(e[r],n,e[i],e[(i+1)%e.length]))return!0}return!1};function Sd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,Ya.useState)(0),[i,o]=(0,Ya.useState)(A_),[l,c]=(0,Ya.useState)(1),[p,f]=(0,Ya.useState)({x:0,y:0}),[b,d]=(0,Ya.useState)(null),h=(0,Ya.useRef)(null),w=(0,Ya.useRef)(null),M=(0,Ya.useRef)(null),D=Si[r],m=i.range?Sa.ranges[i.range]:null,u=Dn/l,g=Bn/l,v=(Dn-u)/2,N=(Bn-g)/2,A=Math.max(-Dn,Math.min(Dn*2-u,v+p.x)),T=Math.max(-Bn,Math.min(Bn*2-g,N+p.y)),z=Number.parseFloat(i.quickLengthM),G=Number.parseFloat(i.quickWidthM),K=z>0&&G>0,fe=E=>Math.abs(E.reduce((x,R,I)=>{let ue=E[(I+1)%E.length];return x+R.x*ue.y-ue.x*R.y},0))/2,Te=(E,x)=>Math.hypot(x.x-E.x,x.y-E.y),Ye=i.isOutlineClosed?fe(i.points):0,Ve=i.isOutlineClosed?i.points.reduce((E,x,R)=>E+Te(x,i.points[(R+1)%i.points.length]),0):0,it=i.isOutlineClosed?i.points.reduce((E,x,R)=>E+(i.wallSegments.has(R)?0:Te(x,i.points[(R+1)%i.points.length])),0):0,pe=i.points.reduce((E,x)=>({x:E.x+x.x/i.points.length,y:E.y+x.y/i.points.length}),{x:0,y:0}),Q=i.points.length>1?(()=>{let E=i.points[0],x=i.points[1],R=Te(E,x),I=R?-(x.y-E.y)/R:0,ue=R?(x.x-E.x)/R:0,ve=(E.x+x.x)/2,Se=(E.y+x.y)/2,k=I*(ve-pe.x)+ue*(Se-pe.y)>=0?1:-1;return{x:ve+I*Ws*k,y:Se+ue*Ws*k}})():null,xe=(()=>{let E=i.range?Sa.ranges[i.range]:Sa.ranges.meridian,x=i.deckSizeMode==="quick"?z*G:Ye,R=i.deckSizeMode==="quick"?2*(z+G):it,I=i.direction==="diagonal"?Sa.wastage.diagonal:Sa.wastage.straight,ue=i.pictureFrame==="yes"?Sa.pictureFrame.extraWastage:0,Se=x/(E.boardWidthM+Sa.boardGapM)/E.boardLengthM,k=Math.ceil(Se*(1+I+ue)),j=Math.ceil(x*30*(1+I+ue)/200),O=Sa.joist.spacingOptions.find(C=>C.id===i.joistSpacing)??Sa.joist.spacingOptions[1],ne=x/O.spacingM,W=Math.ceil(ne/Sa.joist.lengthM);return{range:E,area:x,boardCount:k,screwBoxes:j,joistLengthsNeeded:W,spacing:O}})(),ye=xe?[{key:`boards-${i.range??"meridian"}`,label:`Deck boards (${xe.range.label})`,qty:xe.boardCount,unit:"each",query:"timber decking board",category:"decking",calculatorWasteIncluded:!0},{key:"joists",label:"Treated C24 joists",qty:xe.joistLengthsNeeded,unit:"each",query:"treated joist",category:"timber",calculatorWasteIncluded:!0},{key:"screws",label:"Green decking screws (200/box)",qty:xe.screwBoxes,unit:"box",query:"green decking screws",category:"fixings",calculatorWasteIncluded:!0}]:[],ee=()=>D==="range"?!!i.range:D==="grid"?i.deckSizeMode==="quick"?K:i.isOutlineClosed&&Ye>0:D==="pictureFrame"?!!i.pictureFrame&&!!i.direction:D==="substructure"?!!i.joistSpacing:!0,se=r===Si.length-1?a:"Next",Me=(E,x,R=!1)=>{let I=M.current?.getBoundingClientRect();if(!I)return null;let ue=R?1:.25;return{x:Math.round(Math.max(A,Math.min(A+u,A+(E-I.left)/I.width*u))/ue)*ue,y:Math.round(Math.max(T,Math.min(T+g,T+(x-I.top)/I.height*g))/ue)*ue}},_e=E=>{if(i.isOutlineClosed){let R=E.target;if(R!==E.currentTarget&&!R.classList.contains("deck-outline__grid"))return;w.current={startX:E.clientX,startY:E.clientY,startViewX:A,startViewY:T},E.currentTarget.setPointerCapture(E.pointerId);return}if(i.drawMode!=="outline")return;let x=Me(E.clientX,E.clientY,!0);x&&(d(null),o(R=>{let I=[...R.points,x];return Nd(I,!1)?{...R,drawError:"Edges cannot cross. Choose another corner."}:{...R,points:I,drawError:""}}))},et=(E,x)=>{if(!i.isOutlineClosed){E.stopPropagation(),x===0&&i.points.length>=3&&o(R=>({...R,isOutlineClosed:!0,drawMode:"edges"}));return}E.stopPropagation(),h.current=x,E.currentTarget.setPointerCapture(E.pointerId)},Ht=E=>{if(w.current){let I=M.current?.getBoundingClientRect();if(!I)return;let ue=w.current,ve=ue.startViewX-(E.clientX-ue.startX)/I.width*u,Se=ue.startViewY-(E.clientY-ue.startY)/I.height*g;f({x:ve-v,y:Se-N});return}!i.isOutlineClosed&&i.drawMode==="outline"&&d(Me(E.clientX,E.clientY,!0));let x=h.current;if(x===null)return;let R=Me(E.clientX,E.clientY);R&&o(I=>{let ue=I.points.map((ve,Se)=>Se===x?R:ve);return Nd(ue,!0)?{...I,drawError:"Edges cannot cross. Move the corner to a different position."}:{...I,points:ue,drawError:""}})},Tt=E=>{w.current=null,h.current=null,E.currentTarget.hasPointerCapture(E.pointerId)&&E.currentTarget.releasePointerCapture(E.pointerId)},tt=E=>{o(x=>{let R=new Set(x.wallSegments);return R.has(E)?R.delete(E):R.add(E),{...x,wallSegments:R}})},ct=()=>{r===0?e():n(E=>E-1)},He=()=>{ee()&&(r===Si.length-1?t?.(ye):n(E=>E+1))};return(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)("div",{className:"truss-estimator",children:[(0,U.jsxs)("div",{className:"quick-order-hero",children:[(0,U.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,U.jsx)("h1",{children:"Decking Calculator"}),(0,U.jsx)("p",{children:"Estimate timber boards, joists and screws for your deck."})]}),(0,U.jsxs)("div",{className:"truss-estimator__card",children:[(0,U.jsxs)("div",{className:"truss-estimator__body",children:[D==="range"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Si.length]}),(0,U.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your timber decking"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"Both options are fixed, orderable pressure-treated timber boards."}),(0,U.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Sa.ranges).map(([E,x])=>(0,U.jsxs)("button",{type:"button",className:`truss-estimator__option-card${i.range===E?" is-selected":""}`,onClick:()=>o(R=>({...R,range:E})),children:[(0,U.jsx)("div",{className:"truss-estimator__option-title",children:x.label}),(0,U.jsx)("div",{className:"truss-estimator__option-copy",children:x.blurb}),(0,U.jsxs)("div",{className:"truss-estimator__option-copy",children:[x.boardLengthM,"m boards"]})]},E))})]}):null,D==="grid"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Si.length]}),(0,U.jsx)("h2",{className:"truss-estimator__step-title",children:"Tell us your deck size"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"Start with a quick rectangle estimate, or draw an irregular deck for a more precise result."}),(0,U.jsxs)("div",{className:"truss-estimator__toggle-row",children:[(0,U.jsx)("button",{type:"button",className:`truss-estimator__toggle${i.deckSizeMode==="quick"?" is-selected":""}`,onClick:()=>o(E=>({...E,deckSizeMode:"quick"})),children:"Quick estimate"}),(0,U.jsx)("button",{type:"button",className:`truss-estimator__toggle${i.deckSizeMode==="draw"?" is-selected":""}`,onClick:()=>o(E=>({...E,deckSizeMode:"draw",drawMode:"outline"})),children:"Draw your space"})]}),i.deckSizeMode==="quick"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,U.jsxs)("label",{className:"truss-estimator__field",children:[(0,U.jsx)("span",{children:"Length (m)"}),(0,U.jsx)("input",{type:"number",inputMode:"decimal",min:"0.1",step:"0.1",value:i.quickLengthM,onChange:E=>o(x=>({...x,quickLengthM:E.target.value}))})]}),(0,U.jsxs)("label",{className:"truss-estimator__field",children:[(0,U.jsx)("span",{children:"Width (m)"}),(0,U.jsx)("input",{type:"number",inputMode:"decimal",min:"0.1",step:"0.1",value:i.quickWidthM,onChange:E=>o(x=>({...x,quickWidthM:E.target.value}))})]})]}),(0,U.jsx)("div",{className:"truss-estimator__grid-hint",children:"For L-shaped decks, cut-outs, or sides against a wall, use Draw your space."}),K?(0,U.jsxs)("div",{className:"truss-estimator__grid-stats",children:[(0,U.jsxs)("div",{children:[(z*G).toFixed(2)," m\xB2 deck"]}),(0,U.jsxs)("div",{children:[(2*(z+G)).toFixed(2)," m perimeter"]})]}):null]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"truss-estimator__section-heading",children:"Draw your deck"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"Click to add corners, then close the outline. Drag any handle to refine it."}),(0,U.jsxs)("div",{className:"deck-outline__toolbar",children:[i.isOutlineClosed?(0,U.jsxs)("div",{className:"deck-outline__summary",children:[(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{children:"Deck area"}),(0,U.jsxs)("strong",{children:[Ye.toFixed(2)," m\xB2"]})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{children:"Perimeter"}),(0,U.jsxs)("strong",{children:[Ve.toFixed(2)," m"]})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{children:"Wall edges"}),(0,U.jsx)("strong",{children:i.wallSegments.size>0?i.wallSegments.size:"None"})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{children:"Visible edge"}),(0,U.jsxs)("strong",{children:[it.toFixed(2)," m"]})]})]}):null,(0,U.jsxs)("div",{className:"deck-outline__actions",children:[(0,U.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(E=>({...E,points:E.points.slice(0,-1)})),disabled:i.points.length===0||i.isOutlineClosed,children:"Undo"}),(0,U.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>{d(null),o(E=>({...E,points:[],isOutlineClosed:!1,wallSegments:new Set,drawMode:"outline",drawError:""}))},disabled:i.points.length===0,children:"Clear"}),(0,U.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(E=>({...E,points:[{x:2,y:2},{x:8,y:2},{x:8,y:5},{x:2,y:5}],isOutlineClosed:!0,wallSegments:new Set,drawMode:"edges",drawError:""})),children:"Start with rectangle"})]})]}),(0,U.jsx)("div",{className:"deck-editor-layout",children:(0,U.jsxs)("div",{className:"deck-editor-layout__canvas-column",children:[(0,U.jsxs)("div",{className:"deck-outline",children:[(0,U.jsxs)("svg",{ref:M,className:`deck-outline__canvas${i.isOutlineClosed?" is-pan-mode":""}`,viewBox:`${A} ${T} ${u} ${g}`,preserveAspectRatio:"none","aria-label":"Deck outline drawing area",onPointerDown:_e,onPointerMove:Ht,onPointerUp:Tt,onPointerLeave:()=>{d(null),w.current||(h.current=null)},children:[(0,U.jsx)("defs",{children:(0,U.jsx)("pattern",{id:"deck-outline-grid",width:"1",height:"1",patternUnits:"userSpaceOnUse",children:(0,U.jsx)("path",{d:"M 1 0 L 0 0 0 1",fill:"none",stroke:"currentColor",strokeWidth:"0.03"})})}),(0,U.jsx)("rect",{x:-Dn,y:-Bn,width:Dn*3,height:Bn*3,className:"deck-outline__grid",fill:"url(#deck-outline-grid)"}),i.points.length>1?(0,U.jsx)("polyline",{className:"deck-outline__preview",points:i.points.map(E=>`${E.x},${E.y}`).join(" ")}):null,i.isOutlineClosed?(0,U.jsx)("polygon",{className:"deck-outline__shape",points:i.points.map(E=>`${E.x},${E.y}`).join(" "),stroke:"none"}):null,i.points.length>1?i.points.slice(0,i.isOutlineClosed?void 0:-1).map((E,x)=>{let R=i.points[i.isOutlineClosed?(x+1)%i.points.length:x+1],I=Te(E,R),ue=I?-(R.y-E.y)/I:0,ve=I?(R.x-E.x)/I:0,Se=(E.x+R.x)/2,k=(E.y+R.y)/2,j=ue*(Se-pe.x)+ve*(k-pe.y)>=0?1:-1,O=Se+ue*Ws*j,ne=k+ve*Ws*j;return(0,U.jsxs)("g",{children:[(0,U.jsx)("line",{className:"deck-outline__edge-hit",x1:E.x,y1:E.y,x2:R.x,y2:R.y,onClick:i.isOutlineClosed?()=>tt(x):void 0}),(0,U.jsx)("line",{className:`deck-outline__edge${i.wallSegments.has(x)?" is-wall":""}`,x1:E.x,y1:E.y,x2:R.x,y2:R.y,pointerEvents:"none"}),(0,U.jsxs)("text",{className:`deck-outline__edge-label${i.wallSegments.has(x)?" is-wall":""}`,x:O,y:ne,textAnchor:"middle",dominantBaseline:"central",fontSize:dw/l,children:[I.toFixed(2)," m"]})]},`segment-${x}`)}):null,!i.isOutlineClosed&&i.points.length>0&&b?(()=>{let E=i.points[i.points.length-1],x=Te(E,b);if(!x)return null;let R=-(b.y-E.y)/x,I=(b.x-E.x)/x,ue=(E.x+b.x)/2,ve=(E.y+b.y)/2;return(0,U.jsxs)("g",{className:"deck-outline__live-measurement",children:[(0,U.jsx)("line",{x1:E.x,y1:E.y,x2:b.x,y2:b.y}),(0,U.jsxs)("text",{x:ue+R*.34,y:ve+I*.34,textAnchor:"middle",dominantBaseline:"central",fontSize:dw/l,children:[x.toFixed(2)," m"]})]})})():null,i.points.map((E,x)=>(0,U.jsx)("circle",{className:"deck-outline__point",cx:E.x,cy:E.y,r:"0.13",onPointerDown:R=>et(R,x)},`point-${x}`))]}),(0,U.jsxs)("div",{className:"deck-outline__zoom","aria-label":"Zoom controls",children:[(0,U.jsx)("button",{type:"button",onClick:()=>c(E=>Math.max(.5,E-.25)),disabled:l===.5,"aria-label":"Zoom out",children:"\u2212"}),(0,U.jsxs)("span",{children:[Math.round(l*100),"%"]}),(0,U.jsx)("button",{type:"button",onClick:()=>c(E=>Math.min(1,E+.25)),disabled:l===1,"aria-label":"Zoom in",children:"+"})]}),i.isOutlineClosed&&i.wallSegments.size===0&&Q?(0,U.jsx)("div",{className:"deck-outline__edge-prompt",role:"status",style:{left:`${(Q.x-A)/u*100}%`,top:`${(Q.y-T)/g*100}%`},children:"Tap an edge to mark it as a wall, or leave it as a visible edge."}):null,!i.isOutlineClosed&&i.points.length>=3?(0,U.jsx)("button",{type:"button",className:"deck-outline__close",onClick:()=>o(E=>Nd(E.points,!0)?{...E,drawError:"Edges cannot cross. Adjust the outline before finishing."}:{...E,isOutlineClosed:!0,drawMode:"edges",drawError:""}),children:"Finish outline"}):null]}),(0,U.jsxs)("div",{className:"deck-outline__supporting",children:[(0,U.jsx)("div",{className:"truss-estimator__grid-hint",children:i.isOutlineClosed?"Drag a corner handle to refine the outline.":"Add at least three corners, then click Finish outline."}),i.drawError?(0,U.jsx)("div",{className:"deck-outline__error",role:"alert",children:i.drawError}):null]})]})})]})]}):null,D==="pictureFrame"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Si.length]}),(0,U.jsx)("h2",{className:"truss-estimator__step-title",children:"Picture frame border?"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"A picture frame border runs boards around the perimeter for a finished look and uses extra material."}),(0,U.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"no",label:"No border",img:"/decking/boards/no-border.webp"},{id:"yes",label:"Picture frame",img:"/decking/boards/picture-frame.webp"}].map(E=>(0,U.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${i.pictureFrame===E.id?" is-selected":""}`,onClick:()=>o(x=>({...x,pictureFrame:E.id})),children:[(0,U.jsx)("img",{className:"truss-estimator__visual-card-img",src:Kt(E.img),alt:""}),(0,U.jsx)("span",{children:E.label})]},E.id))}),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"truss-estimator__section-heading",children:"Board direction"}),(0,U.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"straight",label:"Straight",img:"/decking/boards/straight.webp"},{id:"diagonal",label:"Diagonal",img:"/decking/boards/diagonal.webp"}].map(E=>(0,U.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${i.direction===E.id?" is-selected":""}`,onClick:()=>o(x=>({...x,direction:E.id})),children:[(0,U.jsx)("img",{className:"truss-estimator__visual-card-img",src:Kt(E.img),alt:""}),(0,U.jsx)("span",{children:E.label})]},E.id))})]})]}):null,D==="substructure"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Si.length]}),(0,U.jsx)("h2",{className:"truss-estimator__step-title",children:"Substructure"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose the joist spacing. Posts, footings and ground preparation vary by site, so are not included."}),(0,U.jsx)("div",{className:"truss-estimator__section-heading",children:"Joist spacing"}),(0,U.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Sa.joist.spacingOptions.map(E=>(0,U.jsx)("button",{type:"button",className:`truss-estimator__option-card${i.joistSpacing===E.id?" is-selected":""}`,onClick:()=>o(x=>({...x,joistSpacing:E.id})),children:(0,U.jsx)("div",{className:"truss-estimator__option-title",children:E.label})},E.id))})]}):null]}),(0,U.jsxs)("div",{className:"truss-estimator__nav",children:[(0,U.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:ct,children:"Back"}),(0,U.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:He,disabled:!ee(),children:[(0,U.jsx)("span",{children:se}),(0,U.jsx)("span",{className:"arrow",children:(0,U.jsx)(Ot,{})})]})]})]})]})})}var qa=Y(Xe());var H=Y(ae()),mw=12,fw=30,On=12,Ln=8,gw=.56,Ca={ranges:{boundary:{label:"Horizontal lap",blurb:"Traditional pressure-treated timber panels.",panelWidthM:1.83},skyline:{label:"Feather edge",blurb:"Heavier timber panels for a more solid boundary.",panelWidthM:1.83}},heights:["0.9","1.2","1.5","1.8"],gate:{single:{label:"Single lap gate",widthDefault:.9}},mounting:{concrete:{label:"Concrete posts",blurb:"Slotted concrete posts with matching panels."},postcrete:{label:"Postcrete bags",blurb:"Fast-set post-mix bags in a dug hole.",bagsPerPost:2}}},Ci=["range","height","gate","posts"],U_={range:null,colour:null,grid:new Set,excludedEdges:new Set,gridMode:"draw",boundaryMode:"quick",quickLengthM:"",boundaryPoints:[],boundaryClosed:!1,excludedBoundaryEdges:new Set,height:null,gravelBoard:null,gateType:null,gateWidthM:"",mountingType:null,contact:{name:"",email:""}},ac=(e,t,a)=>(t.x-e.x)*(a.y-e.y)-(t.y-e.y)*(a.x-e.x),rc=(e,t,a)=>a.x>=Math.min(e.x,t.x)&&a.x<=Math.max(e.x,t.x)&&a.y>=Math.min(e.y,t.y)&&a.y<=Math.max(e.y,t.y),D_=(e,t,a,r)=>{let n=ac(e,t,a),i=ac(e,t,r),o=ac(a,r,e),l=ac(a,r,t);return n===0&&rc(e,t,a)||i===0&&rc(e,t,r)||o===0&&rc(a,r,e)||l===0&&rc(a,r,t)?!0:n>0!=i>0&&o>0!=l>0},ic=(e,t)=>{let a=t?e.length:e.length-1;for(let r=0;r<a;r+=1)for(let n=r+1;n<a;n+=1)if(!(n===r+1||t&&r===0&&n===a-1)&&D_(e[r],e[(r+1)%e.length],e[n],e[(n+1)%e.length]))return!0;return!1};function Cd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,qa.useState)(0),[i,o]=(0,qa.useState)(U_),l=(0,qa.useRef)(null),c=(0,qa.useRef)(null),[p,f]=(0,qa.useState)(1),[b,d]=(0,qa.useState)({x:0,y:0}),[h,w]=(0,qa.useState)(null),M=(0,qa.useRef)(null),D=(0,qa.useRef)(null),m=(0,qa.useRef)(null),u=Ci[r],g=i.range?Ca.ranges[i.range]:null,v=On/p,N=Ln/p,A=(On-v)/2,T=(Ln-N)/2,z=Math.max(-On,Math.min(On*2-v,A+b.x)),G=Math.max(-Ln,Math.min(Ln*2-N,T+b.y)),K=i.boundaryPoints.reduce((k,j)=>({x:k.x+j.x/Math.max(1,i.boundaryPoints.length),y:k.y+j.y/Math.max(1,i.boundaryPoints.length)}),{x:0,y:0}),fe=k=>{let j=new Set,O=[];return k.forEach(ne=>{let[W,C]=ne.split(",").map(Number),V=[{key:`H,${W},${C}`,type:"H",x:W,y:C},{key:`H,${W},${C+1}`,type:"H",x:W,y:C+1},{key:`V,${W},${C}`,type:"V",x:W,y:C},{key:`V,${W+1},${C}`,type:"V",x:W+1,y:C}],X=[!k.has(`${W},${C-1}`),!k.has(`${W},${C+1}`),!k.has(`${W-1},${C}`),!k.has(`${W+1},${C}`)];V.forEach((me,Ce)=>{X[Ce]&&!j.has(me.key)&&(j.add(me.key),O.push(me))})}),O},Te=(k,j)=>fe(k).filter(O=>!j.has(O.key)),Ye=(k,j)=>Te(k,j).length,Ve=(k,j)=>{let O={};Te(k,j).forEach(W=>{var C,V,X,me;W.type==="H"?((O[C=`${W.x},${W.y}`]||(O[C]=[])).push("H"),(O[V=`${W.x+1},${W.y}`]||(O[V]=[])).push("H")):((O[X=`${W.x},${W.y}`]||(O[X]=[])).push("V"),(O[me=`${W.x},${W.y+1}`]||(O[me]=[])).push("V"))});let ne=0;return Object.values(O).forEach(W=>{(W.length===1||W.length===2&&W[0]!==W[1]||W.length>=3)&&(ne+=1)}),ne},pe=(()=>{let k=i.range?Ca.ranges[i.range]:Ca.ranges.boundary,j=i.height??"1.8",O=i.boundaryMode==="quick"?Math.max(0,Number.parseFloat(i.quickLengthM)||0):i.boundaryClosed?i.boundaryPoints.slice(0,-1).reduce((hr,Jt,Ft)=>hr+(i.excludedBoundaryEdges.has(Ft)?0:Math.hypot(i.boundaryPoints[Ft+1].x-Jt.x,i.boundaryPoints[Ft+1].y-Jt.y)),0):0,ne=i.gateType&&i.gateType!=="none"?Number.parseFloat(i.gateWidthM)||Ca.gate[i.gateType].widthDefault:0,W=Math.max(0,O-ne),C=W>0?Math.ceil(W/k.panelWidthM):0,V=i.boundaryPoints.length>2&&i.boundaryPoints[0].x===i.boundaryPoints[i.boundaryPoints.length-1].x&&i.boundaryPoints[0].y===i.boundaryPoints[i.boundaryPoints.length-1].y,X=i.boundaryMode==="quick"?W>0?2:0:i.boundaryClosed?i.boundaryPoints.slice(0,V?-1:void 0).reduce((hr,Jt,Ft)=>{let Yd=Ft>0&&!i.excludedBoundaryEdges.has(Ft-1),Vd=Ft<i.boundaryPoints.length-1&&!i.excludedBoundaryEdges.has(Ft);return hr+(Yd||Vd?1:0)},0):0,me=W>0?Math.ceil(W/k.panelWidthM)+1:0,Ce=Math.max(0,me-X),dt=i.mountingType?Ca.mounting[i.mountingType]:Ca.mounting.concrete,je=i.gateType&&i.gateType!=="none"?2:0,Fr=Ce+X+je,Ir=i.mountingType==="postcrete"?Fr*Ca.mounting.postcrete.bagsPerPost:0,ll=i.gravelBoard==="yes"?C:0;return{range:k,height:j,totalEdgeM:O,fencedLengthM:W,gateWidthM:ne,panelsCount:C,cornerPostCount:X,intermediatePostCount:Ce,gatePostCount:je,totalPostCount:Fr,bagsCount:Ir,gravelCount:ll,capCount:Fr,mounting:dt}})(),Q=i.gateType&&i.gateType!=="none"?Ca.gate[i.gateType].label:null,ce=Number(pe.height)<=1.2?"6":"8",xe=pe?[{key:`panels-${i.range??"boundary"}-${pe.height}`,label:`${pe.range.label} panels (${pe.height}m)`,qty:pe.panelsCount,unit:"each",query:"fence panel",category:"fencing"},...i.mountingType==="concrete"?[{key:`concrete-intermediate-${ce}`,label:"Intermediate concrete posts",qty:pe.intermediatePostCount,unit:"each",query:"concrete fence post",category:"fencing"},{key:`concrete-end-${ce}`,label:"End and corner concrete posts",qty:pe.cornerPostCount+pe.gatePostCount,unit:"each",query:"concrete end post",category:"fencing"}]:[{key:`timber-post-${ce}`,label:"Timber fence posts",qty:pe.totalPostCount,unit:"each",query:"timber fence post",category:"fencing"},{key:"postcrete",label:"Postcrete",qty:pe.bagsCount,unit:"bag",query:"postcrete",category:"cement"}],...Q?[{key:"gate",label:Q,qty:1,unit:"each",query:"lap gate",category:"fencing"}]:[],...pe.gravelCount>0?[{key:"gravel-boards",label:"Concrete gravel boards",qty:pe.gravelCount,unit:"each",query:"gravel board",category:"fencing"}]:[]]:[],ye=()=>{if(u==="range"){let k=i.boundaryMode==="quick"?(Number.parseFloat(i.quickLengthM)||0)>0:i.boundaryClosed&&i.boundaryPoints.length>=2;return!!i.range&&k}return u==="height"?!!i.height&&!!i.gravelBoard:u==="gate"?!!i.gateType&&(i.gateType==="none"||i.gateWidthM.trim()!==""):u==="posts"?!!i.mountingType:!0},ee=r===Ci.length-1?a:"Next",se=k=>{o(j=>{let O=k(new Set(j.grid)),ne=new Set([...j.excludedEdges].filter(W=>fe(O).some(C=>C.key===W)));return{...j,grid:O,excludedEdges:ne}})},Me=(k,j,O)=>{se(ne=>{let W=`${k},${j}`;return O?ne.add(W):ne.delete(W),ne})},_e=(k,j,O,ne,W)=>{let C=k,V=j,X=Math.abs(O-k),me=k<O?1:-1,Ce=-Math.abs(ne-j),dt=j<ne?1:-1,je=X+Ce;for(;Me(C,V,W),!(C===O&&V===ne);){let Fr=2*je;Fr>=Ce&&(je+=Ce,C+=me),Fr<=X&&(je+=X,V+=dt)}},et=(k,j)=>{let O=c.current?.getBoundingClientRect();if(!O)return null;let ne=Math.floor((k-O.left)/fw),W=Math.floor((j-O.top)/fw);return ne<0||W<0||ne>=mw||W>=mw?null:{x:ne,y:W}},Ht=k=>{if(i.gridMode!=="draw")return;let j=et(k.clientX,k.clientY);if(!j)return;k.preventDefault();let O=`${j.x},${j.y}`,ne=!i.grid.has(O);l.current={active:!0,paintValue:ne,lastX:j.x,lastY:j.y},k.currentTarget.setPointerCapture(k.pointerId),Me(j.x,j.y,ne)},Tt=k=>{let j=l.current;if(!j?.active)return;let O=et(k.clientX,k.clientY);O&&(O.x===j.lastX&&O.y===j.lastY||(_e(j.lastX,j.lastY,O.x,O.y,j.paintValue),l.current={...j,lastX:O.x,lastY:O.y}))},tt=k=>{l.current?.active&&(l.current=null,k.currentTarget.releasePointerCapture(k.pointerId))},ct=(k,j,O=!1)=>{let ne=m.current?.getBoundingClientRect();if(!ne)return null;let W=O?1:.25;return{x:Math.round(Math.max(z,Math.min(z+v,z+(k-ne.left)/ne.width*v))/W)*W,y:Math.round(Math.max(G,Math.min(G+N,G+(j-ne.top)/ne.height*N))/W)*W}},He=k=>{if(i.boundaryClosed){let O=k.target;if(O!==k.currentTarget&&!O.classList.contains("fence-boundary__grid"))return;D.current={startX:k.clientX,startY:k.clientY,startViewX:z,startViewY:G},k.currentTarget.setPointerCapture(k.pointerId);return}let j=ct(k.clientX,k.clientY,!0);j&&(w(null),o(O=>{let ne=[...O.boundaryPoints,j];return ic(ne,!1)?{...O}:{...O,boundaryPoints:ne}}))},E=(k,j)=>{if(k.stopPropagation(),!i.boundaryClosed){if(j!==0||i.boundaryPoints.length<3)return;o(O=>ic(O.boundaryPoints,!0)?O:{...O,boundaryPoints:[...O.boundaryPoints,O.boundaryPoints[0]],boundaryClosed:!0});return}M.current=j,k.currentTarget.setPointerCapture(k.pointerId)},x=k=>{if(D.current){let O=m.current?.getBoundingClientRect();if(!O)return;let ne=D.current,W=ne.startViewX-(k.clientX-ne.startX)/O.width*v,C=ne.startViewY-(k.clientY-ne.startY)/O.height*N;d({x:W-A,y:C-T});return}if(i.boundaryClosed||w(ct(k.clientX,k.clientY,!0)),M.current===null)return;let j=ct(k.clientX,k.clientY);j&&o(O=>{let ne=O.boundaryPoints.length>2&&O.boundaryPoints[0].x===O.boundaryPoints[O.boundaryPoints.length-1].x&&O.boundaryPoints[0].y===O.boundaryPoints[O.boundaryPoints.length-1].y,W=O.boundaryPoints.map((C,V)=>{let X=V===M.current,me=ne&&M.current===0&&V===O.boundaryPoints.length-1;return X||me?j:C});return ic(W,!1)?O:{...O,boundaryPoints:W}})},R=k=>{D.current=null,M.current=null,k.currentTarget.hasPointerCapture(k.pointerId)&&k.currentTarget.releasePointerCapture(k.pointerId)},I=k=>{o(j=>{let O=new Set(j.excludedBoundaryEdges);return O.has(k)?O.delete(k):O.add(k),{...j,excludedBoundaryEdges:O}})},ue=()=>{r===0?e():n(k=>k-1)},ve=()=>{ye()&&(r===Ci.length-1?t?.(xe):n(k=>k+1))},Se=fe(i.grid);return(0,H.jsx)(H.Fragment,{children:(0,H.jsxs)("div",{className:"truss-estimator",children:[(0,H.jsxs)("div",{className:"quick-order-hero",children:[(0,H.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,H.jsx)("h1",{children:"Fencing Calculator"}),(0,H.jsx)("p",{children:"Estimate panels, posts and cost for your fence line in a few steps."})]}),(0,H.jsxs)("div",{className:"truss-estimator__card",children:[(0,H.jsxs)("div",{className:"truss-estimator__body",children:[u==="range"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ci.length]}),(0,H.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your fence panels"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"The calculator uses fixed, orderable timber panels from the catalogue."}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Ca.ranges).map(([k,j])=>(0,H.jsxs)("button",{type:"button",className:`truss-estimator__option-card${i.range===k?" is-selected":""}`,onClick:()=>o(O=>({...O,range:k})),children:[(0,H.jsx)("div",{className:"truss-estimator__option-title",children:j.label}),(0,H.jsx)("div",{className:"truss-estimator__option-copy",children:j.blurb})]},k))})]}):null,u==="range"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"truss-estimator__section-heading",children:"Measure your fence line"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"Use a quick total, or draw the boundary to mark existing edges that do not need new fencing."}),(0,H.jsxs)("div",{className:"truss-estimator__toggle-row",children:[(0,H.jsx)("button",{type:"button",className:`truss-estimator__toggle${i.boundaryMode==="quick"?" is-selected":""}`,onClick:()=>o(k=>({...k,boundaryMode:"quick"})),children:"Quick estimate"}),(0,H.jsx)("button",{type:"button",className:`truss-estimator__toggle${i.boundaryMode==="draw"?" is-selected":""}`,onClick:()=>o(k=>({...k,boundaryMode:"draw"})),children:"Draw your boundary"})]}),i.boundaryMode==="quick"?(0,H.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact fence-boundary__quick-field",children:[(0,H.jsx)("span",{children:"Total fence length (m)"}),(0,H.jsx)("input",{type:"number",min:"0",step:"0.1",value:i.quickLengthM,onChange:k=>o(j=>({...j,quickLengthM:k.target.value}))})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"fence-boundary__toolbar",children:(0,H.jsxs)("div",{className:"fence-boundary__actions",children:[(0,H.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(k=>({...k,boundaryPoints:k.boundaryPoints.slice(0,-1),boundaryClosed:!1,excludedBoundaryEdges:new Set})),disabled:i.boundaryPoints.length===0||i.boundaryClosed,children:"Undo"}),(0,H.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>{d({x:0,y:0}),w(null),o(k=>({...k,boundaryPoints:[],boundaryClosed:!1,excludedBoundaryEdges:new Set}))},disabled:i.boundaryPoints.length===0,children:"Clear"}),(0,H.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(k=>({...k,boundaryPoints:[{x:2,y:2},{x:8,y:2},{x:8,y:5},{x:2,y:5},{x:2,y:2}],boundaryClosed:!0,excludedBoundaryEdges:new Set})),children:"Start with rectangle"})]})}),(0,H.jsxs)("div",{className:"fence-boundary",children:[(0,H.jsxs)("svg",{ref:m,className:`fence-boundary__canvas${i.boundaryClosed?" is-pan-mode":""}`,viewBox:`${z} ${G} ${v} ${N}`,preserveAspectRatio:"none","aria-label":"Fence boundary drawing area",onPointerDown:He,onPointerMove:x,onPointerUp:R,onPointerLeave:()=>{w(null),D.current||(M.current=null)},children:[(0,H.jsx)("defs",{children:(0,H.jsx)("pattern",{id:"fence-boundary-grid",width:"1",height:"1",patternUnits:"userSpaceOnUse",children:(0,H.jsx)("path",{d:"M 1 0 L 0 0 0 1",fill:"none",stroke:"currentColor",strokeWidth:"0.03"})})}),(0,H.jsx)("rect",{x:-On,y:-Ln,width:On*3,height:Ln*3,className:"fence-boundary__grid",fill:"url(#fence-boundary-grid)"}),i.boundaryPoints.length>1?(0,H.jsx)("polyline",{className:"fence-boundary__preview",points:i.boundaryPoints.map(k=>`${k.x},${k.y}`).join(" ")}):null,i.boundaryPoints.length>1?i.boundaryPoints.slice(0,-1).map((k,j)=>{let O=i.boundaryPoints[j+1],ne=Math.hypot(O.x-k.x,O.y-k.y),W=ne?-(O.y-k.y)/ne:0,C=ne?(O.x-k.x)/ne:0,V=(k.x+O.x)/2,X=(k.y+O.y)/2,me=W*(V-K.x)+C*(X-K.y)>=0?1:-1,Ce=V+W*gw*me,dt=X+C*gw*me;return(0,H.jsxs)("g",{children:[(0,H.jsx)("line",{className:"fence-boundary__edge-hit",x1:k.x,y1:k.y,x2:O.x,y2:O.y,onClick:i.boundaryClosed?()=>I(j):void 0}),(0,H.jsx)("line",{className:`fence-boundary__edge${i.excludedBoundaryEdges.has(j)?" is-excluded":""}`,x1:k.x,y1:k.y,x2:O.x,y2:O.y,pointerEvents:"none"}),(0,H.jsxs)("text",{className:`fence-boundary__edge-label${i.excludedBoundaryEdges.has(j)?" is-excluded":""}`,x:Ce,y:dt,textAnchor:"middle",dominantBaseline:"central",fontSize:.21/p,children:[ne.toFixed(2)," m"]})]},`fence-edge-${j}`)}):null,!i.boundaryClosed&&i.boundaryPoints.length>0&&h?(()=>{let k=i.boundaryPoints[i.boundaryPoints.length-1],j=Math.hypot(h.x-k.x,h.y-k.y);if(!j)return null;let O=-(h.y-k.y)/j,ne=(h.x-k.x)/j,W=(k.x+h.x)/2,C=(k.y+h.y)/2;return(0,H.jsxs)("g",{className:"fence-boundary__live-measurement",children:[(0,H.jsx)("line",{x1:k.x,y1:k.y,x2:h.x,y2:h.y}),(0,H.jsxs)("text",{x:W+O*.34,y:C+ne*.34,textAnchor:"middle",dominantBaseline:"central",fontSize:.21/p,children:[j.toFixed(2)," m"]})]})})():null,i.boundaryPoints.map((k,j)=>j>0&&j===i.boundaryPoints.length-1&&k.x===i.boundaryPoints[0]?.x&&k.y===i.boundaryPoints[0]?.y?null:(0,H.jsx)("circle",{className:`fence-boundary__point${!i.boundaryClosed&&j===0&&i.boundaryPoints.length>=3?" is-close-target":""}`,cx:k.x,cy:k.y,r:"0.13",onPointerDown:O=>E(O,j)},`fence-point-${j}`))]}),(0,H.jsxs)("div",{className:"fence-boundary__zoom","aria-label":"Zoom controls",children:[(0,H.jsx)("button",{type:"button",onClick:()=>f(k=>Math.max(.5,k-.25)),disabled:p===.5,"aria-label":"Zoom out",children:"\u2212"}),(0,H.jsxs)("span",{children:[Math.round(p*100),"%"]}),(0,H.jsx)("button",{type:"button",onClick:()=>f(k=>Math.min(1,k+.25)),disabled:p===1,"aria-label":"Zoom in",children:"+"})]}),!i.boundaryClosed&&i.boundaryPoints.length>=2?(0,H.jsx)("button",{type:"button",className:"fence-boundary__close",onClick:()=>o(k=>ic(k.boundaryPoints,!1)?k:{...k,boundaryClosed:!0}),children:"Finish fence line"}):null]}),(0,H.jsx)("div",{className:"truss-estimator__grid-hint",children:i.boundaryClosed?"Drag the blank canvas to pan. Tap an edge to exclude it from the new fence.":"Click to add points, then finish the fence line. The displayed distances update as you draw."})]}),(0,H.jsxs)("div",{className:"truss-estimator__grid-stats",children:[(0,H.jsx)("div",{children:i.boundaryMode==="quick"?`${(Number.parseFloat(i.quickLengthM)||0).toFixed(2)} m fence line`:`${pe.totalEdgeM.toFixed(2)} m fence line`}),i.boundaryMode==="draw"&&i.boundaryClosed?(0,H.jsxs)("div",{children:[pe.cornerPostCount," corner/end posts"]}):null]})]}):null,null,u==="height"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ci.length]}),(0,H.jsx)("h2",{className:"truss-estimator__step-title",children:"Fence height"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"Select the nearest available panel height."}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--pitch",children:Ca.heights.map(k=>(0,H.jsx)("button",{type:"button",className:`truss-estimator__visual-card${i.height===k?" is-selected":""}`,onClick:()=>o(j=>({...j,height:k})),children:(0,H.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--tall",src:Kt(`/fencing/height/${k}.webp`),alt:""})},k))}),(0,H.jsx)("div",{className:"truss-estimator__section-heading",children:"Gravel board?"}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"no",label:"No gravel board",img:"/fencing/no-gravel-board.webp"},{id:"yes",label:"Add gravel board",img:"/fencing/gravel-board.webp"}].map(k=>(0,H.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${i.gravelBoard===k.id?" is-selected":""}`,onClick:()=>o(j=>({...j,gravelBoard:k.id})),children:[(0,H.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--mid",src:Kt(k.img),alt:""}),(0,H.jsx)("span",{children:k.label})]},k.id))})]}):null,u==="gate"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ci.length]}),(0,H.jsx)("h2",{className:"truss-estimator__step-title",children:"Do you need a gate?"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"A gate opening replaces part of the panel run and adds a gate kit with heavy-duty posts."}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"none",label:"No gate",img:"/fencing/gates/no-gate.webp"},{id:"single",label:"Single gate",img:"/fencing/gates/single-gate.webp"}].map(k=>(0,H.jsxs)("button",{type:"button",className:`truss-estimator__visual-card${i.gateType===k.id?" is-selected":""}`,onClick:()=>o(j=>({...j,gateType:k.id,gateWidthM:k.id==="none"?"":String(Ca.gate[k.id].widthDefault)})),children:[(0,H.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--mid",src:Kt(k.img),alt:""}),(0,H.jsx)("span",{children:k.label})]},k.id))}),i.gateType&&i.gateType!=="none"?(0,H.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact",children:[(0,H.jsx)("span",{children:"Gate width (m)"}),(0,H.jsx)("input",{type:"text",inputMode:"decimal",value:i.gateWidthM,onChange:k=>o(j=>({...j,gateWidthM:k.target.value}))})]}):null]}):null,u==="posts"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ci.length]}),(0,H.jsx)("h2",{className:"truss-estimator__step-title",children:"Posts and fixing type"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose how the posts will be set."}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Ca.mounting).map(([k,j])=>(0,H.jsxs)("button",{type:"button",className:`truss-estimator__option-card${i.mountingType===k?" is-selected":""}`,onClick:()=>o(O=>({...O,mountingType:k})),children:[(0,H.jsx)("div",{className:"truss-estimator__option-title",children:j.label}),(0,H.jsx)("div",{className:"truss-estimator__option-copy",children:j.blurb})]},k))})]}):null]}),(0,H.jsxs)("div",{className:"truss-estimator__nav",children:[(0,H.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:ue,children:"Back"}),(0,H.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:ve,disabled:!ye(),children:[(0,H.jsx)("span",{children:ee}),(0,H.jsx)("span",{className:"arrow",children:(0,H.jsx)(Ot,{})})]})]})]})]})})}var nc=Y(Xe()),be=Y(ae()),hw={floor:{label:"Floor",product:"Knauf Acoustic Roll",thickness:"100mm",coverage:12.36,salesUnit:"roll"},wall:{label:"Cavity wall",product:"Celotex CW4100",thickness:"100mm",coverage:3.24,salesUnit:"pack"},roof:{label:"Pitched roof",product:"Kingspan K107",thickness:"100mm",coverage:8.64,salesUnit:"pack"},loft:{label:"Loft",product:"Knauf Loft Roll 44",thickness:"100mm",coverage:13.89,salesUnit:"roll"}};function qd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,nc.useState)("floor"),[i,o]=(0,nc.useState)(""),[l,c]=(0,nc.useState)(""),p=Number.parseFloat(i)*Number.parseFloat(l)||0,f=hw[r],b=Math.ceil(p/f.coverage),d=[{key:`insulation-${r}`,label:`${f.product} ${f.thickness}`,qty:b,unit:f.salesUnit,query:f.product,category:"insulation"}],h=Object.entries(hw);return(0,be.jsx)(be.Fragment,{children:(0,be.jsxs)("div",{className:"truss-estimator",children:[(0,be.jsxs)("div",{className:"quick-order-hero",children:[(0,be.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,be.jsx)("h1",{children:"Insulation Calculator"}),(0,be.jsx)("p",{children:"Estimate insulation coverage and pack quantities for floors, walls, roofs and lofts."})]}),(0,be.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,be.jsx)("h2",{className:"truss-estimator__step-title",children:"Where and what you are insulating"}),(0,be.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose the application and product, and enter the area, for coverage and pack quantities."}),(0,be.jsxs)("div",{className:"materials-calculator__section",children:[(0,be.jsx)("div",{className:"truss-estimator__section-heading",children:"Application"}),(0,be.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:h.map(([w,M])=>(0,be.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===w?" is-selected":""}`,onClick:()=>n(w),children:[(0,be.jsx)("div",{className:"truss-estimator__option-title",children:M.label}),(0,be.jsxs)("div",{className:"truss-estimator__option-copy",children:[M.product,", ",M.thickness]})]},w))})]}),(0,be.jsxs)("div",{className:"materials-calculator__section",children:[(0,be.jsx)("div",{className:"truss-estimator__section-heading",children:"Area"}),(0,be.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,be.jsxs)("label",{className:"truss-estimator__field",children:[(0,be.jsx)("span",{children:"Length (m)"}),(0,be.jsx)("input",{type:"number",min:"0",step:"0.01",value:i,onChange:w=>o(w.target.value)})]}),(0,be.jsxs)("label",{className:"truss-estimator__field",children:[(0,be.jsx)("span",{children:"Width (m)"}),(0,be.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:w=>c(w.target.value)})]})]})]}),(0,be.jsxs)("div",{className:"materials-calculator__totals",children:[(0,be.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,be.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,be.jsxs)("div",{children:[(0,be.jsx)("span",{children:"Insulated area"}),(0,be.jsxs)("strong",{children:[p.toFixed(2)," m\xB2"]})]}),(0,be.jsxs)("div",{children:[(0,be.jsx)("span",{children:f.product}),(0,be.jsxs)("strong",{children:[b," packs"]})]})]}),(0,be.jsx)("p",{className:"materials-calculator__note",children:"This is a simple product choice, not thermal or Building Regulations advice. Confirm the specification before ordering."})]}),(0,be.jsxs)("div",{className:"materials-calculator__actions",children:[(0,be.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,be.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(d),disabled:p<=0,children:a})]})]})]})})}var Hn=Y(Xe()),Z=Y(ae()),B_=10,O_=1.9*.762,L_=1.9*1.524,oc=()=>({height:"",width:""}),lc=e=>Number.parseFloat(e)||0,bw=({height:e,width:t})=>lc(e)*lc(t);function Ed({onBack:e}){let[t,a]=(0,Hn.useState)([oc()]),[r,n]=(0,Hn.useState)([oc()]),[i,o]=(0,Hn.useState)("0"),[l,c]=(0,Hn.useState)("0"),[p,f]=(0,Hn.useState)(1),b=t.reduce((m,u)=>m+bw(u),0),d=r.reduce((m,u)=>m+bw(u),0),h=lc(i)*O_+lc(l)*L_,w=Math.max(0,b-d-h),M=w*p/B_,D=(m,u,g,v)=>{m(N=>N.map((A,T)=>T===u?{...A,[g]:v}:A))};return(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)("div",{className:"truss-estimator",children:[(0,Z.jsxs)("div",{className:"quick-order-hero",children:[(0,Z.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Z.jsx)("h1",{children:"Paint Calculator"}),(0,Z.jsx)("p",{children:"Estimate how much paint you need for your walls, including multiple coats and excluded areas."})]}),(0,Z.jsxs)("div",{className:"truss-estimator__card paint-calculator",children:[(0,Z.jsx)("h2",{className:"truss-estimator__step-title",children:"Walls, exclusions and coats"}),(0,Z.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter each wall, subtract windows and doors, and choose your number of coats. Quantities assume a coverage of 10 m\xB2 per litre."}),(0,Z.jsxs)("div",{className:"paint-calculator__section",children:[(0,Z.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall dimensions"}),(0,Z.jsx)("p",{className:"paint-calculator__hint",children:"Enter the height and width of each wall you want to paint."}),(0,Z.jsxs)("div",{className:"paint-calculator__dimensions-header","aria-hidden":"true",children:[(0,Z.jsx)("span",{}),(0,Z.jsx)("span",{children:"Height (m)"}),(0,Z.jsx)("span",{children:"Width (m)"}),(0,Z.jsx)("span",{})]}),t.map((m,u)=>(0,Z.jsxs)("div",{className:"paint-calculator__row",children:[(0,Z.jsxs)("span",{className:"paint-calculator__row-label",children:["Wall ",u+1]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{className:"sr-only",children:"Height (m)"}),(0,Z.jsx)("input",{"aria-label":`Wall ${u+1} height in metres`,type:"number",min:"0",step:"0.01",value:m.height,onChange:g=>D(a,u,"height",g.target.value)})]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{className:"sr-only",children:"Width (m)"}),(0,Z.jsx)("input",{"aria-label":`Wall ${u+1} width in metres`,type:"number",min:"0",step:"0.01",value:m.width,onChange:g=>D(a,u,"width",g.target.value)})]}),t.length>1?(0,Z.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>a(g=>g.filter((v,N)=>N!==u)),children:"Remove"}):null]},`wall-${u}`)),(0,Z.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>a(m=>[...m,oc()]),children:"+ Add another wall"})]}),(0,Z.jsxs)("div",{className:"paint-calculator__section",children:[(0,Z.jsx)("div",{className:"truss-estimator__section-heading",children:"Areas to exclude"}),(0,Z.jsx)("p",{className:"paint-calculator__hint",children:"Add windows, sockets, skirting boards or other areas that will not be painted."}),(0,Z.jsxs)("div",{className:"paint-calculator__dimensions-header","aria-hidden":"true",children:[(0,Z.jsx)("span",{}),(0,Z.jsx)("span",{children:"Height (m)"}),(0,Z.jsx)("span",{children:"Width (m)"}),(0,Z.jsx)("span",{})]}),r.map((m,u)=>(0,Z.jsxs)("div",{className:"paint-calculator__row",children:[(0,Z.jsxs)("span",{className:"paint-calculator__row-label",children:["Area ",u+1]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{className:"sr-only",children:"Height (m)"}),(0,Z.jsx)("input",{"aria-label":`Area ${u+1} height in metres`,type:"number",min:"0",step:"0.01",value:m.height,onChange:g=>D(n,u,"height",g.target.value)})]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{className:"sr-only",children:"Width (m)"}),(0,Z.jsx)("input",{"aria-label":`Area ${u+1} width in metres`,type:"number",min:"0",step:"0.01",value:m.width,onChange:g=>D(n,u,"width",g.target.value)})]}),r.length>1?(0,Z.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>n(g=>g.filter((v,N)=>N!==u)),children:"Remove"}):null]},`excluded-${u}`)),(0,Z.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>n(m=>[...m,oc()]),children:"+ Add another area"})]}),(0,Z.jsxs)("div",{className:"paint-calculator__section",children:[(0,Z.jsx)("div",{className:"truss-estimator__section-heading",children:"Doors and coats"}),(0,Z.jsx)("p",{className:"paint-calculator__hint",children:"Enter the number of standard single and double doors to leave unpainted. Door sizes are estimated automatically."}),(0,Z.jsxs)("div",{className:"truss-estimator__field-grid paint-calculator__small-fields",children:[(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{children:"Doors"}),(0,Z.jsx)("input",{type:"number",min:"0",step:"1",value:i,onChange:m=>o(m.target.value)})]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{children:"Double doors"}),(0,Z.jsx)("input",{type:"number",min:"0",step:"1",value:l,onChange:m=>c(m.target.value)})]})]}),(0,Z.jsxs)("div",{className:"paint-calculator__coat-field",children:[(0,Z.jsx)("p",{className:"paint-calculator__hint",children:"Most walls need 2 coats for an even finish. Use 3 coats when changing colour significantly or covering a darker wall."}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{children:"Number of coats"}),(0,Z.jsxs)("select",{value:p,onChange:m=>f(Number(m.target.value)),children:[(0,Z.jsx)("option",{value:"1",children:"1 coat"}),(0,Z.jsx)("option",{value:"2",children:"2 coats"}),(0,Z.jsx)("option",{value:"3",children:"3 coats"})]})]})]})]}),(0,Z.jsxs)("div",{className:"paint-calculator__totals",children:[(0,Z.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,Z.jsxs)("div",{className:"paint-calculator__result-grid",children:[(0,Z.jsxs)("div",{children:[(0,Z.jsx)("span",{children:"Paintable area"}),(0,Z.jsxs)("strong",{children:[w.toFixed(2)," m\xB2"]})]}),(0,Z.jsxs)("div",{children:[(0,Z.jsx)("span",{children:"Coverage"}),(0,Z.jsxs)("strong",{children:[p," ",p===1?"coat":"coats"]})]}),(0,Z.jsxs)("div",{children:[(0,Z.jsx)("span",{children:"Paint required"}),(0,Z.jsxs)("strong",{children:[M.toFixed(1)," litres"]})]})]}),(0,Z.jsx)("p",{className:"paint-calculator__note",children:"Based on paint coverage of 10 m\xB2 per litre. Decorative paint is not currently stocked in this catalogue, so this remains an estimate only."})]}),(0,Z.jsxs)("div",{className:"paint-calculator__actions",children:[(0,Z.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,Z.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",disabled:!0,children:"Paint products unavailable"})]})]})]})})}var gr=Y(Xe()),re=Y(ae()),sc=e=>Number.parseFloat(e)||0,Md={paving:[{id:"council",label:"Council paving slab (600 \xD7 600mm)"},{id:"raj",label:"Raj blend sandstone (600 \xD7 600mm)"}],block:[{id:"brindle",label:"Brindle block paving (60mm)"},{id:"charcoal",label:"Charcoal block paving (60mm)"}],gravel:[{id:"pea",label:"20mm pea shingle"}]};function Td({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,gr.useState)("paving"),[i,o]=(0,gr.useState)("council"),[l,c]=(0,gr.useState)(""),[p,f]=(0,gr.useState)(""),[b,d]=(0,gr.useState)("100"),[h,w]=(0,gr.useState)("50"),[M,D]=(0,gr.useState)(!0),[m,u]=(0,gr.useState)(!0),g=sc(l)*sc(p),v=g,N=g*(sc(b)/1e3),A=g*.04,T=g*(sc(h)/1e3),z=Math.ceil(v/.36),G=Math.ceil(v/.1),K=Math.ceil(N*1700/800),fe=Math.ceil(A*1600/800),Te=Math.ceil(T*1600/800),Ye=r==="paving"?{qty:z,unit:"each"}:r==="block"?{qty:v,unit:"m2"}:{qty:Te,unit:"bag"},Ve={paving:"paving slab",block:"block paver",gravel:"decorative gravel"}[r],it=[{key:`surface-${i}`,label:Md[r].find(Q=>Q.id===i)?.label??"Surface material",qty:Ye.qty,unit:Ye.unit,query:Ve,category:"landscaping"},...M?[{key:"sub-base",label:"MOT Type 1 sub-base",qty:K,unit:"bag",query:"MOT Type 1 sub base",category:"aggregate"}]:[],...m?[{key:"bedding",label:"Sharp sand bedding",qty:fe,unit:"bag",query:"sharp sand",category:"aggregate"}]:[]];return(0,re.jsx)(re.Fragment,{children:(0,re.jsxs)("div",{className:"truss-estimator",children:[(0,re.jsxs)("div",{className:"quick-order-hero",children:[(0,re.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,re.jsx)("h1",{children:"Paving & Driveway Calculator"}),(0,re.jsx)("p",{children:"Estimate paving, block paving, sub-base and bedding materials for outdoor areas."})]}),(0,re.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,re.jsx)("h2",{className:"truss-estimator__step-title",children:"Surface and ground build-up"}),(0,re.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose the surface material and enter the area. Sub-base and bedding sand are estimated alongside the surface units."}),(0,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Surface material"}),(0,re.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:[["paving","Paving slabs","For patios and paths"],["block","Block paving","For driveways and paths"],["gravel","Decorative gravel","For paths and landscaping"]].map(([Q,ce,xe])=>(0,re.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===Q?" is-selected":""}`,onClick:()=>{n(Q),o(Md[Q][0].id)},children:[(0,re.jsx)("div",{className:"truss-estimator__option-title",children:ce}),(0,re.jsx)("div",{className:"truss-estimator__option-copy",children:xe})]},Q))}),(0,re.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,re.jsx)("span",{children:"Finish"}),(0,re.jsx)("select",{value:i,onChange:Q=>o(Q.target.value),children:Md[r].map(Q=>(0,re.jsx)("option",{value:Q.id,children:Q.label},Q.id))})]})]}),(0,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Area and groundwork"}),(0,re.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,re.jsxs)("label",{className:"truss-estimator__field",children:[(0,re.jsx)("span",{children:"Length (m)"}),(0,re.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:Q=>c(Q.target.value)})]}),(0,re.jsxs)("label",{className:"truss-estimator__field",children:[(0,re.jsx)("span",{children:"Width (m)"}),(0,re.jsx)("input",{type:"number",min:"0",step:"0.01",value:p,onChange:Q=>f(Q.target.value)})]})]}),r==="gravel"&&(0,re.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,re.jsx)("span",{children:"Gravel depth (mm)"}),(0,re.jsx)("input",{type:"number",min:"0",step:"10",value:h,onChange:Q=>w(Q.target.value)})]}),M&&(0,re.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,re.jsx)("span",{children:"Sub-base depth (mm)"}),(0,re.jsx)("input",{type:"number",min:"0",step:"10",value:b,onChange:Q=>d(Q.target.value)})]}),(0,re.jsxs)("label",{className:"brick-calculator__checkbox materials-calculator__waste",children:[(0,re.jsx)("input",{type:"checkbox",checked:M,onChange:Q=>D(Q.target.checked)}),(0,re.jsx)("span",{children:"Include MOT Type 1 sub-base"})]}),(0,re.jsxs)("label",{className:"brick-calculator__checkbox materials-calculator__waste",children:[(0,re.jsx)("input",{type:"checkbox",checked:m,onChange:Q=>u(Q.target.checked)}),(0,re.jsx)("span",{children:"Include sharp sand bedding"})]})]}),(0,re.jsxs)("div",{className:"materials-calculator__totals",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,re.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"Surface area"}),(0,re.jsxs)("strong",{children:[g.toFixed(2)," m\xB2"]})]}),(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:r==="paving"?"Paving slabs":r==="block"?"Block paving":"Gravel"}),(0,re.jsx)("strong",{children:r==="paving"?`${z} slabs`:r==="block"?`${v.toFixed(2)} m\xB2`:`${Te} bulk bags`})]}),M&&(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"MOT Type 1"}),(0,re.jsxs)("strong",{children:[K," bulk bags"]})]}),m&&(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"Sharp sand"}),(0,re.jsxs)("strong",{children:[fe," bulk bags"]})]})]}),(0,re.jsx)("p",{className:"materials-calculator__note",children:"Slab and block quantities use typical sizes. Confirm pack coverage and laying pattern before ordering."})]}),(0,re.jsxs)("div",{className:"materials-calculator__actions",children:[(0,re.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,re.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(it),disabled:g<=0,children:a})]})]})]})})}var il=Y(Xe()),ie=Y(ae()),H_=2.88,vw=[{id:"standard",label:"Standard wallboard",blurb:"General internal walls and ceilings"},{id:"moisture",label:"Moisture resistant",blurb:"Kitchens, bathrooms and utility rooms"},{id:"fire",label:"Fire resistant",blurb:"Where fire-rated lining is required"},{id:"sound",label:"Sound resistant",blurb:"Improved acoustic performance"}],ww=()=>({length:"",height:""}),zd=e=>Number.parseFloat(e)||0;function Ad({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,il.useState)([ww()]),[i,o]=(0,il.useState)(""),[l,c]=(0,il.useState)("standard"),[p,f]=(0,il.useState)("screws"),b=r.reduce((A,T)=>A+zd(T.length)*zd(T.height),0),d=Math.max(0,b-zd(i)),h=Math.ceil(d/H_),w=Math.ceil(d*12),M=Math.ceil(w/1e3),D=Math.ceil(d*1.2),m=Math.ceil(D/90),u=Math.ceil(d/3.5),g=vw.find(A=>A.id===l)?.label??"Standard",v=[{key:"board",label:`${g} plasterboard`,qty:h,unit:"sheet",query:`${g} plasterboard`,category:"plasterboard"},...p==="screws"?[{key:"screws",label:"Drywall screws",qty:M,unit:"box",query:"drywall screws",category:"fixings"}]:[{key:"adhesive",label:"Board adhesive",qty:u,unit:"bag",query:"drywall board adhesive",category:"plasterboard"}],{key:"tape",label:"Joint tape",qty:m,unit:"roll",query:"plasterboard joint tape",category:"plasterboard"}],N=(A,T,z)=>{n(G=>G.map((K,fe)=>fe===A?{...K,[T]:z}:K))};return(0,ie.jsx)(ie.Fragment,{children:(0,ie.jsxs)("div",{className:"truss-estimator",children:[(0,ie.jsxs)("div",{className:"quick-order-hero",children:[(0,ie.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,ie.jsx)("h1",{children:"Plasterboard & Drylining Calculator"}),(0,ie.jsx)("p",{children:"Estimate boards, fixings and jointing materials for walls and ceilings."})]}),(0,ie.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,ie.jsx)("h2",{className:"truss-estimator__step-title",children:"Boards, fixings and jointing"}),(0,ie.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter the surfaces you are lining and the board specification. Screws, tape and adhesive are estimated with the boards."}),(0,ie.jsxs)("div",{className:"materials-calculator__section",children:[(0,ie.jsx)("div",{className:"truss-estimator__section-heading",children:"Board type"}),(0,ie.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:vw.map(A=>(0,ie.jsxs)("button",{type:"button",className:`truss-estimator__option-card${l===A.id?" is-selected":""}`,onClick:()=>c(A.id),children:[(0,ie.jsx)("div",{className:"truss-estimator__option-title",children:A.label}),(0,ie.jsx)("div",{className:"truss-estimator__option-copy",children:A.blurb})]},A.id))})]}),(0,ie.jsxs)("div",{className:"materials-calculator__section",children:[(0,ie.jsx)("div",{className:"truss-estimator__section-heading",children:"Fixing method"}),(0,ie.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[["screws","Drywall screws","For timber or metal framing"],["adhesive","Board adhesive","For masonry dot-and-dab"]].map(([A,T,z])=>(0,ie.jsxs)("button",{type:"button",className:`truss-estimator__option-card${p===A?" is-selected":""}`,onClick:()=>f(A),children:[(0,ie.jsx)("div",{className:"truss-estimator__option-title",children:T}),(0,ie.jsx)("div",{className:"truss-estimator__option-copy",children:z})]},A))})]}),(0,ie.jsxs)("div",{className:"materials-calculator__section",children:[(0,ie.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall and ceiling areas"}),(0,ie.jsx)("p",{className:"materials-calculator__hint",children:"Add each surface separately so different wall sizes are easy to measure."}),(0,ie.jsxs)("div",{className:"materials-calculator__dimensions-header",children:[(0,ie.jsx)("span",{children:"Surface"}),(0,ie.jsx)("span",{children:"Length (m)"}),(0,ie.jsx)("span",{children:"Height (m)"}),(0,ie.jsx)("span",{})]}),r.map((A,T)=>(0,ie.jsxs)("div",{className:"materials-calculator__surface-row",children:[(0,ie.jsxs)("span",{children:["Surface ",T+1]}),(0,ie.jsx)("input",{"aria-label":`Surface ${T+1} length`,type:"number",min:"0",step:"0.01",value:A.length,onChange:z=>N(T,"length",z.target.value)}),(0,ie.jsx)("input",{"aria-label":`Surface ${T+1} height`,type:"number",min:"0",step:"0.01",value:A.height,onChange:z=>N(T,"height",z.target.value)}),r.length>1?(0,ie.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>n(z=>z.filter((G,K)=>K!==T)),children:"Remove"}):null]},`surface-${T}`)),(0,ie.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>n(A=>[...A,ww()]),children:"+ Add another surface"}),(0,ie.jsxs)("label",{className:"truss-estimator__field materials-calculator__openings",children:[(0,ie.jsxs)("span",{children:["Openings to deduct (m\xB2) ",(0,ie.jsx)("small",{children:"optional"})]}),(0,ie.jsx)("input",{type:"number",min:"0",step:"0.01",value:i,onChange:A=>o(A.target.value)})]})]}),(0,ie.jsxs)("div",{className:"materials-calculator__totals",children:[(0,ie.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,ie.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)("span",{children:"Board area"}),(0,ie.jsxs)("strong",{children:[d.toFixed(2)," m\xB2"]})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("span",{children:"2.4 x 1.2 m boards"}),(0,ie.jsx)("strong",{children:h})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("span",{children:p==="screws"?"Drywall screws":"Board adhesive"}),(0,ie.jsx)("strong",{children:p==="screws"?`${w} (${M} boxes)`:`${u} bags`})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("span",{children:"Joint tape"}),(0,ie.jsxs)("strong",{children:[D," m (",m," rolls)"]})]})]}),(0,ie.jsx)("p",{className:"materials-calculator__note",children:"Figures are estimates. Confirm board specification, fixing patterns and fire or acoustic requirements before ordering."})]}),(0,ie.jsxs)("div",{className:"materials-calculator__actions",children:[(0,ie.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,ie.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(v),disabled:d<=0,children:a})]})]})]})})}var nl=Y(Xe());var y=Y(ae()),Mt={ranges:{standard:{label:"Standard Fink",blurb:"Classic W-shaped truss for standard pitched roofs."},attic:{label:"Attic",blurb:"Room-in-roof truss with usable attic space and clear span."},mono:{label:"Mono-pitch",blurb:"Single-slope truss for lean-to roofs and outbuildings."}},pitches:["15","20","22.5","25","30","35","40","45","50","55"],pitchMultipliers:{15:.95,20:.98,"22.5":1,25:1.02,30:1.05,35:1.1,40:1.18,45:1.27,50:1.38,55:1.52},overhang:{thresholdMM:300,surchargePerTruss:3.5},centresOptions:["400","600"],treatment:{treated:{label:"Treated (tanalised)",surchargePct:.08},untreated:{label:"Untreated",surchargePct:0}},estimate:{design:250,delivery:250,bracingPerMetre:6.5,girderMultiplier:1.8,ranges:{standard:{supplyAt8m:53.33,installPerTruss:30},attic:{supplyAt8m:128.35,installPerTruss:55},mono:{supplyAt8m:60,installPerTruss:38}}}},cc=["range","pitchAndDimensions","quantityAndGirders","bracing"],j_={range:null,pitch:null,spanMM:"",overhangMM:"",roofLengthM:"",centres:null,girderCount:0,bracing:null,treatment:null,contact:{name:"",email:""}};function G_({degrees:e}){let a=e*Math.PI/180,n=82-Math.min(58,38*Math.tan(a));return(0,y.jsxs)("svg",{viewBox:"0 0 100 100",className:"truss-estimator__diagram truss-estimator__diagram--small","aria-hidden":"true",children:[(0,y.jsx)("line",{x1:"6",y1:"82",x2:"94",y2:"82",stroke:"var(--border)",strokeWidth:"2"}),(0,y.jsx)("polygon",{points:`12,82 88,82 50,${n}`,fill:"var(--accent-light)",stroke:"var(--accent)",strokeWidth:"3",strokeLinejoin:"round"})]})}function Q_({type:e}){let t="#b3835a",a="#5c3b22",r="#d9b48f",n="#d3d8de",i="#7c8494",o=(f,b,d,h,w=8,M)=>{let D=d-f,m=h-b,u=Math.hypot(D,m)||1,g=-m/u,v=D/u,N=w*.2;return(0,y.jsxs)("g",{children:[(0,y.jsx)("line",{x1:f,y1:b,x2:d,y2:h,stroke:a,strokeWidth:w+3,strokeLinecap:"square"}),(0,y.jsx)("line",{x1:f,y1:b,x2:d,y2:h,stroke:t,strokeWidth:w,strokeLinecap:"square"}),(0,y.jsx)("line",{x1:f-g*N,y1:b-v*N,x2:d-g*N,y2:h-v*N,stroke:r,strokeWidth:Math.max(1.5,w*.24),strokeLinecap:"round",opacity:"0.9"})]},M)},l=(f,b,d)=>(0,y.jsxs)("g",{children:[(0,y.jsx)("rect",{x:f-7.5,y:b-5.5,width:"15",height:"11",rx:"2",fill:n,stroke:i,strokeWidth:"1"}),(0,y.jsx)("circle",{cx:f-4,cy:b-2.5,r:"1",fill:i}),(0,y.jsx)("circle",{cx:f+4,cy:b-2.5,r:"1",fill:i}),(0,y.jsx)("circle",{cx:f-4,cy:b+2.5,r:"1",fill:i}),(0,y.jsx)("circle",{cx:f+4,cy:b+2.5,r:"1",fill:i}),(0,y.jsx)("circle",{cx:f,cy:b,r:"1",fill:i})]},d),c=(f,b)=>(0,y.jsx)("rect",{x:f-9,y:"110",width:"18",height:"10",fill:a},b),p=(0,y.jsx)("line",{x1:"6",y1:"122",x2:"194",y2:"122",stroke:"var(--border)",strokeWidth:"2"});return e==="attic"?(0,y.jsxs)("svg",{viewBox:"0 0 200 130",className:"truss-estimator__diagram","aria-hidden":"true",children:[p,c(26,"wl"),c(174,"wr"),o(26,112,100,26,8,"b1"),o(174,112,100,26,8,"b2"),o(26,112,174,112,8,"b3"),o(58,112,58,70,6,"b4"),o(142,112,142,70,6,"b5"),o(58,70,142,70,7,"b6"),(0,y.jsx)("rect",{x:"90",y:"82",width:"20",height:"24",fill:"#cfe3f2",stroke:a,strokeWidth:"2"}),(0,y.jsx)("line",{x1:"100",y1:"82",x2:"100",y2:"106",stroke:a,strokeWidth:"1.5"}),l(26,112,"p1"),l(174,112,"p2"),l(100,26,"p3"),l(58,112,"p4"),l(58,70,"p5"),l(142,112,"p6"),l(142,70,"p7")]}):e==="mono"?(0,y.jsxs)("svg",{viewBox:"0 0 200 130",className:"truss-estimator__diagram","aria-hidden":"true",children:[p,c(26,"wl"),c(174,"wr"),o(26,112,174,26,8,"b1"),o(174,26,174,112,8,"b2"),o(26,112,174,112,8,"b3"),o(90,112,90,75,5,"b4"),o(90,75,132,112,5,"b5"),l(26,112,"p1"),l(174,26,"p2"),l(174,112,"p3"),l(90,112,"p4"),l(90,75,"p5"),l(132,112,"p6")]}):(0,y.jsxs)("svg",{viewBox:"0 0 200 130",className:"truss-estimator__diagram","aria-hidden":"true",children:[p,c(26,"wl"),c(174,"wr"),o(26,112,100,34,8,"b1"),o(174,112,100,34,8,"b2"),o(26,112,174,112,8,"b3"),o(63,112,100,34,5,"b4"),o(137,112,100,34,5,"b5"),o(63,112,54,83,5,"b6"),o(137,112,146,83,5,"b7"),(0,y.jsx)("rect",{x:"96",y:"108",width:"8",height:"8",fill:a}),l(26,112,"p1"),l(174,112,"p2"),l(100,34,"p3"),l(63,112,"p4"),l(137,112,"p5"),l(54,83,"p6"),l(146,83,"p7")]})}function Y_({enabled:e}){return(0,y.jsxs)("svg",{viewBox:"0 0 200 130",className:"truss-estimator__diagram","aria-hidden":"true",children:[(0,y.jsx)("line",{x1:"6",y1:"122",x2:"194",y2:"122",stroke:"var(--border)",strokeWidth:"2"}),(0,y.jsx)("rect",{x:"17",y:"110",width:"18",height:"10",fill:"#5c3b22"}),(0,y.jsx)("rect",{x:"165",y:"110",width:"18",height:"10",fill:"#5c3b22"}),(0,y.jsx)("line",{x1:"26",y1:"112",x2:"100",y2:"34",stroke:"#5c3b22",strokeWidth:"11",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"26",y1:"112",x2:"100",y2:"34",stroke:"#b3835a",strokeWidth:"8",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"174",y1:"112",x2:"100",y2:"34",stroke:"#5c3b22",strokeWidth:"11",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"174",y1:"112",x2:"100",y2:"34",stroke:"#b3835a",strokeWidth:"8",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"26",y1:"112",x2:"174",y2:"112",stroke:"#5c3b22",strokeWidth:"11",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"26",y1:"112",x2:"174",y2:"112",stroke:"#b3835a",strokeWidth:"8",strokeLinecap:"square"}),e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("line",{x1:"45",y1:"112",x2:"140",y2:"88",stroke:"var(--accent)",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"7 5"}),(0,y.jsx)("line",{x1:"155",y1:"112",x2:"60",y2:"88",stroke:"var(--accent)",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"7 5"})]}):null,(0,y.jsx)("rect",{x:"18.5",y:"106.5",width:"15",height:"11",rx:"2",fill:"#d3d8de",stroke:"#7c8494",strokeWidth:"1"}),(0,y.jsx)("rect",{x:"166.5",y:"106.5",width:"15",height:"11",rx:"2",fill:"#d3d8de",stroke:"#7c8494",strokeWidth:"1"}),(0,y.jsx)("rect",{x:"92.5",y:"28.5",width:"15",height:"11",rx:"2",fill:"#d3d8de",stroke:"#7c8494",strokeWidth:"1"})]})}function yw({treated:e}){let t=e?"#5a7a4a":"var(--accent)";return(0,y.jsxs)("svg",{viewBox:"0 0 100 100",className:"truss-estimator__diagram truss-estimator__diagram--small","aria-hidden":"true",children:[(0,y.jsx)("rect",{x:"10",y:"22",width:"80",height:"14",rx:"2",fill:t}),(0,y.jsx)("rect",{x:"10",y:"43",width:"80",height:"14",rx:"2",fill:e?"#8faf7a":"var(--accent-light)"}),(0,y.jsx)("rect",{x:"10",y:"64",width:"80",height:"14",rx:"2",fill:t})]})}function Rd({onBack:e}){let[t,a]=(0,nl.useState)(0),[r,n]=(0,nl.useState)(j_),[i,o]=(0,nl.useState)(!1),[l,c]=(0,nl.useState)(!1),p=()=>{let m=Number.parseFloat(r.roofLengthM)||0,u=Number.parseFloat(r.centres??"");return m<=0||!u?0:Math.ceil(m*1e3/u)+1},b=(()=>{let m=r.range?Mt.ranges[r.range]:Mt.ranges.standard,u=r.pitch??"22.5",g=Mt.pitchMultipliers[u],v=(Number.parseFloat(r.spanMM)||0)/1e3,A=(Number.parseFloat(r.overhangMM)||0)>Mt.overhang.thresholdMM,T=p(),z=T+r.girderCount,G=Number.parseFloat(r.roofLengthM)||0,K=r.treatment?Mt.treatment[r.treatment]:Mt.treatment.untreated,fe=Mt.estimate.ranges[r.range??"standard"],Te=fe.supplyAt8m*Math.max(.7,v/8)*g*(1+K.surchargePct)+(A?Mt.overhang.surchargePerTruss:0),Ye=T*Te,Ve=r.girderCount*Te*Mt.estimate.girderMultiplier,it=r.bracing==="yes"?G*Mt.estimate.bracingPerMetre:0,pe=Ye+Ve+it+Mt.estimate.delivery,Q=Mt.estimate.design+T*fe.installPerTruss+r.girderCount*40,ce=pe+Q,xe=ce*.2;return{range:m,count:T,girderCount:r.girderCount,overhangApplies:A,overhangUnits:z,roofLengthM:G,treatment:K,trussSupply:Ye,bracingMaterials:it,delivery:Mt.estimate.delivery,labour:Q,subtotal:ce,vat:xe,total:ce+xe}})(),d=()=>{let m=cc[t];return m==="range"?!!r.range:m==="pitchAndDimensions"?!!r.pitch&&r.spanMM.trim()!==""&&r.overhangMM.trim()!=="":m==="quantityAndGirders"?r.roofLengthM.trim()!==""&&!!r.centres:m==="bracing"?!!r.bracing&&!!r.treatment:!0},h=t===cc.length-1?"View truss request":"Next",w=()=>{i?o(!1):t===0?e():a(m=>m-1)},M=()=>{d()&&(t===cc.length-1?(c(!1),o(!0)):a(m=>m+1))},D=()=>{let m=cc[t];return m==="range"?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Step 1 of 4"}),(0,y.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your truss range"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Pricing shown is placeholder. Swap in your real engineering and pricing catalogue."}),(0,y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--range",children:Object.entries(Mt.ranges).map(([u,g])=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r.range===u?" is-selected":""}`,onClick:()=>n(v=>({...v,range:u})),children:[(0,y.jsx)(Q_,{type:u}),(0,y.jsxs)("div",{className:"truss-estimator__option-info",children:[(0,y.jsx)("div",{className:"truss-estimator__option-title",children:g.label}),(0,y.jsx)("div",{className:"truss-estimator__option-copy",children:g.blurb})]})]},u))})]}):m==="pitchAndDimensions"?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Step 2 of 4"}),(0,y.jsx)("h2",{className:"truss-estimator__step-title",children:"Span, overhang and roof pitch"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Span is wall-to-wall, overhang is the eaves tail beyond the wall line. Steeper pitches use more timber per truss."}),(0,y.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,y.jsxs)("label",{className:"truss-estimator__field",children:[(0,y.jsx)("span",{children:"Span (mm)"}),(0,y.jsx)("input",{type:"text",inputMode:"numeric",value:r.spanMM,onChange:u=>n(g=>({...g,spanMM:u.target.value}))})]}),(0,y.jsxs)("label",{className:"truss-estimator__field",children:[(0,y.jsx)("span",{children:"Overhang (mm)"}),(0,y.jsx)("input",{type:"text",inputMode:"numeric",value:r.overhangMM,onChange:u=>n(g=>({...g,overhangMM:u.target.value}))}),(0,y.jsxs)("small",{children:["Overhangs beyond ",Mt.overhang.thresholdMM,"mm add a small surcharge per truss."]})]})]}),(0,y.jsx)("div",{className:"truss-estimator__section-heading",children:"Roof pitch"}),(0,y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--pitch",children:Mt.pitches.map(u=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card${r.pitch===u?" is-selected":""}`,onClick:()=>n(g=>({...g,pitch:u})),children:[(0,y.jsx)(G_,{degrees:Number.parseFloat(u)}),(0,y.jsxs)("span",{children:[u,"\xB0"]})]},u))})]}):m==="quantityAndGirders"?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Step 3 of 4"}),(0,y.jsx)("h2",{className:"truss-estimator__step-title",children:"Roof length"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Trusses are based on designs at 400mm or 600mm centres wherever possible."}),(0,y.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact",children:[(0,y.jsx)("span",{children:"Roof length (m)"}),(0,y.jsx)("input",{type:"text",inputMode:"decimal",value:r.roofLengthM,onChange:u=>n(g=>({...g,roofLengthM:u.target.value}))})]}),(0,y.jsx)("div",{className:"truss-estimator__section-heading",children:"Truss centres"}),(0,y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--centres",children:Mt.centresOptions.map(u=>(0,y.jsx)("button",{type:"button",className:`truss-estimator__option-card truss-estimator__option-card--compact${r.centres===u?" is-selected":""}`,onClick:()=>n(g=>({...g,centres:u})),children:(0,y.jsxs)("div",{className:"truss-estimator__option-title",children:[u,"mm centres"]})},u))}),(0,y.jsxs)("div",{className:"truss-estimator__stat",children:[p()," trusses estimated"]}),(0,y.jsx)("div",{className:"truss-estimator__section-heading",children:"Girder trusses"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Heavy-duty girder trusses carry point loads over large openings. Set 0 if you do not need any."}),(0,y.jsxs)("div",{className:"truss-estimator__stepper",children:[(0,y.jsx)("button",{type:"button",onClick:()=>n(u=>({...u,girderCount:Math.max(0,u.girderCount-1)})),children:"\u2212"}),(0,y.jsx)("span",{children:r.girderCount}),(0,y.jsx)("button",{type:"button",onClick:()=>n(u=>({...u,girderCount:Math.min(3,u.girderCount+1)})),children:"+"})]})]}):m==="bracing"?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Step 4 of 4"}),(0,y.jsx)("h2",{className:"truss-estimator__step-title",children:"Bracing pack?"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"A timber bracing pack stabilises the roof structure once trusses are erected."}),(0,y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"no",label:"No bracing pack"},{id:"yes",label:"Add bracing pack"}].map(u=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${r.bracing===u.id?" is-selected":""}`,onClick:()=>n(g=>({...g,bracing:u.id})),children:[(0,y.jsx)(Y_,{enabled:u.id==="yes"}),(0,y.jsx)("span",{children:u.label})]},u.id))}),(0,y.jsx)("div",{className:"truss-estimator__section-heading",children:"Timber treatment"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Tanalised timber protects against rot in exposed or damp locations."}),(0,y.jsxs)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${r.treatment==="untreated"?" is-selected":""}`,onClick:()=>n(u=>({...u,treatment:"untreated"})),children:[(0,y.jsx)(yw,{treated:!1}),(0,y.jsx)("span",{children:"Untreated"})]}),(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${r.treatment==="treated"?" is-selected":""}`,onClick:()=>n(u=>({...u,treatment:"treated"})),children:[(0,y.jsx)(yw,{treated:!0}),(0,y.jsx)("span",{children:"Treated (+8% cost)"}),(0,y.jsx)("small",{children:"Applies to trusses, girders and overhang"})]})]})]}):null};return i?(0,y.jsx)(y.Fragment,{children:(0,y.jsxs)("div",{className:"truss-estimator",children:[(0,y.jsxs)("div",{className:"quick-order-hero",children:[(0,y.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,y.jsx)("h1",{children:"Your truss estimate"}),(0,y.jsx)("p",{children:"A provisional quantity and specification based on the dimensions you entered."})]}),(0,y.jsxs)("div",{className:"truss-estimator__card truss-request",style:{minHeight:0},children:[(0,y.jsxs)("div",{className:"truss-request__heading",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Estimated requirement"}),(0,y.jsxs)("h2",{children:[b.range.label," roof trusses"]})]}),(0,y.jsxs)("strong",{children:[b.count,(0,y.jsx)("span",{children:"trusses"})]})]}),(0,y.jsxs)("div",{className:"truss-request__grid",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Span"}),(0,y.jsxs)("strong",{children:[r.spanMM," mm"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Roof length"}),(0,y.jsxs)("strong",{children:[r.roofLengthM," m"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Pitch"}),(0,y.jsxs)("strong",{children:[r.pitch,"\xB0"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Centres"}),(0,y.jsxs)("strong",{children:[r.centres," mm"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Overhang"}),(0,y.jsxs)("strong",{children:[r.overhangMM," mm"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Treatment"}),(0,y.jsx)("strong",{children:b.treatment.label})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Girder trusses"}),(0,y.jsx)("strong",{children:b.girderCount||"None"})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Bracing pack"}),(0,y.jsx)("strong",{children:r.bracing==="yes"?"Included":"Not included"})]})]}),(0,y.jsxs)("div",{className:"truss-request__price",children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Indicative cost estimate"}),(0,y.jsxs)("div",{className:"truss-request__price-grid",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Truss supply allowance"}),(0,y.jsx)("strong",{children:nt(b.trussSupply)})]}),b.bracingMaterials>0&&(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Bracing materials allowance"}),(0,y.jsx)("strong",{children:nt(b.bracingMaterials)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Delivery allowance"}),(0,y.jsx)("strong",{children:nt(b.delivery)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Design and installation labour"}),(0,y.jsx)("strong",{children:nt(b.labour)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Subtotal (ex. VAT)"}),(0,y.jsx)("strong",{children:nt(b.subtotal)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"VAT (20%)"}),(0,y.jsx)("strong",{children:nt(b.vat)})]}),(0,y.jsxs)("div",{className:"truss-request__price-total",children:[(0,y.jsx)("span",{children:"Estimated total"}),(0,y.jsx)("strong",{children:nt(b.total)})]})]}),(0,y.jsx)("p",{children:"Trusses are not listed as fixed products in this catalogue, so supply, delivery and labour are benchmark allowances. Confirm the engineered design and final quote before ordering."})]}),(0,y.jsxs)("div",{className:"truss-request__notice",children:[(0,y.jsx)("strong",{children:"Before ordering"}),(0,y.jsx)("span",{children:"Roof trusses must be designed and signed off for the building. Confirm loading, bearings, wind bracing and final drawings with the truss manufacturer."})]}),(0,y.jsxs)("div",{className:"truss-estimator__nav",children:[(0,y.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:w,children:"Back to calculator"}),(0,y.jsx)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",justifyContent:"center",marginTop:0},onClick:()=>c(!0),children:"Request order"})]}),l&&(0,y.jsx)("p",{className:"truss-request__demo",children:"Demo only \u2014 no order has been sent."})]})]})}):(0,y.jsx)(y.Fragment,{children:(0,y.jsxs)("div",{className:"truss-estimator",children:[(0,y.jsxs)("div",{className:"quick-order-hero",children:[(0,y.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,y.jsx)("h1",{children:"Roof Truss Calculator"}),(0,y.jsx)("p",{children:"Estimate trusses, girders and cost for your roof in a few steps."})]}),(0,y.jsxs)("div",{className:"truss-estimator__card",children:[(0,y.jsx)("div",{className:"truss-estimator__body",children:D()}),(0,y.jsxs)("div",{className:"truss-estimator__nav",children:[(0,y.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:w,children:"Back"}),(0,y.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:M,disabled:!d(),children:[(0,y.jsx)("span",{children:h}),(0,y.jsx)("span",{className:"arrow",children:(0,y.jsx)(Ot,{})})]})]})]})]})})}var qi=Y(Xe()),F=Y(ae()),kw=e=>Number.parseFloat(e)||0,uc=(e,t)=>kw(e)*(t==="m"?1:.3048),_w=()=>({length:"",width:""}),xw=[{id:"chamfered",label:"Chamfered",blurb:"Clean angled edge"},{id:"ogee",label:"Ogee",blurb:"Traditional curved profile"},{id:"pencil-round",label:"Pencil round",blurb:"Simple softened edge"},{id:"torus",label:"Torus",blurb:"Soft rounded detail"}];function V_({profile:e}){return(0,F.jsxs)("svg",{className:"skirting-calculator__profile-diagram",viewBox:"0 0 120 84","aria-hidden":"true",children:[(0,F.jsx)("path",{d:{chamfered:"M16 70V43L43 16H104V70Z",ogee:"M16 70V47C16 36 27 31 40 31C40 21 50 16 63 16H104V70Z","pencil-round":"M16 70V37C16 25 25 16 37 16H104V70Z",torus:"M16 70V49C16 39 25 34 36 34C36 22 47 16 61 16H104V70Z"}[e]}),(0,F.jsx)("line",{x1:"12",y1:"70",x2:"108",y2:"70"})]})}function Ud({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,qi.useState)("total"),[i,o]=(0,qi.useState)("m"),[l,c]=(0,qi.useState)(""),[p,f]=(0,qi.useState)([_w()]),[b,d]=(0,qi.useState)(""),[h,w]=(0,qi.useState)("chamfered"),M="4.2",D=r==="total"?uc(l,i):p.reduce((N,A)=>N+2*(uc(A.length,i)+uc(A.width,i)),0),m=Math.max(0,D-uc(b,i)),u=Math.ceil(m/kw(M)),g=[{key:`skirting-${h}`,label:`${xw.find(N=>N.id===h)?.label} skirting board`,qty:m,unit:"m",query:"skirting board",category:"skirting"}],v=(N,A,T)=>{f(z=>z.map((G,K)=>K===N?{...G,[A]:T}:G))};return(0,F.jsx)(F.Fragment,{children:(0,F.jsxs)("div",{className:"truss-estimator",children:[(0,F.jsxs)("div",{className:"quick-order-hero",children:[(0,F.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,F.jsx)("h1",{children:"Skirting Board Calculator"}),(0,F.jsx)("p",{children:"Work out how many skirting board lengths you need for one room or a whole project."})]}),(0,F.jsxs)("div",{className:"truss-estimator__card skirting-calculator",children:[(0,F.jsx)("h2",{className:"truss-estimator__step-title",children:"Measure by room or total length"}),(0,F.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter a single total or work room by room. The run is converted straight into board lengths."}),(0,F.jsxs)("div",{className:"skirting-calculator__section",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"How would you like to measure?"}),(0,F.jsxs)("div",{className:"brick-calculator__unit-toggle skirting-calculator__mode-toggle",role:"group","aria-label":"Calculation method",children:[(0,F.jsx)("button",{type:"button",className:r==="total"?"is-selected":"",onClick:()=>n("total"),children:"Total length"}),(0,F.jsx)("button",{type:"button",className:r==="rooms"?"is-selected":"",onClick:()=>n("rooms"),children:"Room by room"})]})]}),(0,F.jsxs)("div",{className:"skirting-calculator__section",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"Measurements"}),(0,F.jsxs)("div",{className:"skirting-calculator__unit-row",children:[(0,F.jsx)("span",{children:"Units"}),(0,F.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,F.jsx)("button",{type:"button",className:i==="m"?"is-selected":"",onClick:()=>o("m"),children:"Metres"}),(0,F.jsx)("button",{type:"button",className:i==="ft"?"is-selected":"",onClick:()=>o("ft"),children:"Feet"})]})]}),r==="total"?(0,F.jsxs)("label",{className:"truss-estimator__field skirting-calculator__single-field",children:[(0,F.jsxs)("span",{children:["Total skirting length (",i,")"]}),(0,F.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:N=>c(N.target.value)})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)("div",{className:"skirting-calculator__dimensions-header",children:[(0,F.jsx)("span",{children:"Room"}),(0,F.jsxs)("span",{children:["Length (",i,")"]}),(0,F.jsxs)("span",{children:["Width (",i,")"]}),(0,F.jsx)("span",{})]}),p.map((N,A)=>(0,F.jsxs)("div",{className:"skirting-calculator__room-row",children:[(0,F.jsxs)("span",{className:"skirting-calculator__room-label",children:["Room ",A+1]}),(0,F.jsx)("input",{"aria-label":`Room ${A+1} length in ${i}`,type:"number",min:"0",step:"0.01",value:N.length,onChange:T=>v(A,"length",T.target.value)}),(0,F.jsx)("input",{"aria-label":`Room ${A+1} width in ${i}`,type:"number",min:"0",step:"0.01",value:N.width,onChange:T=>v(A,"width",T.target.value)}),p.length>1?(0,F.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>f(T=>T.filter((z,G)=>G!==A)),children:"Remove"}):null]},`room-${A}`)),(0,F.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>f(N=>[...N,_w()]),children:"+ Add another room"})]}),(0,F.jsxs)("label",{className:"truss-estimator__field skirting-calculator__single-field",children:[(0,F.jsxs)("span",{children:["Openings and doorways to deduct (",i,") ",(0,F.jsx)("small",{children:"optional"})]}),(0,F.jsx)("input",{type:"number",min:"0",step:"0.01",value:b,onChange:N=>d(N.target.value)})]})]}),(0,F.jsxs)("div",{className:"skirting-calculator__section",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"Profile"}),(0,F.jsx)("p",{className:"skirting-calculator__hint",children:"Choose the finish you want for the fixed 4.2m white-primed MDF boards."}),(0,F.jsx)("div",{className:"architrave-calculator__profiles",children:xw.map(N=>(0,F.jsxs)("button",{type:"button",className:`truss-estimator__option-card${h===N.id?" is-selected":""}`,onClick:()=>w(N.id),children:[(0,F.jsx)(V_,{profile:N.id}),(0,F.jsx)("div",{className:"truss-estimator__option-title",children:N.label}),(0,F.jsx)("div",{className:"truss-estimator__option-copy",children:N.blurb})]},N.id))})]}),(0,F.jsxs)("div",{className:"skirting-calculator__section",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"Board and waste"}),(0,F.jsx)("div",{className:"truss-estimator__field-grid skirting-calculator__options-grid",children:(0,F.jsxs)("label",{className:"truss-estimator__field",children:[(0,F.jsx)("span",{children:"Board length"}),(0,F.jsx)("input",{value:"4.20 m",disabled:!0})]})}),(0,F.jsx)("p",{className:"skirting-calculator__hint",children:"Longer boards can reduce the number of joins, while 10% waste allows for cuts, corners and mistakes."})]}),(0,F.jsxs)("div",{className:"skirting-calculator__totals",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,F.jsxs)("div",{className:"skirting-calculator__result-grid",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{children:"Net skirting"}),(0,F.jsxs)("strong",{children:[m.toFixed(2)," m"]})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{children:"Board lengths"}),(0,F.jsx)("strong",{children:u})]})]}),(0,F.jsx)("p",{className:"skirting-calculator__note",children:"Corners and joins vary by room layout. Measure each wall where possible for the most accurate result."})]}),(0,F.jsxs)("div",{className:"skirting-calculator__actions",children:[(0,F.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,F.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(g),disabled:m<=0,children:a})]})]})]})})}var jn=Y(Xe()),oe=Y(ae()),ol=e=>Number.parseFloat(e)||0;function Dd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,jn.useState)("studs"),[i,o]=(0,jn.useState)(""),[l,c]=(0,jn.useState)(""),[p,f]=(0,jn.useState)("600"),[b,d]=(0,jn.useState)("2.4"),h=i&&l&&p?Math.ceil(ol(l)/(ol(p)/1e3))+1:0,w=h*ol(i),M=ol(b)>0?Math.ceil(w/ol(b)):0,D=[{key:r,label:{studs:"Stud timber",joists:"Joist timber",battens:"Batten timber"}[r],qty:w,unit:"m",query:{studs:"cls studwork timber",joists:"timber joist",battens:"roofing batten"}[r],category:"timber"}],m={studs:["Stud wall","Vertical studs along a wall length"],joists:["Joists","Parallel joists across a floor or deck"],battens:["Battens","Regularly spaced battens for lining or cladding"]},g={studs:{member:"Wall height",overall:"Wall length",help:"Studs repeat across the wall length.",count:"Studs"},joists:{member:"Joist span",overall:"Overall width",help:"Joists repeat across the overall floor or deck width.",count:"Joists"},battens:{member:"Batten length",overall:"Overall width",help:"Battens repeat across the overall lining or cladding width.",count:"Battens"}}[r];return(0,oe.jsx)(oe.Fragment,{children:(0,oe.jsxs)("div",{className:"truss-estimator",children:[(0,oe.jsxs)("div",{className:"quick-order-hero",children:[(0,oe.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,oe.jsx)("h1",{children:"Timber Calculator"}),(0,oe.jsx)("p",{children:"Estimate studs, joists or battens from a run length, width and spacing."})]}),(0,oe.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,oe.jsx)("h2",{className:"truss-estimator__step-title",children:"Member size and spacing"}),(0,oe.jsxs)("p",{className:"truss-estimator__step-sub",children:[g.help," Enter the member length and centres to estimate the number of pieces and stock lengths."]}),(0,oe.jsxs)("div",{className:"materials-calculator__section",children:[(0,oe.jsx)("div",{className:"truss-estimator__section-heading",children:"Timber use"}),(0,oe.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:Object.keys(m).map(v=>(0,oe.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===v?" is-selected":""}`,onClick:()=>n(v),children:[(0,oe.jsx)("div",{className:"truss-estimator__option-title",children:m[v][0]}),(0,oe.jsx)("div",{className:"truss-estimator__option-copy",children:m[v][1]})]},v))})]}),(0,oe.jsxs)("div",{className:"materials-calculator__section",children:[(0,oe.jsx)("div",{className:"truss-estimator__section-heading",children:"Dimensions and spacing"}),(0,oe.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,oe.jsxs)("label",{className:"truss-estimator__field",children:[(0,oe.jsxs)("span",{children:[g.member," (m)"]}),(0,oe.jsx)("input",{type:"number",min:"0",step:"0.01",value:i,onChange:v=>o(v.target.value)})]}),(0,oe.jsxs)("label",{className:"truss-estimator__field",children:[(0,oe.jsxs)("span",{children:[g.overall," (m)"]}),(0,oe.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:v=>c(v.target.value)})]})]}),(0,oe.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,oe.jsxs)("label",{className:"truss-estimator__field",children:[(0,oe.jsx)("span",{children:"Centres (mm)"}),(0,oe.jsxs)("select",{value:p,onChange:v=>f(v.target.value),children:[(0,oe.jsx)("option",{value:"300",children:"300 mm"}),(0,oe.jsx)("option",{value:"400",children:"400 mm"}),(0,oe.jsx)("option",{value:"450",children:"450 mm"}),(0,oe.jsx)("option",{value:"600",children:"600 mm"})]})]}),(0,oe.jsxs)("label",{className:"truss-estimator__field",children:[(0,oe.jsx)("span",{children:"Stock length (m)"}),(0,oe.jsxs)("select",{value:b,onChange:v=>d(v.target.value),children:[(0,oe.jsx)("option",{value:"2.4",children:"2.40 m"}),(0,oe.jsx)("option",{value:"3.6",children:"3.60 m"}),(0,oe.jsx)("option",{value:"4.8",children:"4.80 m"})]})]})]})]}),(0,oe.jsxs)("div",{className:"materials-calculator__totals",children:[(0,oe.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,oe.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,oe.jsxs)("div",{children:[(0,oe.jsx)("span",{children:g.count}),(0,oe.jsx)("strong",{children:h})]}),(0,oe.jsxs)("div",{children:[(0,oe.jsx)("span",{children:"Linear metres"}),(0,oe.jsxs)("strong",{children:[w.toFixed(2)," m"]})]}),(0,oe.jsxs)("div",{children:[(0,oe.jsxs)("span",{children:[b," m lengths"]}),(0,oe.jsx)("strong",{children:M})]})]}),(0,oe.jsx)("p",{className:"materials-calculator__note",children:"Spacing is measured centre-to-centre. Add extra timber for plates, noggins, trimming and openings where required."})]}),(0,oe.jsxs)("div",{className:"materials-calculator__actions",children:[(0,oe.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,oe.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(D),disabled:w<=0,children:a})]})]})]})})}var Bd=[{id:"truss",title:"Roof Truss Calculator",desc:"Estimate trusses, girders and roof structure costs.",imageUrl:"/tool-images/truss.webp",Component:Rd},{id:"fencing",title:"Fencing Calculator",desc:"Estimate fence panels, posts, gravel boards and fixings.",imageUrl:"/tool-images/fencing.webp",Component:Cd},{id:"decking",title:"Decking Calculator",desc:"Estimate boards, substructure and fixing quantities.",imageUrl:"/tool-images/decking.webp",Component:Sd},{id:"brick-block",title:"Brick & Block Calculator",desc:"Estimate masonry units and ready-mixed mortar for a wall.",imageUrl:"/tool-images/brick-block.webp",Component:yd},{id:"paint",title:"Paint Calculator",desc:"Estimate paint for walls, doors and multiple coats.",imageUrl:"/tool-images/paint.webp",Component:Ed},{id:"skirting",title:"Skirting Board Calculator",desc:"Estimate skirting lengths for rooms and wall runs.",imageUrl:"/tool-images/skirting.webp",Component:Ud},{id:"architrave",title:"Architrave Calculator",desc:"Estimate architrave lengths for door and window openings.",imageUrl:"/tool-images/architrave.webp",Component:wd},{id:"concrete-aggregate",title:"Concrete & Aggregate Calculator",desc:"Estimate concrete, MOT, sand and gravel quantities.",imageUrl:"/tool-images/concrete-aggregate.webp",Component:kd},{id:"plasterboard",title:"Plasterboard Calculator",desc:"Estimate plasterboard sheets, screws, tape and adhesive.",imageUrl:"/tool-images/plasterboard.webp",Component:Ad},{id:"insulation",title:"Insulation Calculator",desc:"Estimate insulation packs for floors, walls, roofs and lofts.",imageUrl:"/tool-images/insulation.webp",Component:qd},{id:"timber",title:"Timber Calculator",desc:"Estimate studs, joists and battens from spacing and lengths.",imageUrl:"/tool-images/timber.webp",Component:Dd},{id:"paving",title:"Paving & Driveway Calculator",desc:"Estimate paving, block paving, MOT and sharp sand.",imageUrl:"/tool-images/paving.webp",Component:Td}];var dc=Y(Xe());var Le=Y(Xe());var S=Y(ae()),X_=[{dir:"asc",label:"Description (A-Z)"},{dir:"desc",label:"Description (Z-A)"}],Od={wasteFactorEnabled:!0},$_=3e3,Nw=null;function pc(e,t){let a=Fo(t);return a?`${e.toFixed(2)} ${a}`:e.toFixed(2)}function Z_(e){return e&&e.length>0?e.join(" x "):"-"}function Ld({toolId:e,requirements:t,ready:a,onBack:r,onTotalChange:n}){let i=Js(),o=`${e}~${t.map(C=>`${C.key}|${C.query}|${C.category??""}|${C.qty}`).join("~")}`,l=o!==Nw,[c,p]=(0,Le.useState)(null),[f,b]=(0,Le.useState)([]),[d,h]=(0,Le.useState)(l),[w,M]=(0,Le.useState)(null),[D,m]=(0,Le.useState)("tile"),[u,g]=(0,Le.useState)(null),[v,N]=(0,Le.useState)(""),[A,T]=(0,Le.useState)(null),[z,G]=(0,Le.useState)(""),[K,fe]=(0,Le.useState)([]),[Te,Ye]=(0,Le.useState)(new Set),[Ve,it]=(0,Le.useState)(null),[pe,Q]=(0,Le.useState)(""),[ce,xe]=(0,Le.useState)([]),ye=(0,Le.useRef)(null),ee=(0,Le.useRef)(!1),se=C=>`${e}:${C}`,Me=C=>Kr(C.chosen,{lineId:se(C.requirement.key),description:C.requirement.label,unit:C.requirement.unit,qty:C.requirement.qty}),_e=(0,Le.useMemo)(()=>t.map(C=>`${C.key}|${C.query}|${C.category??""}`).join("~"),[t]);(0,Le.useEffect)(()=>{let C=!1;return pw().then(V=>{C||p(V.itemCount>0)}).catch(()=>{C||p(!1)}),()=>{C=!0}},[]),(0,Le.useEffect)(()=>{if(!a||!c)return;let C=!1,V;l&&h(!0),M(null);let X=Date.now();return(async()=>{let me=null;try{me=(await uw(t)).map(({requirement:dt,candidates:je})=>({requirement:dt,candidates:je,chosen:je[0]??null}))}catch(Ce){C||M(Ce instanceof Error?Ce.message:"Could not load products")}if(!C){if(Nw=o,l){let Ce=$_-(Date.now()-X);Ce>0&&await new Promise(dt=>{V=window.setTimeout(dt,Ce)})}C||(me&&(b(me),!ee.current&&i&&(ee.current=!0,i.addManyToCart(me.filter(Ce=>Ce.chosen).map(Me)))),h(!1))}})(),()=>{C=!0,window.clearTimeout(V)}},[a,c,_e]),(0,Le.useEffect)(()=>{if(!A)return;let C=z.trim();if(!C){fe([]);return}let V=!1,X=window.setTimeout(()=>{Jr(C).then(me=>{V||fe(me)}).catch(()=>{V||fe([])})},250);return()=>{V=!0,window.clearTimeout(X)}},[A,z]),(0,Le.useEffect)(()=>{if(!Ve)return;let C=pe.trim();if(!C){xe([]);return}let V=!1,X=window.setTimeout(()=>{Jr(C).then(me=>{V||xe(me)}).catch(()=>{V||xe([])})},250);return()=>{V=!0,window.clearTimeout(X)}},[Ve,pe]);let et=(0,Le.useMemo)(()=>{let C=v.trim().toLowerCase(),V=C?f.filter(X=>X.requirement.label.toLowerCase().includes(C)||(X.chosen?.description??"").toLowerCase().includes(C)||(X.chosen?.product_id??"").toLowerCase().includes(C)):f;return u?[...V].sort((X,me)=>{let Ce=X.requirement.label.localeCompare(me.requirement.label);return u==="asc"?Ce:-Ce}):V},[f,v,u]),Ht=et.filter(C=>C.chosen),Tt=et.filter(C=>!C.chosen),tt=f.filter(C=>C.chosen),ct=tt.filter(C=>C.chosen?.price==null).length,He=tt.reduce((C,V)=>C+(ua(Me(V),Od).lineTotal??0),0);if((0,Le.useEffect)(()=>{n?.(He)},[He,n]),!a||c===!1)return null;let E=i?tt.filter(C=>i.cart[se(C.requirement.key)]).length:0,x=Ve?f.find(C=>C.requirement.key===Ve)??null:null,I=pe.trim()?ce:x?.candidates??[],ue=C=>{let V=A===C.requirement.key;T(V?null:C.requirement.key),G(V?"":C.requirement.query)},ve=(C,V)=>{let X=f.find(me=>me.requirement.key===C);b(me=>me.map(Ce=>Ce.requirement.key===C?{...Ce,chosen:V}:Ce)),i&&X&&i.cart[se(C)]&&i.addToCart(Me({...X,chosen:V})),T(null),G("")},Se=C=>{b(V=>V.map(X=>X.requirement.key===C?{...X,chosen:null}:X)),i?.cart[se(C)]&&i.removeFromCart(se(C))},k=C=>{it(C.requirement.key),Q(""),xe([])},j=()=>{it(null),Q(""),xe([])},O=C=>{if(!i)return;let V=se(C.requirement.key);i.cart[V]?i.removeFromCart(V):i.addToCart(Me(C))},ne=C=>{Ye(V=>{let X=new Set(V);return X.has(C)?X.delete(C):X.add(C),X})},W=C=>{let V=K.length>0?K:C.candidates;return(0,S.jsxs)("div",{className:"estimator-products__picker",children:[(0,S.jsx)("input",{type:"text",className:"results-search-input",value:z,autoFocus:!0,placeholder:"Search products in catalogue...",onChange:X=>G(X.target.value),"aria-label":`Search a product for ${C.requirement.label}`}),(0,S.jsxs)("div",{className:"estimator-products__options",children:[V.map(X=>(0,S.jsxs)("button",{type:"button",className:`estimator-products__option${X.product_id===C.chosen?.product_id?" is-selected":""}`,onClick:()=>ve(C.requirement.key,X),children:[(0,S.jsx)("span",{children:X.description}),(0,S.jsxs)("span",{className:"results-row-meta",children:[X.product_id,X.price!=null&&` \xB7 ${nt(X.price)}`]})]},X.product_id)),V.length===0&&(0,S.jsx)("p",{className:"results-empty-hint",children:"No matching products."})]})]})};return(0,S.jsxs)("section",{className:"estimator-products results-tile-section","aria-label":"Matched products",children:[!d&&(0,S.jsxs)("div",{className:"estimator-products__head",children:[(0,S.jsxs)("div",{className:"results-tile-section__head",children:[(0,S.jsx)("h3",{children:"Matched Products"}),(0,S.jsx)("p",{children:"Products matched to your estimate, check before adding to your basket."})]}),!x&&(0,S.jsxs)("div",{className:"results-summary estimator-products__toolbar",children:[ct>0&&(0,S.jsxs)("span",{className:"summary-chip summary-chip--neutral",children:[(0,S.jsx)("strong",{children:ct})," need pricing"]}),(0,S.jsxs)("div",{className:"estimator-products__controls",children:[(0,S.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search description...",value:v,onChange:C=>N(C.target.value),"aria-label":"Search matched products"}),(0,S.jsxs)("div",{className:"results-view-toggle","aria-label":"Results view",children:[(0,S.jsx)("button",{type:"button",className:`results-view-toggle__btn${D==="tile"?" is-active":""}`,"aria-pressed":D==="tile","aria-label":"Tile view",title:"Tile view",onClick:()=>m("tile"),children:(0,S.jsxs)("svg",{width:"18",height:"12",viewBox:"0 0 15 10",fill:"currentColor",children:[(0,S.jsx)("rect",{x:"0.5",y:"0.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"5.5",y:"0.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"10.5",y:"0.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"0.5",y:"5.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"5.5",y:"5.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"10.5",y:"5.5",width:"4",height:"4"})]})}),(0,S.jsx)("button",{type:"button",className:`results-view-toggle__btn${D==="list"?" is-active":""}`,"aria-pressed":D==="list","aria-label":"List view",title:"List view",onClick:()=>m("list"),children:(0,S.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 15 15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,S.jsx)("line",{x1:"0.5",y1:"2.5",x2:"14.5",y2:"2.5"}),(0,S.jsx)("line",{x1:"0.5",y1:"7.5",x2:"14.5",y2:"7.5"}),(0,S.jsx)("line",{x1:"0.5",y1:"12.5",x2:"14.5",y2:"12.5"})]})})]}),(0,S.jsxs)("details",{ref:ye,style:{position:"relative"},children:[(0,S.jsx)("summary",{className:"bom-toolbar-btn sort-menu-summary","aria-label":"Sort materials",style:{fontSize:16},children:"\u21C5"}),(0,S.jsx)("div",{className:"sort-menu-panel",children:X_.map(C=>{let V=u===C.dir;return(0,S.jsxs)("button",{type:"button",className:`sort-menu-item${V?" is-active":""}`,onClick:()=>{g(V?null:C.dir),ye.current?.removeAttribute("open")},children:[(0,S.jsx)("span",{className:"sort-menu-item__check",children:V?"\u2713":""}),C.label]},C.dir)})})]})]})]})]}),x&&(0,S.jsxs)("div",{className:"results-review-page",children:[(0,S.jsxs)("div",{className:"results-review-page__top",children:[(0,S.jsxs)("button",{type:"button",className:"bom-toolbar-btn bom-toolbar-btn--accent",onClick:j,children:[(0,S.jsx)(Zr,{}),"Back to results"]}),(0,S.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,S.jsx)("div",{className:"results-review-searchbar",children:(0,S.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search products in catalogue...",value:pe,onChange:C=>Q(C.target.value),"aria-label":`Search a product for ${x.requirement.label}`})}),x.chosen&&(0,S.jsx)("div",{className:"results-candidate-actions",children:(0,S.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Se(x.requirement.key),children:"Clear selected product"})})]})]}),(0,S.jsxs)("div",{className:"results-review-page__hero",children:[(0,S.jsx)("div",{className:"results-review-page__image-wrap",children:(0,S.jsx)("img",{className:"fill-img results-review-page__image",src:Qa(x.chosen?.description||x.requirement.label,x.chosen?.product_id,x.chosen?.pdp_photo_url),alt:""})}),(0,S.jsxs)("div",{className:"results-review-page__summary",children:[(0,S.jsx)("h2",{children:x.requirement.label}),(0,S.jsxs)("p",{className:"results-review-page__meta",children:[_i(x.requirement.qty)," ",ka(x.requirement.unit,x.requirement.qty)]}),x.chosen?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("div",{className:"results-review-page__product",children:x.chosen.description}),(0,S.jsxs)("div",{className:"results-row-meta",children:[x.chosen.product_id,x.chosen.price!=null?` \xB7 ${pc(x.chosen.price,x.chosen.price_basis)}`:""]})]}):(0,S.jsx)("div",{className:"results-empty-hint",children:"No product currently selected for this line."}),(0,S.jsx)("div",{className:"results-review-page__actions",children:(0,S.jsx)("button",{type:"button",className:`bom-toolbar-btn${i?.cart[se(x.requirement.key)]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>O(x),disabled:!x.chosen||!i,children:i?.cart[se(x.requirement.key)]?"\u2713 Added":"+ Add to basket"})})]})]}),I.length===0?(0,S.jsx)("p",{className:"results-empty-hint",children:"No matching products."}):(0,S.jsxs)("table",{className:"score-breakdown-table",children:[(0,S.jsx)("thead",{children:(0,S.jsxs)("tr",{children:[(0,S.jsx)("th",{children:"Product"}),(0,S.jsx)("th",{children:"Dims (mm)"}),(0,S.jsx)("th",{children:"Price"}),(0,S.jsx)("th",{"aria-label":"Actions"})]})}),(0,S.jsx)("tbody",{children:I.map(C=>{let V=C.product_id===x.chosen?.product_id;return(0,S.jsxs)("tr",{className:V?"score-breakdown-row--best":"",children:[(0,S.jsxs)("td",{children:[(0,S.jsx)("div",{children:C.description}),(0,S.jsx)("div",{className:"results-row-meta",children:C.product_id})]}),(0,S.jsx)("td",{children:(0,S.jsx)("span",{className:"unit-badge",children:Z_(C.measurements_mm)})}),(0,S.jsx)("td",{children:C.price!=null?pc(C.price,C.price_basis):"-"}),(0,S.jsx)("td",{children:(0,S.jsxs)("label",{className:"switch-toggle",title:V?"Currently selected":"Use this candidate",children:[(0,S.jsx)("input",{type:"checkbox",checked:V,onChange:()=>{V?Se(x.requirement.key):ve(x.requirement.key,C)},"aria-label":V?`${C.description} selected`:`Use ${C.description}`}),(0,S.jsx)("span",{className:"switch-toggle-track","aria-hidden":"true"})]})})]},C.product_id)})})]})]}),!x&&d&&(0,S.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{padding:"32px 24px"},children:[(0,S.jsx)(dr,{}),(0,S.jsx)("p",{className:"banter-message is-visible",style:{fontSize:15,minHeight:0},children:"Matching your materials against the catalogue\u2026"})]}),!x&&w&&(0,S.jsx)("p",{className:"results-empty-hint estimator-products__error",children:w}),!x&&!d&&!w&&et.length===0&&f.length>0&&(0,S.jsx)("p",{className:"results-empty-hint",children:"No materials match the current search."}),!x&&!d&&!w&&D==="tile"&&Ht.length>0&&(0,S.jsx)("div",{className:"results-tile-grid",children:Ht.map(C=>{let{requirement:V,chosen:X}=C,me=X?ua(Me(C),Od):null,Ce=i?!!i.cart[se(V.key)]:!1;return(0,S.jsxs)("article",{className:"results-tile-card",children:[(0,S.jsxs)("button",{type:"button",className:"results-tile-card__surface",onClick:()=>k(C),"aria-label":`Review match for ${V.label}`,children:[(0,S.jsx)("div",{className:"results-tile-card__media",children:(0,S.jsx)("img",{className:"fill-img results-tile-card__image",src:Qa(X?.description||V.label,X?.product_id,X?.pdp_photo_url),alt:""})}),(0,S.jsxs)("div",{className:"results-tile-card__body",children:[X?(0,S.jsxs)("div",{className:"results-tile-card__heading",children:[(0,S.jsx)("div",{className:"results-tile-card__title",children:X.description}),(0,S.jsxs)("div",{className:"results-tile-card__match-meta",children:[(0,S.jsx)("span",{children:X.product_id}),X.price!=null?(0,S.jsx)("span",{children:pc(X.price,X.price_basis)}):null]})]}):(0,S.jsx)("div",{className:"results-empty-hint",children:"No product matched for this line."}),(0,S.jsxs)("div",{className:"results-tile-card__match",children:[(0,S.jsx)("div",{className:"results-tile-card__match-label",children:"\u21B3 calculated as"}),(0,S.jsx)("div",{className:"results-tile-card__match-name",children:V.label}),(0,S.jsxs)("div",{className:"results-tile-card__meta",children:[_i(V.qty)," ",ka(V.unit,V.qty)]}),me?.requiredSellUnits!=null?(0,S.jsxs)("div",{className:"results-tile-card__meta estimator-products__order",children:["Order ",me.requiredSellUnits," ",me.sellUnit,me.lineTotal!=null?` \xB7 ${nt(me.lineTotal)}`:""]}):X?(0,S.jsx)("div",{className:"results-row-meta",children:"Quantity needs review"}):null]})]})]}),(0,S.jsxs)("div",{className:"results-tile-card__actions",children:[(0,S.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>k(C),children:"Review"}),(0,S.jsx)("button",{type:"button",className:`bom-toolbar-btn${Ce?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>O(C),disabled:!X||!i,children:Ce?"\u2713 Added":"+ Add"})]})]},V.key)})}),!x&&!d&&!w&&D==="list"&&Ht.length>0&&(0,S.jsx)("div",{className:"bom-table-wrap",children:(0,S.jsxs)("table",{className:"bom-table results-table","aria-label":"Matched materials",children:[(0,S.jsxs)("colgroup",{children:[(0,S.jsx)("col",{style:{width:"56px"}}),(0,S.jsx)("col",{className:"col-item"}),(0,S.jsx)("col",{style:{width:"90px"}}),(0,S.jsx)("col",{style:{width:"80px"}}),(0,S.jsx)("col",{style:{width:"220px"}}),(0,S.jsx)("col",{style:{width:"110px"}})]}),(0,S.jsx)("thead",{children:(0,S.jsxs)("tr",{className:"bom-col-header",children:[(0,S.jsx)("th",{"aria-label":"Expand"}),(0,S.jsx)("th",{style:{textAlign:"left"},children:"Description"}),(0,S.jsx)("th",{style:{textAlign:"center"},children:"Qty"}),(0,S.jsx)("th",{style:{textAlign:"center"},children:"Unit"}),(0,S.jsx)("th",{style:{textAlign:"center"},children:"Product Matched"}),(0,S.jsx)("th",{style:{textAlign:"center"},children:"Basket"})]})}),(0,S.jsx)("tbody",{children:Ht.map(C=>{let{requirement:V,chosen:X}=C,me=X?ua(Me(C),Od):null,Ce=i?!!i.cart[se(V.key)]:!1,dt=Te.has(V.key);return(0,S.jsxs)(Le.Fragment,{children:[(0,S.jsxs)("tr",{className:"bom-row",children:[(0,S.jsx)("td",{className:"bom-actions",style:{textAlign:"center",paddingLeft:0,paddingRight:0},children:(0,S.jsx)("button",{type:"button",className:"link-btn",onClick:()=>ne(V.key),"aria-expanded":dt,"aria-label":dt?"Collapse product options":"Expand product options",children:dt?"\u25BE":"\u25B8"})}),(0,S.jsxs)("td",{style:{paddingLeft:0},children:[(0,S.jsx)("div",{className:"bom-component-name",children:V.label}),me?.requiredSellUnits!=null&&(0,S.jsxs)("div",{className:"results-row-meta",children:["Order ",me.requiredSellUnits," ",me.sellUnit,me.lineTotal!=null?` \xB7 ${nt(me.lineTotal)}`:""]})]}),(0,S.jsx)("td",{className:"bom-qty col-order",style:{textAlign:"center"},children:_i(V.qty)}),(0,S.jsx)("td",{style:{textAlign:"center"},children:ka(V.unit,V.qty)}),(0,S.jsx)("td",{style:{textAlign:"center"},children:X?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("div",{className:"bom-component-name",children:X.description}),(0,S.jsxs)("div",{className:"results-row-meta",children:[X.product_id,X.price!=null&&` \xB7 ${pc(X.price,X.price_basis)}`]})]}):(0,S.jsx)("span",{className:"results-empty-hint",children:"No match"})}),(0,S.jsx)("td",{style:{textAlign:"center"},children:(0,S.jsx)("button",{type:"button",className:`bom-toolbar-btn${Ce?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>O(C),disabled:!X||!i,children:Ce?"\u2713 Added":"+ Add"})})]}),dt&&(0,S.jsx)("tr",{children:(0,S.jsx)("td",{colSpan:6,style:{paddingLeft:0,paddingRight:0},children:A===V.key?W(C):(0,S.jsxs)("div",{className:"estimator-products__picker",children:[(0,S.jsxs)("div",{className:"estimator-products__options",children:[C.candidates.map(je=>(0,S.jsxs)("button",{type:"button",className:`estimator-products__option${je.product_id===X?.product_id?" is-selected":""}`,onClick:()=>ve(V.key,je),children:[(0,S.jsx)("span",{children:je.description}),(0,S.jsxs)("span",{className:"results-row-meta",children:[je.product_id,je.price!=null&&` \xB7 ${nt(je.price)}`]})]},je.product_id)),C.candidates.length===0&&(0,S.jsx)("p",{className:"results-empty-hint",children:"No candidates found."})]}),(0,S.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>ue(C),children:"Search the catalogue"})]})})})]},V.key)})})]})}),!x&&!d&&!w&&Tt.length>0&&(0,S.jsxs)("section",{className:"results-tile-section results-tile-section--unmatched","aria-label":"Items requiring matching",children:[(0,S.jsxs)("div",{className:"results-tile-section__head",children:[(0,S.jsx)("h3",{children:"Require Matching"}),(0,S.jsx)("p",{children:"We couldn\u2019t confidently match these to a product. Open one to pick from the closest options."})]}),(0,S.jsx)("div",{className:"results-unmatched-list",children:Tt.map(C=>(0,S.jsxs)("button",{type:"button",className:"results-unmatched-card",onClick:()=>k(C),children:[(0,S.jsxs)("span",{className:"results-unmatched-card__main",children:[(0,S.jsx)("span",{className:"results-unmatched-card__title",children:C.requirement.label}),(0,S.jsxs)("span",{className:"results-row-meta",children:[_i(C.requirement.qty)," ",ka(C.requirement.unit,C.requirement.qty)]})]}),(0,S.jsx)("span",{className:"bom-toolbar-btn results-unmatched-card__prompt",children:"Review"})]},C.requirement.key))})]}),!d&&!w&&f.length>0&&(0,S.jsxs)("div",{className:"disclaimer-box",style:{alignItems:"center"},children:[(0,S.jsx)("span",{className:"disclaimer-icon",children:"\u26A0\uFE0F"}),(0,S.jsx)("p",{className:"disclaimer-text",children:"These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence."})]}),!x&&!d&&!w&&(r||E>0)&&(0,S.jsxs)("div",{className:"btn-row estimator-products__footer",children:[r&&(0,S.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:r,children:"Back"}),E>0&&i&&(0,S.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:r?"0 1 70%":1,marginTop:0},onClick:i.openBasket,children:[(0,S.jsxs)("span",{children:["View Basket (",E,")"]}),(0,S.jsx)("span",{className:"arrow",children:(0,S.jsx)(Ot,{})})]})]})]})}var Lt=Y(ae());function Hd({toolId:e,toolTitle:t,requirements:a,onBack:r}){let[n,i]=(0,dc.useState)(0),o=(0,dc.useCallback)(l=>i(l),[]);return(0,Lt.jsx)(Lt.Fragment,{children:(0,Lt.jsxs)("div",{className:"truss-estimator",children:[(0,Lt.jsxs)("div",{className:"quick-order-hero",children:[(0,Lt.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Lt.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,Lt.jsx)("h1",{children:"Your Materials"}),n>0&&(0,Lt.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,Lt.jsx)("strong",{children:nt(n)})," Est. total"]})]}),(0,Lt.jsxs)("p",{children:["Quantities from the ",t,", matched against your merchant\u2019s catalogue."]})]}),(0,Lt.jsx)("div",{className:"truss-estimator__card",style:{minHeight:0},children:(0,Lt.jsx)(Ld,{toolId:e,requirements:a,ready:!0,onBack:r,onTotalChange:o})})]})})}var K_=(e,t)=>{let a=t.key,r={"brick-block":{"brick-common":"5001444","brick-engineering-red":"5002008","brick-engineering-blue":"5001439",block:"5003187",mortar:"6003088"},skirting:{"skirting-chamfered":"4006057","skirting-ogee":"4006045","skirting-pencil-round":"4006048","skirting-torus":"4006042"},architrave:{"architrave-ogee":"4006060","architrave-ovolo":"4006063","architrave-pencil-round":"4006061","architrave-square-edge":"4006062","architrave-torus":"4006059"},plasterboard:{board:"2001035",screws:"2006040",tape:"2007043",adhesive:"2004023"},insulation:{"insulation-floor":"3002110","insulation-wall":"3002012","insulation-roof":"3004047","insulation-loft":"3003046"},timber:{studs:"4001168",joists:"4001201",battens:"4001053"},fencing:{"panels-boundary-0.9":"4001268","panels-boundary-1.2":"4001269","panels-boundary-1.5":"4001270","panels-boundary-1.8":"4001271","panels-skyline-0.9":"4001264","panels-skyline-1.2":"4001265","panels-skyline-1.5":"4001266","panels-skyline-1.8":"4001267","concrete-intermediate-6":"4001290","concrete-intermediate-8":"4001291","concrete-end-6":"4001294","concrete-end-8":"4001295","timber-post-6":"4001242","timber-post-8":"4001243",postcrete:"6003008",gate:"4001630","gravel-boards":"4001284"},decking:{"boards-meridian":"4001251","boards-summit":"4001360",joists:"4001201",screws:"1001103"},paving:{"surface-council":"7003121","surface-raj":"7003003","surface-brindle":"4001621","surface-charcoal":"4001622","surface-pea":"6001004","sub-base":"6001007",bedding:"6001012"}};return e==="plasterboard"?{standard:"2001035",moisture:"2002039",fire:"2002087",sound:"2002044"}[t.label.split(" ")[0].toLowerCase()]??r[e]?.[a]??null:r[e]?.[a]??null};function Sw(e,t){if(e==="paint"||e==="concrete-aggregate")return null;let a=t.map(r=>{let n=K_(e,r);return n?{key:r.key,productId:n,qty:r.qty,unit:r.unit}:null});return a.every(Boolean)?a:null}var jd=Y(Xe());var Pt=Y(ae()),P_=1500;function Cw(e){let{addManyToCart:t,clearCart:a,openBasket:r}=An(),[n,i]=(0,jd.useState)(!1),[o,l]=(0,jd.useState)(null);return{adding:n,basketError:o,addToBasket:async(p,f)=>{let b=Date.now();i(!0),l(null);try{let d=await Promise.all(p.filter(w=>w.qty>0).map(async w=>{let M=(await Jr(w.productId)).find(D=>D.product_id===w.productId);if(!M)throw new Error("A selected product is no longer available in this catalogue.");return Kr(M,{lineId:`${e}:${w.key}`,description:M.description,unit:w.unit??"each",qty:w.qty,calculatorWasteIncluded:f})})),h=P_-(Date.now()-b);h>0&&await new Promise(w=>window.setTimeout(w,h)),a(),t(d),r()}catch(d){l(d instanceof Error?d.message:"Could not add the products to your basket.")}finally{i(!1)}}}}function qw({toolTitle:e}){return(0,Pt.jsx)(Pt.Fragment,{children:(0,Pt.jsxs)("div",{className:"truss-estimator",children:[(0,Pt.jsxs)("div",{className:"quick-order-hero",children:[(0,Pt.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Pt.jsx)("h1",{children:"Your Materials"}),(0,Pt.jsxs)("p",{children:["Calculating quantities from the ",e,"."]})]}),(0,Pt.jsx)("div",{className:"truss-estimator__card",children:(0,Pt.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{flex:1,justifyContent:"center"},children:[(0,Pt.jsx)(dr,{}),(0,Pt.jsx)("p",{className:"banter-message is-visible",children:"Preparing your materials\u2026"})]})})]})})}var Re=Y(ae());function mc(e){let[t,a]=(0,Va.useState)(!1);return(0,Re.jsx)(Ps,{onOpenBasket:()=>a(!0),children:(0,Re.jsx)(J_,{...e,showBasket:t,onShowBasket:a})})}function J_({fullPage:e=!1,hideHeader:t=!1,internal:a=!1,showBasket:r,onShowBasket:n}){let[i,o]=(0,Va.useState)(null),[l,c]=(0,Va.useState)(null),p=Bd.find(z=>z.id===i),{cart:f,updateCartQty:b,updateCartSellUnits:d,updateCartConversions:h,removeFromCart:w,clearCart:M}=An(),{adding:D,basketError:m,addToBasket:u}=Cw(p?.title??"calculator"),g=(0,Va.useRef)(null),v=Gs("estimating-tools",g);(0,Va.useEffect)(()=>{v("viewed")},[v]);let N=r?"basket":D?"adding":l?"review":i??"list",A=(0,Va.useRef)(N);(0,Va.useEffect)(()=>{A.current!==N&&(A.current=N,window.scrollTo(0,0))},[N]);let T=z=>{if(!p)return;v("estimate_completed",{calculator:p.id,lines:z.length});let G=Sw(p.id,z);G?u(G,z[0]?.calculatorWasteIncluded??!1):c(z)};return(0,Re.jsx)(Zo.Provider,{value:v,children:(0,Re.jsx)("div",{ref:g,className:`app-wrapper${e?"":" app-wrapper--embedded"}${t?" app-wrapper--no-header":""}`,style:pr().theme,children:(0,Re.jsx)("main",{className:"main-content",children:r?(0,Re.jsx)(rl,{cart:f,onUpdateQty:b,onUpdateSellUnits:d,onResolveConversions:h,onRemove:w,onBack:()=>n(!1),onStartNewQuote:()=>{M(),o(null),c(null),n(!1)},internal:a}):D&&p?(0,Re.jsx)(qw,{toolTitle:p.title}):p?(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)("div",{hidden:l!==null,children:(0,Re.jsx)(p.Component,{onBack:()=>o(null),onReview:T})}),m&&(0,Re.jsx)("p",{className:"results-empty-hint estimator-products__error",children:m}),l!==null&&(0,Re.jsx)(Hd,{toolId:p.id,toolTitle:p.title,requirements:l,onBack:()=>c(null)})]}):(0,Re.jsx)(Re.Fragment,{children:(0,Re.jsxs)("div",{className:"quick-order-card",children:[(0,Re.jsxs)("div",{className:"quick-order-hero",children:[(0,Re.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,Re.jsx)("h1",{children:"Estimating Tools"}),(0,Re.jsx)("p",{children:"Trade-specific calculators for trusses, fencing, decking, masonry and painting. Dial in your specs and get an instant material estimate."})]}),(0,Re.jsxs)("div",{className:"quick-order-alt",children:[(0,Re.jsx)("div",{className:"quick-order-alt-title",children:"Choose a Calculator"}),(0,Re.jsx)("div",{className:"estimator-tools-grid",children:Bd.map(z=>(0,Re.jsxs)("button",{type:"button",className:"estimator-tool-card",onClick:()=>{v("calculator_selected",{calculator:z.id}),o(z.id),c(null)},children:[(0,Re.jsx)("span",{className:"estimator-tool-card__image-wrap",children:(0,Re.jsx)("img",{className:"fill-img estimator-tool-card__image",src:Kt(z.imageUrl),alt:""})}),(0,Re.jsxs)("span",{className:"estimator-tool-card__content",children:[(0,Re.jsx)("span",{className:"estimator-tool-card__title",children:z.title}),(0,Re.jsx)("span",{className:"estimator-tool-card__desc",children:z.desc})]})]},z.id))})]})]})})})})})}var fc=Y(ae());function Gd({config:e,children:t}){return $b(e),(0,fc.jsx)(fc.Fragment,{children:t})}var Qd=Y(ae()),F_="https://api.metronlabs.ai",I_=["client","api-key","api-url","theme","hide-header","analytics"],W_=["all","events-only","none"];function Mw(e,t){var a;customElements.get(e)||customElements.define(e,(a=class extends HTMLElement{constructor(){super();this.root=null;this.attachShadow({mode:"open"})}connectedCallback(){if(this.dataset.version="0.1.27",!this.root){let n=document.createElement("div"),i=document.createElement("style");i.textContent=`:host { display: block; }
|
|
6798
|
+
`)}function Kr(e,t){return{lineId:t.lineId,description:e?.description||t.description||"(no description)",requestedDescription:t.description,productId:e?.product_id??"-",price:e?.price??null,priceBasis:e?.price_basis??null,unit:t.unit,uoi:e?.uoi??t.unit,uoiCount:e?.uoi_count??null,saleUnit:e?.conversion?.sale_unit??null,saleUnitQuantity:e?.conversion?.sale_unit_quantity??null,unitConversions:e?.conversion?.unit_conversions?.map(a=>({requestUom:a.request_uom,quantityPerSaleUnit:a.quantity_per_sale_unit,evidence:a.evidence,confidence:a.confidence})),pdpPhotoUrl:e?.pdp_photo_url??null,measurementsMm:e?.measurements_mm??[],conversionType:e?.conversion?.conversion_type??null,requestUomsSupported:e?.conversion?.request_uoms_supported??null,salesUomNormalised:e?.conversion?.sales_uom_normalised??null,salesUnitSize:e?.conversion?.sales_unit_size??null,salesUnitSizeUom:e?.conversion?.sales_unit_size_uom??null,coverageQty:e?.conversion?.coverage_qty??null,coverageUom:e?.conversion?.coverage_uom??null,itemsPerPallet:e?.conversion?.items_per_pallet??null,itemsPerPack:e?.conversion?.items_per_pack??null,itemsPerBox:e?.conversion?.items_per_box??null,itemsPerM2:e?.conversion?.items_per_m2??null,wasteFactorDefault:e?.conversion?.waste_factor_default??null,roundingRule:e?.conversion?.rounding_rule??null,derivedCoverageM2:e?.conversion?.derived_coverage_m2??null,derivedLengthM:e?.conversion?.derived_length_m??null,quoteQtyFormulaType:e?.conversion?.quote_qty_formula_type??null,conversionConfidence:e?.conversion?.conversion_confidence??null,conversionNotes:e?.conversion?.conversion_notes??null,calculatorWasteIncluded:t.calculatorWasteIncluded,qty:t.qty}}var Pv=e=>(e??"").trim().toLowerCase(),Z1={sqm:"m2","sq m":"m2","m\xB2":"m2",cbm:"m3","cu m":"m3",lm:"m","lin m":"m",metre:"m",meter:"m",each:"each",ea:"each",nr:"each",no:"each",item:"each",unit:"each",units:"each",pc:"each",pcs:"each",board:"sheet",bags:"bag",length:"length",lengths:"length",pallet:"pallet",pallets:"pallet"},K1=new Set(["sheet","length","box","bag","pack","roll","set","tub","each"]),Xv=new Set(["box","bag","pack","pallet","roll","set","tub"]),$v=(e,t)=>t==="ml"?e:["l","litre","litres"].includes(t)?e*1e3:null,Zv=(e,t)=>t==="g"?e:["kg","kilogram","kilograms"].includes(t)?e*1e3:["t","tonne","tonnes"].includes(t)?e*1e6:null,xi=e=>{let t=Pv(e);return Z1[t]??t},st=(e,t)=>{let a=xi(e),r=xi(t);return a.length>0&&a===r},P1=(e,t)=>{let a=Pv(t);return a?a.includes("round_up_1000")?Math.ceil(e):a.includes("allow_decimal")?Math.round(e*1e3)/1e3:a.includes("round_up")?Math.ceil(e):e:e},J1=e=>(e??"").split(",").map(t=>xi(t)).filter(Boolean),F1=(e,t)=>{let a=J1(e.requestUomsSupported);return!!(a.length===0||a.includes(t)||st(t,"pallet")&&e.itemsPerPallet!=null&&e.itemsPerPallet>0||st(t,"pack")&&e.itemsPerPack!=null&&e.itemsPerPack>0||st(t,"box")&&e.itemsPerBox!=null&&e.itemsPerBox>0)},Kv=(e,t)=>st(t,"pallet")?e.itemsPerPallet??null:st(t,"pack")?e.itemsPerPack??null:st(t,"box")?e.itemsPerBox??null:null,I1=(e,t,a)=>{if(!st(t,"m2"))return null;let r=e.description.match(/(\d+(?:[.,]\d+)?)\s*(m2|m²|sqm|sq\.?\s*m)\s*(?:\/|per)\s*([a-z]+)/i);if(!r||!st(r[3],a))return null;let n=Number.parseFloat(r[1].replace(",","."));return Number.isFinite(n)&&n>0?n:null};function ua(e,t){let a=e.qty,r=xi(e.unit)||"-",n=xi(e.saleUnit??e.salesUnitSizeUom??e.uoi??e.salesUomNormalised)||"-",i=e.saleUnitQuantity??e.salesUnitSize??e.uoiCount??1,o=t?.wasteFactorEnabled===!1?0:t?.wasteFactorOverride??e.wasteFactorOverride??e.wasteFactorDefault??0,l=e.sellUnitsOverride!=null&&Number.isFinite(e.sellUnitsOverride)&&e.sellUnitsOverride>0,c=l?e.sellUnitsOverride??null:null,p=v=>({requestedAmount:a,requestedUnit:r,salesUnitSize:e.salesUnitSize??e.uoiCount??null,sellUnit:n,calculatedSellUnits:null,requiredSellUnits:c,unitPrice:e.price,lineTotal:e.price!=null&&c!=null?e.price*c:null,calculation:c!=null?`${v} Manually set to ${c} ${n}.`:v,costingMode:"review"});if(!F1(e,r))return p("Requested unit is not supported by this catalogue conversion.");let f=null,b="review",d=e.roundingRule,h=`Quantity review required, initial request needed ${a} ${r}.`,w=1+o,M=I1(e,r,n),D=e.unitConversions?.find(v=>st(v.requestUom,r));if(!!e.saleUnit&&(st(r,n)||!!D||st(r,"each")&&!Xv.has(n)))if(st(r,n))f=a*w/i,b="direct",h=`${a} ${r}${o>0?` x ${w}`:""}`;else if(D){f=a*w/D.quantityPerSaleUnit,b="derived";let v=1/D.quantityPerSaleUnit,N=Math.round(v);h=st(n,"each")&&D.quantityPerSaleUnit<1&&Math.abs(v-N)<1e-9?`${a} ${r}${o>0?` x ${w}`:""} x ${N} per ${r}`:`${a} ${r}${o>0?` x ${w}`:""} / ${D.quantityPerSaleUnit} ${r} per ${n}`}else st(r,"each")&&!Xv.has(n)&&(f=a*w/i,b="derived",h=`${a} ${n}${o>0?` x ${w}`:""}`);else if(st(r,n)&&i>0)f=a*w/i,b="direct",h=o>0?`${a} ${r} x ${w} / ${i} ${n} per sell unit`:`${a} ${r} / ${i} ${n} per sell unit`;else if(st(r,"each")&&i>0&&K1.has(n))f=a*w/i,b="derived",h=o>0?`${a} each x ${w} / ${i} each per ${n}`:`${a} each / ${i} each per ${n}`;else if(Kv(e,r)!=null&&i>0){let v=Kv(e,r)??0;f=a*v*w/i,b="derived";let N=`${a} ${r} x ${v} each${o>0?` x ${w}`:""}`;h=i===1&&st(n,"each")?N:`${N} / ${i} each per ${n}`}else if(M!=null)f=a*w/M,b="derived",d??(d="round_up_each"),h=`${a} m2 x ${w} / ${M} m2 per ${n} (from product description)`;else if(e.conversionType==="basket_line_unit")i>0&&(f=a*w/i,b="derived",h=`${a} ${r}${o>0?` x ${w}`:""} / ${i} ${r} per ${n}`);else{if(e.conversionType==="count_only")return p(`Quantity review required, initial request needed ${a} ${r}.`);if(["area_from_dims","explicit_coverage_area","roll_area"].includes(e.conversionType??"")){let v=e.coverageQty??e.derivedCoverageM2??null;st(r,"m2")&&v!=null&&v>0&&(f=a*w/v,b="derived",h=`${a} m2 x ${w} / ${v} m2 per ${n}`)}else if(e.conversionType==="count_per_area"){let v=e.coverageQty??null;st(r,"m2")&&v!=null&&v>0?(f=a/v,b="derived",h=`${a} m2 / ${v} m2 per sell unit`):st(r,"m2")&&e.itemsPerM2!=null&&e.itemsPerM2>0&&i>0&&(f=a*e.itemsPerM2*w/i,b="derived",h=`${a} m2 x ${e.itemsPerM2} ${n}/m2 x ${w} / ${i}`)}else if(e.conversionType==="length_from_dims"){let v=e.coverageQty??e.derivedLengthM??null;st(r,"m")&&v!=null&&v>0&&(f=a*w/v,b="derived",h=`${a} m x ${w} / ${v} m per ${n}`)}else if(e.conversionType==="volume_from_description"){let v=$v(a,r),N=$v(e.coverageQty??0,xi(e.coverageUom));v!=null&&N!=null&&N>0&&(f=v*w/N,b="derived",h=`${a} ${r} x ${w} / ${e.coverageQty} ${e.coverageUom} per ${n}`)}else if(e.conversionType==="weight_from_description"){let v=Zv(a,r),N=Zv(e.coverageQty??0,xi(e.coverageUom));v!=null&&N!=null&&N>0&&(f=v*w/N,b="derived",h=`${a} ${r} x ${w} / ${e.coverageQty} ${e.coverageUom} per ${n}`)}else if(e.conversionType==="same_unit_volume"){let v=e.coverageQty??null;st(r,"m3")&&v!=null&&v>0&&(f=a/v,b="derived",h=`${a} m3 / ${v} m3 per ${n}`)}}if(f==null||!Number.isFinite(f)||f<0)return p(`Quantity review required, initial request needed ${a} ${r}.`);let u=P1(f,d),g=l?e.sellUnitsOverride??null:u;return{requestedAmount:a,requestedUnit:r,salesUnitSize:i,sellUnit:n,calculatedSellUnits:u,requiredSellUnits:g,unitPrice:e.price,lineTotal:e.price!=null&&g!=null?e.price*g:null,calculation:l?`${h} = ${u} ${n} (manually set to ${g})`:`${h} = ${g} ${n}`,costingMode:b}}var Jv=()=>import("./xlsx-K4MOA2QM.js"),Wo=["Source Line ID","Split Line ID","Description","Section","Qty","Unit","Procurement intent","Procurement aliases","Build-up type","Layer count","Total thickness (mm)","Installation clues","System clues","Component requirements","Technical classification","Include in quote","Approval required","Approval type","Missing information","Adjudicator confidence","Decision reason","Selected candidate ID","Selected candidate description","Price basis","Price","Line total","Confidence","Status"],W1=Wo.indexOf("Line total");function e_(e){return e.unmatchable?"Not matched (labour/plant/referential)":e.decision?.include_in_quote===!0&&e.decision.approval_required===!0?"Approval required":e.decision?.include_in_quote===!0?"Quoted":e.decision?.technical_classification==="no_suitable_candidate"?"No suitable candidate":(e.best,"No match")}async function Fv(e){let t=await Jv(),a=t.utils.book_new(),r=new Date().toISOString().slice(0,10),n=[Wo],i=0;for(let c of e){let{item:p,best:f,qty:b,band:d,unmatchable:h,decision:w}=c,M=[p.section,p.subsection,p.subheading].filter(Boolean).join(" / "),D=!h&&f?.price!=null?f.price*b:null;D!=null&&(i+=D),n.push([p.source_line_id,p.line_id,p.description_original||"(no description)",M,b,p.unit,p.procurement_intent||"-",p.procurement_aliases.join(", "),p.build_up_type,p.layer_count,p.total_required_thickness_mm,p.installation_clues.join(", "),p.system_clues.join(", "),p.component_requirements.join(", "),w?.technical_classification??"",w?.include_in_quote==null?"":w.include_in_quote?"yes":"no",w?.approval_required==null?"":w.approval_required?"yes":"no",w?.approval_type??"",w?.missing_information.join(", ")??"",w?.confidence??"",w?.reason??"",h?"-":f?.product_id??w?.selected_candidate_id??"-",h?"-":f?.description??"-",h?"-":f?.price_basis??"-",h?null:f?.price??null,D,h?"-":d,e_(c)])}n.push(Array(Wo.length).fill(null));let o=Array(Wo.length).fill(null);o[0]="Estimated total",o[W1]=i,n.push(o),n.push(["DISCLAIMER: These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence.",...Array(Wo.length-1).fill(null)]);let l=t.utils.aoa_to_sheet(n);l["!cols"]=[{wch:12},{wch:12},{wch:44},{wch:24},{wch:8},{wch:8},{wch:28},{wch:28},{wch:16},{wch:10},{wch:12},{wch:24},{wch:24},{wch:24},{wch:22},{wch:14},{wch:14},{wch:18},{wch:24},{wch:16},{wch:48},{wch:16},{wch:40},{wch:10},{wch:10},{wch:12},{wch:11},{wch:26}],t.utils.book_append_sheet(a,l,"Schedule match"),t.writeFile(a,`schedule-quote-${r}.xlsx`)}var Io=["Product ID","Description","Costing mode","Required amount","Req unit","Sell unit size","Sell unit","Required sell units","Unit price","Line total"];async function Iv(e,t){let a=await Jv(),r=a.utils.book_new(),n=new Date().toISOString().slice(0,10),i=t?[["Account",t.name+" ("+t.id+")"],[],Io]:[Io],o=0;for(let p of e){let f=ua(p),b=f.lineTotal;b!=null&&(o+=b),i.push([p.productId,p.description,f.costingMode,f.requestedAmount,xa(f.requestedUnit),f.salesUnitSize,xa(f.sellUnit),f.requiredSellUnits,f.unitPrice,b])}i.push(Array(Io.length).fill(null));let l=Array(Io.length).fill(null);l[0]="Estimated total",l[Io.length-1]=o,i.push(l);let c=a.utils.aoa_to_sheet(i);c["!cols"]=[{wch:14},{wch:48},{wch:12},{wch:14},{wch:10},{wch:14},{wch:10},{wch:16},{wch:12},{wch:14}],a.utils.book_append_sheet(r,c,"Basket"),a.writeFile(r,t?`basket-${t.id}-${n}.xlsx`:`basket-${n}.xlsx`)}var s=Y(ae()),fd="__none__",el=24,t_=[{dir:"asc",label:"Description (A-Z)"},{dir:"desc",label:"Description (Z-A)"}];function aw(e){return e==null?"low":e>=.7?"high":e>=.5?"medium":"low"}var a_=e=>e.attrs.supply_nature==="labour_only"||e.attrs.supply_nature==="plant"||e.flags.includes("referential");function r_(e,t){if(t!==fd){if(t)return e?.candidates.find(a=>a.product_id===t);if(e?.decision?.selected_candidate_id!=null)return e.candidates.find(a=>a.product_id===e.decision.selected_candidate_id)}}function Wv(e){return{product_id:e.productId,description:e.description,source_list:null,price:e.price,price_basis:e.priceBasis,uoi_count:e.uoiCount??null,uoi:e.uoi,pdp_photo_url:e.pdpPhotoUrl??null,measurements_mm:e.measurementsMm??[],conversion:{sale_unit:e.saleUnit,sale_unit_quantity:e.saleUnitQuantity,unit_conversions:e.unitConversions?.map(t=>({request_uom:t.requestUom,quantity_per_sale_unit:t.quantityPerSaleUnit,evidence:t.evidence,confidence:t.confidence})),sales_uom_normalised:e.salesUomNormalised,conversion_type:e.conversionType,request_uoms_supported:e.requestUomsSupported,sales_unit_size:e.salesUnitSize,sales_unit_size_uom:e.salesUnitSizeUom,coverage_qty:e.coverageQty,coverage_uom:e.coverageUom,items_per_pallet:e.itemsPerPallet,items_per_pack:e.itemsPerPack,items_per_box:e.itemsPerBox,items_per_m2:e.itemsPerM2,waste_factor_default:e.wasteFactorDefault,rounding_rule:e.roundingRule,derived_coverage_m2:e.derivedCoverageM2,derived_length_m:e.derivedLengthM,quote_qty_formula_type:e.quoteQtyFormulaType,conversion_confidence:e.conversionConfidence,conversion_notes:e.conversionNotes},scores:{dimension:0,grade:0,brand:0,fuzzy:0,bm25:0,overall:0},method:"manual_cart_selection"}}function i_(e,t){let a={...e,qty:t.qty,sellUnitsOverride:t.sellUnitsOverride??null};return t.productId!==e.productId||t.conversionType!=="basket_line_unit"?a:{...a,saleUnit:t.saleUnit,saleUnitQuantity:t.saleUnitQuantity,unitConversions:t.unitConversions,conversionType:t.conversionType,requestUomsSupported:t.requestUomsSupported,salesUomNormalised:t.salesUomNormalised,salesUnitSize:t.salesUnitSize,salesUnitSizeUom:t.salesUnitSizeUom,coverageQty:t.coverageQty,coverageUom:t.coverageUom,itemsPerPallet:t.itemsPerPallet,itemsPerPack:t.itemsPerPack,itemsPerBox:t.itemsPerBox,itemsPerM2:t.itemsPerM2,wasteFactorDefault:t.wasteFactorDefault,roundingRule:t.roundingRule,derivedCoverageM2:t.derivedCoverageM2,derivedLengthM:t.derivedLengthM,quoteQtyFormulaType:t.quoteQtyFormulaType,conversionConfidence:t.conversionConfidence,conversionNotes:t.conversionNotes}}function n_(e){return e?e.replace(/_/g," "):"not stated"}function o_({band:e}){return(0,s.jsx)("span",{className:`status-dot status-dot--${e}`,title:e,children:(0,s.jsx)("span",{className:"status-dot__mark"})})}function Tn(e,t){if(e==null)return"-";let a=Fo(t);return a?`${e.toFixed(2)} ${a}`:e.toFixed(2)}function gd(e){return e&&e.length>0?e.join(" x "):"-"}function l_(e){return e==null?"-":Number.isInteger(e/1e3)?`${e/1e3}m`:`${(e/1e3).toFixed(1)}m`}function Mn(e){let t=(e??[]).map(a=>a.trim()).filter(Boolean);return t.length>0?t.join(", "):"-"}function Pr(e,t){return e.customer_display_label?.trim()||e.description_original||"(no description)"}var ew=[{background:"#fff7ed",borderColor:"#fdba74",color:"#9a3412"},{background:"#eff6ff",borderColor:"#93c5fd",color:"#1d4ed8"},{background:"#ecfeff",borderColor:"#67e8f9",color:"#0f766e"},{background:"#f0fdf4",borderColor:"#86efac",color:"#166534"},{background:"#fdf4ff",borderColor:"#f0abfc",color:"#a21caf"}];function s_(e){let t=new Map;return[...new Set(e.filter(mr).map(r=>r.linked_group_id))].forEach((r,n)=>{let i=n%26;t.set(r,{token:String.fromCharCode(65+i),bubbleStyle:ew[n%ew.length]})}),t}function mr(e){return!1}function zn(e){if(!e.linked_group_id)return null;let t=e.linked_group_label||"Linked group",a=e.linked_group_role==="anchor"?"anchor":e.linked_group_role==="dependent"?"dependent":"member",r=e.linked_group_shared_width_mm!=null?`, ${e.linked_group_shared_width_mm}mm family`:"";return`${t} (${a}${r})`}function md({meta:e}){return e?(0,s.jsx)("span",{className:"results-linked-pill",style:e.bubbleStyle,children:`Link ${e.token}`}):null}function c_(e,t,a){let r=t?.rerank?.recommendedCandidateIds??[];if(r.length===0){let o=e.slice(0,5),l=o.some(c=>c.product_id===a)?void 0:e.find(c=>c.product_id===a);return l?[...o,l]:o}let n=new Map(e.map(o=>[o.product_id,o])),i=r.map(o=>n.get(o)).filter(o=>o!=null);if(a&&!i.some(o=>o.product_id===a)){let o=n.get(a);o&&i.unshift(o)}return[...new Map(i.map(o=>[o.product_id,o])).values()].slice(0,5)}function Zs(e){let t=e?.rerank?.recommendedCandidateIds??[];if(t.length===0||!e)return[];let a=new Map(e.candidates.map(r=>[r.product_id,r]));return t.map(r=>a.get(r)).filter(r=>r!=null)}function Ks(e){if(e>=6e4){let t=Math.floor(e/6e4),a=Math.round(e%6e4/1e3);return a===60?`${t+1}m`:`${t}m ${a}s`}return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}s`:`${e}ms`}function u_({processStages:e,llmCalls:t,totalDurationMs:a,llmDurationMs:r,llmCallCount:n}){let i=[...t].sort((l,c)=>c.durationMs-l.durationMs).slice(0,12),o=Math.max(0,t.length-i.length);return(0,s.jsxs)("div",{className:"results-detail-block",style:{marginBottom:18},children:[(0,s.jsx)("h3",{style:{margin:"0 0 12px"},children:"Pipeline timings"}),(0,s.jsxs)("div",{className:"results-summary",style:{marginBottom:12},children:[(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:Ks(a)})," total"]}),(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:n})," LLM calls"]}),(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:Ks(r)})," LLM time"]})]}),(0,s.jsxs)("table",{className:"score-breakdown-table",style:{marginBottom:14},children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Process stage"}),(0,s.jsx)("th",{children:"Duration"})]})}),(0,s.jsx)("tbody",{children:e.map((l,c)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:l.label}),(0,s.jsx)("td",{children:Ks(l.durationMs)})]},`${l.key}-${c}`))})]}),t.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h4",{style:{margin:"0 0 10px"},children:"LLM calls"}),(0,s.jsxs)("table",{className:"score-breakdown-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Call"}),(0,s.jsx)("th",{children:"Duration"})]})}),(0,s.jsx)("tbody",{children:i.map((l,c)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:l.label}),(0,s.jsx)("td",{children:Ks(l.durationMs)})]},`${l.key}-${c}`))})]}),o>0&&(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Showing slowest ",i.length," of ",t.length," LLM calls."]})]})]})}function p_({queries:e}){return e.length===0?null:(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsx)("h4",{style:{margin:"0 0 12px"},children:"Retrieval by procurement query"}),e.map((t,a)=>(0,s.jsxs)("div",{style:{marginBottom:16},children:[(0,s.jsxs)("div",{className:"results-row-meta",style:{marginBottom:6},children:["Query: ",(0,s.jsx)("strong",{children:t.query})]}),t.candidates.length===0?(0,s.jsx)("p",{className:"results-empty-hint",children:"No candidates returned for this query."}):(0,s.jsxs)("table",{className:"score-breakdown-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Product"}),(0,s.jsx)("th",{children:"Dims (mm)"}),(0,s.jsx)("th",{children:"Unit"}),(0,s.jsx)("th",{children:"bm25"})]})}),(0,s.jsx)("tbody",{children:t.candidates.slice(0,5).map((r,n)=>(0,s.jsxs)("tr",{children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("div",{children:r.description}),(0,s.jsx)("div",{className:"results-row-meta",children:r.product_id})]}),(0,s.jsx)("td",{children:gd(r.measurements_mm)}),(0,s.jsx)("td",{children:Fo(r.price_basis)||"-"}),(0,s.jsx)("td",{children:r.bm25.toFixed(2)})]},`${r.product_id}-${n}`))})]})]},`${t.query}-${a}`))]})}function tw({item:e,result:t}){let a=t?.retrieval_debug.map(n=>n.query).filter(Boolean)??[],r=[["Procurement intent",e.procurement_intent||"-"],["Procurement aliases",Mn(e.procurement_aliases)],["Retrieval queries",Mn(a)],["Category",e.attrs.category||"-"],["Fine category",e.attrs.category_fine||"-"],["Brand",e.attrs.brand||"-"],["Material",e.attrs.material||"-"],["Grade / standard",e.attrs.grade_standard||"-"],["Treatment",e.attrs.treatment||"-"],["Supply nature",e.attrs.supply_nature||"-"],["Measurements (mm)",gd(e.attrs.measurements_mm)],["Stock length",l_(e.attrs.stock_length_mm)],["Matching mode",e.matching_mode||"-"],["Build-up type",e.build_up_type||"-"],["Layer count",e.layer_count!=null?String(e.layer_count):"-"],["Required thickness (mm)",e.total_required_thickness_mm!=null?String(e.total_required_thickness_mm):"-"],["Allowed layer thicknesses (mm)",e.acceptable_layer_thicknesses_mm.length>0?e.acceptable_layer_thicknesses_mm.join(", "):"-"],["Installation clues",Mn(e.installation_clues)],["System clues",Mn(e.system_clues)],["Component requirements",Mn(e.component_requirements)],["Linked group",zn(e)||"-"],["Flags",Mn(e.flags)]];return(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsx)("h4",{style:{margin:"0 0 12px"},children:"Search context"}),(0,s.jsx)("dl",{className:"results-detail-grid",children:r.map(([n,i])=>(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:n}),(0,s.jsx)("dd",{children:i})]},n))})]})}function d_({item:e}){let t=e.decomposition_debug;return t?(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsx)("h4",{style:{margin:"0 0 12px"},children:"Decomposition"}),(0,s.jsxs)("dl",{className:"results-detail-grid",children:[(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Attempted"}),(0,s.jsx)("dd",{children:t.attempted?"yes":"no"})]}),(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Applied"}),(0,s.jsx)("dd",{children:t.applied?"yes":"no"})]}),(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Returned items"}),(0,s.jsx)("dd",{children:t.returned_item_count??"-"})]}),(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Reason"}),(0,s.jsx)("dd",{children:t.reason||"-"})]}),(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:"Returned intents"}),(0,s.jsx)("dd",{children:t.items.length>0?t.items.map(a=>`${a.intent}${a.inherits_quantity?" (inherits qty)":""}`).join(", "):"-"})]})]})]}):null}function m_({result:e}){let t=e?.adjudication_debug;if(!t)return null;let a=[["Dependent rerank applied",t.dependent_rerank_applied?"yes":"no"],["Linked parent selected product",t.linked_parent_selected_candidate_description||t.linked_parent_selected_candidate_id||"-"],["Dimension reason overridden",t.dimension_reason_overridden?"yes":"no"]];return(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsx)("h4",{style:{margin:"0 0 12px"},children:"Adjudication context"}),(0,s.jsx)("dl",{className:"results-detail-grid",children:a.map(([r,n])=>(0,s.jsxs)(we.Fragment,{children:[(0,s.jsx)("dt",{children:r}),(0,s.jsx)("dd",{children:n})]},r))}),t.rerank_line_item_input?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h5",{style:{margin:"12px 0 8px"},children:"Rerank input"}),(0,s.jsx)("pre",{className:"results-pre",children:JSON.stringify(t.rerank_line_item_input,null,2)})]}):null]})}function f_({item:e,decision:t,result:a,showRetrievalDebug:r,reviewOnly:n=!1,linkedGroupMeta:i}){if(!t)return null;let o=t.technical_classification==="no_suitable_candidate"?"Exact match not found:":`AI review (${t.confidence??"confidence not stated"}):`;return n?t.reason?(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsxs)("p",{className:"basket-calc-text basket-calc-text--review",children:[(0,s.jsx)("strong",{children:o}),"\xA0",t.reason]}),mr(e)?(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Linked context: ",i?`Link ${i.token} - `:"",zn(e)]}):null]}):null:!t.reason&&!r?(0,s.jsx)(tw,{item:e,result:a}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tw,{item:e,result:a}),r&&(0,s.jsx)(d_,{item:e}),r&&(0,s.jsx)(m_,{result:a}),t.reason&&(0,s.jsxs)("div",{className:"results-detail-block",children:[(0,s.jsxs)("p",{className:"basket-calc-text basket-calc-text--review",children:[(0,s.jsx)("strong",{children:o}),"\xA0",t.reason]}),mr(e)?(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Linked context: ",i?`Link ${i.token} - `:"",zn(e)]}):null]}),r&&(0,s.jsx)(p_,{queries:a?.retrieval_debug??[]})]})}function g_({item:e,candidates:t,result:a,decision:r,unmatchable:n,selectedProductId:i,detailMode:o,onPick:l,onClear:c,showAll:p=!1,internal:f=!1,debugEnabled:b=!1,forceReviewNote:d=!1,linkedGroupMeta:h}){let w=f||o==="detailed",M=b&&o==="detailed",D=w||d?(0,s.jsx)(f_,{item:e,decision:r,result:a,showRetrievalDebug:M,reviewOnly:d&&!w,linkedGroupMeta:h}):null;if(n)return(0,s.jsxs)(s.Fragment,{children:[D,(0,s.jsx)("p",{className:"results-empty-hint",children:"Classified as labour/plant or referencing another line item - skipped by design."})]});if(t.length===0)return(0,s.jsxs)(s.Fragment,{children:[D,(0,s.jsx)("p",{className:"results-empty-hint",children:"No candidates were returned for this line item."})]});let m=p||f||o==="detailed"?t:c_(t,a,i);return(0,s.jsxs)(s.Fragment,{children:[D,(0,s.jsxs)("table",{className:"score-breakdown-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Product"}),(0,s.jsx)("th",{children:"Dims (mm)"}),(0,s.jsx)("th",{children:"Price"}),M&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("th",{children:"dimension"}),(0,s.jsx)("th",{children:"grade"}),(0,s.jsx)("th",{children:"brand"}),(0,s.jsx)("th",{children:"fuzzy"}),(0,s.jsx)("th",{children:"bm25"}),(0,s.jsx)("th",{children:"overall"})]}),(0,s.jsx)("th",{"aria-label":"Actions"})]})}),(0,s.jsx)("tbody",{children:m.map((u,g)=>{let v=u.product_id===i;return(0,s.jsxs)("tr",{className:v?"score-breakdown-row--best":"",children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("div",{children:u.description}),(0,s.jsx)("div",{className:"results-row-meta",children:u.product_id})]}),(0,s.jsx)("td",{children:(0,s.jsx)("span",{className:"unit-badge",children:gd(u.measurements_mm??u.debug?.candidate.measurements_mm)})}),(0,s.jsx)("td",{children:Tn(u.price,u.price_basis)}),M&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{children:(u.scores?.dimension??0).toFixed(2)}),(0,s.jsx)("td",{children:(u.scores?.grade??0).toFixed(2)}),(0,s.jsx)("td",{children:(u.scores?.brand??0).toFixed(2)}),(0,s.jsx)("td",{children:(u.scores?.fuzzy??0).toFixed(2)}),(0,s.jsx)("td",{children:(u.scores?.bm25??0).toFixed(2)}),(0,s.jsx)("td",{children:(0,s.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,s.jsx)(o_,{band:aw(u.scores?.overall)}),(0,s.jsx)("span",{className:"results-overall-cell",children:(u.scores?.overall??0).toFixed(2)})]})})]}),(0,s.jsx)("td",{children:(0,s.jsxs)("label",{className:"switch-toggle",title:v?"Currently selected":"Use this candidate",children:[(0,s.jsx)("input",{type:"checkbox",checked:v,onChange:()=>{v?c?.():l(u)},"aria-label":v?`${u.description} selected`:`Use ${u.description}`}),(0,s.jsx)("span",{className:"switch-toggle-track","aria-hidden":"true"})]})})]},`${u.product_id}-${g}`)})})]})]})}function hd({scheduleResult:e,onStartOver:t,cart:a,onAddToCart:r,onRemoveFromCart:n,onGoToBasket:i,cartSeeded:o,onCartSeeded:l,reviewGateComplete:c,onReviewGateComplete:p,internal:f=!1}){let b=!f&&Qs()==="QZA6-MRA4",d=b?"quote":"basket",{results:h,lineItems:w,parseReport:M,timings:D}=e,[m,u]=(0,we.useState)({}),g=Cn(),[v,N]=(0,we.useState)({}),[A,T]=(0,we.useState)({}),[z,G]=(0,we.useState)(""),[K,fe]=(0,we.useState)(null),[Te,Ye]=(0,we.useState)(1),[Ve,it]=(0,we.useState)(!1);(0,we.useEffect)(()=>{it(new URLSearchParams(window.location.search).get("debug")==="1")},[]);let[pe,Q]=(0,we.useState)("simple"),[ce,xe]=(0,we.useState)(f?"list":"tile"),[ye,ee]=(0,we.useState)(!1),[se,Me]=(0,we.useState)(null),[_e,et]=(0,we.useState)(""),[Ht,Tt]=(0,we.useState)([]),[tt,ct]=(0,we.useState)(!1),[He,E]=(0,we.useState)(null),[x,R]=(0,we.useState)(!1),[I,ue]=(0,we.useState)(null),ve=(0,we.useRef)(null),[Se,k]=(0,we.useState)(new Set),[j,O]=(0,we.useState)(new Set),[ne,W]=(0,we.useState)(!1);(0,we.useEffect)(()=>{Ye(1)},[z,K,ce]);let C=new Map(h.map(_=>[_.line_id,_])),V=s_(w),X=w.map(_=>{let L=C.get(_.line_id),ze=L?.decision,zt=a_(_),Ze=m[_.line_id],It=r_(L,Ze),zi=a[_.line_id],Ow=Ze===fd?void 0:v[_.line_id]??(zi&&zi.productId!==It?.product_id?Wv(zi):It),Wd=zt?void 0:Ow,Lw=_.qty??0;return{item:_,result:L,decision:ze,unmatchable:zt,best:Wd,qty:Lw,band:aw(Wd?.scores?.overall)}}),me=0,Ce=0;for(let _ of X)_.unmatchable||_.decision?.include_in_quote!==!0||!_.best||(_.best.price!=null?me+=_.best.price*_.qty:Ce+=1);let dt=_=>!_.unmatchable&&!_.best&&_.decision?.technical_classification!=="no_suitable_candidate"&&Zs(_.result).length>0,je=_=>_.best??Zs(_.result)[0],Ir=X.filter(_=>!_.unmatchable&&!_.best).filter(_=>!j.has(_.item.line_id)),ll=X.filter(_=>j.has(_.item.line_id)),Ea=X;if(z.trim()){let _=z.trim().toLowerCase();Ea=Ea.filter(L=>L.item.description_original?.toLowerCase().includes(_)||je(L)?.description?.toLowerCase().includes(_))}if(K){let _=K==="asc"?1:-1;Ea=[...Ea].sort((L,ze)=>_*(L.item.description_original||"").localeCompare(ze.item.description_original||""))}let hr=Math.max(1,Math.ceil(Ea.length/el)),Jt=Math.min(Te,hr),Ft=Ea.slice((Jt-1)*el,Jt*el),Yd=Ft.filter(_=>!_.unmatchable&&_.best),Vd=Ft.filter(_=>dt(_)),gc=Ft.filter(_=>!_.unmatchable&&(_.best||dt(_))),Xd=Ft.filter(_=>_.unmatchable||!_.best&&!dt(_)),J=se?X.find(_=>_.item.line_id===se)??null:null,Tw=!f&&!c&&!J&&Ir.length>0,Gn=(0,we.useRef)(null),Qn=()=>{let _=ve.current;if(!_)return;let{top:L,left:ze,width:zt,height:Ze}=_.getBoundingClientRect(),zi=_.querySelector(".bom-toolbar-btn")?.closest("td")?.getBoundingClientRect().left;ue({top:L,left:ze,width:zi?zi-ze:zt,height:Ze})};(0,we.useEffect)(()=>(window.addEventListener("scroll",Qn,!0),window.addEventListener("resize",Qn),()=>{window.removeEventListener("scroll",Qn,!0),window.removeEventListener("resize",Qn)})),(0,we.useEffect)(()=>{let _=L=>{Gn.current&&!L.composedPath().includes(Gn.current)&&Gn.current.removeAttribute("open")};return document.addEventListener("click",_),()=>document.removeEventListener("click",_)},[]);let Ei=_=>{Me(_),et("")},zw=()=>{if(!se)return;let _=a[se];if(_){u(L=>({...L,[se]:_.productId})),N(L=>({...L,[se]:Wv(_)}));return}u(L=>{let ze={...L};return delete ze[se],ze}),N(L=>{let ze={...L};return delete ze[se],ze})},br=(_=!1)=>{let L=se?a[se]:void 0;!_&&L&&J?.best&&L.productId!==J.best.product_id&&!window.confirm("You have selected a new product. Leave without updating it?")||(_||zw(),Me(null),W(!1))},Aw=_=>{if(k(L=>new Set(L).add(_)),Ir.some(L=>L.item.line_id!==_)){br(!0);return}p(),br(!0)},Rw=_=>{if(hc(_),O(L=>new Set(L).add(_)),Ir.some(L=>L.item.line_id!==_)){br(!0);return}p(),br(!0)},Uw=()=>{O(_=>new Set([..._,...Ir.map(L=>L.item.line_id)])),p()},$d=()=>{J?.best&&(Kd(J.item.line_id,J.best),r(Mi(J)),ne?Aw(J.item.line_id):br(!0))},Zd=Xd.length>0?(0,s.jsxs)("section",{className:"results-tile-section results-tile-section--unmatched","aria-label":"Items requiring matching",children:[(0,s.jsxs)("div",{className:"results-tile-section__head",children:[(0,s.jsx)("h3",{children:"Require Matching"}),(0,s.jsx)("p",{children:"We couldn\u2019t confidently match these to a product. Open one to pick from the closest options."})]}),(0,s.jsx)("div",{className:"results-unmatched-list",children:Xd.map(_=>{let{item:L,qty:ze}=_;return(0,s.jsxs)("button",{type:"button",className:"results-unmatched-card",onClick:()=>Ei(L.line_id),children:[(0,s.jsx)("span",{className:"results-unmatched-card__main",children:(0,s.jsx)("span",{className:"results-unmatched-card__title",children:Pr(L,w)})}),(0,s.jsx)("span",{className:"bom-toolbar-btn results-unmatched-card__prompt",children:"Review"})]},L.line_id)})})]}):null,hc=_=>{u(L=>({...L,[_]:fd})),N(L=>({...L,[_]:void 0})),T(L=>({...L,[_]:void 0})),n(_)},bc=(_,L)=>{u(ze=>({...ze,[_]:L.product_id})),N(ze=>({...ze,[_]:L}))},Kd=(_,L)=>{L.method==="catalogue_search"&&T(ze=>({...ze,[_]:L}))};function ax(){g("downloaded",{type:"schedule",lines:X.length}),Fv(X.map(({item:_,best:L,qty:ze,band:zt,unmatchable:Ze,decision:It})=>({item:_,best:L,qty:ze,band:zt,unmatchable:Ze,decision:It})))}function Mi(_){let L=_.best??Zs(_.result)[0];return Kr(L,{lineId:_.item.line_id,description:_.item.description_original,unit:_.item.unit,qty:_.qty})}(0,we.useEffect)(()=>{if(!o){for(let _ of X)!_.unmatchable&&_.best&&r(Mi(_));l()}},[o]),(0,we.useEffect)(()=>{for(let _ of X){let L=a[_.item.line_id];if(!L)continue;let ze=Mi(_);r(i_(ze,L))}},[e]),(0,we.useEffect)(()=>{if(!se){Tt([]),E(null),ct(!1);return}let _=_e.trim();if(!_){Tt([]),E(null),ct(!1);return}let L=!1,ze=window.setTimeout(async()=>{try{ct(!0),E(null);let zt=await fetch(Bt(`/api/catalogue/search?q=${encodeURIComponent(_)}`),{headers:wi()}),Ze=await Zt(zt);if(!zt.ok)throw new Error(Ze?.error||Ze?.message||"Failed to search catalogue");L||Tt(Array.isArray(Ze?.items)?Ze.items:[])}catch(zt){L||(Tt([]),E(zt?.message||"Failed to search catalogue"))}finally{L||ct(!1)}},250);return()=>{L=!0,window.clearTimeout(ze)}},[_e,se]);let vc=Object.keys(a).length,Ma=_e.trim(),Pd=Zs(J?.result),sl=J?.decision?.technical_classification==="no_suitable_candidate"||!!J&&!J.best,Jd=J?.decision?.technical_classification!=null,Fd=J?.decision?.reason??(sl?"No catalogue candidate found. Refine the request or search the catalogue.":null),Dw=Ht.map(_=>({product_id:_.product_id,description:_.description,source_list:_.source_list,price:_.price,price_basis:_.price_basis,uoi_count:_.uoi_count??null,uoi:_.uoi,pdp_photo_url:_.pdp_photo_url??null,conversion:_.conversion,measurements_mm:_.measurements_mm??[],scores:{dimension:0,grade:0,brand:0,fuzzy:0,bm25:0,overall:0},method:"catalogue_search"})),Yn=Ma?Dw:Pd,Ti=J?A[J.item.line_id]:void 0,Vn=!Ma&&Ti&&!Yn.some(_=>_.product_id===Ti.product_id)?[...Yn,Ti]:Yn,Id=(()=>{let _=Vn.slice(0,Ma?12:3);return Ma||!Ti||_.some(L=>L.product_id===Ti.product_id)?_:[..._,Ti]})(),cl=!!J?.best&&a[J.item.line_id]?.productId===J.best.product_id,Bw=!!J?.best&&!!a[J.item.line_id]&&!cl;return(0,s.jsxs)("div",{className:"wizard-step entry-stage",children:[(0,s.jsxs)("div",{className:`quick-order-card${f?"":" quick-order-card--customer"}`,children:[(0,s.jsx)("div",{className:`quick-order-hero${f?"":" quick-order-hero--customer"}`,children:f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,s.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,s.jsx)("h1",{children:"Your Results"}),(0,s.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,s.jsx)("strong",{children:nt(me)})," Est. total"]})]}),(0,s.jsx)("p",{children:"Each line item from your schedule matched against your catalogue, ranked by confidence."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{children:"Review your matched products"}),(0,s.jsxs)("p",{children:["Check you're happy with these items, then click ",b?"View Quote":"View Basket"," to continue."]})]}),(0,s.jsxs)("button",{type:"button",className:"results-total-action",onClick:i,"aria-label":b?"View quote":"View basket",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:b?"View Quote":"View Basket"}),(0,s.jsx)("strong",{children:nt(me)})]}),(0,s.jsx)("span",{className:"arrow",children:(0,s.jsx)(Ot,{})})]})]})}),(0,s.jsxs)("div",{className:"quick-order-panel",style:{paddingTop:16},children:[Ve&&(0,s.jsx)("div",{className:"results-summary",style:{marginBottom:12},children:(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn","aria-pressed":ye,onClick:()=>ee(_=>!_),children:ye?"Hide timings":"Show timings"})}),Ve&&ye&&(0,s.jsx)(u_,{...D}),!b&&(0,s.jsx)("div",{className:"results-toolbar-row",children:!J&&(0,s.jsxs)("div",{className:"results-summary",style:{marginBottom:0},children:[Ce>0&&(0,s.jsxs)("span",{className:"summary-chip summary-chip--neutral",children:[(0,s.jsx)("strong",{children:Ce})," need pricing"]}),(0,s.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[(0,s.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search description...",value:z,onChange:_=>G(_.target.value),"aria-label":"Search line items"}),!f&&(0,s.jsxs)("div",{className:"results-view-toggle","aria-label":"Results view",children:[(0,s.jsx)("button",{type:"button",className:`results-view-toggle__btn${ce==="tile"?" is-active":""}`,"aria-pressed":ce==="tile","aria-label":"Tile view",title:"Tile view",onClick:()=>xe("tile"),children:(0,s.jsxs)("svg",{width:"18",height:"12",viewBox:"0 0 15 10",fill:"currentColor",children:[(0,s.jsx)("rect",{x:"0.5",y:"0.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"5.5",y:"0.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"10.5",y:"0.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"0.5",y:"5.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"5.5",y:"5.5",width:"4",height:"4"}),(0,s.jsx)("rect",{x:"10.5",y:"5.5",width:"4",height:"4"})]})}),(0,s.jsx)("button",{type:"button",className:`results-view-toggle__btn${ce==="list"?" is-active":""}`,"aria-pressed":ce==="list","aria-label":"List view",title:"List view",onClick:()=>xe("list"),children:(0,s.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 15 15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,s.jsx)("line",{x1:"0.5",y1:"2.5",x2:"14.5",y2:"2.5"}),(0,s.jsx)("line",{x1:"0.5",y1:"7.5",x2:"14.5",y2:"7.5"}),(0,s.jsx)("line",{x1:"0.5",y1:"12.5",x2:"14.5",y2:"12.5"})]})})]}),Ve&&(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Q(_=>_==="simple"?"detailed":"simple"),children:pe==="detailed"?"Hide detailed view":"Show detailed view"}),(0,s.jsxs)("details",{ref:Gn,style:{position:"relative"},children:[(0,s.jsx)("summary",{className:"bom-toolbar-btn sort-menu-summary","aria-label":"Sort line items",style:{fontSize:16},children:"\u21C5"}),(0,s.jsx)("div",{className:"sort-menu-panel",children:t_.map(_=>{let L=K===_.dir;return(0,s.jsxs)("button",{type:"button",className:`sort-menu-item${L?" is-active":""}`,onClick:()=>{fe(L?null:_.dir),Gn.current?.removeAttribute("open")},children:[(0,s.jsx)("span",{className:"sort-menu-item__check",children:L?"\u2713":""}),_.label]},_.dir)})})]})]})]})}),ce==="tile"||J?(0,s.jsxs)(s.Fragment,{children:[J?(0,s.jsx)("div",{className:"modal-backdrop quick-order-modal-backdrop",role:"dialog","aria-modal":"true","aria-label":"Product options",onClick:()=>br(),children:(0,s.jsxs)("section",{className:"quick-order-workflow-modal results-review-modal",onClick:_=>_.stopPropagation(),children:[(0,s.jsx)("button",{type:"button",className:"quick-order-workflow-close results-review-modal__close",onClick:()=>br(),"aria-label":"Close product options",children:(0,s.jsx)(Ko,{})}),(0,s.jsx)("div",{className:"results-review-page",children:f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"results-review-page__top",children:[(0,s.jsxs)("button",{type:"button",className:"bom-toolbar-btn bom-toolbar-btn--accent",onClick:()=>br(),children:[(0,s.jsx)(Zr,{}),"Back to results"]}),(0,s.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[Ve&&(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Q(_=>_==="simple"?"detailed":"simple"),children:pe==="detailed"?"Hide detailed info":"Show detailed info"}),(0,s.jsx)("div",{className:"results-review-searchbar",children:(0,s.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search products in catalogue...",value:_e,onChange:_=>et(_.target.value),"aria-label":"Search database candidates"})}),(0,s.jsx)("div",{className:"results-candidate-actions",children:(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>hc(J.item.line_id),children:"Clear selected product"})})]})]}),(0,s.jsxs)("div",{className:"results-review-page__hero",children:[(0,s.jsx)("div",{className:"results-review-page__image-wrap",children:(0,s.jsx)("img",{className:"fill-img results-review-page__image",src:Qa(je(J)?.description||J.item.description_original,je(J)?.product_id,je(J)?.pdp_photo_url),alt:""})}),(0,s.jsxs)("div",{className:"results-review-page__summary",children:[(0,s.jsx)("h2",{children:Pr(J.item,w)}),(0,s.jsxs)("p",{className:"results-review-page__meta",children:[_i(J.qty)," ",ka(J.item.unit,J.qty)]}),J.best?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-review-page__product",children:J.best.description}),J.best.price!=null?(0,s.jsx)("div",{className:"results-row-meta",children:Tn(J.best.price,J.best.price_basis)}):null]}):je(J)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-review-page__product",children:je(J)?.description}),je(J)?.price!=null?(0,s.jsx)("div",{className:"results-row-meta",children:Tn(je(J)?.price??null,je(J)?.price_basis??null)}):null,(0,s.jsx)("div",{className:"results-row-meta",children:"Best reviewed alternative - not yet selected"})]}):(0,s.jsx)("div",{className:"results-empty-hint",children:"No product currently selected for this line item."}),mr(J.item)?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[(0,s.jsx)(md,{meta:V.get(J.item.linked_group_id)}),(0,s.jsx)("div",{className:"results-row-meta",style:{marginTop:0},children:zn(J.item)})]}):null,(0,s.jsx)("div",{className:"results-review-page__actions",children:(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[J.item.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>{a[J.item.line_id]?n(J.item.line_id):(J.best&&Kd(J.item.line_id,J.best),r(Mi(J)))},disabled:!J.best,"aria-label":a[J.item.line_id]?f?"Remove from selection":`Remove from ${d}`:f?"Add to selection":`Add to ${d}`,children:a[J.item.line_id]?"\u2713 Added":f?"+ Add to selection":`Add to ${d}`})})]})]}),tt?(0,s.jsx)("div",{className:"results-empty-card",children:"Searching catalogue\u2026"}):null,!tt&&He?(0,s.jsx)("div",{className:"results-empty-card",children:He}):null,!tt&&!He&&Ma&&Yn.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No candidate products match this database search."}):!tt&&!He?(0,s.jsx)(g_,{item:J.item,candidates:Yn,result:J.result,decision:J.decision,unmatchable:J.unmatchable,selectedProductId:J.best?.product_id??null,detailMode:pe,linkedGroupMeta:mr(J.item)?V.get(J.item.linked_group_id):void 0,onPick:_=>bc(J.item.line_id,_),onClear:()=>hc(J.item.line_id),showAll:f||Ve||Ma.length>0,internal:f,debugEnabled:Ve,forceReviewNote:!0}):null]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("section",{className:"customer-review-request",children:[(0,s.jsx)("span",{className:"customer-review-eyebrow",children:"Original request"}),(0,s.jsx)("strong",{children:Pr(J.item,w)||"Original request"})]}),Fd?(0,s.jsxs)("section",{className:"customer-review-ai",children:[(0,s.jsx)("strong",{children:sl?"Exact match not found:":"AI review:"})," ",Fd]}):null,(0,s.jsxs)("section",{className:"customer-review-options",children:[(0,s.jsx)("div",{className:"customer-review-options__head",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{children:sl?"We couldn't find a suitable product":Jd?"Choose a product":"We couldn't review this item"}),(0,s.jsx)("p",{children:sl?Pd.length>0?"These AI-reviewed alternatives may be useful, but need approval.":"Search the catalogue to choose an alternative.":Jd?`Select the option you want to add to your ${d}.`:"Search the catalogue to choose a product."})]})}),!Ma&&Vn.length>0?(0,s.jsx)("div",{className:"customer-review-option-grid",children:Id.map(_=>{let L=_.product_id===J.best?.product_id;return(0,s.jsxs)("button",{type:"button",className:`customer-review-option${L?" is-selected":""}`,onClick:()=>bc(J.item.line_id,_),"aria-pressed":L,children:[(0,s.jsx)("img",{className:"customer-review-option__image",src:Qa(_.description,_.product_id,_.pdp_photo_url),alt:"",width:64,height:64}),(0,s.jsx)("span",{className:"customer-review-option__copy",children:(0,s.jsx)("strong",{children:_.description})}),(0,s.jsx)("span",{className:"customer-review-option__price",children:_.price!=null?`\xA3${Tn(_.price,_.price_basis)}`:"-"}),(0,s.jsx)("span",{className:"customer-review-option__state",children:L?"Selected":"Choose"})]},_.product_id)})}):null,Vn.length>0&&(0,s.jsx)("div",{className:"customer-review-divider",children:(0,s.jsx)("span",{children:"or"})}),(0,s.jsxs)("label",{className:"customer-review-search",children:[(0,s.jsx)("span",{children:"Search our full catalogue"}),(0,s.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search products...",value:_e,onChange:_=>et(_.target.value),"aria-label":"Search catalogue"})]}),Ma&&tt?(0,s.jsx)("div",{className:"results-empty-card",children:"Searching catalogue\u2026"}):null,Ma&&!tt&&He?(0,s.jsx)("div",{className:"results-empty-card",children:He}):null,Ma&&!tt&&!He&&Vn.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No products match this search."}):null,Ma&&!tt&&!He&&Vn.length>0?(0,s.jsx)("div",{className:"customer-review-option-grid",children:Id.map(_=>{let L=_.product_id===J.best?.product_id;return(0,s.jsxs)("button",{type:"button",className:`customer-review-option${L?" is-selected":""}`,onClick:()=>bc(J.item.line_id,_),"aria-pressed":L,children:[(0,s.jsx)("img",{className:"customer-review-option__image",src:Qa(_.description,_.product_id,_.pdp_photo_url),alt:"",width:64,height:64}),(0,s.jsx)("span",{className:"customer-review-option__copy",children:(0,s.jsx)("strong",{children:_.description})}),(0,s.jsx)("span",{className:"customer-review-option__price",children:_.price!=null?`\xA3${Tn(_.price,_.price_basis)}`:"-"}),(0,s.jsx)("span",{className:"customer-review-option__state",children:L?"Selected":"Choose"})]},_.product_id)})}):null]}),J.best?Bw?(0,s.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,s.jsx)("button",{type:"button",className:"cta-btn customer-review-add",onClick:()=>{$d()},children:(0,s.jsx)("span",{children:"Update product"})}),(0,s.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary customer-review-add",onClick:()=>n(J.item.line_id),children:(0,s.jsx)("span",{children:`Remove from ${d}`})})]}):(0,s.jsx)("button",{type:"button",className:`cta-btn customer-review-add${cl?" cta-btn-secondary":""}`,onClick:()=>{cl?n(J.item.line_id):$d()},children:(0,s.jsx)("span",{children:cl?`Remove from ${d}`:`Add selected product to ${d}`})}):null,ne?(0,s.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary customer-review-skip",onClick:()=>Rw(J.item.line_id),children:"Skip this item"}):null]})})]})}):null,(0,s.jsxs)("div",{className:"results-tile-layout",children:[Ea.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No line items match the current search/filter."}):null,gc.length>0?(0,s.jsx)("section",{className:"results-tile-section","aria-label":"Matched and review items",children:(0,s.jsx)("div",{className:"results-tile-grid",children:gc.map(_=>{let{item:L,best:ze,qty:zt}=_,Ze=je(_),It=!ze&&dt(_);return(0,s.jsxs)("article",{className:"results-tile-card",children:[(0,s.jsxs)("button",{type:"button",className:"results-tile-card__surface",onClick:()=>Ei(L.line_id),"aria-label":`Review match for ${Pr(L,w)||"item"}`,children:[(0,s.jsxs)("div",{className:"results-tile-card__media",children:[It||mr(L)?(0,s.jsxs)("div",{className:"results-tile-card__badges",children:[mr(L)?(0,s.jsx)(md,{meta:V.get(L.linked_group_id)}):(0,s.jsx)("span",{}),It?(0,s.jsx)("span",{style:{padding:"6px 10px",borderRadius:999,background:"#fef3c7",color:"#92400e",fontSize:12,fontWeight:700,lineHeight:1},children:"Partially matched"}):null]}):null,(0,s.jsx)("img",{className:"fill-img results-tile-card__image",src:Qa(Ze?.description||L.description_original,Ze?.product_id,Ze?.pdp_photo_url),alt:""})]}),(0,s.jsxs)("div",{className:"results-tile-card__body",children:[Ze?(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("div",{className:"results-tile-card__heading",children:(0,s.jsx)("div",{className:"results-tile-card__title",children:Ze.description})})}):(0,s.jsx)("div",{className:"results-empty-hint",children:"No product currently selected for this line item."}),(0,s.jsx)("div",{className:"results-tile-card__match",children:Ze?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-tile-card__match-label",children:It?"\u21B3 partially matched from":"\u21B3 matched from"}),(0,s.jsx)("div",{className:"results-tile-card__match-name",children:Pr(L,w)}),mr(L)?(0,s.jsx)("div",{className:"results-row-meta",children:zn(L)}):null]}):(0,s.jsx)("span",{className:"results-empty-hint",children:"No matched product selected."})})]}),(0,s.jsx)("span",{className:"results-tile-card__hover-prompt","aria-hidden":"true",children:"Click to view options"})]}),(0,s.jsxs)("div",{className:"results-tile-card__actions",children:[f&&(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Ei(L.line_id),children:"Review"}),(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[L.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>{a[L.line_id]?n(L.line_id):r(Mi(_))},disabled:!Ze,"aria-label":a[L.line_id]?f?"Remove from selection":`Remove from ${d}`:f?"Add to selection":`Add to ${d}`,children:a[L.line_id]?"\u2713 Added":f?"+ Add":`Add to ${d}`})]})]},L.line_id)})})}):null,Zd]})]}):(0,s.jsxs)(s.Fragment,{children:[I&&(0,s.jsx)("div",{className:"results-table__hover-overlay",style:I,"aria-hidden":"true",children:"Click to view options"}),(0,s.jsx)("div",{className:"bom-table-wrap",children:(0,s.jsxs)("table",{className:"bom-table results-table","aria-label":"Matched line items",children:[(0,s.jsxs)("colgroup",{children:[(0,s.jsx)("col",{className:"col-item"}),(0,s.jsx)("col",{style:{width:"220px"}}),(0,s.jsx)("col",{style:{width:"100px"}}),pe==="simple"&&(0,s.jsx)("col",{style:{width:"110px"}})]}),(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"bom-col-header",children:[(0,s.jsx)("th",{style:{textAlign:"left"},children:"Description"}),(0,s.jsx)("th",{style:{textAlign:"center"},children:"Product Matched"}),(0,s.jsx)("th",{style:{textAlign:"center"},children:"Price"}),pe==="simple"&&(0,s.jsx)("th",{style:{textAlign:"center"},children:f?"Selection":b?"Quote":"Basket"})]})}),(0,s.jsxs)("tbody",{children:[Ea.length===0&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:pe==="simple"?4:3,className:"results-empty-hint",style:{padding:"16px 8px"},children:"No line items match the current search/filter."})}),gc.map(_=>{let{item:L,result:ze,decision:zt,best:Ze}=_;return(0,s.jsxs)("tr",{className:"bom-row results-table__review-row",onClick:()=>Ei(L.line_id),onMouseEnter:It=>{ve.current=It.currentTarget,Qn()},onMouseLeave:()=>{ve.current=null,ue(null)},children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("div",{className:"bom-component-name",children:Pr(L,w)}),mr(L)?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[(0,s.jsx)(md,{meta:V.get(L.linked_group_id)}),(0,s.jsx)("div",{className:"results-row-meta",style:{marginTop:0},children:zn(L)})]}):null]}),(0,s.jsx)("td",{children:Ze?(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"results-match-cell-text",title:Ze.description,children:Ze.description}),pe==="detailed"&&zt?.technical_classification&&(0,s.jsxs)("div",{className:"results-row-meta",children:[n_(zt.technical_classification),zt.approval_required?" - approval required":""]})]}):(0,s.jsx)("span",{className:"results-empty-hint"})}),(0,s.jsx)("td",{style:{textAlign:"center"},children:Ze?.price!=null?Tn(Ze.price,Ze.price_basis):"-"}),pe==="simple"&&(0,s.jsx)("td",{style:{textAlign:"center"},children:(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[L.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,style:{width:84,justifyContent:"center"},onClick:It=>{It.stopPropagation(),a[L.line_id]?n(L.line_id):r(Mi(_))},"aria-label":a[L.line_id]?f?"Remove from selection":`Remove from ${d}`:f?"Add to selection":`Add to ${d}`,children:a[L.line_id]?"\u2713 Added":f?"+ Add":`Add to ${d}`})})]},L.line_id)})]})]})}),Zd]}),!J&&hr>1&&(0,s.jsxs)("div",{className:"results-pagination",children:[(0,s.jsxs)("span",{className:"results-pagination-count",children:["Showing ",(Jt-1)*el+1,"\u2013",Math.min(Jt*el,Ea.length)," of ",Ea.length]}),(0,s.jsxs)("div",{className:"results-pagination-controls",children:[(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Ye(Jt-1),disabled:Jt===1,children:"Previous"}),(0,s.jsxs)("span",{className:"results-pagination-page",children:["Page ",Jt," of ",hr]}),(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Ye(Jt+1),disabled:Jt===hr,children:"Next"})]})]}),(M.itemCount!=null||M.headingCount!=null||M.skippedCount!=null)&&(0,s.jsxs)("div",{className:"results-summary",style:{marginTop:16},children:[M.itemCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:M.itemCount})," items parsed"]}),M.headingCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:M.headingCount})," headings"]}),M.skippedCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:M.skippedCount})," rows skipped"]})]}),(0,s.jsxs)("div",{className:"disclaimer-box",children:[(0,s.jsx)("span",{className:"disclaimer-icon",children:"\u26A0\uFE0F"}),(0,s.jsx)("p",{className:"disclaimer-text",children:"These matches are generated automatically and should be reviewed before purchase."})]}),!J&&(0,s.jsxs)("div",{className:"btn-row results-actions",children:[(0,s.jsxs)("button",{className:"cta-btn cta-btn-secondary",style:{flex:(vc>0,"0 1 30%"),gap:10,justifyContent:"center"},onClick:()=>R(!0),"aria-label":"Start over",children:[(0,s.jsx)(pd,{}),(0,s.jsx)("span",{children:"Start Over"})]}),vc>0&&(0,s.jsxs)("button",{className:"cta-btn",style:{flex:"0 1 70%"},onClick:i,"aria-label":f?"View selection":b?"View quote":"View basket",children:[(0,s.jsxs)("span",{children:[f?"View Selection":b?"View Quote":"View Basket"," (",vc,")"]}),(0,s.jsx)("span",{className:"arrow",children:(0,s.jsx)(Ot,{})})]})]})]})]}),Tw&&(0,s.jsx)("div",{className:"modal-backdrop quick-order-modal-backdrop review-gate-modal-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"review-gate-title",children:(0,s.jsxs)("section",{className:"quick-order-workflow-modal review-gate-modal",children:[(0,s.jsxs)("div",{className:"review-gate-modal__header",children:[(0,s.jsx)("h2",{id:"review-gate-title",children:"Choose products for these items"}),(0,s.jsx)("p",{children:"We couldn\u2019t find a clear match for these items, so we need your help. Select an option from the suggestions, search the catalogue, or leave the item out."})]}),(0,s.jsx)("div",{className:"review-gate-list",children:Ir.map(_=>{let L=Se.has(_.item.line_id),ze=dt(_);return(0,s.jsx)("div",{className:`review-gate-item${L?" is-reviewed":""}`,children:(0,s.jsxs)("button",{type:"button",className:"review-gate-item__review",onClick:()=>{W(!0),Ei(_.item.line_id)},children:[(0,s.jsxs)("span",{className:"review-gate-item__copy",children:[(0,s.jsx)("strong",{children:Pr(_.item,w)}),(0,s.jsx)("span",{children:_.decision?.reason||(ze?"A close alternative is available but needs confirmation.":"No product has been selected for this item yet.")})]}),(0,s.jsx)("span",{className:"review-gate-item__action",children:L?"Choice made":"Choose a product"})]})},_.item.line_id)})}),(0,s.jsx)("button",{type:"button",className:"review-gate-skip",onClick:Uw,children:"Skip all"}),ll.length>0?(0,s.jsxs)("div",{className:"review-gate-skipped",children:[(0,s.jsx)("strong",{children:"Skipped"}),ll.map(_=>(0,s.jsxs)("button",{type:"button",className:"review-gate-item is-skipped",onClick:()=>{O(L=>{let ze=new Set(L);return ze.delete(_.item.line_id),ze}),W(!0),Ei(_.item.line_id)},children:[(0,s.jsxs)("span",{className:"review-gate-item__copy",children:[(0,s.jsx)("strong",{children:Pr(_.item,w)}),(0,s.jsx)("span",{children:`Not added to your ${d}.`})]}),(0,s.jsx)("span",{className:"review-gate-item__action",children:"Choose a product"})]},_.item.line_id))]}):null]})}),x&&(0,s.jsx)("div",{className:"modal-backdrop quick-order-modal-backdrop start-over-modal",role:"dialog","aria-modal":"true","aria-labelledby":"start-over-modal-title",children:(0,s.jsxs)("div",{className:"modal-card start-over-modal__card",children:[(0,s.jsx)("h2",{id:"start-over-modal-title",className:"modal-title",children:"Start over?"}),(0,s.jsxs)("p",{className:"modal-body",children:["This will clear the current results and ",b?"quote":"basket"," and take you back to the start."]}),(0,s.jsxs)("div",{className:"modal-actions",children:[(0,s.jsx)("button",{type:"button",className:"modal-btn modal-btn-secondary",onClick:()=>R(!1),children:"Cancel"}),(0,s.jsx)("button",{type:"button",className:"modal-btn modal-btn-danger",onClick:()=>{R(!1),t()},autoFocus:!0,children:"Start Over"})]})]})})]})}var wt=Y(Xe());var q=Y(ae()),h_=.2,tl=10,rw="Enter a valid email address so we can send your quote.",b_=(e,t)=>{let a=`${t.requestedAmount} ${xa(t.requestedUnit,t.requestedAmount)}`,r=`${t.requiredSellUnits} ${xa(t.sellUnit,t.requiredSellUnits??0)}`,n=e.unitConversions?.find(i=>i.requestUom===t.requestedUnit);return n&&n.quantityPerSaleUnit<1?`${a} requested \u2192 order ${r} (${Math.round(1/n.quantityPerSaleUnit)} ${xa(t.sellUnit,2)} per ${xa(t.requestedUnit,1)})`:e.coverageQty&&/^m per /i.test(e.coverageUom??"")?`${a} requested \u2192 order ${r} (${e.coverageQty} ${e.coverageUom})`:`${a} requested \u2192 order ${r}`},v_=e=>["box","pack"].includes(e.requestedUnit)?"Pack size needed to calculate the order quantity.":`This product is sold by ${xa(e.sellUnit,1)}.`;function w_(){return(0,q.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,q.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,q.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,q.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,q.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function al(){return(0,q.jsx)("svg",{width:"8",height:"5",viewBox:"0 0 8 5",fill:"none",children:(0,q.jsx)("path",{d:"M1 4L4 1L7 4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function rl({cart:e,onUpdateQty:t,onUpdateSellUnits:a,onResolveConversions:r,onRemove:n,onBack:i,onStartNewQuote:o,internal:l=!1}){let c=(0,wt.useId)(),p=!l&&Qs()==="QZA6-MRA4",f=Object.values(e),[b,d]=(0,wt.useState)(""),[h,w]=(0,wt.useState)(!1),[M,D]=(0,wt.useState)(!1),m=Cn(),[u,g]=(0,wt.useState)(""),[v,N]=(0,wt.useState)({}),[A,T]=(0,wt.useState)({}),[z,G]=(0,wt.useState)(1),[K,fe]=(0,wt.useState)({}),[Te,Ye]=(0,wt.useState)(!1),[Ve,it]=(0,wt.useState)("0"),pe=(0,wt.useRef)(new Set);(0,wt.useEffect)(()=>{if(!r)return;for(let R of Object.values(e))ua(R).requiredSellUnits!=null&&pe.current.delete(R.lineId);let x=Object.values(e).filter(R=>R.productId!=="-"&&ua(R).requiredSellUnits==null&&!pe.current.has(R.lineId));x.length!==0&&(x.forEach(R=>pe.current.add(R.lineId)),fetch(Bt("/api/catalogue/resolve-conversions"),{method:"POST",headers:{"Content-Type":"application/json",...Ga()},body:JSON.stringify({lines:x.map(R=>({line_id:R.lineId,product_id:R.productId,requested_description:R.requestedDescription??R.description,requested_qty:R.qty,requested_uom:R.unit,selected_description:R.description,selected_uoi:R.uoi,selected_uoi_count:R.uoiCount,selected_conversion:{sales_uom_normalised:R.salesUomNormalised,conversion_type:R.conversionType,sales_unit_size:R.salesUnitSize,sales_unit_size_uom:R.salesUnitSizeUom,coverage_qty:R.coverageQty,coverage_uom:R.coverageUom}}))})}).then(R=>R.ok?Zt(R):null).then(R=>{let I={};for(let ue of R?.data?.items??R?.items??[]){let ve=ue?.conversion;!ve||typeof ue?.line_id!="string"||(I[ue.line_id]={conversionType:ve.conversion_type,requestUomsSupported:ve.request_uoms_supported,salesUomNormalised:ve.sales_uom_normalised,salesUnitSize:ve.sales_unit_size,salesUnitSizeUom:ve.sales_unit_size_uom,coverageQty:ve.coverage_qty,coverageUom:ve.coverage_uom,roundingRule:ve.rounding_rule,conversionConfidence:ve.conversion_confidence,conversionNotes:ve.conversion_notes})}Object.keys(I).length>0&&r(I)}).catch(()=>{}))},[e,r]);function Q(x){N(R=>{let I={...R};return delete I[x],I})}function ce(x,R){let I=parseFloat(R);!isNaN(I)&&I>=0&&t(x,I),Q(x)}function xe(x,R,I){t(x,Math.max(0,R+I)),Q(x)}function ye(x){T(R=>{let I={...R};return delete I[x],I})}function ee(x,R){let I=parseFloat(R);!isNaN(I)&&I>=0&&a(x,I),ye(x)}function se(x,R,I){a(x,Math.max(0,R+I)),ye(x)}async function Me(){let x=b.trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x)){g(rw);return}g(""),D(!0);try{let R=await fetch(Bt("/api/quote-requests"),{method:"POST",headers:{"Content-Type":"application/json",...Ga()},body:JSON.stringify({email:x,items:_e.map(({item:I,pricing:ue})=>{let ve=ue.requiredSellUnits??ue.requestedAmount,Se=ue.requiredSellUnits!=null?ue.sellUnit:ue.requestedUnit;return{product_id:I.productId,description:I.description,quantity:ve,unit:xa(Se,ve),unit_price:ue.requiredSellUnits!=null?ue.unitPrice:null,line_total:ue.lineTotal}})})});if(!R.ok){let I=await Zt(R);console.error("Quote request failed",R.status,I?.message),g(R.status===429?"You've sent a few requests already. Please try again in a few minutes.":"Your request couldn't be sent. Please try again, or contact us if it keeps happening.");return}m("quote_requested",{items:_e.length,total:Math.round(Tt*100)/100}),w(!0),window.scrollTo(0,0)}catch{g("Your request couldn't be sent. Check your connection and try again.")}finally{D(!1)}}let _e=f.map(x=>({item:x,pricing:ua(x,{wasteFactorEnabled:Te,wasteFactorOverride:Math.max(0,Number.parseFloat(Ve)||0)/100})})),et=_e.reduce((x,R)=>x+(R.pricing.lineTotal??0),0),Ht=et*h_,Tt=et+Ht,tt=(0,wt.useRef)({items:_e.length,total:Math.round(Tt*100)/100});(0,wt.useEffect)(()=>{m("basket_viewed",tt.current)},[m]);let ct=Math.max(1,Math.ceil(_e.length/tl)),He=Math.min(z,ct),E=_e.slice((He-1)*tl,He*tl);return h?(0,q.jsx)("div",{className:"wizard-step entry-stage",children:(0,q.jsxs)("div",{className:"quote-request-sent",role:"status",children:[(0,q.jsx)("div",{className:"quote-request-sent-icon","aria-hidden":"true",children:(0,q.jsx)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,q.jsx)("polyline",{points:"5 12.5 10 17.5 19 7"})})}),(0,q.jsx)("h1",{children:"Quote requested"}),(0,q.jsxs)("p",{children:["You're all done. We'll email your sharper price to ",(0,q.jsx)("strong",{children:b.trim()}),", usually within one working day."]}),(0,q.jsx)("button",{type:"button",className:"cta-btn",onClick:o,children:(0,q.jsx)("span",{children:"Start a new quote"})}),(0,q.jsx)("p",{className:"quote-request-sent-note",children:"Nothing is charged until you approve the quote."})]})}):(0,q.jsx)("div",{className:`wizard-step entry-stage${p?" basket-layout--qza6-mra4":""}`,children:(0,q.jsxs)("div",{className:`quick-order-card${l?"":" quick-order-card--customer"}`,children:[(0,q.jsxs)("div",{className:`quick-order-hero${l?"":" quick-order-hero--customer"}`,children:[l&&(0,q.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,q.jsxs)("div",{className:"basket-hero-copy",children:[p&&(0,q.jsxs)("button",{type:"button",className:"cta-btn cta-btn-secondary basket-hero-back",onClick:i,children:[(0,q.jsx)(Zr,{}),(0,q.jsx)("span",{children:"Back to results"})]}),(0,q.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,q.jsx)("h1",{children:l?"Your Selection":p?"Request a quote":"Your Basket"}),l&&(0,q.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,q.jsx)("strong",{children:f.length})," ",f.length===1?"item":"items"]})]}),(0,q.jsx)("p",{children:l?"Review the items you've added before exporting them for review.":p?"Check your items & quantities below, and we'll do our best to beat list prices.":"Review your quantities and order summary before you buy."})]})]}),(0,q.jsx)("div",{className:"quick-order-panel",style:{paddingTop:16},children:f.length===0?(0,q.jsxs)("div",{className:"quick-order-history-empty",children:[(0,q.jsx)("div",{className:"basket-empty-icon","aria-hidden":"true",children:l?"\u{1F4CB}":"\u{1F9FA}"}),(0,q.jsx)("p",{children:l?"Your selection is empty.":p?"Your quote request is empty.":"Your basket is empty."}),(0,q.jsx)("p",{className:"basket-empty-hint",children:p?"Go back to your results and add items for your quote.":"Go back to your results and add quoted items."}),(0,q.jsx)("div",{className:"btn-row",style:{marginTop:20,justifyContent:"center"},children:(0,q.jsx)("button",{className:"cta-btn",style:{width:"auto",maxWidth:280},onClick:i,"aria-label":"Back to results",children:(0,q.jsx)("span",{children:"Back to Results"})})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)("div",{className:"basket-layout",children:[(0,q.jsxs)("div",{className:"basket-main",children:[(0,q.jsx)("div",{className:"basket-list","aria-label":l?"Selection items":p?"Quote request items":"Basket items",children:E.map(({item:x,pricing:R})=>{let I=v[x.lineId]??String(R.requestedAmount),ue=R.requestedUnit===R.sellUnit||R.costingMode==="review",ve=R.requiredSellUnits==null||R.requestedAmount!==R.requiredSellUnits||R.requestedUnit!==R.sellUnit;return(0,q.jsxs)("article",{className:"basket-card",children:[(0,q.jsxs)("div",{className:"basket-card-top",children:[(0,q.jsx)("img",{className:"basket-card-thumb",src:Qa(x.description,x.productId,x.pdpPhotoUrl),alt:"",width:48,height:48}),(0,q.jsxs)("div",{className:"basket-card-info",children:[(0,q.jsx)("div",{className:"bom-component-name",children:x.description}),ve&&R.costingMode!=="review"&&(0,q.jsxs)("button",{type:"button",className:"basket-calc-toggle",onClick:()=>fe(Se=>({...Se,[x.lineId]:!Se[x.lineId]})),"aria-expanded":!!K[x.lineId],children:["How we calculated this",(0,q.jsx)("span",{className:`basket-calc-toggle-chevron${K[x.lineId]?" basket-calc-toggle-chevron--open":""}`,children:(0,q.jsx)(al,{})})]})]}),(0,q.jsx)("div",{className:"basket-card-actions",children:(0,q.jsx)("button",{type:"button",className:"mf-remove-small-btn basket-card-remove",onClick:()=>n(x.lineId),"aria-label":`Remove ${x.description}`,children:(0,q.jsx)(w_,{})})})]}),l&&(0,q.jsxs)("div",{className:"results-detail-block basket-internal-detail",children:[(0,q.jsxs)("dl",{className:"results-detail-grid",children:[(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Conversion type"}),(0,q.jsx)("dd",{children:x.conversionType??"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Conversion confidence"}),(0,q.jsx)("dd",{children:x.conversionConfidence??"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Sales unit"}),(0,q.jsx)("dd",{children:x.salesUnitSize!=null?(0,q.jsxs)(q.Fragment,{children:[x.salesUnitSize," ",ka(x.salesUnitSizeUom,x.salesUnitSize)]}):"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Coverage"}),(0,q.jsx)("dd",{children:x.coverageQty!=null?(0,q.jsxs)(q.Fragment,{children:[x.coverageQty," ",ka(x.coverageUom,x.coverageQty)]}):"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Waste factor"}),(0,q.jsx)("dd",{children:x.wasteFactorDefault??"-"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)("dt",{children:"Rounding rule"}),(0,q.jsx)("dd",{children:x.roundingRule??"-"})]})]}),x.conversionNotes&&(0,q.jsx)("p",{className:"results-rerank-note",children:x.conversionNotes})]}),R.costingMode==="review"?(0,q.jsxs)("p",{className:"basket-calc-text basket-calc-text--review",children:[(0,q.jsx)("strong",{children:"Quantity needs confirmation."})," ",v_(R)]}):ve&&K[x.lineId]?(0,q.jsx)("p",{className:"basket-calc-text",children:b_(x,R)}):null,(0,q.jsxs)("div",{className:"basket-card-stats",children:[(0,q.jsxs)("div",{className:"basket-stat",children:[(0,q.jsx)("span",{className:"basket-stat-label",children:"Requested qty"}),(0,q.jsxs)("div",{className:"basket-stat-value",children:[(0,q.jsxs)("div",{className:"basket-qty-field",children:[(0,q.jsx)("input",{className:"bom-qty-edit",type:"number",inputMode:"decimal",min:"0",placeholder:"-",value:I,disabled:ue,onChange:Se=>N(k=>({...k,[x.lineId]:Se.target.value})),onBlur:Se=>ce(x.lineId,Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&Se.target.blur()},"aria-label":`${x.description} requested quantity`}),(0,q.jsxs)("div",{className:"basket-qty-arrows",children:[(0,q.jsx)("button",{type:"button",className:"basket-qty-arrow",disabled:ue,onClick:()=>xe(x.lineId,parseFloat(I)||0,1),"aria-label":`Increase ${x.description} quantity`,children:(0,q.jsx)(al,{})}),(0,q.jsx)("button",{type:"button",className:"basket-qty-arrow basket-qty-arrow--down",disabled:ue,onClick:()=>xe(x.lineId,parseFloat(I)||0,-1),"aria-label":`Decrease ${x.description} quantity`,children:(0,q.jsx)(al,{})})]})]}),(0,q.jsx)("span",{className:"basket-metric-unit",children:ka(R.requestedUnit,parseFloat(I)||0)})]})]}),(0,q.jsxs)("div",{className:"basket-stat basket-stat--right",children:[(0,q.jsx)("span",{className:"basket-stat-label",children:"Order qty"}),(0,q.jsxs)("div",{className:"basket-stat-value",children:[(0,q.jsxs)("div",{className:"basket-qty-field",children:[(0,q.jsx)("input",{className:"bom-qty-edit",type:"number",inputMode:"decimal",min:"0",placeholder:"-",value:A[x.lineId]??String(R.requiredSellUnits??""),onChange:Se=>T(k=>({...k,[x.lineId]:Se.target.value})),onBlur:Se=>ee(x.lineId,Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&Se.target.blur()},"aria-label":`${x.description} order quantity`}),(0,q.jsxs)("div",{className:"basket-qty-arrows",children:[(0,q.jsx)("button",{type:"button",className:"basket-qty-arrow",onClick:()=>se(x.lineId,parseFloat(A[x.lineId]??String(R.requiredSellUnits??"0"))||0,1),"aria-label":`Increase ${x.description} order quantity`,children:(0,q.jsx)(al,{})}),(0,q.jsx)("button",{type:"button",className:"basket-qty-arrow basket-qty-arrow--down",onClick:()=>se(x.lineId,parseFloat(A[x.lineId]??String(R.requiredSellUnits??"0"))||0,-1),"aria-label":`Decrease ${x.description} order quantity`,children:(0,q.jsx)(al,{})})]})]}),(0,q.jsx)("span",{className:"basket-metric-unit",children:ka(R.sellUnit,parseFloat(A[x.lineId]??String(R.requiredSellUnits??"0"))||0)})]})]}),(0,q.jsxs)("div",{className:"basket-stat basket-stat--total",children:[(0,q.jsx)("span",{className:"basket-stat-label",children:"Total"}),(0,q.jsxs)("div",{className:"basket-stat-value",children:[(0,q.jsx)("strong",{children:R.lineTotal!=null?nt(R.lineTotal):"-"}),R.lineTotal!=null&&(0,q.jsx)("span",{className:"basket-metric-unit",children:"ex. VAT"})]})]})]})]},x.lineId)})}),ct>1&&(0,q.jsxs)("div",{className:"results-pagination",children:[(0,q.jsxs)("span",{className:"results-pagination-count",children:["Showing ",(He-1)*tl+1,"\u2013",Math.min(He*tl,_e.length)," of ",_e.length]}),(0,q.jsxs)("div",{className:"results-pagination-controls",children:[(0,q.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>G(He-1),disabled:He===1,children:"Previous"}),(0,q.jsxs)("span",{className:"results-pagination-page",children:["Page ",He," of ",ct]}),(0,q.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>G(He+1),disabled:He===ct,children:"Next"})]})]})]}),(0,q.jsxs)("aside",{className:"basket-sidebar",children:[(0,q.jsx)("div",{className:"basket-sidebar-title",children:p?"Quote request summary":"Order summary"}),(0,q.jsxs)("div",{className:"basket-sidebar-row",children:[(0,q.jsx)("span",{children:p?"List price (ex. VAT)":"Subtotal (ex. VAT)"}),(0,q.jsx)("span",{children:nt(et)})]}),(0,q.jsxs)("div",{className:"basket-sidebar-row",children:[(0,q.jsx)("span",{children:"VAT (20%)"}),(0,q.jsx)("span",{children:nt(Ht)})]}),(0,q.jsxs)("div",{className:"basket-sidebar-row basket-sidebar-row--total",children:[(0,q.jsx)("span",{children:p?"List price (inc. VAT)":"Total"}),(0,q.jsx)("span",{children:nt(Tt)})]}),!p&&(0,q.jsx)("div",{className:"basket-summary-waste",children:(0,q.jsxs)("div",{className:"basket-waste-control",children:[(0,q.jsxs)("label",{className:"basket-global-waste",children:[(0,q.jsx)("input",{type:"checkbox",checked:Te,onChange:x=>Ye(x.target.checked)}),(0,q.jsx)("span",{children:"Add waste factor"})]}),(0,q.jsxs)("label",{className:"basket-global-waste-percent",children:[(0,q.jsx)("input",{type:"number",inputMode:"decimal",min:"0",step:"0.1",value:Ve,onChange:x=>it(x.target.value),disabled:!Te,"aria-label":"Waste factor percent"}),(0,q.jsx)("span",{children:"%"})]})]})}),(0,q.jsx)("label",{htmlFor:`${c}-basket-reference`,className:"basket-sidebar-label",children:p?"Enter email for your sharper quote":"Your reference (optional)"}),(0,q.jsx)("input",{id:`${c}-basket-reference`,type:p?"email":"text",className:"basket-sidebar-input",value:b,onChange:x=>{d(x.target.value),p&&g("")},placeholder:p?"you@example.com":"PO number or job reference","aria-invalid":p&&u===rw,"aria-describedby":p&&u?`${c}-basket-reference-error`:void 0}),p&&u&&(0,q.jsx)("p",{id:`${c}-basket-reference-error`,className:"basket-quote-request-error",role:"alert",children:u}),p?(0,q.jsx)("button",{type:"button",className:"cta-btn",onClick:()=>{Me()},disabled:M,"aria-busy":M,children:(0,q.jsx)("span",{children:M?"Sending\u2026":"Request our best quote"})}):(0,q.jsx)("button",{className:"cta-btn",onClick:()=>{m("downloaded",{type:"basket",items:f.length}),Iv(f)},"aria-label":l?"Download selection":"Download basket",children:(0,q.jsx)("span",{children:l?"Download Quote":"Buy Now"})}),(0,q.jsxs)("p",{className:"basket-sidebar-disclaimer",children:[(0,q.jsx)("span",{"aria-hidden":"true",children:"\u26A0\uFE0F"}),p?"This is a quote request, not an order. We'll confirm our best price, availability and delivery before you approve.":"Prices and availability are estimates and should be confirmed before procurement."]})]})]}),(0,q.jsx)("div",{className:"btn-row results-actions",children:(0,q.jsxs)("button",{className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",gap:10,justifyContent:"center"},onClick:i,"aria-label":"Back to results",children:[(0,q.jsx)(Zr,{}),(0,q.jsx)("span",{children:"Back to results"})]})})]})})]})})}var Et=Y(Xe()),iw=Y(ae()),bd=(0,Et.createContext)(null);function Ps({children:e,onOpenBasket:t}){let[a,r]=(0,Et.useState)({}),n=(0,Et.useCallback)(d=>{r(h=>({...h,[d.lineId]:d}))},[]),i=(0,Et.useCallback)(d=>{r(h=>{let w={...h};for(let M of d)w[M.lineId]=M;return w})},[]),o=(0,Et.useCallback)(d=>{r(h=>{let w={...h};return delete w[d],w})},[]),l=(0,Et.useCallback)((d,h)=>{r(w=>w[d]?{...w,[d]:{...w[d],qty:h,sellUnitsOverride:null}}:w)},[]),c=(0,Et.useCallback)((d,h)=>{r(w=>w[d]?{...w,[d]:{...w[d],sellUnitsOverride:h}}:w)},[]),p=(0,Et.useCallback)(d=>{r(h=>{let w=!1,M={...h};for(let[D,m]of Object.entries(d))M[D]&&(M[D]={...M[D],...m},w=!0);return w?M:h})},[]),f=(0,Et.useCallback)(()=>r({}),[]),b=(0,Et.useMemo)(()=>({cart:a,count:Object.keys(a).length,addToCart:n,addManyToCart:i,removeFromCart:o,updateCartQty:l,updateCartSellUnits:c,updateCartConversions:p,clearCart:f,openBasket:t??(()=>{})}),[a,n,i,o,l,c,p,f,t]);return(0,iw.jsx)(bd.Provider,{value:b,children:e})}function An(){let e=(0,Et.useContext)(bd);if(!e)throw new Error("useCart must be used inside a <CartProvider>");return e}function Js(){return(0,Et.useContext)(bd)}var Na=Y(ae());function Fs(e){return(0,Na.jsx)(Ps,{children:(0,Na.jsx)(y_,{...e})})}function y_({fullPage:e=!1,hideHeader:t=!1,internal:a=!1}){let[r,n]=(0,Pe.useState)("entry"),[i,o]=(0,Pe.useState)(null),[l,c]=(0,Pe.useState)(""),p=(0,Pe.useRef)(null),[f,b]=(0,Pe.useState)(0),[d,h]=(0,Pe.useState)(null),[w,M]=(0,Pe.useState)(!1),{cart:D,addToCart:m,removeFromCart:u,updateCartQty:g,updateCartSellUnits:v,updateCartConversions:N,clearCart:A}=An(),[T,z]=(0,Pe.useState)(!1),G=(0,Pe.useRef)(new Map),K=(0,Pe.useRef)(null),fe=Gs("quick-quote",K);(0,Pe.useEffect)(()=>{fe("viewed")},[fe]),(0,Pe.useEffect)(()=>{for(let ee of Object.values(D))ua(ee).requiredSellUnits!=null&&G.current.delete(ee.lineId);let ye=Object.values(D).filter(ee=>{if(ee.productId==="-"||ua(ee).requiredSellUnits!=null)return!1;let se=`${ee.productId}|${ee.qty}|${ee.unit}`;return G.current.get(ee.lineId)===se?!1:(G.current.set(ee.lineId,se),!0)});ye.length!==0&&fetch(Bt("/api/catalogue/resolve-conversions"),{method:"POST",headers:{"Content-Type":"application/json",...Ga()},body:JSON.stringify({lines:ye.map(ee=>({line_id:ee.lineId,product_id:ee.productId,requested_description:ee.requestedDescription??ee.description,requested_qty:ee.qty,requested_uom:ee.unit,selected_description:ee.description,selected_uoi:ee.uoi,selected_uoi_count:ee.uoiCount,selected_conversion:{sales_uom_normalised:ee.salesUomNormalised,conversion_type:ee.conversionType,sales_unit_size:ee.salesUnitSize,sales_unit_size_uom:ee.salesUnitSizeUom,coverage_qty:ee.coverageQty,coverage_uom:ee.coverageUom}}))})}).then(ee=>ee.ok?Zt(ee):null).then(ee=>{let se={};for(let Me of ee?.data?.items??ee?.items??[]){let _e=Me?.conversion;!_e||typeof Me?.line_id!="string"||(se[Me.line_id]={conversionType:_e.conversion_type,requestUomsSupported:_e.request_uoms_supported,salesUomNormalised:_e.sales_uom_normalised,salesUnitSize:_e.sales_unit_size,salesUnitSizeUom:_e.sales_unit_size_uom,coverageQty:_e.coverage_qty,coverageUom:_e.coverage_uom,roundingRule:_e.rounding_rule,conversionConfidence:_e.conversion_confidence,conversionNotes:_e.conversion_notes})}Object.keys(se).length>0&&N(se)}).catch(()=>{})},[D,N]),(0,Pe.useEffect)(()=>{if(window.location.hash!=="#matched-products"&&window.location.hash!=="#quote-request")return;let ye=new URL(window.location.href);ye.hash="",window.history.replaceState({...window.history.state??{},boqQuoteStage:"entry"},"",ye)},[]);let Te=(0,Pe.useCallback)(ye=>{if(typeof window>"u")return;let ee=new URL(window.location.href);ee.hash=ye==="basket"?"quote-request":"matched-products",window.history.pushState({boqQuoteStage:ye},"",ee)},[]);(0,Pe.useEffect)(()=>{let ye=ee=>{let se=ee.state?.boqQuoteStage;n(se==="basket"?"basket":se==="results"&&d?"results":"entry")};return window.addEventListener("popstate",ye),()=>window.removeEventListener("popstate",ye)},[d]);let Ye=(0,Pe.useCallback)(()=>{Te("basket"),n("basket")},[Te]),Ve=(0,Pe.useCallback)(()=>{window.history.state?.boqQuoteStage==="basket"?window.history.back():n(d?"results":"entry")},[d]),it=(0,Pe.useRef)(r);(0,Pe.useEffect)(()=>{it.current!==r&&(it.current=r,window.scrollTo(0,0))},[r]);let pe=()=>{n("entry"),o(null),c(""),b(0),h(null),M(!1),A(),z(!1)},Q=(0,Pe.useCallback)(async(ye,ee,se=!0)=>{c(""),b(0);let Me=0,_e=()=>{Me=Math.min(Me+1,3),b(Me)};try{let{jobId:et}=await Ib(ye,ee,se),{promise:Ht,cancel:Tt}=ev(()=>Wb(et),5e3,_e,"schedule");p.current=Tt;let tt=await Ht;if(tt.status==="failed"||!tt.result)throw new Error(tt.error||"Failed to process schedule");let ct=tt.result.lineItems.length,He=tt.result.results.filter(E=>E.candidates.length>0).length;fe("results_shown",{lines:ct,matched:He,unmatched:ct-He}),M(!1),h(tt.result),Te("results"),n("results")}catch(et){fe("error",{stage:"matching"}),c(et?.message||"Failed to process schedule"),n("entry")}finally{p.current?.(),p.current=null}},[Te,fe]),ce=(0,Pe.useCallback)(async(ye,ee,se=!0)=>{let Me=ye.trim();if(!Me)return;o("schedule");let _e=new File([Me],"pasted-schedule.txt",{type:"text/plain"});await Q(_e,ee,se)},[Q]),xe=(0,Pe.useCallback)(async ye=>{o("schedule"),await Q(ye)},[Q]);return(0,Na.jsx)(Zo.Provider,{value:fe,children:(0,Na.jsx)("div",{ref:K,className:`app-wrapper${e?"":" app-wrapper--embedded"}${t?" app-wrapper--no-header":""}${!e&&r==="processing"?" app-wrapper--loading":""}`,style:pr().theme,children:(0,Na.jsxs)("main",{className:"main-content",children:[l&&(0,Na.jsxs)("div",{className:"error-box",role:"alert",children:[(0,Na.jsx)("strong",{children:"Error:"})," ",l]}),r==="entry"&&(0,Na.jsx)(cd,{onPasteSchedule:ce,onUploadSchedule:xe,onEntryModeChange:o}),r==="results"&&i==="schedule"&&d&&(0,Na.jsx)(hd,{scheduleResult:d,onStartOver:pe,cart:D,onAddToCart:m,onRemoveFromCart:u,onGoToBasket:Ye,cartSeeded:T,onCartSeeded:()=>z(!0),reviewGateComplete:w,onReviewGateComplete:()=>M(!0),internal:a}),r==="basket"&&(0,Na.jsx)(rl,{cart:D,onUpdateQty:g,onUpdateSellUnits:v,onRemove:u,onBack:Ve,onStartNewQuote:pe,internal:a})]})})})}var Va=Y(Xe());var ki=Y(Xe()),te=Y(ae()),nw=[{id:"ogee",label:"Ogee",blurb:"Traditional curved profile"},{id:"torus",label:"Torus",blurb:"Soft rounded detail"},{id:"ovolo",label:"Ovolo",blurb:"Traditional rounded profile"},{id:"pencil-round",label:"Pencil round",blurb:"Simple softened edge"},{id:"square-edge",label:"Square edge",blurb:"Clean contemporary edge"}],Is=e=>Number.parseFloat(e)||0,ow=(e,t)=>Is(e)*(t==="m"?1:.3048),vd=(e,t)=>Is(e.quantity)*(2*ow(e.height,t)+ow(e.width,t)),__=()=>({quantity:"1",width:"",height:""});function x_({profile:e}){return(0,te.jsxs)("svg",{className:"architrave-calculator__profile-diagram",viewBox:"0 0 112 76","aria-hidden":"true",children:[(0,te.jsx)("path",{d:{ogee:"M18 62 V38 C18 28 28 22 40 22 H78 C88 22 94 28 94 38 V62",torus:"M18 62 V40 C18 27 30 20 42 20 C54 20 58 30 66 30 C74 30 78 20 90 20 C102 20 94 34 94 40 V62",ovolo:"M18 62 V38 C18 28 30 20 42 20 H70 C82 20 94 28 94 38 V62","pencil-round":"M18 62 V38 C18 28 28 20 40 20 H72 C84 20 94 28 94 38 V62","square-edge":"M18 62 V20 H94 V62"}[e]}),(0,te.jsx)("line",{x1:"12",y1:"66",x2:"100",y2:"66"})]})}function wd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,ki.useState)("m"),[i,o]=(0,ki.useState)({quantity:"1",width:"0.76",height:"1.98"}),[l,c]=(0,ki.useState)({quantity:"0",width:"1.52",height:"1.98"}),[p,f]=(0,ki.useState)([]),[b,d]=(0,ki.useState)("ogee"),[h,w]=(0,ki.useState)("2.4"),M=(N,A,T)=>{N(z=>({...z,[A]:T}))},D=vd(i,r)+vd(l,r)+p.reduce((N,A)=>N+vd(A,r),0),m=Is(h)>0?Math.ceil(D/Is(h)):0,u=nw.find(N=>N.id===b)?.label??"",g=[{key:`architrave-${b}`,label:`Architrave (${u})`,qty:D,unit:"m",query:`${u} architrave`,category:"architrave"}],v=(N,A,T,z)=>(0,te.jsxs)("div",{className:"architrave-calculator__opening-row",children:[(0,te.jsx)("span",{children:N}),(0,te.jsx)("input",{"aria-label":`${N} quantity`,type:"number",min:"0",step:"1",value:A.quantity,onChange:G=>T("quantity",G.target.value)}),(0,te.jsx)("input",{"aria-label":`${N} width`,type:"number",min:"0",step:"0.01",value:A.width,onChange:G=>T("width",G.target.value)}),(0,te.jsx)("input",{"aria-label":`${N} height`,type:"number",min:"0",step:"0.01",value:A.height,onChange:G=>T("height",G.target.value)}),z?(0,te.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:z,children:"Remove"}):null]});return(0,te.jsx)(te.Fragment,{children:(0,te.jsxs)("div",{className:"truss-estimator",children:[(0,te.jsxs)("div",{className:"quick-order-hero",children:[(0,te.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,te.jsx)("h1",{children:"Architrave Calculator"}),(0,te.jsx)("p",{children:"Estimate architrave lengths and board quantities for door openings."})]}),(0,te.jsxs)("div",{className:"truss-estimator__card architrave-calculator",children:[(0,te.jsx)("h2",{className:"truss-estimator__step-title",children:"Measure your openings"}),(0,te.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter each door or window opening. Mitred corners are allowed for, and board lengths are worked out from the net run."}),(0,te.jsxs)("div",{className:"architrave-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Door openings"}),(0,te.jsx)("p",{className:"architrave-calculator__hint",children:"Each opening is calculated as two side pieces plus one head piece."}),(0,te.jsxs)("div",{className:"architrave-calculator__unit-row",children:[(0,te.jsx)("span",{children:"Units"}),(0,te.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,te.jsx)("button",{type:"button",className:r==="m"?"is-selected":"",onClick:()=>n("m"),children:"Metres"}),(0,te.jsx)("button",{type:"button",className:r==="ft"?"is-selected":"",onClick:()=>n("ft"),children:"Feet"})]})]}),(0,te.jsxs)("div",{className:"architrave-calculator__dimensions-header",children:[(0,te.jsx)("span",{children:"Opening"}),(0,te.jsx)("span",{children:"Qty"}),(0,te.jsxs)("span",{children:["Width (",r,")"]}),(0,te.jsxs)("span",{children:["Height (",r,")"]}),(0,te.jsx)("span",{})]}),v("Single doors",i,(N,A)=>M(o,N,A)),v("Double doors",l,(N,A)=>M(c,N,A)),p.map((N,A)=>v(`Alternative door ${A+1}`,N,(T,z)=>f(G=>G.map((K,fe)=>fe===A?{...K,[T]:z}:K)),()=>f(T=>T.filter((z,G)=>G!==A)))),(0,te.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>f(N=>[...N,__()]),children:"+ Add alternative-sized door"})]}),(0,te.jsxs)("div",{className:"architrave-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Standard profile"}),(0,te.jsx)("p",{className:"architrave-calculator__hint",children:"Choose the profile you plan to use. Length calculations are the same for each profile."}),(0,te.jsx)("div",{className:"architrave-calculator__profiles",children:nw.map(N=>(0,te.jsxs)("button",{type:"button",className:`truss-estimator__option-card${b===N.id?" is-selected":""}`,onClick:()=>d(N.id),children:[(0,te.jsx)(x_,{profile:N.id}),(0,te.jsx)("div",{className:"truss-estimator__option-title",children:N.label}),(0,te.jsx)("div",{className:"truss-estimator__option-copy",children:N.blurb})]},N.id))})]}),(0,te.jsxs)("div",{className:"architrave-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Board and waste"}),(0,te.jsx)("div",{className:"architrave-calculator__options",children:(0,te.jsxs)("label",{className:"truss-estimator__field",children:[(0,te.jsx)("span",{children:"Board length (m)"}),(0,te.jsx)("input",{value:"4.40 m",disabled:!0})]})}),(0,te.jsx)("p",{className:"architrave-calculator__hint",children:"Waste allows for mitred corners, cuts and damaged lengths."})]}),(0,te.jsxs)("div",{className:"architrave-calculator__totals",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,te.jsxs)("div",{className:"architrave-calculator__result-grid",children:[(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"Architrave needed"}),(0,te.jsxs)("strong",{children:[D.toFixed(2)," m"]})]}),(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"Board lengths"}),(0,te.jsx)("strong",{children:m})]})]})]}),(0,te.jsxs)("div",{className:"architrave-calculator__actions",children:[(0,te.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,te.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(g),disabled:D<=0,children:a})]})]})]})})}var Ni=Y(Xe()),le=Y(ae()),lw=60,sw=10,k_=.02,N_=.012,S_=.01,Rn=e=>Number.parseFloat(e)||0,C_=(e,t=2)=>e.toFixed(t);function yd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,Ni.useState)("brick"),[i,o]=(0,Ni.useState)("engineering-red"),[l,c]=(0,Ni.useState)("metric"),[p,f]=(0,Ni.useState)(""),[b,d]=(0,Ni.useState)(""),[h,w]=(0,Ni.useState)(!0),M=l==="metric"?Rn(p)*Rn(b):Rn(p)*Rn(b)*.092903,m=M*(r==="brick"?lw:sw),u=Math.ceil(m),g=M*(r==="brick"?k_:N_),v=Math.ceil(g/S_),N=l==="metric"?M:M*10.7639,A=[{key:r==="brick"?`brick-${i}`:"block",label:r==="brick"?{common:"Common concrete bricks","engineering-red":"Red engineering bricks","engineering-blue":"Blue engineering bricks"}[i]:"Blocks",qty:u,unit:"each",query:r==="brick"?"facing brick":"concrete block",category:"masonry"},...h?[{key:"mortar",label:"Blue Circle Quality Assured Mortar Mix 20kg",qty:v,unit:"bag",query:"ready mixed mortar",category:"mortar"}]:[]],T=z=>{if(z===l)return;let G=z==="imperial"?3.28084:.3048;f((Rn(p)*G).toFixed(2)),d((Rn(b)*G).toFixed(2)),c(z)};return(0,le.jsx)(le.Fragment,{children:(0,le.jsxs)("div",{className:"truss-estimator",children:[(0,le.jsxs)("div",{className:"quick-order-hero",children:[(0,le.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,le.jsx)("h1",{children:"Brick & Block Calculator"}),(0,le.jsx)("p",{children:"Estimate masonry units, sand and cement for a wall."})]}),(0,le.jsxs)("div",{className:"truss-estimator__card brick-calculator",children:[(0,le.jsx)("h2",{className:"truss-estimator__step-title",children:"Wall area and masonry type"}),(0,le.jsx)("p",{className:"truss-estimator__step-sub",children:"Pick brick or block and enter the wall dimensions for unit counts plus ready-mixed mortar."}),(0,le.jsxs)("div",{className:"brick-calculator__section",children:[(0,le.jsx)("div",{className:"truss-estimator__section-heading",children:"Masonry type"}),(0,le.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[["brick","Brick"],["block","Block"]].map(([z,G])=>(0,le.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===z?" is-selected":""}`,onClick:()=>n(z),children:[(0,le.jsx)("div",{className:"truss-estimator__option-title",children:G}),(0,le.jsxs)("div",{className:"truss-estimator__option-copy",children:["Approx. ",z==="brick"?lw:sw," per m\xB2"]})]},z))})]}),r==="brick"&&(0,le.jsxs)("div",{className:"brick-calculator__section",children:[(0,le.jsx)("div",{className:"truss-estimator__section-heading",children:"Brick type"}),(0,le.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:[["common","Common concrete","General-purpose grey concrete brick"],["engineering-red","Engineering red","Class B perforated, 65mm"],["engineering-blue","Engineering blue","Class B solid, 65mm"]].map(([z,G,K])=>(0,le.jsxs)("button",{type:"button",className:`truss-estimator__option-card${i===z?" is-selected":""}`,onClick:()=>o(z),children:[(0,le.jsx)("div",{className:"truss-estimator__option-title",children:G}),(0,le.jsx)("div",{className:"truss-estimator__option-copy",children:K})]},z))})]}),(0,le.jsxs)("div",{className:"brick-calculator__section",children:[(0,le.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall dimensions"}),(0,le.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,le.jsx)("button",{type:"button",className:l==="metric"?"is-selected":"",onClick:()=>T("metric"),children:"Metric"}),(0,le.jsx)("button",{type:"button",className:l==="imperial"?"is-selected":"",onClick:()=>T("imperial"),children:"Imperial"})]}),(0,le.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,le.jsxs)("label",{className:"truss-estimator__field",children:[(0,le.jsxs)("span",{children:["Height (",l==="metric"?"m":"ft",")"]}),(0,le.jsx)("input",{type:"number",min:"0",step:"0.01",value:p,onChange:z=>f(z.target.value)})]}),(0,le.jsxs)("label",{className:"truss-estimator__field",children:[(0,le.jsxs)("span",{children:["Width (",l==="metric"?"m":"ft",")"]}),(0,le.jsx)("input",{type:"number",min:"0",step:"0.01",value:b,onChange:z=>d(z.target.value)})]})]})]}),(0,le.jsx)("div",{className:"brick-calculator__options",children:(0,le.jsxs)("label",{className:"brick-calculator__checkbox",children:[(0,le.jsx)("input",{type:"checkbox",checked:h,onChange:z=>w(z.target.checked)}),(0,le.jsx)("span",{children:"Include ready-mixed mortar"})]})}),(0,le.jsxs)("div",{className:"brick-calculator__totals",children:[(0,le.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,le.jsxs)("div",{className:"brick-calculator__result-grid",children:[(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{children:"Wall area"}),(0,le.jsxs)("strong",{children:[C_(N)," ",l==="metric"?"m\xB2":"ft\xB2"]})]}),(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{children:r==="brick"?"Bricks":"Blocks"}),(0,le.jsx)("strong",{children:u.toLocaleString("en-GB")})]}),h?(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{children:"Ready-mixed mortar"}),(0,le.jsxs)("strong",{children:[v," x 20kg bags"]})]}):null]}),(0,le.jsx)("p",{className:"brick-calculator__note",children:"Estimate based on standard nominal sizes and 10mm joints. Mortar bags are approximate; confirm the required mortar specification before ordering."})]}),(0,le.jsxs)("div",{className:"brick-calculator__actions",children:[(0,le.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,le.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(A),disabled:M<=0,children:a})]})]})]})})}var fr=Y(Xe());var cw=new Map;function q_(e){return{product_id:e.product_id,description:e.description,source_list:e.source_list??null,price:e.price??null,list_price:e.list_price,discount:e.discount,price_basis:e.price_basis??null,uoi_count:e.uoi_count??null,uoi:e.uoi??null,pdp_photo_url:e.pdp_photo_url??null,conversion:e.conversion,measurements_mm:e.measurements_mm??e.attrs?.measurements_mm??[],scores:{dimension:0,grade:0,brand:0,fuzzy:0,bm25:0,overall:0},method:"estimator_catalogue_search"}}async function Jr(e,t,a=12,r){let n=`${e}||${t??""}||${a}||${r??""}`,i=cw.get(n);if(i)return i;let o=new URLSearchParams({q:e,limit:String(a)});t&&o.set("category",t),r&&o.set("account",r);let l=await fetch(Bt(`/api/catalogue/search?${o.toString()}`),{headers:wi()}),c=await Zt(l);if(!l.ok)throw new Error(c?.error||c?.message||"Could not reach the product catalogue");let p=Array.isArray(c?.items)?c.items.map(q_):[];return cw.set(n,p),p}async function uw(e,t){return await Promise.all(e.map(async r=>{try{return{requirement:r,candidates:await Jr(r.query,r.category,void 0,t)}}catch{return{requirement:r,candidates:[]}}}))}async function pw(){let e=await fetch(Bt("/api/catalogue"),{headers:wi()});if(!e.ok)return{itemCount:0,uploadedAt:null};let t=await Zt(e);return{itemCount:Number(t?.itemCount)||0,uploadedAt:t?.uploadedAt??null}}var $=Y(ae()),E_=1.54,M_=1440,T_=25,_d=800,z_=1500,xd=e=>Number.parseFloat(e)||0,Un={mot:{label:"MOT Type 1",blurb:"Sub-base for patios and driveways",density:1.7,productId:"6001007"},"sharp-sand":{label:"Sharp sand",blurb:"Bedding and general groundwork",density:1.6,productId:"6001012"},gravel:{label:"20mm gravel",blurb:"Drainage and landscaping",density:1.6,productId:"6001004"}};function kd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let r=Js(),[n,i]=(0,fr.useState)("m"),[o,l]=(0,fr.useState)(""),[c,p]=(0,fr.useState)(""),[f,b]=(0,fr.useState)(""),[d,h]=(0,fr.useState)("concrete"),[w,M]=(0,fr.useState)("mot"),[D,m]=(0,fr.useState)(!1),[u,g]=(0,fr.useState)(null),v=n==="m"?1:.3048,N=xd(o)*v*xd(c)*v*xd(f)*(n==="m"?.01:.0254),A=Un[w],T=N*E_/7,z=T*M_,G=T*2,K=T*4,fe=Math.ceil(z/T_),Te=Math.ceil(G*Un["sharp-sand"].density*1e3/_d),Ye=Math.ceil(K*Un.gravel.density*1e3/_d),Ve=Math.ceil(N*A.density*1e3/_d),it=d==="concrete"?[{key:"cement",label:"Blue Circle General Purpose Grey Cement 25kg",qty:fe,productId:"6003004"},{key:"sharp-sand",label:"Sharp Sand Bulk Bag (800kg)",qty:Te,productId:"6001012"},{key:"gravel",label:"20mm Non Decorative Pea Shingle/Gravel Bulk Bag (800kg)",qty:Ye,productId:"6001004"}]:[{key:w,label:`${A.label} Bulk Bag (800kg)`,qty:Ve,productId:A.productId}],pe=()=>{if(t){t(it.map(ce=>({key:ce.key,label:ce.label,qty:ce.qty,unit:"each",query:ce.productId})));return}Q()},Q=async()=>{let ce=Date.now();m(!0),g(null);try{let xe=await Promise.all(it.map(async ee=>{let se=(await Jr(ee.productId)).find(Me=>Me.product_id===ee.productId);if(!se)throw new Error(`${ee.label} is no longer available in this catalogue.`);return Kr(se,{lineId:`concrete-aggregate:${ee.key}`,description:ee.label,unit:"bag",qty:ee.qty})})),ye=z_-(Date.now()-ce);ye>0&&await new Promise(ee=>window.setTimeout(ee,ye)),r?.clearCart(),r?.addManyToCart(xe),r?.openBasket()}catch(xe){g(xe instanceof Error?xe.message:"Could not add the products to your basket.")}finally{m(!1)}};return D?(0,$.jsx)($.Fragment,{children:(0,$.jsxs)("div",{className:"truss-estimator",children:[(0,$.jsxs)("div",{className:"quick-order-hero",children:[(0,$.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,$.jsx)("h1",{children:"Your Materials"}),(0,$.jsx)("p",{children:"Calculating quantities from the Concrete & Aggregate Calculator."})]}),(0,$.jsx)("div",{className:"truss-estimator__card",children:(0,$.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{flex:1,justifyContent:"center"},children:[(0,$.jsx)(dr,{}),(0,$.jsx)("p",{className:"banter-message is-visible",children:"Preparing your materials\u2026"})]})})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)("div",{className:"truss-estimator",children:[(0,$.jsxs)("div",{className:"quick-order-hero",children:[(0,$.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,$.jsx)("h1",{children:"Concrete & Aggregate Calculator"}),(0,$.jsx)("p",{children:"Calculate fixed site-mix concrete ingredients or aggregate bulk bags."})]}),(0,$.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,$.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose what you need"}),(0,$.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter the area and depth. The calculator adds the fixed Materials Market products directly to your basket."}),(0,$.jsxs)("div",{className:"materials-calculator__section",children:[(0,$.jsx)("div",{className:"truss-estimator__section-heading",children:"Material type"}),(0,$.jsxs)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[(0,$.jsxs)("button",{type:"button",className:`truss-estimator__option-card${d==="concrete"?" is-selected":""}`,onClick:()=>h("concrete"),children:[(0,$.jsx)("div",{className:"truss-estimator__option-title",children:"Site-mixed concrete"}),(0,$.jsx)("div",{className:"truss-estimator__option-copy",children:"Cement, sharp sand and 20mm aggregate"})]}),(0,$.jsxs)("button",{type:"button",className:`truss-estimator__option-card${d==="aggregate"?" is-selected":""}`,onClick:()=>h("aggregate"),children:[(0,$.jsx)("div",{className:"truss-estimator__option-title",children:"Aggregates"}),(0,$.jsx)("div",{className:"truss-estimator__option-copy",children:"MOT Type 1, sharp sand or 20mm gravel"})]})]})]}),d==="aggregate"&&(0,$.jsxs)("div",{className:"materials-calculator__section",children:[(0,$.jsx)("div",{className:"truss-estimator__section-heading",children:"Aggregate type"}),(0,$.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.keys(Un).map(ce=>(0,$.jsxs)("button",{type:"button",className:`truss-estimator__option-card${w===ce?" is-selected":""}`,onClick:()=>M(ce),children:[(0,$.jsx)("div",{className:"truss-estimator__option-title",children:Un[ce].label}),(0,$.jsx)("div",{className:"truss-estimator__option-copy",children:Un[ce].blurb})]},ce))})]}),(0,$.jsxs)("div",{className:"materials-calculator__section",children:[(0,$.jsx)("div",{className:"truss-estimator__section-heading",children:"Area and depth"}),(0,$.jsxs)("div",{className:"materials-calculator__unit-row",children:[(0,$.jsx)("span",{children:"Units"}),(0,$.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,$.jsx)("button",{type:"button",className:n==="m"?"is-selected":"",onClick:()=>i("m"),children:"Metric"}),(0,$.jsx)("button",{type:"button",className:n==="ft"?"is-selected":"",onClick:()=>i("ft"),children:"Imperial"})]})]}),(0,$.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,$.jsxs)("label",{className:"truss-estimator__field",children:[(0,$.jsxs)("span",{children:["Length (",n,")"]}),(0,$.jsx)("input",{type:"number",min:"0",step:"0.01",value:o,onChange:ce=>l(ce.target.value)})]}),(0,$.jsxs)("label",{className:"truss-estimator__field",children:[(0,$.jsxs)("span",{children:["Width (",n,")"]}),(0,$.jsx)("input",{type:"number",min:"0",step:"0.01",value:c,onChange:ce=>p(ce.target.value)})]})]}),(0,$.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,$.jsxs)("span",{children:["Depth (",n==="m"?"cm":"inches",")"]}),(0,$.jsx)("input",{type:"number",min:"0",step:"0.1",value:f,onChange:ce=>b(ce.target.value)})]})]}),(0,$.jsxs)("div",{className:"materials-calculator__totals",children:[(0,$.jsx)("div",{className:"truss-estimator__section-heading",children:"Materials required"}),(0,$.jsx)("div",{className:"materials-calculator__result-grid",children:d==="concrete"?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:"Cement"}),(0,$.jsxs)("strong",{children:[z.toFixed(0)," kg"]})]}),(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:"Sharp sand"}),(0,$.jsxs)("strong",{children:[G.toFixed(2)," m\xB3"]})]}),(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:"20mm aggregate"}),(0,$.jsxs)("strong",{children:[K.toFixed(2)," m\xB3"]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:A.label}),(0,$.jsxs)("strong",{children:[N.toFixed(2)," m\xB3"]})]}),(0,$.jsxs)("div",{children:[(0,$.jsx)("span",{children:"Approx. weight"}),(0,$.jsxs)("strong",{children:[(N*A.density).toFixed(2)," t"]})]}),(0,$.jsx)("div",{})]})}),(0,$.jsx)("p",{className:"materials-calculator__note",children:d==="concrete"?"Based on a 1:2:4 mix. Confirm the mix design for structural work.":"Figures are estimates. Confirm the specification and supplier quantities before ordering."})]}),u&&(0,$.jsx)("p",{className:"results-empty-hint estimator-products__error",children:u}),(0,$.jsxs)("div",{className:"materials-calculator__actions",children:[(0,$.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,$.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:pe,disabled:N<=0||D,children:D?"Adding products\u2026":a})]})]})]})})}var Ya=Y(Xe());var U=Y(ae()),Dn=12,Bn=8,Ws=.56,dw=.21,Sa={ranges:{meridian:{label:"Standard grooved timber",blurb:"32 \xD7 125mm pressure-treated softwood boards.",boardLengthM:3.6,boardWidthM:.125},summit:{label:"Wide grooved timber",blurb:"32 \xD7 150mm pressure-treated softwood boards.",boardLengthM:3.6,boardWidthM:.15}},boardGapM:.006,wastage:{straight:.05,diagonal:.15},pictureFrame:{extraWastage:.08},joist:{lengthM:2.4,spacingOptions:[{id:"300",label:"300mm centres (heavy duty)",spacingM:.3},{id:"400",label:"400mm centres (standard)",spacingM:.4},{id:"450",label:"450mm centres (light use)",spacingM:.45}]}},Si=["range","grid","pictureFrame","substructure"],A_={range:null,colour:null,deckSizeMode:"quick",quickLengthM:"",quickWidthM:"",points:[],isOutlineClosed:!1,wallSegments:new Set,drawMode:"outline",drawError:"",pictureFrame:null,direction:null,deckHeightMode:"standard",deckHeightCm:"",joistSpacing:null,supportType:null,contact:{name:"",email:""}},ec=(e,t,a)=>(t.x-e.x)*(a.y-e.y)-(t.y-e.y)*(a.x-e.x),tc=(e,t,a)=>a.x>=Math.min(e.x,t.x)&&a.x<=Math.max(e.x,t.x)&&a.y>=Math.min(e.y,t.y)&&a.y<=Math.max(e.y,t.y),R_=(e,t,a,r)=>{let n=ec(e,t,a),i=ec(e,t,r),o=ec(a,r,e),l=ec(a,r,t);return n===0&&tc(e,t,a)||i===0&&tc(e,t,r)||o===0&&tc(a,r,e)||l===0&&tc(a,r,t)?!0:n>0!=i>0&&o>0!=l>0},Nd=(e,t)=>{let a=t?e.length:e.length-1;for(let r=0;r<a;r+=1){let n=e[(r+1)%e.length];for(let i=r+1;i<a;i+=1)if(!(i===r+1||t&&r===0&&i===a-1)&&R_(e[r],n,e[i],e[(i+1)%e.length]))return!0}return!1};function Sd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,Ya.useState)(0),[i,o]=(0,Ya.useState)(A_),[l,c]=(0,Ya.useState)(1),[p,f]=(0,Ya.useState)({x:0,y:0}),[b,d]=(0,Ya.useState)(null),h=(0,Ya.useRef)(null),w=(0,Ya.useRef)(null),M=(0,Ya.useRef)(null),D=Si[r],m=i.range?Sa.ranges[i.range]:null,u=Dn/l,g=Bn/l,v=(Dn-u)/2,N=(Bn-g)/2,A=Math.max(-Dn,Math.min(Dn*2-u,v+p.x)),T=Math.max(-Bn,Math.min(Bn*2-g,N+p.y)),z=Number.parseFloat(i.quickLengthM),G=Number.parseFloat(i.quickWidthM),K=z>0&&G>0,fe=E=>Math.abs(E.reduce((x,R,I)=>{let ue=E[(I+1)%E.length];return x+R.x*ue.y-ue.x*R.y},0))/2,Te=(E,x)=>Math.hypot(x.x-E.x,x.y-E.y),Ye=i.isOutlineClosed?fe(i.points):0,Ve=i.isOutlineClosed?i.points.reduce((E,x,R)=>E+Te(x,i.points[(R+1)%i.points.length]),0):0,it=i.isOutlineClosed?i.points.reduce((E,x,R)=>E+(i.wallSegments.has(R)?0:Te(x,i.points[(R+1)%i.points.length])),0):0,pe=i.points.reduce((E,x)=>({x:E.x+x.x/i.points.length,y:E.y+x.y/i.points.length}),{x:0,y:0}),Q=i.points.length>1?(()=>{let E=i.points[0],x=i.points[1],R=Te(E,x),I=R?-(x.y-E.y)/R:0,ue=R?(x.x-E.x)/R:0,ve=(E.x+x.x)/2,Se=(E.y+x.y)/2,k=I*(ve-pe.x)+ue*(Se-pe.y)>=0?1:-1;return{x:ve+I*Ws*k,y:Se+ue*Ws*k}})():null,xe=(()=>{let E=i.range?Sa.ranges[i.range]:Sa.ranges.meridian,x=i.deckSizeMode==="quick"?z*G:Ye,R=i.deckSizeMode==="quick"?2*(z+G):it,I=i.direction==="diagonal"?Sa.wastage.diagonal:Sa.wastage.straight,ue=i.pictureFrame==="yes"?Sa.pictureFrame.extraWastage:0,Se=x/(E.boardWidthM+Sa.boardGapM)/E.boardLengthM,k=Math.ceil(Se*(1+I+ue)),j=Math.ceil(x*30*(1+I+ue)/200),O=Sa.joist.spacingOptions.find(C=>C.id===i.joistSpacing)??Sa.joist.spacingOptions[1],ne=x/O.spacingM,W=Math.ceil(ne/Sa.joist.lengthM);return{range:E,area:x,boardCount:k,screwBoxes:j,joistLengthsNeeded:W,spacing:O}})(),ye=xe?[{key:`boards-${i.range??"meridian"}`,label:`Deck boards (${xe.range.label})`,qty:xe.boardCount,unit:"each",query:"timber decking board",category:"decking",calculatorWasteIncluded:!0},{key:"joists",label:"Treated C24 joists",qty:xe.joistLengthsNeeded,unit:"each",query:"treated joist",category:"timber",calculatorWasteIncluded:!0},{key:"screws",label:"Green decking screws (200/box)",qty:xe.screwBoxes,unit:"box",query:"green decking screws",category:"fixings",calculatorWasteIncluded:!0}]:[],ee=()=>D==="range"?!!i.range:D==="grid"?i.deckSizeMode==="quick"?K:i.isOutlineClosed&&Ye>0:D==="pictureFrame"?!!i.pictureFrame&&!!i.direction:D==="substructure"?!!i.joistSpacing:!0,se=r===Si.length-1?a:"Next",Me=(E,x,R=!1)=>{let I=M.current?.getBoundingClientRect();if(!I)return null;let ue=R?1:.25;return{x:Math.round(Math.max(A,Math.min(A+u,A+(E-I.left)/I.width*u))/ue)*ue,y:Math.round(Math.max(T,Math.min(T+g,T+(x-I.top)/I.height*g))/ue)*ue}},_e=E=>{if(i.isOutlineClosed){let R=E.target;if(R!==E.currentTarget&&!R.classList.contains("deck-outline__grid"))return;w.current={startX:E.clientX,startY:E.clientY,startViewX:A,startViewY:T},E.currentTarget.setPointerCapture(E.pointerId);return}if(i.drawMode!=="outline")return;let x=Me(E.clientX,E.clientY,!0);x&&(d(null),o(R=>{let I=[...R.points,x];return Nd(I,!1)?{...R,drawError:"Edges cannot cross. Choose another corner."}:{...R,points:I,drawError:""}}))},et=(E,x)=>{if(!i.isOutlineClosed){E.stopPropagation(),x===0&&i.points.length>=3&&o(R=>({...R,isOutlineClosed:!0,drawMode:"edges"}));return}E.stopPropagation(),h.current=x,E.currentTarget.setPointerCapture(E.pointerId)},Ht=E=>{if(w.current){let I=M.current?.getBoundingClientRect();if(!I)return;let ue=w.current,ve=ue.startViewX-(E.clientX-ue.startX)/I.width*u,Se=ue.startViewY-(E.clientY-ue.startY)/I.height*g;f({x:ve-v,y:Se-N});return}!i.isOutlineClosed&&i.drawMode==="outline"&&d(Me(E.clientX,E.clientY,!0));let x=h.current;if(x===null)return;let R=Me(E.clientX,E.clientY);R&&o(I=>{let ue=I.points.map((ve,Se)=>Se===x?R:ve);return Nd(ue,!0)?{...I,drawError:"Edges cannot cross. Move the corner to a different position."}:{...I,points:ue,drawError:""}})},Tt=E=>{w.current=null,h.current=null,E.currentTarget.hasPointerCapture(E.pointerId)&&E.currentTarget.releasePointerCapture(E.pointerId)},tt=E=>{o(x=>{let R=new Set(x.wallSegments);return R.has(E)?R.delete(E):R.add(E),{...x,wallSegments:R}})},ct=()=>{r===0?e():n(E=>E-1)},He=()=>{ee()&&(r===Si.length-1?t?.(ye):n(E=>E+1))};return(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)("div",{className:"truss-estimator",children:[(0,U.jsxs)("div",{className:"quick-order-hero",children:[(0,U.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,U.jsx)("h1",{children:"Decking Calculator"}),(0,U.jsx)("p",{children:"Estimate timber boards, joists and screws for your deck."})]}),(0,U.jsxs)("div",{className:"truss-estimator__card",children:[(0,U.jsxs)("div",{className:"truss-estimator__body",children:[D==="range"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Si.length]}),(0,U.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your timber decking"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"Both options are fixed, orderable pressure-treated timber boards."}),(0,U.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Sa.ranges).map(([E,x])=>(0,U.jsxs)("button",{type:"button",className:`truss-estimator__option-card${i.range===E?" is-selected":""}`,onClick:()=>o(R=>({...R,range:E})),children:[(0,U.jsx)("div",{className:"truss-estimator__option-title",children:x.label}),(0,U.jsx)("div",{className:"truss-estimator__option-copy",children:x.blurb}),(0,U.jsxs)("div",{className:"truss-estimator__option-copy",children:[x.boardLengthM,"m boards"]})]},E))})]}):null,D==="grid"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Si.length]}),(0,U.jsx)("h2",{className:"truss-estimator__step-title",children:"Tell us your deck size"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"Start with a quick rectangle estimate, or draw an irregular deck for a more precise result."}),(0,U.jsxs)("div",{className:"truss-estimator__toggle-row",children:[(0,U.jsx)("button",{type:"button",className:`truss-estimator__toggle${i.deckSizeMode==="quick"?" is-selected":""}`,onClick:()=>o(E=>({...E,deckSizeMode:"quick"})),children:"Quick estimate"}),(0,U.jsx)("button",{type:"button",className:`truss-estimator__toggle${i.deckSizeMode==="draw"?" is-selected":""}`,onClick:()=>o(E=>({...E,deckSizeMode:"draw",drawMode:"outline"})),children:"Draw your space"})]}),i.deckSizeMode==="quick"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,U.jsxs)("label",{className:"truss-estimator__field",children:[(0,U.jsx)("span",{children:"Length (m)"}),(0,U.jsx)("input",{type:"number",inputMode:"decimal",min:"0.1",step:"0.1",value:i.quickLengthM,onChange:E=>o(x=>({...x,quickLengthM:E.target.value}))})]}),(0,U.jsxs)("label",{className:"truss-estimator__field",children:[(0,U.jsx)("span",{children:"Width (m)"}),(0,U.jsx)("input",{type:"number",inputMode:"decimal",min:"0.1",step:"0.1",value:i.quickWidthM,onChange:E=>o(x=>({...x,quickWidthM:E.target.value}))})]})]}),(0,U.jsx)("div",{className:"truss-estimator__grid-hint",children:"For L-shaped decks, cut-outs, or sides against a wall, use Draw your space."}),K?(0,U.jsxs)("div",{className:"truss-estimator__grid-stats",children:[(0,U.jsxs)("div",{children:[(z*G).toFixed(2)," m\xB2 deck"]}),(0,U.jsxs)("div",{children:[(2*(z+G)).toFixed(2)," m perimeter"]})]}):null]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"truss-estimator__section-heading",children:"Draw your deck"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"Click to add corners, then close the outline. Drag any handle to refine it."}),(0,U.jsxs)("div",{className:"deck-outline__toolbar",children:[i.isOutlineClosed?(0,U.jsxs)("div",{className:"deck-outline__summary",children:[(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{children:"Deck area"}),(0,U.jsxs)("strong",{children:[Ye.toFixed(2)," m\xB2"]})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{children:"Perimeter"}),(0,U.jsxs)("strong",{children:[Ve.toFixed(2)," m"]})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{children:"Wall edges"}),(0,U.jsx)("strong",{children:i.wallSegments.size>0?i.wallSegments.size:"None"})]}),(0,U.jsxs)("div",{children:[(0,U.jsx)("span",{children:"Visible edge"}),(0,U.jsxs)("strong",{children:[it.toFixed(2)," m"]})]})]}):null,(0,U.jsxs)("div",{className:"deck-outline__actions",children:[(0,U.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(E=>({...E,points:E.points.slice(0,-1)})),disabled:i.points.length===0||i.isOutlineClosed,children:"Undo"}),(0,U.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>{d(null),o(E=>({...E,points:[],isOutlineClosed:!1,wallSegments:new Set,drawMode:"outline",drawError:""}))},disabled:i.points.length===0,children:"Clear"}),(0,U.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(E=>({...E,points:[{x:2,y:2},{x:8,y:2},{x:8,y:5},{x:2,y:5}],isOutlineClosed:!0,wallSegments:new Set,drawMode:"edges",drawError:""})),children:"Start with rectangle"})]})]}),(0,U.jsx)("div",{className:"deck-editor-layout",children:(0,U.jsxs)("div",{className:"deck-editor-layout__canvas-column",children:[(0,U.jsxs)("div",{className:"deck-outline",children:[(0,U.jsxs)("svg",{ref:M,className:`deck-outline__canvas${i.isOutlineClosed?" is-pan-mode":""}`,viewBox:`${A} ${T} ${u} ${g}`,preserveAspectRatio:"none","aria-label":"Deck outline drawing area",onPointerDown:_e,onPointerMove:Ht,onPointerUp:Tt,onPointerLeave:()=>{d(null),w.current||(h.current=null)},children:[(0,U.jsx)("defs",{children:(0,U.jsx)("pattern",{id:"deck-outline-grid",width:"1",height:"1",patternUnits:"userSpaceOnUse",children:(0,U.jsx)("path",{d:"M 1 0 L 0 0 0 1",fill:"none",stroke:"currentColor",strokeWidth:"0.03"})})}),(0,U.jsx)("rect",{x:-Dn,y:-Bn,width:Dn*3,height:Bn*3,className:"deck-outline__grid",fill:"url(#deck-outline-grid)"}),i.points.length>1?(0,U.jsx)("polyline",{className:"deck-outline__preview",points:i.points.map(E=>`${E.x},${E.y}`).join(" ")}):null,i.isOutlineClosed?(0,U.jsx)("polygon",{className:"deck-outline__shape",points:i.points.map(E=>`${E.x},${E.y}`).join(" "),stroke:"none"}):null,i.points.length>1?i.points.slice(0,i.isOutlineClosed?void 0:-1).map((E,x)=>{let R=i.points[i.isOutlineClosed?(x+1)%i.points.length:x+1],I=Te(E,R),ue=I?-(R.y-E.y)/I:0,ve=I?(R.x-E.x)/I:0,Se=(E.x+R.x)/2,k=(E.y+R.y)/2,j=ue*(Se-pe.x)+ve*(k-pe.y)>=0?1:-1,O=Se+ue*Ws*j,ne=k+ve*Ws*j;return(0,U.jsxs)("g",{children:[(0,U.jsx)("line",{className:"deck-outline__edge-hit",x1:E.x,y1:E.y,x2:R.x,y2:R.y,onClick:i.isOutlineClosed?()=>tt(x):void 0}),(0,U.jsx)("line",{className:`deck-outline__edge${i.wallSegments.has(x)?" is-wall":""}`,x1:E.x,y1:E.y,x2:R.x,y2:R.y,pointerEvents:"none"}),(0,U.jsxs)("text",{className:`deck-outline__edge-label${i.wallSegments.has(x)?" is-wall":""}`,x:O,y:ne,textAnchor:"middle",dominantBaseline:"central",fontSize:dw/l,children:[I.toFixed(2)," m"]})]},`segment-${x}`)}):null,!i.isOutlineClosed&&i.points.length>0&&b?(()=>{let E=i.points[i.points.length-1],x=Te(E,b);if(!x)return null;let R=-(b.y-E.y)/x,I=(b.x-E.x)/x,ue=(E.x+b.x)/2,ve=(E.y+b.y)/2;return(0,U.jsxs)("g",{className:"deck-outline__live-measurement",children:[(0,U.jsx)("line",{x1:E.x,y1:E.y,x2:b.x,y2:b.y}),(0,U.jsxs)("text",{x:ue+R*.34,y:ve+I*.34,textAnchor:"middle",dominantBaseline:"central",fontSize:dw/l,children:[x.toFixed(2)," m"]})]})})():null,i.points.map((E,x)=>(0,U.jsx)("circle",{className:"deck-outline__point",cx:E.x,cy:E.y,r:"0.13",onPointerDown:R=>et(R,x)},`point-${x}`))]}),(0,U.jsxs)("div",{className:"deck-outline__zoom","aria-label":"Zoom controls",children:[(0,U.jsx)("button",{type:"button",onClick:()=>c(E=>Math.max(.5,E-.25)),disabled:l===.5,"aria-label":"Zoom out",children:"\u2212"}),(0,U.jsxs)("span",{children:[Math.round(l*100),"%"]}),(0,U.jsx)("button",{type:"button",onClick:()=>c(E=>Math.min(1,E+.25)),disabled:l===1,"aria-label":"Zoom in",children:"+"})]}),i.isOutlineClosed&&i.wallSegments.size===0&&Q?(0,U.jsx)("div",{className:"deck-outline__edge-prompt",role:"status",style:{left:`${(Q.x-A)/u*100}%`,top:`${(Q.y-T)/g*100}%`},children:"Tap an edge to mark it as a wall, or leave it as a visible edge."}):null,!i.isOutlineClosed&&i.points.length>=3?(0,U.jsx)("button",{type:"button",className:"deck-outline__close",onClick:()=>o(E=>Nd(E.points,!0)?{...E,drawError:"Edges cannot cross. Adjust the outline before finishing."}:{...E,isOutlineClosed:!0,drawMode:"edges",drawError:""}),children:"Finish outline"}):null]}),(0,U.jsxs)("div",{className:"deck-outline__supporting",children:[(0,U.jsx)("div",{className:"truss-estimator__grid-hint",children:i.isOutlineClosed?"Drag a corner handle to refine the outline.":"Add at least three corners, then click Finish outline."}),i.drawError?(0,U.jsx)("div",{className:"deck-outline__error",role:"alert",children:i.drawError}):null]})]})})]})]}):null,D==="pictureFrame"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Si.length]}),(0,U.jsx)("h2",{className:"truss-estimator__step-title",children:"Picture frame border?"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"A picture frame border runs boards around the perimeter for a finished look and uses extra material."}),(0,U.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"no",label:"No border",img:"/decking/boards/no-border.webp"},{id:"yes",label:"Picture frame",img:"/decking/boards/picture-frame.webp"}].map(E=>(0,U.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${i.pictureFrame===E.id?" is-selected":""}`,onClick:()=>o(x=>({...x,pictureFrame:E.id})),children:[(0,U.jsx)("img",{className:"truss-estimator__visual-card-img",src:Kt(E.img),alt:""}),(0,U.jsx)("span",{children:E.label})]},E.id))}),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("div",{className:"truss-estimator__section-heading",children:"Board direction"}),(0,U.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"straight",label:"Straight",img:"/decking/boards/straight.webp"},{id:"diagonal",label:"Diagonal",img:"/decking/boards/diagonal.webp"}].map(E=>(0,U.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${i.direction===E.id?" is-selected":""}`,onClick:()=>o(x=>({...x,direction:E.id})),children:[(0,U.jsx)("img",{className:"truss-estimator__visual-card-img",src:Kt(E.img),alt:""}),(0,U.jsx)("span",{children:E.label})]},E.id))})]})]}):null,D==="substructure"?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Si.length]}),(0,U.jsx)("h2",{className:"truss-estimator__step-title",children:"Substructure"}),(0,U.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose the joist spacing. Posts, footings and ground preparation vary by site, so are not included."}),(0,U.jsx)("div",{className:"truss-estimator__section-heading",children:"Joist spacing"}),(0,U.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Sa.joist.spacingOptions.map(E=>(0,U.jsx)("button",{type:"button",className:`truss-estimator__option-card${i.joistSpacing===E.id?" is-selected":""}`,onClick:()=>o(x=>({...x,joistSpacing:E.id})),children:(0,U.jsx)("div",{className:"truss-estimator__option-title",children:E.label})},E.id))})]}):null]}),(0,U.jsxs)("div",{className:"truss-estimator__nav",children:[(0,U.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:ct,children:"Back"}),(0,U.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:He,disabled:!ee(),children:[(0,U.jsx)("span",{children:se}),(0,U.jsx)("span",{className:"arrow",children:(0,U.jsx)(Ot,{})})]})]})]})]})})}var qa=Y(Xe());var H=Y(ae()),mw=12,fw=30,On=12,Ln=8,gw=.56,Ca={ranges:{boundary:{label:"Horizontal lap",blurb:"Traditional pressure-treated timber panels.",panelWidthM:1.83},skyline:{label:"Feather edge",blurb:"Heavier timber panels for a more solid boundary.",panelWidthM:1.83}},heights:["0.9","1.2","1.5","1.8"],gate:{single:{label:"Single lap gate",widthDefault:.9}},mounting:{concrete:{label:"Concrete posts",blurb:"Slotted concrete posts with matching panels."},postcrete:{label:"Postcrete bags",blurb:"Fast-set post-mix bags in a dug hole.",bagsPerPost:2}}},Ci=["range","height","gate","posts"],U_={range:null,colour:null,grid:new Set,excludedEdges:new Set,gridMode:"draw",boundaryMode:"quick",quickLengthM:"",boundaryPoints:[],boundaryClosed:!1,excludedBoundaryEdges:new Set,height:null,gravelBoard:null,gateType:null,gateWidthM:"",mountingType:null,contact:{name:"",email:""}},ac=(e,t,a)=>(t.x-e.x)*(a.y-e.y)-(t.y-e.y)*(a.x-e.x),rc=(e,t,a)=>a.x>=Math.min(e.x,t.x)&&a.x<=Math.max(e.x,t.x)&&a.y>=Math.min(e.y,t.y)&&a.y<=Math.max(e.y,t.y),D_=(e,t,a,r)=>{let n=ac(e,t,a),i=ac(e,t,r),o=ac(a,r,e),l=ac(a,r,t);return n===0&&rc(e,t,a)||i===0&&rc(e,t,r)||o===0&&rc(a,r,e)||l===0&&rc(a,r,t)?!0:n>0!=i>0&&o>0!=l>0},ic=(e,t)=>{let a=t?e.length:e.length-1;for(let r=0;r<a;r+=1)for(let n=r+1;n<a;n+=1)if(!(n===r+1||t&&r===0&&n===a-1)&&D_(e[r],e[(r+1)%e.length],e[n],e[(n+1)%e.length]))return!0;return!1};function Cd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,qa.useState)(0),[i,o]=(0,qa.useState)(U_),l=(0,qa.useRef)(null),c=(0,qa.useRef)(null),[p,f]=(0,qa.useState)(1),[b,d]=(0,qa.useState)({x:0,y:0}),[h,w]=(0,qa.useState)(null),M=(0,qa.useRef)(null),D=(0,qa.useRef)(null),m=(0,qa.useRef)(null),u=Ci[r],g=i.range?Ca.ranges[i.range]:null,v=On/p,N=Ln/p,A=(On-v)/2,T=(Ln-N)/2,z=Math.max(-On,Math.min(On*2-v,A+b.x)),G=Math.max(-Ln,Math.min(Ln*2-N,T+b.y)),K=i.boundaryPoints.reduce((k,j)=>({x:k.x+j.x/Math.max(1,i.boundaryPoints.length),y:k.y+j.y/Math.max(1,i.boundaryPoints.length)}),{x:0,y:0}),fe=k=>{let j=new Set,O=[];return k.forEach(ne=>{let[W,C]=ne.split(",").map(Number),V=[{key:`H,${W},${C}`,type:"H",x:W,y:C},{key:`H,${W},${C+1}`,type:"H",x:W,y:C+1},{key:`V,${W},${C}`,type:"V",x:W,y:C},{key:`V,${W+1},${C}`,type:"V",x:W+1,y:C}],X=[!k.has(`${W},${C-1}`),!k.has(`${W},${C+1}`),!k.has(`${W-1},${C}`),!k.has(`${W+1},${C}`)];V.forEach((me,Ce)=>{X[Ce]&&!j.has(me.key)&&(j.add(me.key),O.push(me))})}),O},Te=(k,j)=>fe(k).filter(O=>!j.has(O.key)),Ye=(k,j)=>Te(k,j).length,Ve=(k,j)=>{let O={};Te(k,j).forEach(W=>{var C,V,X,me;W.type==="H"?((O[C=`${W.x},${W.y}`]||(O[C]=[])).push("H"),(O[V=`${W.x+1},${W.y}`]||(O[V]=[])).push("H")):((O[X=`${W.x},${W.y}`]||(O[X]=[])).push("V"),(O[me=`${W.x},${W.y+1}`]||(O[me]=[])).push("V"))});let ne=0;return Object.values(O).forEach(W=>{(W.length===1||W.length===2&&W[0]!==W[1]||W.length>=3)&&(ne+=1)}),ne},pe=(()=>{let k=i.range?Ca.ranges[i.range]:Ca.ranges.boundary,j=i.height??"1.8",O=i.boundaryMode==="quick"?Math.max(0,Number.parseFloat(i.quickLengthM)||0):i.boundaryClosed?i.boundaryPoints.slice(0,-1).reduce((hr,Jt,Ft)=>hr+(i.excludedBoundaryEdges.has(Ft)?0:Math.hypot(i.boundaryPoints[Ft+1].x-Jt.x,i.boundaryPoints[Ft+1].y-Jt.y)),0):0,ne=i.gateType&&i.gateType!=="none"?Number.parseFloat(i.gateWidthM)||Ca.gate[i.gateType].widthDefault:0,W=Math.max(0,O-ne),C=W>0?Math.ceil(W/k.panelWidthM):0,V=i.boundaryPoints.length>2&&i.boundaryPoints[0].x===i.boundaryPoints[i.boundaryPoints.length-1].x&&i.boundaryPoints[0].y===i.boundaryPoints[i.boundaryPoints.length-1].y,X=i.boundaryMode==="quick"?W>0?2:0:i.boundaryClosed?i.boundaryPoints.slice(0,V?-1:void 0).reduce((hr,Jt,Ft)=>{let Yd=Ft>0&&!i.excludedBoundaryEdges.has(Ft-1),Vd=Ft<i.boundaryPoints.length-1&&!i.excludedBoundaryEdges.has(Ft);return hr+(Yd||Vd?1:0)},0):0,me=W>0?Math.ceil(W/k.panelWidthM)+1:0,Ce=Math.max(0,me-X),dt=i.mountingType?Ca.mounting[i.mountingType]:Ca.mounting.concrete,je=i.gateType&&i.gateType!=="none"?2:0,Fr=Ce+X+je,Ir=i.mountingType==="postcrete"?Fr*Ca.mounting.postcrete.bagsPerPost:0,ll=i.gravelBoard==="yes"?C:0;return{range:k,height:j,totalEdgeM:O,fencedLengthM:W,gateWidthM:ne,panelsCount:C,cornerPostCount:X,intermediatePostCount:Ce,gatePostCount:je,totalPostCount:Fr,bagsCount:Ir,gravelCount:ll,capCount:Fr,mounting:dt}})(),Q=i.gateType&&i.gateType!=="none"?Ca.gate[i.gateType].label:null,ce=Number(pe.height)<=1.2?"6":"8",xe=pe?[{key:`panels-${i.range??"boundary"}-${pe.height}`,label:`${pe.range.label} panels (${pe.height}m)`,qty:pe.panelsCount,unit:"each",query:"fence panel",category:"fencing"},...i.mountingType==="concrete"?[{key:`concrete-intermediate-${ce}`,label:"Intermediate concrete posts",qty:pe.intermediatePostCount,unit:"each",query:"concrete fence post",category:"fencing"},{key:`concrete-end-${ce}`,label:"End and corner concrete posts",qty:pe.cornerPostCount+pe.gatePostCount,unit:"each",query:"concrete end post",category:"fencing"}]:[{key:`timber-post-${ce}`,label:"Timber fence posts",qty:pe.totalPostCount,unit:"each",query:"timber fence post",category:"fencing"},{key:"postcrete",label:"Postcrete",qty:pe.bagsCount,unit:"bag",query:"postcrete",category:"cement"}],...Q?[{key:"gate",label:Q,qty:1,unit:"each",query:"lap gate",category:"fencing"}]:[],...pe.gravelCount>0?[{key:"gravel-boards",label:"Concrete gravel boards",qty:pe.gravelCount,unit:"each",query:"gravel board",category:"fencing"}]:[]]:[],ye=()=>{if(u==="range"){let k=i.boundaryMode==="quick"?(Number.parseFloat(i.quickLengthM)||0)>0:i.boundaryClosed&&i.boundaryPoints.length>=2;return!!i.range&&k}return u==="height"?!!i.height&&!!i.gravelBoard:u==="gate"?!!i.gateType&&(i.gateType==="none"||i.gateWidthM.trim()!==""):u==="posts"?!!i.mountingType:!0},ee=r===Ci.length-1?a:"Next",se=k=>{o(j=>{let O=k(new Set(j.grid)),ne=new Set([...j.excludedEdges].filter(W=>fe(O).some(C=>C.key===W)));return{...j,grid:O,excludedEdges:ne}})},Me=(k,j,O)=>{se(ne=>{let W=`${k},${j}`;return O?ne.add(W):ne.delete(W),ne})},_e=(k,j,O,ne,W)=>{let C=k,V=j,X=Math.abs(O-k),me=k<O?1:-1,Ce=-Math.abs(ne-j),dt=j<ne?1:-1,je=X+Ce;for(;Me(C,V,W),!(C===O&&V===ne);){let Fr=2*je;Fr>=Ce&&(je+=Ce,C+=me),Fr<=X&&(je+=X,V+=dt)}},et=(k,j)=>{let O=c.current?.getBoundingClientRect();if(!O)return null;let ne=Math.floor((k-O.left)/fw),W=Math.floor((j-O.top)/fw);return ne<0||W<0||ne>=mw||W>=mw?null:{x:ne,y:W}},Ht=k=>{if(i.gridMode!=="draw")return;let j=et(k.clientX,k.clientY);if(!j)return;k.preventDefault();let O=`${j.x},${j.y}`,ne=!i.grid.has(O);l.current={active:!0,paintValue:ne,lastX:j.x,lastY:j.y},k.currentTarget.setPointerCapture(k.pointerId),Me(j.x,j.y,ne)},Tt=k=>{let j=l.current;if(!j?.active)return;let O=et(k.clientX,k.clientY);O&&(O.x===j.lastX&&O.y===j.lastY||(_e(j.lastX,j.lastY,O.x,O.y,j.paintValue),l.current={...j,lastX:O.x,lastY:O.y}))},tt=k=>{l.current?.active&&(l.current=null,k.currentTarget.releasePointerCapture(k.pointerId))},ct=(k,j,O=!1)=>{let ne=m.current?.getBoundingClientRect();if(!ne)return null;let W=O?1:.25;return{x:Math.round(Math.max(z,Math.min(z+v,z+(k-ne.left)/ne.width*v))/W)*W,y:Math.round(Math.max(G,Math.min(G+N,G+(j-ne.top)/ne.height*N))/W)*W}},He=k=>{if(i.boundaryClosed){let O=k.target;if(O!==k.currentTarget&&!O.classList.contains("fence-boundary__grid"))return;D.current={startX:k.clientX,startY:k.clientY,startViewX:z,startViewY:G},k.currentTarget.setPointerCapture(k.pointerId);return}let j=ct(k.clientX,k.clientY,!0);j&&(w(null),o(O=>{let ne=[...O.boundaryPoints,j];return ic(ne,!1)?{...O}:{...O,boundaryPoints:ne}}))},E=(k,j)=>{if(k.stopPropagation(),!i.boundaryClosed){if(j!==0||i.boundaryPoints.length<3)return;o(O=>ic(O.boundaryPoints,!0)?O:{...O,boundaryPoints:[...O.boundaryPoints,O.boundaryPoints[0]],boundaryClosed:!0});return}M.current=j,k.currentTarget.setPointerCapture(k.pointerId)},x=k=>{if(D.current){let O=m.current?.getBoundingClientRect();if(!O)return;let ne=D.current,W=ne.startViewX-(k.clientX-ne.startX)/O.width*v,C=ne.startViewY-(k.clientY-ne.startY)/O.height*N;d({x:W-A,y:C-T});return}if(i.boundaryClosed||w(ct(k.clientX,k.clientY,!0)),M.current===null)return;let j=ct(k.clientX,k.clientY);j&&o(O=>{let ne=O.boundaryPoints.length>2&&O.boundaryPoints[0].x===O.boundaryPoints[O.boundaryPoints.length-1].x&&O.boundaryPoints[0].y===O.boundaryPoints[O.boundaryPoints.length-1].y,W=O.boundaryPoints.map((C,V)=>{let X=V===M.current,me=ne&&M.current===0&&V===O.boundaryPoints.length-1;return X||me?j:C});return ic(W,!1)?O:{...O,boundaryPoints:W}})},R=k=>{D.current=null,M.current=null,k.currentTarget.hasPointerCapture(k.pointerId)&&k.currentTarget.releasePointerCapture(k.pointerId)},I=k=>{o(j=>{let O=new Set(j.excludedBoundaryEdges);return O.has(k)?O.delete(k):O.add(k),{...j,excludedBoundaryEdges:O}})},ue=()=>{r===0?e():n(k=>k-1)},ve=()=>{ye()&&(r===Ci.length-1?t?.(xe):n(k=>k+1))},Se=fe(i.grid);return(0,H.jsx)(H.Fragment,{children:(0,H.jsxs)("div",{className:"truss-estimator",children:[(0,H.jsxs)("div",{className:"quick-order-hero",children:[(0,H.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,H.jsx)("h1",{children:"Fencing Calculator"}),(0,H.jsx)("p",{children:"Estimate panels, posts and cost for your fence line in a few steps."})]}),(0,H.jsxs)("div",{className:"truss-estimator__card",children:[(0,H.jsxs)("div",{className:"truss-estimator__body",children:[u==="range"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ci.length]}),(0,H.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your fence panels"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"The calculator uses fixed, orderable timber panels from the catalogue."}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Ca.ranges).map(([k,j])=>(0,H.jsxs)("button",{type:"button",className:`truss-estimator__option-card${i.range===k?" is-selected":""}`,onClick:()=>o(O=>({...O,range:k})),children:[(0,H.jsx)("div",{className:"truss-estimator__option-title",children:j.label}),(0,H.jsx)("div",{className:"truss-estimator__option-copy",children:j.blurb})]},k))})]}):null,u==="range"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"truss-estimator__section-heading",children:"Measure your fence line"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"Use a quick total, or draw the boundary to mark existing edges that do not need new fencing."}),(0,H.jsxs)("div",{className:"truss-estimator__toggle-row",children:[(0,H.jsx)("button",{type:"button",className:`truss-estimator__toggle${i.boundaryMode==="quick"?" is-selected":""}`,onClick:()=>o(k=>({...k,boundaryMode:"quick"})),children:"Quick estimate"}),(0,H.jsx)("button",{type:"button",className:`truss-estimator__toggle${i.boundaryMode==="draw"?" is-selected":""}`,onClick:()=>o(k=>({...k,boundaryMode:"draw"})),children:"Draw your boundary"})]}),i.boundaryMode==="quick"?(0,H.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact fence-boundary__quick-field",children:[(0,H.jsx)("span",{children:"Total fence length (m)"}),(0,H.jsx)("input",{type:"number",min:"0",step:"0.1",value:i.quickLengthM,onChange:k=>o(j=>({...j,quickLengthM:k.target.value}))})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"fence-boundary__toolbar",children:(0,H.jsxs)("div",{className:"fence-boundary__actions",children:[(0,H.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(k=>({...k,boundaryPoints:k.boundaryPoints.slice(0,-1),boundaryClosed:!1,excludedBoundaryEdges:new Set})),disabled:i.boundaryPoints.length===0||i.boundaryClosed,children:"Undo"}),(0,H.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>{d({x:0,y:0}),w(null),o(k=>({...k,boundaryPoints:[],boundaryClosed:!1,excludedBoundaryEdges:new Set}))},disabled:i.boundaryPoints.length===0,children:"Clear"}),(0,H.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(k=>({...k,boundaryPoints:[{x:2,y:2},{x:8,y:2},{x:8,y:5},{x:2,y:5},{x:2,y:2}],boundaryClosed:!0,excludedBoundaryEdges:new Set})),children:"Start with rectangle"})]})}),(0,H.jsxs)("div",{className:"fence-boundary",children:[(0,H.jsxs)("svg",{ref:m,className:`fence-boundary__canvas${i.boundaryClosed?" is-pan-mode":""}`,viewBox:`${z} ${G} ${v} ${N}`,preserveAspectRatio:"none","aria-label":"Fence boundary drawing area",onPointerDown:He,onPointerMove:x,onPointerUp:R,onPointerLeave:()=>{w(null),D.current||(M.current=null)},children:[(0,H.jsx)("defs",{children:(0,H.jsx)("pattern",{id:"fence-boundary-grid",width:"1",height:"1",patternUnits:"userSpaceOnUse",children:(0,H.jsx)("path",{d:"M 1 0 L 0 0 0 1",fill:"none",stroke:"currentColor",strokeWidth:"0.03"})})}),(0,H.jsx)("rect",{x:-On,y:-Ln,width:On*3,height:Ln*3,className:"fence-boundary__grid",fill:"url(#fence-boundary-grid)"}),i.boundaryPoints.length>1?(0,H.jsx)("polyline",{className:"fence-boundary__preview",points:i.boundaryPoints.map(k=>`${k.x},${k.y}`).join(" ")}):null,i.boundaryPoints.length>1?i.boundaryPoints.slice(0,-1).map((k,j)=>{let O=i.boundaryPoints[j+1],ne=Math.hypot(O.x-k.x,O.y-k.y),W=ne?-(O.y-k.y)/ne:0,C=ne?(O.x-k.x)/ne:0,V=(k.x+O.x)/2,X=(k.y+O.y)/2,me=W*(V-K.x)+C*(X-K.y)>=0?1:-1,Ce=V+W*gw*me,dt=X+C*gw*me;return(0,H.jsxs)("g",{children:[(0,H.jsx)("line",{className:"fence-boundary__edge-hit",x1:k.x,y1:k.y,x2:O.x,y2:O.y,onClick:i.boundaryClosed?()=>I(j):void 0}),(0,H.jsx)("line",{className:`fence-boundary__edge${i.excludedBoundaryEdges.has(j)?" is-excluded":""}`,x1:k.x,y1:k.y,x2:O.x,y2:O.y,pointerEvents:"none"}),(0,H.jsxs)("text",{className:`fence-boundary__edge-label${i.excludedBoundaryEdges.has(j)?" is-excluded":""}`,x:Ce,y:dt,textAnchor:"middle",dominantBaseline:"central",fontSize:.21/p,children:[ne.toFixed(2)," m"]})]},`fence-edge-${j}`)}):null,!i.boundaryClosed&&i.boundaryPoints.length>0&&h?(()=>{let k=i.boundaryPoints[i.boundaryPoints.length-1],j=Math.hypot(h.x-k.x,h.y-k.y);if(!j)return null;let O=-(h.y-k.y)/j,ne=(h.x-k.x)/j,W=(k.x+h.x)/2,C=(k.y+h.y)/2;return(0,H.jsxs)("g",{className:"fence-boundary__live-measurement",children:[(0,H.jsx)("line",{x1:k.x,y1:k.y,x2:h.x,y2:h.y}),(0,H.jsxs)("text",{x:W+O*.34,y:C+ne*.34,textAnchor:"middle",dominantBaseline:"central",fontSize:.21/p,children:[j.toFixed(2)," m"]})]})})():null,i.boundaryPoints.map((k,j)=>j>0&&j===i.boundaryPoints.length-1&&k.x===i.boundaryPoints[0]?.x&&k.y===i.boundaryPoints[0]?.y?null:(0,H.jsx)("circle",{className:`fence-boundary__point${!i.boundaryClosed&&j===0&&i.boundaryPoints.length>=3?" is-close-target":""}`,cx:k.x,cy:k.y,r:"0.13",onPointerDown:O=>E(O,j)},`fence-point-${j}`))]}),(0,H.jsxs)("div",{className:"fence-boundary__zoom","aria-label":"Zoom controls",children:[(0,H.jsx)("button",{type:"button",onClick:()=>f(k=>Math.max(.5,k-.25)),disabled:p===.5,"aria-label":"Zoom out",children:"\u2212"}),(0,H.jsxs)("span",{children:[Math.round(p*100),"%"]}),(0,H.jsx)("button",{type:"button",onClick:()=>f(k=>Math.min(1,k+.25)),disabled:p===1,"aria-label":"Zoom in",children:"+"})]}),!i.boundaryClosed&&i.boundaryPoints.length>=2?(0,H.jsx)("button",{type:"button",className:"fence-boundary__close",onClick:()=>o(k=>ic(k.boundaryPoints,!1)?k:{...k,boundaryClosed:!0}),children:"Finish fence line"}):null]}),(0,H.jsx)("div",{className:"truss-estimator__grid-hint",children:i.boundaryClosed?"Drag the blank canvas to pan. Tap an edge to exclude it from the new fence.":"Click to add points, then finish the fence line. The displayed distances update as you draw."})]}),(0,H.jsxs)("div",{className:"truss-estimator__grid-stats",children:[(0,H.jsx)("div",{children:i.boundaryMode==="quick"?`${(Number.parseFloat(i.quickLengthM)||0).toFixed(2)} m fence line`:`${pe.totalEdgeM.toFixed(2)} m fence line`}),i.boundaryMode==="draw"&&i.boundaryClosed?(0,H.jsxs)("div",{children:[pe.cornerPostCount," corner/end posts"]}):null]})]}):null,null,u==="height"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ci.length]}),(0,H.jsx)("h2",{className:"truss-estimator__step-title",children:"Fence height"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"Select the nearest available panel height."}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--pitch",children:Ca.heights.map(k=>(0,H.jsx)("button",{type:"button",className:`truss-estimator__visual-card${i.height===k?" is-selected":""}`,onClick:()=>o(j=>({...j,height:k})),children:(0,H.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--tall",src:Kt(`/fencing/height/${k}.webp`),alt:""})},k))}),(0,H.jsx)("div",{className:"truss-estimator__section-heading",children:"Gravel board?"}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"no",label:"No gravel board",img:"/fencing/no-gravel-board.webp"},{id:"yes",label:"Add gravel board",img:"/fencing/gravel-board.webp"}].map(k=>(0,H.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${i.gravelBoard===k.id?" is-selected":""}`,onClick:()=>o(j=>({...j,gravelBoard:k.id})),children:[(0,H.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--mid",src:Kt(k.img),alt:""}),(0,H.jsx)("span",{children:k.label})]},k.id))})]}):null,u==="gate"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ci.length]}),(0,H.jsx)("h2",{className:"truss-estimator__step-title",children:"Do you need a gate?"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"A gate opening replaces part of the panel run and adds a gate kit with heavy-duty posts."}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"none",label:"No gate",img:"/fencing/gates/no-gate.webp"},{id:"single",label:"Single gate",img:"/fencing/gates/single-gate.webp"}].map(k=>(0,H.jsxs)("button",{type:"button",className:`truss-estimator__visual-card${i.gateType===k.id?" is-selected":""}`,onClick:()=>o(j=>({...j,gateType:k.id,gateWidthM:k.id==="none"?"":String(Ca.gate[k.id].widthDefault)})),children:[(0,H.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--mid",src:Kt(k.img),alt:""}),(0,H.jsx)("span",{children:k.label})]},k.id))}),i.gateType&&i.gateType!=="none"?(0,H.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact",children:[(0,H.jsx)("span",{children:"Gate width (m)"}),(0,H.jsx)("input",{type:"text",inputMode:"decimal",value:i.gateWidthM,onChange:k=>o(j=>({...j,gateWidthM:k.target.value}))})]}):null]}):null,u==="posts"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ci.length]}),(0,H.jsx)("h2",{className:"truss-estimator__step-title",children:"Posts and fixing type"}),(0,H.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose how the posts will be set."}),(0,H.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Ca.mounting).map(([k,j])=>(0,H.jsxs)("button",{type:"button",className:`truss-estimator__option-card${i.mountingType===k?" is-selected":""}`,onClick:()=>o(O=>({...O,mountingType:k})),children:[(0,H.jsx)("div",{className:"truss-estimator__option-title",children:j.label}),(0,H.jsx)("div",{className:"truss-estimator__option-copy",children:j.blurb})]},k))})]}):null]}),(0,H.jsxs)("div",{className:"truss-estimator__nav",children:[(0,H.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:ue,children:"Back"}),(0,H.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:ve,disabled:!ye(),children:[(0,H.jsx)("span",{children:ee}),(0,H.jsx)("span",{className:"arrow",children:(0,H.jsx)(Ot,{})})]})]})]})]})})}var nc=Y(Xe()),be=Y(ae()),hw={floor:{label:"Floor",product:"Knauf Acoustic Roll",thickness:"100mm",coverage:12.36,salesUnit:"roll"},wall:{label:"Cavity wall",product:"Celotex CW4100",thickness:"100mm",coverage:3.24,salesUnit:"pack"},roof:{label:"Pitched roof",product:"Kingspan K107",thickness:"100mm",coverage:8.64,salesUnit:"pack"},loft:{label:"Loft",product:"Knauf Loft Roll 44",thickness:"100mm",coverage:13.89,salesUnit:"roll"}};function qd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,nc.useState)("floor"),[i,o]=(0,nc.useState)(""),[l,c]=(0,nc.useState)(""),p=Number.parseFloat(i)*Number.parseFloat(l)||0,f=hw[r],b=Math.ceil(p/f.coverage),d=[{key:`insulation-${r}`,label:`${f.product} ${f.thickness}`,qty:b,unit:f.salesUnit,query:f.product,category:"insulation"}],h=Object.entries(hw);return(0,be.jsx)(be.Fragment,{children:(0,be.jsxs)("div",{className:"truss-estimator",children:[(0,be.jsxs)("div",{className:"quick-order-hero",children:[(0,be.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,be.jsx)("h1",{children:"Insulation Calculator"}),(0,be.jsx)("p",{children:"Estimate insulation coverage and pack quantities for floors, walls, roofs and lofts."})]}),(0,be.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,be.jsx)("h2",{className:"truss-estimator__step-title",children:"Where and what you are insulating"}),(0,be.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose the application and product, and enter the area, for coverage and pack quantities."}),(0,be.jsxs)("div",{className:"materials-calculator__section",children:[(0,be.jsx)("div",{className:"truss-estimator__section-heading",children:"Application"}),(0,be.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:h.map(([w,M])=>(0,be.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===w?" is-selected":""}`,onClick:()=>n(w),children:[(0,be.jsx)("div",{className:"truss-estimator__option-title",children:M.label}),(0,be.jsxs)("div",{className:"truss-estimator__option-copy",children:[M.product,", ",M.thickness]})]},w))})]}),(0,be.jsxs)("div",{className:"materials-calculator__section",children:[(0,be.jsx)("div",{className:"truss-estimator__section-heading",children:"Area"}),(0,be.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,be.jsxs)("label",{className:"truss-estimator__field",children:[(0,be.jsx)("span",{children:"Length (m)"}),(0,be.jsx)("input",{type:"number",min:"0",step:"0.01",value:i,onChange:w=>o(w.target.value)})]}),(0,be.jsxs)("label",{className:"truss-estimator__field",children:[(0,be.jsx)("span",{children:"Width (m)"}),(0,be.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:w=>c(w.target.value)})]})]})]}),(0,be.jsxs)("div",{className:"materials-calculator__totals",children:[(0,be.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,be.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,be.jsxs)("div",{children:[(0,be.jsx)("span",{children:"Insulated area"}),(0,be.jsxs)("strong",{children:[p.toFixed(2)," m\xB2"]})]}),(0,be.jsxs)("div",{children:[(0,be.jsx)("span",{children:f.product}),(0,be.jsxs)("strong",{children:[b," packs"]})]})]}),(0,be.jsx)("p",{className:"materials-calculator__note",children:"This is a simple product choice, not thermal or Building Regulations advice. Confirm the specification before ordering."})]}),(0,be.jsxs)("div",{className:"materials-calculator__actions",children:[(0,be.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,be.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(d),disabled:p<=0,children:a})]})]})]})})}var Hn=Y(Xe()),Z=Y(ae()),B_=10,O_=1.9*.762,L_=1.9*1.524,oc=()=>({height:"",width:""}),lc=e=>Number.parseFloat(e)||0,bw=({height:e,width:t})=>lc(e)*lc(t);function Ed({onBack:e}){let[t,a]=(0,Hn.useState)([oc()]),[r,n]=(0,Hn.useState)([oc()]),[i,o]=(0,Hn.useState)("0"),[l,c]=(0,Hn.useState)("0"),[p,f]=(0,Hn.useState)(1),b=t.reduce((m,u)=>m+bw(u),0),d=r.reduce((m,u)=>m+bw(u),0),h=lc(i)*O_+lc(l)*L_,w=Math.max(0,b-d-h),M=w*p/B_,D=(m,u,g,v)=>{m(N=>N.map((A,T)=>T===u?{...A,[g]:v}:A))};return(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)("div",{className:"truss-estimator",children:[(0,Z.jsxs)("div",{className:"quick-order-hero",children:[(0,Z.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Z.jsx)("h1",{children:"Paint Calculator"}),(0,Z.jsx)("p",{children:"Estimate how much paint you need for your walls, including multiple coats and excluded areas."})]}),(0,Z.jsxs)("div",{className:"truss-estimator__card paint-calculator",children:[(0,Z.jsx)("h2",{className:"truss-estimator__step-title",children:"Walls, exclusions and coats"}),(0,Z.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter each wall, subtract windows and doors, and choose your number of coats. Quantities assume a coverage of 10 m\xB2 per litre."}),(0,Z.jsxs)("div",{className:"paint-calculator__section",children:[(0,Z.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall dimensions"}),(0,Z.jsx)("p",{className:"paint-calculator__hint",children:"Enter the height and width of each wall you want to paint."}),(0,Z.jsxs)("div",{className:"paint-calculator__dimensions-header","aria-hidden":"true",children:[(0,Z.jsx)("span",{}),(0,Z.jsx)("span",{children:"Height (m)"}),(0,Z.jsx)("span",{children:"Width (m)"}),(0,Z.jsx)("span",{})]}),t.map((m,u)=>(0,Z.jsxs)("div",{className:"paint-calculator__row",children:[(0,Z.jsxs)("span",{className:"paint-calculator__row-label",children:["Wall ",u+1]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{className:"sr-only",children:"Height (m)"}),(0,Z.jsx)("input",{"aria-label":`Wall ${u+1} height in metres`,type:"number",min:"0",step:"0.01",value:m.height,onChange:g=>D(a,u,"height",g.target.value)})]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{className:"sr-only",children:"Width (m)"}),(0,Z.jsx)("input",{"aria-label":`Wall ${u+1} width in metres`,type:"number",min:"0",step:"0.01",value:m.width,onChange:g=>D(a,u,"width",g.target.value)})]}),t.length>1?(0,Z.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>a(g=>g.filter((v,N)=>N!==u)),children:"Remove"}):null]},`wall-${u}`)),(0,Z.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>a(m=>[...m,oc()]),children:"+ Add another wall"})]}),(0,Z.jsxs)("div",{className:"paint-calculator__section",children:[(0,Z.jsx)("div",{className:"truss-estimator__section-heading",children:"Areas to exclude"}),(0,Z.jsx)("p",{className:"paint-calculator__hint",children:"Add windows, sockets, skirting boards or other areas that will not be painted."}),(0,Z.jsxs)("div",{className:"paint-calculator__dimensions-header","aria-hidden":"true",children:[(0,Z.jsx)("span",{}),(0,Z.jsx)("span",{children:"Height (m)"}),(0,Z.jsx)("span",{children:"Width (m)"}),(0,Z.jsx)("span",{})]}),r.map((m,u)=>(0,Z.jsxs)("div",{className:"paint-calculator__row",children:[(0,Z.jsxs)("span",{className:"paint-calculator__row-label",children:["Area ",u+1]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{className:"sr-only",children:"Height (m)"}),(0,Z.jsx)("input",{"aria-label":`Area ${u+1} height in metres`,type:"number",min:"0",step:"0.01",value:m.height,onChange:g=>D(n,u,"height",g.target.value)})]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{className:"sr-only",children:"Width (m)"}),(0,Z.jsx)("input",{"aria-label":`Area ${u+1} width in metres`,type:"number",min:"0",step:"0.01",value:m.width,onChange:g=>D(n,u,"width",g.target.value)})]}),r.length>1?(0,Z.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>n(g=>g.filter((v,N)=>N!==u)),children:"Remove"}):null]},`excluded-${u}`)),(0,Z.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>n(m=>[...m,oc()]),children:"+ Add another area"})]}),(0,Z.jsxs)("div",{className:"paint-calculator__section",children:[(0,Z.jsx)("div",{className:"truss-estimator__section-heading",children:"Doors and coats"}),(0,Z.jsx)("p",{className:"paint-calculator__hint",children:"Enter the number of standard single and double doors to leave unpainted. Door sizes are estimated automatically."}),(0,Z.jsxs)("div",{className:"truss-estimator__field-grid paint-calculator__small-fields",children:[(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{children:"Doors"}),(0,Z.jsx)("input",{type:"number",min:"0",step:"1",value:i,onChange:m=>o(m.target.value)})]}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{children:"Double doors"}),(0,Z.jsx)("input",{type:"number",min:"0",step:"1",value:l,onChange:m=>c(m.target.value)})]})]}),(0,Z.jsxs)("div",{className:"paint-calculator__coat-field",children:[(0,Z.jsx)("p",{className:"paint-calculator__hint",children:"Most walls need 2 coats for an even finish. Use 3 coats when changing colour significantly or covering a darker wall."}),(0,Z.jsxs)("label",{className:"truss-estimator__field",children:[(0,Z.jsx)("span",{children:"Number of coats"}),(0,Z.jsxs)("select",{value:p,onChange:m=>f(Number(m.target.value)),children:[(0,Z.jsx)("option",{value:"1",children:"1 coat"}),(0,Z.jsx)("option",{value:"2",children:"2 coats"}),(0,Z.jsx)("option",{value:"3",children:"3 coats"})]})]})]})]}),(0,Z.jsxs)("div",{className:"paint-calculator__totals",children:[(0,Z.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,Z.jsxs)("div",{className:"paint-calculator__result-grid",children:[(0,Z.jsxs)("div",{children:[(0,Z.jsx)("span",{children:"Paintable area"}),(0,Z.jsxs)("strong",{children:[w.toFixed(2)," m\xB2"]})]}),(0,Z.jsxs)("div",{children:[(0,Z.jsx)("span",{children:"Coverage"}),(0,Z.jsxs)("strong",{children:[p," ",p===1?"coat":"coats"]})]}),(0,Z.jsxs)("div",{children:[(0,Z.jsx)("span",{children:"Paint required"}),(0,Z.jsxs)("strong",{children:[M.toFixed(1)," litres"]})]})]}),(0,Z.jsx)("p",{className:"paint-calculator__note",children:"Based on paint coverage of 10 m\xB2 per litre. Decorative paint is not currently stocked in this catalogue, so this remains an estimate only."})]}),(0,Z.jsxs)("div",{className:"paint-calculator__actions",children:[(0,Z.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,Z.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",disabled:!0,children:"Paint products unavailable"})]})]})]})})}var gr=Y(Xe()),re=Y(ae()),sc=e=>Number.parseFloat(e)||0,Md={paving:[{id:"council",label:"Council paving slab (600 \xD7 600mm)"},{id:"raj",label:"Raj blend sandstone (600 \xD7 600mm)"}],block:[{id:"brindle",label:"Brindle block paving (60mm)"},{id:"charcoal",label:"Charcoal block paving (60mm)"}],gravel:[{id:"pea",label:"20mm pea shingle"}]};function Td({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,gr.useState)("paving"),[i,o]=(0,gr.useState)("council"),[l,c]=(0,gr.useState)(""),[p,f]=(0,gr.useState)(""),[b,d]=(0,gr.useState)("100"),[h,w]=(0,gr.useState)("50"),[M,D]=(0,gr.useState)(!0),[m,u]=(0,gr.useState)(!0),g=sc(l)*sc(p),v=g,N=g*(sc(b)/1e3),A=g*.04,T=g*(sc(h)/1e3),z=Math.ceil(v/.36),G=Math.ceil(v/.1),K=Math.ceil(N*1700/800),fe=Math.ceil(A*1600/800),Te=Math.ceil(T*1600/800),Ye=r==="paving"?{qty:z,unit:"each"}:r==="block"?{qty:v,unit:"m2"}:{qty:Te,unit:"bag"},Ve={paving:"paving slab",block:"block paver",gravel:"decorative gravel"}[r],it=[{key:`surface-${i}`,label:Md[r].find(Q=>Q.id===i)?.label??"Surface material",qty:Ye.qty,unit:Ye.unit,query:Ve,category:"landscaping"},...M?[{key:"sub-base",label:"MOT Type 1 sub-base",qty:K,unit:"bag",query:"MOT Type 1 sub base",category:"aggregate"}]:[],...m?[{key:"bedding",label:"Sharp sand bedding",qty:fe,unit:"bag",query:"sharp sand",category:"aggregate"}]:[]];return(0,re.jsx)(re.Fragment,{children:(0,re.jsxs)("div",{className:"truss-estimator",children:[(0,re.jsxs)("div",{className:"quick-order-hero",children:[(0,re.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,re.jsx)("h1",{children:"Paving & Driveway Calculator"}),(0,re.jsx)("p",{children:"Estimate paving, block paving, sub-base and bedding materials for outdoor areas."})]}),(0,re.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,re.jsx)("h2",{className:"truss-estimator__step-title",children:"Surface and ground build-up"}),(0,re.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose the surface material and enter the area. Sub-base and bedding sand are estimated alongside the surface units."}),(0,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Surface material"}),(0,re.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:[["paving","Paving slabs","For patios and paths"],["block","Block paving","For driveways and paths"],["gravel","Decorative gravel","For paths and landscaping"]].map(([Q,ce,xe])=>(0,re.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===Q?" is-selected":""}`,onClick:()=>{n(Q),o(Md[Q][0].id)},children:[(0,re.jsx)("div",{className:"truss-estimator__option-title",children:ce}),(0,re.jsx)("div",{className:"truss-estimator__option-copy",children:xe})]},Q))}),(0,re.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,re.jsx)("span",{children:"Finish"}),(0,re.jsx)("select",{value:i,onChange:Q=>o(Q.target.value),children:Md[r].map(Q=>(0,re.jsx)("option",{value:Q.id,children:Q.label},Q.id))})]})]}),(0,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Area and groundwork"}),(0,re.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,re.jsxs)("label",{className:"truss-estimator__field",children:[(0,re.jsx)("span",{children:"Length (m)"}),(0,re.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:Q=>c(Q.target.value)})]}),(0,re.jsxs)("label",{className:"truss-estimator__field",children:[(0,re.jsx)("span",{children:"Width (m)"}),(0,re.jsx)("input",{type:"number",min:"0",step:"0.01",value:p,onChange:Q=>f(Q.target.value)})]})]}),r==="gravel"&&(0,re.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,re.jsx)("span",{children:"Gravel depth (mm)"}),(0,re.jsx)("input",{type:"number",min:"0",step:"10",value:h,onChange:Q=>w(Q.target.value)})]}),M&&(0,re.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,re.jsx)("span",{children:"Sub-base depth (mm)"}),(0,re.jsx)("input",{type:"number",min:"0",step:"10",value:b,onChange:Q=>d(Q.target.value)})]}),(0,re.jsxs)("label",{className:"brick-calculator__checkbox materials-calculator__waste",children:[(0,re.jsx)("input",{type:"checkbox",checked:M,onChange:Q=>D(Q.target.checked)}),(0,re.jsx)("span",{children:"Include MOT Type 1 sub-base"})]}),(0,re.jsxs)("label",{className:"brick-calculator__checkbox materials-calculator__waste",children:[(0,re.jsx)("input",{type:"checkbox",checked:m,onChange:Q=>u(Q.target.checked)}),(0,re.jsx)("span",{children:"Include sharp sand bedding"})]})]}),(0,re.jsxs)("div",{className:"materials-calculator__totals",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,re.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"Surface area"}),(0,re.jsxs)("strong",{children:[g.toFixed(2)," m\xB2"]})]}),(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:r==="paving"?"Paving slabs":r==="block"?"Block paving":"Gravel"}),(0,re.jsx)("strong",{children:r==="paving"?`${z} slabs`:r==="block"?`${v.toFixed(2)} m\xB2`:`${Te} bulk bags`})]}),M&&(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"MOT Type 1"}),(0,re.jsxs)("strong",{children:[K," bulk bags"]})]}),m&&(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"Sharp sand"}),(0,re.jsxs)("strong",{children:[fe," bulk bags"]})]})]}),(0,re.jsx)("p",{className:"materials-calculator__note",children:"Slab and block quantities use typical sizes. Confirm pack coverage and laying pattern before ordering."})]}),(0,re.jsxs)("div",{className:"materials-calculator__actions",children:[(0,re.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,re.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(it),disabled:g<=0,children:a})]})]})]})})}var il=Y(Xe()),ie=Y(ae()),H_=2.88,vw=[{id:"standard",label:"Standard wallboard",blurb:"General internal walls and ceilings"},{id:"moisture",label:"Moisture resistant",blurb:"Kitchens, bathrooms and utility rooms"},{id:"fire",label:"Fire resistant",blurb:"Where fire-rated lining is required"},{id:"sound",label:"Sound resistant",blurb:"Improved acoustic performance"}],ww=()=>({length:"",height:""}),zd=e=>Number.parseFloat(e)||0;function Ad({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,il.useState)([ww()]),[i,o]=(0,il.useState)(""),[l,c]=(0,il.useState)("standard"),[p,f]=(0,il.useState)("screws"),b=r.reduce((A,T)=>A+zd(T.length)*zd(T.height),0),d=Math.max(0,b-zd(i)),h=Math.ceil(d/H_),w=Math.ceil(d*12),M=Math.ceil(w/1e3),D=Math.ceil(d*1.2),m=Math.ceil(D/90),u=Math.ceil(d/3.5),g=vw.find(A=>A.id===l)?.label??"Standard",v=[{key:"board",label:`${g} plasterboard`,qty:h,unit:"sheet",query:`${g} plasterboard`,category:"plasterboard"},...p==="screws"?[{key:"screws",label:"Drywall screws",qty:M,unit:"box",query:"drywall screws",category:"fixings"}]:[{key:"adhesive",label:"Board adhesive",qty:u,unit:"bag",query:"drywall board adhesive",category:"plasterboard"}],{key:"tape",label:"Joint tape",qty:m,unit:"roll",query:"plasterboard joint tape",category:"plasterboard"}],N=(A,T,z)=>{n(G=>G.map((K,fe)=>fe===A?{...K,[T]:z}:K))};return(0,ie.jsx)(ie.Fragment,{children:(0,ie.jsxs)("div",{className:"truss-estimator",children:[(0,ie.jsxs)("div",{className:"quick-order-hero",children:[(0,ie.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,ie.jsx)("h1",{children:"Plasterboard & Drylining Calculator"}),(0,ie.jsx)("p",{children:"Estimate boards, fixings and jointing materials for walls and ceilings."})]}),(0,ie.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,ie.jsx)("h2",{className:"truss-estimator__step-title",children:"Boards, fixings and jointing"}),(0,ie.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter the surfaces you are lining and the board specification. Screws, tape and adhesive are estimated with the boards."}),(0,ie.jsxs)("div",{className:"materials-calculator__section",children:[(0,ie.jsx)("div",{className:"truss-estimator__section-heading",children:"Board type"}),(0,ie.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:vw.map(A=>(0,ie.jsxs)("button",{type:"button",className:`truss-estimator__option-card${l===A.id?" is-selected":""}`,onClick:()=>c(A.id),children:[(0,ie.jsx)("div",{className:"truss-estimator__option-title",children:A.label}),(0,ie.jsx)("div",{className:"truss-estimator__option-copy",children:A.blurb})]},A.id))})]}),(0,ie.jsxs)("div",{className:"materials-calculator__section",children:[(0,ie.jsx)("div",{className:"truss-estimator__section-heading",children:"Fixing method"}),(0,ie.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[["screws","Drywall screws","For timber or metal framing"],["adhesive","Board adhesive","For masonry dot-and-dab"]].map(([A,T,z])=>(0,ie.jsxs)("button",{type:"button",className:`truss-estimator__option-card${p===A?" is-selected":""}`,onClick:()=>f(A),children:[(0,ie.jsx)("div",{className:"truss-estimator__option-title",children:T}),(0,ie.jsx)("div",{className:"truss-estimator__option-copy",children:z})]},A))})]}),(0,ie.jsxs)("div",{className:"materials-calculator__section",children:[(0,ie.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall and ceiling areas"}),(0,ie.jsx)("p",{className:"materials-calculator__hint",children:"Add each surface separately so different wall sizes are easy to measure."}),(0,ie.jsxs)("div",{className:"materials-calculator__dimensions-header",children:[(0,ie.jsx)("span",{children:"Surface"}),(0,ie.jsx)("span",{children:"Length (m)"}),(0,ie.jsx)("span",{children:"Height (m)"}),(0,ie.jsx)("span",{})]}),r.map((A,T)=>(0,ie.jsxs)("div",{className:"materials-calculator__surface-row",children:[(0,ie.jsxs)("span",{children:["Surface ",T+1]}),(0,ie.jsx)("input",{"aria-label":`Surface ${T+1} length`,type:"number",min:"0",step:"0.01",value:A.length,onChange:z=>N(T,"length",z.target.value)}),(0,ie.jsx)("input",{"aria-label":`Surface ${T+1} height`,type:"number",min:"0",step:"0.01",value:A.height,onChange:z=>N(T,"height",z.target.value)}),r.length>1?(0,ie.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>n(z=>z.filter((G,K)=>K!==T)),children:"Remove"}):null]},`surface-${T}`)),(0,ie.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>n(A=>[...A,ww()]),children:"+ Add another surface"}),(0,ie.jsxs)("label",{className:"truss-estimator__field materials-calculator__openings",children:[(0,ie.jsxs)("span",{children:["Openings to deduct (m\xB2) ",(0,ie.jsx)("small",{children:"optional"})]}),(0,ie.jsx)("input",{type:"number",min:"0",step:"0.01",value:i,onChange:A=>o(A.target.value)})]})]}),(0,ie.jsxs)("div",{className:"materials-calculator__totals",children:[(0,ie.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,ie.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)("span",{children:"Board area"}),(0,ie.jsxs)("strong",{children:[d.toFixed(2)," m\xB2"]})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("span",{children:"2.4 x 1.2 m boards"}),(0,ie.jsx)("strong",{children:h})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("span",{children:p==="screws"?"Drywall screws":"Board adhesive"}),(0,ie.jsx)("strong",{children:p==="screws"?`${w} (${M} boxes)`:`${u} bags`})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("span",{children:"Joint tape"}),(0,ie.jsxs)("strong",{children:[D," m (",m," rolls)"]})]})]}),(0,ie.jsx)("p",{className:"materials-calculator__note",children:"Figures are estimates. Confirm board specification, fixing patterns and fire or acoustic requirements before ordering."})]}),(0,ie.jsxs)("div",{className:"materials-calculator__actions",children:[(0,ie.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,ie.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(v),disabled:d<=0,children:a})]})]})]})})}var nl=Y(Xe());var y=Y(ae()),Mt={ranges:{standard:{label:"Standard Fink",blurb:"Classic W-shaped truss for standard pitched roofs."},attic:{label:"Attic",blurb:"Room-in-roof truss with usable attic space and clear span."},mono:{label:"Mono-pitch",blurb:"Single-slope truss for lean-to roofs and outbuildings."}},pitches:["15","20","22.5","25","30","35","40","45","50","55"],pitchMultipliers:{15:.95,20:.98,"22.5":1,25:1.02,30:1.05,35:1.1,40:1.18,45:1.27,50:1.38,55:1.52},overhang:{thresholdMM:300,surchargePerTruss:3.5},centresOptions:["400","600"],treatment:{treated:{label:"Treated (tanalised)",surchargePct:.08},untreated:{label:"Untreated",surchargePct:0}},estimate:{design:250,delivery:250,bracingPerMetre:6.5,girderMultiplier:1.8,ranges:{standard:{supplyAt8m:53.33,installPerTruss:30},attic:{supplyAt8m:128.35,installPerTruss:55},mono:{supplyAt8m:60,installPerTruss:38}}}},cc=["range","pitchAndDimensions","quantityAndGirders","bracing"],j_={range:null,pitch:null,spanMM:"",overhangMM:"",roofLengthM:"",centres:null,girderCount:0,bracing:null,treatment:null,contact:{name:"",email:""}};function G_({degrees:e}){let a=e*Math.PI/180,n=82-Math.min(58,38*Math.tan(a));return(0,y.jsxs)("svg",{viewBox:"0 0 100 100",className:"truss-estimator__diagram truss-estimator__diagram--small","aria-hidden":"true",children:[(0,y.jsx)("line",{x1:"6",y1:"82",x2:"94",y2:"82",stroke:"var(--border)",strokeWidth:"2"}),(0,y.jsx)("polygon",{points:`12,82 88,82 50,${n}`,fill:"var(--accent-light)",stroke:"var(--accent)",strokeWidth:"3",strokeLinejoin:"round"})]})}function Q_({type:e}){let t="#b3835a",a="#5c3b22",r="#d9b48f",n="#d3d8de",i="#7c8494",o=(f,b,d,h,w=8,M)=>{let D=d-f,m=h-b,u=Math.hypot(D,m)||1,g=-m/u,v=D/u,N=w*.2;return(0,y.jsxs)("g",{children:[(0,y.jsx)("line",{x1:f,y1:b,x2:d,y2:h,stroke:a,strokeWidth:w+3,strokeLinecap:"square"}),(0,y.jsx)("line",{x1:f,y1:b,x2:d,y2:h,stroke:t,strokeWidth:w,strokeLinecap:"square"}),(0,y.jsx)("line",{x1:f-g*N,y1:b-v*N,x2:d-g*N,y2:h-v*N,stroke:r,strokeWidth:Math.max(1.5,w*.24),strokeLinecap:"round",opacity:"0.9"})]},M)},l=(f,b,d)=>(0,y.jsxs)("g",{children:[(0,y.jsx)("rect",{x:f-7.5,y:b-5.5,width:"15",height:"11",rx:"2",fill:n,stroke:i,strokeWidth:"1"}),(0,y.jsx)("circle",{cx:f-4,cy:b-2.5,r:"1",fill:i}),(0,y.jsx)("circle",{cx:f+4,cy:b-2.5,r:"1",fill:i}),(0,y.jsx)("circle",{cx:f-4,cy:b+2.5,r:"1",fill:i}),(0,y.jsx)("circle",{cx:f+4,cy:b+2.5,r:"1",fill:i}),(0,y.jsx)("circle",{cx:f,cy:b,r:"1",fill:i})]},d),c=(f,b)=>(0,y.jsx)("rect",{x:f-9,y:"110",width:"18",height:"10",fill:a},b),p=(0,y.jsx)("line",{x1:"6",y1:"122",x2:"194",y2:"122",stroke:"var(--border)",strokeWidth:"2"});return e==="attic"?(0,y.jsxs)("svg",{viewBox:"0 0 200 130",className:"truss-estimator__diagram","aria-hidden":"true",children:[p,c(26,"wl"),c(174,"wr"),o(26,112,100,26,8,"b1"),o(174,112,100,26,8,"b2"),o(26,112,174,112,8,"b3"),o(58,112,58,70,6,"b4"),o(142,112,142,70,6,"b5"),o(58,70,142,70,7,"b6"),(0,y.jsx)("rect",{x:"90",y:"82",width:"20",height:"24",fill:"#cfe3f2",stroke:a,strokeWidth:"2"}),(0,y.jsx)("line",{x1:"100",y1:"82",x2:"100",y2:"106",stroke:a,strokeWidth:"1.5"}),l(26,112,"p1"),l(174,112,"p2"),l(100,26,"p3"),l(58,112,"p4"),l(58,70,"p5"),l(142,112,"p6"),l(142,70,"p7")]}):e==="mono"?(0,y.jsxs)("svg",{viewBox:"0 0 200 130",className:"truss-estimator__diagram","aria-hidden":"true",children:[p,c(26,"wl"),c(174,"wr"),o(26,112,174,26,8,"b1"),o(174,26,174,112,8,"b2"),o(26,112,174,112,8,"b3"),o(90,112,90,75,5,"b4"),o(90,75,132,112,5,"b5"),l(26,112,"p1"),l(174,26,"p2"),l(174,112,"p3"),l(90,112,"p4"),l(90,75,"p5"),l(132,112,"p6")]}):(0,y.jsxs)("svg",{viewBox:"0 0 200 130",className:"truss-estimator__diagram","aria-hidden":"true",children:[p,c(26,"wl"),c(174,"wr"),o(26,112,100,34,8,"b1"),o(174,112,100,34,8,"b2"),o(26,112,174,112,8,"b3"),o(63,112,100,34,5,"b4"),o(137,112,100,34,5,"b5"),o(63,112,54,83,5,"b6"),o(137,112,146,83,5,"b7"),(0,y.jsx)("rect",{x:"96",y:"108",width:"8",height:"8",fill:a}),l(26,112,"p1"),l(174,112,"p2"),l(100,34,"p3"),l(63,112,"p4"),l(137,112,"p5"),l(54,83,"p6"),l(146,83,"p7")]})}function Y_({enabled:e}){return(0,y.jsxs)("svg",{viewBox:"0 0 200 130",className:"truss-estimator__diagram","aria-hidden":"true",children:[(0,y.jsx)("line",{x1:"6",y1:"122",x2:"194",y2:"122",stroke:"var(--border)",strokeWidth:"2"}),(0,y.jsx)("rect",{x:"17",y:"110",width:"18",height:"10",fill:"#5c3b22"}),(0,y.jsx)("rect",{x:"165",y:"110",width:"18",height:"10",fill:"#5c3b22"}),(0,y.jsx)("line",{x1:"26",y1:"112",x2:"100",y2:"34",stroke:"#5c3b22",strokeWidth:"11",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"26",y1:"112",x2:"100",y2:"34",stroke:"#b3835a",strokeWidth:"8",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"174",y1:"112",x2:"100",y2:"34",stroke:"#5c3b22",strokeWidth:"11",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"174",y1:"112",x2:"100",y2:"34",stroke:"#b3835a",strokeWidth:"8",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"26",y1:"112",x2:"174",y2:"112",stroke:"#5c3b22",strokeWidth:"11",strokeLinecap:"square"}),(0,y.jsx)("line",{x1:"26",y1:"112",x2:"174",y2:"112",stroke:"#b3835a",strokeWidth:"8",strokeLinecap:"square"}),e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("line",{x1:"45",y1:"112",x2:"140",y2:"88",stroke:"var(--accent)",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"7 5"}),(0,y.jsx)("line",{x1:"155",y1:"112",x2:"60",y2:"88",stroke:"var(--accent)",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"7 5"})]}):null,(0,y.jsx)("rect",{x:"18.5",y:"106.5",width:"15",height:"11",rx:"2",fill:"#d3d8de",stroke:"#7c8494",strokeWidth:"1"}),(0,y.jsx)("rect",{x:"166.5",y:"106.5",width:"15",height:"11",rx:"2",fill:"#d3d8de",stroke:"#7c8494",strokeWidth:"1"}),(0,y.jsx)("rect",{x:"92.5",y:"28.5",width:"15",height:"11",rx:"2",fill:"#d3d8de",stroke:"#7c8494",strokeWidth:"1"})]})}function yw({treated:e}){let t=e?"#5a7a4a":"var(--accent)";return(0,y.jsxs)("svg",{viewBox:"0 0 100 100",className:"truss-estimator__diagram truss-estimator__diagram--small","aria-hidden":"true",children:[(0,y.jsx)("rect",{x:"10",y:"22",width:"80",height:"14",rx:"2",fill:t}),(0,y.jsx)("rect",{x:"10",y:"43",width:"80",height:"14",rx:"2",fill:e?"#8faf7a":"var(--accent-light)"}),(0,y.jsx)("rect",{x:"10",y:"64",width:"80",height:"14",rx:"2",fill:t})]})}function Rd({onBack:e}){let[t,a]=(0,nl.useState)(0),[r,n]=(0,nl.useState)(j_),[i,o]=(0,nl.useState)(!1),[l,c]=(0,nl.useState)(!1),p=()=>{let m=Number.parseFloat(r.roofLengthM)||0,u=Number.parseFloat(r.centres??"");return m<=0||!u?0:Math.ceil(m*1e3/u)+1},b=(()=>{let m=r.range?Mt.ranges[r.range]:Mt.ranges.standard,u=r.pitch??"22.5",g=Mt.pitchMultipliers[u],v=(Number.parseFloat(r.spanMM)||0)/1e3,A=(Number.parseFloat(r.overhangMM)||0)>Mt.overhang.thresholdMM,T=p(),z=T+r.girderCount,G=Number.parseFloat(r.roofLengthM)||0,K=r.treatment?Mt.treatment[r.treatment]:Mt.treatment.untreated,fe=Mt.estimate.ranges[r.range??"standard"],Te=fe.supplyAt8m*Math.max(.7,v/8)*g*(1+K.surchargePct)+(A?Mt.overhang.surchargePerTruss:0),Ye=T*Te,Ve=r.girderCount*Te*Mt.estimate.girderMultiplier,it=r.bracing==="yes"?G*Mt.estimate.bracingPerMetre:0,pe=Ye+Ve+it+Mt.estimate.delivery,Q=Mt.estimate.design+T*fe.installPerTruss+r.girderCount*40,ce=pe+Q,xe=ce*.2;return{range:m,count:T,girderCount:r.girderCount,overhangApplies:A,overhangUnits:z,roofLengthM:G,treatment:K,trussSupply:Ye,bracingMaterials:it,delivery:Mt.estimate.delivery,labour:Q,subtotal:ce,vat:xe,total:ce+xe}})(),d=()=>{let m=cc[t];return m==="range"?!!r.range:m==="pitchAndDimensions"?!!r.pitch&&r.spanMM.trim()!==""&&r.overhangMM.trim()!=="":m==="quantityAndGirders"?r.roofLengthM.trim()!==""&&!!r.centres:m==="bracing"?!!r.bracing&&!!r.treatment:!0},h=t===cc.length-1?"View truss request":"Next",w=()=>{i?o(!1):t===0?e():a(m=>m-1)},M=()=>{d()&&(t===cc.length-1?(c(!1),o(!0)):a(m=>m+1))},D=()=>{let m=cc[t];return m==="range"?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Step 1 of 4"}),(0,y.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your truss range"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Pricing shown is placeholder. Swap in your real engineering and pricing catalogue."}),(0,y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--range",children:Object.entries(Mt.ranges).map(([u,g])=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r.range===u?" is-selected":""}`,onClick:()=>n(v=>({...v,range:u})),children:[(0,y.jsx)(Q_,{type:u}),(0,y.jsxs)("div",{className:"truss-estimator__option-info",children:[(0,y.jsx)("div",{className:"truss-estimator__option-title",children:g.label}),(0,y.jsx)("div",{className:"truss-estimator__option-copy",children:g.blurb})]})]},u))})]}):m==="pitchAndDimensions"?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Step 2 of 4"}),(0,y.jsx)("h2",{className:"truss-estimator__step-title",children:"Span, overhang and roof pitch"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Span is wall-to-wall, overhang is the eaves tail beyond the wall line. Steeper pitches use more timber per truss."}),(0,y.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,y.jsxs)("label",{className:"truss-estimator__field",children:[(0,y.jsx)("span",{children:"Span (mm)"}),(0,y.jsx)("input",{type:"text",inputMode:"numeric",value:r.spanMM,onChange:u=>n(g=>({...g,spanMM:u.target.value}))})]}),(0,y.jsxs)("label",{className:"truss-estimator__field",children:[(0,y.jsx)("span",{children:"Overhang (mm)"}),(0,y.jsx)("input",{type:"text",inputMode:"numeric",value:r.overhangMM,onChange:u=>n(g=>({...g,overhangMM:u.target.value}))}),(0,y.jsxs)("small",{children:["Overhangs beyond ",Mt.overhang.thresholdMM,"mm add a small surcharge per truss."]})]})]}),(0,y.jsx)("div",{className:"truss-estimator__section-heading",children:"Roof pitch"}),(0,y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--pitch",children:Mt.pitches.map(u=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card${r.pitch===u?" is-selected":""}`,onClick:()=>n(g=>({...g,pitch:u})),children:[(0,y.jsx)(G_,{degrees:Number.parseFloat(u)}),(0,y.jsxs)("span",{children:[u,"\xB0"]})]},u))})]}):m==="quantityAndGirders"?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Step 3 of 4"}),(0,y.jsx)("h2",{className:"truss-estimator__step-title",children:"Roof length"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Trusses are based on designs at 400mm or 600mm centres wherever possible."}),(0,y.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact",children:[(0,y.jsx)("span",{children:"Roof length (m)"}),(0,y.jsx)("input",{type:"text",inputMode:"decimal",value:r.roofLengthM,onChange:u=>n(g=>({...g,roofLengthM:u.target.value}))})]}),(0,y.jsx)("div",{className:"truss-estimator__section-heading",children:"Truss centres"}),(0,y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--centres",children:Mt.centresOptions.map(u=>(0,y.jsx)("button",{type:"button",className:`truss-estimator__option-card truss-estimator__option-card--compact${r.centres===u?" is-selected":""}`,onClick:()=>n(g=>({...g,centres:u})),children:(0,y.jsxs)("div",{className:"truss-estimator__option-title",children:[u,"mm centres"]})},u))}),(0,y.jsxs)("div",{className:"truss-estimator__stat",children:[p()," trusses estimated"]}),(0,y.jsx)("div",{className:"truss-estimator__section-heading",children:"Girder trusses"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Heavy-duty girder trusses carry point loads over large openings. Set 0 if you do not need any."}),(0,y.jsxs)("div",{className:"truss-estimator__stepper",children:[(0,y.jsx)("button",{type:"button",onClick:()=>n(u=>({...u,girderCount:Math.max(0,u.girderCount-1)})),children:"\u2212"}),(0,y.jsx)("span",{children:r.girderCount}),(0,y.jsx)("button",{type:"button",onClick:()=>n(u=>({...u,girderCount:Math.min(3,u.girderCount+1)})),children:"+"})]})]}):m==="bracing"?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Step 4 of 4"}),(0,y.jsx)("h2",{className:"truss-estimator__step-title",children:"Bracing pack?"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"A timber bracing pack stabilises the roof structure once trusses are erected."}),(0,y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[{id:"no",label:"No bracing pack"},{id:"yes",label:"Add bracing pack"}].map(u=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${r.bracing===u.id?" is-selected":""}`,onClick:()=>n(g=>({...g,bracing:u.id})),children:[(0,y.jsx)(Y_,{enabled:u.id==="yes"}),(0,y.jsx)("span",{children:u.label})]},u.id))}),(0,y.jsx)("div",{className:"truss-estimator__section-heading",children:"Timber treatment"}),(0,y.jsx)("p",{className:"truss-estimator__step-sub",children:"Tanalised timber protects against rot in exposed or damp locations."}),(0,y.jsxs)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${r.treatment==="untreated"?" is-selected":""}`,onClick:()=>n(u=>({...u,treatment:"untreated"})),children:[(0,y.jsx)(yw,{treated:!1}),(0,y.jsx)("span",{children:"Untreated"})]}),(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${r.treatment==="treated"?" is-selected":""}`,onClick:()=>n(u=>({...u,treatment:"treated"})),children:[(0,y.jsx)(yw,{treated:!0}),(0,y.jsx)("span",{children:"Treated (+8% cost)"}),(0,y.jsx)("small",{children:"Applies to trusses, girders and overhang"})]})]})]}):null};return i?(0,y.jsx)(y.Fragment,{children:(0,y.jsxs)("div",{className:"truss-estimator",children:[(0,y.jsxs)("div",{className:"quick-order-hero",children:[(0,y.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,y.jsx)("h1",{children:"Your truss estimate"}),(0,y.jsx)("p",{children:"A provisional quantity and specification based on the dimensions you entered."})]}),(0,y.jsxs)("div",{className:"truss-estimator__card truss-request",style:{minHeight:0},children:[(0,y.jsxs)("div",{className:"truss-request__heading",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Estimated requirement"}),(0,y.jsxs)("h2",{children:[b.range.label," roof trusses"]})]}),(0,y.jsxs)("strong",{children:[b.count,(0,y.jsx)("span",{children:"trusses"})]})]}),(0,y.jsxs)("div",{className:"truss-request__grid",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Span"}),(0,y.jsxs)("strong",{children:[r.spanMM," mm"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Roof length"}),(0,y.jsxs)("strong",{children:[r.roofLengthM," m"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Pitch"}),(0,y.jsxs)("strong",{children:[r.pitch,"\xB0"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Centres"}),(0,y.jsxs)("strong",{children:[r.centres," mm"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Overhang"}),(0,y.jsxs)("strong",{children:[r.overhangMM," mm"]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Treatment"}),(0,y.jsx)("strong",{children:b.treatment.label})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Girder trusses"}),(0,y.jsx)("strong",{children:b.girderCount||"None"})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Bracing pack"}),(0,y.jsx)("strong",{children:r.bracing==="yes"?"Included":"Not included"})]})]}),(0,y.jsxs)("div",{className:"truss-request__price",children:[(0,y.jsx)("div",{className:"truss-estimator__step-label",children:"Indicative cost estimate"}),(0,y.jsxs)("div",{className:"truss-request__price-grid",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Truss supply allowance"}),(0,y.jsx)("strong",{children:nt(b.trussSupply)})]}),b.bracingMaterials>0&&(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Bracing materials allowance"}),(0,y.jsx)("strong",{children:nt(b.bracingMaterials)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Delivery allowance"}),(0,y.jsx)("strong",{children:nt(b.delivery)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Design and installation labour"}),(0,y.jsx)("strong",{children:nt(b.labour)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Subtotal (ex. VAT)"}),(0,y.jsx)("strong",{children:nt(b.subtotal)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"VAT (20%)"}),(0,y.jsx)("strong",{children:nt(b.vat)})]}),(0,y.jsxs)("div",{className:"truss-request__price-total",children:[(0,y.jsx)("span",{children:"Estimated total"}),(0,y.jsx)("strong",{children:nt(b.total)})]})]}),(0,y.jsx)("p",{children:"Trusses are not listed as fixed products in this catalogue, so supply, delivery and labour are benchmark allowances. Confirm the engineered design and final quote before ordering."})]}),(0,y.jsxs)("div",{className:"truss-request__notice",children:[(0,y.jsx)("strong",{children:"Before ordering"}),(0,y.jsx)("span",{children:"Roof trusses must be designed and signed off for the building. Confirm loading, bearings, wind bracing and final drawings with the truss manufacturer."})]}),(0,y.jsxs)("div",{className:"truss-estimator__nav",children:[(0,y.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:w,children:"Back to calculator"}),(0,y.jsx)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",justifyContent:"center",marginTop:0},onClick:()=>c(!0),children:"Request order"})]}),l&&(0,y.jsx)("p",{className:"truss-request__demo",children:"Demo only \u2014 no order has been sent."})]})]})}):(0,y.jsx)(y.Fragment,{children:(0,y.jsxs)("div",{className:"truss-estimator",children:[(0,y.jsxs)("div",{className:"quick-order-hero",children:[(0,y.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,y.jsx)("h1",{children:"Roof Truss Calculator"}),(0,y.jsx)("p",{children:"Estimate trusses, girders and cost for your roof in a few steps."})]}),(0,y.jsxs)("div",{className:"truss-estimator__card",children:[(0,y.jsx)("div",{className:"truss-estimator__body",children:D()}),(0,y.jsxs)("div",{className:"truss-estimator__nav",children:[(0,y.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:w,children:"Back"}),(0,y.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:M,disabled:!d(),children:[(0,y.jsx)("span",{children:h}),(0,y.jsx)("span",{className:"arrow",children:(0,y.jsx)(Ot,{})})]})]})]})]})})}var qi=Y(Xe()),F=Y(ae()),kw=e=>Number.parseFloat(e)||0,uc=(e,t)=>kw(e)*(t==="m"?1:.3048),_w=()=>({length:"",width:""}),xw=[{id:"chamfered",label:"Chamfered",blurb:"Clean angled edge"},{id:"ogee",label:"Ogee",blurb:"Traditional curved profile"},{id:"pencil-round",label:"Pencil round",blurb:"Simple softened edge"},{id:"torus",label:"Torus",blurb:"Soft rounded detail"}];function V_({profile:e}){return(0,F.jsxs)("svg",{className:"skirting-calculator__profile-diagram",viewBox:"0 0 120 84","aria-hidden":"true",children:[(0,F.jsx)("path",{d:{chamfered:"M16 70V43L43 16H104V70Z",ogee:"M16 70V47C16 36 27 31 40 31C40 21 50 16 63 16H104V70Z","pencil-round":"M16 70V37C16 25 25 16 37 16H104V70Z",torus:"M16 70V49C16 39 25 34 36 34C36 22 47 16 61 16H104V70Z"}[e]}),(0,F.jsx)("line",{x1:"12",y1:"70",x2:"108",y2:"70"})]})}function Ud({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,qi.useState)("total"),[i,o]=(0,qi.useState)("m"),[l,c]=(0,qi.useState)(""),[p,f]=(0,qi.useState)([_w()]),[b,d]=(0,qi.useState)(""),[h,w]=(0,qi.useState)("chamfered"),M="4.2",D=r==="total"?uc(l,i):p.reduce((N,A)=>N+2*(uc(A.length,i)+uc(A.width,i)),0),m=Math.max(0,D-uc(b,i)),u=Math.ceil(m/kw(M)),g=[{key:`skirting-${h}`,label:`${xw.find(N=>N.id===h)?.label} skirting board`,qty:m,unit:"m",query:"skirting board",category:"skirting"}],v=(N,A,T)=>{f(z=>z.map((G,K)=>K===N?{...G,[A]:T}:G))};return(0,F.jsx)(F.Fragment,{children:(0,F.jsxs)("div",{className:"truss-estimator",children:[(0,F.jsxs)("div",{className:"quick-order-hero",children:[(0,F.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,F.jsx)("h1",{children:"Skirting Board Calculator"}),(0,F.jsx)("p",{children:"Work out how many skirting board lengths you need for one room or a whole project."})]}),(0,F.jsxs)("div",{className:"truss-estimator__card skirting-calculator",children:[(0,F.jsx)("h2",{className:"truss-estimator__step-title",children:"Measure by room or total length"}),(0,F.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter a single total or work room by room. The run is converted straight into board lengths."}),(0,F.jsxs)("div",{className:"skirting-calculator__section",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"How would you like to measure?"}),(0,F.jsxs)("div",{className:"brick-calculator__unit-toggle skirting-calculator__mode-toggle",role:"group","aria-label":"Calculation method",children:[(0,F.jsx)("button",{type:"button",className:r==="total"?"is-selected":"",onClick:()=>n("total"),children:"Total length"}),(0,F.jsx)("button",{type:"button",className:r==="rooms"?"is-selected":"",onClick:()=>n("rooms"),children:"Room by room"})]})]}),(0,F.jsxs)("div",{className:"skirting-calculator__section",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"Measurements"}),(0,F.jsxs)("div",{className:"skirting-calculator__unit-row",children:[(0,F.jsx)("span",{children:"Units"}),(0,F.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,F.jsx)("button",{type:"button",className:i==="m"?"is-selected":"",onClick:()=>o("m"),children:"Metres"}),(0,F.jsx)("button",{type:"button",className:i==="ft"?"is-selected":"",onClick:()=>o("ft"),children:"Feet"})]})]}),r==="total"?(0,F.jsxs)("label",{className:"truss-estimator__field skirting-calculator__single-field",children:[(0,F.jsxs)("span",{children:["Total skirting length (",i,")"]}),(0,F.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:N=>c(N.target.value)})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)("div",{className:"skirting-calculator__dimensions-header",children:[(0,F.jsx)("span",{children:"Room"}),(0,F.jsxs)("span",{children:["Length (",i,")"]}),(0,F.jsxs)("span",{children:["Width (",i,")"]}),(0,F.jsx)("span",{})]}),p.map((N,A)=>(0,F.jsxs)("div",{className:"skirting-calculator__room-row",children:[(0,F.jsxs)("span",{className:"skirting-calculator__room-label",children:["Room ",A+1]}),(0,F.jsx)("input",{"aria-label":`Room ${A+1} length in ${i}`,type:"number",min:"0",step:"0.01",value:N.length,onChange:T=>v(A,"length",T.target.value)}),(0,F.jsx)("input",{"aria-label":`Room ${A+1} width in ${i}`,type:"number",min:"0",step:"0.01",value:N.width,onChange:T=>v(A,"width",T.target.value)}),p.length>1?(0,F.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>f(T=>T.filter((z,G)=>G!==A)),children:"Remove"}):null]},`room-${A}`)),(0,F.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>f(N=>[...N,_w()]),children:"+ Add another room"})]}),(0,F.jsxs)("label",{className:"truss-estimator__field skirting-calculator__single-field",children:[(0,F.jsxs)("span",{children:["Openings and doorways to deduct (",i,") ",(0,F.jsx)("small",{children:"optional"})]}),(0,F.jsx)("input",{type:"number",min:"0",step:"0.01",value:b,onChange:N=>d(N.target.value)})]})]}),(0,F.jsxs)("div",{className:"skirting-calculator__section",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"Profile"}),(0,F.jsx)("p",{className:"skirting-calculator__hint",children:"Choose the finish you want for the fixed 4.2m white-primed MDF boards."}),(0,F.jsx)("div",{className:"architrave-calculator__profiles",children:xw.map(N=>(0,F.jsxs)("button",{type:"button",className:`truss-estimator__option-card${h===N.id?" is-selected":""}`,onClick:()=>w(N.id),children:[(0,F.jsx)(V_,{profile:N.id}),(0,F.jsx)("div",{className:"truss-estimator__option-title",children:N.label}),(0,F.jsx)("div",{className:"truss-estimator__option-copy",children:N.blurb})]},N.id))})]}),(0,F.jsxs)("div",{className:"skirting-calculator__section",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"Board and waste"}),(0,F.jsx)("div",{className:"truss-estimator__field-grid skirting-calculator__options-grid",children:(0,F.jsxs)("label",{className:"truss-estimator__field",children:[(0,F.jsx)("span",{children:"Board length"}),(0,F.jsx)("input",{value:"4.20 m",disabled:!0})]})}),(0,F.jsx)("p",{className:"skirting-calculator__hint",children:"Longer boards can reduce the number of joins, while 10% waste allows for cuts, corners and mistakes."})]}),(0,F.jsxs)("div",{className:"skirting-calculator__totals",children:[(0,F.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,F.jsxs)("div",{className:"skirting-calculator__result-grid",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{children:"Net skirting"}),(0,F.jsxs)("strong",{children:[m.toFixed(2)," m"]})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{children:"Board lengths"}),(0,F.jsx)("strong",{children:u})]})]}),(0,F.jsx)("p",{className:"skirting-calculator__note",children:"Corners and joins vary by room layout. Measure each wall where possible for the most accurate result."})]}),(0,F.jsxs)("div",{className:"skirting-calculator__actions",children:[(0,F.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,F.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(g),disabled:m<=0,children:a})]})]})]})})}var jn=Y(Xe()),oe=Y(ae()),ol=e=>Number.parseFloat(e)||0;function Dd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,n]=(0,jn.useState)("studs"),[i,o]=(0,jn.useState)(""),[l,c]=(0,jn.useState)(""),[p,f]=(0,jn.useState)("600"),[b,d]=(0,jn.useState)("2.4"),h=i&&l&&p?Math.ceil(ol(l)/(ol(p)/1e3))+1:0,w=h*ol(i),M=ol(b)>0?Math.ceil(w/ol(b)):0,D=[{key:r,label:{studs:"Stud timber",joists:"Joist timber",battens:"Batten timber"}[r],qty:w,unit:"m",query:{studs:"cls studwork timber",joists:"timber joist",battens:"roofing batten"}[r],category:"timber"}],m={studs:["Stud wall","Vertical studs along a wall length"],joists:["Joists","Parallel joists across a floor or deck"],battens:["Battens","Regularly spaced battens for lining or cladding"]},g={studs:{member:"Wall height",overall:"Wall length",help:"Studs repeat across the wall length.",count:"Studs"},joists:{member:"Joist span",overall:"Overall width",help:"Joists repeat across the overall floor or deck width.",count:"Joists"},battens:{member:"Batten length",overall:"Overall width",help:"Battens repeat across the overall lining or cladding width.",count:"Battens"}}[r];return(0,oe.jsx)(oe.Fragment,{children:(0,oe.jsxs)("div",{className:"truss-estimator",children:[(0,oe.jsxs)("div",{className:"quick-order-hero",children:[(0,oe.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,oe.jsx)("h1",{children:"Timber Calculator"}),(0,oe.jsx)("p",{children:"Estimate studs, joists or battens from a run length, width and spacing."})]}),(0,oe.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,oe.jsx)("h2",{className:"truss-estimator__step-title",children:"Member size and spacing"}),(0,oe.jsxs)("p",{className:"truss-estimator__step-sub",children:[g.help," Enter the member length and centres to estimate the number of pieces and stock lengths."]}),(0,oe.jsxs)("div",{className:"materials-calculator__section",children:[(0,oe.jsx)("div",{className:"truss-estimator__section-heading",children:"Timber use"}),(0,oe.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:Object.keys(m).map(v=>(0,oe.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===v?" is-selected":""}`,onClick:()=>n(v),children:[(0,oe.jsx)("div",{className:"truss-estimator__option-title",children:m[v][0]}),(0,oe.jsx)("div",{className:"truss-estimator__option-copy",children:m[v][1]})]},v))})]}),(0,oe.jsxs)("div",{className:"materials-calculator__section",children:[(0,oe.jsx)("div",{className:"truss-estimator__section-heading",children:"Dimensions and spacing"}),(0,oe.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,oe.jsxs)("label",{className:"truss-estimator__field",children:[(0,oe.jsxs)("span",{children:[g.member," (m)"]}),(0,oe.jsx)("input",{type:"number",min:"0",step:"0.01",value:i,onChange:v=>o(v.target.value)})]}),(0,oe.jsxs)("label",{className:"truss-estimator__field",children:[(0,oe.jsxs)("span",{children:[g.overall," (m)"]}),(0,oe.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:v=>c(v.target.value)})]})]}),(0,oe.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,oe.jsxs)("label",{className:"truss-estimator__field",children:[(0,oe.jsx)("span",{children:"Centres (mm)"}),(0,oe.jsxs)("select",{value:p,onChange:v=>f(v.target.value),children:[(0,oe.jsx)("option",{value:"300",children:"300 mm"}),(0,oe.jsx)("option",{value:"400",children:"400 mm"}),(0,oe.jsx)("option",{value:"450",children:"450 mm"}),(0,oe.jsx)("option",{value:"600",children:"600 mm"})]})]}),(0,oe.jsxs)("label",{className:"truss-estimator__field",children:[(0,oe.jsx)("span",{children:"Stock length (m)"}),(0,oe.jsxs)("select",{value:b,onChange:v=>d(v.target.value),children:[(0,oe.jsx)("option",{value:"2.4",children:"2.40 m"}),(0,oe.jsx)("option",{value:"3.6",children:"3.60 m"}),(0,oe.jsx)("option",{value:"4.8",children:"4.80 m"})]})]})]})]}),(0,oe.jsxs)("div",{className:"materials-calculator__totals",children:[(0,oe.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,oe.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,oe.jsxs)("div",{children:[(0,oe.jsx)("span",{children:g.count}),(0,oe.jsx)("strong",{children:h})]}),(0,oe.jsxs)("div",{children:[(0,oe.jsx)("span",{children:"Linear metres"}),(0,oe.jsxs)("strong",{children:[w.toFixed(2)," m"]})]}),(0,oe.jsxs)("div",{children:[(0,oe.jsxs)("span",{children:[b," m lengths"]}),(0,oe.jsx)("strong",{children:M})]})]}),(0,oe.jsx)("p",{className:"materials-calculator__note",children:"Spacing is measured centre-to-centre. Add extra timber for plates, noggins, trimming and openings where required."})]}),(0,oe.jsxs)("div",{className:"materials-calculator__actions",children:[(0,oe.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,oe.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(D),disabled:w<=0,children:a})]})]})]})})}var Bd=[{id:"truss",title:"Roof Truss Calculator",desc:"Estimate trusses, girders and roof structure costs.",imageUrl:"/tool-images/truss.webp",Component:Rd},{id:"fencing",title:"Fencing Calculator",desc:"Estimate fence panels, posts, gravel boards and fixings.",imageUrl:"/tool-images/fencing.webp",Component:Cd},{id:"decking",title:"Decking Calculator",desc:"Estimate boards, substructure and fixing quantities.",imageUrl:"/tool-images/decking.webp",Component:Sd},{id:"brick-block",title:"Brick & Block Calculator",desc:"Estimate masonry units and ready-mixed mortar for a wall.",imageUrl:"/tool-images/brick-block.webp",Component:yd},{id:"paint",title:"Paint Calculator",desc:"Estimate paint for walls, doors and multiple coats.",imageUrl:"/tool-images/paint.webp",Component:Ed},{id:"skirting",title:"Skirting Board Calculator",desc:"Estimate skirting lengths for rooms and wall runs.",imageUrl:"/tool-images/skirting.webp",Component:Ud},{id:"architrave",title:"Architrave Calculator",desc:"Estimate architrave lengths for door and window openings.",imageUrl:"/tool-images/architrave.webp",Component:wd},{id:"concrete-aggregate",title:"Concrete & Aggregate Calculator",desc:"Estimate concrete, MOT, sand and gravel quantities.",imageUrl:"/tool-images/concrete-aggregate.webp",Component:kd},{id:"plasterboard",title:"Plasterboard Calculator",desc:"Estimate plasterboard sheets, screws, tape and adhesive.",imageUrl:"/tool-images/plasterboard.webp",Component:Ad},{id:"insulation",title:"Insulation Calculator",desc:"Estimate insulation packs for floors, walls, roofs and lofts.",imageUrl:"/tool-images/insulation.webp",Component:qd},{id:"timber",title:"Timber Calculator",desc:"Estimate studs, joists and battens from spacing and lengths.",imageUrl:"/tool-images/timber.webp",Component:Dd},{id:"paving",title:"Paving & Driveway Calculator",desc:"Estimate paving, block paving, MOT and sharp sand.",imageUrl:"/tool-images/paving.webp",Component:Td}];var dc=Y(Xe());var Le=Y(Xe());var S=Y(ae()),X_=[{dir:"asc",label:"Description (A-Z)"},{dir:"desc",label:"Description (Z-A)"}],Od={wasteFactorEnabled:!0},$_=3e3,Nw=null;function pc(e,t){let a=Fo(t);return a?`${e.toFixed(2)} ${a}`:e.toFixed(2)}function Z_(e){return e&&e.length>0?e.join(" x "):"-"}function Ld({toolId:e,requirements:t,ready:a,onBack:r,onTotalChange:n}){let i=Js(),o=`${e}~${t.map(C=>`${C.key}|${C.query}|${C.category??""}|${C.qty}`).join("~")}`,l=o!==Nw,[c,p]=(0,Le.useState)(null),[f,b]=(0,Le.useState)([]),[d,h]=(0,Le.useState)(l),[w,M]=(0,Le.useState)(null),[D,m]=(0,Le.useState)("tile"),[u,g]=(0,Le.useState)(null),[v,N]=(0,Le.useState)(""),[A,T]=(0,Le.useState)(null),[z,G]=(0,Le.useState)(""),[K,fe]=(0,Le.useState)([]),[Te,Ye]=(0,Le.useState)(new Set),[Ve,it]=(0,Le.useState)(null),[pe,Q]=(0,Le.useState)(""),[ce,xe]=(0,Le.useState)([]),ye=(0,Le.useRef)(null),ee=(0,Le.useRef)(!1),se=C=>`${e}:${C}`,Me=C=>Kr(C.chosen,{lineId:se(C.requirement.key),description:C.requirement.label,unit:C.requirement.unit,qty:C.requirement.qty}),_e=(0,Le.useMemo)(()=>t.map(C=>`${C.key}|${C.query}|${C.category??""}`).join("~"),[t]);(0,Le.useEffect)(()=>{let C=!1;return pw().then(V=>{C||p(V.itemCount>0)}).catch(()=>{C||p(!1)}),()=>{C=!0}},[]),(0,Le.useEffect)(()=>{if(!a||!c)return;let C=!1,V;l&&h(!0),M(null);let X=Date.now();return(async()=>{let me=null;try{me=(await uw(t)).map(({requirement:dt,candidates:je})=>({requirement:dt,candidates:je,chosen:je[0]??null}))}catch(Ce){C||M(Ce instanceof Error?Ce.message:"Could not load products")}if(!C){if(Nw=o,l){let Ce=$_-(Date.now()-X);Ce>0&&await new Promise(dt=>{V=window.setTimeout(dt,Ce)})}C||(me&&(b(me),!ee.current&&i&&(ee.current=!0,i.addManyToCart(me.filter(Ce=>Ce.chosen).map(Me)))),h(!1))}})(),()=>{C=!0,window.clearTimeout(V)}},[a,c,_e]),(0,Le.useEffect)(()=>{if(!A)return;let C=z.trim();if(!C){fe([]);return}let V=!1,X=window.setTimeout(()=>{Jr(C).then(me=>{V||fe(me)}).catch(()=>{V||fe([])})},250);return()=>{V=!0,window.clearTimeout(X)}},[A,z]),(0,Le.useEffect)(()=>{if(!Ve)return;let C=pe.trim();if(!C){xe([]);return}let V=!1,X=window.setTimeout(()=>{Jr(C).then(me=>{V||xe(me)}).catch(()=>{V||xe([])})},250);return()=>{V=!0,window.clearTimeout(X)}},[Ve,pe]);let et=(0,Le.useMemo)(()=>{let C=v.trim().toLowerCase(),V=C?f.filter(X=>X.requirement.label.toLowerCase().includes(C)||(X.chosen?.description??"").toLowerCase().includes(C)||(X.chosen?.product_id??"").toLowerCase().includes(C)):f;return u?[...V].sort((X,me)=>{let Ce=X.requirement.label.localeCompare(me.requirement.label);return u==="asc"?Ce:-Ce}):V},[f,v,u]),Ht=et.filter(C=>C.chosen),Tt=et.filter(C=>!C.chosen),tt=f.filter(C=>C.chosen),ct=tt.filter(C=>C.chosen?.price==null).length,He=tt.reduce((C,V)=>C+(ua(Me(V),Od).lineTotal??0),0);if((0,Le.useEffect)(()=>{n?.(He)},[He,n]),!a||c===!1)return null;let E=i?tt.filter(C=>i.cart[se(C.requirement.key)]).length:0,x=Ve?f.find(C=>C.requirement.key===Ve)??null:null,I=pe.trim()?ce:x?.candidates??[],ue=C=>{let V=A===C.requirement.key;T(V?null:C.requirement.key),G(V?"":C.requirement.query)},ve=(C,V)=>{let X=f.find(me=>me.requirement.key===C);b(me=>me.map(Ce=>Ce.requirement.key===C?{...Ce,chosen:V}:Ce)),i&&X&&i.cart[se(C)]&&i.addToCart(Me({...X,chosen:V})),T(null),G("")},Se=C=>{b(V=>V.map(X=>X.requirement.key===C?{...X,chosen:null}:X)),i?.cart[se(C)]&&i.removeFromCart(se(C))},k=C=>{it(C.requirement.key),Q(""),xe([])},j=()=>{it(null),Q(""),xe([])},O=C=>{if(!i)return;let V=se(C.requirement.key);i.cart[V]?i.removeFromCart(V):i.addToCart(Me(C))},ne=C=>{Ye(V=>{let X=new Set(V);return X.has(C)?X.delete(C):X.add(C),X})},W=C=>{let V=K.length>0?K:C.candidates;return(0,S.jsxs)("div",{className:"estimator-products__picker",children:[(0,S.jsx)("input",{type:"text",className:"results-search-input",value:z,autoFocus:!0,placeholder:"Search products in catalogue...",onChange:X=>G(X.target.value),"aria-label":`Search a product for ${C.requirement.label}`}),(0,S.jsxs)("div",{className:"estimator-products__options",children:[V.map(X=>(0,S.jsxs)("button",{type:"button",className:`estimator-products__option${X.product_id===C.chosen?.product_id?" is-selected":""}`,onClick:()=>ve(C.requirement.key,X),children:[(0,S.jsx)("span",{children:X.description}),(0,S.jsxs)("span",{className:"results-row-meta",children:[X.product_id,X.price!=null&&` \xB7 ${nt(X.price)}`]})]},X.product_id)),V.length===0&&(0,S.jsx)("p",{className:"results-empty-hint",children:"No matching products."})]})]})};return(0,S.jsxs)("section",{className:"estimator-products results-tile-section","aria-label":"Matched products",children:[!d&&(0,S.jsxs)("div",{className:"estimator-products__head",children:[(0,S.jsxs)("div",{className:"results-tile-section__head",children:[(0,S.jsx)("h3",{children:"Matched Products"}),(0,S.jsx)("p",{children:"Products matched to your estimate, check before adding to your basket."})]}),!x&&(0,S.jsxs)("div",{className:"results-summary estimator-products__toolbar",children:[ct>0&&(0,S.jsxs)("span",{className:"summary-chip summary-chip--neutral",children:[(0,S.jsx)("strong",{children:ct})," need pricing"]}),(0,S.jsxs)("div",{className:"estimator-products__controls",children:[(0,S.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search description...",value:v,onChange:C=>N(C.target.value),"aria-label":"Search matched products"}),(0,S.jsxs)("div",{className:"results-view-toggle","aria-label":"Results view",children:[(0,S.jsx)("button",{type:"button",className:`results-view-toggle__btn${D==="tile"?" is-active":""}`,"aria-pressed":D==="tile","aria-label":"Tile view",title:"Tile view",onClick:()=>m("tile"),children:(0,S.jsxs)("svg",{width:"18",height:"12",viewBox:"0 0 15 10",fill:"currentColor",children:[(0,S.jsx)("rect",{x:"0.5",y:"0.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"5.5",y:"0.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"10.5",y:"0.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"0.5",y:"5.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"5.5",y:"5.5",width:"4",height:"4"}),(0,S.jsx)("rect",{x:"10.5",y:"5.5",width:"4",height:"4"})]})}),(0,S.jsx)("button",{type:"button",className:`results-view-toggle__btn${D==="list"?" is-active":""}`,"aria-pressed":D==="list","aria-label":"List view",title:"List view",onClick:()=>m("list"),children:(0,S.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 15 15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,S.jsx)("line",{x1:"0.5",y1:"2.5",x2:"14.5",y2:"2.5"}),(0,S.jsx)("line",{x1:"0.5",y1:"7.5",x2:"14.5",y2:"7.5"}),(0,S.jsx)("line",{x1:"0.5",y1:"12.5",x2:"14.5",y2:"12.5"})]})})]}),(0,S.jsxs)("details",{ref:ye,style:{position:"relative"},children:[(0,S.jsx)("summary",{className:"bom-toolbar-btn sort-menu-summary","aria-label":"Sort materials",style:{fontSize:16},children:"\u21C5"}),(0,S.jsx)("div",{className:"sort-menu-panel",children:X_.map(C=>{let V=u===C.dir;return(0,S.jsxs)("button",{type:"button",className:`sort-menu-item${V?" is-active":""}`,onClick:()=>{g(V?null:C.dir),ye.current?.removeAttribute("open")},children:[(0,S.jsx)("span",{className:"sort-menu-item__check",children:V?"\u2713":""}),C.label]},C.dir)})})]})]})]})]}),x&&(0,S.jsxs)("div",{className:"results-review-page",children:[(0,S.jsxs)("div",{className:"results-review-page__top",children:[(0,S.jsxs)("button",{type:"button",className:"bom-toolbar-btn bom-toolbar-btn--accent",onClick:j,children:[(0,S.jsx)(Zr,{}),"Back to results"]}),(0,S.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,S.jsx)("div",{className:"results-review-searchbar",children:(0,S.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search products in catalogue...",value:pe,onChange:C=>Q(C.target.value),"aria-label":`Search a product for ${x.requirement.label}`})}),x.chosen&&(0,S.jsx)("div",{className:"results-candidate-actions",children:(0,S.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Se(x.requirement.key),children:"Clear selected product"})})]})]}),(0,S.jsxs)("div",{className:"results-review-page__hero",children:[(0,S.jsx)("div",{className:"results-review-page__image-wrap",children:(0,S.jsx)("img",{className:"fill-img results-review-page__image",src:Qa(x.chosen?.description||x.requirement.label,x.chosen?.product_id,x.chosen?.pdp_photo_url),alt:""})}),(0,S.jsxs)("div",{className:"results-review-page__summary",children:[(0,S.jsx)("h2",{children:x.requirement.label}),(0,S.jsxs)("p",{className:"results-review-page__meta",children:[_i(x.requirement.qty)," ",ka(x.requirement.unit,x.requirement.qty)]}),x.chosen?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("div",{className:"results-review-page__product",children:x.chosen.description}),(0,S.jsxs)("div",{className:"results-row-meta",children:[x.chosen.product_id,x.chosen.price!=null?` \xB7 ${pc(x.chosen.price,x.chosen.price_basis)}`:""]})]}):(0,S.jsx)("div",{className:"results-empty-hint",children:"No product currently selected for this line."}),(0,S.jsx)("div",{className:"results-review-page__actions",children:(0,S.jsx)("button",{type:"button",className:`bom-toolbar-btn${i?.cart[se(x.requirement.key)]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>O(x),disabled:!x.chosen||!i,children:i?.cart[se(x.requirement.key)]?"\u2713 Added":"+ Add to basket"})})]})]}),I.length===0?(0,S.jsx)("p",{className:"results-empty-hint",children:"No matching products."}):(0,S.jsxs)("table",{className:"score-breakdown-table",children:[(0,S.jsx)("thead",{children:(0,S.jsxs)("tr",{children:[(0,S.jsx)("th",{children:"Product"}),(0,S.jsx)("th",{children:"Dims (mm)"}),(0,S.jsx)("th",{children:"Price"}),(0,S.jsx)("th",{"aria-label":"Actions"})]})}),(0,S.jsx)("tbody",{children:I.map(C=>{let V=C.product_id===x.chosen?.product_id;return(0,S.jsxs)("tr",{className:V?"score-breakdown-row--best":"",children:[(0,S.jsxs)("td",{children:[(0,S.jsx)("div",{children:C.description}),(0,S.jsx)("div",{className:"results-row-meta",children:C.product_id})]}),(0,S.jsx)("td",{children:(0,S.jsx)("span",{className:"unit-badge",children:Z_(C.measurements_mm)})}),(0,S.jsx)("td",{children:C.price!=null?pc(C.price,C.price_basis):"-"}),(0,S.jsx)("td",{children:(0,S.jsxs)("label",{className:"switch-toggle",title:V?"Currently selected":"Use this candidate",children:[(0,S.jsx)("input",{type:"checkbox",checked:V,onChange:()=>{V?Se(x.requirement.key):ve(x.requirement.key,C)},"aria-label":V?`${C.description} selected`:`Use ${C.description}`}),(0,S.jsx)("span",{className:"switch-toggle-track","aria-hidden":"true"})]})})]},C.product_id)})})]})]}),!x&&d&&(0,S.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{padding:"32px 24px"},children:[(0,S.jsx)(dr,{}),(0,S.jsx)("p",{className:"banter-message is-visible",style:{fontSize:15,minHeight:0},children:"Matching your materials against the catalogue\u2026"})]}),!x&&w&&(0,S.jsx)("p",{className:"results-empty-hint estimator-products__error",children:w}),!x&&!d&&!w&&et.length===0&&f.length>0&&(0,S.jsx)("p",{className:"results-empty-hint",children:"No materials match the current search."}),!x&&!d&&!w&&D==="tile"&&Ht.length>0&&(0,S.jsx)("div",{className:"results-tile-grid",children:Ht.map(C=>{let{requirement:V,chosen:X}=C,me=X?ua(Me(C),Od):null,Ce=i?!!i.cart[se(V.key)]:!1;return(0,S.jsxs)("article",{className:"results-tile-card",children:[(0,S.jsxs)("button",{type:"button",className:"results-tile-card__surface",onClick:()=>k(C),"aria-label":`Review match for ${V.label}`,children:[(0,S.jsx)("div",{className:"results-tile-card__media",children:(0,S.jsx)("img",{className:"fill-img results-tile-card__image",src:Qa(X?.description||V.label,X?.product_id,X?.pdp_photo_url),alt:""})}),(0,S.jsxs)("div",{className:"results-tile-card__body",children:[X?(0,S.jsxs)("div",{className:"results-tile-card__heading",children:[(0,S.jsx)("div",{className:"results-tile-card__title",children:X.description}),(0,S.jsxs)("div",{className:"results-tile-card__match-meta",children:[(0,S.jsx)("span",{children:X.product_id}),X.price!=null?(0,S.jsx)("span",{children:pc(X.price,X.price_basis)}):null]})]}):(0,S.jsx)("div",{className:"results-empty-hint",children:"No product matched for this line."}),(0,S.jsxs)("div",{className:"results-tile-card__match",children:[(0,S.jsx)("div",{className:"results-tile-card__match-label",children:"\u21B3 calculated as"}),(0,S.jsx)("div",{className:"results-tile-card__match-name",children:V.label}),(0,S.jsxs)("div",{className:"results-tile-card__meta",children:[_i(V.qty)," ",ka(V.unit,V.qty)]}),me?.requiredSellUnits!=null?(0,S.jsxs)("div",{className:"results-tile-card__meta estimator-products__order",children:["Order ",me.requiredSellUnits," ",me.sellUnit,me.lineTotal!=null?` \xB7 ${nt(me.lineTotal)}`:""]}):X?(0,S.jsx)("div",{className:"results-row-meta",children:"Quantity needs review"}):null]})]})]}),(0,S.jsxs)("div",{className:"results-tile-card__actions",children:[(0,S.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>k(C),children:"Review"}),(0,S.jsx)("button",{type:"button",className:`bom-toolbar-btn${Ce?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>O(C),disabled:!X||!i,children:Ce?"\u2713 Added":"+ Add"})]})]},V.key)})}),!x&&!d&&!w&&D==="list"&&Ht.length>0&&(0,S.jsx)("div",{className:"bom-table-wrap",children:(0,S.jsxs)("table",{className:"bom-table results-table","aria-label":"Matched materials",children:[(0,S.jsxs)("colgroup",{children:[(0,S.jsx)("col",{style:{width:"56px"}}),(0,S.jsx)("col",{className:"col-item"}),(0,S.jsx)("col",{style:{width:"90px"}}),(0,S.jsx)("col",{style:{width:"80px"}}),(0,S.jsx)("col",{style:{width:"220px"}}),(0,S.jsx)("col",{style:{width:"110px"}})]}),(0,S.jsx)("thead",{children:(0,S.jsxs)("tr",{className:"bom-col-header",children:[(0,S.jsx)("th",{"aria-label":"Expand"}),(0,S.jsx)("th",{style:{textAlign:"left"},children:"Description"}),(0,S.jsx)("th",{style:{textAlign:"center"},children:"Qty"}),(0,S.jsx)("th",{style:{textAlign:"center"},children:"Unit"}),(0,S.jsx)("th",{style:{textAlign:"center"},children:"Product Matched"}),(0,S.jsx)("th",{style:{textAlign:"center"},children:"Basket"})]})}),(0,S.jsx)("tbody",{children:Ht.map(C=>{let{requirement:V,chosen:X}=C,me=X?ua(Me(C),Od):null,Ce=i?!!i.cart[se(V.key)]:!1,dt=Te.has(V.key);return(0,S.jsxs)(Le.Fragment,{children:[(0,S.jsxs)("tr",{className:"bom-row",children:[(0,S.jsx)("td",{className:"bom-actions",style:{textAlign:"center",paddingLeft:0,paddingRight:0},children:(0,S.jsx)("button",{type:"button",className:"link-btn",onClick:()=>ne(V.key),"aria-expanded":dt,"aria-label":dt?"Collapse product options":"Expand product options",children:dt?"\u25BE":"\u25B8"})}),(0,S.jsxs)("td",{style:{paddingLeft:0},children:[(0,S.jsx)("div",{className:"bom-component-name",children:V.label}),me?.requiredSellUnits!=null&&(0,S.jsxs)("div",{className:"results-row-meta",children:["Order ",me.requiredSellUnits," ",me.sellUnit,me.lineTotal!=null?` \xB7 ${nt(me.lineTotal)}`:""]})]}),(0,S.jsx)("td",{className:"bom-qty col-order",style:{textAlign:"center"},children:_i(V.qty)}),(0,S.jsx)("td",{style:{textAlign:"center"},children:ka(V.unit,V.qty)}),(0,S.jsx)("td",{style:{textAlign:"center"},children:X?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("div",{className:"bom-component-name",children:X.description}),(0,S.jsxs)("div",{className:"results-row-meta",children:[X.product_id,X.price!=null&&` \xB7 ${pc(X.price,X.price_basis)}`]})]}):(0,S.jsx)("span",{className:"results-empty-hint",children:"No match"})}),(0,S.jsx)("td",{style:{textAlign:"center"},children:(0,S.jsx)("button",{type:"button",className:`bom-toolbar-btn${Ce?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>O(C),disabled:!X||!i,children:Ce?"\u2713 Added":"+ Add"})})]}),dt&&(0,S.jsx)("tr",{children:(0,S.jsx)("td",{colSpan:6,style:{paddingLeft:0,paddingRight:0},children:A===V.key?W(C):(0,S.jsxs)("div",{className:"estimator-products__picker",children:[(0,S.jsxs)("div",{className:"estimator-products__options",children:[C.candidates.map(je=>(0,S.jsxs)("button",{type:"button",className:`estimator-products__option${je.product_id===X?.product_id?" is-selected":""}`,onClick:()=>ve(V.key,je),children:[(0,S.jsx)("span",{children:je.description}),(0,S.jsxs)("span",{className:"results-row-meta",children:[je.product_id,je.price!=null&&` \xB7 ${nt(je.price)}`]})]},je.product_id)),C.candidates.length===0&&(0,S.jsx)("p",{className:"results-empty-hint",children:"No candidates found."})]}),(0,S.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>ue(C),children:"Search the catalogue"})]})})})]},V.key)})})]})}),!x&&!d&&!w&&Tt.length>0&&(0,S.jsxs)("section",{className:"results-tile-section results-tile-section--unmatched","aria-label":"Items requiring matching",children:[(0,S.jsxs)("div",{className:"results-tile-section__head",children:[(0,S.jsx)("h3",{children:"Require Matching"}),(0,S.jsx)("p",{children:"We couldn\u2019t confidently match these to a product. Open one to pick from the closest options."})]}),(0,S.jsx)("div",{className:"results-unmatched-list",children:Tt.map(C=>(0,S.jsxs)("button",{type:"button",className:"results-unmatched-card",onClick:()=>k(C),children:[(0,S.jsxs)("span",{className:"results-unmatched-card__main",children:[(0,S.jsx)("span",{className:"results-unmatched-card__title",children:C.requirement.label}),(0,S.jsxs)("span",{className:"results-row-meta",children:[_i(C.requirement.qty)," ",ka(C.requirement.unit,C.requirement.qty)]})]}),(0,S.jsx)("span",{className:"bom-toolbar-btn results-unmatched-card__prompt",children:"Review"})]},C.requirement.key))})]}),!d&&!w&&f.length>0&&(0,S.jsxs)("div",{className:"disclaimer-box",style:{alignItems:"center"},children:[(0,S.jsx)("span",{className:"disclaimer-icon",children:"\u26A0\uFE0F"}),(0,S.jsx)("p",{className:"disclaimer-text",children:"These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence."})]}),!x&&!d&&!w&&(r||E>0)&&(0,S.jsxs)("div",{className:"btn-row estimator-products__footer",children:[r&&(0,S.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:r,children:"Back"}),E>0&&i&&(0,S.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:r?"0 1 70%":1,marginTop:0},onClick:i.openBasket,children:[(0,S.jsxs)("span",{children:["View Basket (",E,")"]}),(0,S.jsx)("span",{className:"arrow",children:(0,S.jsx)(Ot,{})})]})]})]})}var Lt=Y(ae());function Hd({toolId:e,toolTitle:t,requirements:a,onBack:r}){let[n,i]=(0,dc.useState)(0),o=(0,dc.useCallback)(l=>i(l),[]);return(0,Lt.jsx)(Lt.Fragment,{children:(0,Lt.jsxs)("div",{className:"truss-estimator",children:[(0,Lt.jsxs)("div",{className:"quick-order-hero",children:[(0,Lt.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Lt.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,Lt.jsx)("h1",{children:"Your Materials"}),n>0&&(0,Lt.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,Lt.jsx)("strong",{children:nt(n)})," Est. total"]})]}),(0,Lt.jsxs)("p",{children:["Quantities from the ",t,", matched against your merchant\u2019s catalogue."]})]}),(0,Lt.jsx)("div",{className:"truss-estimator__card",style:{minHeight:0},children:(0,Lt.jsx)(Ld,{toolId:e,requirements:a,ready:!0,onBack:r,onTotalChange:o})})]})})}var K_=(e,t)=>{let a=t.key,r={"brick-block":{"brick-common":"5001444","brick-engineering-red":"5002008","brick-engineering-blue":"5001439",block:"5003187",mortar:"6003088"},skirting:{"skirting-chamfered":"4006057","skirting-ogee":"4006045","skirting-pencil-round":"4006048","skirting-torus":"4006042"},architrave:{"architrave-ogee":"4006060","architrave-ovolo":"4006063","architrave-pencil-round":"4006061","architrave-square-edge":"4006062","architrave-torus":"4006059"},plasterboard:{board:"2001035",screws:"2006040",tape:"2007043",adhesive:"2004023"},insulation:{"insulation-floor":"3002110","insulation-wall":"3002012","insulation-roof":"3004047","insulation-loft":"3003046"},timber:{studs:"4001168",joists:"4001201",battens:"4001053"},fencing:{"panels-boundary-0.9":"4001268","panels-boundary-1.2":"4001269","panels-boundary-1.5":"4001270","panels-boundary-1.8":"4001271","panels-skyline-0.9":"4001264","panels-skyline-1.2":"4001265","panels-skyline-1.5":"4001266","panels-skyline-1.8":"4001267","concrete-intermediate-6":"4001290","concrete-intermediate-8":"4001291","concrete-end-6":"4001294","concrete-end-8":"4001295","timber-post-6":"4001242","timber-post-8":"4001243",postcrete:"6003008",gate:"4001630","gravel-boards":"4001284"},decking:{"boards-meridian":"4001251","boards-summit":"4001360",joists:"4001201",screws:"1001103"},paving:{"surface-council":"7003121","surface-raj":"7003003","surface-brindle":"4001621","surface-charcoal":"4001622","surface-pea":"6001004","sub-base":"6001007",bedding:"6001012"}};return e==="plasterboard"?{standard:"2001035",moisture:"2002039",fire:"2002087",sound:"2002044"}[t.label.split(" ")[0].toLowerCase()]??r[e]?.[a]??null:r[e]?.[a]??null};function Sw(e,t){if(e==="paint"||e==="concrete-aggregate")return null;let a=t.map(r=>{let n=K_(e,r);return n?{key:r.key,productId:n,qty:r.qty,unit:r.unit}:null});return a.every(Boolean)?a:null}var jd=Y(Xe());var Pt=Y(ae()),P_=1500;function Cw(e){let{addManyToCart:t,clearCart:a,openBasket:r}=An(),[n,i]=(0,jd.useState)(!1),[o,l]=(0,jd.useState)(null);return{adding:n,basketError:o,addToBasket:async(p,f)=>{let b=Date.now();i(!0),l(null);try{let d=await Promise.all(p.filter(w=>w.qty>0).map(async w=>{let M=(await Jr(w.productId)).find(D=>D.product_id===w.productId);if(!M)throw new Error("A selected product is no longer available in this catalogue.");return Kr(M,{lineId:`${e}:${w.key}`,description:M.description,unit:w.unit??"each",qty:w.qty,calculatorWasteIncluded:f})})),h=P_-(Date.now()-b);h>0&&await new Promise(w=>window.setTimeout(w,h)),a(),t(d),r()}catch(d){l(d instanceof Error?d.message:"Could not add the products to your basket.")}finally{i(!1)}}}}function qw({toolTitle:e}){return(0,Pt.jsx)(Pt.Fragment,{children:(0,Pt.jsxs)("div",{className:"truss-estimator",children:[(0,Pt.jsxs)("div",{className:"quick-order-hero",children:[(0,Pt.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Pt.jsx)("h1",{children:"Your Materials"}),(0,Pt.jsxs)("p",{children:["Calculating quantities from the ",e,"."]})]}),(0,Pt.jsx)("div",{className:"truss-estimator__card",children:(0,Pt.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{flex:1,justifyContent:"center"},children:[(0,Pt.jsx)(dr,{}),(0,Pt.jsx)("p",{className:"banter-message is-visible",children:"Preparing your materials\u2026"})]})})]})})}var Re=Y(ae());function mc(e){let[t,a]=(0,Va.useState)(!1);return(0,Re.jsx)(Ps,{onOpenBasket:()=>a(!0),children:(0,Re.jsx)(J_,{...e,showBasket:t,onShowBasket:a})})}function J_({fullPage:e=!1,hideHeader:t=!1,internal:a=!1,showBasket:r,onShowBasket:n}){let[i,o]=(0,Va.useState)(null),[l,c]=(0,Va.useState)(null),p=Bd.find(z=>z.id===i),{cart:f,updateCartQty:b,updateCartSellUnits:d,updateCartConversions:h,removeFromCart:w,clearCart:M}=An(),{adding:D,basketError:m,addToBasket:u}=Cw(p?.title??"calculator"),g=(0,Va.useRef)(null),v=Gs("estimating-tools",g);(0,Va.useEffect)(()=>{v("viewed")},[v]);let N=r?"basket":D?"adding":l?"review":i??"list",A=(0,Va.useRef)(N);(0,Va.useEffect)(()=>{A.current!==N&&(A.current=N,window.scrollTo(0,0))},[N]);let T=z=>{if(!p)return;v("estimate_completed",{calculator:p.id,lines:z.length});let G=Sw(p.id,z);G?u(G,z[0]?.calculatorWasteIncluded??!1):c(z)};return(0,Re.jsx)(Zo.Provider,{value:v,children:(0,Re.jsx)("div",{ref:g,className:`app-wrapper${e?"":" app-wrapper--embedded"}${t?" app-wrapper--no-header":""}`,style:pr().theme,children:(0,Re.jsx)("main",{className:"main-content",children:r?(0,Re.jsx)(rl,{cart:f,onUpdateQty:b,onUpdateSellUnits:d,onResolveConversions:h,onRemove:w,onBack:()=>n(!1),onStartNewQuote:()=>{M(),o(null),c(null),n(!1)},internal:a}):D&&p?(0,Re.jsx)(qw,{toolTitle:p.title}):p?(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)("div",{hidden:l!==null,children:(0,Re.jsx)(p.Component,{onBack:()=>o(null),onReview:T})}),m&&(0,Re.jsx)("p",{className:"results-empty-hint estimator-products__error",children:m}),l!==null&&(0,Re.jsx)(Hd,{toolId:p.id,toolTitle:p.title,requirements:l,onBack:()=>c(null)})]}):(0,Re.jsx)(Re.Fragment,{children:(0,Re.jsxs)("div",{className:"quick-order-card",children:[(0,Re.jsxs)("div",{className:"quick-order-hero",children:[(0,Re.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,Re.jsx)("h1",{children:"Estimating Tools"}),(0,Re.jsx)("p",{children:"Trade-specific calculators for trusses, fencing, decking, masonry and painting. Dial in your specs and get an instant material estimate."})]}),(0,Re.jsxs)("div",{className:"quick-order-alt",children:[(0,Re.jsx)("div",{className:"quick-order-alt-title",children:"Choose a Calculator"}),(0,Re.jsx)("div",{className:"estimator-tools-grid",children:Bd.map(z=>(0,Re.jsxs)("button",{type:"button",className:"estimator-tool-card",onClick:()=>{v("calculator_selected",{calculator:z.id}),o(z.id),c(null)},children:[(0,Re.jsx)("span",{className:"estimator-tool-card__image-wrap",children:(0,Re.jsx)("img",{className:"fill-img estimator-tool-card__image",src:Kt(z.imageUrl),alt:""})}),(0,Re.jsxs)("span",{className:"estimator-tool-card__content",children:[(0,Re.jsx)("span",{className:"estimator-tool-card__title",children:z.title}),(0,Re.jsx)("span",{className:"estimator-tool-card__desc",children:z.desc})]})]},z.id))})]})]})})})})})}var fc=Y(ae());function Gd({config:e,children:t}){return $b(e),(0,fc.jsx)(fc.Fragment,{children:t})}var Qd=Y(ae()),F_="https://api.metronlabs.ai",I_=["client","api-key","api-url","theme","hide-header","analytics"],W_=["all","events-only","none"];function Mw(e,t){var a;customElements.get(e)||customElements.define(e,(a=class extends HTMLElement{constructor(){super();this.root=null;this.attachShadow({mode:"open"})}connectedCallback(){if(this.dataset.version="0.1.28",!this.root){let n=document.createElement("div"),i=document.createElement("style");i.textContent=`:host { display: block; }
|
|
6781
6799
|
:host > div { all: initial; display: block; }
|
|
6782
6800
|
${Xb}`,this.shadowRoot.replaceChildren(i,n),this.root=(0,Ew.createRoot)(n)}this.renderWidget()}disconnectedCallback(){queueMicrotask(()=>{this.isConnected||!this.root||(this.root.unmount(),this.root=null)})}attributeChangedCallback(){this.root&&this.renderWidget()}renderWidget(){let n=this.getAttribute("client")??void 0,i=this.getAttribute("api-key")??void 0;(!n||!i)&&console.error(`<${e}> needs client and api-key attributes.`);let o={apiBaseUrl:this.getAttribute("api-url")||F_,client:n,apiKey:i,theme:tx(e,this.getAttribute("theme")),analytics:ex(this.getAttribute("analytics"))};this.root.render((0,Qd.jsx)(Gd,{config:o,children:(0,Qd.jsx)(t,{hideHeader:this.hasAttribute("hide-header")})}))}},a.observedAttributes=I_,a))}function ex(e){return W_.find(t=>t===e)??"all"}function tx(e,t){if(t)try{return JSON.parse(t)}catch{console.error(`<${e}> theme attribute isn't valid JSON; using the default colours.`);return}}Mw("metron-labs-quick-quote",Fs);Mw("metron-labs-estimating-tools",mc);
|
|
6783
6801
|
/*! Bundled license information:
|