@metron-labs/quote-react 0.1.69 → 0.1.70
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
CHANGED
|
@@ -6971,7 +6971,7 @@ Error generating stack: `+r.message+`
|
|
|
6971
6971
|
`).map(t=>t.trim()).filter(Boolean);function cv(e){let t=y_(e);if(t.length>500)return`That's ${t.length} lines - the limit is 500. Split the list and match it in parts.`;if(e.length>5e4)return`That's ${e.length.toLocaleString("en-GB")} characters - the limit is ${5e4.toLocaleString("en-GB")}. Split the list and match it in parts.`;let a=t.findIndex(r=>r.length>500);return a>=0?`Line ${a+1} is ${t[a].length} characters - keep each item on its own line (max 500).`:null}async function uv(e){if(e.size<=5242880)return e;let t;try{t=await createImageBitmap(e)}catch{return e}let a=Math.min(1,2e3/Math.max(t.width,t.height)),r=document.createElement("canvas");r.width=Math.round(t.width*a),r.height=Math.round(t.height*a);let i=r.getContext("2d");if(!i)return e;i.fillStyle="#fff",i.fillRect(0,0,r.width,r.height),i.drawImage(t,0,0,r.width,r.height),t.close();let n=await new Promise(o=>r.toBlob(o,"image/jpeg",.85));return!n||n.size>=e.size?e:new File([n],`${e.name.replace(/\.[^.]+$/,"")}.jpg`,{type:"image/jpeg"})}var $r=$(He());var ec=$(He()),Ws=$(F()),k_=[4,5,4],_d=4e3;function wi(){let[e,t]=(0,ec.useState)(0);(0,ec.useEffect)(()=>{let r=setInterval(()=>t(i=>i+1),_d);return()=>clearInterval(r)},[]);let a=0;return(0,Ws.jsx)("div",{className:"brick-wall","aria-hidden":!0,children:k_.map((r,i)=>(0,Ws.jsx)("div",{className:"brick-wall__course",children:Array.from({length:r},(n,o)=>(0,Ws.jsx)("span",{className:`brick-wall__brick${r===5&&(o===0||o===4)?" brick-wall__brick--half":""}`,style:{"--i":a++}},o))},i))},e)}var al=$(F()),tc=["Measuring twice, quoting once","Counting bricks so you don't have to","Haggling with the price of timber","Adding a bit extra for the skip","Double-checking nobody ordered too much sand","Rounding up, obviously","Making sure the numbers add up better than the last lot did","Checking if copper pipe is still worth its weight in gold","Squeezing a bit more accuracy out of the numbers","Totting it all up on the back of a fag packet, digitally","Making sure the quote is tighter than your tolerances","Nearly there, unlike most site schedules","Working out if it'll all fit on one pallet","Double-checking the VAT, because someone has to","Giving the calculator a proper workout","Making sure nothing's out of stock before you get excited"];function fv(e){let t=[...e];for(let a=t.length-1;a>0;a--){let r=Math.floor(Math.random()*(a+1));[t[a],t[r]]=[t[r],t[a]]}return t}function hv(){let e=(0,$r.useRef)(0),t=(0,$r.useRef)(fv(tc.map((o,l)=>l))),[a,r]=(0,$r.useState)(tc[t.current[0]]),[i,n]=(0,$r.useState)(!0);return(0,$r.useEffect)(()=>{let o=setInterval(()=>{n(!1),window.setTimeout(()=>{e.current++,e.current>=t.current.length&&(t.current=fv(tc.map((l,c)=>c)),e.current=0),r(tc[t.current[e.current]]),n(!0)},600)},_d);return()=>clearInterval(o)},[]),(0,al.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",children:[(0,al.jsx)(wi,{}),(0,al.jsx)("p",{className:`banter-message${i?" is-visible":""}`,children:a})]})}var ac=$(He());function rl(e,t){let a=(0,ac.useRef)(t);a.current=t,(0,ac.useEffect)(()=>{if(!e)return;let r=i=>{i.key!=="Escape"||i.defaultPrevented||i.isComposing||(i.preventDefault(),a.current())};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e])}var xd={"#quote-entry":"entry","#matched-products":"results","#quote-request":"basket"},gv=!1,ic="",kd=!1,bv=()=>window.navigation,rc=-1;function S_(){if(kd)return-1;let e=bv()?.currentEntry?.index;return e==null||rc<0||e===rc?0:e<rc?-1:1}function N_(e){let t=new URL(ic||window.location.href),a=new URL(window.location.href);if(ic=a.href,t.pathname!==a.pathname||t.search!==a.search||!(t.hash in xd)&&!(a.hash in xd))return;let r=t.href===a.href?S_():0;if(r){e.stopImmediatePropagation(),window.history.go(r);return}kd=!1;let i=e.state;Object.defineProperty(e,"state",{value:null}),setTimeout(()=>{if(window.location.href!==a.href)return;let n=xd[a.hash],o=n&&i?.turbo?{boqQuoteStage:n}:i;JSON.stringify(window.history.state)!==JSON.stringify(o)&&window.history.replaceState(o,"",a.href)})}function wv(){gv||typeof window>"u"||(gv=!0,ic=window.location.href,window.addEventListener("popstate",N_,{capture:!0}),bv()?.addEventListener("currententrychange",e=>{rc=e.from?.index??-1}))}function Rn(e,t,a){window.history[e](t,"",a),ic=window.location.href}function nc(){kd=!0,window.history.back()}var Sd=$(F());function Qt(){return(0,Sd.jsx)("svg",{className:"forward-arrow",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Sd.jsx)("path",{d:"M3 8H13M13 8L9 4M13 8L9 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var Nd=$(F());function il(){return(0,Nd.jsx)("svg",{className:"close-icon",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,Nd.jsx)("path",{d:"M3.5 3.5L12.5 12.5M12.5 3.5L3.5 12.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}var J=$(F()),C_=[...Tn.schedule,...Tn.photo].join(","),q_={paste:[{title:"Paste List",desc:"Paste your material list straight from a spreadsheet or document."},{title:"Check Matches",desc:"Review the suggested products and adjust any that need changing."},{title:"Review Quote",desc:"Review the matched materials for your quote."}],upload:[{title:"Upload File",desc:"Upload a photo, spreadsheet, Word document or PDF."},{title:"Check Matches",desc:"Review the suggested products and adjust any that need changing."},{title:"Review Quote",desc:"Review the matched materials for your quote."}]},An="#quote-entry",oc="metron-quick-quote-entry";function Cd({onPasteSchedule:e,onUploadSchedule:t,onEntryModeChange:a,draft:r,onSubmitDraft:i,onCancelMatch:n}){let o=(0,St.useRef)(null),l=En(),c=(0,St.useRef)(0),p=(0,St.useRef)(0),[m,g]=(0,St.useState)(()=>r&&typeof window<"u"&&window.location.hash===An?r.tab:null),[d,b]=(0,St.useState)(r?.text??""),[v,E]=(0,St.useState)(r?.file??null),[O,f]=(0,St.useState)(""),[u,h]=(0,St.useState)(!1),[w,k]=(0,St.useState)(!1),[z,A]=(0,St.useState)(null),U=d.split(`
|
|
6972
6972
|
`).filter(Z=>Z.trim()).length,R=cv(d),H=m==="paste"?!!d:!!v;(0,St.useEffect)(()=>{if(!v||!zn(v)){A(null);return}let Z=URL.createObjectURL(v);return A(Z),()=>URL.revokeObjectURL(Z)},[v]);let oe=(0,St.useRef)(m??r?.tab??null);m&&(oe.current=m),(0,St.useEffect)(()=>{if(r||window.location.hash!==An)return;let Z=null;try{Z=JSON.parse(window.sessionStorage.getItem(oc)??"null")}catch{}if(!Z?.tab){let ge=new URL(window.location.href);ge.hash="",Rn("replaceState",window.history.state,ge);return}oe.current=Z.tab,g(Z.tab),b(Z.text??"")},[]),(0,St.useEffect)(()=>{if(m)try{window.sessionStorage.setItem(oc,JSON.stringify({tab:m,text:d}))}catch{}},[m,d]),(0,St.useEffect)(()=>{let Z=()=>{if(window.location.hash===An)return g(oe.current);g(null),p.current++,h(!1),n?.()};return window.addEventListener("popstate",Z),()=>window.removeEventListener("popstate",Z)},[]);let Te=Z=>{l("method_selected",{method:Z}),g(Z),a(null);let ge=window.location.hash;if(ge===An)return;let Re=new URL(window.location.href);Re.hash=An,Rn(ge==="#matched-products"||ge==="#quote-request"?"replaceState":"pushState",{boqQuoteStage:"entry"},Re)},je=()=>{g(null),a(null),window.location.hash===An&&nc()};rl(!!m&&!u,je);let Ve=Z=>{if(!Z?.length)return;if(Z.length>1)return f("Please choose one file at a time.");let ge=Z[0],Re=yd(ge,zn(ge)?1/0:void 0);if(Re)return f(Re);f(""),E(ge)},Ne=async Z=>{m==="paste"&&E(null),m==="upload"&&b(""),m&&i?.({tab:m,text:m==="paste"?d:"",file:m==="upload"?v:null});let ge=++p.current;h(!0);try{await Z()}finally{ge===p.current&&h(!1)}},we=()=>{if(v)return l("list_submitted",{method:zn(v)?"photo":"upload"}),Ne(async()=>{if(!zn(v))return t(v);try{let Z=await uv(v),ge=yd(Z);if(ge)throw new Error(ge);await t(Z)}catch(Z){l("error",{stage:"photo"}),f(Z?.message||"Failed to process image upload")}})},le=Z=>Z.dataTransfer.types.includes("Files"),Fe=Z=>{le(Z)&&(Z.preventDefault(),c.current+=1,k(!0))},Ee=Z=>{le(Z)&&(c.current-=1,c.current<=0&&(c.current=0,k(!1)))},Nt=Z=>{le(Z)&&(Z.preventDefault(),c.current=0,k(!1),Ve(Z.dataTransfer.files),Te("upload"))};return(0,J.jsxs)("div",{className:"wizard-step entry-stage",onDragEnter:Fe,onDragOver:Z=>le(Z)&&Z.preventDefault(),onDragLeave:Ee,onDrop:Nt,children:[w&&(0,J.jsx)("div",{className:"entry-drop-overlay","aria-hidden":"true",children:"Drop your file to upload"}),(0,J.jsxs)("div",{className:"quick-order-card",children:[(0,J.jsxs)("div",{className:"quick-order-alt",children:[(0,J.jsxs)("div",{className:"quick-order-entry-copy",children:[(0,J.jsx)("div",{className:"quick-order-alt-title",children:"How would you like to get started?"}),(0,J.jsx)("p",{className:"quick-order-alt-intro",children:"Upload a file or type a list of items and quantities. We'll match them to our products and help you build a quote."})]}),(0,J.jsxs)("div",{className:"entry-options entry-options--workflow entry-options--two",children:[(0,J.jsxs)("button",{type:"button",className:`entry-option-card entry-option-card--paste${m==="paste"?" entry-option-card--active":""}`,onClick:()=>Te("paste"),children:[(0,J.jsxs)("span",{className:"entry-option-content",children:[(0,J.jsx)("span",{className:"entry-option-title",children:"Type or paste a list"}),(0,J.jsx)("span",{className:"entry-option-desc",children:"Enter your materials and quantities"})]}),(0,J.jsx)("span",{className:"entry-option-media entry-option-media--paste","aria-hidden":"true",children:(0,J.jsx)("img",{className:"fill-img",src:It("/quick-order/paste-list.webp"),alt:""})})]}),(0,J.jsxs)("button",{type:"button",className:`entry-option-card entry-option-card--upload${m==="upload"?" entry-option-card--active":""}`,onClick:()=>Te("upload"),children:[(0,J.jsxs)("span",{className:"entry-option-content",children:[(0,J.jsx)("span",{className:"entry-option-title",children:"Upload a file"}),(0,J.jsx)("span",{className:"entry-option-desc",children:"A photo, spreadsheet, Word document or PDF"})]}),(0,J.jsx)("span",{className:"entry-option-media entry-option-media--upload","aria-hidden":"true",children:(0,J.jsx)("img",{className:"fill-img",src:It("/quick-order/photo-list.webp"),alt:""})})]})]})]}),m&&(0,J.jsx)("div",{className:"modal-backdrop quick-order-modal-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"quick-order-workflow-title",onClick:()=>!H&&je(),children:(0,J.jsxs)("section",{className:`quick-order-workflow-modal${u?" quick-order-workflow-modal--matching":""}`,onClick:Z=>Z.stopPropagation(),children:[(0,J.jsxs)("header",{className:"quick-order-workflow-modal-header",children:[(0,J.jsx)("h2",{id:"quick-order-workflow-title",children:m==="paste"?"Type or paste a list":"Upload a file"}),(0,J.jsx)("button",{type:"button",className:"quick-order-workflow-close",onClick:je,"aria-label":"Close",children:(0,J.jsx)(il,{})})]}),(0,J.jsxs)("div",{className:"quick-order-panel",children:[(0,J.jsxs)("div",{className:"quick-order-body","aria-hidden":u,children:[(0,J.jsx)("div",{className:"quick-order-body-main",children:m==="paste"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("textarea",{className:"paste-textarea",placeholder:`Paste your line items here, one per line, e.g.
|
|
6973
6973
|
insulated plasterboard 50mm
|
|
6974
|
-
C24 timber 4.8m`,value:d,onChange:Z=>b(Z.target.value),"aria-label":"Paste schedule line items"}),R&&(0,J.jsxs)("div",{className:"error-box",role:"alert",children:[(0,J.jsx)("strong",{children:"Error:"})," ",R]}),(0,J.jsxs)("div",{className:"quick-order-hint",children:[(0,J.jsx)("strong",{children:"Tip:"}),'\xA0Paste one line per item. Include a count, e.g. "x10", to help us find the right stock and pricing.']}),(0,J.jsx)("div",{className:"quick-order-actions",children:(0,J.jsxs)("button",{type:"button",className:"cta-btn",disabled:!U||!!R,onClick:()=>{l("list_submitted",{method:"paste",lines:U}),Ne(()=>e(d))},"aria-label":"Match pasted lines",children:[(0,J.jsx)("span",{children:"Match line items"}),(0,J.jsx)("span",{className:"arrow",children:(0,J.jsx)(Qt,{})})]})})]}):(0,J.jsxs)(J.Fragment,{children:[O&&(0,J.jsxs)("div",{className:"error-box",role:"alert",children:[(0,J.jsx)("strong",{children:"Error:"})," ",O]}),(0,J.jsxs)("div",{className:`upload-zone${v?" has-file":""}`,onClick:()=>o.current?.click(),onDragOver:Z=>Z.preventDefault(),onDrop:Nt,role:"button",tabIndex:0,onKeyDown:Z=>(Z.key==="Enter"||Z.key===" ")&&o.current?.click(),"aria-label":"Upload zone: click or drag a list or image file here",children:[z?(0,J.jsx)("img",{src:z,alt:v?.name??"Selected photo",className:"upload-zone-photo-preview"}):(0,J.jsx)("div",{className:"upload-zone-icon",children:(0,J.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,J.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,J.jsx)("polyline",{points:"14,2 14,8 20,8"}),(0,J.jsx)("polyline",{points:"9,15 11,17 15,13"})]})}),v?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("div",{className:"upload-zone-subtext",children:v.name}),(0,J.jsx)("button",{type:"button",className:"link-btn link-btn--underline",onClick:Z=>{Z.stopPropagation(),E(null),f(""),o.current&&(o.current.value="")},children:"Remove"})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("div",{className:"upload-zone-text",children:"Drop a photo, spreadsheet, Word document or PDF"}),(0,J.jsx)("div",{className:"upload-zone-subtext",children:"or click to choose a file"})]}),(0,J.jsx)("input",{ref:o,type:"file",accept:C_,className:"visually-hidden",onChange:Z=>Ve(Z.target.files),tabIndex:-1,"aria-hidden":"true"})]}),(0,J.jsx)("div",{className:"quick-order-actions",children:(0,J.jsxs)("button",{type:"button",className:"cta-btn",disabled:!v,onClick:()=>{we()},"aria-label":"Match uploaded items",children:[(0,J.jsx)("span",{children:"Match items"}),(0,J.jsx)("span",{className:"arrow",children:(0,J.jsx)(Qt,{})})]})})]})}),(0,J.jsx)("aside",{className:"quick-order-sidebar",children:q_[m].map((Z,ge)=>(0,J.jsxs)("div",{className:"quick-order-step quick-order-step--rail",children:[(0,J.jsx)("span",{className:"quick-order-step-dot",children:ge+1}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"quick-order-step-title",children:Z.title}),(0,J.jsx)("div",{className:"quick-order-step-desc",children:Z.desc})]})]},Z.title))})]}),u&&(0,J.jsx)("div",{className:"quick-order-matching-overlay",children:(0,J.jsx)(hv,{})})]})]})})]})]})}var Rt=$(He()),yv=$(F());function Un(e){return JSON.stringify([e.productId,e.qty,e.unit,e.linkedContext??[]])}function E_(e,t){let a={...e,[t.lineId]:t};for(let[r,i]of Object.entries(a)){if(!i.linkedContext)continue;let n=i.linkedContext.find(l=>l.role==="anchor"&&l.line_id&&a[l.line_id]),o=n?.line_id?a[n.line_id]:void 0;if(!(!n||!o||n.product_id===o.productId&&n.description===o.description)){if(i.conversionType!=="basket_line_unit"){a[r]={...i,linkedContext:i.linkedContext.map(l=>l.line_id===n.line_id?{...l,product_id:o.productId,measurements_mm:o.measurementsMm??[],description:o.description}:l)};continue}a[r]={...i,qty:0,sellUnitsOverride:null,linkedContext:i.linkedContext.map(l=>l.line_id===n.line_id?{...l,product_id:o.productId,measurements_mm:o.measurementsMm??[],description:o.description}:l),conversionType:null,requestUomsSupported:null,salesUomNormalised:null,salesUnitSize:null,salesUnitSizeUom:null,coverageQty:null,coverageUom:null,roundingRule:null,conversionConfidence:null,conversionNotes:null}}}return a}var qd=(0,Rt.createContext)(null);function lc({children:e,onOpenBasket:t}){let[a,r]=(0,Rt.useState)({}),i=(0,Rt.useCallback)(d=>{r(b=>E_(b,d))},[]),n=(0,Rt.useCallback)(d=>{r(b=>{let v={...b};for(let E of d)v[E.lineId]=E;return v})},[]),o=(0,Rt.useCallback)(d=>{r(b=>{let v={...b};return delete v[d],v})},[]),l=(0,Rt.useCallback)((d,b)=>{r(v=>v[d]?{...v,[d]:{...v[d],qty:b,sellUnitsOverride:null}}:v)},[]),c=(0,Rt.useCallback)((d,b)=>{r(v=>v[d]?{...v,[d]:{...v[d],sellUnitsOverride:b}}:v)},[]),p=(0,Rt.useCallback)(d=>{r(b=>{let v=!1,E={...b};for(let[O,f]of Object.entries(d))E[O]&&(E[O]={...E[O],...f},v=!0);return v?E:b})},[]),m=(0,Rt.useCallback)(()=>r({}),[]),g=(0,Rt.useMemo)(()=>({cart:a,count:Object.keys(a).length,addToCart:i,addManyToCart:n,removeFromCart:o,updateCartQty:l,updateCartSellUnits:c,updateCartConversions:p,clearCart:m,openBasket:t??(()=>{})}),[a,i,n,o,l,c,p,m,t]);return(0,yv.jsx)(qd.Provider,{value:g,children:e})}function Dn(){let e=(0,Rt.useContext)(qd);if(!e)throw new Error("useCart must be used inside a <CartProvider>");return e}function vv(){return(0,Rt.useContext)(qd)}var dt=$(He());function vi(e){return e===0?"-":Number.isInteger(e)?e.toString():e<1?e.toFixed(2):e.toFixed(1)}function nt(e){return`\xA3${e.toLocaleString("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2})}`}var Nv=e=>(e??"").trim().toLowerCase(),M_={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",piece:"each",pieces:"each",board:"sheet",bags:"bag",length:"length",lengths:"length",pallet:"pallet",pallets:"pallet"},Ed=new Set(["sheet","length","box","bag","pack","roll","set","tub","each"]),_v=new Set(["box","bag","pack","pallet","roll","set","tub"]),Md=(e,t)=>t==="ml"?e:["l","litre","litres"].includes(t)?e*1e3:null,Td=(e,t)=>t==="g"?e:["kg","kilogram","kilograms"].includes(t)?e*1e3:["t","tonne","tonnes"].includes(t)?e*1e6:null,mr=e=>{let t=Nv(e);return M_[t]??t},at=(e,t)=>{let a=mr(e),r=mr(t);return a.length>0&&a===r},xv=(e,t)=>{let a=Nv(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},T_=e=>(e??"").split(",").map(t=>mr(t)).filter(Boolean),z_=(e,t)=>{let a=T_(e.requestUomsSupported);return!!(a.length===0||a.includes(t)||at(t,"pallet")&&e.itemsPerPallet!=null&&e.itemsPerPallet>0||at(t,"pack")&&e.itemsPerPack!=null&&e.itemsPerPack>0||at(t,"box")&&e.itemsPerBox!=null&&e.itemsPerBox>0)},kv=(e,t)=>at(t,"pallet")?e.itemsPerPallet??null:at(t,"pack")?e.itemsPerPack??null:at(t,"box")?e.itemsPerBox??null:null,Sv=(e,t)=>{let a=t==="volume"?/(\d+(?:[.,]\d+)?)\s*(ml|l|ltr|ltrs|litres?|liters?)\b/i:/(\d+(?:[.,]\d+)?)\s*(kg|kgs|tonnes?)\b/i,r=e.description.match(a);if(!r)return null;let i=Number.parseFloat(r[1].replace(",","."));if(!Number.isFinite(i)||i<=0)return null;let n=r[2].toLowerCase();return t==="volume"?{ml:n==="ml"?i:i*1e3}:{g:n.startsWith("tonne")?i*1e6:i*1e3}},R_=["volume_from_description","same_unit_volume"],A_=["weight_from_description","mass_from_pack","same_unit_mass"],U_=(e,t,a)=>{if(!at(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||!at(r[3],a))return null;let i=Number.parseFloat(r[1].replace(",","."));return Number.isFinite(i)&&i>0?i:null};function sc(e,t){let a=e.map(r=>Ft(r,t).lineTotal);return a.some(r=>r==null)?null:a.reduce((r,i)=>r+(i??0),0)}function Ft(e,t){let a=e.qty,r=mr(e.saleUnit??e.salesUnitSizeUom??e.uoi??e.salesUomNormalised)||"-",i=mr(e.unit)||(a>0&&Ed.has(r)?r:"-"),n=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?Ed.has(r)?Math.ceil(e.sellUnitsOverride):e.sellUnitsOverride:null,p=R=>({requestedAmount:a,requestedUnit:i,salesUnitSize:e.salesUnitSize??e.uoiCount??null,sellUnit:r,calculatedSellUnits:null,requiredSellUnits:c,unitPrice:e.price,lineTotal:e.price!=null&&c!=null?e.price*c:null,calculation:c!=null?`${R} Order quantity set to ${c} ${r}.`:R,costingMode:"review"});if(!Number.isFinite(a)||a<=0)return p("Quantity needs confirmation.");let m=Md(a,i),g=Td(a,i),d=at(i,r)?null:m!=null&&!R_.includes(e.conversionType??"")?Sv(e,"volume"):g!=null&&!A_.includes(e.conversionType??"")?Sv(e,"weight"):null,b=d?.ml!=null?m:g,v=d?.ml??d?.g??null;if(b!=null&&v!=null){let R=mr(e.uoi)||r,H=d?.ml!=null?`${v/1e3} l`:`${v/1e3} kg`,oe=l?c:Math.ceil(b*(1+o)/v-1e-9);return{requestedAmount:a,requestedUnit:i,salesUnitSize:1,sellUnit:R,calculatedSellUnits:oe,requiredSellUnits:oe,unitPrice:e.price,lineTotal:e.price!=null?e.price*oe:null,calculation:`${a} ${i}${o>0?` x ${1+o}`:""} / ${H} per ${R} (from product description) = ${oe} ${R}`,costingMode:"derived"}}if(i==="sales_unit"){let R=mr(e.uoi)||r,H=l?c:xv(a*(1+o),e.roundingRule??"round_up_each");return{requestedAmount:a,requestedUnit:R,salesUnitSize:1,sellUnit:R,calculatedSellUnits:H,requiredSellUnits:H,unitPrice:e.price,lineTotal:e.price!=null?e.price*H:null,calculation:`${a} ${R}${o>0?` x ${1+o}`:""} = ${H} ${R}`,costingMode:"direct"}}if(!z_(e,i))return p("Requested unit is not supported by this catalogue conversion.");let E=null,O="review",f=e.roundingRule,u=`Quantity review required, initial request needed ${a} ${i}.`,h=1+o,w=U_(e,i,r),k=e.unitConversions?.find(R=>at(R.requestUom,i));if(!!e.saleUnit&&(at(i,r)||!!k||at(i,"each")&&!_v.has(r)))if(at(i,r))E=a*h/n,O="direct",u=`${a} ${i}${o>0?` x ${h}`:""}`;else if(k){E=a*h/k.quantityPerSaleUnit,O="derived";let R=1/k.quantityPerSaleUnit,H=Math.round(R);u=at(r,"each")&&k.quantityPerSaleUnit<1&&Math.abs(R-H)<1e-9?`${a} ${i}${o>0?` x ${h}`:""} x ${H} per ${i}`:`${a} ${i}${o>0?` x ${h}`:""} / ${k.quantityPerSaleUnit} ${i} per ${r}`}else at(i,"each")&&!_v.has(r)&&(E=a*h/n,O="derived",u=`${a} ${r}${o>0?` x ${h}`:""}`);else if(at(i,r)&&n>0)E=a*h/n,O="direct",u=o>0?`${a} ${i} x ${h} / ${n} ${r} per sell unit`:`${a} ${i} / ${n} ${r} per sell unit`;else if(at(i,"each")&&n>0&&Ed.has(r))E=a*h/n,O="derived",u=o>0?`${a} each x ${h} / ${n} each per ${r}`:`${a} each / ${n} each per ${r}`;else if(kv(e,i)!=null&&n>0){let R=kv(e,i)??0;E=a*R*h/n,O="derived";let H=`${a} ${i} x ${R} each${o>0?` x ${h}`:""}`;u=n===1&&at(r,"each")?H:`${H} / ${n} each per ${r}`}else if(w!=null)E=a*h/w,O="derived",f??(f="round_up_each"),u=`${a} m2 x ${h} / ${w} m2 per ${r} (from product description)`;else if(e.conversionType==="basket_line_unit")n>0&&(E=a*h/n,O="derived",u=`${a} ${i}${o>0?` x ${h}`:""} / ${n} ${i} per ${r}`);else{if(e.conversionType==="count_only")return p(`Quantity review required, initial request needed ${a} ${i}.`);if(["area_from_dims","explicit_coverage_area","roll_area"].includes(e.conversionType??"")){let R=e.coverageQty??e.derivedCoverageM2??null;at(i,"m2")&&R!=null&&R>0&&(E=a*h/R,O="derived",u=`${a} m2 x ${h} / ${R} m2 per ${r}`)}else if(e.conversionType==="count_per_area"){let R=e.coverageQty??null;at(i,"m2")&&R!=null&&R>0?(E=a/R,O="derived",u=`${a} m2 / ${R} m2 per sell unit`):at(i,"m2")&&e.itemsPerM2!=null&&e.itemsPerM2>0&&n>0&&(E=a*e.itemsPerM2*h/n,O="derived",u=`${a} m2 x ${e.itemsPerM2} ${r}/m2 x ${h} / ${n}`)}else if(e.conversionType==="length_from_dims"){let R=e.coverageQty??e.derivedLengthM??null;at(i,"m")&&R!=null&&R>0&&(E=a*h/R,O="derived",u=`${a} m x ${h} / ${R} m per ${r}`)}else if(e.conversionType==="volume_from_description"){let R=Md(a,i),H=Md(e.coverageQty??0,mr(e.coverageUom));R!=null&&H!=null&&H>0&&(E=R*h/H,O="derived",u=`${a} ${i} x ${h} / ${e.coverageQty} ${e.coverageUom} per ${r}`)}else if(e.conversionType==="weight_from_description"||e.conversionType==="mass_from_pack"){let R=mr((e.coverageUom??"").split(" ")[0]),H=Td(a,i),oe=Td(e.coverageQty??0,R);H!=null&&oe!=null&&oe>0&&(E=H*h/oe,O="derived",u=`${a} ${i} x ${h} / ${e.coverageQty} ${R} per ${r}`)}else if(e.conversionType==="same_unit_volume"){let R=e.coverageQty??null;at(i,"m3")&&R!=null&&R>0&&(E=a/R,O="derived",u=`${a} m3 / ${R} m3 per ${r}`)}}if(E==null||!Number.isFinite(E)||E<0)return p(`Quantity review required, initial request needed ${a} ${i}.`);let A=xv(E,f),U=l?c:A;return{requestedAmount:a,requestedUnit:i,salesUnitSize:n,sellUnit:r,calculatedSellUnits:A,requiredSellUnits:U,unitPrice:e.price,lineTotal:e.price!=null&&U!=null?e.price*U:null,calculation:l?`${u} = ${A} ${r} (manually set to ${U})`:`${u} = ${U} ${r}`,costingMode:O}}var nl=$(F());function zd({unit:e}){return(0,nl.jsx)(nl.Fragment,{children:e.split(/([²³])/).map((t,a)=>t==="\xB2"||t==="\xB3"?(0,nl.jsx)("span",{className:"unit-sup",children:t},a):t)})}var Cv=$(F());function D_(e,t){return t===1||/^m\d*$/i.test(e)?e:/(s|x|z|ch|sh)$/i.test(e)?`${e}es`:/[^aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:`${e}s`}function _a(e,t){let a=(e??"").trim();if(!a||a==="-")return"";let r=/^each$/i.test(a)?"unit":a;return t!=null?D_(r,t):r}function xa(e,t){let a=_a(e,t);return a?(0,Cv.jsx)(zd,{unit:a}):null}function ol(e){let t=(e??"").trim();if(!t)return"";let a=t.match(/^per\s+(.+)$/i);if(!a)return t;let r=_a(a[1]);return r?`per ${r}`:""}var qv=()=>import("./xlsx-K4MOA2QM.js"),sl=["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","Review required","Decision reason","Selected candidate ID","Selected candidate description","Price basis","Price","Line total","Confidence","Status"],O_=sl.indexOf("Line total");function B_(e){return e.unmatchable?"Not matched (labour/plant/referential)":e.best?"Selected":"Needs review"}async function Ev(e){let t=await qv(),a=t.utils.book_new(),r=new Date().toISOString().slice(0,10),i=[sl],n=0;for(let c of e){let{item:p,best:m,qty:g,band:d,unmatchable:b,decision:v}=c,E=[p.section,p.subsection,p.subheading].filter(Boolean).join(" / "),O=!b&&m?.price!=null?m.price*g:null;O!=null&&(n+=O),i.push([p.source_line_id,p.line_id,p.description_original||"(no description)",E,g,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(", "),m?"no":"yes",v?.reason??"",b?"-":m?.product_id??v?.selected_candidate_id??"-",b?"-":m?.description??"-",b?"-":m?.price_basis??"-",b?null:m?.price??null,O,b?"-":d,B_(c)])}i.push(Array(sl.length).fill(null));let o=Array(sl.length).fill(null);o[0]="Estimated total",o[O_]=n,i.push(o),i.push(["DISCLAIMER: These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence.",...Array(sl.length-1).fill(null)]);let l=t.utils.aoa_to_sheet(i);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 ll=["Product ID","Description","Costing mode","Required amount","Req unit","Sell unit size","Sell unit","Required sell units","Unit price","Line total"];async function Mv(e,t){let a=await qv(),r=a.utils.book_new(),i=new Date().toISOString().slice(0,10),n=t?[["Account",t.name+" ("+t.id+")"],[],ll]:[ll],o=0;for(let p of e){let m=Ft(p),g=m.lineTotal;g!=null&&(o+=g),n.push([p.productId,p.description,m.costingMode,m.requestedAmount,_a(m.requestedUnit),m.salesUnitSize,_a(m.sellUnit),m.requiredSellUnits,m.unitPrice,g])}n.push(Array(ll.length).fill(null));let l=Array(ll.length).fill(null);l[0]="Estimated total",l[ll.length-1]=o,n.push(l);let c=a.utils.aoa_to_sheet(n);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}-${i}.xlsx`:`basket-${i}.xlsx`)}var Rd=$(F());function Vr(){return(0,Rd.jsx)("svg",{className:"back-arrow",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Rd.jsx)("path",{d:"M13 8H3M3 8L7 4M3 8L7 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var Ad=$(F());function yi(){return(0,Ad.jsx)("svg",{width:"8",height:"5",viewBox:"0 0 8 5",fill:"none",children:(0,Ad.jsx)("path",{d:"M1 4L4 1L7 4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}var _i=$(F());function Ud(){return(0,_i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,_i.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,_i.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,_i.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,_i.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}var ja=$(F());function Dd(e){return(0,ja.jsxs)("svg",{viewBox:"0 0 640 420",preserveAspectRatio:"xMidYMid slice",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",...e,children:[(0,ja.jsx)("rect",{width:"640",height:"420",fill:"#fbf1cf"}),(0,ja.jsx)("rect",{x:"88",y:"78",width:"432",height:"264",rx:"16",fill:"#f0c43f"}),(0,ja.jsx)("rect",{x:"120",y:"110",width:"368",height:"200",rx:"10",fill:"#ffd95e"}),(0,ja.jsxs)("g",{stroke:"#e2b12e",strokeWidth:"8",opacity:"0.75",children:[(0,ja.jsx)("line",{x1:"140",y1:"140",x2:"468",y2:"140"}),(0,ja.jsx)("line",{x1:"140",y1:"190",x2:"468",y2:"190"}),(0,ja.jsx)("line",{x1:"140",y1:"240",x2:"468",y2:"240"})]})]})}var Xr=$(F());function Od(e){return(0,Xr.jsxs)("svg",{viewBox:"0 0 640 420",preserveAspectRatio:"xMidYMid slice",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",...e,children:[(0,Xr.jsx)("rect",{width:"640",height:"420",fill:"#edf1f5"}),(0,Xr.jsx)("rect",{x:"132",y:"108",width:"376",height:"204",rx:"18",fill:"#d5dde6"}),(0,Xr.jsx)("rect",{x:"168",y:"144",width:"304",height:"24",rx:"12",fill:"#9aa6b2"}),(0,Xr.jsx)("rect",{x:"168",y:"188",width:"250",height:"24",rx:"12",fill:"#aab5c0"}),(0,Xr.jsx)("rect",{x:"168",y:"232",width:"220",height:"24",rx:"12",fill:"#aab5c0"})]})}var Bd=$(F()),L_=[{match:["building sand"],path:"/schedule-products/building-sand.webp"},{match:["drywall screw"],path:"/schedule-products/drywall-screws.webp"},{match:["scrim"],path:"/schedule-products/scrim-tape.webp"},{match:["loft insulation","loft roll"],path:"/schedule-products/loft-insulation-roll.webp"},{match:["wall tie"],path:"/schedule-products/wall-ties.webp"},{match:["red multi","multi stock","brick"],path:"/schedule-products/red-multi-stock-bricks.webp"}];function za({description:e,photoUrl:t,className:a,width:r,height:i}){let n=(e||"").toLowerCase(),o=L_.find(p=>p.match.some(m=>n.includes(m))),l=t||o&&It(o.path);if(l)return(0,Bd.jsx)("img",{className:a,src:l,alt:"",width:r,height:i});let c=n.includes("insulation")?Dd:Od;return(0,Bd.jsx)(c,{className:a,width:r,height:i})}var M=$(F()),Tv=.2,cl=10,zv="Enter a valid email address so we can send your quote.",H_=(e,t)=>{let a=`${t.requestedAmount} ${_a(t.requestedUnit,t.requestedAmount)}`,r=`${t.requiredSellUnits} ${_a(t.sellUnit,t.requiredSellUnits??0)}`,i=e.unitConversions?.find(n=>n.requestUom===t.requestedUnit);return i&&i.quantityPerSaleUnit<1?`${a} requested \u2192 order ${r} (${Math.round(1/i.quantityPerSaleUnit)} ${_a(t.sellUnit,2)} per ${_a(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}`},Q_=e=>["box","pack"].includes(e.requestedUnit)?"Pack size needed to calculate the order quantity.":`This product is sold by ${_a(e.sellUnit,1)}.`;function ul({cart:e,onUpdateQty:t,onUpdateSellUnits:a,onResolveConversions:r,onRemove:i,onBack:n,onStartNewQuote:o,onQuoteRequested:l,internal:c=!1}){let p=(0,dt.useId)(),m=En(),g=!c&&Is()==="QZA6-MRA4",d=!c,b=Object.values(e),v=(0,dt.useRef)(new Map),[E,O]=(0,dt.useState)(""),[f,u]=(0,dt.useState)(!1),[h,w]=(0,dt.useState)(!1),[k,z]=(0,dt.useState)(""),[A,U]=(0,dt.useState)({}),[R,H]=(0,dt.useState)({}),[oe,Te]=(0,dt.useState)(1),[je,Ve]=(0,dt.useState)({}),[Ne,we]=(0,dt.useState)(!1),[le,Fe]=(0,dt.useState)("0"),[Ee,Nt]=(0,dt.useState)({});(0,dt.useEffect)(()=>{if(!r)return;for(let D of Object.values(e))Ft(D).requiredSellUnits!=null&&v.current.delete(D.lineId);let _=Object.values(e).filter(D=>{if(D.productId==="-"||Ft(D).requiredSellUnits!=null)return!1;let V=Un(D);return v.current.get(D.lineId)===V?!1:(v.current.set(D.lineId,V),!0)});if(_.length===0)return;let q=new Map(_.map(D=>[D.lineId,Un(D)]));Nt(D=>({...D,...Object.fromEntries(q)})),fetch(Ta("/api/catalogue/resolve-conversions"),{method:"POST",headers:{"Content-Type":"application/json",...Mn()},body:JSON.stringify({lines:_.map(D=>({line_id:D.lineId,product_id:D.productId,requested_description:D.requestedDescription??D.description,requested_qty:D.qty,requested_uom:D.unit||null,linked_context:D.linkedContext??[],selected_description:D.description,selected_uoi:D.uoi,selected_uoi_count:D.uoiCount,selected_conversion:{sales_uom_normalised:D.salesUomNormalised,conversion_type:D.conversionType,sales_unit_size:D.salesUnitSize,sales_unit_size_uom:D.salesUnitSizeUom,coverage_qty:D.coverageQty,coverage_uom:D.coverageUom}}))})}).then(D=>D.ok?Ga(D):null).then(D=>{let V={},N=new Map(_.map(L=>[L.lineId,Un(L)]));for(let L of D?.data?.items??D?.items??[]){let X=L?.conversion;!X||typeof L?.line_id!="string"||v.current.get(L.line_id)!==N.get(L.line_id)||(V[L.line_id]={conversionConfidence:X.conversion_confidence,conversionNotes:X.conversion_notes,...Number.isFinite(X.suggested_order_qty)&&X.suggested_order_qty>0?{sellUnitsOverride:X.suggested_order_qty}:{}})}Object.keys(V).length>0&&r(V)}).catch(D=>console.error("Catalogue conversion resolution failed",D)).finally(()=>{Nt(D=>{let V={...D};for(let[N,L]of q)V[N]===L&&delete V[N];return V})})},[e,r]);function Z(_){U(q=>{let D={...q};return delete D[_],D})}function ge(_,q){let D=parseFloat(q);!isNaN(D)&&D>=0&&t(_,Math.min(D,1e5)),Z(_)}function Re(_,q,D){t(_,Math.min(1e5,Math.max(0,q+D))),Z(_)}function bt(_){H(q=>{let D={...q};return delete D[_],D})}function jt(_,q){let D=parseFloat(q);!isNaN(D)&&D>=0&&a(_,Math.min(D,1e5)),bt(_)}function Ct(_,q,D){a(_,Math.min(1e5,Math.max(0,q+D))),bt(_)}async function wt(){if(be.some(({pricing:q})=>q.lineTotal==null)){z(g?"Confirm the highlighted quantities before requesting a quote.":"Confirm the highlighted quantities before sending your basket.");return}let _=E.trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_)){z(zv);return}z(""),w(!0);try{let q=await fetch(Ta("/api/quote-requests"),{method:"POST",headers:{"Content-Type":"application/json",...Mn()},body:JSON.stringify({email:_,items:be.map(({item:D,pricing:V})=>{let N=V.requiredSellUnits??V.requestedAmount,L=V.requiredSellUnits!=null?V.sellUnit:V.requestedUnit;return{product_id:D.productId,description:D.description,quantity:N,unit:_a(L,N),unit_price:V.requiredSellUnits!=null?V.unitPrice:null,line_total:V.lineTotal}})})});if(!q.ok){let D=await Ga(q);console.error("Quote request failed",q.status,D?.message),z(q.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}T!=null&&m("quote_requested",{items:be.length,total:Math.round(T*100)/100}),u(!0),l?.(),window.scrollTo(0,0)}catch{z("Your request couldn't be sent. Check your connection and try again.")}finally{w(!1)}}let be=b.map(_=>({item:_,pricing:Ft(_,{wasteFactorEnabled:Ne,wasteFactorOverride:Math.max(0,Number.parseFloat(le)||0)/100})})),de=sc(b,{wasteFactorEnabled:Ne,wasteFactorOverride:Math.max(0,Number.parseFloat(le)||0)/100}),tt=de==null?null:de*Tv,T=de==null?null:de*(1+Tv),G=be.filter(({pricing:_})=>_.lineTotal==null).length,ie=Object.keys(Ee).length,ce=!!r&&b.some(_=>{if(_.productId==="-"||Ft(_).requiredSellUnits!=null)return!1;let q=Un(_);return v.current.get(_.lineId)!==q||Ee[_.lineId]===q}),ve=(0,dt.useRef)({items:be.length,...T==null?{}:{total:Math.round(T*100)/100}});(0,dt.useEffect)(()=>{m("basket_viewed",ve.current)},[m]);let Ye=Math.max(1,Math.ceil(be.length/cl)),qe=Math.min(oe,Ye),x=be.slice((qe-1)*cl,qe*cl);return f?(0,M.jsx)("div",{className:"wizard-step entry-stage",children:(0,M.jsxs)("div",{className:"quote-request-sent",role:"status",children:[(0,M.jsx)("div",{className:"quote-request-sent-icon","aria-hidden":"true",children:(0,M.jsx)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,M.jsx)("polyline",{points:"5 12.5 10 17.5 19 7"})})}),(0,M.jsx)("h1",{children:g?"Quote requested":"Basket sent"}),g?(0,M.jsxs)("p",{children:["You're all done. We'll email your sharper price to ",(0,M.jsx)("strong",{children:E.trim()}),", usually within one working day."]}):(0,M.jsxs)("p",{children:["You're all done. We'll email ",(0,M.jsx)("strong",{children:E.trim()})," to confirm prices, availability and delivery, usually within one working day."]}),(0,M.jsx)("button",{type:"button",className:"cta-btn",onClick:o,children:(0,M.jsx)("span",{children:g?"Start a new quote":"Start a new basket"})}),(0,M.jsx)("p",{className:"quote-request-sent-note",children:g?"Nothing is charged until you approve the quote.":"Nothing is charged until you approve the order."})]})}):!c&&b.length===0?(0,M.jsx)("div",{className:"wizard-step entry-stage",children:(0,M.jsxs)("div",{className:"quote-request-sent",children:[(0,M.jsx)("div",{className:"quote-request-sent-icon","aria-hidden":"true",children:(0,M.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,M.jsx)("path",{d:"M3 9h18l-2 11H5z"}),(0,M.jsx)("path",{d:"M8 9l4-6 4 6"})]})}),(0,M.jsx)("h1",{children:g?"Your quote request is empty":"Your basket is empty"}),(0,M.jsx)("p",{children:g?"Start again with your list to build your quote.":"Start again with your list to fill your basket."}),(0,M.jsx)("button",{type:"button",className:"cta-btn",onClick:o,children:(0,M.jsx)("span",{children:"Back to start"})})]})}):(0,M.jsx)("div",{className:`wizard-step entry-stage${g?" basket-layout--qza6-mra4":""}`,children:(0,M.jsxs)("div",{className:`quick-order-card${c?"":" quick-order-card--customer"}`,children:[(0,M.jsxs)("div",{className:`quick-order-hero${c?"":" quick-order-hero--customer"}`,children:[c&&(0,M.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,M.jsxs)("div",{className:"basket-hero-copy",children:[g&&(0,M.jsxs)("button",{type:"button",className:"cta-btn cta-btn-secondary basket-hero-back",onClick:n,children:[(0,M.jsx)(Vr,{}),(0,M.jsx)("span",{children:"Back to results"})]}),(0,M.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,M.jsx)("h1",{children:c?"Your Selection":g?"Request a quote":"Your Basket"}),c&&(0,M.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,M.jsx)("strong",{children:b.length})," ",b.length===1?"item":"items"]})]}),(0,M.jsx)("p",{children:c?"Review the items you've added before exporting them for review.":g?"Check your items and quantities below, and we'll do our best to beat list prices.":"Review your quantities and order summary, then send us your basket."})]})]}),(0,M.jsx)("div",{className:"quick-order-panel",style:{paddingTop:16},children:ce?(0,M.jsxs)("div",{className:"basket-resolving",role:"status","aria-label":"Calculating order quantities",children:[(0,M.jsx)("span",{className:"basket-resolving-wheel","aria-hidden":"true"}),(0,M.jsx)("span",{children:"Calculating your quantities\u2026"})]}):b.length===0?(0,M.jsxs)("div",{className:"quick-order-history-empty",children:[(0,M.jsx)("div",{className:"basket-empty-icon","aria-hidden":"true",children:"\u{1F4CB}"}),(0,M.jsx)("p",{children:"Your selection is empty."}),(0,M.jsx)("p",{className:"basket-empty-hint",children:"Go back to your results and add quoted items."}),(0,M.jsx)("div",{className:"btn-row",style:{marginTop:20,justifyContent:"center"},children:(0,M.jsx)("button",{className:"cta-btn",style:{width:"auto",maxWidth:280},onClick:n,"aria-label":"Back to results",children:(0,M.jsx)("span",{children:"Back to Results"})})})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)("div",{className:"basket-layout",children:[(0,M.jsxs)("div",{className:"basket-main",children:[(0,M.jsx)("div",{className:"basket-list","aria-label":c?"Selection items":g?"Quote request items":"Basket items",children:x.map(({item:_,pricing:q})=>{let D=A[_.lineId]??String(q.requestedAmount),V=q.requestedUnit===q.sellUnit||q.costingMode==="review",N=q.requiredSellUnits==null||q.requestedAmount!==q.requiredSellUnits||q.requestedUnit!==q.sellUnit;return(0,M.jsxs)("article",{className:"basket-card",children:[(0,M.jsxs)("div",{className:"basket-card-top",children:[(0,M.jsx)(za,{className:"basket-card-thumb",description:_.description,photoUrl:_.pdpPhotoUrl,width:48,height:48}),(0,M.jsxs)("div",{className:"basket-card-info",children:[(0,M.jsx)("div",{className:"bom-component-name",children:_.description}),N&&q.costingMode!=="review"&&(0,M.jsxs)("button",{type:"button",className:"basket-calc-toggle",onClick:()=>Ve(L=>({...L,[_.lineId]:!L[_.lineId]})),"aria-expanded":!!je[_.lineId],children:["How we calculated this",(0,M.jsx)("span",{className:`basket-calc-toggle-chevron${je[_.lineId]?" basket-calc-toggle-chevron--open":""}`,children:(0,M.jsx)(yi,{})})]})]}),(0,M.jsx)("div",{className:"basket-card-actions",children:(0,M.jsx)("button",{type:"button",className:"mf-remove-small-btn basket-card-remove",onClick:()=>i(_.lineId),"aria-label":`Remove ${_.description}`,children:(0,M.jsx)(Ud,{})})})]}),c&&(0,M.jsxs)("div",{className:"results-detail-block basket-internal-detail",children:[(0,M.jsxs)("dl",{className:"results-detail-grid",children:[(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Conversion type"}),(0,M.jsx)("dd",{children:_.conversionType??"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Conversion confidence"}),(0,M.jsx)("dd",{children:_.conversionConfidence??"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Sales unit"}),(0,M.jsx)("dd",{children:_.salesUnitSize!=null?(0,M.jsxs)(M.Fragment,{children:[_.salesUnitSize," ",xa(_.salesUnitSizeUom,_.salesUnitSize)]}):"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Coverage"}),(0,M.jsx)("dd",{children:_.coverageQty!=null?(0,M.jsxs)(M.Fragment,{children:[_.coverageQty," ",xa(_.coverageUom,_.coverageQty)]}):"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Waste factor"}),(0,M.jsx)("dd",{children:_.wasteFactorDefault??"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Rounding rule"}),(0,M.jsx)("dd",{children:_.roundingRule??"-"})]})]}),_.conversionNotes&&(0,M.jsx)("p",{className:"results-rerank-note",children:_.conversionNotes})]}),q.costingMode==="review"?(0,M.jsxs)("p",{className:"basket-calc-text basket-calc-text--review",children:[(0,M.jsx)("strong",{children:Ee[_.lineId]===Un(_)?"Calculating order quantity\u2026":"Quantity needs confirmation."})," ",Q_(q)]}):N&&je[_.lineId]?(0,M.jsx)("p",{className:"basket-calc-text",children:H_(_,q)}):null,(0,M.jsxs)("div",{className:"basket-card-stats",children:[(0,M.jsxs)("div",{className:"basket-stat",children:[(0,M.jsx)("span",{className:"basket-stat-label",children:"Requested qty"}),(0,M.jsxs)("div",{className:"basket-stat-value",children:[(0,M.jsxs)("div",{className:"basket-qty-field",children:[(0,M.jsx)("input",{className:"bom-qty-edit",type:"number",inputMode:"decimal",min:"0",placeholder:"-",value:D,disabled:V,onChange:L=>U(X=>({...X,[_.lineId]:L.target.value})),onBlur:L=>ge(_.lineId,L.target.value),onKeyDown:L=>{L.key==="Enter"&&L.target.blur()},"aria-label":`${_.description} requested quantity`}),(0,M.jsxs)("div",{className:"basket-qty-arrows",children:[(0,M.jsx)("button",{type:"button",className:"basket-qty-arrow",disabled:V,onClick:()=>Re(_.lineId,parseFloat(D)||0,1),"aria-label":`Increase ${_.description} quantity`,children:(0,M.jsx)(yi,{})}),(0,M.jsx)("button",{type:"button",className:"basket-qty-arrow basket-qty-arrow--down",disabled:V,onClick:()=>Re(_.lineId,parseFloat(D)||0,-1),"aria-label":`Decrease ${_.description} quantity`,children:(0,M.jsx)(yi,{})})]})]}),(0,M.jsx)("span",{className:"basket-metric-unit",children:xa(q.requestedUnit,parseFloat(D)||0)})]})]}),(0,M.jsxs)("div",{className:"basket-stat basket-stat--right",children:[(0,M.jsx)("span",{className:"basket-stat-label",children:"Order qty"}),(0,M.jsxs)("div",{className:"basket-stat-value",children:[(0,M.jsxs)("div",{className:"basket-qty-field",children:[(0,M.jsx)("input",{className:"bom-qty-edit",type:"number",inputMode:"decimal",min:"0",placeholder:"-",value:R[_.lineId]??String(q.requiredSellUnits??""),onChange:L=>H(X=>({...X,[_.lineId]:L.target.value})),onBlur:L=>jt(_.lineId,L.target.value),onKeyDown:L=>{L.key==="Enter"&&L.target.blur()},"aria-label":`${_.description} order quantity`}),(0,M.jsxs)("div",{className:"basket-qty-arrows",children:[(0,M.jsx)("button",{type:"button",className:"basket-qty-arrow",onClick:()=>Ct(_.lineId,parseFloat(R[_.lineId]??String(q.requiredSellUnits??"0"))||0,1),"aria-label":`Increase ${_.description} order quantity`,children:(0,M.jsx)(yi,{})}),(0,M.jsx)("button",{type:"button",className:"basket-qty-arrow basket-qty-arrow--down",onClick:()=>Ct(_.lineId,parseFloat(R[_.lineId]??String(q.requiredSellUnits??"0"))||0,-1),"aria-label":`Decrease ${_.description} order quantity`,children:(0,M.jsx)(yi,{})})]})]}),(0,M.jsx)("span",{className:"basket-metric-unit",children:xa(q.sellUnit,parseFloat(R[_.lineId]??String(q.requiredSellUnits??"0"))||0)})]})]}),(0,M.jsxs)("div",{className:"basket-stat basket-stat--total",children:[(0,M.jsx)("span",{className:"basket-stat-label",children:"Total"}),(0,M.jsxs)("div",{className:"basket-stat-value",children:[(0,M.jsx)("strong",{children:q.lineTotal!=null?nt(q.lineTotal):"-"}),q.lineTotal!=null&&(0,M.jsx)("span",{className:"basket-metric-unit",children:"ex. VAT"})]})]})]})]},_.lineId)})}),Ye>1&&(0,M.jsxs)("div",{className:"results-pagination",children:[(0,M.jsxs)("span",{className:"results-pagination-count",children:["Showing ",(qe-1)*cl+1,"\u2013",Math.min(qe*cl,be.length)," of ",be.length]}),(0,M.jsxs)("div",{className:"results-pagination-controls",children:[(0,M.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Te(qe-1),disabled:qe===1,children:"Previous"}),(0,M.jsxs)("span",{className:"results-pagination-page",children:["Page ",qe," of ",Ye]}),(0,M.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Te(qe+1),disabled:qe===Ye,children:"Next"})]})]})]}),(0,M.jsxs)("aside",{className:"basket-sidebar",children:[(0,M.jsx)("div",{className:"basket-sidebar-title",children:g?"Quote request summary":"Order summary"}),(0,M.jsxs)("div",{className:"basket-sidebar-row",children:[(0,M.jsx)("span",{children:g?"List price (ex. VAT)":"Subtotal (ex. VAT)"}),(0,M.jsx)("span",{children:de==null?"To confirm":nt(de)})]}),(0,M.jsxs)("div",{className:"basket-sidebar-row",children:[(0,M.jsx)("span",{children:"VAT (20%)"}),(0,M.jsx)("span",{children:tt==null?"To confirm":nt(tt)})]}),(0,M.jsxs)("div",{className:"basket-sidebar-row basket-sidebar-row--total",children:[(0,M.jsx)("span",{children:g?"List price (inc.\xA0VAT)":"Total"}),(0,M.jsx)("span",{children:T==null?"To confirm":nt(T)})]}),!g&&(0,M.jsx)("div",{className:"basket-summary-waste",children:(0,M.jsxs)("div",{className:"basket-waste-control",children:[(0,M.jsxs)("label",{className:"basket-global-waste",children:[(0,M.jsx)("input",{type:"checkbox",checked:Ne,onChange:_=>we(_.target.checked)}),(0,M.jsx)("span",{children:"Add waste factor"})]}),(0,M.jsxs)("label",{className:"basket-global-waste-percent",children:[(0,M.jsx)("input",{type:"number",inputMode:"decimal",min:"0",step:"0.1",value:le,onChange:_=>Fe(_.target.value),disabled:!Ne,"aria-label":"Waste factor percent"}),(0,M.jsx)("span",{children:"%"})]})]})}),(0,M.jsx)("label",{htmlFor:`${p}-basket-reference`,className:"basket-sidebar-label",children:g?"Enter email for your sharper quote":d?"Your email":"Your reference (optional)"}),(0,M.jsx)("input",{id:`${p}-basket-reference`,type:d?"email":"text",className:"basket-sidebar-input",value:E,onChange:_=>{O(_.target.value),d&&z("")},placeholder:d?"you@example.com":"PO number or job reference","aria-invalid":d&&k===zv,"aria-describedby":d&&k?`${p}-basket-reference-error`:void 0}),d&&k&&(0,M.jsx)("p",{id:`${p}-basket-reference-error`,className:"basket-quote-request-error",role:"alert",children:k}),d?(0,M.jsx)("button",{type:"button",className:"cta-btn",onClick:()=>{wt()},disabled:h||G>0||ie>0,"aria-busy":h,children:(0,M.jsx)("span",{children:h?"Sending\u2026":g?"Request our best quote":"Send basket"})}):(0,M.jsx)("button",{className:"cta-btn",onClick:()=>{m("downloaded",{type:"basket",items:b.length}),Mv(b)},"aria-label":"Download selection",children:(0,M.jsx)("span",{children:"Download Quote"})}),(0,M.jsxs)("p",{className:"basket-sidebar-disclaimer",children:[(0,M.jsx)("span",{"aria-hidden":"true",children:"\u26A0\uFE0F"}),g?"This is a quote request, not an order. We'll confirm our best price, availability and delivery before you approve.":d?"Sending your basket isn't an order. We'll confirm prices, availability and delivery before you approve.":"Prices and availability are estimates and should be confirmed before procurement."]})]})]}),(0,M.jsx)("div",{className:"btn-row results-actions",children:(0,M.jsxs)("button",{className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",gap:10,justifyContent:"center"},onClick:n,"aria-label":"Back to results",children:[(0,M.jsx)(Vr,{}),(0,M.jsx)("span",{children:"Back to results"})]})})]})})]})})}var xe=$(He());function On(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,linkedContext:t.linkedContext}}var xi=$(F());function Hd(){return(0,xi.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,xi.jsx)("path",{d:"M3 12a9 9 0 0 1 15.36-6.36L21 8"}),(0,xi.jsx)("path",{d:"M21 3v5h-5"}),(0,xi.jsx)("path",{d:"M21 12a9 9 0 0 1-15.36 6.36L3 16"}),(0,xi.jsx)("path",{d:"M3 21v-5h5"})]})}var s=$(F()),jd="__none__",pl=24,G_=[{dir:"asc",label:"Description (A-Z)"},{dir:"desc",label:"Description (Z-A)"}];function Dv(e){return e==null?"low":e>=.7?"high":e>=.5?"medium":"low"}var j_=e=>e.attrs.supply_nature==="labour_only"||e.attrs.supply_nature==="plant"||e.flags.includes("referential");function Y_(e,t){if(t!==jd){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 Rv(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 $_({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 Ln(e,t){if(e==null)return"-";let a=ol(t);return a?`${e.toFixed(2)} ${a}`:e.toFixed(2)}function Yd(e){return e&&e.length>0?e.join(" x "):"-"}function V_(e){return e==null?"-":Number.isInteger(e/1e3)?`${e/1e3}m`:`${(e/1e3).toFixed(1)}m`}function Bn(e){let t=(e??[]).map(a=>a.trim()).filter(Boolean);return t.length>0?t.join(", "):"-"}function Zr(e,t){let a=typeof e.description_original=="string"?e.description_original.trim():"";return(typeof e.customer_display_label=="string"?e.customer_display_label.trim():"")||a||"(no description)"}function X_(e,t){return t>0||e==null?null:nt(e)}var Av=[{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 Z_(e){let t=new Map;return[...new Set(e.filter(Kr).map(r=>r.linked_group_id))].forEach((r,i)=>{let n=i%26;t.set(r,{token:String.fromCharCode(65+n),bubbleStyle:Av[i%Av.length]})}),t}function Kr(e){return!1}function Hn(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 Qd({meta:e}){return e?(0,s.jsx)("span",{className:"results-linked-pill",style:e.bubbleStyle,children:`Link ${e.token}`}):null}function K_(e,t,a){let r=t?.rerank?.recommendedCandidateIds??[];if(r.length===0){let o=e.slice(0,6),l=o.some(c=>c.product_id===a)?void 0:e.find(c=>c.product_id===a);return l?[...o,l]:o}let i=new Map(e.map(o=>[o.product_id,o])),n=r.map(o=>i.get(o)).filter(o=>o!=null);if(a&&!n.some(o=>o.product_id===a)){let o=i.get(a);o&&n.unshift(o)}return[...new Map(n.map(o=>[o.product_id,o])).values()].slice(0,6)}function Gd(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 cc(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 P_({processStages:e,llmCalls:t,totalDurationMs:a,llmDurationMs:r,llmCallCount:i}){let n=[...t].sort((l,c)=>c.durationMs-l.durationMs).slice(0,12),o=Math.max(0,t.length-n.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:cc(a)})," total"]}),(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:i})," LLM calls"]}),(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:cc(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:cc(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:n.map((l,c)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:l.label}),(0,s.jsx)("td",{children:cc(l.durationMs)})]},`${l.key}-${c}`))})]}),o>0&&(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Showing slowest ",n.length," of ",t.length," LLM calls."]})]})]})}function J_({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,i)=>(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:Yd(r.measurements_mm)}),(0,s.jsx)("td",{children:ol(r.price_basis)||"-"}),(0,s.jsx)("td",{children:r.bm25.toFixed(2)})]},`${r.product_id}-${i}`))})]})]},`${t.query}-${a}`))]})}function Uv({item:e,result:t}){let a=t?.retrieval_debug.map(i=>i.query).filter(Boolean)??[],r=[["Procurement intent",e.procurement_intent||"-"],["Procurement aliases",Bn(e.procurement_aliases)],["Retrieval queries",Bn(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)",Yd(e.attrs.measurements_mm)],["Stock length",V_(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",Bn(e.installation_clues)],["System clues",Bn(e.system_clues)],["Component requirements",Bn(e.component_requirements)],["Linked group",Hn(e)||"-"],["Flags",Bn(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(([i,n])=>(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:i}),(0,s.jsx)("dd",{children:n})]},i))})]})}function I_({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)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:"Attempted"}),(0,s.jsx)("dd",{children:t.attempted?"yes":"no"})]}),(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:"Applied"}),(0,s.jsx)("dd",{children:t.applied?"yes":"no"})]}),(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:"Returned items"}),(0,s.jsx)("dd",{children:t.returned_item_count??"-"})]}),(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:"Reason"}),(0,s.jsx)("dd",{children:t.reason||"-"})]}),(0,s.jsxs)(xe.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 F_({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||"-"]];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,i])=>(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:r}),(0,s.jsx)("dd",{children:i})]},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 W_({item:e,decision:t,selectedProductId:a,result:r,showRetrievalDebug:i,reviewOnly:n=!1,linkedGroupMeta:o}){if(!t)return null;let l=a==null?"Needs review:":"Selected:";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:l}),"\xA0",t.reason]}),Kr(e)?(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Linked context: ",o?`Link ${o.token} - `:"",Hn(e)]}):null]}):null:!t.reason&&!i?(0,s.jsx)(Uv,{item:e,result:r}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Uv,{item:e,result:r}),i&&(0,s.jsx)(I_,{item:e}),i&&(0,s.jsx)(F_,{result:r}),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:l}),"\xA0",t.reason]}),Kr(e)?(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Linked context: ",o?`Link ${o.token} - `:"",Hn(e)]}):null]}),i&&(0,s.jsx)(J_,{queries:r?.retrieval_debug??[]})]})}function ex({item:e,candidates:t,result:a,decision:r,unmatchable:i,selectedProductId:n,detailMode:o,onPick:l,onClear:c,showAll:p=!1,internal:m=!1,debugEnabled:g=!1,forceReviewNote:d=!1,linkedGroupMeta:b}){let v=m||o==="detailed",E=g&&o==="detailed",O=v||d?(0,s.jsx)(W_,{item:e,decision:r,selectedProductId:n,result:a,showRetrievalDebug:E,reviewOnly:d&&!v,linkedGroupMeta:b}):null;if(i)return(0,s.jsxs)(s.Fragment,{children:[O,(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:[O,(0,s.jsx)("p",{className:"results-empty-hint",children:"No candidates were returned for this line item."})]});let f=p||m||o==="detailed"?t:K_(t,a,n);return(0,s.jsxs)(s.Fragment,{children:[O,(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"}),E&&(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:f.map((u,h)=>{let w=u.product_id===n;return(0,s.jsxs)("tr",{className:w?"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:Yd(u.measurements_mm??u.debug?.candidate.measurements_mm)})}),(0,s.jsx)("td",{children:Ln(u.price,u.price_basis)}),E&&(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)($_,{band:Dv(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:w?"Currently selected":"Use this candidate",children:[(0,s.jsx)("input",{type:"checkbox",checked:w,onChange:()=>{w?c?.():l(u)},"aria-label":w?`${u.description} selected`:`Use ${u.description}`}),(0,s.jsx)("span",{className:"switch-toggle-track","aria-hidden":"true"})]})})]},`${u.product_id}-${h}`)})})]})]})}function $d({scheduleResult:e,onStartOver:t,cart:a,onAddToCart:r,onRemoveFromCart:i,onGoToBasket:n,cartSeeded:o,onCartSeeded:l,reviewGateComplete:c,onReviewGateComplete:p,internal:m=!1}){let g=!m&&Is()==="QZA6-MRA4",d=g?"quote":"basket",{results:b,lineItems:v,parseReport:E,timings:O}=e,[f,u]=(0,xe.useState)({}),h=En(),[w,k]=(0,xe.useState)({}),[z,A]=(0,xe.useState)({}),[U,R]=(0,xe.useState)(""),[H,oe]=(0,xe.useState)(null),[Te,je]=(0,xe.useState)(1),Ve=Ot().debug===!0,[Ne,we]=(0,xe.useState)("simple"),[le,Fe]=(0,xe.useState)(m?"list":"tile"),[Ee,Nt]=(0,xe.useState)(!1),[Z,ge]=(0,xe.useState)(null),[Re,bt]=(0,xe.useState)(""),[jt,Ct]=(0,xe.useState)([]),[wt,be]=(0,xe.useState)(!1),[de,tt]=(0,xe.useState)(null),[T,G]=(0,xe.useState)(!1),[ie,ce]=(0,xe.useState)(null),ve=(0,xe.useRef)(null),[Ye,qe]=(0,xe.useState)(new Set),[x,_]=(0,xe.useState)(new Set),[q,D]=(0,xe.useState)(!1);(0,xe.useEffect)(()=>{je(1)},[U,H,le]);let V=new Map(b.map(S=>[S.line_id,S])),N=Z_(v),L=v.map(S=>{let j=V.get(S.line_id),fe=j?.decision,ft=j_(S),Ze=f[S.line_id],Xa=Y_(j,Ze),Ai=a[S.line_id],v0=Ze===jd?void 0:w[S.line_id]??(Ai&&Ai.productId!==Xa?.product_id?Rv(Ai):Xa),Cm=ft?void 0:v0,y0=S.qty??0;return{item:S,result:j,decision:fe,unmatchable:ft,best:Cm,qty:y0,band:Dv(Cm?.scores?.overall)}}),ue=L.some(S=>!S.unmatchable&&!S.best&&!x.has(S.item.line_id))?null:sc(Object.values(a),{wasteFactorEnabled:!1,wasteFactorOverride:0}),ke=0;for(let S of L){if(S.unmatchable||!S.best)continue;let j=a[S.item.line_id];(!j||Ft(j).lineTotal==null)&&(ke+=1)}ke>0&&(ue=null);let vt=X_(ue,ke),mt=S=>!S.unmatchable&&!S.best&&Gd(S.result).length>0,Ut=S=>S.best??Gd(S.result)[0],Jr=L.filter(S=>!S.unmatchable&&!S.best).filter(S=>!x.has(S.item.line_id)),Ec=L.filter(S=>x.has(S.item.line_id)),Yt=L;if(U.trim()){let S=U.trim().toLowerCase();Yt=Yt.filter(j=>j.item.description_original?.toLowerCase().includes(S)||Ut(j)?.description?.toLowerCase().includes(S))}if(H){let S=H==="asc"?1:-1;Yt=[...Yt].sort((j,fe)=>S*(j.item.description_original||"").localeCompare(fe.item.description_original||""))}let hr=Math.max(1,Math.ceil(Yt.length/pl)),yt=Math.min(Te,hr),Zn=Yt.slice((yt-1)*pl,yt*pl),wm=Zn.filter(S=>!S.unmatchable&&S.best),Mc=Zn.filter(S=>!S.unmatchable&&S.best),vm=Zn.filter(S=>S.unmatchable||!S.best),P=Z?L.find(S=>S.item.line_id===Z)??null:null,d0=!m&&!c&&!P&&Jr.length>0,Kn=(0,xe.useRef)(null),Pn=()=>{let S=ve.current;if(!S)return;let{top:j,left:fe,width:ft,height:Ze}=S.getBoundingClientRect(),Ai=S.querySelector(".bom-toolbar-btn")?.closest("td")?.getBoundingClientRect().left;ce({top:j,left:fe,width:Ai?Ai-fe:ft,height:Ze})};(0,xe.useEffect)(()=>(window.addEventListener("scroll",Pn,!0),window.addEventListener("resize",Pn),()=>{window.removeEventListener("scroll",Pn,!0),window.removeEventListener("resize",Pn)})),(0,xe.useEffect)(()=>{let S=j=>{Kn.current&&!j.composedPath().includes(Kn.current)&&Kn.current.removeAttribute("open")};return document.addEventListener("click",S),()=>document.removeEventListener("click",S)},[]);let zi=S=>{ge(S),bt("")},m0=()=>{if(!Z)return;let S=a[Z];if(S){u(j=>({...j,[Z]:S.productId})),k(j=>({...j,[Z]:Rv(S)}));return}u(j=>{let fe={...j};return delete fe[Z],fe}),k(j=>{let fe={...j};return delete fe[Z],fe})},Va=(S=!1)=>{let j=Z?a[Z]:void 0;!S&&j&&P?.best&&j.productId!==P.best.product_id&&!window.confirm("You have selected a new product. Leave without updating it?")||(S||m0(),ge(null),D(!1))};rl(T,()=>G(!1)),rl(!!P&&!T,()=>Va());let f0=S=>{if(qe(j=>new Set(j).add(S)),Jr.some(j=>j.item.line_id!==S)){Va(!0);return}p(),Va(!0)},h0=S=>{if(Tc(S),_(j=>new Set(j).add(S)),Jr.some(j=>j.item.line_id!==S)){Va(!0);return}p(),Va(!0)},g0=()=>{_(S=>new Set([...S,...Jr.map(j=>j.item.line_id)])),p()},ym=()=>{P?.best&&(xm(P.item.line_id,P.best),r(Jn(P)),q?f0(P.item.line_id):Va(!0))},_m=vm.length>0?(0,s.jsxs)("section",{className:"results-tile-section results-tile-section--unmatched","aria-label":"Items needing review",children:[(0,s.jsxs)("div",{className:"results-tile-section__head",children:[(0,s.jsx)("h3",{children:"Needs review"}),(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:vm.map(S=>{let{item:j,qty:fe}=S;return(0,s.jsxs)("button",{type:"button",className:"results-unmatched-card",onClick:()=>zi(j.line_id),children:[(0,s.jsx)("span",{className:"results-unmatched-card__main",children:(0,s.jsx)("span",{className:"results-unmatched-card__title",children:Zr(j,v)})}),(0,s.jsx)("span",{className:"bom-toolbar-btn results-unmatched-card__prompt",children:"Review"})]},j.line_id)})})]}):null,Tc=S=>{u(j=>({...j,[S]:jd})),k(j=>({...j,[S]:void 0})),A(j=>({...j,[S]:void 0})),i(S)},zc=(S,j)=>{u(fe=>({...fe,[S]:j.product_id})),k(fe=>({...fe,[S]:j}))},xm=(S,j)=>{j.method==="catalogue_search"&&A(fe=>({...fe,[S]:j}))};function Hx(){h("downloaded",{type:"schedule",lines:L.length}),Ev(L.map(({item:S,best:j,qty:fe,band:ft,unmatchable:Ze,decision:Xa})=>({item:S,best:j,qty:fe,band:ft,unmatchable:Ze,decision:Xa})))}function Jn(S){let j=S.best;if(!j)throw new Error("Cannot add a line item without a selected product.");return On(j,{lineId:S.item.line_id,description:S.item.description_original,unit:S.item.unit,qty:S.qty,linkedContext:S.item.linked_group_role==="dependent"&&S.item.linked_group_id?v.filter(fe=>fe.linked_group_id===S.item.linked_group_id&&fe.linked_group_role==="anchor").slice(0,1).map(fe=>{let ft=a[fe.line_id];return{line_id:fe.line_id,product_id:ft?.productId??null,measurements_mm:ft?.measurementsMm??fe.attrs.measurements_mm,description:ft?.description??fe.description_original,qty:fe.qty,unit:fe.unit,role:"anchor"}}):void 0})}(0,xe.useEffect)(()=>{if(!o){for(let S of L)!S.unmatchable&&S.best&&r(Jn(S));l()}},[o]),(0,xe.useEffect)(()=>{if(!Z){Ct([]),tt(null),be(!1);return}let S=Re.trim();if(!S){Ct([]),tt(null),be(!1);return}let j=!1,fe=window.setTimeout(async()=>{try{be(!0),tt(null);let ft=await fetch(Ta(`/api/catalogue/search?q=${encodeURIComponent(S)}`),{headers:bi()}),Ze=await Ga(ft);if(!ft.ok)throw new Error(Ze?.error||Ze?.message||"Failed to search catalogue");j||Ct(Array.isArray(Ze?.items)?Ze.items:[])}catch(ft){j||(Ct([]),tt(ft?.message||"Failed to search catalogue"))}finally{j||be(!1)}},250);return()=>{j=!0,window.clearTimeout(fe)}},[Re,Z]);let Rc=Object.keys(a).length,Ca=Re.trim(),Ac=Gd(P?.result),bl=!!P&&!P.best&&(P.result?.candidates.length===0||P.result?.rerank?.selectedCandidateId===null),km=P?.result?.rerank!=null,Sm=P?.decision?.reason??(bl?"No catalogue candidate found. Refine the request or search the catalogue.":null),b0=jt.map(S=>({product_id:S.product_id,description:S.description,source_list:S.source_list,price:S.price,price_basis:S.price_basis,uoi_count:S.uoi_count??null,uoi:S.uoi,pdp_photo_url:S.pdp_photo_url??null,conversion:S.conversion,measurements_mm:S.measurements_mm??[],scores:{dimension:0,grade:0,brand:0,fuzzy:0,bm25:0,overall:0},method:"catalogue_search"})),In=Ca?b0:Ac,Ri=P?z[P.item.line_id]:void 0,Fn=!Ca&&Ri&&!In.some(S=>S.product_id===Ri.product_id)?[...In,Ri]:In,Nm=(()=>{let S=Fn.slice(0,Ca?12:6);return Ca||!Ri||S.some(j=>j.product_id===Ri.product_id)?S:[...S,Ri]})(),wl=!!P?.best&&a[P.item.line_id]?.productId===P.best.product_id,w0=!!P?.best&&!!a[P.item.line_id]&&!wl;return(0,s.jsxs)("div",{className:"wizard-step entry-stage",children:[(0,s.jsxs)("div",{className:`quick-order-card${m?"":" quick-order-card--customer"}`,children:[(0,s.jsx)("div",{className:`quick-order-hero${m?"":" quick-order-hero--customer"}`,children:m?(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:vt??"Review quantities"})," 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 ",g?"View Quote":"View Basket"," to continue."]})]}),(0,s.jsxs)("button",{type:"button",className:"results-total-action",onClick:n,disabled:Rc===0,"aria-label":g?"View quote":"View basket",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:g?"View Quote":"View Basket"}),vt!=null&&(0,s.jsx)("strong",{children:vt})]}),(0,s.jsx)("span",{className:"arrow",children:(0,s.jsx)(Qt,{})})]})]})}),(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":Ee,onClick:()=>Nt(S=>!S),children:Ee?"Hide timings":"Show timings"})}),Ve&&Ee&&(0,s.jsx)(P_,{...O}),!g&&(0,s.jsx)("div",{className:"results-toolbar-row",children:!P&&(0,s.jsx)("div",{className:"results-summary",style:{marginBottom:0},children:(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:U,onChange:S=>R(S.target.value),"aria-label":"Search line items"}),!m&&(0,s.jsxs)("div",{className:"results-view-toggle","aria-label":"Results view",children:[(0,s.jsx)("button",{type:"button",className:`results-view-toggle__btn${le==="tile"?" is-active":""}`,"aria-pressed":le==="tile","aria-label":"Tile view",title:"Tile view",onClick:()=>Fe("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${le==="list"?" is-active":""}`,"aria-pressed":le==="list","aria-label":"List view",title:"List view",onClick:()=>Fe("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:()=>we(S=>S==="simple"?"detailed":"simple"),children:Ne==="detailed"?"Hide detailed view":"Show detailed view"}),(0,s.jsxs)("details",{ref:Kn,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:G_.map(S=>{let j=H===S.dir;return(0,s.jsxs)("button",{type:"button",className:`sort-menu-item${j?" is-active":""}`,onClick:()=>{oe(j?null:S.dir),Kn.current?.removeAttribute("open")},children:[(0,s.jsx)("span",{className:"sort-menu-item__check",children:j?"\u2713":""}),S.label]},S.dir)})})]})]})})}),le==="tile"||P?(0,s.jsxs)(s.Fragment,{children:[P?(0,s.jsx)("div",{className:"modal-backdrop quick-order-modal-backdrop",role:"dialog","aria-modal":"true","aria-label":"Product options",onClick:()=>Va(),children:(0,s.jsxs)("section",{className:"quick-order-workflow-modal results-review-modal",onClick:S=>S.stopPropagation(),children:[(0,s.jsx)("button",{type:"button",className:"quick-order-workflow-close results-review-modal__close",onClick:()=>Va(),"aria-label":"Close product options",children:(0,s.jsx)(il,{})}),(0,s.jsx)("div",{className:"results-review-page",children:m?(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:()=>Va(),children:[(0,s.jsx)(Vr,{}),"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:()=>we(S=>S==="simple"?"detailed":"simple"),children:Ne==="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:Re,onChange:S=>bt(S.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:()=>Tc(P.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)(za,{className:"fill-img results-review-page__image",description:Ut(P)?.description||P.item.description_original,photoUrl:Ut(P)?.pdp_photo_url})}),(0,s.jsxs)("div",{className:"results-review-page__summary",children:[(0,s.jsx)("h2",{children:Zr(P.item,v)}),(0,s.jsxs)("p",{className:"results-review-page__meta",children:[vi(P.qty)," ",xa(P.item.unit,P.qty)]}),P.best?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-review-page__product",children:P.best.description}),P.best.price!=null?(0,s.jsx)("div",{className:"results-row-meta",children:Ln(P.best.price,P.best.price_basis)}):null]}):Ut(P)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-review-page__product",children:Ut(P)?.description}),Ut(P)?.price!=null?(0,s.jsx)("div",{className:"results-row-meta",children:Ln(Ut(P)?.price??null,Ut(P)?.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."}),Kr(P.item)?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[(0,s.jsx)(Qd,{meta:N.get(P.item.linked_group_id)}),(0,s.jsx)("div",{className:"results-row-meta",style:{marginTop:0},children:Hn(P.item)})]}):null,(0,s.jsx)("div",{className:"results-review-page__actions",children:(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[P.item.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>{a[P.item.line_id]?i(P.item.line_id):(P.best&&xm(P.item.line_id,P.best),r(Jn(P)))},disabled:!P.best,"aria-label":a[P.item.line_id]?m?"Remove from selection":`Remove from ${d}`:m?"Add to selection":`Add to ${d}`,children:a[P.item.line_id]?"\u2713 Added":m?"+ Add to selection":`Add to ${d}`})})]})]}),wt?(0,s.jsx)("div",{className:"results-empty-card",children:"Searching catalogue\u2026"}):null,!wt&&de?(0,s.jsx)("div",{className:"results-empty-card",children:de}):null,!wt&&!de&&Ca&&In.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No candidate products match this database search."}):!wt&&!de?(0,s.jsx)(ex,{item:P.item,candidates:In,result:P.result,decision:P.decision,unmatchable:P.unmatchable,selectedProductId:P.best?.product_id??null,detailMode:Ne,linkedGroupMeta:Kr(P.item)?N.get(P.item.linked_group_id):void 0,onPick:S=>zc(P.item.line_id,S),onClear:()=>Tc(P.item.line_id),showAll:m||Ve||Ca.length>0,internal:m,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:Zr(P.item,v)||"Original request"})]}),Sm?(0,s.jsxs)("section",{className:"customer-review-ai",children:[(0,s.jsx)("strong",{children:bl?"No automatic match:":"AI review:"})," ",Sm]}):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:bl?Ac.length>0?"Choose a product":"No suitable product found":km?"Choose a product":"We couldn't review this item"}),(0,s.jsx)("p",{children:bl?Ac.length>0?"No product was selected automatically. Review these related options before adding one.":"Search the catalogue to choose an alternative.":km?`Select the option you want to add to your ${d}.`:"Search the catalogue to choose a product."})]})}),!Ca&&Fn.length>0?(0,s.jsx)("div",{className:"customer-review-option-grid",children:Nm.map(S=>{let j=S.product_id===P.best?.product_id;return(0,s.jsxs)("button",{type:"button",className:`customer-review-option${j?" is-selected":""}`,onClick:()=>zc(P.item.line_id,S),"aria-pressed":j,children:[(0,s.jsx)(za,{className:"customer-review-option__image",description:S.description,photoUrl:S.pdp_photo_url,width:64,height:64}),(0,s.jsx)("span",{className:"customer-review-option__copy",children:(0,s.jsx)("strong",{children:S.description})}),(0,s.jsx)("span",{className:"customer-review-option__price",children:S.price!=null?`\xA3${Ln(S.price,S.price_basis)}`:"-"}),(0,s.jsx)("span",{className:"customer-review-option__state",children:j?"Selected":"Choose"})]},S.product_id)})}):null,Fn.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:Re,onChange:S=>bt(S.target.value),"aria-label":"Search catalogue"})]}),Ca&&wt?(0,s.jsx)("div",{className:"results-empty-card",children:"Searching catalogue\u2026"}):null,Ca&&!wt&&de?(0,s.jsx)("div",{className:"results-empty-card",children:de}):null,Ca&&!wt&&!de&&Fn.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No products match this search."}):null,Ca&&!wt&&!de&&Fn.length>0?(0,s.jsx)("div",{className:"customer-review-option-grid",children:Nm.map(S=>{let j=S.product_id===P.best?.product_id;return(0,s.jsxs)("button",{type:"button",className:`customer-review-option${j?" is-selected":""}`,onClick:()=>zc(P.item.line_id,S),"aria-pressed":j,children:[(0,s.jsx)(za,{className:"customer-review-option__image",description:S.description,photoUrl:S.pdp_photo_url,width:64,height:64}),(0,s.jsx)("span",{className:"customer-review-option__copy",children:(0,s.jsx)("strong",{children:S.description})}),(0,s.jsx)("span",{className:"customer-review-option__price",children:S.price!=null?`\xA3${Ln(S.price,S.price_basis)}`:"-"}),(0,s.jsx)("span",{className:"customer-review-option__state",children:j?"Selected":"Choose"})]},S.product_id)})}):null]}),P.best?w0?(0,s.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,s.jsx)("button",{type:"button",className:"cta-btn customer-review-add",onClick:()=>{ym()},children:(0,s.jsx)("span",{children:"Update product"})}),(0,s.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary customer-review-add",onClick:()=>i(P.item.line_id),children:(0,s.jsx)("span",{children:`Remove from ${d}`})})]}):(0,s.jsx)("button",{type:"button",className:`cta-btn customer-review-add${wl?" cta-btn-secondary":""}`,onClick:()=>{wl?i(P.item.line_id):ym()},children:(0,s.jsx)("span",{children:wl?`Remove from ${d}`:`Add selected product to ${d}`})}):null,q?(0,s.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary customer-review-skip",onClick:()=>h0(P.item.line_id),children:"Skip this item"}):null]})})]})}):null,(0,s.jsxs)("div",{className:"results-tile-layout",children:[Yt.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No line items match the current search/filter."}):null,Mc.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:Mc.map(S=>{let{item:j,best:fe,qty:ft}=S,Ze=Ut(S);return(0,s.jsxs)("article",{className:"results-tile-card",children:[(0,s.jsxs)("button",{type:"button",className:"results-tile-card__surface",onClick:()=>zi(j.line_id),"aria-label":`Review match for ${Zr(j,v)||"item"}`,children:[(0,s.jsxs)("div",{className:"results-tile-card__media",children:[Kr(j)?(0,s.jsx)("div",{className:"results-tile-card__badges",children:(0,s.jsx)(Qd,{meta:N.get(j.linked_group_id)})}):null,(0,s.jsx)(za,{className:"fill-img results-tile-card__image",description:Ze?.description||j.description_original,photoUrl:Ze?.pdp_photo_url})]}),(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:"\u21B3 matched from"}),(0,s.jsx)("div",{className:"results-tile-card__match-name",children:Zr(j,v)}),Kr(j)?(0,s.jsx)("div",{className:"results-row-meta",children:Hn(j)}):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:[m&&(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>zi(j.line_id),children:"Review"}),(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[j.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>{a[j.line_id]?i(j.line_id):r(Jn(S))},disabled:!fe,"aria-label":a[j.line_id]?m?"Remove from selection":`Remove from ${d}`:m?"Add to selection":`Add to ${d}`,children:a[j.line_id]?"\u2713 Added":m?"+ Add":`Add to ${d}`})]})]},j.line_id)})})}):null,_m]})]}):(0,s.jsxs)(s.Fragment,{children:[ie&&(0,s.jsx)("div",{className:"results-table__hover-overlay",style:ie,"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"}}),Ne==="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"}),Ne==="simple"&&(0,s.jsx)("th",{style:{textAlign:"center"},children:m?"Selection":g?"Quote":"Basket"})]})}),(0,s.jsxs)("tbody",{children:[Yt.length===0&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:Ne==="simple"?4:3,className:"results-empty-hint",style:{padding:"16px 8px"},children:"No line items match the current search/filter."})}),Mc.map(S=>{let{item:j,result:fe,decision:ft,best:Ze}=S;return(0,s.jsxs)("tr",{className:"bom-row results-table__review-row",onClick:()=>zi(j.line_id),onMouseEnter:Xa=>{ve.current=Xa.currentTarget,Pn()},onMouseLeave:()=>{ve.current=null,ce(null)},children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("div",{className:"bom-component-name",children:Zr(j,v)}),Kr(j)?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[(0,s.jsx)(Qd,{meta:N.get(j.linked_group_id)}),(0,s.jsx)("div",{className:"results-row-meta",style:{marginTop:0},children:Hn(j)})]}):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}),Ne==="detailed"&&ft&&(0,s.jsx)("div",{className:"results-row-meta",children:ft.selected_candidate_id===Ze.product_id?"Automatically selected":"Selected"})]}):(0,s.jsx)("span",{className:"results-empty-hint"})}),(0,s.jsx)("td",{style:{textAlign:"center"},children:Ze?.price!=null?Ln(Ze.price,Ze.price_basis):"-"}),Ne==="simple"&&(0,s.jsx)("td",{style:{textAlign:"center"},children:(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[j.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,style:{width:84,justifyContent:"center"},onClick:Xa=>{Xa.stopPropagation(),a[j.line_id]?i(j.line_id):r(Jn(S))},"aria-label":a[j.line_id]?m?"Remove from selection":`Remove from ${d}`:m?"Add to selection":`Add to ${d}`,children:a[j.line_id]?"\u2713 Added":m?"+ Add":`Add to ${d}`})})]},j.line_id)})]})]})}),_m]}),!P&&hr>1&&(0,s.jsxs)("div",{className:"results-pagination",children:[(0,s.jsxs)("span",{className:"results-pagination-count",children:["Showing ",(yt-1)*pl+1,"\u2013",Math.min(yt*pl,Yt.length)," of ",Yt.length]}),(0,s.jsxs)("div",{className:"results-pagination-controls",children:[(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>je(yt-1),disabled:yt===1,children:"Previous"}),(0,s.jsxs)("span",{className:"results-pagination-page",children:["Page ",yt," of ",hr]}),(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>je(yt+1),disabled:yt===hr,children:"Next"})]})]}),(E.itemCount!=null||E.headingCount!=null||E.skippedCount!=null)&&(0,s.jsxs)("div",{className:"results-summary",style:{marginTop:16},children:[E.itemCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:E.itemCount})," items parsed"]}),E.headingCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:E.headingCount})," headings"]}),E.skippedCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:E.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."})]}),!P&&(0,s.jsxs)("div",{className:"btn-row results-actions",children:[(0,s.jsxs)("button",{className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",gap:10,justifyContent:"center"},onClick:()=>G(!0),"aria-label":"Start over",children:[(0,s.jsx)(Hd,{}),(0,s.jsx)("span",{children:"Start Over"})]}),(0,s.jsxs)("button",{className:"cta-btn",style:{flex:"0 1 70%"},onClick:n,disabled:Rc===0,"aria-label":m?"View selection":g?"View quote":"View basket",children:[(0,s.jsxs)("span",{children:[m?"View Selection":g?"View Quote":"View Basket"," (",Rc,")"]}),(0,s.jsx)("span",{className:"arrow",children:(0,s.jsx)(Qt,{})})]})]})]})]}),d0&&(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:Jr.map(S=>{let j=Ye.has(S.item.line_id),fe=mt(S);return(0,s.jsx)("div",{className:`review-gate-item${j?" is-reviewed":""}`,children:(0,s.jsxs)("button",{type:"button",className:"review-gate-item__review",onClick:()=>{D(!0),zi(S.item.line_id)},children:[(0,s.jsxs)("span",{className:"review-gate-item__copy",children:[(0,s.jsx)("strong",{children:Zr(S.item,v)}),(0,s.jsx)("span",{children:S.decision?.reason||(fe?"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:j?"Choice made":"Choose a product"})]})},S.item.line_id)})}),(0,s.jsx)("button",{type:"button",className:"review-gate-skip",onClick:g0,children:"Skip all"}),Ec.length>0?(0,s.jsxs)("div",{className:"review-gate-skipped",children:[(0,s.jsx)("strong",{children:"Skipped"}),Ec.map(S=>(0,s.jsxs)("button",{type:"button",className:"review-gate-item is-skipped",onClick:()=>{_(j=>{let fe=new Set(j);return fe.delete(S.item.line_id),fe}),D(!0),zi(S.item.line_id)},children:[(0,s.jsxs)("span",{className:"review-gate-item__copy",children:[(0,s.jsx)("strong",{children:Zr(S.item,v)}),(0,s.jsx)("span",{children:`Not added to your ${d}.`})]}),(0,s.jsx)("span",{className:"review-gate-item__action",children:"Choose a product"})]},S.item.line_id))]}):null]})}),T&&(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 ",g?"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:()=>G(!1),children:"Cancel"}),(0,s.jsx)("button",{type:"button",className:"modal-btn modal-btn-danger",onClick:()=>{G(!1),t()},autoFocus:!0,children:"Start Over"})]})]})})]})}var ka=$(F()),Vd="metron-quick-quote",tx=1440*60*1e3;function uc(e){return(0,ka.jsx)(lc,{children:(0,ka.jsx)(ax,{...e})})}function ax({fullPage:e=!1,hideHeader:t=!1,internal:a=!1}){let[r,i]=(0,De.useState)("entry"),[n,o]=(0,De.useState)(null),[l,c]=(0,De.useState)(""),p=(0,De.useRef)(null),m=(0,De.useRef)(0),[g,d]=(0,De.useState)(0),[b,v]=(0,De.useState)(null),[E,O]=(0,De.useState)(!1),{cart:f,addToCart:u,addManyToCart:h,removeFromCart:w,updateCartQty:k,updateCartSellUnits:z,updateCartConversions:A,clearCart:U}=Dn(),[R,H]=(0,De.useState)(!1),[oe,Te]=(0,De.useState)(null),je=()=>{Te(null);try{window.sessionStorage.removeItem(oc)}catch{}},Ve=(0,De.useRef)(null),Ne=Js("quick-quote",Ve);(0,De.useEffect)(()=>{Ne("viewed")},[Ne]);let[we,le]=(0,De.useState)(!1);(0,De.useEffect)(()=>{wv();let be=window.location.hash,de=null;try{de=JSON.parse(window.sessionStorage.getItem(Vd)??"null")}catch{}if(de&&!(Date.now()-(de.savedAt??0)<tx)&&(de=null),de?.scheduleResult)o("schedule"),v(de.scheduleResult),O(de.reviewGateComplete),H(de.cartSeeded),h(Object.values(de.cart)),be==="#quote-request"?i("basket"):be==="#matched-products"&&i("results");else if(be==="#matched-products"||be==="#quote-request"){let tt=new URL(window.location.href);tt.hash="",Rn("replaceState",window.history.state,tt)}le(!0)},[]),(0,De.useEffect)(()=>{if(we)try{b?window.sessionStorage.setItem(Vd,JSON.stringify({savedAt:Date.now(),scheduleResult:b,reviewGateComplete:E,cartSeeded:R,cart:f})):window.sessionStorage.removeItem(Vd)}catch{}},[we,b,E,R,f]);let Fe=(0,De.useCallback)(be=>{if(typeof window>"u")return;let de=new URL(window.location.href);de.hash=be==="basket"?"quote-request":"matched-products";let tt=be==="results"&&(window.location.hash==="#matched-products"||window.location.hash==="#quote-request");Rn(tt?"replaceState":"pushState",{boqQuoteStage:be},de)},[]),Ee=(0,De.useRef)(!1);(0,De.useEffect)(()=>{let be=()=>{Ee.current=!1;let de=window.location.hash;de==="#quote-request"?i("basket"):de==="#matched-products"&&b?(o("schedule"),i("results")):i("entry")};return window.addEventListener("popstate",be),()=>window.removeEventListener("popstate",be)},[b]);let Nt=(0,De.useCallback)(()=>{Fe("basket"),i("basket")},[Fe]),Z=(0,De.useCallback)(()=>{if(window.location.hash==="#quote-request"){if(Ee.current)return;Ee.current=!0,nc();return}i(b?"results":"entry")},[b]),ge=(0,De.useRef)(r);(0,De.useEffect)(()=>{ge.current!==r&&(ge.current=r,window.scrollTo(0,0))},[r]);let Re=()=>{i("entry"),o(null),c(""),d(0),v(null),O(!1),U(),H(!1),je()},bt=(0,De.useCallback)(async(be,de,tt=!0)=>{let T=++m.current;c(""),d(0);let G=0,ie=()=>{G=Math.min(G+1,3),d(G)};try{let{jobId:ce}=await Nw(be,de,tt);if(T!==m.current)return;let{promise:ve,cancel:Ye}=qw(()=>Cw(ce),5e3,ie,"schedule");p.current=Ye;let qe=await ve;if(qe.status==="failed"||!qe.result)throw new Error(qe.error||"Failed to process schedule");let x=qe.result.lineItems.length,_=qe.result.results.filter(q=>q.candidates.length>0).length;Ne("results_shown",{lines:x,matched:_,unmatched:x-_}),U(),H(!1),O(!1),v(qe.result),Fe("results"),i("results")}catch(ce){if(T!==m.current)return;Ne("error",{stage:"matching"}),c(ce?.message||"Failed to process schedule"),i("entry")}finally{T===m.current&&(p.current?.(),p.current=null)}},[Fe,Ne,U]),jt=(0,De.useCallback)(()=>{m.current++,p.current?.(),p.current=null},[]),Ct=(0,De.useCallback)(async(be,de,tt=!0)=>{if(!be.trim())return;o("schedule");let T=new File([be],"pasted-schedule.txt",{type:"text/plain"});await bt(T,de,tt)},[bt]),wt=(0,De.useCallback)(async be=>{o("schedule"),await bt(be)},[bt]);return(0,ka.jsx)(tl.Provider,{value:Ne,children:(0,ka.jsx)("div",{ref:Ve,className:`app-wrapper${e?"":" app-wrapper--embedded"}${t?" app-wrapper--no-header":""}${!e&&r==="processing"?" app-wrapper--loading":""}`,style:Ot().theme,children:(0,ka.jsxs)("main",{className:"main-content",children:[l&&(0,ka.jsxs)("div",{className:"error-box",role:"alert",children:[(0,ka.jsx)("strong",{children:"Error:"})," ",l]}),r==="entry"&&(0,ka.jsx)(Cd,{onPasteSchedule:Ct,onUploadSchedule:wt,onEntryModeChange:o,draft:oe,onSubmitDraft:Te,onCancelMatch:jt}),r==="results"&&n==="schedule"&&b&&(0,ka.jsx)($d,{scheduleResult:b,onStartOver:Re,cart:f,onAddToCart:u,onRemoveFromCart:w,onGoToBasket:Nt,cartSeeded:R,onCartSeeded:()=>H(!0),reviewGateComplete:E,onReviewGateComplete:()=>O(!0),internal:a}),r==="basket"&&(0,ka.jsx)(ul,{cart:f,onUpdateQty:k,onUpdateSellUnits:z,onResolveConversions:A,onRemove:w,onBack:Z,onStartNewQuote:Re,onQuoteRequested:()=>{v(null),O(!1),H(!1),U(),je()},internal:a})]})})})}var $a=$(He());var Si=$(He());var Ov={"NZ4Y-ZMSQ":{"brick-block":{"brick-common":"105499","brick-engineering-red":"1654","brick-engineering-blue":"1723",block:"501","mortar-cement":"1762 cement","mortar-sand":"564 building sand"},skirting:{"skirting-chamfered":"1525","skirting-ogee":"135 primed mdf ogee","skirting-pencil-round":"892","skirting-torus":"1941"},architrave:{"architrave-ogee":"134 primed mdf ogee","architrave-pencil-round":"1896","architrave-square-edge":"118 primed mdf square","architrave-torus":"1531"},plasterboard:{standard:"1647",moisture:"11 moisture plasterboard",fire:"14 fire plasterboard",sound:"1769",screws:"131160",tape:"1766",adhesive:"108439"},paint:{"paint-emulsion":"157217"},"concrete-aggregate":{cement:"1762 cement","sharp-sand":"563",gravel:"571",mot:"569"},insulation:{"insulation-floor":"152187","insulation-ground":"442","insulation-wall":"147","insulation-roof":"442","insulation-loft":"152180"},timber:{studs:"1213",joists:"208",battens:"1729"},fencing:{"panels-boundary-0.9":"66 lap fence panel","panels-boundary-1.2":"1450","panels-boundary-1.5":"1449","panels-boundary-1.8":"1448","panels-skyline-1.8":"1475","concrete-intermediate-8":"40197","concrete-end-8":"40198","timber-post-6":"141411","timber-post-8":"1709",postcrete:"12142","gate-boundary":"1984","gate-skyline":"40002","gravel-boards":"40200"},decking:{"boards-summit":"24322",joists:"208",screws:"131079"},paving:{"surface-council":"1669","surface-raj":"12363","surface-brindle":"304","surface-charcoal":"296","surface-pea":"431","sub-base":"569",bedding:"563"}}};function dl(e,t){let a=Ov[Ot().client??""]?.[e];if(!a)return null;let r=e==="plasterboard"&&t.key==="board"?t.label.split(" ")[0].toLowerCase():t.key;return a[r]??null}function ki(e,t){let a=Ov[Ot().client??""]?.[e];return!a||t in a}function Bv(e,t){let a=t.map(r=>{let i=dl(e,r);return i?{key:r.key,productId:i.split(" ")[0],search:i,qty:r.qty,unit:r.unit}:null});return a.length>0&&a.every(Boolean)?a:null}var ee=$(F()),Lv=[{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"}],pc=e=>Number.parseFloat(e)||0,Hv=(e,t)=>pc(e)*(t==="m"?1:.3048),Xd=(e,t)=>pc(e.quantity)*(2*Hv(e.height,t)+Hv(e.width,t)),rx=()=>({quantity:"1",width:"",height:""});function ix({profile:e}){return(0,ee.jsxs)("svg",{className:"architrave-calculator__profile-diagram",viewBox:"0 0 112 76","aria-hidden":"true",children:[(0,ee.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,ee.jsx)("line",{x1:"12",y1:"66",x2:"100",y2:"66"})]})}function Zd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Si.useState)("m"),[n,o]=(0,Si.useState)({quantity:"1",width:"0.76",height:"1.98"}),[l,c]=(0,Si.useState)({quantity:"0",width:"1.52",height:"1.98"}),[p,m]=(0,Si.useState)([]),[g,d]=(0,Si.useState)("ogee"),[b,v]=(0,Si.useState)("2.4"),E=(k,z,A)=>{k(U=>({...U,[z]:A}))},O=Xd(n,r)+Xd(l,r)+p.reduce((k,z)=>k+Xd(z,r),0),f=pc(b)>0?Math.ceil(O/pc(b)):0,u=Lv.find(k=>k.id===g)?.label??"",h=[{key:`architrave-${g}`,label:`Architrave (${u})`,qty:O,unit:"m",query:`${u} architrave`,category:"architrave"}],w=(k,z,A,U)=>(0,ee.jsxs)("div",{className:"architrave-calculator__opening-row",children:[(0,ee.jsx)("span",{children:k}),(0,ee.jsx)("input",{"aria-label":`${k} quantity`,type:"number",min:"0",step:"1",value:z.quantity,onChange:R=>A("quantity",R.target.value)}),(0,ee.jsx)("input",{"aria-label":`${k} width`,type:"number",min:"0",step:"0.01",value:z.width,onChange:R=>A("width",R.target.value)}),(0,ee.jsx)("input",{"aria-label":`${k} height`,type:"number",min:"0",step:"0.01",value:z.height,onChange:R=>A("height",R.target.value)}),U?(0,ee.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:U,children:"Remove"}):null]});return(0,ee.jsx)(ee.Fragment,{children:(0,ee.jsxs)("div",{className:"truss-estimator",children:[(0,ee.jsxs)("div",{className:"quick-order-hero",children:[(0,ee.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,ee.jsx)("h1",{children:"Architrave Calculator"}),(0,ee.jsx)("p",{children:"Estimate architrave lengths and board quantities for door openings."})]}),(0,ee.jsxs)("div",{className:"truss-estimator__card architrave-calculator",children:[(0,ee.jsx)("h2",{className:"truss-estimator__step-title",children:"Measure your openings"}),(0,ee.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,ee.jsxs)("div",{className:"architrave-calculator__section",children:[(0,ee.jsx)("div",{className:"truss-estimator__section-heading",children:"Door openings"}),(0,ee.jsx)("p",{className:"architrave-calculator__hint",children:"Each opening is calculated as two side pieces plus one head piece."}),(0,ee.jsxs)("div",{className:"architrave-calculator__unit-row",children:[(0,ee.jsx)("span",{children:"Units"}),(0,ee.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,ee.jsx)("button",{type:"button",className:r==="m"?"is-selected":"",onClick:()=>i("m"),children:"Metres"}),(0,ee.jsx)("button",{type:"button",className:r==="ft"?"is-selected":"",onClick:()=>i("ft"),children:"Feet"})]})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__dimensions-header",children:[(0,ee.jsx)("span",{children:"Opening"}),(0,ee.jsx)("span",{children:"Qty"}),(0,ee.jsxs)("span",{children:["Width (",r,")"]}),(0,ee.jsxs)("span",{children:["Height (",r,")"]}),(0,ee.jsx)("span",{})]}),w("Single doors",n,(k,z)=>E(o,k,z)),w("Double doors",l,(k,z)=>E(c,k,z)),p.map((k,z)=>w(`Alternative door ${z+1}`,k,(A,U)=>m(R=>R.map((H,oe)=>oe===z?{...H,[A]:U}:H)),()=>m(A=>A.filter((U,R)=>R!==z)))),(0,ee.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>m(k=>[...k,rx()]),children:"+ Add alternative-sized door"})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__section",children:[(0,ee.jsx)("div",{className:"truss-estimator__section-heading",children:"Standard profile"}),(0,ee.jsx)("p",{className:"architrave-calculator__hint",children:"Choose the profile you plan to use. Length calculations are the same for each profile."}),(0,ee.jsx)("div",{className:"architrave-calculator__profiles",children:Lv.filter(k=>ki("architrave",`architrave-${k.id}`)).map(k=>(0,ee.jsxs)("button",{type:"button",className:`truss-estimator__option-card${g===k.id?" is-selected":""}`,onClick:()=>d(k.id),children:[(0,ee.jsx)(ix,{profile:k.id}),(0,ee.jsx)("div",{className:"truss-estimator__option-title",children:k.label}),(0,ee.jsx)("div",{className:"truss-estimator__option-copy",children:k.blurb})]},k.id))})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__section",children:[(0,ee.jsx)("div",{className:"truss-estimator__section-heading",children:"Board and waste"}),(0,ee.jsx)("div",{className:"architrave-calculator__options",children:(0,ee.jsxs)("label",{className:"truss-estimator__field",children:[(0,ee.jsx)("span",{children:"Board length (m)"}),(0,ee.jsx)("input",{value:"4.40 m",disabled:!0})]})}),(0,ee.jsx)("p",{className:"architrave-calculator__hint",children:"Waste allows for mitred corners, cuts and damaged lengths."})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__totals",children:[(0,ee.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,ee.jsxs)("div",{className:"architrave-calculator__result-grid",children:[(0,ee.jsxs)("div",{children:[(0,ee.jsx)("span",{children:"Architrave needed"}),(0,ee.jsxs)("strong",{children:[O.toFixed(2)," m"]})]}),(0,ee.jsxs)("div",{children:[(0,ee.jsx)("span",{children:"Board lengths"}),(0,ee.jsx)("strong",{children:f})]})]})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__actions",children:[(0,ee.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,ee.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(h),disabled:O<=0,children:a})]})]})]})})}var Ni=$(He()),ae=$(F()),Qv=60,Gv=10,nx=.02,ox=.012,jv=1,Yv=4,lx=1.33,sx=1440,cx=1600,Qn=e=>Number.parseFloat(e)||0,ux=(e,t=2)=>e.toFixed(t);function Kd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Ni.useState)("brick"),[n,o]=(0,Ni.useState)("engineering-red"),[l,c]=(0,Ni.useState)("metric"),[p,m]=(0,Ni.useState)(""),[g,d]=(0,Ni.useState)(""),[b,v]=(0,Ni.useState)(!0),E=l==="metric"?Qn(p)*Qn(g):Qn(p)*Qn(g)*.092903,f=E*(r==="brick"?Qv:Gv),u=Math.ceil(f),w=E*(r==="brick"?nx:ox)*lx/(jv+Yv),k=Math.ceil(w*jv*sx),z=Math.ceil(w*Yv*cx),A=l==="metric"?E:E*10.7639,U=[{key:r==="brick"?`brick-${n}`:"block",label:r==="brick"?{common:"Common concrete bricks","engineering-red":"Red engineering bricks","engineering-blue":"Blue engineering bricks"}[n]:"Blocks",qty:u,unit:"each",query:r==="brick"?"facing brick":"concrete block",category:"masonry"},...b?[{key:"mortar-cement",label:"General purpose cement",qty:k,unit:"kg",query:"general purpose cement",category:"cement"},{key:"mortar-sand",label:"Building sand",qty:z,unit:"kg",query:"building sand",category:"aggregate"}]:[]],R=H=>{if(H===l)return;let oe=H==="imperial"?3.28084:.3048;m((Qn(p)*oe).toFixed(2)),d((Qn(g)*oe).toFixed(2)),c(H)};return(0,ae.jsx)(ae.Fragment,{children:(0,ae.jsxs)("div",{className:"truss-estimator",children:[(0,ae.jsxs)("div",{className:"quick-order-hero",children:[(0,ae.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,ae.jsx)("h1",{children:"Brick and Block Calculator"}),(0,ae.jsx)("p",{children:"Estimate masonry units, sand and cement for a wall."})]}),(0,ae.jsxs)("div",{className:"truss-estimator__card brick-calculator",children:[(0,ae.jsx)("h2",{className:"truss-estimator__step-title",children:"Wall area and masonry type"}),(0,ae.jsx)("p",{className:"truss-estimator__step-sub",children:"Pick brick or block and enter the wall dimensions for unit counts plus the cement and sand for the mortar."}),(0,ae.jsxs)("div",{className:"brick-calculator__section",children:[(0,ae.jsx)("div",{className:"truss-estimator__section-heading",children:"Masonry type"}),(0,ae.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[["brick","Brick"],["block","Block"]].map(([H,oe])=>(0,ae.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===H?" is-selected":""}`,onClick:()=>i(H),children:[(0,ae.jsx)("div",{className:"truss-estimator__option-title",children:oe}),(0,ae.jsxs)("div",{className:"truss-estimator__option-copy",children:["Approx. ",H==="brick"?Qv:Gv," per m\xB2"]})]},H))})]}),r==="brick"&&(0,ae.jsxs)("div",{className:"brick-calculator__section",children:[(0,ae.jsx)("div",{className:"truss-estimator__section-heading",children:"Brick type"}),(0,ae.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(([H,oe,Te])=>(0,ae.jsxs)("button",{type:"button",className:`truss-estimator__option-card${n===H?" is-selected":""}`,onClick:()=>o(H),children:[(0,ae.jsx)("div",{className:"truss-estimator__option-title",children:oe}),(0,ae.jsx)("div",{className:"truss-estimator__option-copy",children:Te})]},H))})]}),(0,ae.jsxs)("div",{className:"brick-calculator__section",children:[(0,ae.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall dimensions"}),(0,ae.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,ae.jsx)("button",{type:"button",className:l==="metric"?"is-selected":"",onClick:()=>R("metric"),children:"Metric"}),(0,ae.jsx)("button",{type:"button",className:l==="imperial"?"is-selected":"",onClick:()=>R("imperial"),children:"Imperial"})]}),(0,ae.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,ae.jsxs)("label",{className:"truss-estimator__field",children:[(0,ae.jsxs)("span",{children:["Height (",l==="metric"?"m":"ft",")"]}),(0,ae.jsx)("input",{type:"number",min:"0",step:"0.01",value:p,onChange:H=>m(H.target.value)})]}),(0,ae.jsxs)("label",{className:"truss-estimator__field",children:[(0,ae.jsxs)("span",{children:["Width (",l==="metric"?"m":"ft",")"]}),(0,ae.jsx)("input",{type:"number",min:"0",step:"0.01",value:g,onChange:H=>d(H.target.value)})]})]})]}),(0,ae.jsx)("div",{className:"brick-calculator__options",children:(0,ae.jsxs)("label",{className:"brick-calculator__checkbox",children:[(0,ae.jsx)("input",{type:"checkbox",checked:b,onChange:H=>v(H.target.checked)}),(0,ae.jsx)("span",{children:"Include mortar (cement and building sand, mixed 1:4)"})]})}),(0,ae.jsxs)("div",{className:"brick-calculator__totals",children:[(0,ae.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,ae.jsxs)("div",{className:"brick-calculator__result-grid",children:[(0,ae.jsxs)("div",{children:[(0,ae.jsx)("span",{children:"Wall area"}),(0,ae.jsxs)("strong",{children:[ux(A)," ",l==="metric"?"m\xB2":"ft\xB2"]})]}),(0,ae.jsxs)("div",{children:[(0,ae.jsx)("span",{children:r==="brick"?"Bricks":"Blocks"}),(0,ae.jsx)("strong",{children:u.toLocaleString("en-GB")})]}),b?(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)("div",{children:[(0,ae.jsx)("span",{children:"Cement"}),(0,ae.jsxs)("strong",{children:[k," kg"]})]}),(0,ae.jsxs)("div",{children:[(0,ae.jsx)("span",{children:"Building sand"}),(0,ae.jsxs)("strong",{children:[z," kg"]})]})]}):null]}),(0,ae.jsx)("p",{className:"brick-calculator__note",children:"Estimate based on standard nominal sizes and 10mm joints. Mortar is a general purpose 1:4 cement and sand mix; quantities are approximate, so confirm the specification before ordering."})]}),(0,ae.jsxs)("div",{className:"brick-calculator__actions",children:[(0,ae.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,ae.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(U),disabled:E<=0,children:a})]})]})]})})}var Ci=$(He()),W=$(F()),px=1.54,dx=1440,Pd=e=>Number.parseFloat(e)||0,Pr={mot:{label:"MOT Type 1",blurb:"Sub-base for patios and driveways",density:1.7,query:"MOT type 1"},"sharp-sand":{label:"Sharp sand",blurb:"Bedding and general groundwork",density:1.6,query:"sharp sand"},gravel:{label:"20mm gravel",blurb:"Drainage and landscaping",density:1.6,query:"20mm gravel"}};function Jd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Ci.useState)("m"),[n,o]=(0,Ci.useState)(""),[l,c]=(0,Ci.useState)(""),[p,m]=(0,Ci.useState)(""),[g,d]=(0,Ci.useState)("concrete"),[b,v]=(0,Ci.useState)("mot"),E=r==="m"?1:.3048,O=Pd(n)*E*Pd(l)*E*Pd(p)*(r==="m"?.01:.0254),f=Pr[b],u=O*px/7,h=u*dx,w=u*2,k=u*4,z=(U,R)=>Math.ceil(U*R*1e3),A=g==="concrete"?[{key:"cement",label:"General purpose cement",qty:Math.ceil(h),unit:"kg",query:"general purpose cement"},{key:"sharp-sand",label:"Sharp sand",qty:z(w,Pr["sharp-sand"].density),unit:"kg",query:Pr["sharp-sand"].query},{key:"gravel",label:"20mm gravel",qty:z(k,Pr.gravel.density),unit:"kg",query:Pr.gravel.query}]:[{key:b,label:f.label,qty:z(O,f.density),unit:"kg",query:f.query}];return(0,W.jsx)(W.Fragment,{children:(0,W.jsxs)("div",{className:"truss-estimator",children:[(0,W.jsxs)("div",{className:"quick-order-hero",children:[(0,W.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,W.jsx)("h1",{children:"Concrete and Aggregate Calculator"}),(0,W.jsx)("p",{children:"Calculate fixed site-mix concrete ingredients or aggregate bulk bags."})]}),(0,W.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,W.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose what you need"}),(0,W.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter the area and depth. The calculator works out the materials and adds them to your basket."}),(0,W.jsxs)("div",{className:"materials-calculator__section",children:[(0,W.jsx)("div",{className:"truss-estimator__section-heading",children:"Material type"}),(0,W.jsxs)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[(0,W.jsxs)("button",{type:"button",className:`truss-estimator__option-card${g==="concrete"?" is-selected":""}`,onClick:()=>d("concrete"),children:[(0,W.jsx)("div",{className:"truss-estimator__option-title",children:"Site-mixed concrete"}),(0,W.jsx)("div",{className:"truss-estimator__option-copy",children:"Cement, sharp sand and 20mm aggregate"})]}),(0,W.jsxs)("button",{type:"button",className:`truss-estimator__option-card${g==="aggregate"?" is-selected":""}`,onClick:()=>d("aggregate"),children:[(0,W.jsx)("div",{className:"truss-estimator__option-title",children:"Aggregates"}),(0,W.jsx)("div",{className:"truss-estimator__option-copy",children:"MOT Type 1, sharp sand or 20mm gravel"})]})]})]}),g==="aggregate"&&(0,W.jsxs)("div",{className:"materials-calculator__section",children:[(0,W.jsx)("div",{className:"truss-estimator__section-heading",children:"Aggregate type"}),(0,W.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.keys(Pr).map(U=>(0,W.jsxs)("button",{type:"button",className:`truss-estimator__option-card${b===U?" is-selected":""}`,onClick:()=>v(U),children:[(0,W.jsx)("div",{className:"truss-estimator__option-title",children:Pr[U].label}),(0,W.jsx)("div",{className:"truss-estimator__option-copy",children:Pr[U].blurb})]},U))})]}),(0,W.jsxs)("div",{className:"materials-calculator__section",children:[(0,W.jsx)("div",{className:"truss-estimator__section-heading",children:"Area and depth"}),(0,W.jsxs)("div",{className:"materials-calculator__unit-row",children:[(0,W.jsx)("span",{children:"Units"}),(0,W.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,W.jsx)("button",{type:"button",className:r==="m"?"is-selected":"",onClick:()=>i("m"),children:"Metric"}),(0,W.jsx)("button",{type:"button",className:r==="ft"?"is-selected":"",onClick:()=>i("ft"),children:"Imperial"})]})]}),(0,W.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,W.jsxs)("label",{className:"truss-estimator__field",children:[(0,W.jsxs)("span",{children:["Length (",r,")"]}),(0,W.jsx)("input",{type:"number",min:"0",step:"0.01",value:n,onChange:U=>o(U.target.value)})]}),(0,W.jsxs)("label",{className:"truss-estimator__field",children:[(0,W.jsxs)("span",{children:["Width (",r,")"]}),(0,W.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:U=>c(U.target.value)})]})]}),(0,W.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,W.jsxs)("span",{children:["Depth (",r==="m"?"cm":"inches",")"]}),(0,W.jsx)("input",{type:"number",min:"0",step:"0.1",value:p,onChange:U=>m(U.target.value)})]})]}),(0,W.jsxs)("div",{className:"materials-calculator__totals",children:[(0,W.jsx)("div",{className:"truss-estimator__section-heading",children:"Materials required"}),(0,W.jsx)("div",{className:"materials-calculator__result-grid",children:g==="concrete"?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:"Cement"}),(0,W.jsxs)("strong",{children:[h.toFixed(0)," kg"]})]}),(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:"Sharp sand"}),(0,W.jsxs)("strong",{children:[w.toFixed(2)," m\xB3"]})]}),(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:"20mm aggregate"}),(0,W.jsxs)("strong",{children:[k.toFixed(2)," m\xB3"]})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:f.label}),(0,W.jsxs)("strong",{children:[O.toFixed(2)," m\xB3"]})]}),(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:"Approx. weight"}),(0,W.jsxs)("strong",{children:[(O*f.density).toFixed(2)," t"]})]}),(0,W.jsx)("div",{})]})}),(0,W.jsx)("p",{className:"materials-calculator__note",children:g==="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."})]}),(0,W.jsxs)("div",{className:"materials-calculator__actions",children:[(0,W.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,W.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(A),disabled:O<=0,children:a})]})]})]})})}var Ya=$(He());var B=$(F()),Gn=12,jn=8,dc=.56,$v=.21,Ra={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:{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}]}},qi=["range","grid","pictureFrame","substructure"],mx={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:""}},mc=(e,t,a)=>(t.x-e.x)*(a.y-e.y)-(t.y-e.y)*(a.x-e.x),fc=(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),fx=(e,t,a,r)=>{let i=mc(e,t,a),n=mc(e,t,r),o=mc(a,r,e),l=mc(a,r,t);return i===0&&fc(e,t,a)||n===0&&fc(e,t,r)||o===0&&fc(a,r,e)||l===0&&fc(a,r,t)?!0:i>0!=n>0&&o>0!=l>0},Id=(e,t)=>{let a=t?e.length:e.length-1;for(let r=0;r<a;r+=1){let i=e[(r+1)%e.length];for(let n=r+1;n<a;n+=1)if(!(n===r+1||t&&r===0&&n===a-1)&&fx(e[r],i,e[n],e[(n+1)%e.length]))return!0}return!1};function Fd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Ya.useState)(0),[n,o]=(0,Ya.useState)(mx),[l,c]=(0,Ya.useState)(1),[p,m]=(0,Ya.useState)({x:0,y:0}),[g,d]=(0,Ya.useState)(null),b=(0,Ya.useRef)(null),v=(0,Ya.useRef)(null),E=(0,Ya.useRef)(null),O=qi[r],f=n.range?Ra.ranges[n.range]:null,u=Gn/l,h=jn/l,w=(Gn-u)/2,k=(jn-h)/2,z=Math.max(-Gn,Math.min(Gn*2-u,w+p.x)),A=Math.max(-jn,Math.min(jn*2-h,k+p.y)),U=Number.parseFloat(n.quickLengthM),R=Number.parseFloat(n.quickWidthM),H=U>0&&R>0,oe=T=>Math.abs(T.reduce((G,ie,ce)=>{let ve=T[(ce+1)%T.length];return G+ie.x*ve.y-ve.x*ie.y},0))/2,Te=(T,G)=>Math.hypot(G.x-T.x,G.y-T.y),je=n.isOutlineClosed?oe(n.points):0,Ve=n.isOutlineClosed?n.points.reduce((T,G,ie)=>T+Te(G,n.points[(ie+1)%n.points.length]),0):0,Ne=n.isOutlineClosed?n.points.reduce((T,G,ie)=>T+(n.wallSegments.has(ie)?0:Te(G,n.points[(ie+1)%n.points.length])),0):0,we=n.points.reduce((T,G)=>({x:T.x+G.x/n.points.length,y:T.y+G.y/n.points.length}),{x:0,y:0}),le=n.points.length>1?(()=>{let T=n.points[0],G=n.points[1],ie=Te(T,G),ce=ie?-(G.y-T.y)/ie:0,ve=ie?(G.x-T.x)/ie:0,Ye=(T.x+G.x)/2,qe=(T.y+G.y)/2,x=ce*(Ye-we.x)+ve*(qe-we.y)>=0?1:-1;return{x:Ye+ce*dc*x,y:qe+ve*dc*x}})():null,Ee=(()=>{let T=n.range?Ra.ranges[n.range]:Ra.ranges.meridian,G=n.deckSizeMode==="quick"?U*R:je,ie=n.deckSizeMode==="quick"?2*(U+R):Ne,ce=n.direction==="diagonal"?Ra.wastage.diagonal:Ra.wastage.straight,ve=n.pictureFrame==="yes"?Ra.pictureFrame.extraWastage:0,qe=G/(T.boardWidthM+Ra.boardGapM)/T.boardLengthM,x=Math.ceil(qe*(1+ce+ve)),_=Math.ceil(G*30*(1+ce+ve)/200),q=Ra.joist.spacingOptions.find(N=>N.id===n.joistSpacing)??Ra.joist.spacingOptions[1],D=G/q.spacingM,V=Math.ceil(D);return{range:T,area:G,boardCount:x,screwBoxes:_,joistMetres:V,spacing:q}})(),Nt=Ee?[{key:`boards-${n.range??"meridian"}`,label:`Deck boards (${Ee.range.label})`,qty:Math.round(Ee.boardCount*Ee.range.boardLengthM*100)/100,unit:"m",query:"timber decking board",category:"decking",calculatorWasteIncluded:!0},{key:"joists",label:"Treated C24 joists",qty:Ee.joistMetres,unit:"m",query:"treated joist",category:"timber",calculatorWasteIncluded:!0},{key:"screws",label:"Green decking screws (200/box)",qty:Ee.screwBoxes,unit:"box",query:"green decking screws",category:"fixings",calculatorWasteIncluded:!0}]:[],Z=()=>O==="range"?!!n.range:O==="grid"?n.deckSizeMode==="quick"?H:n.isOutlineClosed&&je>0:O==="pictureFrame"?!!n.pictureFrame&&!!n.direction:O==="substructure"?!!n.joistSpacing:!0,ge=r===qi.length-1?a:"Next",Re=(T,G,ie=!1)=>{let ce=E.current?.getBoundingClientRect();if(!ce)return null;let ve=ie?1:.25;return{x:Math.round(Math.max(z,Math.min(z+u,z+(T-ce.left)/ce.width*u))/ve)*ve,y:Math.round(Math.max(A,Math.min(A+h,A+(G-ce.top)/ce.height*h))/ve)*ve}},bt=T=>{if(n.isOutlineClosed){let ie=T.target;if(ie!==T.currentTarget&&!ie.classList.contains("deck-outline__grid"))return;v.current={startX:T.clientX,startY:T.clientY,startViewX:z,startViewY:A},T.currentTarget.setPointerCapture(T.pointerId);return}if(n.drawMode!=="outline")return;let G=Re(T.clientX,T.clientY,!0);G&&(d(null),o(ie=>{let ce=[...ie.points,G];return Id(ce,!1)?{...ie,drawError:"Edges cannot cross. Choose another corner."}:{...ie,points:ce,drawError:""}}))},jt=(T,G)=>{if(!n.isOutlineClosed){T.stopPropagation(),G===0&&n.points.length>=3&&o(ie=>({...ie,isOutlineClosed:!0,drawMode:"edges"}));return}T.stopPropagation(),b.current=G,T.currentTarget.setPointerCapture(T.pointerId)},Ct=T=>{if(v.current){let ce=E.current?.getBoundingClientRect();if(!ce)return;let ve=v.current,Ye=ve.startViewX-(T.clientX-ve.startX)/ce.width*u,qe=ve.startViewY-(T.clientY-ve.startY)/ce.height*h;m({x:Ye-w,y:qe-k});return}!n.isOutlineClosed&&n.drawMode==="outline"&&d(Re(T.clientX,T.clientY,!0));let G=b.current;if(G===null)return;let ie=Re(T.clientX,T.clientY);ie&&o(ce=>{let ve=ce.points.map((Ye,qe)=>qe===G?ie:Ye);return Id(ve,!0)?{...ce,drawError:"Edges cannot cross. Move the corner to a different position."}:{...ce,points:ve,drawError:""}})},wt=T=>{v.current=null,b.current=null,T.currentTarget.hasPointerCapture(T.pointerId)&&T.currentTarget.releasePointerCapture(T.pointerId)},be=T=>{o(G=>{let ie=new Set(G.wallSegments);return ie.has(T)?ie.delete(T):ie.add(T),{...G,wallSegments:ie}})},de=()=>{r===0?e():i(T=>T-1)},tt=()=>{Z()&&(r===qi.length-1?t?.(Nt):i(T=>T+1))};return(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)("div",{className:"truss-estimator",children:[(0,B.jsxs)("div",{className:"quick-order-hero",children:[(0,B.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,B.jsx)("h1",{children:"Decking Calculator"}),(0,B.jsx)("p",{children:"Estimate timber boards, joists and screws for your deck."})]}),(0,B.jsxs)("div",{className:"truss-estimator__card",children:[(0,B.jsxs)("div",{className:"truss-estimator__body",children:[O==="range"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",qi.length]}),(0,B.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your timber decking"}),(0,B.jsx)("p",{className:"truss-estimator__step-sub",children:"Both options are fixed, orderable pressure-treated timber boards."}),(0,B.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Ra.ranges).filter(([T])=>ki("decking",`boards-${T}`)).map(([T,G])=>(0,B.jsxs)("button",{type:"button",className:`truss-estimator__option-card${n.range===T?" is-selected":""}`,onClick:()=>o(ie=>({...ie,range:T})),children:[(0,B.jsx)("div",{className:"truss-estimator__option-title",children:G.label}),(0,B.jsx)("div",{className:"truss-estimator__option-copy",children:G.blurb}),(0,B.jsxs)("div",{className:"truss-estimator__option-copy",children:[G.boardLengthM,"m boards"]})]},T))})]}):null,O==="grid"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",qi.length]}),(0,B.jsx)("h2",{className:"truss-estimator__step-title",children:"Tell us your deck size"}),(0,B.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,B.jsxs)("div",{className:"truss-estimator__toggle-row",children:[(0,B.jsx)("button",{type:"button",className:`truss-estimator__toggle${n.deckSizeMode==="quick"?" is-selected":""}`,onClick:()=>o(T=>({...T,deckSizeMode:"quick"})),children:"Quick estimate"}),(0,B.jsx)("button",{type:"button",className:`truss-estimator__toggle${n.deckSizeMode==="draw"?" is-selected":""}`,onClick:()=>o(T=>({...T,deckSizeMode:"draw",drawMode:"outline"})),children:"Draw your space"})]}),n.deckSizeMode==="quick"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,B.jsxs)("label",{className:"truss-estimator__field",children:[(0,B.jsx)("span",{children:"Length (m)"}),(0,B.jsx)("input",{type:"number",inputMode:"decimal",min:"0.1",step:"0.1",value:n.quickLengthM,onChange:T=>o(G=>({...G,quickLengthM:T.target.value}))})]}),(0,B.jsxs)("label",{className:"truss-estimator__field",children:[(0,B.jsx)("span",{children:"Width (m)"}),(0,B.jsx)("input",{type:"number",inputMode:"decimal",min:"0.1",step:"0.1",value:n.quickWidthM,onChange:T=>o(G=>({...G,quickWidthM:T.target.value}))})]})]}),(0,B.jsx)("div",{className:"truss-estimator__grid-hint",children:"For L-shaped decks, cut-outs, or sides against a wall, use Draw your space."}),H?(0,B.jsxs)("div",{className:"truss-estimator__grid-stats",children:[(0,B.jsxs)("div",{children:[(U*R).toFixed(2)," m\xB2 deck"]}),(0,B.jsxs)("div",{children:[(2*(U+R)).toFixed(2)," m perimeter"]})]}):null]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"truss-estimator__section-heading",children:"Draw your deck"}),(0,B.jsx)("p",{className:"truss-estimator__step-sub",children:"Click to add corners, then close the outline. Drag any handle to refine it."}),(0,B.jsxs)("div",{className:"deck-outline__toolbar",children:[n.isOutlineClosed?(0,B.jsxs)("div",{className:"deck-outline__summary",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{children:"Deck area"}),(0,B.jsxs)("strong",{children:[je.toFixed(2)," m\xB2"]})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{children:"Perimeter"}),(0,B.jsxs)("strong",{children:[Ve.toFixed(2)," m"]})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{children:"Wall edges"}),(0,B.jsx)("strong",{children:n.wallSegments.size>0?n.wallSegments.size:"None"})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{children:"Visible edge"}),(0,B.jsxs)("strong",{children:[Ne.toFixed(2)," m"]})]})]}):null,(0,B.jsxs)("div",{className:"deck-outline__actions",children:[(0,B.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(T=>({...T,points:T.points.slice(0,-1)})),disabled:n.points.length===0||n.isOutlineClosed,children:"Undo"}),(0,B.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>{d(null),o(T=>({...T,points:[],isOutlineClosed:!1,wallSegments:new Set,drawMode:"outline",drawError:""}))},disabled:n.points.length===0,children:"Clear"}),(0,B.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(T=>({...T,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,B.jsx)("div",{className:"deck-editor-layout",children:(0,B.jsxs)("div",{className:"deck-editor-layout__canvas-column",children:[(0,B.jsxs)("div",{className:"deck-outline",children:[(0,B.jsxs)("svg",{ref:E,className:`deck-outline__canvas${n.isOutlineClosed?" is-pan-mode":""}`,viewBox:`${z} ${A} ${u} ${h}`,preserveAspectRatio:"none","aria-label":"Deck outline drawing area",onPointerDown:bt,onPointerMove:Ct,onPointerUp:wt,onPointerLeave:()=>{d(null),v.current||(b.current=null)},children:[(0,B.jsx)("defs",{children:(0,B.jsx)("pattern",{id:"deck-outline-grid",width:"1",height:"1",patternUnits:"userSpaceOnUse",children:(0,B.jsx)("path",{d:"M 1 0 L 0 0 0 1",fill:"none",stroke:"currentColor",strokeWidth:"0.03"})})}),(0,B.jsx)("rect",{x:-Gn,y:-jn,width:Gn*3,height:jn*3,className:"deck-outline__grid",fill:"url(#deck-outline-grid)"}),n.points.length>1?(0,B.jsx)("polyline",{className:"deck-outline__preview",points:n.points.map(T=>`${T.x},${T.y}`).join(" ")}):null,n.isOutlineClosed?(0,B.jsx)("polygon",{className:"deck-outline__shape",points:n.points.map(T=>`${T.x},${T.y}`).join(" "),stroke:"none"}):null,n.points.length>1?n.points.slice(0,n.isOutlineClosed?void 0:-1).map((T,G)=>{let ie=n.points[n.isOutlineClosed?(G+1)%n.points.length:G+1],ce=Te(T,ie),ve=ce?-(ie.y-T.y)/ce:0,Ye=ce?(ie.x-T.x)/ce:0,qe=(T.x+ie.x)/2,x=(T.y+ie.y)/2,_=ve*(qe-we.x)+Ye*(x-we.y)>=0?1:-1,q=qe+ve*dc*_,D=x+Ye*dc*_;return(0,B.jsxs)("g",{children:[(0,B.jsx)("line",{className:"deck-outline__edge-hit",x1:T.x,y1:T.y,x2:ie.x,y2:ie.y,onClick:n.isOutlineClosed?()=>be(G):void 0}),(0,B.jsx)("line",{className:`deck-outline__edge${n.wallSegments.has(G)?" is-wall":""}`,x1:T.x,y1:T.y,x2:ie.x,y2:ie.y,pointerEvents:"none"}),(0,B.jsxs)("text",{className:`deck-outline__edge-label${n.wallSegments.has(G)?" is-wall":""}`,x:q,y:D,textAnchor:"middle",dominantBaseline:"central",fontSize:$v/l,children:[ce.toFixed(2)," m"]})]},`segment-${G}`)}):null,!n.isOutlineClosed&&n.points.length>0&&g?(()=>{let T=n.points[n.points.length-1],G=Te(T,g);if(!G)return null;let ie=-(g.y-T.y)/G,ce=(g.x-T.x)/G,ve=(T.x+g.x)/2,Ye=(T.y+g.y)/2;return(0,B.jsxs)("g",{className:"deck-outline__live-measurement",children:[(0,B.jsx)("line",{x1:T.x,y1:T.y,x2:g.x,y2:g.y}),(0,B.jsxs)("text",{x:ve+ie*.34,y:Ye+ce*.34,textAnchor:"middle",dominantBaseline:"central",fontSize:$v/l,children:[G.toFixed(2)," m"]})]})})():null,n.points.map((T,G)=>(0,B.jsx)("circle",{className:"deck-outline__point",cx:T.x,cy:T.y,r:"0.13",onPointerDown:ie=>jt(ie,G)},`point-${G}`))]}),(0,B.jsxs)("div",{className:"deck-outline__zoom","aria-label":"Zoom controls",children:[(0,B.jsx)("button",{type:"button",onClick:()=>c(T=>Math.max(.5,T-.25)),disabled:l===.5,"aria-label":"Zoom out",children:"\u2212"}),(0,B.jsxs)("span",{children:[Math.round(l*100),"%"]}),(0,B.jsx)("button",{type:"button",onClick:()=>c(T=>Math.min(1,T+.25)),disabled:l===1,"aria-label":"Zoom in",children:"+"})]}),n.isOutlineClosed&&n.wallSegments.size===0&&le?(0,B.jsx)("div",{className:"deck-outline__edge-prompt",role:"status",style:{left:`${(le.x-z)/u*100}%`,top:`${(le.y-A)/h*100}%`},children:"Tap an edge to mark it as a wall, or leave it as a visible edge."}):null,!n.isOutlineClosed&&n.points.length>=3?(0,B.jsx)("button",{type:"button",className:"deck-outline__close",onClick:()=>o(T=>Id(T.points,!0)?{...T,drawError:"Edges cannot cross. Adjust the outline before finishing."}:{...T,isOutlineClosed:!0,drawMode:"edges",drawError:""}),children:"Finish outline"}):null]}),(0,B.jsxs)("div",{className:"deck-outline__supporting",children:[(0,B.jsx)("div",{className:"truss-estimator__grid-hint",children:n.isOutlineClosed?"Drag a corner handle to refine the outline.":"Add at least three corners, then click Finish outline."}),n.drawError?(0,B.jsx)("div",{className:"deck-outline__error",role:"alert",children:n.drawError}):null]})]})})]})]}):null,O==="pictureFrame"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",qi.length]}),(0,B.jsx)("h2",{className:"truss-estimator__step-title",children:"Picture frame border?"}),(0,B.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,B.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(T=>(0,B.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${n.pictureFrame===T.id?" is-selected":""}`,onClick:()=>o(G=>({...G,pictureFrame:T.id})),children:[(0,B.jsx)("img",{className:"truss-estimator__visual-card-img",src:It(T.img),alt:""}),(0,B.jsx)("span",{children:T.label})]},T.id))}),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"truss-estimator__section-heading",children:"Board direction"}),(0,B.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(T=>(0,B.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${n.direction===T.id?" is-selected":""}`,onClick:()=>o(G=>({...G,direction:T.id})),children:[(0,B.jsx)("img",{className:"truss-estimator__visual-card-img",src:It(T.img),alt:""}),(0,B.jsx)("span",{children:T.label})]},T.id))})]})]}):null,O==="substructure"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",qi.length]}),(0,B.jsx)("h2",{className:"truss-estimator__step-title",children:"Substructure"}),(0,B.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,B.jsx)("div",{className:"truss-estimator__section-heading",children:"Joist spacing"}),(0,B.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Ra.joist.spacingOptions.map(T=>(0,B.jsx)("button",{type:"button",className:`truss-estimator__option-card${n.joistSpacing===T.id?" is-selected":""}`,onClick:()=>o(G=>({...G,joistSpacing:T.id})),children:(0,B.jsx)("div",{className:"truss-estimator__option-title",children:T.label})},T.id))})]}):null]}),(0,B.jsxs)("div",{className:"truss-estimator__nav",children:[(0,B.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:de,children:"Back"}),(0,B.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:tt,disabled:!Z(),children:[(0,B.jsx)("span",{children:ge}),(0,B.jsx)("span",{className:"arrow",children:(0,B.jsx)(Qt,{})})]})]})]})]})})}var Na=$(He());var Y=$(F()),Vv=12,Xv=30,Yn=12,$n=8,Zv=.56,Sa={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 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}}},Ei=["range","height","gate","posts"],Wd=e=>Number(e)<=1.2?"6":"8",Kv=(e,t)=>ki("fencing",`panels-${e??"boundary"}-${t}`),Pv=(e,t)=>!t||ki("fencing",e==="concrete"?`concrete-intermediate-${Wd(t)}`:`timber-post-${Wd(t)}`),hx={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:""}},hc=(e,t,a)=>(t.x-e.x)*(a.y-e.y)-(t.y-e.y)*(a.x-e.x),gc=(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),gx=(e,t,a,r)=>{let i=hc(e,t,a),n=hc(e,t,r),o=hc(a,r,e),l=hc(a,r,t);return i===0&&gc(e,t,a)||n===0&&gc(e,t,r)||o===0&&gc(a,r,e)||l===0&&gc(a,r,t)?!0:i>0!=n>0&&o>0!=l>0},bc=(e,t)=>{let a=t?e.length:e.length-1;for(let r=0;r<a;r+=1)for(let i=r+1;i<a;i+=1)if(!(i===r+1||t&&r===0&&i===a-1)&&gx(e[r],e[(r+1)%e.length],e[i],e[(i+1)%e.length]))return!0;return!1};function em({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Na.useState)(0),[n,o]=(0,Na.useState)(hx),l=(0,Na.useRef)(null),c=(0,Na.useRef)(null),[p,m]=(0,Na.useState)(1),[g,d]=(0,Na.useState)({x:0,y:0}),[b,v]=(0,Na.useState)(null),E=(0,Na.useRef)(null),O=(0,Na.useRef)(null),f=(0,Na.useRef)(null),u=Ei[r],h=n.range?Sa.ranges[n.range]:null,w=Yn/p,k=$n/p,z=(Yn-w)/2,A=($n-k)/2,U=Math.max(-Yn,Math.min(Yn*2-w,z+g.x)),R=Math.max(-$n,Math.min($n*2-k,A+g.y)),H=n.boundaryPoints.reduce((x,_)=>({x:x.x+_.x/Math.max(1,n.boundaryPoints.length),y:x.y+_.y/Math.max(1,n.boundaryPoints.length)}),{x:0,y:0}),oe=x=>{let _=new Set,q=[];return x.forEach(D=>{let[V,N]=D.split(",").map(Number),L=[{key:`H,${V},${N}`,type:"H",x:V,y:N},{key:`H,${V},${N+1}`,type:"H",x:V,y:N+1},{key:`V,${V},${N}`,type:"V",x:V,y:N},{key:`V,${V+1},${N}`,type:"V",x:V+1,y:N}],X=[!x.has(`${V},${N-1}`),!x.has(`${V},${N+1}`),!x.has(`${V-1},${N}`),!x.has(`${V+1},${N}`)];L.forEach((ue,ke)=>{X[ke]&&!_.has(ue.key)&&(_.add(ue.key),q.push(ue))})}),q},Te=(x,_)=>oe(x).filter(q=>!_.has(q.key)),je=(x,_)=>Te(x,_).length,Ve=(x,_)=>{let q={};Te(x,_).forEach(V=>{var N,L,X,ue;V.type==="H"?((q[N=`${V.x},${V.y}`]||(q[N]=[])).push("H"),(q[L=`${V.x+1},${V.y}`]||(q[L]=[])).push("H")):((q[X=`${V.x},${V.y}`]||(q[X]=[])).push("V"),(q[ue=`${V.x},${V.y+1}`]||(q[ue]=[])).push("V"))});let D=0;return Object.values(q).forEach(V=>{(V.length===1||V.length===2&&V[0]!==V[1]||V.length>=3)&&(D+=1)}),D},we=(()=>{let x=n.range?Sa.ranges[n.range]:Sa.ranges.boundary,_=n.height??"1.8",q=n.boundaryMode==="quick"?Math.max(0,Number.parseFloat(n.quickLengthM)||0):n.boundaryClosed?n.boundaryPoints.slice(0,-1).reduce((Yt,hr,yt)=>Yt+(n.excludedBoundaryEdges.has(yt)?0:Math.hypot(n.boundaryPoints[yt+1].x-hr.x,n.boundaryPoints[yt+1].y-hr.y)),0):0,D=n.gateType&&n.gateType!=="none"?Number.parseFloat(n.gateWidthM)||Sa.gate[n.gateType].widthDefault:0,V=Math.max(0,q-D),N=V>0?Math.ceil(V/x.panelWidthM):0,L=n.boundaryPoints.length>2&&n.boundaryPoints[0].x===n.boundaryPoints[n.boundaryPoints.length-1].x&&n.boundaryPoints[0].y===n.boundaryPoints[n.boundaryPoints.length-1].y,X=n.boundaryMode==="quick"?V>0?2:0:n.boundaryClosed?n.boundaryPoints.slice(0,L?-1:void 0).reduce((Yt,hr,yt)=>{let Zn=yt>0&&!n.excludedBoundaryEdges.has(yt-1),wm=yt<n.boundaryPoints.length-1&&!n.excludedBoundaryEdges.has(yt);return Yt+(Zn||wm?1:0)},0):0,ue=V>0?Math.ceil(V/x.panelWidthM)+1:0,ke=Math.max(0,ue-X),vt=n.mountingType?Sa.mounting[n.mountingType]:Sa.mounting.concrete,mt=n.gateType&&n.gateType!=="none"?2:0,Ut=ke+X+mt,bm=n.mountingType==="postcrete"?Ut*Sa.mounting.postcrete.bagsPerPost:0,Jr=n.gravelBoard==="yes"?N:0;return{range:x,height:_,totalEdgeM:q,fencedLengthM:V,gateWidthM:D,panelsCount:N,cornerPostCount:X,intermediatePostCount:ke,gatePostCount:mt,totalPostCount:Ut,bagsCount:bm,gravelCount:Jr,capCount:Ut,mounting:vt}})(),le=n.gateType&&n.gateType!=="none"?Sa.gate[n.gateType].label:null,Fe=Wd(we.height),Ee=we?[{key:`panels-${n.range??"boundary"}-${we.height}`,label:`${we.range.label} panels (${we.height}m)`,qty:we.panelsCount,unit:"each",query:"fence panel",category:"fencing"},...n.mountingType==="concrete"?[{key:`concrete-intermediate-${Fe}`,label:"Intermediate concrete posts",qty:we.intermediatePostCount,unit:"each",query:"concrete fence post",category:"fencing"},{key:`concrete-end-${Fe}`,label:"End and corner concrete posts",qty:we.cornerPostCount+we.gatePostCount,unit:"each",query:"concrete end post",category:"fencing"}]:[{key:`timber-post-${Fe}`,label:"Timber fence posts",qty:we.totalPostCount,unit:"each",query:"timber fence post",category:"fencing"},{key:"postcrete",label:"Postcrete",qty:we.bagsCount,unit:"bag",query:"postcrete",category:"cement"}],...le?[{key:`gate-${n.range??"boundary"}`,label:n.range==="skyline"?"Single feather edge gate":"Single lap gate",qty:1,unit:"each",query:n.range==="skyline"?"feather edge gate":"lap gate",category:"fencing"}]:[],...we.gravelCount>0?[{key:"gravel-boards",label:"Concrete gravel boards",qty:we.gravelCount,unit:"each",query:"gravel board",category:"fencing"}]:[]]:[],Nt=()=>{if(u==="range"){let x=n.boundaryMode==="quick"?(Number.parseFloat(n.quickLengthM)||0)>0:n.boundaryClosed&&n.boundaryPoints.length>=2;return!!n.range&&x}return u==="height"?!!n.height&&!!n.gravelBoard:u==="gate"?!!n.gateType&&(n.gateType==="none"||n.gateWidthM.trim()!==""):u==="posts"?!!n.mountingType:!0},Z=r===Ei.length-1?a:"Next",ge=x=>{o(_=>{let q=x(new Set(_.grid)),D=new Set([..._.excludedEdges].filter(V=>oe(q).some(N=>N.key===V)));return{..._,grid:q,excludedEdges:D}})},Re=(x,_,q)=>{ge(D=>{let V=`${x},${_}`;return q?D.add(V):D.delete(V),D})},bt=(x,_,q,D,V)=>{let N=x,L=_,X=Math.abs(q-x),ue=x<q?1:-1,ke=-Math.abs(D-_),vt=_<D?1:-1,mt=X+ke;for(;Re(N,L,V),!(N===q&&L===D);){let Ut=2*mt;Ut>=ke&&(mt+=ke,N+=ue),Ut<=X&&(mt+=X,L+=vt)}},jt=(x,_)=>{let q=c.current?.getBoundingClientRect();if(!q)return null;let D=Math.floor((x-q.left)/Xv),V=Math.floor((_-q.top)/Xv);return D<0||V<0||D>=Vv||V>=Vv?null:{x:D,y:V}},Ct=x=>{if(n.gridMode!=="draw")return;let _=jt(x.clientX,x.clientY);if(!_)return;x.preventDefault();let q=`${_.x},${_.y}`,D=!n.grid.has(q);l.current={active:!0,paintValue:D,lastX:_.x,lastY:_.y},x.currentTarget.setPointerCapture(x.pointerId),Re(_.x,_.y,D)},wt=x=>{let _=l.current;if(!_?.active)return;let q=jt(x.clientX,x.clientY);q&&(q.x===_.lastX&&q.y===_.lastY||(bt(_.lastX,_.lastY,q.x,q.y,_.paintValue),l.current={..._,lastX:q.x,lastY:q.y}))},be=x=>{l.current?.active&&(l.current=null,x.currentTarget.releasePointerCapture(x.pointerId))},de=(x,_,q=!1)=>{let D=f.current?.getBoundingClientRect();if(!D)return null;let V=q?1:.25;return{x:Math.round(Math.max(U,Math.min(U+w,U+(x-D.left)/D.width*w))/V)*V,y:Math.round(Math.max(R,Math.min(R+k,R+(_-D.top)/D.height*k))/V)*V}},tt=x=>{if(n.boundaryClosed){let q=x.target;if(q!==x.currentTarget&&!q.classList.contains("fence-boundary__grid"))return;O.current={startX:x.clientX,startY:x.clientY,startViewX:U,startViewY:R},x.currentTarget.setPointerCapture(x.pointerId);return}let _=de(x.clientX,x.clientY,!0);_&&(v(null),o(q=>{let D=[...q.boundaryPoints,_];return bc(D,!1)?{...q}:{...q,boundaryPoints:D}}))},T=(x,_)=>{if(x.stopPropagation(),!n.boundaryClosed){if(_!==0||n.boundaryPoints.length<3)return;o(q=>bc(q.boundaryPoints,!0)?q:{...q,boundaryPoints:[...q.boundaryPoints,q.boundaryPoints[0]],boundaryClosed:!0});return}E.current=_,x.currentTarget.setPointerCapture(x.pointerId)},G=x=>{if(O.current){let q=f.current?.getBoundingClientRect();if(!q)return;let D=O.current,V=D.startViewX-(x.clientX-D.startX)/q.width*w,N=D.startViewY-(x.clientY-D.startY)/q.height*k;d({x:V-z,y:N-A});return}if(n.boundaryClosed||v(de(x.clientX,x.clientY,!0)),E.current===null)return;let _=de(x.clientX,x.clientY);_&&o(q=>{let D=q.boundaryPoints.length>2&&q.boundaryPoints[0].x===q.boundaryPoints[q.boundaryPoints.length-1].x&&q.boundaryPoints[0].y===q.boundaryPoints[q.boundaryPoints.length-1].y,V=q.boundaryPoints.map((N,L)=>{let X=L===E.current,ue=D&&E.current===0&&L===q.boundaryPoints.length-1;return X||ue?_:N});return bc(V,!1)?q:{...q,boundaryPoints:V}})},ie=x=>{O.current=null,E.current=null,x.currentTarget.hasPointerCapture(x.pointerId)&&x.currentTarget.releasePointerCapture(x.pointerId)},ce=x=>{o(_=>{let q=new Set(_.excludedBoundaryEdges);return q.has(x)?q.delete(x):q.add(x),{..._,excludedBoundaryEdges:q}})},ve=()=>{r===0?e():i(x=>x-1)},Ye=()=>{Nt()&&(r===Ei.length-1?t?.(Ee):i(x=>x+1))},qe=oe(n.grid);return(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:"Fencing Calculator"}),(0,Y.jsx)("p",{children:"Estimate panels, posts and cost for your fence line in a few steps."})]}),(0,Y.jsxs)("div",{className:"truss-estimator__card",children:[(0,Y.jsxs)("div",{className:"truss-estimator__body",children:[u==="range"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ei.length]}),(0,Y.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your fence panels"}),(0,Y.jsx)("p",{className:"truss-estimator__step-sub",children:"The calculator uses fixed, orderable timber panels from the catalogue."}),(0,Y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Sa.ranges).map(([x,_])=>(0,Y.jsxs)("button",{type:"button",className:`truss-estimator__option-card${n.range===x?" is-selected":""}`,onClick:()=>o(q=>({...q,range:x,height:q.height&&Kv(x,q.height)?q.height:null})),children:[(0,Y.jsx)("div",{className:"truss-estimator__option-title",children:_.label}),(0,Y.jsx)("div",{className:"truss-estimator__option-copy",children:_.blurb})]},x))})]}):null,u==="range"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{className:"truss-estimator__section-heading",children:"Measure your fence line"}),(0,Y.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,Y.jsxs)("div",{className:"truss-estimator__toggle-row",children:[(0,Y.jsx)("button",{type:"button",className:`truss-estimator__toggle${n.boundaryMode==="quick"?" is-selected":""}`,onClick:()=>o(x=>({...x,boundaryMode:"quick"})),children:"Quick estimate"}),(0,Y.jsx)("button",{type:"button",className:`truss-estimator__toggle${n.boundaryMode==="draw"?" is-selected":""}`,onClick:()=>o(x=>({...x,boundaryMode:"draw"})),children:"Draw your boundary"})]}),n.boundaryMode==="quick"?(0,Y.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact fence-boundary__quick-field",children:[(0,Y.jsx)("span",{children:"Total fence length (m)"}),(0,Y.jsx)("input",{type:"number",min:"0",step:"0.1",value:n.quickLengthM,onChange:x=>o(_=>({..._,quickLengthM:x.target.value}))})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{className:"fence-boundary__toolbar",children:(0,Y.jsxs)("div",{className:"fence-boundary__actions",children:[(0,Y.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(x=>({...x,boundaryPoints:x.boundaryPoints.slice(0,-1),boundaryClosed:!1,excludedBoundaryEdges:new Set})),disabled:n.boundaryPoints.length===0||n.boundaryClosed,children:"Undo"}),(0,Y.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>{d({x:0,y:0}),v(null),o(x=>({...x,boundaryPoints:[],boundaryClosed:!1,excludedBoundaryEdges:new Set}))},disabled:n.boundaryPoints.length===0,children:"Clear"}),(0,Y.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(x=>({...x,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,Y.jsxs)("div",{className:"fence-boundary",children:[(0,Y.jsxs)("svg",{ref:f,className:`fence-boundary__canvas${n.boundaryClosed?" is-pan-mode":""}`,viewBox:`${U} ${R} ${w} ${k}`,preserveAspectRatio:"none","aria-label":"Fence boundary drawing area",onPointerDown:tt,onPointerMove:G,onPointerUp:ie,onPointerLeave:()=>{v(null),O.current||(E.current=null)},children:[(0,Y.jsx)("defs",{children:(0,Y.jsx)("pattern",{id:"fence-boundary-grid",width:"1",height:"1",patternUnits:"userSpaceOnUse",children:(0,Y.jsx)("path",{d:"M 1 0 L 0 0 0 1",fill:"none",stroke:"currentColor",strokeWidth:"0.03"})})}),(0,Y.jsx)("rect",{x:-Yn,y:-$n,width:Yn*3,height:$n*3,className:"fence-boundary__grid",fill:"url(#fence-boundary-grid)"}),n.boundaryPoints.length>1?(0,Y.jsx)("polyline",{className:"fence-boundary__preview",points:n.boundaryPoints.map(x=>`${x.x},${x.y}`).join(" ")}):null,n.boundaryPoints.length>1?n.boundaryPoints.slice(0,-1).map((x,_)=>{let q=n.boundaryPoints[_+1],D=Math.hypot(q.x-x.x,q.y-x.y),V=D?-(q.y-x.y)/D:0,N=D?(q.x-x.x)/D:0,L=(x.x+q.x)/2,X=(x.y+q.y)/2,ue=V*(L-H.x)+N*(X-H.y)>=0?1:-1,ke=L+V*Zv*ue,vt=X+N*Zv*ue;return(0,Y.jsxs)("g",{children:[(0,Y.jsx)("line",{className:"fence-boundary__edge-hit",x1:x.x,y1:x.y,x2:q.x,y2:q.y,onClick:n.boundaryClosed?()=>ce(_):void 0}),(0,Y.jsx)("line",{className:`fence-boundary__edge${n.excludedBoundaryEdges.has(_)?" is-excluded":""}`,x1:x.x,y1:x.y,x2:q.x,y2:q.y,pointerEvents:"none"}),(0,Y.jsxs)("text",{className:`fence-boundary__edge-label${n.excludedBoundaryEdges.has(_)?" is-excluded":""}`,x:ke,y:vt,textAnchor:"middle",dominantBaseline:"central",fontSize:.21/p,children:[D.toFixed(2)," m"]})]},`fence-edge-${_}`)}):null,!n.boundaryClosed&&n.boundaryPoints.length>0&&b?(()=>{let x=n.boundaryPoints[n.boundaryPoints.length-1],_=Math.hypot(b.x-x.x,b.y-x.y);if(!_)return null;let q=-(b.y-x.y)/_,D=(b.x-x.x)/_,V=(x.x+b.x)/2,N=(x.y+b.y)/2;return(0,Y.jsxs)("g",{className:"fence-boundary__live-measurement",children:[(0,Y.jsx)("line",{x1:x.x,y1:x.y,x2:b.x,y2:b.y}),(0,Y.jsxs)("text",{x:V+q*.34,y:N+D*.34,textAnchor:"middle",dominantBaseline:"central",fontSize:.21/p,children:[_.toFixed(2)," m"]})]})})():null,n.boundaryPoints.map((x,_)=>_>0&&_===n.boundaryPoints.length-1&&x.x===n.boundaryPoints[0]?.x&&x.y===n.boundaryPoints[0]?.y?null:(0,Y.jsx)("circle",{className:`fence-boundary__point${!n.boundaryClosed&&_===0&&n.boundaryPoints.length>=3?" is-close-target":""}`,cx:x.x,cy:x.y,r:"0.13",onPointerDown:q=>T(q,_)},`fence-point-${_}`))]}),(0,Y.jsxs)("div",{className:"fence-boundary__zoom","aria-label":"Zoom controls",children:[(0,Y.jsx)("button",{type:"button",onClick:()=>m(x=>Math.max(.5,x-.25)),disabled:p===.5,"aria-label":"Zoom out",children:"\u2212"}),(0,Y.jsxs)("span",{children:[Math.round(p*100),"%"]}),(0,Y.jsx)("button",{type:"button",onClick:()=>m(x=>Math.min(1,x+.25)),disabled:p===1,"aria-label":"Zoom in",children:"+"})]}),!n.boundaryClosed&&n.boundaryPoints.length>=2?(0,Y.jsx)("button",{type:"button",className:"fence-boundary__close",onClick:()=>o(x=>bc(x.boundaryPoints,!1)?x:{...x,boundaryClosed:!0}),children:"Finish fence line"}):null]}),(0,Y.jsx)("div",{className:"truss-estimator__grid-hint",children:n.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,Y.jsxs)("div",{className:"truss-estimator__grid-stats",children:[(0,Y.jsx)("div",{children:n.boundaryMode==="quick"?`${(Number.parseFloat(n.quickLengthM)||0).toFixed(2)} m fence line`:`${we.totalEdgeM.toFixed(2)} m fence line`}),n.boundaryMode==="draw"&&n.boundaryClosed?(0,Y.jsxs)("div",{children:[we.cornerPostCount," corner/end posts"]}):null]})]}):null,null,u==="height"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ei.length]}),(0,Y.jsx)("h2",{className:"truss-estimator__step-title",children:"Fence height"}),(0,Y.jsx)("p",{className:"truss-estimator__step-sub",children:"Select the nearest available panel height."}),(0,Y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--pitch",children:Sa.heights.filter(x=>Kv(n.range,x)).map(x=>(0,Y.jsx)("button",{type:"button",className:`truss-estimator__visual-card${n.height===x?" is-selected":""}`,onClick:()=>o(_=>({..._,height:x,mountingType:_.mountingType&&Pv(_.mountingType,x)?_.mountingType:null})),children:(0,Y.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--tall",src:It(`/fencing/height/${x}.webp`),alt:""})},x))}),(0,Y.jsx)("div",{className:"truss-estimator__section-heading",children:"Gravel board?"}),(0,Y.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(x=>(0,Y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${n.gravelBoard===x.id?" is-selected":""}`,onClick:()=>o(_=>({..._,gravelBoard:x.id})),children:[(0,Y.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--mid",src:It(x.img),alt:""}),(0,Y.jsx)("span",{children:x.label})]},x.id))})]}):null,u==="gate"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ei.length]}),(0,Y.jsx)("h2",{className:"truss-estimator__step-title",children:"Do you need a gate?"}),(0,Y.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,Y.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(x=>(0,Y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card${n.gateType===x.id?" is-selected":""}`,onClick:()=>o(_=>({..._,gateType:x.id,gateWidthM:x.id==="none"?"":String(Sa.gate[x.id].widthDefault)})),children:[(0,Y.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--mid",src:It(x.img),alt:""}),(0,Y.jsx)("span",{children:x.label})]},x.id))}),n.gateType&&n.gateType!=="none"?(0,Y.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact",children:[(0,Y.jsx)("span",{children:"Gate width (m)"}),(0,Y.jsx)("input",{type:"text",inputMode:"decimal",value:n.gateWidthM,onChange:x=>o(_=>({..._,gateWidthM:x.target.value}))})]}):null]}):null,u==="posts"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ei.length]}),(0,Y.jsx)("h2",{className:"truss-estimator__step-title",children:"Posts and fixing type"}),(0,Y.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose how the posts will be set."}),(0,Y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Sa.mounting).filter(([x])=>Pv(x,n.height)).map(([x,_])=>(0,Y.jsxs)("button",{type:"button",className:`truss-estimator__option-card${n.mountingType===x?" is-selected":""}`,onClick:()=>o(q=>({...q,mountingType:x})),children:[(0,Y.jsx)("div",{className:"truss-estimator__option-title",children:_.label}),(0,Y.jsx)("div",{className:"truss-estimator__option-copy",children:_.blurb})]},x))})]}):null]}),(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:ve,children:"Back"}),(0,Y.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:Ye,disabled:!Nt(),children:[(0,Y.jsx)("span",{children:Z}),(0,Y.jsx)("span",{className:"arrow",children:(0,Y.jsx)(Qt,{})})]})]})]})]})})}var wc=$(He()),he=$(F()),Jv={floor:{label:"Floor between rooms",product:"Knauf Acoustic Roll",thickness:"100mm",coverage:12.36},ground:{label:"Ground floor",product:"Rigid PIR insulation board",thickness:"100mm",coverage:2.88},wall:{label:"Cavity wall",product:"Celotex CW4100",thickness:"100mm",coverage:3.24},roof:{label:"Pitched roof",product:"Kingspan K107",thickness:"100mm",coverage:8.64},loft:{label:"Loft",product:"Knauf Loft Roll 44",thickness:"100mm",coverage:13.89}};function tm({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,wc.useState)("floor"),[n,o]=(0,wc.useState)(""),[l,c]=(0,wc.useState)(""),p=Number.parseFloat(n)*Number.parseFloat(l)||0,m=Jv[r],g=Math.ceil(p/m.coverage),d=[{key:`insulation-${r}`,label:`${m.product} ${m.thickness}`,qty:Math.round(p*100)/100,unit:"m2",query:m.product,category:"insulation"}],b=Object.entries(Jv);return(0,he.jsx)(he.Fragment,{children:(0,he.jsxs)("div",{className:"truss-estimator",children:[(0,he.jsxs)("div",{className:"quick-order-hero",children:[(0,he.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,he.jsx)("h1",{children:"Insulation Calculator"}),(0,he.jsx)("p",{children:"Estimate insulation coverage and pack quantities for floors, walls, roofs and lofts."})]}),(0,he.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,he.jsx)("h2",{className:"truss-estimator__step-title",children:"Where and what you are insulating"}),(0,he.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose the application and product, and enter the area, for coverage and pack quantities."}),(0,he.jsxs)("div",{className:"materials-calculator__section",children:[(0,he.jsx)("div",{className:"truss-estimator__section-heading",children:"Application"}),(0,he.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:b.map(([v,E])=>(0,he.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===v?" is-selected":""}`,onClick:()=>i(v),children:[(0,he.jsx)("div",{className:"truss-estimator__option-title",children:E.label}),(0,he.jsxs)("div",{className:"truss-estimator__option-copy",children:[E.product,", ",E.thickness]})]},v))})]}),(0,he.jsxs)("div",{className:"materials-calculator__section",children:[(0,he.jsx)("div",{className:"truss-estimator__section-heading",children:"Area"}),(0,he.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,he.jsxs)("label",{className:"truss-estimator__field",children:[(0,he.jsx)("span",{children:"Length (m)"}),(0,he.jsx)("input",{type:"number",min:"0",step:"0.01",value:n,onChange:v=>o(v.target.value)})]}),(0,he.jsxs)("label",{className:"truss-estimator__field",children:[(0,he.jsx)("span",{children:"Width (m)"}),(0,he.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:v=>c(v.target.value)})]})]})]}),(0,he.jsxs)("div",{className:"materials-calculator__totals",children:[(0,he.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,he.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("span",{children:"Insulated area"}),(0,he.jsxs)("strong",{children:[p.toFixed(2)," m\xB2"]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)("span",{children:m.product}),(0,he.jsxs)("strong",{children:[g," packs"]})]})]}),(0,he.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,he.jsxs)("div",{className:"materials-calculator__actions",children:[(0,he.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,he.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(d),disabled:p<=0,children:a})]})]})]})})}var Vn=$(He());var K=$(F()),bx=10,wx=1.9*.762,vx=1.9*1.524,vc=()=>({height:"",width:""}),yc=e=>Number.parseFloat(e)||0,Iv=({height:e,width:t})=>yc(e)*yc(t);function am({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Vn.useState)([vc()]),[n,o]=(0,Vn.useState)([vc()]),[l,c]=(0,Vn.useState)("0"),[p,m]=(0,Vn.useState)("0"),[g,d]=(0,Vn.useState)(1),b=r.reduce((k,z)=>k+Iv(z),0),v=n.reduce((k,z)=>k+Iv(z),0),E=yc(l)*wx+yc(p)*vx,O=Math.max(0,b-v-E),f=O*g/bx,u={key:"paint-emulsion",label:"Matt emulsion, brilliant white",qty:Math.round(f*10)/10,unit:"litres",query:"matt emulsion brilliant white"},h=dl("paint",u)!=null,w=(k,z,A,U)=>{k(R=>R.map((H,oe)=>oe===z?{...H,[A]:U}:H))};return(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)("div",{className:"truss-estimator",children:[(0,K.jsxs)("div",{className:"quick-order-hero",children:[(0,K.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,K.jsx)("h1",{children:"Paint Calculator"}),(0,K.jsx)("p",{children:"Estimate how much paint you need for your walls, including multiple coats and excluded areas."})]}),(0,K.jsxs)("div",{className:"truss-estimator__card paint-calculator",children:[(0,K.jsx)("h2",{className:"truss-estimator__step-title",children:"Walls, exclusions and coats"}),(0,K.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,K.jsxs)("div",{className:"paint-calculator__section",children:[(0,K.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall dimensions"}),(0,K.jsx)("p",{className:"paint-calculator__hint",children:"Enter the height and width of each wall you want to paint."}),(0,K.jsxs)("div",{className:"paint-calculator__dimensions-header","aria-hidden":"true",children:[(0,K.jsx)("span",{}),(0,K.jsx)("span",{children:"Height (m)"}),(0,K.jsx)("span",{children:"Width (m)"}),(0,K.jsx)("span",{})]}),r.map((k,z)=>(0,K.jsxs)("div",{className:"paint-calculator__row",children:[(0,K.jsxs)("span",{className:"paint-calculator__row-label",children:["Wall ",z+1]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{className:"sr-only",children:"Height (m)"}),(0,K.jsx)("input",{"aria-label":`Wall ${z+1} height in metres`,type:"number",min:"0",step:"0.01",value:k.height,onChange:A=>w(i,z,"height",A.target.value)})]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{className:"sr-only",children:"Width (m)"}),(0,K.jsx)("input",{"aria-label":`Wall ${z+1} width in metres`,type:"number",min:"0",step:"0.01",value:k.width,onChange:A=>w(i,z,"width",A.target.value)})]}),r.length>1?(0,K.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>i(A=>A.filter((U,R)=>R!==z)),children:"Remove"}):null]},`wall-${z}`)),(0,K.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>i(k=>[...k,vc()]),children:"+ Add another wall"})]}),(0,K.jsxs)("div",{className:"paint-calculator__section",children:[(0,K.jsx)("div",{className:"truss-estimator__section-heading",children:"Areas to exclude"}),(0,K.jsx)("p",{className:"paint-calculator__hint",children:"Add windows, sockets, skirting boards or other areas that will not be painted."}),(0,K.jsxs)("div",{className:"paint-calculator__dimensions-header","aria-hidden":"true",children:[(0,K.jsx)("span",{}),(0,K.jsx)("span",{children:"Height (m)"}),(0,K.jsx)("span",{children:"Width (m)"}),(0,K.jsx)("span",{})]}),n.map((k,z)=>(0,K.jsxs)("div",{className:"paint-calculator__row",children:[(0,K.jsxs)("span",{className:"paint-calculator__row-label",children:["Area ",z+1]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{className:"sr-only",children:"Height (m)"}),(0,K.jsx)("input",{"aria-label":`Area ${z+1} height in metres`,type:"number",min:"0",step:"0.01",value:k.height,onChange:A=>w(o,z,"height",A.target.value)})]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{className:"sr-only",children:"Width (m)"}),(0,K.jsx)("input",{"aria-label":`Area ${z+1} width in metres`,type:"number",min:"0",step:"0.01",value:k.width,onChange:A=>w(o,z,"width",A.target.value)})]}),n.length>1?(0,K.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>o(A=>A.filter((U,R)=>R!==z)),children:"Remove"}):null]},`excluded-${z}`)),(0,K.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>o(k=>[...k,vc()]),children:"+ Add another area"})]}),(0,K.jsxs)("div",{className:"paint-calculator__section",children:[(0,K.jsx)("div",{className:"truss-estimator__section-heading",children:"Doors and coats"}),(0,K.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,K.jsxs)("div",{className:"truss-estimator__field-grid paint-calculator__small-fields",children:[(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{children:"Doors"}),(0,K.jsx)("input",{type:"number",min:"0",step:"1",value:l,onChange:k=>c(k.target.value)})]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{children:"Double doors"}),(0,K.jsx)("input",{type:"number",min:"0",step:"1",value:p,onChange:k=>m(k.target.value)})]})]}),(0,K.jsxs)("div",{className:"paint-calculator__coat-field",children:[(0,K.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,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{children:"Number of coats"}),(0,K.jsxs)("select",{value:g,onChange:k=>d(Number(k.target.value)),children:[(0,K.jsx)("option",{value:"1",children:"1 coat"}),(0,K.jsx)("option",{value:"2",children:"2 coats"}),(0,K.jsx)("option",{value:"3",children:"3 coats"})]})]})]})]}),(0,K.jsxs)("div",{className:"paint-calculator__totals",children:[(0,K.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,K.jsxs)("div",{className:"paint-calculator__result-grid",children:[(0,K.jsxs)("div",{children:[(0,K.jsx)("span",{children:"Paintable area"}),(0,K.jsxs)("strong",{children:[O.toFixed(2)," m\xB2"]})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("span",{children:"Coverage"}),(0,K.jsxs)("strong",{children:[g," ",g===1?"coat":"coats"]})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("span",{children:"Paint required"}),(0,K.jsxs)("strong",{children:[f.toFixed(1)," litres"]})]})]}),(0,K.jsx)("p",{className:"paint-calculator__note",children:h?"Based on paint coverage of 10 m\xB2 per litre. Ordered as brilliant white matt emulsion, rounded up to whole tins.":"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,K.jsxs)("div",{className:"paint-calculator__actions",children:[(0,K.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),h?(0,K.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.([u]),disabled:f<=0,children:a}):(0,K.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",disabled:!0,children:"Paint products unavailable"})]})]})]})})}var fr=$(He()),te=$(F()),_c=e=>Number.parseFloat(e)||0,rm={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 im({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,fr.useState)("paving"),[n,o]=(0,fr.useState)("council"),[l,c]=(0,fr.useState)(""),[p,m]=(0,fr.useState)(""),[g,d]=(0,fr.useState)("100"),[b,v]=(0,fr.useState)("50"),[E,O]=(0,fr.useState)(!0),[f,u]=(0,fr.useState)(!0),h=_c(l)*_c(p),w=h,k=h*(_c(g)/1e3),z=h*.04,A=h*(_c(b)/1e3),U=Math.ceil(w/.36),R=Math.ceil(w/.1),H=Math.ceil(k*1700/800),oe=Math.ceil(z*1600/800),Te=Math.ceil(A*1600/800),je=r==="paving"?{qty:U,unit:"each"}:r==="block"?{qty:w,unit:"m2"}:{qty:Te,unit:"bag"},Ve={paving:"paving slab",block:"block paver",gravel:"decorative gravel"}[r],Ne=[{key:`surface-${n}`,label:rm[r].find(le=>le.id===n)?.label??"Surface material",qty:je.qty,unit:je.unit,query:Ve,category:"landscaping"},...E?[{key:"sub-base",label:"MOT Type 1 sub-base",qty:H,unit:"bag",query:"MOT Type 1 sub base",category:"aggregate"}]:[],...f?[{key:"bedding",label:"Sharp sand bedding",qty:oe,unit:"bag",query:"sharp sand",category:"aggregate"}]:[]];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:"Paving and Driveway Calculator"}),(0,te.jsx)("p",{children:"Estimate paving, block paving, sub-base and bedding materials for outdoor areas."})]}),(0,te.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,te.jsx)("h2",{className:"truss-estimator__step-title",children:"Surface and ground build-up"}),(0,te.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,te.jsxs)("div",{className:"materials-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Surface material"}),(0,te.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(([le,Fe,Ee])=>(0,te.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===le?" is-selected":""}`,onClick:()=>{i(le),o(rm[le][0].id)},children:[(0,te.jsx)("div",{className:"truss-estimator__option-title",children:Fe}),(0,te.jsx)("div",{className:"truss-estimator__option-copy",children:Ee})]},le))}),(0,te.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,te.jsx)("span",{children:"Finish"}),(0,te.jsx)("select",{value:n,onChange:le=>o(le.target.value),children:rm[r].map(le=>(0,te.jsx)("option",{value:le.id,children:le.label},le.id))})]})]}),(0,te.jsxs)("div",{className:"materials-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Area and groundwork"}),(0,te.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,te.jsxs)("label",{className:"truss-estimator__field",children:[(0,te.jsx)("span",{children:"Length (m)"}),(0,te.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:le=>c(le.target.value)})]}),(0,te.jsxs)("label",{className:"truss-estimator__field",children:[(0,te.jsx)("span",{children:"Width (m)"}),(0,te.jsx)("input",{type:"number",min:"0",step:"0.01",value:p,onChange:le=>m(le.target.value)})]})]}),r==="gravel"&&(0,te.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,te.jsx)("span",{children:"Gravel depth (mm)"}),(0,te.jsx)("input",{type:"number",min:"0",step:"10",value:b,onChange:le=>v(le.target.value)})]}),E&&(0,te.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,te.jsx)("span",{children:"Sub-base depth (mm)"}),(0,te.jsx)("input",{type:"number",min:"0",step:"10",value:g,onChange:le=>d(le.target.value)})]}),(0,te.jsxs)("label",{className:"brick-calculator__checkbox materials-calculator__waste",children:[(0,te.jsx)("input",{type:"checkbox",checked:E,onChange:le=>O(le.target.checked)}),(0,te.jsx)("span",{children:"Include MOT Type 1 sub-base"})]}),(0,te.jsxs)("label",{className:"brick-calculator__checkbox materials-calculator__waste",children:[(0,te.jsx)("input",{type:"checkbox",checked:f,onChange:le=>u(le.target.checked)}),(0,te.jsx)("span",{children:"Include sharp sand bedding"})]})]}),(0,te.jsxs)("div",{className:"materials-calculator__totals",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,te.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"Surface area"}),(0,te.jsxs)("strong",{children:[h.toFixed(2)," m\xB2"]})]}),(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:r==="paving"?"Paving slabs":r==="block"?"Block paving":"Gravel"}),(0,te.jsx)("strong",{children:r==="paving"?`${U} slabs`:r==="block"?`${w.toFixed(2)} m\xB2`:`${Te} bulk bags`})]}),E&&(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"MOT Type 1"}),(0,te.jsxs)("strong",{children:[H," bulk bags"]})]}),f&&(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"Sharp sand"}),(0,te.jsxs)("strong",{children:[oe," bulk bags"]})]})]}),(0,te.jsx)("p",{className:"materials-calculator__note",children:"Slab and block quantities use typical sizes. Confirm pack coverage and laying pattern before ordering."})]}),(0,te.jsxs)("div",{className:"materials-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?.(Ne),disabled:h<=0,children:a})]})]})]})})}var ml=$(He()),re=$(F()),yx=2.88,Fv=[{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"}],Wv=()=>({length:"",height:""}),nm=e=>Number.parseFloat(e)||0;function om({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,ml.useState)([Wv()]),[n,o]=(0,ml.useState)(""),[l,c]=(0,ml.useState)("standard"),[p,m]=(0,ml.useState)("screws"),g=r.reduce((z,A)=>z+nm(A.length)*nm(A.height),0),d=Math.max(0,g-nm(n)),b=Math.ceil(d/yx),v=Math.ceil(d*12),E=Math.ceil(v/1e3),O=Math.ceil(d*1.2),f=Math.ceil(O/90),u=Math.ceil(d/3.5),h=Fv.find(z=>z.id===l)?.label??"Standard",w=[{key:"board",label:`${h} plasterboard`,qty:b,unit:"sheet",query:`${h} plasterboard`,category:"plasterboard"},...p==="screws"?[{key:"screws",label:"Drywall screws",qty:E,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:f,unit:"roll",query:"plasterboard joint tape",category:"plasterboard"}],k=(z,A,U)=>{i(R=>R.map((H,oe)=>oe===z?{...H,[A]:U}:H))};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:"Plasterboard and Drylining Calculator"}),(0,re.jsx)("p",{children:"Estimate boards, fixings and jointing materials for walls and ceilings."})]}),(0,re.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,re.jsx)("h2",{className:"truss-estimator__step-title",children:"Boards, fixings and jointing"}),(0,re.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,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Board type"}),(0,re.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Fv.map(z=>(0,re.jsxs)("button",{type:"button",className:`truss-estimator__option-card${l===z.id?" is-selected":""}`,onClick:()=>c(z.id),children:[(0,re.jsx)("div",{className:"truss-estimator__option-title",children:z.label}),(0,re.jsx)("div",{className:"truss-estimator__option-copy",children:z.blurb})]},z.id))})]}),(0,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Fixing method"}),(0,re.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(([z,A,U])=>(0,re.jsxs)("button",{type:"button",className:`truss-estimator__option-card${p===z?" is-selected":""}`,onClick:()=>m(z),children:[(0,re.jsx)("div",{className:"truss-estimator__option-title",children:A}),(0,re.jsx)("div",{className:"truss-estimator__option-copy",children:U})]},z))})]}),(0,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall and ceiling areas"}),(0,re.jsx)("p",{className:"materials-calculator__hint",children:"Add each surface separately so different wall sizes are easy to measure."}),(0,re.jsxs)("div",{className:"materials-calculator__dimensions-header",children:[(0,re.jsx)("span",{children:"Surface"}),(0,re.jsx)("span",{children:"Length (m)"}),(0,re.jsx)("span",{children:"Height (m)"}),(0,re.jsx)("span",{})]}),r.map((z,A)=>(0,re.jsxs)("div",{className:"materials-calculator__surface-row",children:[(0,re.jsxs)("span",{children:["Surface ",A+1]}),(0,re.jsx)("input",{"aria-label":`Surface ${A+1} length`,type:"number",min:"0",step:"0.01",value:z.length,onChange:U=>k(A,"length",U.target.value)}),(0,re.jsx)("input",{"aria-label":`Surface ${A+1} height`,type:"number",min:"0",step:"0.01",value:z.height,onChange:U=>k(A,"height",U.target.value)}),r.length>1?(0,re.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>i(U=>U.filter((R,H)=>H!==A)),children:"Remove"}):null]},`surface-${A}`)),(0,re.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>i(z=>[...z,Wv()]),children:"+ Add another surface"}),(0,re.jsxs)("label",{className:"truss-estimator__field materials-calculator__openings",children:[(0,re.jsxs)("span",{children:["Openings to deduct (m\xB2) ",(0,re.jsx)("small",{children:"optional"})]}),(0,re.jsx)("input",{type:"number",min:"0",step:"0.01",value:n,onChange:z=>o(z.target.value)})]})]}),(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:"Board area"}),(0,re.jsxs)("strong",{children:[d.toFixed(2)," m\xB2"]})]}),(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"2.4 x 1.2 m boards"}),(0,re.jsx)("strong",{children:b})]}),(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:p==="screws"?"Drywall screws":"Board adhesive"}),(0,re.jsx)("strong",{children:p==="screws"?`${v} (${E} boxes)`:`${u} bags`})]}),(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"Joint tape"}),(0,re.jsxs)("strong",{children:[O," m (",f," rolls)"]})]})]}),(0,re.jsx)("p",{className:"materials-calculator__note",children:"Figures are estimates. Confirm board specification, fixing patterns and fire or acoustic requirements 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?.(w),disabled:d<=0,children:a})]})]})]})})}var fl=$(He());var y=$(F()),At={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}}}},xc=["range","pitchAndDimensions","quantityAndGirders","bracing"],_x={range:null,pitch:null,spanMM:"",overhangMM:"",roofLengthM:"",centres:null,girderCount:0,bracing:null,treatment:null,contact:{name:"",email:""}};function xx({degrees:e}){let a=e*Math.PI/180,i=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,${i}`,fill:"var(--accent-light)",stroke:"var(--accent)",strokeWidth:"3",strokeLinejoin:"round"})]})}function kx({type:e}){let t="#b3835a",a="#5c3b22",r="#d9b48f",i="#d3d8de",n="#7c8494",o=(m,g,d,b,v=8,E)=>{let O=d-m,f=b-g,u=Math.hypot(O,f)||1,h=-f/u,w=O/u,k=v*.2;return(0,y.jsxs)("g",{children:[(0,y.jsx)("line",{x1:m,y1:g,x2:d,y2:b,stroke:a,strokeWidth:v+3,strokeLinecap:"square"}),(0,y.jsx)("line",{x1:m,y1:g,x2:d,y2:b,stroke:t,strokeWidth:v,strokeLinecap:"square"}),(0,y.jsx)("line",{x1:m-h*k,y1:g-w*k,x2:d-h*k,y2:b-w*k,stroke:r,strokeWidth:Math.max(1.5,v*.24),strokeLinecap:"round",opacity:"0.9"})]},E)},l=(m,g,d)=>(0,y.jsxs)("g",{children:[(0,y.jsx)("rect",{x:m-7.5,y:g-5.5,width:"15",height:"11",rx:"2",fill:i,stroke:n,strokeWidth:"1"}),(0,y.jsx)("circle",{cx:m-4,cy:g-2.5,r:"1",fill:n}),(0,y.jsx)("circle",{cx:m+4,cy:g-2.5,r:"1",fill:n}),(0,y.jsx)("circle",{cx:m-4,cy:g+2.5,r:"1",fill:n}),(0,y.jsx)("circle",{cx:m+4,cy:g+2.5,r:"1",fill:n}),(0,y.jsx)("circle",{cx:m,cy:g,r:"1",fill:n})]},d),c=(m,g)=>(0,y.jsx)("rect",{x:m-9,y:"110",width:"18",height:"10",fill:a},g),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 Sx({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 e0({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 lm({onBack:e}){let[t,a]=(0,fl.useState)(0),[r,i]=(0,fl.useState)(_x),[n,o]=(0,fl.useState)(!1),[l,c]=(0,fl.useState)(!1),p=()=>{let f=Number.parseFloat(r.roofLengthM)||0,u=Number.parseFloat(r.centres??"");return f<=0||!u?0:Math.ceil(f*1e3/u)+1},g=(()=>{let f=r.range?At.ranges[r.range]:At.ranges.standard,u=r.pitch??"22.5",h=At.pitchMultipliers[u],w=(Number.parseFloat(r.spanMM)||0)/1e3,z=(Number.parseFloat(r.overhangMM)||0)>At.overhang.thresholdMM,A=p(),U=A+r.girderCount,R=Number.parseFloat(r.roofLengthM)||0,H=r.treatment?At.treatment[r.treatment]:At.treatment.untreated,oe=At.estimate.ranges[r.range??"standard"],Te=oe.supplyAt8m*Math.max(.7,w/8)*h*(1+H.surchargePct)+(z?At.overhang.surchargePerTruss:0),je=A*Te,Ve=r.girderCount*Te*At.estimate.girderMultiplier,Ne=r.bracing==="yes"?R*At.estimate.bracingPerMetre:0,we=je+Ve+Ne+At.estimate.delivery,le=At.estimate.design+A*oe.installPerTruss+r.girderCount*40,Fe=we+le,Ee=Fe*.2;return{range:f,count:A,girderCount:r.girderCount,overhangApplies:z,overhangUnits:U,roofLengthM:R,treatment:H,trussSupply:je,bracingMaterials:Ne,delivery:At.estimate.delivery,labour:le,subtotal:Fe,vat:Ee,total:Fe+Ee}})(),d=()=>{let f=xc[t];return f==="range"?!!r.range:f==="pitchAndDimensions"?!!r.pitch&&r.spanMM.trim()!==""&&r.overhangMM.trim()!=="":f==="quantityAndGirders"?r.roofLengthM.trim()!==""&&!!r.centres:f==="bracing"?!!r.bracing&&!!r.treatment:!0},b=t===xc.length-1?"View truss request":"Next",v=()=>{n?o(!1):t===0?e():a(f=>f-1)},E=()=>{d()&&(t===xc.length-1?(c(!1),o(!0)):a(f=>f+1))},O=()=>{let f=xc[t];return f==="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(At.ranges).map(([u,h])=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r.range===u?" is-selected":""}`,onClick:()=>i(w=>({...w,range:u})),children:[(0,y.jsx)(kx,{type:u}),(0,y.jsxs)("div",{className:"truss-estimator__option-info",children:[(0,y.jsx)("div",{className:"truss-estimator__option-title",children:h.label}),(0,y.jsx)("div",{className:"truss-estimator__option-copy",children:h.blurb})]})]},u))})]}):f==="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=>i(h=>({...h,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=>i(h=>({...h,overhangMM:u.target.value}))}),(0,y.jsxs)("small",{children:["Overhangs beyond ",At.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:At.pitches.map(u=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card${r.pitch===u?" is-selected":""}`,onClick:()=>i(h=>({...h,pitch:u})),children:[(0,y.jsx)(xx,{degrees:Number.parseFloat(u)}),(0,y.jsxs)("span",{children:[u,"\xB0"]})]},u))})]}):f==="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=>i(h=>({...h,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:At.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:()=>i(h=>({...h,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:()=>i(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:()=>i(u=>({...u,girderCount:Math.min(3,u.girderCount+1)})),children:"+"})]})]}):f==="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:()=>i(h=>({...h,bracing:u.id})),children:[(0,y.jsx)(Sx,{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:()=>i(u=>({...u,treatment:"untreated"})),children:[(0,y.jsx)(e0,{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:()=>i(u=>({...u,treatment:"treated"})),children:[(0,y.jsx)(e0,{treated:!0}),(0,y.jsx)("span",{children:"Treated (+8% cost)"}),(0,y.jsx)("small",{children:"Applies to trusses, girders and overhang"})]})]})]}):null};return n?(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:[g.range.label," roof trusses"]})]}),(0,y.jsxs)("strong",{children:[g.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:g.treatment.label})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Girder trusses"}),(0,y.jsx)("strong",{children:g.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(g.trussSupply)})]}),g.bracingMaterials>0&&(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Bracing materials allowance"}),(0,y.jsx)("strong",{children:nt(g.bracingMaterials)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Delivery allowance"}),(0,y.jsx)("strong",{children:nt(g.delivery)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Design and installation labour"}),(0,y.jsx)("strong",{children:nt(g.labour)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Subtotal (ex. VAT)"}),(0,y.jsx)("strong",{children:nt(g.subtotal)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"VAT (20%)"}),(0,y.jsx)("strong",{children:nt(g.vat)})]}),(0,y.jsxs)("div",{className:"truss-request__price-total",children:[(0,y.jsx)("span",{children:"Estimated total"}),(0,y.jsx)("strong",{children:nt(g.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:v,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:O()}),(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:v,children:"Back"}),(0,y.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:E,disabled:!d(),children:[(0,y.jsx)("span",{children:b}),(0,y.jsx)("span",{className:"arrow",children:(0,y.jsx)(Qt,{})})]})]})]})]})})}var Mi=$(He()),I=$(F()),r0=e=>Number.parseFloat(e)||0,kc=(e,t)=>r0(e)*(t==="m"?1:.3048),t0=()=>({length:"",width:""}),a0=[{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 Nx({profile:e}){return(0,I.jsxs)("svg",{className:"skirting-calculator__profile-diagram",viewBox:"0 0 120 84","aria-hidden":"true",children:[(0,I.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,I.jsx)("line",{x1:"12",y1:"70",x2:"108",y2:"70"})]})}function sm({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Mi.useState)("total"),[n,o]=(0,Mi.useState)("m"),[l,c]=(0,Mi.useState)(""),[p,m]=(0,Mi.useState)([t0()]),[g,d]=(0,Mi.useState)(""),[b,v]=(0,Mi.useState)("chamfered"),E="4.4",O=r==="total"?kc(l,n):p.reduce((k,z)=>k+2*(kc(z.length,n)+kc(z.width,n)),0),f=Math.max(0,O-kc(g,n)),u=Math.ceil(f/r0(E)),h=[{key:`skirting-${b}`,label:`${a0.find(k=>k.id===b)?.label} skirting board`,qty:f,unit:"m",query:"skirting board",category:"skirting"}],w=(k,z,A)=>{m(U=>U.map((R,H)=>H===k?{...R,[z]:A}:R))};return(0,I.jsx)(I.Fragment,{children:(0,I.jsxs)("div",{className:"truss-estimator",children:[(0,I.jsxs)("div",{className:"quick-order-hero",children:[(0,I.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,I.jsx)("h1",{children:"Skirting Board Calculator"}),(0,I.jsx)("p",{children:"Work out how many skirting board lengths you need for one room or a whole project."})]}),(0,I.jsxs)("div",{className:"truss-estimator__card skirting-calculator",children:[(0,I.jsx)("h2",{className:"truss-estimator__step-title",children:"Measure by room or total length"}),(0,I.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,I.jsxs)("div",{className:"skirting-calculator__section",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"How would you like to measure?"}),(0,I.jsxs)("div",{className:"brick-calculator__unit-toggle skirting-calculator__mode-toggle",role:"group","aria-label":"Calculation method",children:[(0,I.jsx)("button",{type:"button",className:r==="total"?"is-selected":"",onClick:()=>i("total"),children:"Total length"}),(0,I.jsx)("button",{type:"button",className:r==="rooms"?"is-selected":"",onClick:()=>i("rooms"),children:"Room by room"})]})]}),(0,I.jsxs)("div",{className:"skirting-calculator__section",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"Measurements"}),(0,I.jsxs)("div",{className:"skirting-calculator__unit-row",children:[(0,I.jsx)("span",{children:"Units"}),(0,I.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,I.jsx)("button",{type:"button",className:n==="m"?"is-selected":"",onClick:()=>o("m"),children:"Metres"}),(0,I.jsx)("button",{type:"button",className:n==="ft"?"is-selected":"",onClick:()=>o("ft"),children:"Feet"})]})]}),r==="total"?(0,I.jsxs)("label",{className:"truss-estimator__field skirting-calculator__single-field",children:[(0,I.jsxs)("span",{children:["Total skirting length (",n,")"]}),(0,I.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:k=>c(k.target.value)})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"skirting-calculator__dimensions-header",children:[(0,I.jsx)("span",{children:"Room"}),(0,I.jsxs)("span",{children:["Length (",n,")"]}),(0,I.jsxs)("span",{children:["Width (",n,")"]}),(0,I.jsx)("span",{})]}),p.map((k,z)=>(0,I.jsxs)("div",{className:"skirting-calculator__room-row",children:[(0,I.jsxs)("span",{className:"skirting-calculator__room-label",children:["Room ",z+1]}),(0,I.jsx)("input",{"aria-label":`Room ${z+1} length in ${n}`,type:"number",min:"0",step:"0.01",value:k.length,onChange:A=>w(z,"length",A.target.value)}),(0,I.jsx)("input",{"aria-label":`Room ${z+1} width in ${n}`,type:"number",min:"0",step:"0.01",value:k.width,onChange:A=>w(z,"width",A.target.value)}),p.length>1?(0,I.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>m(A=>A.filter((U,R)=>R!==z)),children:"Remove"}):null]},`room-${z}`)),(0,I.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>m(k=>[...k,t0()]),children:"+ Add another room"})]}),(0,I.jsxs)("label",{className:"truss-estimator__field skirting-calculator__single-field",children:[(0,I.jsxs)("span",{children:["Openings and doorways to deduct (",n,") ",(0,I.jsx)("small",{children:"optional"})]}),(0,I.jsx)("input",{type:"number",min:"0",step:"0.01",value:g,onChange:k=>d(k.target.value)})]})]}),(0,I.jsxs)("div",{className:"skirting-calculator__section",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"Profile"}),(0,I.jsx)("p",{className:"skirting-calculator__hint",children:"Choose the finish you want for the fixed 4.4m white-primed MDF boards."}),(0,I.jsx)("div",{className:"architrave-calculator__profiles",children:a0.map(k=>(0,I.jsxs)("button",{type:"button",className:`truss-estimator__option-card${b===k.id?" is-selected":""}`,onClick:()=>v(k.id),children:[(0,I.jsx)(Nx,{profile:k.id}),(0,I.jsx)("div",{className:"truss-estimator__option-title",children:k.label}),(0,I.jsx)("div",{className:"truss-estimator__option-copy",children:k.blurb})]},k.id))})]}),(0,I.jsxs)("div",{className:"skirting-calculator__section",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"Board and waste"}),(0,I.jsx)("div",{className:"truss-estimator__field-grid skirting-calculator__options-grid",children:(0,I.jsxs)("label",{className:"truss-estimator__field",children:[(0,I.jsx)("span",{children:"Board length"}),(0,I.jsx)("input",{value:"4.40 m",disabled:!0})]})}),(0,I.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,I.jsxs)("div",{className:"skirting-calculator__totals",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,I.jsxs)("div",{className:"skirting-calculator__result-grid",children:[(0,I.jsxs)("div",{children:[(0,I.jsx)("span",{children:"Net skirting"}),(0,I.jsxs)("strong",{children:[f.toFixed(2)," m"]})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("span",{children:"Board lengths"}),(0,I.jsx)("strong",{children:u})]})]}),(0,I.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,I.jsxs)("div",{className:"skirting-calculator__actions",children:[(0,I.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,I.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(h),disabled:f<=0,children:a})]})]})]})})}var Xn=$(He()),ne=$(F()),hl=e=>Number.parseFloat(e)||0;function cm({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Xn.useState)("studs"),[n,o]=(0,Xn.useState)(""),[l,c]=(0,Xn.useState)(""),[p,m]=(0,Xn.useState)("600"),[g,d]=(0,Xn.useState)("2.4"),b=n&&l&&p?Math.ceil(hl(l)/(hl(p)/1e3))+1:0,v=b*hl(n),E=hl(g)>0?Math.ceil(v/hl(g)):0,O=[{key:r,label:{studs:"Stud timber",joists:"Joist timber",battens:"Batten timber"}[r],qty:v,unit:"m",query:{studs:"cls studwork timber",joists:"timber joist",battens:"roofing batten"}[r],category:"timber"}],f={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"]},h={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,ne.jsx)(ne.Fragment,{children:(0,ne.jsxs)("div",{className:"truss-estimator",children:[(0,ne.jsxs)("div",{className:"quick-order-hero",children:[(0,ne.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,ne.jsx)("h1",{children:"Timber Calculator"}),(0,ne.jsx)("p",{children:"Estimate studs, joists or battens from a run length, width and spacing."})]}),(0,ne.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,ne.jsx)("h2",{className:"truss-estimator__step-title",children:"Member size and spacing"}),(0,ne.jsxs)("p",{className:"truss-estimator__step-sub",children:[h.help," Enter the member length and centres to estimate the number of pieces and stock lengths."]}),(0,ne.jsxs)("div",{className:"materials-calculator__section",children:[(0,ne.jsx)("div",{className:"truss-estimator__section-heading",children:"Timber use"}),(0,ne.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:Object.keys(f).map(w=>(0,ne.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===w?" is-selected":""}`,onClick:()=>i(w),children:[(0,ne.jsx)("div",{className:"truss-estimator__option-title",children:f[w][0]}),(0,ne.jsx)("div",{className:"truss-estimator__option-copy",children:f[w][1]})]},w))})]}),(0,ne.jsxs)("div",{className:"materials-calculator__section",children:[(0,ne.jsx)("div",{className:"truss-estimator__section-heading",children:"Dimensions and spacing"}),(0,ne.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,ne.jsxs)("label",{className:"truss-estimator__field",children:[(0,ne.jsxs)("span",{children:[h.member," (m)"]}),(0,ne.jsx)("input",{type:"number",min:"0",step:"0.01",value:n,onChange:w=>o(w.target.value)})]}),(0,ne.jsxs)("label",{className:"truss-estimator__field",children:[(0,ne.jsxs)("span",{children:[h.overall," (m)"]}),(0,ne.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:w=>c(w.target.value)})]})]}),(0,ne.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,ne.jsxs)("label",{className:"truss-estimator__field",children:[(0,ne.jsx)("span",{children:"Centres (mm)"}),(0,ne.jsxs)("select",{value:p,onChange:w=>m(w.target.value),children:[(0,ne.jsx)("option",{value:"300",children:"300 mm"}),(0,ne.jsx)("option",{value:"400",children:"400 mm"}),(0,ne.jsx)("option",{value:"450",children:"450 mm"}),(0,ne.jsx)("option",{value:"600",children:"600 mm"})]})]}),(0,ne.jsxs)("label",{className:"truss-estimator__field",children:[(0,ne.jsx)("span",{children:"Stock length (m)"}),(0,ne.jsxs)("select",{value:g,onChange:w=>d(w.target.value),children:[(0,ne.jsx)("option",{value:"2.4",children:"2.40 m"}),(0,ne.jsx)("option",{value:"3.6",children:"3.60 m"}),(0,ne.jsx)("option",{value:"4.8",children:"4.80 m"})]})]})]})]}),(0,ne.jsxs)("div",{className:"materials-calculator__totals",children:[(0,ne.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,ne.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,ne.jsxs)("div",{children:[(0,ne.jsx)("span",{children:h.count}),(0,ne.jsx)("strong",{children:b})]}),(0,ne.jsxs)("div",{children:[(0,ne.jsx)("span",{children:"Linear metres"}),(0,ne.jsxs)("strong",{children:[v.toFixed(2)," m"]})]}),(0,ne.jsxs)("div",{children:[(0,ne.jsxs)("span",{children:[g," m lengths"]}),(0,ne.jsx)("strong",{children:E})]})]}),(0,ne.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,ne.jsxs)("div",{className:"materials-calculator__actions",children:[(0,ne.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,ne.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(O),disabled:v<=0,children:a})]})]})]})})}var um=[{id:"truss",title:"Roof Truss Calculator",desc:"Estimate trusses, girders and roof structure costs.",imageUrl:"/tool-images/truss.webp",Component:lm},{id:"fencing",title:"Fencing Calculator",desc:"Estimate fence panels, posts, gravel boards and fixings.",imageUrl:"/tool-images/fencing.webp",Component:em},{id:"decking",title:"Decking Calculator",desc:"Estimate boards, substructure and fixing quantities.",imageUrl:"/tool-images/decking.webp",Component:Fd},{id:"brick-block",title:"Brick and Block Calculator",desc:"Estimate masonry units and ready-mixed mortar for a wall.",imageUrl:"/tool-images/brick-block.webp",Component:Kd},{id:"paint",title:"Paint Calculator",desc:"Estimate paint for walls, doors and multiple coats.",imageUrl:"/tool-images/paint.webp",Component:am},{id:"skirting",title:"Skirting Board Calculator",desc:"Estimate skirting lengths for rooms and wall runs.",imageUrl:"/tool-images/skirting.webp",Component:sm},{id:"architrave",title:"Architrave Calculator",desc:"Estimate architrave lengths for door and window openings.",imageUrl:"/tool-images/architrave.webp",Component:Zd},{id:"concrete-aggregate",title:"Concrete and Aggregate Calculator",desc:"Estimate concrete, MOT, sand and gravel quantities.",imageUrl:"/tool-images/concrete-aggregate.webp",Component:Jd},{id:"plasterboard",title:"Plasterboard Calculator",desc:"Estimate plasterboard sheets, screws, tape and adhesive.",imageUrl:"/tool-images/plasterboard.webp",Component:om},{id:"insulation",title:"Insulation Calculator",desc:"Estimate insulation packs for floors, walls, roofs and lofts.",imageUrl:"/tool-images/insulation.webp",Component:tm},{id:"timber",title:"Timber Calculator",desc:"Estimate studs, joists and battens from spacing and lengths.",imageUrl:"/tool-images/timber.webp",Component:cm},{id:"paving",title:"Paving and Driveway Calculator",desc:"Estimate paving, block paving, MOT and sharp sand.",imageUrl:"/tool-images/paving.webp",Component:im}];var pm=$(He());var Cx=new Set(["bag","box","roll","pack"]),qx=new Set(["each","bag","box","roll","pack","tub"]);function gl(e,t){let r=(t?.conversion?.request_uoms_supported??"").split(",").map(o=>o.trim().toLowerCase()).includes("sales_unit");if(e==="each"){let o=(t?.uoi_count??1)===1&&(t?.conversion?.sales_unit_size??1)===1;return r&&o?"sales_unit":e}if(!Cx.has(e))return e;if(r)return"sales_unit";let i=t?.uoi;return i!=null&&qx.has(i.toLowerCase())&&(t?.uoi_count??1)===1?i:e}var i0=new Map;function Ex(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 Ti(e,t,a=12,r){let i=`${Ot().client??""}||${e}||${t??""}||${a}||${r??""}`,n=i0.get(i);if(n)return n;let o=new URLSearchParams({q:e,limit:String(a)});t&&o.set("category",t),r&&o.set("account",r);let l=await fetch(Ta(`/api/catalogue/search?${o.toString()}`),{headers:bi()}),c=await Ga(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(Ex):[];return i0.set(i,p),p}async function n0(e,t,a){return await Promise.all(e.map(async i=>{try{let n=a?dl(a,i):null,[o,l]=await Promise.all([n?Ti(n,void 0,void 0,t).then(p=>p.find(m=>m.product_id===n.split(" ")[0]),()=>{}):void 0,Ti(i.query,i.category,void 0,t)]),c=o?[o,...l.filter(p=>p.product_id!==o.product_id)]:l;return{requirement:i,candidates:c}}catch{return{requirement:i,candidates:[]}}}))}async function o0(){let e=await fetch(Ta("/api/catalogue"),{headers:bi()});if(!e.ok)return{itemCount:0,uploadedAt:null};let t=await Ga(e);return{itemCount:Number(t?.itemCount)||0,uploadedAt:t?.uploadedAt??null}}var Wt=$(F()),Mx=1500;function l0(e){let{addManyToCart:t,clearCart:a,openBasket:r}=Dn(),[i,n]=(0,pm.useState)(!1),[o,l]=(0,pm.useState)(null);return{adding:i,basketError:o,addToBasket:async(p,m)=>{let g=Date.now();n(!0),l(null);try{let d=await Promise.all(p.filter(v=>v.qty>0).map(async v=>{let E=(await Ti(v.search)).find(O=>O.product_id===v.productId);if(!E)throw new Error("A selected product is no longer available in this catalogue.");return On(E,{lineId:`${e}:${v.key}`,description:E.description,unit:gl(v.unit??"each",E),qty:v.qty,calculatorWasteIncluded:m})})),b=Mx-(Date.now()-g);b>0&&await new Promise(v=>window.setTimeout(v,b)),a(),t(d),r()}catch(d){l(d instanceof Error?d.message:"Could not add the products to your basket.")}finally{n(!1)}}}}function s0({toolTitle:e}){return(0,Wt.jsx)(Wt.Fragment,{children:(0,Wt.jsxs)("div",{className:"truss-estimator",children:[(0,Wt.jsxs)("div",{className:"quick-order-hero",children:[(0,Wt.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Wt.jsx)("h1",{children:"Your Materials"}),(0,Wt.jsxs)("p",{children:["Calculating quantities from the ",e,"."]})]}),(0,Wt.jsx)("div",{className:"truss-estimator__card",children:(0,Wt.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{flex:1,justifyContent:"center"},children:[(0,Wt.jsx)(wi,{}),(0,Wt.jsx)("p",{className:"banter-message is-visible",children:"Preparing your materials\u2026"})]})})]})})}var Nc=$(He());var Le=$(He());var C=$(F()),Tx=[{dir:"asc",label:"Description (A-Z)"},{dir:"desc",label:"Description (Z-A)"}],dm={wasteFactorEnabled:!0},zx=3e3,c0=null;function Sc(e,t){let a=ol(t);return a?`${e.toFixed(2)} ${a}`:e.toFixed(2)}function Rx(e){return e&&e.length>0?e.join(" x "):"-"}function mm({toolId:e,requirements:t,ready:a,onBack:r,onTotalChange:i}){let n=vv(),o=`${e}~${t.map(N=>`${N.key}|${N.query}|${N.category??""}|${N.qty}`).join("~")}`,l=o!==c0,[c,p]=(0,Le.useState)(null),[m,g]=(0,Le.useState)([]),[d,b]=(0,Le.useState)(l),[v,E]=(0,Le.useState)(null),[O,f]=(0,Le.useState)("tile"),[u,h]=(0,Le.useState)(null),[w,k]=(0,Le.useState)(""),[z,A]=(0,Le.useState)(null),[U,R]=(0,Le.useState)(""),[H,oe]=(0,Le.useState)([]),[Te,je]=(0,Le.useState)(new Set),[Ve,Ne]=(0,Le.useState)(null),[we,le]=(0,Le.useState)(""),[Fe,Ee]=(0,Le.useState)([]),Nt=(0,Le.useRef)(null),Z=(0,Le.useRef)(!1),ge=N=>`${e}:${N}`,Re=N=>On(N.chosen,{lineId:ge(N.requirement.key),description:N.requirement.label,unit:gl(N.requirement.unit,N.chosen),qty:N.requirement.qty}),bt=(0,Le.useMemo)(()=>t.map(N=>`${N.key}|${N.query}|${N.category??""}`).join("~"),[t]);(0,Le.useEffect)(()=>{let N=!1;return o0().then(L=>{N||p(L.itemCount>0)}).catch(()=>{N||p(!1)}),()=>{N=!0}},[]),(0,Le.useEffect)(()=>{if(!a||!c)return;let N=!1,L;l&&b(!0),E(null);let X=Date.now();return(async()=>{let ue=null;try{ue=(await n0(t,void 0,e)).map(({requirement:vt,candidates:mt})=>({requirement:vt,candidates:mt,chosen:mt[0]??null}))}catch(ke){N||E(ke instanceof Error?ke.message:"Could not load products")}if(!N){if(c0=o,l){let ke=zx-(Date.now()-X);ke>0&&await new Promise(vt=>{L=window.setTimeout(vt,ke)})}N||(ue&&(g(ue),!Z.current&&n&&(Z.current=!0,n.addManyToCart(ue.filter(ke=>ke.chosen).map(Re)))),b(!1))}})(),()=>{N=!0,window.clearTimeout(L)}},[a,c,bt]),(0,Le.useEffect)(()=>{if(!z)return;let N=U.trim();if(!N){oe([]);return}let L=!1,X=window.setTimeout(()=>{Ti(N).then(ue=>{L||oe(ue)}).catch(()=>{L||oe([])})},250);return()=>{L=!0,window.clearTimeout(X)}},[z,U]),(0,Le.useEffect)(()=>{if(!Ve)return;let N=we.trim();if(!N){Ee([]);return}let L=!1,X=window.setTimeout(()=>{Ti(N).then(ue=>{L||Ee(ue)}).catch(()=>{L||Ee([])})},250);return()=>{L=!0,window.clearTimeout(X)}},[Ve,we]);let jt=(0,Le.useMemo)(()=>{let N=w.trim().toLowerCase(),L=N?m.filter(X=>X.requirement.label.toLowerCase().includes(N)||(X.chosen?.description??"").toLowerCase().includes(N)||(X.chosen?.product_id??"").toLowerCase().includes(N)):m;return u?[...L].sort((X,ue)=>{let ke=X.requirement.label.localeCompare(ue.requirement.label);return u==="asc"?ke:-ke}):L},[m,w,u]),Ct=jt.filter(N=>N.chosen),wt=jt.filter(N=>!N.chosen),be=m.filter(N=>N.chosen),de=be.filter(N=>N.chosen?.price==null).length,tt=be.reduce((N,L)=>N+(Ft(Re(L),dm).lineTotal??0),0);if((0,Le.useEffect)(()=>{i?.(tt)},[tt,i]),!a||c===!1)return null;let T=n?be.filter(N=>n.cart[ge(N.requirement.key)]).length:0,G=Ve?m.find(N=>N.requirement.key===Ve)??null:null,ce=we.trim()?Fe:G?.candidates??[],ve=N=>{let L=z===N.requirement.key;A(L?null:N.requirement.key),R(L?"":N.requirement.query)},Ye=(N,L)=>{let X=m.find(ue=>ue.requirement.key===N);g(ue=>ue.map(ke=>ke.requirement.key===N?{...ke,chosen:L}:ke)),n&&X&&n.cart[ge(N)]&&n.addToCart(Re({...X,chosen:L})),A(null),R("")},qe=N=>{g(L=>L.map(X=>X.requirement.key===N?{...X,chosen:null}:X)),n?.cart[ge(N)]&&n.removeFromCart(ge(N))},x=N=>{Ne(N.requirement.key),le(""),Ee([])},_=()=>{Ne(null),le(""),Ee([])},q=N=>{if(!n)return;let L=ge(N.requirement.key);n.cart[L]?n.removeFromCart(L):n.addToCart(Re(N))},D=N=>{je(L=>{let X=new Set(L);return X.has(N)?X.delete(N):X.add(N),X})},V=N=>{let L=H.length>0?H:N.candidates;return(0,C.jsxs)("div",{className:"estimator-products__picker",children:[(0,C.jsx)("input",{type:"text",className:"results-search-input",value:U,autoFocus:!0,placeholder:"Search products in catalogue...",onChange:X=>R(X.target.value),"aria-label":`Search a product for ${N.requirement.label}`}),(0,C.jsxs)("div",{className:"estimator-products__options",children:[L.map(X=>(0,C.jsxs)("button",{type:"button",className:`estimator-products__option${X.product_id===N.chosen?.product_id?" is-selected":""}`,onClick:()=>Ye(N.requirement.key,X),children:[(0,C.jsx)("span",{children:X.description}),(0,C.jsxs)("span",{className:"results-row-meta",children:[X.product_id,X.price!=null&&` \xB7 ${nt(X.price)}`]})]},X.product_id)),L.length===0&&(0,C.jsx)("p",{className:"results-empty-hint",children:"No matching products."})]})]})};return(0,C.jsxs)("section",{className:"estimator-products results-tile-section","aria-label":"Matched products",children:[!d&&(0,C.jsxs)("div",{className:"estimator-products__head",children:[(0,C.jsxs)("div",{className:"results-tile-section__head",children:[(0,C.jsx)("h3",{children:"Matched Products"}),(0,C.jsx)("p",{children:"Products matched to your estimate, check before adding to your basket."})]}),!G&&(0,C.jsx)("div",{className:"results-summary estimator-products__toolbar",children:(0,C.jsxs)("div",{className:"estimator-products__controls",children:[(0,C.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search description...",value:w,onChange:N=>k(N.target.value),"aria-label":"Search matched products"}),(0,C.jsxs)("div",{className:"results-view-toggle","aria-label":"Results view",children:[(0,C.jsx)("button",{type:"button",className:`results-view-toggle__btn${O==="tile"?" is-active":""}`,"aria-pressed":O==="tile","aria-label":"Tile view",title:"Tile view",onClick:()=>f("tile"),children:(0,C.jsxs)("svg",{width:"18",height:"12",viewBox:"0 0 15 10",fill:"currentColor",children:[(0,C.jsx)("rect",{x:"0.5",y:"0.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"5.5",y:"0.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"10.5",y:"0.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"0.5",y:"5.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"5.5",y:"5.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"10.5",y:"5.5",width:"4",height:"4"})]})}),(0,C.jsx)("button",{type:"button",className:`results-view-toggle__btn${O==="list"?" is-active":""}`,"aria-pressed":O==="list","aria-label":"List view",title:"List view",onClick:()=>f("list"),children:(0,C.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 15 15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,C.jsx)("line",{x1:"0.5",y1:"2.5",x2:"14.5",y2:"2.5"}),(0,C.jsx)("line",{x1:"0.5",y1:"7.5",x2:"14.5",y2:"7.5"}),(0,C.jsx)("line",{x1:"0.5",y1:"12.5",x2:"14.5",y2:"12.5"})]})})]}),(0,C.jsxs)("details",{ref:Nt,style:{position:"relative"},children:[(0,C.jsx)("summary",{className:"bom-toolbar-btn sort-menu-summary","aria-label":"Sort materials",style:{fontSize:16},children:"\u21C5"}),(0,C.jsx)("div",{className:"sort-menu-panel",children:Tx.map(N=>{let L=u===N.dir;return(0,C.jsxs)("button",{type:"button",className:`sort-menu-item${L?" is-active":""}`,onClick:()=>{h(L?null:N.dir),Nt.current?.removeAttribute("open")},children:[(0,C.jsx)("span",{className:"sort-menu-item__check",children:L?"\u2713":""}),N.label]},N.dir)})})]})]})})]}),G&&(0,C.jsxs)("div",{className:"results-review-page",children:[(0,C.jsxs)("div",{className:"results-review-page__top",children:[(0,C.jsxs)("button",{type:"button",className:"bom-toolbar-btn bom-toolbar-btn--accent",onClick:_,children:[(0,C.jsx)(Vr,{}),"Back to results"]}),(0,C.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,C.jsx)("div",{className:"results-review-searchbar",children:(0,C.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search products in catalogue...",value:we,onChange:N=>le(N.target.value),"aria-label":`Search a product for ${G.requirement.label}`})}),G.chosen&&(0,C.jsx)("div",{className:"results-candidate-actions",children:(0,C.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>qe(G.requirement.key),children:"Clear selected product"})})]})]}),(0,C.jsxs)("div",{className:"results-review-page__hero",children:[(0,C.jsx)("div",{className:"results-review-page__image-wrap",children:(0,C.jsx)(za,{className:"fill-img results-review-page__image",description:G.chosen?.description||G.requirement.label,photoUrl:G.chosen?.pdp_photo_url})}),(0,C.jsxs)("div",{className:"results-review-page__summary",children:[(0,C.jsx)("h2",{children:G.requirement.label}),(0,C.jsxs)("p",{className:"results-review-page__meta",children:[vi(G.requirement.qty)," ",xa(G.requirement.unit,G.requirement.qty)]}),G.chosen?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"results-review-page__product",children:G.chosen.description}),(0,C.jsxs)("div",{className:"results-row-meta",children:[G.chosen.product_id,G.chosen.price!=null?` \xB7 ${Sc(G.chosen.price,G.chosen.price_basis)}`:""]})]}):(0,C.jsx)("div",{className:"results-empty-hint",children:"No product currently selected for this line."}),(0,C.jsx)("div",{className:"results-review-page__actions",children:(0,C.jsx)("button",{type:"button",className:`bom-toolbar-btn${n?.cart[ge(G.requirement.key)]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>q(G),disabled:!G.chosen||!n,children:n?.cart[ge(G.requirement.key)]?"\u2713 Added":"+ Add to basket"})})]})]}),ce.length===0?(0,C.jsx)("p",{className:"results-empty-hint",children:"No matching products."}):(0,C.jsxs)("table",{className:"score-breakdown-table",children:[(0,C.jsx)("thead",{children:(0,C.jsxs)("tr",{children:[(0,C.jsx)("th",{children:"Product"}),(0,C.jsx)("th",{children:"Dims (mm)"}),(0,C.jsx)("th",{children:"Price"}),(0,C.jsx)("th",{"aria-label":"Actions"})]})}),(0,C.jsx)("tbody",{children:ce.map(N=>{let L=N.product_id===G.chosen?.product_id;return(0,C.jsxs)("tr",{className:L?"score-breakdown-row--best":"",children:[(0,C.jsxs)("td",{children:[(0,C.jsx)("div",{children:N.description}),(0,C.jsx)("div",{className:"results-row-meta",children:N.product_id})]}),(0,C.jsx)("td",{children:(0,C.jsx)("span",{className:"unit-badge",children:Rx(N.measurements_mm)})}),(0,C.jsx)("td",{children:N.price!=null?Sc(N.price,N.price_basis):"-"}),(0,C.jsx)("td",{children:(0,C.jsxs)("label",{className:"switch-toggle",title:L?"Currently selected":"Use this candidate",children:[(0,C.jsx)("input",{type:"checkbox",checked:L,onChange:()=>{L?qe(G.requirement.key):Ye(G.requirement.key,N)},"aria-label":L?`${N.description} selected`:`Use ${N.description}`}),(0,C.jsx)("span",{className:"switch-toggle-track","aria-hidden":"true"})]})})]},N.product_id)})})]})]}),!G&&d&&(0,C.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{padding:"32px 24px"},children:[(0,C.jsx)(wi,{}),(0,C.jsx)("p",{className:"banter-message is-visible",style:{fontSize:15,minHeight:0},children:"Matching your materials against the catalogue\u2026"})]}),!G&&v&&(0,C.jsx)("p",{className:"results-empty-hint estimator-products__error",children:v}),!G&&!d&&!v&&jt.length===0&&m.length>0&&(0,C.jsx)("p",{className:"results-empty-hint",children:"No materials match the current search."}),!G&&!d&&!v&&O==="tile"&&Ct.length>0&&(0,C.jsx)("div",{className:"results-tile-grid",children:Ct.map(N=>{let{requirement:L,chosen:X}=N,ue=X?Ft(Re(N),dm):null,ke=n?!!n.cart[ge(L.key)]:!1;return(0,C.jsxs)("article",{className:"results-tile-card",children:[(0,C.jsxs)("button",{type:"button",className:"results-tile-card__surface",onClick:()=>x(N),"aria-label":`Review match for ${L.label}`,children:[(0,C.jsx)("div",{className:"results-tile-card__media",children:(0,C.jsx)(za,{className:"fill-img results-tile-card__image",description:X?.description||L.label,photoUrl:X?.pdp_photo_url})}),(0,C.jsxs)("div",{className:"results-tile-card__body",children:[X?(0,C.jsxs)("div",{className:"results-tile-card__heading",children:[(0,C.jsx)("div",{className:"results-tile-card__title",children:X.description}),(0,C.jsxs)("div",{className:"results-tile-card__match-meta",children:[(0,C.jsx)("span",{children:X.product_id}),X.price!=null?(0,C.jsx)("span",{children:Sc(X.price,X.price_basis)}):null]})]}):(0,C.jsx)("div",{className:"results-empty-hint",children:"No product matched for this line."}),(0,C.jsxs)("div",{className:"results-tile-card__match",children:[(0,C.jsx)("div",{className:"results-tile-card__match-label",children:"\u21B3 calculated as"}),(0,C.jsx)("div",{className:"results-tile-card__match-name",children:L.label}),(0,C.jsxs)("div",{className:"results-tile-card__meta",children:[vi(L.qty)," ",xa(L.unit,L.qty)]}),ue?.requiredSellUnits!=null?(0,C.jsxs)("div",{className:"results-tile-card__meta estimator-products__order",children:["Order ",ue.requiredSellUnits," ",ue.sellUnit,ue.lineTotal!=null?` \xB7 ${nt(ue.lineTotal)}`:""]}):X?(0,C.jsx)("div",{className:"results-row-meta",children:"Quantity needs review"}):null]})]})]}),(0,C.jsxs)("div",{className:"results-tile-card__actions",children:[(0,C.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>x(N),children:"Review"}),(0,C.jsx)("button",{type:"button",className:`bom-toolbar-btn${ke?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>q(N),disabled:!X||!n,children:ke?"\u2713 Added":"+ Add"})]})]},L.key)})}),!G&&!d&&!v&&O==="list"&&Ct.length>0&&(0,C.jsx)("div",{className:"bom-table-wrap",children:(0,C.jsxs)("table",{className:"bom-table results-table","aria-label":"Matched materials",children:[(0,C.jsxs)("colgroup",{children:[(0,C.jsx)("col",{style:{width:"56px"}}),(0,C.jsx)("col",{className:"col-item"}),(0,C.jsx)("col",{style:{width:"90px"}}),(0,C.jsx)("col",{style:{width:"80px"}}),(0,C.jsx)("col",{style:{width:"220px"}}),(0,C.jsx)("col",{style:{width:"110px"}})]}),(0,C.jsx)("thead",{children:(0,C.jsxs)("tr",{className:"bom-col-header",children:[(0,C.jsx)("th",{"aria-label":"Expand"}),(0,C.jsx)("th",{style:{textAlign:"left"},children:"Description"}),(0,C.jsx)("th",{style:{textAlign:"center"},children:"Qty"}),(0,C.jsx)("th",{style:{textAlign:"center"},children:"Unit"}),(0,C.jsx)("th",{style:{textAlign:"center"},children:"Product Matched"}),(0,C.jsx)("th",{style:{textAlign:"center"},children:"Basket"})]})}),(0,C.jsx)("tbody",{children:Ct.map(N=>{let{requirement:L,chosen:X}=N,ue=X?Ft(Re(N),dm):null,ke=n?!!n.cart[ge(L.key)]:!1,vt=Te.has(L.key);return(0,C.jsxs)(Le.Fragment,{children:[(0,C.jsxs)("tr",{className:"bom-row",children:[(0,C.jsx)("td",{className:"bom-actions",style:{textAlign:"center",paddingLeft:0,paddingRight:0},children:(0,C.jsx)("button",{type:"button",className:"link-btn",onClick:()=>D(L.key),"aria-expanded":vt,"aria-label":vt?"Collapse product options":"Expand product options",children:vt?"\u25BE":"\u25B8"})}),(0,C.jsxs)("td",{style:{paddingLeft:0},children:[(0,C.jsx)("div",{className:"bom-component-name",children:L.label}),ue?.requiredSellUnits!=null&&(0,C.jsxs)("div",{className:"results-row-meta",children:["Order ",ue.requiredSellUnits," ",ue.sellUnit,ue.lineTotal!=null?` \xB7 ${nt(ue.lineTotal)}`:""]})]}),(0,C.jsx)("td",{className:"bom-qty col-order",style:{textAlign:"center"},children:vi(L.qty)}),(0,C.jsx)("td",{style:{textAlign:"center"},children:xa(L.unit,L.qty)}),(0,C.jsx)("td",{style:{textAlign:"center"},children:X?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"bom-component-name",children:X.description}),(0,C.jsxs)("div",{className:"results-row-meta",children:[X.product_id,X.price!=null&&` \xB7 ${Sc(X.price,X.price_basis)}`]})]}):(0,C.jsx)("span",{className:"results-empty-hint",children:"No match"})}),(0,C.jsx)("td",{style:{textAlign:"center"},children:(0,C.jsx)("button",{type:"button",className:`bom-toolbar-btn${ke?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>q(N),disabled:!X||!n,children:ke?"\u2713 Added":"+ Add"})})]}),vt&&(0,C.jsx)("tr",{children:(0,C.jsx)("td",{colSpan:6,style:{paddingLeft:0,paddingRight:0},children:z===L.key?V(N):(0,C.jsxs)("div",{className:"estimator-products__picker",children:[(0,C.jsxs)("div",{className:"estimator-products__options",children:[N.candidates.map(mt=>(0,C.jsxs)("button",{type:"button",className:`estimator-products__option${mt.product_id===X?.product_id?" is-selected":""}`,onClick:()=>Ye(L.key,mt),children:[(0,C.jsx)("span",{children:mt.description}),(0,C.jsxs)("span",{className:"results-row-meta",children:[mt.product_id,mt.price!=null&&` \xB7 ${nt(mt.price)}`]})]},mt.product_id)),N.candidates.length===0&&(0,C.jsx)("p",{className:"results-empty-hint",children:"No candidates found."})]}),(0,C.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>ve(N),children:"Search the catalogue"})]})})})]},L.key)})})]})}),!G&&!d&&!v&&wt.length>0&&(0,C.jsxs)("section",{className:"results-tile-section results-tile-section--unmatched","aria-label":"Items requiring matching",children:[(0,C.jsxs)("div",{className:"results-tile-section__head",children:[(0,C.jsx)("h3",{children:"Require Matching"}),(0,C.jsx)("p",{children:"We couldn\u2019t confidently match these to a product. Open one to pick from the closest options."})]}),(0,C.jsx)("div",{className:"results-unmatched-list",children:wt.map(N=>(0,C.jsxs)("button",{type:"button",className:"results-unmatched-card",onClick:()=>x(N),children:[(0,C.jsxs)("span",{className:"results-unmatched-card__main",children:[(0,C.jsx)("span",{className:"results-unmatched-card__title",children:N.requirement.label}),(0,C.jsxs)("span",{className:"results-row-meta",children:[vi(N.requirement.qty)," ",xa(N.requirement.unit,N.requirement.qty)]})]}),(0,C.jsx)("span",{className:"bom-toolbar-btn results-unmatched-card__prompt",children:"Review"})]},N.requirement.key))})]}),!d&&!v&&m.length>0&&(0,C.jsxs)("div",{className:"disclaimer-box",style:{alignItems:"center"},children:[(0,C.jsx)("span",{className:"disclaimer-icon",children:"\u26A0\uFE0F"}),(0,C.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."})]}),!G&&!d&&!v&&(r||T>0)&&(0,C.jsxs)("div",{className:"btn-row estimator-products__footer",children:[r&&(0,C.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:r,children:"Back"}),T>0&&n&&(0,C.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:r?"0 1 70%":1,marginTop:0},onClick:n.openBasket,children:[(0,C.jsxs)("span",{children:["View Basket (",T,")"]}),(0,C.jsx)("span",{className:"arrow",children:(0,C.jsx)(Qt,{})})]})]})]})}var Gt=$(F());function fm({toolId:e,toolTitle:t,requirements:a,onBack:r}){let[i,n]=(0,Nc.useState)(0),o=(0,Nc.useCallback)(l=>n(l),[]);return(0,Gt.jsx)(Gt.Fragment,{children:(0,Gt.jsxs)("div",{className:"truss-estimator",children:[(0,Gt.jsxs)("div",{className:"quick-order-hero",children:[(0,Gt.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Gt.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,Gt.jsx)("h1",{children:"Your Materials"}),i>0&&(0,Gt.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,Gt.jsx)("strong",{children:nt(i)})," Est. total"]})]}),(0,Gt.jsxs)("p",{children:["Quantities from the ",t,", matched against your merchant\u2019s catalogue."]})]}),(0,Gt.jsx)("div",{className:"truss-estimator__card",style:{minHeight:0},children:(0,Gt.jsx)(mm,{toolId:e,requirements:a,ready:!0,onBack:r,onTotalChange:o})})]})})}var ze=$(F());function Cc(e){let[t,a]=(0,$a.useState)(!1);return(0,ze.jsx)(lc,{onOpenBasket:()=>a(!0),children:(0,ze.jsx)(Ax,{...e,showBasket:t,onShowBasket:a})})}function Ax({fullPage:e=!1,hideHeader:t=!1,internal:a=!1,showBasket:r,onShowBasket:i}){let[n,o]=(0,$a.useState)(null),[l,c]=(0,$a.useState)(null),p=um.find(U=>U.id===n),{cart:m,updateCartQty:g,updateCartSellUnits:d,updateCartConversions:b,removeFromCart:v,clearCart:E}=Dn(),{adding:O,basketError:f,addToBasket:u}=l0(p?.title??"calculator"),h=(0,$a.useRef)(null),w=Js("estimating-tools",h);(0,$a.useEffect)(()=>{w("viewed")},[w]);let k=r?"basket":O?"adding":l?"review":n??"list",z=(0,$a.useRef)(k);(0,$a.useEffect)(()=>{z.current!==k&&(z.current=k,window.scrollTo(0,0))},[k]);let A=U=>{if(!p)return;w("estimate_completed",{calculator:p.id,lines:U.length});let R=Bv(p.id,U);R?u(R,U[0]?.calculatorWasteIncluded??!1):c(U)};return(0,ze.jsx)(tl.Provider,{value:w,children:(0,ze.jsx)("div",{ref:h,className:`app-wrapper${e?"":" app-wrapper--embedded"}${t?" app-wrapper--no-header":""}${a?"":" estimating-tools--customer"}`,style:Ot().theme,children:(0,ze.jsx)("main",{className:"main-content",children:r?(0,ze.jsx)(ul,{cart:m,onUpdateQty:g,onUpdateSellUnits:d,onResolveConversions:b,onRemove:v,onBack:()=>i(!1),onStartNewQuote:()=>{E(),o(null),c(null),i(!1)},internal:a}):O&&p?(0,ze.jsx)(s0,{toolTitle:p.title}):p?(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)("div",{hidden:l!==null,children:(0,ze.jsx)(p.Component,{onBack:()=>o(null),onReview:A})}),f&&(0,ze.jsx)("p",{className:"results-empty-hint estimator-products__error",children:f}),l!==null&&(0,ze.jsx)(fm,{toolId:p.id,toolTitle:p.title,requirements:l,onBack:()=>c(null)})]}):(0,ze.jsx)(ze.Fragment,{children:(0,ze.jsxs)("div",{className:"quick-order-card",children:[(0,ze.jsxs)("div",{className:"quick-order-hero",children:[(0,ze.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,ze.jsx)("h1",{children:"Estimating Tools"}),(0,ze.jsx)("p",{children:"Trade-specific calculators for trusses, fencing, decking, masonry and painting. Dial in your specs and get an instant material estimate."})]}),(0,ze.jsxs)("div",{className:"quick-order-alt",children:[(0,ze.jsx)("div",{className:"quick-order-alt-title",children:"Choose a Calculator"}),(0,ze.jsx)("div",{className:"estimator-tools-grid",children:um.map(U=>(0,ze.jsxs)("button",{type:"button",className:"estimator-tool-card",onClick:()=>{w("calculator_selected",{calculator:U.id}),o(U.id),c(null)},children:[(0,ze.jsx)("span",{className:"estimator-tool-card__image-wrap",children:(0,ze.jsx)("img",{className:"fill-img estimator-tool-card__image",src:It(U.imageUrl),alt:""})}),(0,ze.jsxs)("span",{className:"estimator-tool-card__content",children:[(0,ze.jsx)("span",{className:"estimator-tool-card__title",children:U.title}),(0,ze.jsx)("span",{className:"estimator-tool-card__desc",children:U.desc})]})]},U.id))})]})]})})})})})}var qc=$(F());function hm({config:e,children:t}){return vw(e),(0,qc.jsx)(qc.Fragment,{children:t})}var gm=$(F()),Ux="https://api.metronlabs.ai",Dx=["client","api-key","api-url","theme","hide-header","analytics"],Ox=["all","events-only","none"];function p0(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.69",this.id||(this.id=e),this.setAttribute("data-turbo-permanent",""),this.setAttribute("data-turbolinks-permanent",""),!this.root){let i=document.createElement("div"),n=document.createElement("style");n.textContent=`:host { display: block; }
|
|
6974
|
+
C24 timber 4.8m`,value:d,onChange:Z=>b(Z.target.value),"aria-label":"Paste schedule line items"}),R&&(0,J.jsxs)("div",{className:"error-box",role:"alert",children:[(0,J.jsx)("strong",{children:"Error:"})," ",R]}),(0,J.jsxs)("div",{className:"quick-order-hint",children:[(0,J.jsx)("strong",{children:"Tip:"}),'\xA0Paste one line per item. Include a count, e.g. "x10", to help us find the right stock and pricing.']}),(0,J.jsx)("div",{className:"quick-order-actions",children:(0,J.jsxs)("button",{type:"button",className:"cta-btn",disabled:!U||!!R,onClick:()=>{l("list_submitted",{method:"paste",lines:U}),Ne(()=>e(d))},"aria-label":"Match pasted lines",children:[(0,J.jsx)("span",{children:"Match line items"}),(0,J.jsx)("span",{className:"arrow",children:(0,J.jsx)(Qt,{})})]})})]}):(0,J.jsxs)(J.Fragment,{children:[O&&(0,J.jsxs)("div",{className:"error-box",role:"alert",children:[(0,J.jsx)("strong",{children:"Error:"})," ",O]}),(0,J.jsxs)("div",{className:`upload-zone${v?" has-file":""}`,onClick:()=>o.current?.click(),onDragOver:Z=>Z.preventDefault(),onDrop:Nt,role:"button",tabIndex:0,onKeyDown:Z=>(Z.key==="Enter"||Z.key===" ")&&o.current?.click(),"aria-label":"Upload zone: click or drag a list or image file here",children:[z?(0,J.jsx)("img",{src:z,alt:v?.name??"Selected photo",className:"upload-zone-photo-preview"}):(0,J.jsx)("div",{className:"upload-zone-icon",children:(0,J.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,J.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,J.jsx)("polyline",{points:"14,2 14,8 20,8"}),(0,J.jsx)("polyline",{points:"9,15 11,17 15,13"})]})}),v?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("div",{className:"upload-zone-subtext",children:v.name}),(0,J.jsx)("button",{type:"button",className:"link-btn link-btn--underline",onClick:Z=>{Z.stopPropagation(),E(null),f(""),o.current&&(o.current.value="")},children:"Remove"})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("div",{className:"upload-zone-text",children:"Drop a photo, spreadsheet, Word document or PDF"}),(0,J.jsx)("div",{className:"upload-zone-subtext",children:"or click to choose a file"})]}),(0,J.jsx)("input",{ref:o,type:"file",accept:C_,className:"visually-hidden",onChange:Z=>Ve(Z.target.files),tabIndex:-1,"aria-hidden":"true"})]}),(0,J.jsx)("div",{className:"quick-order-actions",children:(0,J.jsxs)("button",{type:"button",className:"cta-btn",disabled:!v,onClick:()=>{we()},"aria-label":"Match uploaded items",children:[(0,J.jsx)("span",{children:"Match items"}),(0,J.jsx)("span",{className:"arrow",children:(0,J.jsx)(Qt,{})})]})})]})}),(0,J.jsx)("aside",{className:"quick-order-sidebar",children:q_[m].map((Z,ge)=>(0,J.jsxs)("div",{className:"quick-order-step quick-order-step--rail",children:[(0,J.jsx)("span",{className:"quick-order-step-dot",children:ge+1}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"quick-order-step-title",children:Z.title}),(0,J.jsx)("div",{className:"quick-order-step-desc",children:Z.desc})]})]},Z.title))})]}),u&&(0,J.jsx)("div",{className:"quick-order-matching-overlay",children:(0,J.jsx)(hv,{})})]})]})})]})]})}var Rt=$(He()),yv=$(F());function Un(e){return JSON.stringify([e.productId,e.qty,e.unit,e.linkedContext??[]])}function E_(e,t){let a={...e,[t.lineId]:t};for(let[r,i]of Object.entries(a)){if(!i.linkedContext)continue;let n=i.linkedContext.find(l=>l.role==="anchor"&&l.line_id&&a[l.line_id]),o=n?.line_id?a[n.line_id]:void 0;if(!(!n||!o||n.product_id===o.productId&&n.description===o.description)){if(i.conversionType!=="basket_line_unit"){a[r]={...i,linkedContext:i.linkedContext.map(l=>l.line_id===n.line_id?{...l,product_id:o.productId,measurements_mm:o.measurementsMm??[],description:o.description}:l)};continue}a[r]={...i,qty:0,sellUnitsOverride:null,linkedContext:i.linkedContext.map(l=>l.line_id===n.line_id?{...l,product_id:o.productId,measurements_mm:o.measurementsMm??[],description:o.description}:l),conversionType:null,requestUomsSupported:null,salesUomNormalised:null,salesUnitSize:null,salesUnitSizeUom:null,coverageQty:null,coverageUom:null,roundingRule:null,conversionConfidence:null,conversionNotes:null}}}return a}var qd=(0,Rt.createContext)(null);function lc({children:e,onOpenBasket:t}){let[a,r]=(0,Rt.useState)({}),i=(0,Rt.useCallback)(d=>{r(b=>E_(b,d))},[]),n=(0,Rt.useCallback)(d=>{r(b=>{let v={...b};for(let E of d)v[E.lineId]=E;return v})},[]),o=(0,Rt.useCallback)(d=>{r(b=>{let v={...b};return delete v[d],v})},[]),l=(0,Rt.useCallback)((d,b)=>{r(v=>v[d]?{...v,[d]:{...v[d],qty:b,sellUnitsOverride:null}}:v)},[]),c=(0,Rt.useCallback)((d,b)=>{r(v=>v[d]?{...v,[d]:{...v[d],sellUnitsOverride:b}}:v)},[]),p=(0,Rt.useCallback)(d=>{r(b=>{let v=!1,E={...b};for(let[O,f]of Object.entries(d))E[O]&&(E[O]={...E[O],...f},v=!0);return v?E:b})},[]),m=(0,Rt.useCallback)(()=>r({}),[]),g=(0,Rt.useMemo)(()=>({cart:a,count:Object.keys(a).length,addToCart:i,addManyToCart:n,removeFromCart:o,updateCartQty:l,updateCartSellUnits:c,updateCartConversions:p,clearCart:m,openBasket:t??(()=>{})}),[a,i,n,o,l,c,p,m,t]);return(0,yv.jsx)(qd.Provider,{value:g,children:e})}function Dn(){let e=(0,Rt.useContext)(qd);if(!e)throw new Error("useCart must be used inside a <CartProvider>");return e}function vv(){return(0,Rt.useContext)(qd)}var dt=$(He());function vi(e){return e===0?"-":Number.isInteger(e)?e.toString():e<1?e.toFixed(2):e.toFixed(1)}function nt(e){return`\xA3${e.toLocaleString("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2})}`}var Nv=e=>(e??"").trim().toLowerCase(),M_={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",piece:"each",pieces:"each",board:"sheet",bags:"bag",length:"length",lengths:"length",pallet:"pallet",pallets:"pallet"},Ed=new Set(["sheet","length","box","bag","pack","roll","set","tub","each"]),_v=new Set(["box","bag","pack","pallet","roll","set","tub"]),Md=(e,t)=>t==="ml"?e:["l","litre","litres"].includes(t)?e*1e3:null,Td=(e,t)=>t==="g"?e:["kg","kilogram","kilograms"].includes(t)?e*1e3:["t","tonne","tonnes"].includes(t)?e*1e6:null,mr=e=>{let t=Nv(e);return M_[t]??t},at=(e,t)=>{let a=mr(e),r=mr(t);return a.length>0&&a===r},xv=(e,t)=>{let a=Nv(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},T_=e=>(e??"").split(",").map(t=>mr(t)).filter(Boolean),z_=(e,t)=>{let a=T_(e.requestUomsSupported);return!!(a.length===0||a.includes(t)||at(t,"pallet")&&e.itemsPerPallet!=null&&e.itemsPerPallet>0||at(t,"pack")&&e.itemsPerPack!=null&&e.itemsPerPack>0||at(t,"box")&&e.itemsPerBox!=null&&e.itemsPerBox>0)},kv=(e,t)=>at(t,"pallet")?e.itemsPerPallet??null:at(t,"pack")?e.itemsPerPack??null:at(t,"box")?e.itemsPerBox??null:null,Sv=(e,t)=>{let a=t==="volume"?/(\d+(?:[.,]\d+)?)\s*(ml|l|ltr|ltrs|litres?|liters?)\b/i:/(\d+(?:[.,]\d+)?)\s*(kg|kgs|tonnes?)\b/i,r=e.description.match(a);if(!r)return null;let i=Number.parseFloat(r[1].replace(",","."));if(!Number.isFinite(i)||i<=0)return null;let n=r[2].toLowerCase();return t==="volume"?{ml:n==="ml"?i:i*1e3}:{g:n.startsWith("tonne")?i*1e6:i*1e3}},R_=["volume_from_description","same_unit_volume"],A_=["weight_from_description","mass_from_pack","same_unit_mass"],U_=(e,t,a)=>{if(!at(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||!at(r[3],a))return null;let i=Number.parseFloat(r[1].replace(",","."));return Number.isFinite(i)&&i>0?i:null};function sc(e,t){let a=e.map(r=>Ft(r,t).lineTotal);return a.some(r=>r==null)?null:a.reduce((r,i)=>r+(i??0),0)}function Ft(e,t){let a=e.qty,r=mr(e.saleUnit??e.salesUnitSizeUom??e.uoi??e.salesUomNormalised)||"-",i=mr(e.unit)||(a>0&&Ed.has(r)?r:"-"),n=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?Ed.has(r)?Math.ceil(e.sellUnitsOverride):e.sellUnitsOverride:null,p=R=>({requestedAmount:a,requestedUnit:i,salesUnitSize:e.salesUnitSize??e.uoiCount??null,sellUnit:r,calculatedSellUnits:null,requiredSellUnits:c,unitPrice:e.price,lineTotal:e.price!=null&&c!=null?e.price*c:null,calculation:c!=null?`${R} Order quantity set to ${c} ${r}.`:R,costingMode:"review"});if(!Number.isFinite(a)||a<=0)return p("Quantity needs confirmation.");let m=Md(a,i),g=Td(a,i),d=at(i,r)?null:m!=null&&!R_.includes(e.conversionType??"")?Sv(e,"volume"):g!=null&&!A_.includes(e.conversionType??"")?Sv(e,"weight"):null,b=d?.ml!=null?m:g,v=d?.ml??d?.g??null;if(b!=null&&v!=null){let R=mr(e.uoi)||r,H=d?.ml!=null?`${v/1e3} l`:`${v/1e3} kg`,oe=l?c:Math.ceil(b*(1+o)/v-1e-9);return{requestedAmount:a,requestedUnit:i,salesUnitSize:1,sellUnit:R,calculatedSellUnits:oe,requiredSellUnits:oe,unitPrice:e.price,lineTotal:e.price!=null?e.price*oe:null,calculation:`${a} ${i}${o>0?` x ${1+o}`:""} / ${H} per ${R} (from product description) = ${oe} ${R}`,costingMode:"derived"}}if(i==="sales_unit"){let R=mr(e.uoi)||r,H=l?c:xv(a*(1+o),e.roundingRule??"round_up_each");return{requestedAmount:a,requestedUnit:R,salesUnitSize:1,sellUnit:R,calculatedSellUnits:H,requiredSellUnits:H,unitPrice:e.price,lineTotal:e.price!=null?e.price*H:null,calculation:`${a} ${R}${o>0?` x ${1+o}`:""} = ${H} ${R}`,costingMode:"direct"}}if(!z_(e,i))return p("Requested unit is not supported by this catalogue conversion.");let E=null,O="review",f=e.roundingRule,u=`Quantity review required, initial request needed ${a} ${i}.`,h=1+o,w=U_(e,i,r),k=e.unitConversions?.find(R=>at(R.requestUom,i));if(!!e.saleUnit&&(at(i,r)||!!k||at(i,"each")&&!_v.has(r)))if(at(i,r))E=a*h/n,O="direct",u=`${a} ${i}${o>0?` x ${h}`:""}`;else if(k){E=a*h/k.quantityPerSaleUnit,O="derived";let R=1/k.quantityPerSaleUnit,H=Math.round(R);u=at(r,"each")&&k.quantityPerSaleUnit<1&&Math.abs(R-H)<1e-9?`${a} ${i}${o>0?` x ${h}`:""} x ${H} per ${i}`:`${a} ${i}${o>0?` x ${h}`:""} / ${k.quantityPerSaleUnit} ${i} per ${r}`}else at(i,"each")&&!_v.has(r)&&(E=a*h/n,O="derived",u=`${a} ${r}${o>0?` x ${h}`:""}`);else if(at(i,r)&&n>0)E=a*h/n,O="direct",u=o>0?`${a} ${i} x ${h} / ${n} ${r} per sell unit`:`${a} ${i} / ${n} ${r} per sell unit`;else if(at(i,"each")&&n>0&&Ed.has(r))E=a*h/n,O="derived",u=o>0?`${a} each x ${h} / ${n} each per ${r}`:`${a} each / ${n} each per ${r}`;else if(kv(e,i)!=null&&n>0){let R=kv(e,i)??0;E=a*R*h/n,O="derived";let H=`${a} ${i} x ${R} each${o>0?` x ${h}`:""}`;u=n===1&&at(r,"each")?H:`${H} / ${n} each per ${r}`}else if(w!=null)E=a*h/w,O="derived",f??(f="round_up_each"),u=`${a} m2 x ${h} / ${w} m2 per ${r} (from product description)`;else if(e.conversionType==="basket_line_unit")n>0&&(E=a*h/n,O="derived",u=`${a} ${i}${o>0?` x ${h}`:""} / ${n} ${i} per ${r}`);else{if(e.conversionType==="count_only")return p(`Quantity review required, initial request needed ${a} ${i}.`);if(["area_from_dims","explicit_coverage_area","roll_area"].includes(e.conversionType??"")){let R=e.coverageQty??e.derivedCoverageM2??null;at(i,"m2")&&R!=null&&R>0&&(E=a*h/R,O="derived",u=`${a} m2 x ${h} / ${R} m2 per ${r}`)}else if(e.conversionType==="count_per_area"){let R=e.coverageQty??null;at(i,"m2")&&R!=null&&R>0?(E=a/R,O="derived",u=`${a} m2 / ${R} m2 per sell unit`):at(i,"m2")&&e.itemsPerM2!=null&&e.itemsPerM2>0&&n>0&&(E=a*e.itemsPerM2*h/n,O="derived",u=`${a} m2 x ${e.itemsPerM2} ${r}/m2 x ${h} / ${n}`)}else if(e.conversionType==="length_from_dims"){let R=e.coverageQty??e.derivedLengthM??null;at(i,"m")&&R!=null&&R>0&&(E=a*h/R,O="derived",u=`${a} m x ${h} / ${R} m per ${r}`)}else if(e.conversionType==="volume_from_description"){let R=Md(a,i),H=Md(e.coverageQty??0,mr(e.coverageUom));R!=null&&H!=null&&H>0&&(E=R*h/H,O="derived",u=`${a} ${i} x ${h} / ${e.coverageQty} ${e.coverageUom} per ${r}`)}else if(e.conversionType==="weight_from_description"||e.conversionType==="mass_from_pack"){let R=mr((e.coverageUom??"").split(" ")[0]),H=Td(a,i),oe=Td(e.coverageQty??0,R);H!=null&&oe!=null&&oe>0&&(E=H*h/oe,O="derived",u=`${a} ${i} x ${h} / ${e.coverageQty} ${R} per ${r}`)}else if(e.conversionType==="same_unit_volume"){let R=e.coverageQty??null;at(i,"m3")&&R!=null&&R>0&&(E=a/R,O="derived",u=`${a} m3 / ${R} m3 per ${r}`)}}if(E==null||!Number.isFinite(E)||E<0)return p(`Quantity review required, initial request needed ${a} ${i}.`);let A=xv(E,f),U=l?c:A;return{requestedAmount:a,requestedUnit:i,salesUnitSize:n,sellUnit:r,calculatedSellUnits:A,requiredSellUnits:U,unitPrice:e.price,lineTotal:e.price!=null&&U!=null?e.price*U:null,calculation:l?`${u} = ${A} ${r} (manually set to ${U})`:`${u} = ${U} ${r}`,costingMode:O}}var nl=$(F());function zd({unit:e}){return(0,nl.jsx)(nl.Fragment,{children:e.split(/([²³])/).map((t,a)=>t==="\xB2"||t==="\xB3"?(0,nl.jsx)("span",{className:"unit-sup",children:t},a):t)})}var Cv=$(F());function D_(e,t){return t===1||/^m\d*$/i.test(e)?e:/(s|x|z|ch|sh)$/i.test(e)?`${e}es`:/[^aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:`${e}s`}function _a(e,t){let a=(e??"").trim();if(!a||a==="-")return"";let r=/^each$/i.test(a)?"unit":a;return t!=null?D_(r,t):r}function xa(e,t){let a=_a(e,t);return a?(0,Cv.jsx)(zd,{unit:a}):null}function ol(e){let t=(e??"").trim();if(!t)return"";let a=t.match(/^per\s+(.+)$/i);if(!a)return t;let r=_a(a[1]);return r?`per ${r}`:""}var qv=()=>import("./xlsx-K4MOA2QM.js"),sl=["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","Review required","Decision reason","Selected candidate ID","Selected candidate description","Price basis","Price","Line total","Confidence","Status"],O_=sl.indexOf("Line total");function B_(e){return e.unmatchable?"Not matched (labour/plant/referential)":e.best?"Selected":"Needs review"}async function Ev(e){let t=await qv(),a=t.utils.book_new(),r=new Date().toISOString().slice(0,10),i=[sl],n=0;for(let c of e){let{item:p,best:m,qty:g,band:d,unmatchable:b,decision:v}=c,E=[p.section,p.subsection,p.subheading].filter(Boolean).join(" / "),O=!b&&m?.price!=null?m.price*g:null;O!=null&&(n+=O),i.push([p.source_line_id,p.line_id,p.description_original||"(no description)",E,g,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(", "),m?"no":"yes",v?.reason??"",b?"-":m?.product_id??v?.selected_candidate_id??"-",b?"-":m?.description??"-",b?"-":m?.price_basis??"-",b?null:m?.price??null,O,b?"-":d,B_(c)])}i.push(Array(sl.length).fill(null));let o=Array(sl.length).fill(null);o[0]="Estimated total",o[O_]=n,i.push(o),i.push(["DISCLAIMER: These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence.",...Array(sl.length-1).fill(null)]);let l=t.utils.aoa_to_sheet(i);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 ll=["Product ID","Description","Costing mode","Required amount","Req unit","Sell unit size","Sell unit","Required sell units","Unit price","Line total"];async function Mv(e,t){let a=await qv(),r=a.utils.book_new(),i=new Date().toISOString().slice(0,10),n=t?[["Account",t.name+" ("+t.id+")"],[],ll]:[ll],o=0;for(let p of e){let m=Ft(p),g=m.lineTotal;g!=null&&(o+=g),n.push([p.productId,p.description,m.costingMode,m.requestedAmount,_a(m.requestedUnit),m.salesUnitSize,_a(m.sellUnit),m.requiredSellUnits,m.unitPrice,g])}n.push(Array(ll.length).fill(null));let l=Array(ll.length).fill(null);l[0]="Estimated total",l[ll.length-1]=o,n.push(l);let c=a.utils.aoa_to_sheet(n);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}-${i}.xlsx`:`basket-${i}.xlsx`)}var Rd=$(F());function Vr(){return(0,Rd.jsx)("svg",{className:"back-arrow",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Rd.jsx)("path",{d:"M13 8H3M3 8L7 4M3 8L7 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var Ad=$(F());function yi(){return(0,Ad.jsx)("svg",{width:"8",height:"5",viewBox:"0 0 8 5",fill:"none",children:(0,Ad.jsx)("path",{d:"M1 4L4 1L7 4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}var _i=$(F());function Ud(){return(0,_i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,_i.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,_i.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,_i.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,_i.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}var ja=$(F());function Dd(e){return(0,ja.jsxs)("svg",{viewBox:"0 0 640 420",preserveAspectRatio:"xMidYMid slice",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",...e,children:[(0,ja.jsx)("rect",{width:"640",height:"420",fill:"#fbf1cf"}),(0,ja.jsx)("rect",{x:"88",y:"78",width:"432",height:"264",rx:"16",fill:"#f0c43f"}),(0,ja.jsx)("rect",{x:"120",y:"110",width:"368",height:"200",rx:"10",fill:"#ffd95e"}),(0,ja.jsxs)("g",{stroke:"#e2b12e",strokeWidth:"8",opacity:"0.75",children:[(0,ja.jsx)("line",{x1:"140",y1:"140",x2:"468",y2:"140"}),(0,ja.jsx)("line",{x1:"140",y1:"190",x2:"468",y2:"190"}),(0,ja.jsx)("line",{x1:"140",y1:"240",x2:"468",y2:"240"})]})]})}var Xr=$(F());function Od(e){return(0,Xr.jsxs)("svg",{viewBox:"0 0 640 420",preserveAspectRatio:"xMidYMid slice",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",...e,children:[(0,Xr.jsx)("rect",{width:"640",height:"420",fill:"#edf1f5"}),(0,Xr.jsx)("rect",{x:"132",y:"108",width:"376",height:"204",rx:"18",fill:"#d5dde6"}),(0,Xr.jsx)("rect",{x:"168",y:"144",width:"304",height:"24",rx:"12",fill:"#9aa6b2"}),(0,Xr.jsx)("rect",{x:"168",y:"188",width:"250",height:"24",rx:"12",fill:"#aab5c0"}),(0,Xr.jsx)("rect",{x:"168",y:"232",width:"220",height:"24",rx:"12",fill:"#aab5c0"})]})}var Bd=$(F()),L_=[{match:["building sand"],path:"/schedule-products/building-sand.webp"},{match:["drywall screw"],path:"/schedule-products/drywall-screws.webp"},{match:["scrim"],path:"/schedule-products/scrim-tape.webp"},{match:["loft insulation","loft roll"],path:"/schedule-products/loft-insulation-roll.webp"},{match:["wall tie"],path:"/schedule-products/wall-ties.webp"},{match:["red multi","multi stock","brick"],path:"/schedule-products/red-multi-stock-bricks.webp"}];function za({description:e,photoUrl:t,className:a,width:r,height:i}){let n=(e||"").toLowerCase(),o=L_.find(p=>p.match.some(m=>n.includes(m))),l=t||o&&It(o.path);if(l)return(0,Bd.jsx)("img",{className:a,src:l,alt:"",width:r,height:i});let c=n.includes("insulation")?Dd:Od;return(0,Bd.jsx)(c,{className:a,width:r,height:i})}var M=$(F()),Tv=.2,cl=10,zv="Enter a valid email address so we can send your quote.",H_=(e,t)=>{let a=`${t.requestedAmount} ${_a(t.requestedUnit,t.requestedAmount)}`,r=`${t.requiredSellUnits} ${_a(t.sellUnit,t.requiredSellUnits??0)}`,i=e.unitConversions?.find(n=>n.requestUom===t.requestedUnit);return i&&i.quantityPerSaleUnit<1?`${a} requested \u2192 order ${r} (${Math.round(1/i.quantityPerSaleUnit)} ${_a(t.sellUnit,2)} per ${_a(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}`},Q_=e=>["box","pack"].includes(e.requestedUnit)?"Pack size needed to calculate the order quantity.":`This product is sold by ${_a(e.sellUnit,1)}.`;function ul({cart:e,onUpdateQty:t,onUpdateSellUnits:a,onResolveConversions:r,onRemove:i,onBack:n,onStartNewQuote:o,onQuoteRequested:l,internal:c=!1}){let p=(0,dt.useId)(),m=En(),g=!c&&Is()==="QZA6-MRA4",d=!c,b=Object.values(e),v=(0,dt.useRef)(new Map),[E,O]=(0,dt.useState)(""),[f,u]=(0,dt.useState)(!1),[h,w]=(0,dt.useState)(!1),[k,z]=(0,dt.useState)(""),[A,U]=(0,dt.useState)({}),[R,H]=(0,dt.useState)({}),[oe,Te]=(0,dt.useState)(1),[je,Ve]=(0,dt.useState)({}),[Ne,we]=(0,dt.useState)(!1),[le,Fe]=(0,dt.useState)("0"),[Ee,Nt]=(0,dt.useState)({});(0,dt.useEffect)(()=>{if(!r)return;for(let D of Object.values(e))Ft(D).requiredSellUnits!=null&&v.current.delete(D.lineId);let _=Object.values(e).filter(D=>{if(D.productId==="-"||Ft(D).requiredSellUnits!=null)return!1;let V=Un(D);return v.current.get(D.lineId)===V?!1:(v.current.set(D.lineId,V),!0)});if(_.length===0)return;let q=new Map(_.map(D=>[D.lineId,Un(D)]));Nt(D=>({...D,...Object.fromEntries(q)})),fetch(Ta("/api/catalogue/resolve-conversions"),{method:"POST",headers:{"Content-Type":"application/json",...Mn()},body:JSON.stringify({lines:_.map(D=>({line_id:D.lineId,product_id:D.productId,requested_description:D.requestedDescription??D.description,requested_qty:D.qty,requested_uom:D.unit||null,linked_context:D.linkedContext??[],selected_description:D.description,selected_uoi:D.uoi,selected_uoi_count:D.uoiCount,selected_conversion:{sales_uom_normalised:D.salesUomNormalised,conversion_type:D.conversionType,sales_unit_size:D.salesUnitSize,sales_unit_size_uom:D.salesUnitSizeUom,coverage_qty:D.coverageQty,coverage_uom:D.coverageUom}}))})}).then(D=>D.ok?Ga(D):null).then(D=>{let V={},N=new Map(_.map(L=>[L.lineId,Un(L)]));for(let L of D?.data?.items??D?.items??[]){let X=L?.conversion;!X||typeof L?.line_id!="string"||v.current.get(L.line_id)!==N.get(L.line_id)||(V[L.line_id]={conversionConfidence:X.conversion_confidence,conversionNotes:X.conversion_notes,...Number.isFinite(X.suggested_order_qty)&&X.suggested_order_qty>0?{sellUnitsOverride:X.suggested_order_qty}:{}})}Object.keys(V).length>0&&r(V)}).catch(D=>console.error("Catalogue conversion resolution failed",D)).finally(()=>{Nt(D=>{let V={...D};for(let[N,L]of q)V[N]===L&&delete V[N];return V})})},[e,r]);function Z(_){U(q=>{let D={...q};return delete D[_],D})}function ge(_,q){let D=parseFloat(q);!isNaN(D)&&D>=0&&t(_,Math.min(D,1e5)),Z(_)}function Re(_,q,D){t(_,Math.min(1e5,Math.max(0,q+D))),Z(_)}function bt(_){H(q=>{let D={...q};return delete D[_],D})}function jt(_,q){let D=parseFloat(q);!isNaN(D)&&D>=0&&a(_,Math.min(D,1e5)),bt(_)}function Ct(_,q,D){a(_,Math.min(1e5,Math.max(0,q+D))),bt(_)}async function wt(){if(be.some(({pricing:q})=>q.lineTotal==null)){z(g?"Confirm the highlighted quantities before requesting a quote.":"Confirm the highlighted quantities before sending your basket.");return}let _=E.trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_)){z(zv);return}z(""),w(!0);try{let q=await fetch(Ta("/api/quote-requests"),{method:"POST",headers:{"Content-Type":"application/json",...Mn()},body:JSON.stringify({email:_,items:be.map(({item:D,pricing:V})=>{let N=V.requiredSellUnits??V.requestedAmount,L=V.requiredSellUnits!=null?V.sellUnit:V.requestedUnit;return{product_id:D.productId,description:D.description,quantity:N,unit:_a(L,N),unit_price:V.requiredSellUnits!=null?V.unitPrice:null,line_total:V.lineTotal}})})});if(!q.ok){let D=await Ga(q);console.error("Quote request failed",q.status,D?.message),z(q.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}T!=null&&m("quote_requested",{items:be.length,total:Math.round(T*100)/100}),u(!0),l?.(),window.scrollTo(0,0)}catch{z("Your request couldn't be sent. Check your connection and try again.")}finally{w(!1)}}let be=b.map(_=>({item:_,pricing:Ft(_,{wasteFactorEnabled:Ne,wasteFactorOverride:Math.max(0,Number.parseFloat(le)||0)/100})})),de=sc(b,{wasteFactorEnabled:Ne,wasteFactorOverride:Math.max(0,Number.parseFloat(le)||0)/100}),tt=de==null?null:de*Tv,T=de==null?null:de*(1+Tv),G=be.filter(({pricing:_})=>_.lineTotal==null).length,ie=Object.keys(Ee).length,ce=!!r&&b.some(_=>{if(_.productId==="-"||Ft(_).requiredSellUnits!=null)return!1;let q=Un(_);return v.current.get(_.lineId)!==q||Ee[_.lineId]===q}),ve=(0,dt.useRef)({items:be.length,...T==null?{}:{total:Math.round(T*100)/100}});(0,dt.useEffect)(()=>{m("basket_viewed",ve.current)},[m]);let Ye=Math.max(1,Math.ceil(be.length/cl)),qe=Math.min(oe,Ye),x=be.slice((qe-1)*cl,qe*cl);return f?(0,M.jsx)("div",{className:"wizard-step entry-stage",children:(0,M.jsxs)("div",{className:"quote-request-sent",role:"status",children:[(0,M.jsx)("div",{className:"quote-request-sent-icon","aria-hidden":"true",children:(0,M.jsx)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,M.jsx)("polyline",{points:"5 12.5 10 17.5 19 7"})})}),(0,M.jsx)("h1",{children:g?"Quote requested":"Basket sent"}),g?(0,M.jsxs)("p",{children:["You're all done. We'll email your sharper price to ",(0,M.jsx)("strong",{children:E.trim()}),", usually within one working day."]}):(0,M.jsxs)("p",{children:["You're all done. We'll email ",(0,M.jsx)("strong",{children:E.trim()})," to confirm prices, availability and delivery, usually within one working day."]}),(0,M.jsx)("button",{type:"button",className:"cta-btn",onClick:o,children:(0,M.jsx)("span",{children:g?"Start a new quote":"Start a new basket"})}),(0,M.jsx)("p",{className:"quote-request-sent-note",children:g?"Nothing is charged until you approve the quote.":"Nothing is charged until you approve the order."})]})}):!c&&b.length===0?(0,M.jsx)("div",{className:"wizard-step entry-stage",children:(0,M.jsxs)("div",{className:"quote-request-sent",children:[(0,M.jsx)("div",{className:"quote-request-sent-icon","aria-hidden":"true",children:(0,M.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,M.jsx)("path",{d:"M3 9h18l-2 11H5z"}),(0,M.jsx)("path",{d:"M8 9l4-6 4 6"})]})}),(0,M.jsx)("h1",{children:g?"Your quote request is empty":"Your basket is empty"}),(0,M.jsx)("p",{children:g?"Start again with your list to build your quote.":"Start again with your list to fill your basket."}),(0,M.jsx)("button",{type:"button",className:"cta-btn",onClick:o,children:(0,M.jsx)("span",{children:"Back to start"})})]})}):(0,M.jsx)("div",{className:`wizard-step entry-stage${g?" basket-layout--qza6-mra4":""}`,children:(0,M.jsxs)("div",{className:`quick-order-card${c?"":" quick-order-card--customer"}`,children:[(0,M.jsxs)("div",{className:`quick-order-hero${c?"":" quick-order-hero--customer"}`,children:[c&&(0,M.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,M.jsxs)("div",{className:"basket-hero-copy",children:[g&&(0,M.jsxs)("button",{type:"button",className:"cta-btn cta-btn-secondary basket-hero-back",onClick:n,children:[(0,M.jsx)(Vr,{}),(0,M.jsx)("span",{children:"Back to results"})]}),(0,M.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,M.jsx)("h1",{children:c?"Your Selection":g?"Request a quote":"Your Basket"}),c&&(0,M.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,M.jsx)("strong",{children:b.length})," ",b.length===1?"item":"items"]})]}),(0,M.jsx)("p",{children:c?"Review the items you've added before exporting them for review.":g?"Check your items and quantities below, and we'll do our best to beat list prices.":"Review your quantities and order summary, then send us your basket."})]})]}),(0,M.jsx)("div",{className:"quick-order-panel",style:{paddingTop:16},children:ce?(0,M.jsxs)("div",{className:"basket-resolving",role:"status","aria-label":"Calculating order quantities",children:[(0,M.jsx)("span",{className:"basket-resolving-wheel","aria-hidden":"true"}),(0,M.jsx)("span",{children:"Calculating your quantities\u2026"})]}):b.length===0?(0,M.jsxs)("div",{className:"quick-order-history-empty",children:[(0,M.jsx)("div",{className:"basket-empty-icon","aria-hidden":"true",children:"\u{1F4CB}"}),(0,M.jsx)("p",{children:"Your selection is empty."}),(0,M.jsx)("p",{className:"basket-empty-hint",children:"Go back to your results and add quoted items."}),(0,M.jsx)("div",{className:"btn-row",style:{marginTop:20,justifyContent:"center"},children:(0,M.jsx)("button",{className:"cta-btn",style:{width:"auto",maxWidth:280},onClick:n,"aria-label":"Back to results",children:(0,M.jsx)("span",{children:"Back to Results"})})})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)("div",{className:"basket-layout",children:[(0,M.jsxs)("div",{className:"basket-main",children:[(0,M.jsx)("div",{className:"basket-list","aria-label":c?"Selection items":g?"Quote request items":"Basket items",children:x.map(({item:_,pricing:q})=>{let D=A[_.lineId]??String(q.requestedAmount),V=q.requestedUnit===q.sellUnit||q.costingMode==="review",N=q.requiredSellUnits==null||q.requestedAmount!==q.requiredSellUnits||q.requestedUnit!==q.sellUnit;return(0,M.jsxs)("article",{className:"basket-card",children:[(0,M.jsxs)("div",{className:"basket-card-top",children:[(0,M.jsx)(za,{className:"basket-card-thumb",description:_.description,photoUrl:_.pdpPhotoUrl,width:48,height:48}),(0,M.jsxs)("div",{className:"basket-card-info",children:[(0,M.jsx)("div",{className:"bom-component-name",children:_.description}),N&&q.costingMode!=="review"&&(0,M.jsxs)("button",{type:"button",className:"basket-calc-toggle",onClick:()=>Ve(L=>({...L,[_.lineId]:!L[_.lineId]})),"aria-expanded":!!je[_.lineId],children:["How we calculated this",(0,M.jsx)("span",{className:`basket-calc-toggle-chevron${je[_.lineId]?" basket-calc-toggle-chevron--open":""}`,children:(0,M.jsx)(yi,{})})]})]}),(0,M.jsx)("div",{className:"basket-card-actions",children:(0,M.jsx)("button",{type:"button",className:"mf-remove-small-btn basket-card-remove",onClick:()=>i(_.lineId),"aria-label":`Remove ${_.description}`,children:(0,M.jsx)(Ud,{})})})]}),c&&(0,M.jsxs)("div",{className:"results-detail-block basket-internal-detail",children:[(0,M.jsxs)("dl",{className:"results-detail-grid",children:[(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Conversion type"}),(0,M.jsx)("dd",{children:_.conversionType??"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Conversion confidence"}),(0,M.jsx)("dd",{children:_.conversionConfidence??"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Sales unit"}),(0,M.jsx)("dd",{children:_.salesUnitSize!=null?(0,M.jsxs)(M.Fragment,{children:[_.salesUnitSize," ",xa(_.salesUnitSizeUom,_.salesUnitSize)]}):"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Coverage"}),(0,M.jsx)("dd",{children:_.coverageQty!=null?(0,M.jsxs)(M.Fragment,{children:[_.coverageQty," ",xa(_.coverageUom,_.coverageQty)]}):"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Waste factor"}),(0,M.jsx)("dd",{children:_.wasteFactorDefault??"-"})]}),(0,M.jsxs)("div",{children:[(0,M.jsx)("dt",{children:"Rounding rule"}),(0,M.jsx)("dd",{children:_.roundingRule??"-"})]})]}),_.conversionNotes&&(0,M.jsx)("p",{className:"results-rerank-note",children:_.conversionNotes})]}),q.costingMode==="review"?(0,M.jsxs)("p",{className:"basket-calc-text basket-calc-text--review",children:[(0,M.jsx)("strong",{children:Ee[_.lineId]===Un(_)?"Calculating order quantity\u2026":"Quantity needs confirmation."})," ",Q_(q)]}):N&&je[_.lineId]?(0,M.jsx)("p",{className:"basket-calc-text",children:H_(_,q)}):null,(0,M.jsxs)("div",{className:"basket-card-stats",children:[(0,M.jsxs)("div",{className:"basket-stat",children:[(0,M.jsx)("span",{className:"basket-stat-label",children:"Requested qty"}),(0,M.jsxs)("div",{className:"basket-stat-value",children:[(0,M.jsxs)("div",{className:"basket-qty-field",children:[(0,M.jsx)("input",{className:"bom-qty-edit",type:"number",inputMode:"decimal",min:"0",placeholder:"-",value:D,disabled:V,onChange:L=>U(X=>({...X,[_.lineId]:L.target.value})),onBlur:L=>ge(_.lineId,L.target.value),onKeyDown:L=>{L.key==="Enter"&&L.target.blur()},"aria-label":`${_.description} requested quantity`}),(0,M.jsxs)("div",{className:"basket-qty-arrows",children:[(0,M.jsx)("button",{type:"button",className:"basket-qty-arrow",disabled:V,onClick:()=>Re(_.lineId,parseFloat(D)||0,1),"aria-label":`Increase ${_.description} quantity`,children:(0,M.jsx)(yi,{})}),(0,M.jsx)("button",{type:"button",className:"basket-qty-arrow basket-qty-arrow--down",disabled:V,onClick:()=>Re(_.lineId,parseFloat(D)||0,-1),"aria-label":`Decrease ${_.description} quantity`,children:(0,M.jsx)(yi,{})})]})]}),(0,M.jsx)("span",{className:"basket-metric-unit",children:xa(q.requestedUnit,parseFloat(D)||0)})]})]}),(0,M.jsxs)("div",{className:"basket-stat basket-stat--right",children:[(0,M.jsx)("span",{className:"basket-stat-label",children:"Order qty"}),(0,M.jsxs)("div",{className:"basket-stat-value",children:[(0,M.jsxs)("div",{className:"basket-qty-field",children:[(0,M.jsx)("input",{className:"bom-qty-edit",type:"number",inputMode:"decimal",min:"0",placeholder:"-",value:R[_.lineId]??String(q.requiredSellUnits??""),onChange:L=>H(X=>({...X,[_.lineId]:L.target.value})),onBlur:L=>jt(_.lineId,L.target.value),onKeyDown:L=>{L.key==="Enter"&&L.target.blur()},"aria-label":`${_.description} order quantity`}),(0,M.jsxs)("div",{className:"basket-qty-arrows",children:[(0,M.jsx)("button",{type:"button",className:"basket-qty-arrow",onClick:()=>Ct(_.lineId,parseFloat(R[_.lineId]??String(q.requiredSellUnits??"0"))||0,1),"aria-label":`Increase ${_.description} order quantity`,children:(0,M.jsx)(yi,{})}),(0,M.jsx)("button",{type:"button",className:"basket-qty-arrow basket-qty-arrow--down",onClick:()=>Ct(_.lineId,parseFloat(R[_.lineId]??String(q.requiredSellUnits??"0"))||0,-1),"aria-label":`Decrease ${_.description} order quantity`,children:(0,M.jsx)(yi,{})})]})]}),(0,M.jsx)("span",{className:"basket-metric-unit",children:xa(q.sellUnit,parseFloat(R[_.lineId]??String(q.requiredSellUnits??"0"))||0)})]})]}),(0,M.jsxs)("div",{className:"basket-stat basket-stat--total",children:[(0,M.jsx)("span",{className:"basket-stat-label",children:"Total"}),(0,M.jsxs)("div",{className:"basket-stat-value",children:[(0,M.jsx)("strong",{children:q.lineTotal!=null?nt(q.lineTotal):"-"}),q.lineTotal!=null&&(0,M.jsx)("span",{className:"basket-metric-unit",children:"ex. VAT"})]})]})]})]},_.lineId)})}),Ye>1&&(0,M.jsxs)("div",{className:"results-pagination",children:[(0,M.jsxs)("span",{className:"results-pagination-count",children:["Showing ",(qe-1)*cl+1,"\u2013",Math.min(qe*cl,be.length)," of ",be.length]}),(0,M.jsxs)("div",{className:"results-pagination-controls",children:[(0,M.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Te(qe-1),disabled:qe===1,children:"Previous"}),(0,M.jsxs)("span",{className:"results-pagination-page",children:["Page ",qe," of ",Ye]}),(0,M.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>Te(qe+1),disabled:qe===Ye,children:"Next"})]})]})]}),(0,M.jsxs)("aside",{className:"basket-sidebar",children:[(0,M.jsx)("div",{className:"basket-sidebar-title",children:g?"Quote request summary":"Order summary"}),(0,M.jsxs)("div",{className:"basket-sidebar-row",children:[(0,M.jsx)("span",{children:g?"List price (ex. VAT)":"Subtotal (ex. VAT)"}),(0,M.jsx)("span",{children:de==null?"To confirm":nt(de)})]}),(0,M.jsxs)("div",{className:"basket-sidebar-row",children:[(0,M.jsx)("span",{children:"VAT (20%)"}),(0,M.jsx)("span",{children:tt==null?"To confirm":nt(tt)})]}),(0,M.jsxs)("div",{className:"basket-sidebar-row basket-sidebar-row--total",children:[(0,M.jsx)("span",{children:g?"List price (inc.\xA0VAT)":"Total"}),(0,M.jsx)("span",{children:T==null?"To confirm":nt(T)})]}),!g&&(0,M.jsx)("div",{className:"basket-summary-waste",children:(0,M.jsxs)("div",{className:"basket-waste-control",children:[(0,M.jsxs)("label",{className:"basket-global-waste",children:[(0,M.jsx)("input",{type:"checkbox",checked:Ne,onChange:_=>we(_.target.checked)}),(0,M.jsx)("span",{children:"Add waste factor"})]}),(0,M.jsxs)("label",{className:"basket-global-waste-percent",children:[(0,M.jsx)("input",{type:"number",inputMode:"decimal",min:"0",step:"0.1",value:le,onChange:_=>Fe(_.target.value),disabled:!Ne,"aria-label":"Waste factor percent"}),(0,M.jsx)("span",{children:"%"})]})]})}),(0,M.jsx)("label",{htmlFor:`${p}-basket-reference`,className:"basket-sidebar-label",children:g?"Enter email for your sharper quote":d?"Your email":"Your reference (optional)"}),(0,M.jsx)("input",{id:`${p}-basket-reference`,type:d?"email":"text",className:"basket-sidebar-input",value:E,onChange:_=>{O(_.target.value),d&&z("")},placeholder:d?"you@example.com":"PO number or job reference","aria-invalid":d&&k===zv,"aria-describedby":d&&k?`${p}-basket-reference-error`:void 0}),d&&k&&(0,M.jsx)("p",{id:`${p}-basket-reference-error`,className:"basket-quote-request-error",role:"alert",children:k}),d?(0,M.jsx)("button",{type:"button",className:"cta-btn",onClick:()=>{wt()},disabled:h||G>0||ie>0,"aria-busy":h,children:(0,M.jsx)("span",{children:h?"Sending\u2026":g?"Request our best quote":"Send basket"})}):(0,M.jsx)("button",{className:"cta-btn",onClick:()=>{m("downloaded",{type:"basket",items:b.length}),Mv(b)},"aria-label":"Download selection",children:(0,M.jsx)("span",{children:"Download Quote"})}),(0,M.jsxs)("p",{className:"basket-sidebar-disclaimer",children:[(0,M.jsx)("span",{"aria-hidden":"true",children:"\u26A0\uFE0F"}),g?"This is a quote request, not an order. We'll confirm our best price, availability and delivery before you approve.":d?"Sending your basket isn't an order. We'll confirm prices, availability and delivery before you approve.":"Prices and availability are estimates and should be confirmed before procurement."]})]})]}),(0,M.jsx)("div",{className:"btn-row results-actions",children:(0,M.jsxs)("button",{className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",gap:10,justifyContent:"center"},onClick:n,"aria-label":"Back to results",children:[(0,M.jsx)(Vr,{}),(0,M.jsx)("span",{children:"Back to results"})]})})]})})]})})}var xe=$(He());function On(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,linkedContext:t.linkedContext}}var xi=$(F());function Hd(){return(0,xi.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,xi.jsx)("path",{d:"M3 12a9 9 0 0 1 15.36-6.36L21 8"}),(0,xi.jsx)("path",{d:"M21 3v5h-5"}),(0,xi.jsx)("path",{d:"M21 12a9 9 0 0 1-15.36 6.36L3 16"}),(0,xi.jsx)("path",{d:"M3 21v-5h5"})]})}var s=$(F()),jd="__none__",pl=24,G_=[{dir:"asc",label:"Description (A-Z)"},{dir:"desc",label:"Description (Z-A)"}];function Dv(e){return e==null?"low":e>=.7?"high":e>=.5?"medium":"low"}var j_=e=>e.attrs.supply_nature==="labour_only"||e.attrs.supply_nature==="plant"||e.flags.includes("referential");function Y_(e,t){if(t!==jd){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 Rv(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 $_({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 Ln(e,t){if(e==null)return"-";let a=ol(t);return a?`${e.toFixed(2)} ${a}`:e.toFixed(2)}function Yd(e){return e&&e.length>0?e.join(" x "):"-"}function V_(e){return e==null?"-":Number.isInteger(e/1e3)?`${e/1e3}m`:`${(e/1e3).toFixed(1)}m`}function Bn(e){let t=(e??[]).map(a=>a.trim()).filter(Boolean);return t.length>0?t.join(", "):"-"}function Zr(e,t){let a=typeof e.description_original=="string"?e.description_original.trim():"";return(typeof e.customer_display_label=="string"?e.customer_display_label.trim():"")||a||"(no description)"}function X_(e,t){return t>0||e==null?null:nt(e)}var Av=[{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 Z_(e){let t=new Map;return[...new Set(e.filter(Kr).map(r=>r.linked_group_id))].forEach((r,i)=>{let n=i%26;t.set(r,{token:String.fromCharCode(65+n),bubbleStyle:Av[i%Av.length]})}),t}function Kr(e){return!1}function Hn(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 Qd({meta:e}){return e?(0,s.jsx)("span",{className:"results-linked-pill",style:e.bubbleStyle,children:`Link ${e.token}`}):null}function K_(e,t,a){let r=t?.rerank?.recommendedCandidateIds??[],i=new Map(e.map(c=>[c.product_id,c])),n=r.length>0?r.map(c=>i.get(c)).filter(c=>c!=null):e.slice(0,6),o=a?i.get(a):void 0,l=o?[o,...n.filter(({product_id:c})=>c!==o.product_id)]:n;return[...new Map(l.map(c=>[c.product_id,c])).values()].slice(0,6)}function Gd(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 cc(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 P_({processStages:e,llmCalls:t,totalDurationMs:a,llmDurationMs:r,llmCallCount:i}){let n=[...t].sort((l,c)=>c.durationMs-l.durationMs).slice(0,12),o=Math.max(0,t.length-n.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:cc(a)})," total"]}),(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:i})," LLM calls"]}),(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:cc(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:cc(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:n.map((l,c)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:l.label}),(0,s.jsx)("td",{children:cc(l.durationMs)})]},`${l.key}-${c}`))})]}),o>0&&(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Showing slowest ",n.length," of ",t.length," LLM calls."]})]})]})}function J_({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,i)=>(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:Yd(r.measurements_mm)}),(0,s.jsx)("td",{children:ol(r.price_basis)||"-"}),(0,s.jsx)("td",{children:r.bm25.toFixed(2)})]},`${r.product_id}-${i}`))})]})]},`${t.query}-${a}`))]})}function Uv({item:e,result:t}){let a=t?.retrieval_debug.map(i=>i.query).filter(Boolean)??[],r=[["Procurement intent",e.procurement_intent||"-"],["Procurement aliases",Bn(e.procurement_aliases)],["Retrieval queries",Bn(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)",Yd(e.attrs.measurements_mm)],["Stock length",V_(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",Bn(e.installation_clues)],["System clues",Bn(e.system_clues)],["Component requirements",Bn(e.component_requirements)],["Linked group",Hn(e)||"-"],["Flags",Bn(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(([i,n])=>(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:i}),(0,s.jsx)("dd",{children:n})]},i))})]})}function I_({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)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:"Attempted"}),(0,s.jsx)("dd",{children:t.attempted?"yes":"no"})]}),(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:"Applied"}),(0,s.jsx)("dd",{children:t.applied?"yes":"no"})]}),(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:"Returned items"}),(0,s.jsx)("dd",{children:t.returned_item_count??"-"})]}),(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:"Reason"}),(0,s.jsx)("dd",{children:t.reason||"-"})]}),(0,s.jsxs)(xe.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 F_({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||"-"]];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,i])=>(0,s.jsxs)(xe.Fragment,{children:[(0,s.jsx)("dt",{children:r}),(0,s.jsx)("dd",{children:i})]},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 W_({item:e,decision:t,selectedProductId:a,result:r,showRetrievalDebug:i,reviewOnly:n=!1,linkedGroupMeta:o}){if(!t)return null;let l=a==null?"Needs review:":"Selected:";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:l}),"\xA0",t.reason]}),Kr(e)?(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Linked context: ",o?`Link ${o.token} - `:"",Hn(e)]}):null]}):null:!t.reason&&!i?(0,s.jsx)(Uv,{item:e,result:r}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Uv,{item:e,result:r}),i&&(0,s.jsx)(I_,{item:e}),i&&(0,s.jsx)(F_,{result:r}),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:l}),"\xA0",t.reason]}),Kr(e)?(0,s.jsxs)("p",{className:"results-row-meta",style:{marginTop:8},children:["Linked context: ",o?`Link ${o.token} - `:"",Hn(e)]}):null]}),i&&(0,s.jsx)(J_,{queries:r?.retrieval_debug??[]})]})}function ex({item:e,candidates:t,result:a,decision:r,unmatchable:i,selectedProductId:n,detailMode:o,onPick:l,onClear:c,showAll:p=!1,internal:m=!1,debugEnabled:g=!1,forceReviewNote:d=!1,linkedGroupMeta:b}){let v=m||o==="detailed",E=g&&o==="detailed",O=v||d?(0,s.jsx)(W_,{item:e,decision:r,selectedProductId:n,result:a,showRetrievalDebug:E,reviewOnly:d&&!v,linkedGroupMeta:b}):null;if(i)return(0,s.jsxs)(s.Fragment,{children:[O,(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:[O,(0,s.jsx)("p",{className:"results-empty-hint",children:"No candidates were returned for this line item."})]});let f=p||m||o==="detailed"?t:K_(t,a,n);return(0,s.jsxs)(s.Fragment,{children:[O,(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"}),E&&(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:f.map((u,h)=>{let w=u.product_id===n;return(0,s.jsxs)("tr",{className:w?"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:Yd(u.measurements_mm??u.debug?.candidate.measurements_mm)})}),(0,s.jsx)("td",{children:Ln(u.price,u.price_basis)}),E&&(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)($_,{band:Dv(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:w?"Currently selected":"Use this candidate",children:[(0,s.jsx)("input",{type:"checkbox",checked:w,onChange:()=>{w?c?.():l(u)},"aria-label":w?`${u.description} selected`:`Use ${u.description}`}),(0,s.jsx)("span",{className:"switch-toggle-track","aria-hidden":"true"})]})})]},`${u.product_id}-${h}`)})})]})]})}function $d({scheduleResult:e,onStartOver:t,cart:a,onAddToCart:r,onRemoveFromCart:i,onGoToBasket:n,cartSeeded:o,onCartSeeded:l,reviewGateComplete:c,onReviewGateComplete:p,internal:m=!1}){let g=!m&&Is()==="QZA6-MRA4",d=g?"quote":"basket",{results:b,lineItems:v,parseReport:E,timings:O}=e,[f,u]=(0,xe.useState)({}),h=En(),[w,k]=(0,xe.useState)({}),[z,A]=(0,xe.useState)({}),[U,R]=(0,xe.useState)(""),[H,oe]=(0,xe.useState)(null),[Te,je]=(0,xe.useState)(1),Ve=Ot().debug===!0,[Ne,we]=(0,xe.useState)("simple"),[le,Fe]=(0,xe.useState)(m?"list":"tile"),[Ee,Nt]=(0,xe.useState)(!1),[Z,ge]=(0,xe.useState)(null),[Re,bt]=(0,xe.useState)(""),[jt,Ct]=(0,xe.useState)([]),[wt,be]=(0,xe.useState)(!1),[de,tt]=(0,xe.useState)(null),[T,G]=(0,xe.useState)(!1),[ie,ce]=(0,xe.useState)(null),ve=(0,xe.useRef)(null),[Ye,qe]=(0,xe.useState)(new Set),[x,_]=(0,xe.useState)(new Set),[q,D]=(0,xe.useState)(!1);(0,xe.useEffect)(()=>{je(1)},[U,H,le]);let V=new Map(b.map(S=>[S.line_id,S])),N=Z_(v),L=v.map(S=>{let j=V.get(S.line_id),fe=j?.decision,ft=j_(S),Ze=f[S.line_id],Xa=Y_(j,Ze),Ai=a[S.line_id],v0=Ze===jd?void 0:w[S.line_id]??(Ai&&Ai.productId!==Xa?.product_id?Rv(Ai):Xa),Cm=ft?void 0:v0,y0=S.qty??0;return{item:S,result:j,decision:fe,unmatchable:ft,best:Cm,qty:y0,band:Dv(Cm?.scores?.overall)}}),ue=L.some(S=>!S.unmatchable&&!S.best&&!x.has(S.item.line_id))?null:sc(Object.values(a),{wasteFactorEnabled:!1,wasteFactorOverride:0}),ke=0;for(let S of L){if(S.unmatchable||!S.best)continue;let j=a[S.item.line_id];(!j||Ft(j).lineTotal==null)&&(ke+=1)}ke>0&&(ue=null);let vt=X_(ue,ke),mt=S=>!S.unmatchable&&!S.best&&Gd(S.result).length>0,Ut=S=>S.best??Gd(S.result)[0],Jr=L.filter(S=>!S.unmatchable&&!S.best).filter(S=>!x.has(S.item.line_id)),Ec=L.filter(S=>x.has(S.item.line_id)),Yt=L;if(U.trim()){let S=U.trim().toLowerCase();Yt=Yt.filter(j=>j.item.description_original?.toLowerCase().includes(S)||Ut(j)?.description?.toLowerCase().includes(S))}if(H){let S=H==="asc"?1:-1;Yt=[...Yt].sort((j,fe)=>S*(j.item.description_original||"").localeCompare(fe.item.description_original||""))}let hr=Math.max(1,Math.ceil(Yt.length/pl)),yt=Math.min(Te,hr),Zn=Yt.slice((yt-1)*pl,yt*pl),wm=Zn.filter(S=>!S.unmatchable&&S.best),Mc=Zn.filter(S=>!S.unmatchable&&S.best),vm=Zn.filter(S=>S.unmatchable||!S.best),P=Z?L.find(S=>S.item.line_id===Z)??null:null,d0=!m&&!c&&!P&&Jr.length>0,Kn=(0,xe.useRef)(null),Pn=()=>{let S=ve.current;if(!S)return;let{top:j,left:fe,width:ft,height:Ze}=S.getBoundingClientRect(),Ai=S.querySelector(".bom-toolbar-btn")?.closest("td")?.getBoundingClientRect().left;ce({top:j,left:fe,width:Ai?Ai-fe:ft,height:Ze})};(0,xe.useEffect)(()=>(window.addEventListener("scroll",Pn,!0),window.addEventListener("resize",Pn),()=>{window.removeEventListener("scroll",Pn,!0),window.removeEventListener("resize",Pn)})),(0,xe.useEffect)(()=>{let S=j=>{Kn.current&&!j.composedPath().includes(Kn.current)&&Kn.current.removeAttribute("open")};return document.addEventListener("click",S),()=>document.removeEventListener("click",S)},[]);let zi=S=>{ge(S),bt("")},m0=()=>{if(!Z)return;let S=a[Z];if(S){u(j=>({...j,[Z]:S.productId})),k(j=>({...j,[Z]:Rv(S)}));return}u(j=>{let fe={...j};return delete fe[Z],fe}),k(j=>{let fe={...j};return delete fe[Z],fe})},Va=(S=!1)=>{let j=Z?a[Z]:void 0;!S&&j&&P?.best&&j.productId!==P.best.product_id&&!window.confirm("You have selected a new product. Leave without updating it?")||(S||m0(),ge(null),D(!1))};rl(T,()=>G(!1)),rl(!!P&&!T,()=>Va());let f0=S=>{if(qe(j=>new Set(j).add(S)),Jr.some(j=>j.item.line_id!==S)){Va(!0);return}p(),Va(!0)},h0=S=>{if(Tc(S),_(j=>new Set(j).add(S)),Jr.some(j=>j.item.line_id!==S)){Va(!0);return}p(),Va(!0)},g0=()=>{_(S=>new Set([...S,...Jr.map(j=>j.item.line_id)])),p()},ym=()=>{P?.best&&(xm(P.item.line_id,P.best),r(Jn(P)),q?f0(P.item.line_id):Va(!0))},_m=vm.length>0?(0,s.jsxs)("section",{className:"results-tile-section results-tile-section--unmatched","aria-label":"Items needing review",children:[(0,s.jsxs)("div",{className:"results-tile-section__head",children:[(0,s.jsx)("h3",{children:"Needs review"}),(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:vm.map(S=>{let{item:j,qty:fe}=S;return(0,s.jsxs)("button",{type:"button",className:"results-unmatched-card",onClick:()=>zi(j.line_id),children:[(0,s.jsx)("span",{className:"results-unmatched-card__main",children:(0,s.jsx)("span",{className:"results-unmatched-card__title",children:Zr(j,v)})}),(0,s.jsx)("span",{className:"bom-toolbar-btn results-unmatched-card__prompt",children:"Review"})]},j.line_id)})})]}):null,Tc=S=>{u(j=>({...j,[S]:jd})),k(j=>({...j,[S]:void 0})),A(j=>({...j,[S]:void 0})),i(S)},zc=(S,j)=>{u(fe=>({...fe,[S]:j.product_id})),k(fe=>({...fe,[S]:j}))},xm=(S,j)=>{j.method==="catalogue_search"&&A(fe=>({...fe,[S]:j}))};function Hx(){h("downloaded",{type:"schedule",lines:L.length}),Ev(L.map(({item:S,best:j,qty:fe,band:ft,unmatchable:Ze,decision:Xa})=>({item:S,best:j,qty:fe,band:ft,unmatchable:Ze,decision:Xa})))}function Jn(S){let j=S.best;if(!j)throw new Error("Cannot add a line item without a selected product.");return On(j,{lineId:S.item.line_id,description:S.item.description_original,unit:S.item.unit,qty:S.qty,linkedContext:S.item.linked_group_role==="dependent"&&S.item.linked_group_id?v.filter(fe=>fe.linked_group_id===S.item.linked_group_id&&fe.linked_group_role==="anchor").slice(0,1).map(fe=>{let ft=a[fe.line_id];return{line_id:fe.line_id,product_id:ft?.productId??null,measurements_mm:ft?.measurementsMm??fe.attrs.measurements_mm,description:ft?.description??fe.description_original,qty:fe.qty,unit:fe.unit,role:"anchor"}}):void 0})}(0,xe.useEffect)(()=>{if(!o){for(let S of L)!S.unmatchable&&S.best&&r(Jn(S));l()}},[o]),(0,xe.useEffect)(()=>{if(!Z){Ct([]),tt(null),be(!1);return}let S=Re.trim();if(!S){Ct([]),tt(null),be(!1);return}let j=!1,fe=window.setTimeout(async()=>{try{be(!0),tt(null);let ft=await fetch(Ta(`/api/catalogue/search?q=${encodeURIComponent(S)}`),{headers:bi()}),Ze=await Ga(ft);if(!ft.ok)throw new Error(Ze?.error||Ze?.message||"Failed to search catalogue");j||Ct(Array.isArray(Ze?.items)?Ze.items:[])}catch(ft){j||(Ct([]),tt(ft?.message||"Failed to search catalogue"))}finally{j||be(!1)}},250);return()=>{j=!0,window.clearTimeout(fe)}},[Re,Z]);let Rc=Object.keys(a).length,Ca=Re.trim(),Ac=Gd(P?.result),bl=!!P&&!P.best&&(P.result?.candidates.length===0||P.result?.rerank?.selectedCandidateId===null),km=P?.result?.rerank!=null,Sm=P?.decision?.reason??(bl?"No catalogue candidate found. Refine the request or search the catalogue.":null),b0=jt.map(S=>({product_id:S.product_id,description:S.description,source_list:S.source_list,price:S.price,price_basis:S.price_basis,uoi_count:S.uoi_count??null,uoi:S.uoi,pdp_photo_url:S.pdp_photo_url??null,conversion:S.conversion,measurements_mm:S.measurements_mm??[],scores:{dimension:0,grade:0,brand:0,fuzzy:0,bm25:0,overall:0},method:"catalogue_search"})),In=Ca?b0:Ac,Ri=P?z[P.item.line_id]:void 0,Fn=!Ca&&Ri&&!In.some(S=>S.product_id===Ri.product_id)?[...In,Ri]:In,Nm=(()=>{let S=Fn.slice(0,Ca?12:6);return Ca||!Ri||S.some(j=>j.product_id===Ri.product_id)?S:[...S,Ri]})(),wl=!!P?.best&&a[P.item.line_id]?.productId===P.best.product_id,w0=!!P?.best&&!!a[P.item.line_id]&&!wl;return(0,s.jsxs)("div",{className:"wizard-step entry-stage",children:[(0,s.jsxs)("div",{className:`quick-order-card${m?"":" quick-order-card--customer"}`,children:[(0,s.jsx)("div",{className:`quick-order-hero${m?"":" quick-order-hero--customer"}`,children:m?(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:vt??"Review quantities"})," 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 ",g?"View Quote":"View Basket"," to continue."]})]}),(0,s.jsxs)("button",{type:"button",className:"results-total-action",onClick:n,disabled:Rc===0,"aria-label":g?"View quote":"View basket",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:g?"View Quote":"View Basket"}),vt!=null&&(0,s.jsx)("strong",{children:vt})]}),(0,s.jsx)("span",{className:"arrow",children:(0,s.jsx)(Qt,{})})]})]})}),(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":Ee,onClick:()=>Nt(S=>!S),children:Ee?"Hide timings":"Show timings"})}),Ve&&Ee&&(0,s.jsx)(P_,{...O}),!g&&(0,s.jsx)("div",{className:"results-toolbar-row",children:!P&&(0,s.jsx)("div",{className:"results-summary",style:{marginBottom:0},children:(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:U,onChange:S=>R(S.target.value),"aria-label":"Search line items"}),!m&&(0,s.jsxs)("div",{className:"results-view-toggle","aria-label":"Results view",children:[(0,s.jsx)("button",{type:"button",className:`results-view-toggle__btn${le==="tile"?" is-active":""}`,"aria-pressed":le==="tile","aria-label":"Tile view",title:"Tile view",onClick:()=>Fe("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${le==="list"?" is-active":""}`,"aria-pressed":le==="list","aria-label":"List view",title:"List view",onClick:()=>Fe("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:()=>we(S=>S==="simple"?"detailed":"simple"),children:Ne==="detailed"?"Hide detailed view":"Show detailed view"}),(0,s.jsxs)("details",{ref:Kn,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:G_.map(S=>{let j=H===S.dir;return(0,s.jsxs)("button",{type:"button",className:`sort-menu-item${j?" is-active":""}`,onClick:()=>{oe(j?null:S.dir),Kn.current?.removeAttribute("open")},children:[(0,s.jsx)("span",{className:"sort-menu-item__check",children:j?"\u2713":""}),S.label]},S.dir)})})]})]})})}),le==="tile"||P?(0,s.jsxs)(s.Fragment,{children:[P?(0,s.jsx)("div",{className:"modal-backdrop quick-order-modal-backdrop",role:"dialog","aria-modal":"true","aria-label":"Product options",onClick:()=>Va(),children:(0,s.jsxs)("section",{className:"quick-order-workflow-modal results-review-modal",onClick:S=>S.stopPropagation(),children:[(0,s.jsx)("button",{type:"button",className:"quick-order-workflow-close results-review-modal__close",onClick:()=>Va(),"aria-label":"Close product options",children:(0,s.jsx)(il,{})}),(0,s.jsx)("div",{className:"results-review-page",children:m?(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:()=>Va(),children:[(0,s.jsx)(Vr,{}),"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:()=>we(S=>S==="simple"?"detailed":"simple"),children:Ne==="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:Re,onChange:S=>bt(S.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:()=>Tc(P.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)(za,{className:"fill-img results-review-page__image",description:Ut(P)?.description||P.item.description_original,photoUrl:Ut(P)?.pdp_photo_url})}),(0,s.jsxs)("div",{className:"results-review-page__summary",children:[(0,s.jsx)("h2",{children:Zr(P.item,v)}),(0,s.jsxs)("p",{className:"results-review-page__meta",children:[vi(P.qty)," ",xa(P.item.unit,P.qty)]}),P.best?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-review-page__product",children:P.best.description}),P.best.price!=null?(0,s.jsx)("div",{className:"results-row-meta",children:Ln(P.best.price,P.best.price_basis)}):null]}):Ut(P)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"results-review-page__product",children:Ut(P)?.description}),Ut(P)?.price!=null?(0,s.jsx)("div",{className:"results-row-meta",children:Ln(Ut(P)?.price??null,Ut(P)?.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."}),Kr(P.item)?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[(0,s.jsx)(Qd,{meta:N.get(P.item.linked_group_id)}),(0,s.jsx)("div",{className:"results-row-meta",style:{marginTop:0},children:Hn(P.item)})]}):null,(0,s.jsx)("div",{className:"results-review-page__actions",children:(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[P.item.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>{a[P.item.line_id]?i(P.item.line_id):(P.best&&xm(P.item.line_id,P.best),r(Jn(P)))},disabled:!P.best,"aria-label":a[P.item.line_id]?m?"Remove from selection":`Remove from ${d}`:m?"Add to selection":`Add to ${d}`,children:a[P.item.line_id]?"\u2713 Added":m?"+ Add to selection":`Add to ${d}`})})]})]}),wt?(0,s.jsx)("div",{className:"results-empty-card",children:"Searching catalogue\u2026"}):null,!wt&&de?(0,s.jsx)("div",{className:"results-empty-card",children:de}):null,!wt&&!de&&Ca&&In.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No candidate products match this database search."}):!wt&&!de?(0,s.jsx)(ex,{item:P.item,candidates:In,result:P.result,decision:P.decision,unmatchable:P.unmatchable,selectedProductId:P.best?.product_id??null,detailMode:Ne,linkedGroupMeta:Kr(P.item)?N.get(P.item.linked_group_id):void 0,onPick:S=>zc(P.item.line_id,S),onClear:()=>Tc(P.item.line_id),showAll:m||Ve||Ca.length>0,internal:m,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:Zr(P.item,v)||"Original request"})]}),Sm?(0,s.jsxs)("section",{className:"customer-review-ai",children:[(0,s.jsx)("strong",{children:bl?"No automatic match:":"AI review:"})," ",Sm]}):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:bl?Ac.length>0?"Choose a product":"No suitable product found":km?"Choose a product":"We couldn't review this item"}),(0,s.jsx)("p",{children:bl?Ac.length>0?"No product was selected automatically. Review these related options before adding one.":"Search the catalogue to choose an alternative.":km?`Select the option you want to add to your ${d}.`:"Search the catalogue to choose a product."})]})}),!Ca&&Fn.length>0?(0,s.jsx)("div",{className:"customer-review-option-grid",children:Nm.map(S=>{let j=S.product_id===P.best?.product_id;return(0,s.jsxs)("button",{type:"button",className:`customer-review-option${j?" is-selected":""}`,onClick:()=>zc(P.item.line_id,S),"aria-pressed":j,children:[(0,s.jsx)(za,{className:"customer-review-option__image",description:S.description,photoUrl:S.pdp_photo_url,width:64,height:64}),(0,s.jsx)("span",{className:"customer-review-option__copy",children:(0,s.jsx)("strong",{children:S.description})}),(0,s.jsx)("span",{className:"customer-review-option__price",children:S.price!=null?`\xA3${Ln(S.price,S.price_basis)}`:"-"}),(0,s.jsx)("span",{className:"customer-review-option__state",children:j?"Selected":"Choose"})]},S.product_id)})}):null,Fn.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:Re,onChange:S=>bt(S.target.value),"aria-label":"Search catalogue"})]}),Ca&&wt?(0,s.jsx)("div",{className:"results-empty-card",children:"Searching catalogue\u2026"}):null,Ca&&!wt&&de?(0,s.jsx)("div",{className:"results-empty-card",children:de}):null,Ca&&!wt&&!de&&Fn.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No products match this search."}):null,Ca&&!wt&&!de&&Fn.length>0?(0,s.jsx)("div",{className:"customer-review-option-grid",children:Nm.map(S=>{let j=S.product_id===P.best?.product_id;return(0,s.jsxs)("button",{type:"button",className:`customer-review-option${j?" is-selected":""}`,onClick:()=>zc(P.item.line_id,S),"aria-pressed":j,children:[(0,s.jsx)(za,{className:"customer-review-option__image",description:S.description,photoUrl:S.pdp_photo_url,width:64,height:64}),(0,s.jsx)("span",{className:"customer-review-option__copy",children:(0,s.jsx)("strong",{children:S.description})}),(0,s.jsx)("span",{className:"customer-review-option__price",children:S.price!=null?`\xA3${Ln(S.price,S.price_basis)}`:"-"}),(0,s.jsx)("span",{className:"customer-review-option__state",children:j?"Selected":"Choose"})]},S.product_id)})}):null]}),P.best?w0?(0,s.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,s.jsx)("button",{type:"button",className:"cta-btn customer-review-add",onClick:()=>{ym()},children:(0,s.jsx)("span",{children:"Update product"})}),(0,s.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary customer-review-add",onClick:()=>i(P.item.line_id),children:(0,s.jsx)("span",{children:`Remove from ${d}`})})]}):(0,s.jsx)("button",{type:"button",className:`cta-btn customer-review-add${wl?" cta-btn-secondary":""}`,onClick:()=>{wl?i(P.item.line_id):ym()},children:(0,s.jsx)("span",{children:wl?`Remove from ${d}`:`Add selected product to ${d}`})}):null,q?(0,s.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary customer-review-skip",onClick:()=>h0(P.item.line_id),children:"Skip this item"}):null]})})]})}):null,(0,s.jsxs)("div",{className:"results-tile-layout",children:[Yt.length===0?(0,s.jsx)("div",{className:"results-empty-card",children:"No line items match the current search/filter."}):null,Mc.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:Mc.map(S=>{let{item:j,best:fe,qty:ft}=S,Ze=Ut(S);return(0,s.jsxs)("article",{className:"results-tile-card",children:[(0,s.jsxs)("button",{type:"button",className:"results-tile-card__surface",onClick:()=>zi(j.line_id),"aria-label":`Review match for ${Zr(j,v)||"item"}`,children:[(0,s.jsxs)("div",{className:"results-tile-card__media",children:[Kr(j)?(0,s.jsx)("div",{className:"results-tile-card__badges",children:(0,s.jsx)(Qd,{meta:N.get(j.linked_group_id)})}):null,(0,s.jsx)(za,{className:"fill-img results-tile-card__image",description:Ze?.description||j.description_original,photoUrl:Ze?.pdp_photo_url})]}),(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:"\u21B3 matched from"}),(0,s.jsx)("div",{className:"results-tile-card__match-name",children:Zr(j,v)}),Kr(j)?(0,s.jsx)("div",{className:"results-row-meta",children:Hn(j)}):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:[m&&(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>zi(j.line_id),children:"Review"}),(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[j.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>{a[j.line_id]?i(j.line_id):r(Jn(S))},disabled:!fe,"aria-label":a[j.line_id]?m?"Remove from selection":`Remove from ${d}`:m?"Add to selection":`Add to ${d}`,children:a[j.line_id]?"\u2713 Added":m?"+ Add":`Add to ${d}`})]})]},j.line_id)})})}):null,_m]})]}):(0,s.jsxs)(s.Fragment,{children:[ie&&(0,s.jsx)("div",{className:"results-table__hover-overlay",style:ie,"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"}}),Ne==="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"}),Ne==="simple"&&(0,s.jsx)("th",{style:{textAlign:"center"},children:m?"Selection":g?"Quote":"Basket"})]})}),(0,s.jsxs)("tbody",{children:[Yt.length===0&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:Ne==="simple"?4:3,className:"results-empty-hint",style:{padding:"16px 8px"},children:"No line items match the current search/filter."})}),Mc.map(S=>{let{item:j,result:fe,decision:ft,best:Ze}=S;return(0,s.jsxs)("tr",{className:"bom-row results-table__review-row",onClick:()=>zi(j.line_id),onMouseEnter:Xa=>{ve.current=Xa.currentTarget,Pn()},onMouseLeave:()=>{ve.current=null,ce(null)},children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("div",{className:"bom-component-name",children:Zr(j,v)}),Kr(j)?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[(0,s.jsx)(Qd,{meta:N.get(j.linked_group_id)}),(0,s.jsx)("div",{className:"results-row-meta",style:{marginTop:0},children:Hn(j)})]}):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}),Ne==="detailed"&&ft&&(0,s.jsx)("div",{className:"results-row-meta",children:ft.selected_candidate_id===Ze.product_id?"Automatically selected":"Selected"})]}):(0,s.jsx)("span",{className:"results-empty-hint"})}),(0,s.jsx)("td",{style:{textAlign:"center"},children:Ze?.price!=null?Ln(Ze.price,Ze.price_basis):"-"}),Ne==="simple"&&(0,s.jsx)("td",{style:{textAlign:"center"},children:(0,s.jsx)("button",{type:"button",className:`bom-toolbar-btn${a[j.line_id]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,style:{width:84,justifyContent:"center"},onClick:Xa=>{Xa.stopPropagation(),a[j.line_id]?i(j.line_id):r(Jn(S))},"aria-label":a[j.line_id]?m?"Remove from selection":`Remove from ${d}`:m?"Add to selection":`Add to ${d}`,children:a[j.line_id]?"\u2713 Added":m?"+ Add":`Add to ${d}`})})]},j.line_id)})]})]})}),_m]}),!P&&hr>1&&(0,s.jsxs)("div",{className:"results-pagination",children:[(0,s.jsxs)("span",{className:"results-pagination-count",children:["Showing ",(yt-1)*pl+1,"\u2013",Math.min(yt*pl,Yt.length)," of ",Yt.length]}),(0,s.jsxs)("div",{className:"results-pagination-controls",children:[(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>je(yt-1),disabled:yt===1,children:"Previous"}),(0,s.jsxs)("span",{className:"results-pagination-page",children:["Page ",yt," of ",hr]}),(0,s.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>je(yt+1),disabled:yt===hr,children:"Next"})]})]}),(E.itemCount!=null||E.headingCount!=null||E.skippedCount!=null)&&(0,s.jsxs)("div",{className:"results-summary",style:{marginTop:16},children:[E.itemCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:E.itemCount})," items parsed"]}),E.headingCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:E.headingCount})," headings"]}),E.skippedCount!=null&&(0,s.jsxs)("span",{className:"summary-chip",children:[(0,s.jsx)("strong",{children:E.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."})]}),!P&&(0,s.jsxs)("div",{className:"btn-row results-actions",children:[(0,s.jsxs)("button",{className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",gap:10,justifyContent:"center"},onClick:()=>G(!0),"aria-label":"Start over",children:[(0,s.jsx)(Hd,{}),(0,s.jsx)("span",{children:"Start Over"})]}),(0,s.jsxs)("button",{className:"cta-btn",style:{flex:"0 1 70%"},onClick:n,disabled:Rc===0,"aria-label":m?"View selection":g?"View quote":"View basket",children:[(0,s.jsxs)("span",{children:[m?"View Selection":g?"View Quote":"View Basket"," (",Rc,")"]}),(0,s.jsx)("span",{className:"arrow",children:(0,s.jsx)(Qt,{})})]})]})]})]}),d0&&(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:Jr.map(S=>{let j=Ye.has(S.item.line_id),fe=mt(S);return(0,s.jsx)("div",{className:`review-gate-item${j?" is-reviewed":""}`,children:(0,s.jsxs)("button",{type:"button",className:"review-gate-item__review",onClick:()=>{D(!0),zi(S.item.line_id)},children:[(0,s.jsxs)("span",{className:"review-gate-item__copy",children:[(0,s.jsx)("strong",{children:Zr(S.item,v)}),(0,s.jsx)("span",{children:S.decision?.reason||(fe?"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:j?"Choice made":"Choose a product"})]})},S.item.line_id)})}),(0,s.jsx)("button",{type:"button",className:"review-gate-skip",onClick:g0,children:"Skip all"}),Ec.length>0?(0,s.jsxs)("div",{className:"review-gate-skipped",children:[(0,s.jsx)("strong",{children:"Skipped"}),Ec.map(S=>(0,s.jsxs)("button",{type:"button",className:"review-gate-item is-skipped",onClick:()=>{_(j=>{let fe=new Set(j);return fe.delete(S.item.line_id),fe}),D(!0),zi(S.item.line_id)},children:[(0,s.jsxs)("span",{className:"review-gate-item__copy",children:[(0,s.jsx)("strong",{children:Zr(S.item,v)}),(0,s.jsx)("span",{children:`Not added to your ${d}.`})]}),(0,s.jsx)("span",{className:"review-gate-item__action",children:"Choose a product"})]},S.item.line_id))]}):null]})}),T&&(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 ",g?"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:()=>G(!1),children:"Cancel"}),(0,s.jsx)("button",{type:"button",className:"modal-btn modal-btn-danger",onClick:()=>{G(!1),t()},autoFocus:!0,children:"Start Over"})]})]})})]})}var ka=$(F()),Vd="metron-quick-quote",tx=1440*60*1e3;function uc(e){return(0,ka.jsx)(lc,{children:(0,ka.jsx)(ax,{...e})})}function ax({fullPage:e=!1,hideHeader:t=!1,internal:a=!1}){let[r,i]=(0,De.useState)("entry"),[n,o]=(0,De.useState)(null),[l,c]=(0,De.useState)(""),p=(0,De.useRef)(null),m=(0,De.useRef)(0),[g,d]=(0,De.useState)(0),[b,v]=(0,De.useState)(null),[E,O]=(0,De.useState)(!1),{cart:f,addToCart:u,addManyToCart:h,removeFromCart:w,updateCartQty:k,updateCartSellUnits:z,updateCartConversions:A,clearCart:U}=Dn(),[R,H]=(0,De.useState)(!1),[oe,Te]=(0,De.useState)(null),je=()=>{Te(null);try{window.sessionStorage.removeItem(oc)}catch{}},Ve=(0,De.useRef)(null),Ne=Js("quick-quote",Ve);(0,De.useEffect)(()=>{Ne("viewed")},[Ne]);let[we,le]=(0,De.useState)(!1);(0,De.useEffect)(()=>{wv();let be=window.location.hash,de=null;try{de=JSON.parse(window.sessionStorage.getItem(Vd)??"null")}catch{}if(de&&!(Date.now()-(de.savedAt??0)<tx)&&(de=null),de?.scheduleResult)o("schedule"),v(de.scheduleResult),O(de.reviewGateComplete),H(de.cartSeeded),h(Object.values(de.cart)),be==="#quote-request"?i("basket"):be==="#matched-products"&&i("results");else if(be==="#matched-products"||be==="#quote-request"){let tt=new URL(window.location.href);tt.hash="",Rn("replaceState",window.history.state,tt)}le(!0)},[]),(0,De.useEffect)(()=>{if(we)try{b?window.sessionStorage.setItem(Vd,JSON.stringify({savedAt:Date.now(),scheduleResult:b,reviewGateComplete:E,cartSeeded:R,cart:f})):window.sessionStorage.removeItem(Vd)}catch{}},[we,b,E,R,f]);let Fe=(0,De.useCallback)(be=>{if(typeof window>"u")return;let de=new URL(window.location.href);de.hash=be==="basket"?"quote-request":"matched-products";let tt=be==="results"&&(window.location.hash==="#matched-products"||window.location.hash==="#quote-request");Rn(tt?"replaceState":"pushState",{boqQuoteStage:be},de)},[]),Ee=(0,De.useRef)(!1);(0,De.useEffect)(()=>{let be=()=>{Ee.current=!1;let de=window.location.hash;de==="#quote-request"?i("basket"):de==="#matched-products"&&b?(o("schedule"),i("results")):i("entry")};return window.addEventListener("popstate",be),()=>window.removeEventListener("popstate",be)},[b]);let Nt=(0,De.useCallback)(()=>{Fe("basket"),i("basket")},[Fe]),Z=(0,De.useCallback)(()=>{if(window.location.hash==="#quote-request"){if(Ee.current)return;Ee.current=!0,nc();return}i(b?"results":"entry")},[b]),ge=(0,De.useRef)(r);(0,De.useEffect)(()=>{ge.current!==r&&(ge.current=r,window.scrollTo(0,0))},[r]);let Re=()=>{i("entry"),o(null),c(""),d(0),v(null),O(!1),U(),H(!1),je()},bt=(0,De.useCallback)(async(be,de,tt=!0)=>{let T=++m.current;c(""),d(0);let G=0,ie=()=>{G=Math.min(G+1,3),d(G)};try{let{jobId:ce}=await Nw(be,de,tt);if(T!==m.current)return;let{promise:ve,cancel:Ye}=qw(()=>Cw(ce),5e3,ie,"schedule");p.current=Ye;let qe=await ve;if(qe.status==="failed"||!qe.result)throw new Error(qe.error||"Failed to process schedule");let x=qe.result.lineItems.length,_=qe.result.results.filter(q=>q.candidates.length>0).length;Ne("results_shown",{lines:x,matched:_,unmatched:x-_}),U(),H(!1),O(!1),v(qe.result),Fe("results"),i("results")}catch(ce){if(T!==m.current)return;Ne("error",{stage:"matching"}),c(ce?.message||"Failed to process schedule"),i("entry")}finally{T===m.current&&(p.current?.(),p.current=null)}},[Fe,Ne,U]),jt=(0,De.useCallback)(()=>{m.current++,p.current?.(),p.current=null},[]),Ct=(0,De.useCallback)(async(be,de,tt=!0)=>{if(!be.trim())return;o("schedule");let T=new File([be],"pasted-schedule.txt",{type:"text/plain"});await bt(T,de,tt)},[bt]),wt=(0,De.useCallback)(async be=>{o("schedule"),await bt(be)},[bt]);return(0,ka.jsx)(tl.Provider,{value:Ne,children:(0,ka.jsx)("div",{ref:Ve,className:`app-wrapper${e?"":" app-wrapper--embedded"}${t?" app-wrapper--no-header":""}${!e&&r==="processing"?" app-wrapper--loading":""}`,style:Ot().theme,children:(0,ka.jsxs)("main",{className:"main-content",children:[l&&(0,ka.jsxs)("div",{className:"error-box",role:"alert",children:[(0,ka.jsx)("strong",{children:"Error:"})," ",l]}),r==="entry"&&(0,ka.jsx)(Cd,{onPasteSchedule:Ct,onUploadSchedule:wt,onEntryModeChange:o,draft:oe,onSubmitDraft:Te,onCancelMatch:jt}),r==="results"&&n==="schedule"&&b&&(0,ka.jsx)($d,{scheduleResult:b,onStartOver:Re,cart:f,onAddToCart:u,onRemoveFromCart:w,onGoToBasket:Nt,cartSeeded:R,onCartSeeded:()=>H(!0),reviewGateComplete:E,onReviewGateComplete:()=>O(!0),internal:a}),r==="basket"&&(0,ka.jsx)(ul,{cart:f,onUpdateQty:k,onUpdateSellUnits:z,onResolveConversions:A,onRemove:w,onBack:Z,onStartNewQuote:Re,onQuoteRequested:()=>{v(null),O(!1),H(!1),U(),je()},internal:a})]})})})}var $a=$(He());var Si=$(He());var Ov={"NZ4Y-ZMSQ":{"brick-block":{"brick-common":"105499","brick-engineering-red":"1654","brick-engineering-blue":"1723",block:"501","mortar-cement":"1762 cement","mortar-sand":"564 building sand"},skirting:{"skirting-chamfered":"1525","skirting-ogee":"135 primed mdf ogee","skirting-pencil-round":"892","skirting-torus":"1941"},architrave:{"architrave-ogee":"134 primed mdf ogee","architrave-pencil-round":"1896","architrave-square-edge":"118 primed mdf square","architrave-torus":"1531"},plasterboard:{standard:"1647",moisture:"11 moisture plasterboard",fire:"14 fire plasterboard",sound:"1769",screws:"131160",tape:"1766",adhesive:"108439"},paint:{"paint-emulsion":"157217"},"concrete-aggregate":{cement:"1762 cement","sharp-sand":"563",gravel:"571",mot:"569"},insulation:{"insulation-floor":"152187","insulation-ground":"442","insulation-wall":"147","insulation-roof":"442","insulation-loft":"152180"},timber:{studs:"1213",joists:"208",battens:"1729"},fencing:{"panels-boundary-0.9":"66 lap fence panel","panels-boundary-1.2":"1450","panels-boundary-1.5":"1449","panels-boundary-1.8":"1448","panels-skyline-1.8":"1475","concrete-intermediate-8":"40197","concrete-end-8":"40198","timber-post-6":"141411","timber-post-8":"1709",postcrete:"12142","gate-boundary":"1984","gate-skyline":"40002","gravel-boards":"40200"},decking:{"boards-summit":"24322",joists:"208",screws:"131079"},paving:{"surface-council":"1669","surface-raj":"12363","surface-brindle":"304","surface-charcoal":"296","surface-pea":"431","sub-base":"569",bedding:"563"}}};function dl(e,t){let a=Ov[Ot().client??""]?.[e];if(!a)return null;let r=e==="plasterboard"&&t.key==="board"?t.label.split(" ")[0].toLowerCase():t.key;return a[r]??null}function ki(e,t){let a=Ov[Ot().client??""]?.[e];return!a||t in a}function Bv(e,t){let a=t.map(r=>{let i=dl(e,r);return i?{key:r.key,productId:i.split(" ")[0],search:i,qty:r.qty,unit:r.unit}:null});return a.length>0&&a.every(Boolean)?a:null}var ee=$(F()),Lv=[{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"}],pc=e=>Number.parseFloat(e)||0,Hv=(e,t)=>pc(e)*(t==="m"?1:.3048),Xd=(e,t)=>pc(e.quantity)*(2*Hv(e.height,t)+Hv(e.width,t)),rx=()=>({quantity:"1",width:"",height:""});function ix({profile:e}){return(0,ee.jsxs)("svg",{className:"architrave-calculator__profile-diagram",viewBox:"0 0 112 76","aria-hidden":"true",children:[(0,ee.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,ee.jsx)("line",{x1:"12",y1:"66",x2:"100",y2:"66"})]})}function Zd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Si.useState)("m"),[n,o]=(0,Si.useState)({quantity:"1",width:"0.76",height:"1.98"}),[l,c]=(0,Si.useState)({quantity:"0",width:"1.52",height:"1.98"}),[p,m]=(0,Si.useState)([]),[g,d]=(0,Si.useState)("ogee"),[b,v]=(0,Si.useState)("2.4"),E=(k,z,A)=>{k(U=>({...U,[z]:A}))},O=Xd(n,r)+Xd(l,r)+p.reduce((k,z)=>k+Xd(z,r),0),f=pc(b)>0?Math.ceil(O/pc(b)):0,u=Lv.find(k=>k.id===g)?.label??"",h=[{key:`architrave-${g}`,label:`Architrave (${u})`,qty:O,unit:"m",query:`${u} architrave`,category:"architrave"}],w=(k,z,A,U)=>(0,ee.jsxs)("div",{className:"architrave-calculator__opening-row",children:[(0,ee.jsx)("span",{children:k}),(0,ee.jsx)("input",{"aria-label":`${k} quantity`,type:"number",min:"0",step:"1",value:z.quantity,onChange:R=>A("quantity",R.target.value)}),(0,ee.jsx)("input",{"aria-label":`${k} width`,type:"number",min:"0",step:"0.01",value:z.width,onChange:R=>A("width",R.target.value)}),(0,ee.jsx)("input",{"aria-label":`${k} height`,type:"number",min:"0",step:"0.01",value:z.height,onChange:R=>A("height",R.target.value)}),U?(0,ee.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:U,children:"Remove"}):null]});return(0,ee.jsx)(ee.Fragment,{children:(0,ee.jsxs)("div",{className:"truss-estimator",children:[(0,ee.jsxs)("div",{className:"quick-order-hero",children:[(0,ee.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,ee.jsx)("h1",{children:"Architrave Calculator"}),(0,ee.jsx)("p",{children:"Estimate architrave lengths and board quantities for door openings."})]}),(0,ee.jsxs)("div",{className:"truss-estimator__card architrave-calculator",children:[(0,ee.jsx)("h2",{className:"truss-estimator__step-title",children:"Measure your openings"}),(0,ee.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,ee.jsxs)("div",{className:"architrave-calculator__section",children:[(0,ee.jsx)("div",{className:"truss-estimator__section-heading",children:"Door openings"}),(0,ee.jsx)("p",{className:"architrave-calculator__hint",children:"Each opening is calculated as two side pieces plus one head piece."}),(0,ee.jsxs)("div",{className:"architrave-calculator__unit-row",children:[(0,ee.jsx)("span",{children:"Units"}),(0,ee.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,ee.jsx)("button",{type:"button",className:r==="m"?"is-selected":"",onClick:()=>i("m"),children:"Metres"}),(0,ee.jsx)("button",{type:"button",className:r==="ft"?"is-selected":"",onClick:()=>i("ft"),children:"Feet"})]})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__dimensions-header",children:[(0,ee.jsx)("span",{children:"Opening"}),(0,ee.jsx)("span",{children:"Qty"}),(0,ee.jsxs)("span",{children:["Width (",r,")"]}),(0,ee.jsxs)("span",{children:["Height (",r,")"]}),(0,ee.jsx)("span",{})]}),w("Single doors",n,(k,z)=>E(o,k,z)),w("Double doors",l,(k,z)=>E(c,k,z)),p.map((k,z)=>w(`Alternative door ${z+1}`,k,(A,U)=>m(R=>R.map((H,oe)=>oe===z?{...H,[A]:U}:H)),()=>m(A=>A.filter((U,R)=>R!==z)))),(0,ee.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>m(k=>[...k,rx()]),children:"+ Add alternative-sized door"})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__section",children:[(0,ee.jsx)("div",{className:"truss-estimator__section-heading",children:"Standard profile"}),(0,ee.jsx)("p",{className:"architrave-calculator__hint",children:"Choose the profile you plan to use. Length calculations are the same for each profile."}),(0,ee.jsx)("div",{className:"architrave-calculator__profiles",children:Lv.filter(k=>ki("architrave",`architrave-${k.id}`)).map(k=>(0,ee.jsxs)("button",{type:"button",className:`truss-estimator__option-card${g===k.id?" is-selected":""}`,onClick:()=>d(k.id),children:[(0,ee.jsx)(ix,{profile:k.id}),(0,ee.jsx)("div",{className:"truss-estimator__option-title",children:k.label}),(0,ee.jsx)("div",{className:"truss-estimator__option-copy",children:k.blurb})]},k.id))})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__section",children:[(0,ee.jsx)("div",{className:"truss-estimator__section-heading",children:"Board and waste"}),(0,ee.jsx)("div",{className:"architrave-calculator__options",children:(0,ee.jsxs)("label",{className:"truss-estimator__field",children:[(0,ee.jsx)("span",{children:"Board length (m)"}),(0,ee.jsx)("input",{value:"4.40 m",disabled:!0})]})}),(0,ee.jsx)("p",{className:"architrave-calculator__hint",children:"Waste allows for mitred corners, cuts and damaged lengths."})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__totals",children:[(0,ee.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,ee.jsxs)("div",{className:"architrave-calculator__result-grid",children:[(0,ee.jsxs)("div",{children:[(0,ee.jsx)("span",{children:"Architrave needed"}),(0,ee.jsxs)("strong",{children:[O.toFixed(2)," m"]})]}),(0,ee.jsxs)("div",{children:[(0,ee.jsx)("span",{children:"Board lengths"}),(0,ee.jsx)("strong",{children:f})]})]})]}),(0,ee.jsxs)("div",{className:"architrave-calculator__actions",children:[(0,ee.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,ee.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(h),disabled:O<=0,children:a})]})]})]})})}var Ni=$(He()),ae=$(F()),Qv=60,Gv=10,nx=.02,ox=.012,jv=1,Yv=4,lx=1.33,sx=1440,cx=1600,Qn=e=>Number.parseFloat(e)||0,ux=(e,t=2)=>e.toFixed(t);function Kd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Ni.useState)("brick"),[n,o]=(0,Ni.useState)("engineering-red"),[l,c]=(0,Ni.useState)("metric"),[p,m]=(0,Ni.useState)(""),[g,d]=(0,Ni.useState)(""),[b,v]=(0,Ni.useState)(!0),E=l==="metric"?Qn(p)*Qn(g):Qn(p)*Qn(g)*.092903,f=E*(r==="brick"?Qv:Gv),u=Math.ceil(f),w=E*(r==="brick"?nx:ox)*lx/(jv+Yv),k=Math.ceil(w*jv*sx),z=Math.ceil(w*Yv*cx),A=l==="metric"?E:E*10.7639,U=[{key:r==="brick"?`brick-${n}`:"block",label:r==="brick"?{common:"Common concrete bricks","engineering-red":"Red engineering bricks","engineering-blue":"Blue engineering bricks"}[n]:"Blocks",qty:u,unit:"each",query:r==="brick"?"facing brick":"concrete block",category:"masonry"},...b?[{key:"mortar-cement",label:"General purpose cement",qty:k,unit:"kg",query:"general purpose cement",category:"cement"},{key:"mortar-sand",label:"Building sand",qty:z,unit:"kg",query:"building sand",category:"aggregate"}]:[]],R=H=>{if(H===l)return;let oe=H==="imperial"?3.28084:.3048;m((Qn(p)*oe).toFixed(2)),d((Qn(g)*oe).toFixed(2)),c(H)};return(0,ae.jsx)(ae.Fragment,{children:(0,ae.jsxs)("div",{className:"truss-estimator",children:[(0,ae.jsxs)("div",{className:"quick-order-hero",children:[(0,ae.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,ae.jsx)("h1",{children:"Brick and Block Calculator"}),(0,ae.jsx)("p",{children:"Estimate masonry units, sand and cement for a wall."})]}),(0,ae.jsxs)("div",{className:"truss-estimator__card brick-calculator",children:[(0,ae.jsx)("h2",{className:"truss-estimator__step-title",children:"Wall area and masonry type"}),(0,ae.jsx)("p",{className:"truss-estimator__step-sub",children:"Pick brick or block and enter the wall dimensions for unit counts plus the cement and sand for the mortar."}),(0,ae.jsxs)("div",{className:"brick-calculator__section",children:[(0,ae.jsx)("div",{className:"truss-estimator__section-heading",children:"Masonry type"}),(0,ae.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[["brick","Brick"],["block","Block"]].map(([H,oe])=>(0,ae.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===H?" is-selected":""}`,onClick:()=>i(H),children:[(0,ae.jsx)("div",{className:"truss-estimator__option-title",children:oe}),(0,ae.jsxs)("div",{className:"truss-estimator__option-copy",children:["Approx. ",H==="brick"?Qv:Gv," per m\xB2"]})]},H))})]}),r==="brick"&&(0,ae.jsxs)("div",{className:"brick-calculator__section",children:[(0,ae.jsx)("div",{className:"truss-estimator__section-heading",children:"Brick type"}),(0,ae.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(([H,oe,Te])=>(0,ae.jsxs)("button",{type:"button",className:`truss-estimator__option-card${n===H?" is-selected":""}`,onClick:()=>o(H),children:[(0,ae.jsx)("div",{className:"truss-estimator__option-title",children:oe}),(0,ae.jsx)("div",{className:"truss-estimator__option-copy",children:Te})]},H))})]}),(0,ae.jsxs)("div",{className:"brick-calculator__section",children:[(0,ae.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall dimensions"}),(0,ae.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,ae.jsx)("button",{type:"button",className:l==="metric"?"is-selected":"",onClick:()=>R("metric"),children:"Metric"}),(0,ae.jsx)("button",{type:"button",className:l==="imperial"?"is-selected":"",onClick:()=>R("imperial"),children:"Imperial"})]}),(0,ae.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,ae.jsxs)("label",{className:"truss-estimator__field",children:[(0,ae.jsxs)("span",{children:["Height (",l==="metric"?"m":"ft",")"]}),(0,ae.jsx)("input",{type:"number",min:"0",step:"0.01",value:p,onChange:H=>m(H.target.value)})]}),(0,ae.jsxs)("label",{className:"truss-estimator__field",children:[(0,ae.jsxs)("span",{children:["Width (",l==="metric"?"m":"ft",")"]}),(0,ae.jsx)("input",{type:"number",min:"0",step:"0.01",value:g,onChange:H=>d(H.target.value)})]})]})]}),(0,ae.jsx)("div",{className:"brick-calculator__options",children:(0,ae.jsxs)("label",{className:"brick-calculator__checkbox",children:[(0,ae.jsx)("input",{type:"checkbox",checked:b,onChange:H=>v(H.target.checked)}),(0,ae.jsx)("span",{children:"Include mortar (cement and building sand, mixed 1:4)"})]})}),(0,ae.jsxs)("div",{className:"brick-calculator__totals",children:[(0,ae.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,ae.jsxs)("div",{className:"brick-calculator__result-grid",children:[(0,ae.jsxs)("div",{children:[(0,ae.jsx)("span",{children:"Wall area"}),(0,ae.jsxs)("strong",{children:[ux(A)," ",l==="metric"?"m\xB2":"ft\xB2"]})]}),(0,ae.jsxs)("div",{children:[(0,ae.jsx)("span",{children:r==="brick"?"Bricks":"Blocks"}),(0,ae.jsx)("strong",{children:u.toLocaleString("en-GB")})]}),b?(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)("div",{children:[(0,ae.jsx)("span",{children:"Cement"}),(0,ae.jsxs)("strong",{children:[k," kg"]})]}),(0,ae.jsxs)("div",{children:[(0,ae.jsx)("span",{children:"Building sand"}),(0,ae.jsxs)("strong",{children:[z," kg"]})]})]}):null]}),(0,ae.jsx)("p",{className:"brick-calculator__note",children:"Estimate based on standard nominal sizes and 10mm joints. Mortar is a general purpose 1:4 cement and sand mix; quantities are approximate, so confirm the specification before ordering."})]}),(0,ae.jsxs)("div",{className:"brick-calculator__actions",children:[(0,ae.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,ae.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(U),disabled:E<=0,children:a})]})]})]})})}var Ci=$(He()),W=$(F()),px=1.54,dx=1440,Pd=e=>Number.parseFloat(e)||0,Pr={mot:{label:"MOT Type 1",blurb:"Sub-base for patios and driveways",density:1.7,query:"MOT type 1"},"sharp-sand":{label:"Sharp sand",blurb:"Bedding and general groundwork",density:1.6,query:"sharp sand"},gravel:{label:"20mm gravel",blurb:"Drainage and landscaping",density:1.6,query:"20mm gravel"}};function Jd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Ci.useState)("m"),[n,o]=(0,Ci.useState)(""),[l,c]=(0,Ci.useState)(""),[p,m]=(0,Ci.useState)(""),[g,d]=(0,Ci.useState)("concrete"),[b,v]=(0,Ci.useState)("mot"),E=r==="m"?1:.3048,O=Pd(n)*E*Pd(l)*E*Pd(p)*(r==="m"?.01:.0254),f=Pr[b],u=O*px/7,h=u*dx,w=u*2,k=u*4,z=(U,R)=>Math.ceil(U*R*1e3),A=g==="concrete"?[{key:"cement",label:"General purpose cement",qty:Math.ceil(h),unit:"kg",query:"general purpose cement"},{key:"sharp-sand",label:"Sharp sand",qty:z(w,Pr["sharp-sand"].density),unit:"kg",query:Pr["sharp-sand"].query},{key:"gravel",label:"20mm gravel",qty:z(k,Pr.gravel.density),unit:"kg",query:Pr.gravel.query}]:[{key:b,label:f.label,qty:z(O,f.density),unit:"kg",query:f.query}];return(0,W.jsx)(W.Fragment,{children:(0,W.jsxs)("div",{className:"truss-estimator",children:[(0,W.jsxs)("div",{className:"quick-order-hero",children:[(0,W.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,W.jsx)("h1",{children:"Concrete and Aggregate Calculator"}),(0,W.jsx)("p",{children:"Calculate fixed site-mix concrete ingredients or aggregate bulk bags."})]}),(0,W.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,W.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose what you need"}),(0,W.jsx)("p",{className:"truss-estimator__step-sub",children:"Enter the area and depth. The calculator works out the materials and adds them to your basket."}),(0,W.jsxs)("div",{className:"materials-calculator__section",children:[(0,W.jsx)("div",{className:"truss-estimator__section-heading",children:"Material type"}),(0,W.jsxs)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:[(0,W.jsxs)("button",{type:"button",className:`truss-estimator__option-card${g==="concrete"?" is-selected":""}`,onClick:()=>d("concrete"),children:[(0,W.jsx)("div",{className:"truss-estimator__option-title",children:"Site-mixed concrete"}),(0,W.jsx)("div",{className:"truss-estimator__option-copy",children:"Cement, sharp sand and 20mm aggregate"})]}),(0,W.jsxs)("button",{type:"button",className:`truss-estimator__option-card${g==="aggregate"?" is-selected":""}`,onClick:()=>d("aggregate"),children:[(0,W.jsx)("div",{className:"truss-estimator__option-title",children:"Aggregates"}),(0,W.jsx)("div",{className:"truss-estimator__option-copy",children:"MOT Type 1, sharp sand or 20mm gravel"})]})]})]}),g==="aggregate"&&(0,W.jsxs)("div",{className:"materials-calculator__section",children:[(0,W.jsx)("div",{className:"truss-estimator__section-heading",children:"Aggregate type"}),(0,W.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.keys(Pr).map(U=>(0,W.jsxs)("button",{type:"button",className:`truss-estimator__option-card${b===U?" is-selected":""}`,onClick:()=>v(U),children:[(0,W.jsx)("div",{className:"truss-estimator__option-title",children:Pr[U].label}),(0,W.jsx)("div",{className:"truss-estimator__option-copy",children:Pr[U].blurb})]},U))})]}),(0,W.jsxs)("div",{className:"materials-calculator__section",children:[(0,W.jsx)("div",{className:"truss-estimator__section-heading",children:"Area and depth"}),(0,W.jsxs)("div",{className:"materials-calculator__unit-row",children:[(0,W.jsx)("span",{children:"Units"}),(0,W.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,W.jsx)("button",{type:"button",className:r==="m"?"is-selected":"",onClick:()=>i("m"),children:"Metric"}),(0,W.jsx)("button",{type:"button",className:r==="ft"?"is-selected":"",onClick:()=>i("ft"),children:"Imperial"})]})]}),(0,W.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,W.jsxs)("label",{className:"truss-estimator__field",children:[(0,W.jsxs)("span",{children:["Length (",r,")"]}),(0,W.jsx)("input",{type:"number",min:"0",step:"0.01",value:n,onChange:U=>o(U.target.value)})]}),(0,W.jsxs)("label",{className:"truss-estimator__field",children:[(0,W.jsxs)("span",{children:["Width (",r,")"]}),(0,W.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:U=>c(U.target.value)})]})]}),(0,W.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,W.jsxs)("span",{children:["Depth (",r==="m"?"cm":"inches",")"]}),(0,W.jsx)("input",{type:"number",min:"0",step:"0.1",value:p,onChange:U=>m(U.target.value)})]})]}),(0,W.jsxs)("div",{className:"materials-calculator__totals",children:[(0,W.jsx)("div",{className:"truss-estimator__section-heading",children:"Materials required"}),(0,W.jsx)("div",{className:"materials-calculator__result-grid",children:g==="concrete"?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:"Cement"}),(0,W.jsxs)("strong",{children:[h.toFixed(0)," kg"]})]}),(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:"Sharp sand"}),(0,W.jsxs)("strong",{children:[w.toFixed(2)," m\xB3"]})]}),(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:"20mm aggregate"}),(0,W.jsxs)("strong",{children:[k.toFixed(2)," m\xB3"]})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:f.label}),(0,W.jsxs)("strong",{children:[O.toFixed(2)," m\xB3"]})]}),(0,W.jsxs)("div",{children:[(0,W.jsx)("span",{children:"Approx. weight"}),(0,W.jsxs)("strong",{children:[(O*f.density).toFixed(2)," t"]})]}),(0,W.jsx)("div",{})]})}),(0,W.jsx)("p",{className:"materials-calculator__note",children:g==="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."})]}),(0,W.jsxs)("div",{className:"materials-calculator__actions",children:[(0,W.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,W.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(A),disabled:O<=0,children:a})]})]})]})})}var Ya=$(He());var B=$(F()),Gn=12,jn=8,dc=.56,$v=.21,Ra={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:{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}]}},qi=["range","grid","pictureFrame","substructure"],mx={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:""}},mc=(e,t,a)=>(t.x-e.x)*(a.y-e.y)-(t.y-e.y)*(a.x-e.x),fc=(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),fx=(e,t,a,r)=>{let i=mc(e,t,a),n=mc(e,t,r),o=mc(a,r,e),l=mc(a,r,t);return i===0&&fc(e,t,a)||n===0&&fc(e,t,r)||o===0&&fc(a,r,e)||l===0&&fc(a,r,t)?!0:i>0!=n>0&&o>0!=l>0},Id=(e,t)=>{let a=t?e.length:e.length-1;for(let r=0;r<a;r+=1){let i=e[(r+1)%e.length];for(let n=r+1;n<a;n+=1)if(!(n===r+1||t&&r===0&&n===a-1)&&fx(e[r],i,e[n],e[(n+1)%e.length]))return!0}return!1};function Fd({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Ya.useState)(0),[n,o]=(0,Ya.useState)(mx),[l,c]=(0,Ya.useState)(1),[p,m]=(0,Ya.useState)({x:0,y:0}),[g,d]=(0,Ya.useState)(null),b=(0,Ya.useRef)(null),v=(0,Ya.useRef)(null),E=(0,Ya.useRef)(null),O=qi[r],f=n.range?Ra.ranges[n.range]:null,u=Gn/l,h=jn/l,w=(Gn-u)/2,k=(jn-h)/2,z=Math.max(-Gn,Math.min(Gn*2-u,w+p.x)),A=Math.max(-jn,Math.min(jn*2-h,k+p.y)),U=Number.parseFloat(n.quickLengthM),R=Number.parseFloat(n.quickWidthM),H=U>0&&R>0,oe=T=>Math.abs(T.reduce((G,ie,ce)=>{let ve=T[(ce+1)%T.length];return G+ie.x*ve.y-ve.x*ie.y},0))/2,Te=(T,G)=>Math.hypot(G.x-T.x,G.y-T.y),je=n.isOutlineClosed?oe(n.points):0,Ve=n.isOutlineClosed?n.points.reduce((T,G,ie)=>T+Te(G,n.points[(ie+1)%n.points.length]),0):0,Ne=n.isOutlineClosed?n.points.reduce((T,G,ie)=>T+(n.wallSegments.has(ie)?0:Te(G,n.points[(ie+1)%n.points.length])),0):0,we=n.points.reduce((T,G)=>({x:T.x+G.x/n.points.length,y:T.y+G.y/n.points.length}),{x:0,y:0}),le=n.points.length>1?(()=>{let T=n.points[0],G=n.points[1],ie=Te(T,G),ce=ie?-(G.y-T.y)/ie:0,ve=ie?(G.x-T.x)/ie:0,Ye=(T.x+G.x)/2,qe=(T.y+G.y)/2,x=ce*(Ye-we.x)+ve*(qe-we.y)>=0?1:-1;return{x:Ye+ce*dc*x,y:qe+ve*dc*x}})():null,Ee=(()=>{let T=n.range?Ra.ranges[n.range]:Ra.ranges.meridian,G=n.deckSizeMode==="quick"?U*R:je,ie=n.deckSizeMode==="quick"?2*(U+R):Ne,ce=n.direction==="diagonal"?Ra.wastage.diagonal:Ra.wastage.straight,ve=n.pictureFrame==="yes"?Ra.pictureFrame.extraWastage:0,qe=G/(T.boardWidthM+Ra.boardGapM)/T.boardLengthM,x=Math.ceil(qe*(1+ce+ve)),_=Math.ceil(G*30*(1+ce+ve)/200),q=Ra.joist.spacingOptions.find(N=>N.id===n.joistSpacing)??Ra.joist.spacingOptions[1],D=G/q.spacingM,V=Math.ceil(D);return{range:T,area:G,boardCount:x,screwBoxes:_,joistMetres:V,spacing:q}})(),Nt=Ee?[{key:`boards-${n.range??"meridian"}`,label:`Deck boards (${Ee.range.label})`,qty:Math.round(Ee.boardCount*Ee.range.boardLengthM*100)/100,unit:"m",query:"timber decking board",category:"decking",calculatorWasteIncluded:!0},{key:"joists",label:"Treated C24 joists",qty:Ee.joistMetres,unit:"m",query:"treated joist",category:"timber",calculatorWasteIncluded:!0},{key:"screws",label:"Green decking screws (200/box)",qty:Ee.screwBoxes,unit:"box",query:"green decking screws",category:"fixings",calculatorWasteIncluded:!0}]:[],Z=()=>O==="range"?!!n.range:O==="grid"?n.deckSizeMode==="quick"?H:n.isOutlineClosed&&je>0:O==="pictureFrame"?!!n.pictureFrame&&!!n.direction:O==="substructure"?!!n.joistSpacing:!0,ge=r===qi.length-1?a:"Next",Re=(T,G,ie=!1)=>{let ce=E.current?.getBoundingClientRect();if(!ce)return null;let ve=ie?1:.25;return{x:Math.round(Math.max(z,Math.min(z+u,z+(T-ce.left)/ce.width*u))/ve)*ve,y:Math.round(Math.max(A,Math.min(A+h,A+(G-ce.top)/ce.height*h))/ve)*ve}},bt=T=>{if(n.isOutlineClosed){let ie=T.target;if(ie!==T.currentTarget&&!ie.classList.contains("deck-outline__grid"))return;v.current={startX:T.clientX,startY:T.clientY,startViewX:z,startViewY:A},T.currentTarget.setPointerCapture(T.pointerId);return}if(n.drawMode!=="outline")return;let G=Re(T.clientX,T.clientY,!0);G&&(d(null),o(ie=>{let ce=[...ie.points,G];return Id(ce,!1)?{...ie,drawError:"Edges cannot cross. Choose another corner."}:{...ie,points:ce,drawError:""}}))},jt=(T,G)=>{if(!n.isOutlineClosed){T.stopPropagation(),G===0&&n.points.length>=3&&o(ie=>({...ie,isOutlineClosed:!0,drawMode:"edges"}));return}T.stopPropagation(),b.current=G,T.currentTarget.setPointerCapture(T.pointerId)},Ct=T=>{if(v.current){let ce=E.current?.getBoundingClientRect();if(!ce)return;let ve=v.current,Ye=ve.startViewX-(T.clientX-ve.startX)/ce.width*u,qe=ve.startViewY-(T.clientY-ve.startY)/ce.height*h;m({x:Ye-w,y:qe-k});return}!n.isOutlineClosed&&n.drawMode==="outline"&&d(Re(T.clientX,T.clientY,!0));let G=b.current;if(G===null)return;let ie=Re(T.clientX,T.clientY);ie&&o(ce=>{let ve=ce.points.map((Ye,qe)=>qe===G?ie:Ye);return Id(ve,!0)?{...ce,drawError:"Edges cannot cross. Move the corner to a different position."}:{...ce,points:ve,drawError:""}})},wt=T=>{v.current=null,b.current=null,T.currentTarget.hasPointerCapture(T.pointerId)&&T.currentTarget.releasePointerCapture(T.pointerId)},be=T=>{o(G=>{let ie=new Set(G.wallSegments);return ie.has(T)?ie.delete(T):ie.add(T),{...G,wallSegments:ie}})},de=()=>{r===0?e():i(T=>T-1)},tt=()=>{Z()&&(r===qi.length-1?t?.(Nt):i(T=>T+1))};return(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)("div",{className:"truss-estimator",children:[(0,B.jsxs)("div",{className:"quick-order-hero",children:[(0,B.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,B.jsx)("h1",{children:"Decking Calculator"}),(0,B.jsx)("p",{children:"Estimate timber boards, joists and screws for your deck."})]}),(0,B.jsxs)("div",{className:"truss-estimator__card",children:[(0,B.jsxs)("div",{className:"truss-estimator__body",children:[O==="range"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",qi.length]}),(0,B.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your timber decking"}),(0,B.jsx)("p",{className:"truss-estimator__step-sub",children:"Both options are fixed, orderable pressure-treated timber boards."}),(0,B.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Ra.ranges).filter(([T])=>ki("decking",`boards-${T}`)).map(([T,G])=>(0,B.jsxs)("button",{type:"button",className:`truss-estimator__option-card${n.range===T?" is-selected":""}`,onClick:()=>o(ie=>({...ie,range:T})),children:[(0,B.jsx)("div",{className:"truss-estimator__option-title",children:G.label}),(0,B.jsx)("div",{className:"truss-estimator__option-copy",children:G.blurb}),(0,B.jsxs)("div",{className:"truss-estimator__option-copy",children:[G.boardLengthM,"m boards"]})]},T))})]}):null,O==="grid"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",qi.length]}),(0,B.jsx)("h2",{className:"truss-estimator__step-title",children:"Tell us your deck size"}),(0,B.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,B.jsxs)("div",{className:"truss-estimator__toggle-row",children:[(0,B.jsx)("button",{type:"button",className:`truss-estimator__toggle${n.deckSizeMode==="quick"?" is-selected":""}`,onClick:()=>o(T=>({...T,deckSizeMode:"quick"})),children:"Quick estimate"}),(0,B.jsx)("button",{type:"button",className:`truss-estimator__toggle${n.deckSizeMode==="draw"?" is-selected":""}`,onClick:()=>o(T=>({...T,deckSizeMode:"draw",drawMode:"outline"})),children:"Draw your space"})]}),n.deckSizeMode==="quick"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,B.jsxs)("label",{className:"truss-estimator__field",children:[(0,B.jsx)("span",{children:"Length (m)"}),(0,B.jsx)("input",{type:"number",inputMode:"decimal",min:"0.1",step:"0.1",value:n.quickLengthM,onChange:T=>o(G=>({...G,quickLengthM:T.target.value}))})]}),(0,B.jsxs)("label",{className:"truss-estimator__field",children:[(0,B.jsx)("span",{children:"Width (m)"}),(0,B.jsx)("input",{type:"number",inputMode:"decimal",min:"0.1",step:"0.1",value:n.quickWidthM,onChange:T=>o(G=>({...G,quickWidthM:T.target.value}))})]})]}),(0,B.jsx)("div",{className:"truss-estimator__grid-hint",children:"For L-shaped decks, cut-outs, or sides against a wall, use Draw your space."}),H?(0,B.jsxs)("div",{className:"truss-estimator__grid-stats",children:[(0,B.jsxs)("div",{children:[(U*R).toFixed(2)," m\xB2 deck"]}),(0,B.jsxs)("div",{children:[(2*(U+R)).toFixed(2)," m perimeter"]})]}):null]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"truss-estimator__section-heading",children:"Draw your deck"}),(0,B.jsx)("p",{className:"truss-estimator__step-sub",children:"Click to add corners, then close the outline. Drag any handle to refine it."}),(0,B.jsxs)("div",{className:"deck-outline__toolbar",children:[n.isOutlineClosed?(0,B.jsxs)("div",{className:"deck-outline__summary",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{children:"Deck area"}),(0,B.jsxs)("strong",{children:[je.toFixed(2)," m\xB2"]})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{children:"Perimeter"}),(0,B.jsxs)("strong",{children:[Ve.toFixed(2)," m"]})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{children:"Wall edges"}),(0,B.jsx)("strong",{children:n.wallSegments.size>0?n.wallSegments.size:"None"})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{children:"Visible edge"}),(0,B.jsxs)("strong",{children:[Ne.toFixed(2)," m"]})]})]}):null,(0,B.jsxs)("div",{className:"deck-outline__actions",children:[(0,B.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(T=>({...T,points:T.points.slice(0,-1)})),disabled:n.points.length===0||n.isOutlineClosed,children:"Undo"}),(0,B.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>{d(null),o(T=>({...T,points:[],isOutlineClosed:!1,wallSegments:new Set,drawMode:"outline",drawError:""}))},disabled:n.points.length===0,children:"Clear"}),(0,B.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(T=>({...T,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,B.jsx)("div",{className:"deck-editor-layout",children:(0,B.jsxs)("div",{className:"deck-editor-layout__canvas-column",children:[(0,B.jsxs)("div",{className:"deck-outline",children:[(0,B.jsxs)("svg",{ref:E,className:`deck-outline__canvas${n.isOutlineClosed?" is-pan-mode":""}`,viewBox:`${z} ${A} ${u} ${h}`,preserveAspectRatio:"none","aria-label":"Deck outline drawing area",onPointerDown:bt,onPointerMove:Ct,onPointerUp:wt,onPointerLeave:()=>{d(null),v.current||(b.current=null)},children:[(0,B.jsx)("defs",{children:(0,B.jsx)("pattern",{id:"deck-outline-grid",width:"1",height:"1",patternUnits:"userSpaceOnUse",children:(0,B.jsx)("path",{d:"M 1 0 L 0 0 0 1",fill:"none",stroke:"currentColor",strokeWidth:"0.03"})})}),(0,B.jsx)("rect",{x:-Gn,y:-jn,width:Gn*3,height:jn*3,className:"deck-outline__grid",fill:"url(#deck-outline-grid)"}),n.points.length>1?(0,B.jsx)("polyline",{className:"deck-outline__preview",points:n.points.map(T=>`${T.x},${T.y}`).join(" ")}):null,n.isOutlineClosed?(0,B.jsx)("polygon",{className:"deck-outline__shape",points:n.points.map(T=>`${T.x},${T.y}`).join(" "),stroke:"none"}):null,n.points.length>1?n.points.slice(0,n.isOutlineClosed?void 0:-1).map((T,G)=>{let ie=n.points[n.isOutlineClosed?(G+1)%n.points.length:G+1],ce=Te(T,ie),ve=ce?-(ie.y-T.y)/ce:0,Ye=ce?(ie.x-T.x)/ce:0,qe=(T.x+ie.x)/2,x=(T.y+ie.y)/2,_=ve*(qe-we.x)+Ye*(x-we.y)>=0?1:-1,q=qe+ve*dc*_,D=x+Ye*dc*_;return(0,B.jsxs)("g",{children:[(0,B.jsx)("line",{className:"deck-outline__edge-hit",x1:T.x,y1:T.y,x2:ie.x,y2:ie.y,onClick:n.isOutlineClosed?()=>be(G):void 0}),(0,B.jsx)("line",{className:`deck-outline__edge${n.wallSegments.has(G)?" is-wall":""}`,x1:T.x,y1:T.y,x2:ie.x,y2:ie.y,pointerEvents:"none"}),(0,B.jsxs)("text",{className:`deck-outline__edge-label${n.wallSegments.has(G)?" is-wall":""}`,x:q,y:D,textAnchor:"middle",dominantBaseline:"central",fontSize:$v/l,children:[ce.toFixed(2)," m"]})]},`segment-${G}`)}):null,!n.isOutlineClosed&&n.points.length>0&&g?(()=>{let T=n.points[n.points.length-1],G=Te(T,g);if(!G)return null;let ie=-(g.y-T.y)/G,ce=(g.x-T.x)/G,ve=(T.x+g.x)/2,Ye=(T.y+g.y)/2;return(0,B.jsxs)("g",{className:"deck-outline__live-measurement",children:[(0,B.jsx)("line",{x1:T.x,y1:T.y,x2:g.x,y2:g.y}),(0,B.jsxs)("text",{x:ve+ie*.34,y:Ye+ce*.34,textAnchor:"middle",dominantBaseline:"central",fontSize:$v/l,children:[G.toFixed(2)," m"]})]})})():null,n.points.map((T,G)=>(0,B.jsx)("circle",{className:"deck-outline__point",cx:T.x,cy:T.y,r:"0.13",onPointerDown:ie=>jt(ie,G)},`point-${G}`))]}),(0,B.jsxs)("div",{className:"deck-outline__zoom","aria-label":"Zoom controls",children:[(0,B.jsx)("button",{type:"button",onClick:()=>c(T=>Math.max(.5,T-.25)),disabled:l===.5,"aria-label":"Zoom out",children:"\u2212"}),(0,B.jsxs)("span",{children:[Math.round(l*100),"%"]}),(0,B.jsx)("button",{type:"button",onClick:()=>c(T=>Math.min(1,T+.25)),disabled:l===1,"aria-label":"Zoom in",children:"+"})]}),n.isOutlineClosed&&n.wallSegments.size===0&&le?(0,B.jsx)("div",{className:"deck-outline__edge-prompt",role:"status",style:{left:`${(le.x-z)/u*100}%`,top:`${(le.y-A)/h*100}%`},children:"Tap an edge to mark it as a wall, or leave it as a visible edge."}):null,!n.isOutlineClosed&&n.points.length>=3?(0,B.jsx)("button",{type:"button",className:"deck-outline__close",onClick:()=>o(T=>Id(T.points,!0)?{...T,drawError:"Edges cannot cross. Adjust the outline before finishing."}:{...T,isOutlineClosed:!0,drawMode:"edges",drawError:""}),children:"Finish outline"}):null]}),(0,B.jsxs)("div",{className:"deck-outline__supporting",children:[(0,B.jsx)("div",{className:"truss-estimator__grid-hint",children:n.isOutlineClosed?"Drag a corner handle to refine the outline.":"Add at least three corners, then click Finish outline."}),n.drawError?(0,B.jsx)("div",{className:"deck-outline__error",role:"alert",children:n.drawError}):null]})]})})]})]}):null,O==="pictureFrame"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",qi.length]}),(0,B.jsx)("h2",{className:"truss-estimator__step-title",children:"Picture frame border?"}),(0,B.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,B.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(T=>(0,B.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${n.pictureFrame===T.id?" is-selected":""}`,onClick:()=>o(G=>({...G,pictureFrame:T.id})),children:[(0,B.jsx)("img",{className:"truss-estimator__visual-card-img",src:It(T.img),alt:""}),(0,B.jsx)("span",{children:T.label})]},T.id))}),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"truss-estimator__section-heading",children:"Board direction"}),(0,B.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(T=>(0,B.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${n.direction===T.id?" is-selected":""}`,onClick:()=>o(G=>({...G,direction:T.id})),children:[(0,B.jsx)("img",{className:"truss-estimator__visual-card-img",src:It(T.img),alt:""}),(0,B.jsx)("span",{children:T.label})]},T.id))})]})]}):null,O==="substructure"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",qi.length]}),(0,B.jsx)("h2",{className:"truss-estimator__step-title",children:"Substructure"}),(0,B.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,B.jsx)("div",{className:"truss-estimator__section-heading",children:"Joist spacing"}),(0,B.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Ra.joist.spacingOptions.map(T=>(0,B.jsx)("button",{type:"button",className:`truss-estimator__option-card${n.joistSpacing===T.id?" is-selected":""}`,onClick:()=>o(G=>({...G,joistSpacing:T.id})),children:(0,B.jsx)("div",{className:"truss-estimator__option-title",children:T.label})},T.id))})]}):null]}),(0,B.jsxs)("div",{className:"truss-estimator__nav",children:[(0,B.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:de,children:"Back"}),(0,B.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:tt,disabled:!Z(),children:[(0,B.jsx)("span",{children:ge}),(0,B.jsx)("span",{className:"arrow",children:(0,B.jsx)(Qt,{})})]})]})]})]})})}var Na=$(He());var Y=$(F()),Vv=12,Xv=30,Yn=12,$n=8,Zv=.56,Sa={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 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}}},Ei=["range","height","gate","posts"],Wd=e=>Number(e)<=1.2?"6":"8",Kv=(e,t)=>ki("fencing",`panels-${e??"boundary"}-${t}`),Pv=(e,t)=>!t||ki("fencing",e==="concrete"?`concrete-intermediate-${Wd(t)}`:`timber-post-${Wd(t)}`),hx={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:""}},hc=(e,t,a)=>(t.x-e.x)*(a.y-e.y)-(t.y-e.y)*(a.x-e.x),gc=(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),gx=(e,t,a,r)=>{let i=hc(e,t,a),n=hc(e,t,r),o=hc(a,r,e),l=hc(a,r,t);return i===0&&gc(e,t,a)||n===0&&gc(e,t,r)||o===0&&gc(a,r,e)||l===0&&gc(a,r,t)?!0:i>0!=n>0&&o>0!=l>0},bc=(e,t)=>{let a=t?e.length:e.length-1;for(let r=0;r<a;r+=1)for(let i=r+1;i<a;i+=1)if(!(i===r+1||t&&r===0&&i===a-1)&&gx(e[r],e[(r+1)%e.length],e[i],e[(i+1)%e.length]))return!0;return!1};function em({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Na.useState)(0),[n,o]=(0,Na.useState)(hx),l=(0,Na.useRef)(null),c=(0,Na.useRef)(null),[p,m]=(0,Na.useState)(1),[g,d]=(0,Na.useState)({x:0,y:0}),[b,v]=(0,Na.useState)(null),E=(0,Na.useRef)(null),O=(0,Na.useRef)(null),f=(0,Na.useRef)(null),u=Ei[r],h=n.range?Sa.ranges[n.range]:null,w=Yn/p,k=$n/p,z=(Yn-w)/2,A=($n-k)/2,U=Math.max(-Yn,Math.min(Yn*2-w,z+g.x)),R=Math.max(-$n,Math.min($n*2-k,A+g.y)),H=n.boundaryPoints.reduce((x,_)=>({x:x.x+_.x/Math.max(1,n.boundaryPoints.length),y:x.y+_.y/Math.max(1,n.boundaryPoints.length)}),{x:0,y:0}),oe=x=>{let _=new Set,q=[];return x.forEach(D=>{let[V,N]=D.split(",").map(Number),L=[{key:`H,${V},${N}`,type:"H",x:V,y:N},{key:`H,${V},${N+1}`,type:"H",x:V,y:N+1},{key:`V,${V},${N}`,type:"V",x:V,y:N},{key:`V,${V+1},${N}`,type:"V",x:V+1,y:N}],X=[!x.has(`${V},${N-1}`),!x.has(`${V},${N+1}`),!x.has(`${V-1},${N}`),!x.has(`${V+1},${N}`)];L.forEach((ue,ke)=>{X[ke]&&!_.has(ue.key)&&(_.add(ue.key),q.push(ue))})}),q},Te=(x,_)=>oe(x).filter(q=>!_.has(q.key)),je=(x,_)=>Te(x,_).length,Ve=(x,_)=>{let q={};Te(x,_).forEach(V=>{var N,L,X,ue;V.type==="H"?((q[N=`${V.x},${V.y}`]||(q[N]=[])).push("H"),(q[L=`${V.x+1},${V.y}`]||(q[L]=[])).push("H")):((q[X=`${V.x},${V.y}`]||(q[X]=[])).push("V"),(q[ue=`${V.x},${V.y+1}`]||(q[ue]=[])).push("V"))});let D=0;return Object.values(q).forEach(V=>{(V.length===1||V.length===2&&V[0]!==V[1]||V.length>=3)&&(D+=1)}),D},we=(()=>{let x=n.range?Sa.ranges[n.range]:Sa.ranges.boundary,_=n.height??"1.8",q=n.boundaryMode==="quick"?Math.max(0,Number.parseFloat(n.quickLengthM)||0):n.boundaryClosed?n.boundaryPoints.slice(0,-1).reduce((Yt,hr,yt)=>Yt+(n.excludedBoundaryEdges.has(yt)?0:Math.hypot(n.boundaryPoints[yt+1].x-hr.x,n.boundaryPoints[yt+1].y-hr.y)),0):0,D=n.gateType&&n.gateType!=="none"?Number.parseFloat(n.gateWidthM)||Sa.gate[n.gateType].widthDefault:0,V=Math.max(0,q-D),N=V>0?Math.ceil(V/x.panelWidthM):0,L=n.boundaryPoints.length>2&&n.boundaryPoints[0].x===n.boundaryPoints[n.boundaryPoints.length-1].x&&n.boundaryPoints[0].y===n.boundaryPoints[n.boundaryPoints.length-1].y,X=n.boundaryMode==="quick"?V>0?2:0:n.boundaryClosed?n.boundaryPoints.slice(0,L?-1:void 0).reduce((Yt,hr,yt)=>{let Zn=yt>0&&!n.excludedBoundaryEdges.has(yt-1),wm=yt<n.boundaryPoints.length-1&&!n.excludedBoundaryEdges.has(yt);return Yt+(Zn||wm?1:0)},0):0,ue=V>0?Math.ceil(V/x.panelWidthM)+1:0,ke=Math.max(0,ue-X),vt=n.mountingType?Sa.mounting[n.mountingType]:Sa.mounting.concrete,mt=n.gateType&&n.gateType!=="none"?2:0,Ut=ke+X+mt,bm=n.mountingType==="postcrete"?Ut*Sa.mounting.postcrete.bagsPerPost:0,Jr=n.gravelBoard==="yes"?N:0;return{range:x,height:_,totalEdgeM:q,fencedLengthM:V,gateWidthM:D,panelsCount:N,cornerPostCount:X,intermediatePostCount:ke,gatePostCount:mt,totalPostCount:Ut,bagsCount:bm,gravelCount:Jr,capCount:Ut,mounting:vt}})(),le=n.gateType&&n.gateType!=="none"?Sa.gate[n.gateType].label:null,Fe=Wd(we.height),Ee=we?[{key:`panels-${n.range??"boundary"}-${we.height}`,label:`${we.range.label} panels (${we.height}m)`,qty:we.panelsCount,unit:"each",query:"fence panel",category:"fencing"},...n.mountingType==="concrete"?[{key:`concrete-intermediate-${Fe}`,label:"Intermediate concrete posts",qty:we.intermediatePostCount,unit:"each",query:"concrete fence post",category:"fencing"},{key:`concrete-end-${Fe}`,label:"End and corner concrete posts",qty:we.cornerPostCount+we.gatePostCount,unit:"each",query:"concrete end post",category:"fencing"}]:[{key:`timber-post-${Fe}`,label:"Timber fence posts",qty:we.totalPostCount,unit:"each",query:"timber fence post",category:"fencing"},{key:"postcrete",label:"Postcrete",qty:we.bagsCount,unit:"bag",query:"postcrete",category:"cement"}],...le?[{key:`gate-${n.range??"boundary"}`,label:n.range==="skyline"?"Single feather edge gate":"Single lap gate",qty:1,unit:"each",query:n.range==="skyline"?"feather edge gate":"lap gate",category:"fencing"}]:[],...we.gravelCount>0?[{key:"gravel-boards",label:"Concrete gravel boards",qty:we.gravelCount,unit:"each",query:"gravel board",category:"fencing"}]:[]]:[],Nt=()=>{if(u==="range"){let x=n.boundaryMode==="quick"?(Number.parseFloat(n.quickLengthM)||0)>0:n.boundaryClosed&&n.boundaryPoints.length>=2;return!!n.range&&x}return u==="height"?!!n.height&&!!n.gravelBoard:u==="gate"?!!n.gateType&&(n.gateType==="none"||n.gateWidthM.trim()!==""):u==="posts"?!!n.mountingType:!0},Z=r===Ei.length-1?a:"Next",ge=x=>{o(_=>{let q=x(new Set(_.grid)),D=new Set([..._.excludedEdges].filter(V=>oe(q).some(N=>N.key===V)));return{..._,grid:q,excludedEdges:D}})},Re=(x,_,q)=>{ge(D=>{let V=`${x},${_}`;return q?D.add(V):D.delete(V),D})},bt=(x,_,q,D,V)=>{let N=x,L=_,X=Math.abs(q-x),ue=x<q?1:-1,ke=-Math.abs(D-_),vt=_<D?1:-1,mt=X+ke;for(;Re(N,L,V),!(N===q&&L===D);){let Ut=2*mt;Ut>=ke&&(mt+=ke,N+=ue),Ut<=X&&(mt+=X,L+=vt)}},jt=(x,_)=>{let q=c.current?.getBoundingClientRect();if(!q)return null;let D=Math.floor((x-q.left)/Xv),V=Math.floor((_-q.top)/Xv);return D<0||V<0||D>=Vv||V>=Vv?null:{x:D,y:V}},Ct=x=>{if(n.gridMode!=="draw")return;let _=jt(x.clientX,x.clientY);if(!_)return;x.preventDefault();let q=`${_.x},${_.y}`,D=!n.grid.has(q);l.current={active:!0,paintValue:D,lastX:_.x,lastY:_.y},x.currentTarget.setPointerCapture(x.pointerId),Re(_.x,_.y,D)},wt=x=>{let _=l.current;if(!_?.active)return;let q=jt(x.clientX,x.clientY);q&&(q.x===_.lastX&&q.y===_.lastY||(bt(_.lastX,_.lastY,q.x,q.y,_.paintValue),l.current={..._,lastX:q.x,lastY:q.y}))},be=x=>{l.current?.active&&(l.current=null,x.currentTarget.releasePointerCapture(x.pointerId))},de=(x,_,q=!1)=>{let D=f.current?.getBoundingClientRect();if(!D)return null;let V=q?1:.25;return{x:Math.round(Math.max(U,Math.min(U+w,U+(x-D.left)/D.width*w))/V)*V,y:Math.round(Math.max(R,Math.min(R+k,R+(_-D.top)/D.height*k))/V)*V}},tt=x=>{if(n.boundaryClosed){let q=x.target;if(q!==x.currentTarget&&!q.classList.contains("fence-boundary__grid"))return;O.current={startX:x.clientX,startY:x.clientY,startViewX:U,startViewY:R},x.currentTarget.setPointerCapture(x.pointerId);return}let _=de(x.clientX,x.clientY,!0);_&&(v(null),o(q=>{let D=[...q.boundaryPoints,_];return bc(D,!1)?{...q}:{...q,boundaryPoints:D}}))},T=(x,_)=>{if(x.stopPropagation(),!n.boundaryClosed){if(_!==0||n.boundaryPoints.length<3)return;o(q=>bc(q.boundaryPoints,!0)?q:{...q,boundaryPoints:[...q.boundaryPoints,q.boundaryPoints[0]],boundaryClosed:!0});return}E.current=_,x.currentTarget.setPointerCapture(x.pointerId)},G=x=>{if(O.current){let q=f.current?.getBoundingClientRect();if(!q)return;let D=O.current,V=D.startViewX-(x.clientX-D.startX)/q.width*w,N=D.startViewY-(x.clientY-D.startY)/q.height*k;d({x:V-z,y:N-A});return}if(n.boundaryClosed||v(de(x.clientX,x.clientY,!0)),E.current===null)return;let _=de(x.clientX,x.clientY);_&&o(q=>{let D=q.boundaryPoints.length>2&&q.boundaryPoints[0].x===q.boundaryPoints[q.boundaryPoints.length-1].x&&q.boundaryPoints[0].y===q.boundaryPoints[q.boundaryPoints.length-1].y,V=q.boundaryPoints.map((N,L)=>{let X=L===E.current,ue=D&&E.current===0&&L===q.boundaryPoints.length-1;return X||ue?_:N});return bc(V,!1)?q:{...q,boundaryPoints:V}})},ie=x=>{O.current=null,E.current=null,x.currentTarget.hasPointerCapture(x.pointerId)&&x.currentTarget.releasePointerCapture(x.pointerId)},ce=x=>{o(_=>{let q=new Set(_.excludedBoundaryEdges);return q.has(x)?q.delete(x):q.add(x),{..._,excludedBoundaryEdges:q}})},ve=()=>{r===0?e():i(x=>x-1)},Ye=()=>{Nt()&&(r===Ei.length-1?t?.(Ee):i(x=>x+1))},qe=oe(n.grid);return(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:"Fencing Calculator"}),(0,Y.jsx)("p",{children:"Estimate panels, posts and cost for your fence line in a few steps."})]}),(0,Y.jsxs)("div",{className:"truss-estimator__card",children:[(0,Y.jsxs)("div",{className:"truss-estimator__body",children:[u==="range"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ei.length]}),(0,Y.jsx)("h2",{className:"truss-estimator__step-title",children:"Choose your fence panels"}),(0,Y.jsx)("p",{className:"truss-estimator__step-sub",children:"The calculator uses fixed, orderable timber panels from the catalogue."}),(0,Y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Sa.ranges).map(([x,_])=>(0,Y.jsxs)("button",{type:"button",className:`truss-estimator__option-card${n.range===x?" is-selected":""}`,onClick:()=>o(q=>({...q,range:x,height:q.height&&Kv(x,q.height)?q.height:null})),children:[(0,Y.jsx)("div",{className:"truss-estimator__option-title",children:_.label}),(0,Y.jsx)("div",{className:"truss-estimator__option-copy",children:_.blurb})]},x))})]}):null,u==="range"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{className:"truss-estimator__section-heading",children:"Measure your fence line"}),(0,Y.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,Y.jsxs)("div",{className:"truss-estimator__toggle-row",children:[(0,Y.jsx)("button",{type:"button",className:`truss-estimator__toggle${n.boundaryMode==="quick"?" is-selected":""}`,onClick:()=>o(x=>({...x,boundaryMode:"quick"})),children:"Quick estimate"}),(0,Y.jsx)("button",{type:"button",className:`truss-estimator__toggle${n.boundaryMode==="draw"?" is-selected":""}`,onClick:()=>o(x=>({...x,boundaryMode:"draw"})),children:"Draw your boundary"})]}),n.boundaryMode==="quick"?(0,Y.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact fence-boundary__quick-field",children:[(0,Y.jsx)("span",{children:"Total fence length (m)"}),(0,Y.jsx)("input",{type:"number",min:"0",step:"0.1",value:n.quickLengthM,onChange:x=>o(_=>({..._,quickLengthM:x.target.value}))})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{className:"fence-boundary__toolbar",children:(0,Y.jsxs)("div",{className:"fence-boundary__actions",children:[(0,Y.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(x=>({...x,boundaryPoints:x.boundaryPoints.slice(0,-1),boundaryClosed:!1,excludedBoundaryEdges:new Set})),disabled:n.boundaryPoints.length===0||n.boundaryClosed,children:"Undo"}),(0,Y.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>{d({x:0,y:0}),v(null),o(x=>({...x,boundaryPoints:[],boundaryClosed:!1,excludedBoundaryEdges:new Set}))},disabled:n.boundaryPoints.length===0,children:"Clear"}),(0,Y.jsx)("button",{type:"button",className:"deck-outline__action",onClick:()=>o(x=>({...x,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,Y.jsxs)("div",{className:"fence-boundary",children:[(0,Y.jsxs)("svg",{ref:f,className:`fence-boundary__canvas${n.boundaryClosed?" is-pan-mode":""}`,viewBox:`${U} ${R} ${w} ${k}`,preserveAspectRatio:"none","aria-label":"Fence boundary drawing area",onPointerDown:tt,onPointerMove:G,onPointerUp:ie,onPointerLeave:()=>{v(null),O.current||(E.current=null)},children:[(0,Y.jsx)("defs",{children:(0,Y.jsx)("pattern",{id:"fence-boundary-grid",width:"1",height:"1",patternUnits:"userSpaceOnUse",children:(0,Y.jsx)("path",{d:"M 1 0 L 0 0 0 1",fill:"none",stroke:"currentColor",strokeWidth:"0.03"})})}),(0,Y.jsx)("rect",{x:-Yn,y:-$n,width:Yn*3,height:$n*3,className:"fence-boundary__grid",fill:"url(#fence-boundary-grid)"}),n.boundaryPoints.length>1?(0,Y.jsx)("polyline",{className:"fence-boundary__preview",points:n.boundaryPoints.map(x=>`${x.x},${x.y}`).join(" ")}):null,n.boundaryPoints.length>1?n.boundaryPoints.slice(0,-1).map((x,_)=>{let q=n.boundaryPoints[_+1],D=Math.hypot(q.x-x.x,q.y-x.y),V=D?-(q.y-x.y)/D:0,N=D?(q.x-x.x)/D:0,L=(x.x+q.x)/2,X=(x.y+q.y)/2,ue=V*(L-H.x)+N*(X-H.y)>=0?1:-1,ke=L+V*Zv*ue,vt=X+N*Zv*ue;return(0,Y.jsxs)("g",{children:[(0,Y.jsx)("line",{className:"fence-boundary__edge-hit",x1:x.x,y1:x.y,x2:q.x,y2:q.y,onClick:n.boundaryClosed?()=>ce(_):void 0}),(0,Y.jsx)("line",{className:`fence-boundary__edge${n.excludedBoundaryEdges.has(_)?" is-excluded":""}`,x1:x.x,y1:x.y,x2:q.x,y2:q.y,pointerEvents:"none"}),(0,Y.jsxs)("text",{className:`fence-boundary__edge-label${n.excludedBoundaryEdges.has(_)?" is-excluded":""}`,x:ke,y:vt,textAnchor:"middle",dominantBaseline:"central",fontSize:.21/p,children:[D.toFixed(2)," m"]})]},`fence-edge-${_}`)}):null,!n.boundaryClosed&&n.boundaryPoints.length>0&&b?(()=>{let x=n.boundaryPoints[n.boundaryPoints.length-1],_=Math.hypot(b.x-x.x,b.y-x.y);if(!_)return null;let q=-(b.y-x.y)/_,D=(b.x-x.x)/_,V=(x.x+b.x)/2,N=(x.y+b.y)/2;return(0,Y.jsxs)("g",{className:"fence-boundary__live-measurement",children:[(0,Y.jsx)("line",{x1:x.x,y1:x.y,x2:b.x,y2:b.y}),(0,Y.jsxs)("text",{x:V+q*.34,y:N+D*.34,textAnchor:"middle",dominantBaseline:"central",fontSize:.21/p,children:[_.toFixed(2)," m"]})]})})():null,n.boundaryPoints.map((x,_)=>_>0&&_===n.boundaryPoints.length-1&&x.x===n.boundaryPoints[0]?.x&&x.y===n.boundaryPoints[0]?.y?null:(0,Y.jsx)("circle",{className:`fence-boundary__point${!n.boundaryClosed&&_===0&&n.boundaryPoints.length>=3?" is-close-target":""}`,cx:x.x,cy:x.y,r:"0.13",onPointerDown:q=>T(q,_)},`fence-point-${_}`))]}),(0,Y.jsxs)("div",{className:"fence-boundary__zoom","aria-label":"Zoom controls",children:[(0,Y.jsx)("button",{type:"button",onClick:()=>m(x=>Math.max(.5,x-.25)),disabled:p===.5,"aria-label":"Zoom out",children:"\u2212"}),(0,Y.jsxs)("span",{children:[Math.round(p*100),"%"]}),(0,Y.jsx)("button",{type:"button",onClick:()=>m(x=>Math.min(1,x+.25)),disabled:p===1,"aria-label":"Zoom in",children:"+"})]}),!n.boundaryClosed&&n.boundaryPoints.length>=2?(0,Y.jsx)("button",{type:"button",className:"fence-boundary__close",onClick:()=>o(x=>bc(x.boundaryPoints,!1)?x:{...x,boundaryClosed:!0}),children:"Finish fence line"}):null]}),(0,Y.jsx)("div",{className:"truss-estimator__grid-hint",children:n.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,Y.jsxs)("div",{className:"truss-estimator__grid-stats",children:[(0,Y.jsx)("div",{children:n.boundaryMode==="quick"?`${(Number.parseFloat(n.quickLengthM)||0).toFixed(2)} m fence line`:`${we.totalEdgeM.toFixed(2)} m fence line`}),n.boundaryMode==="draw"&&n.boundaryClosed?(0,Y.jsxs)("div",{children:[we.cornerPostCount," corner/end posts"]}):null]})]}):null,null,u==="height"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ei.length]}),(0,Y.jsx)("h2",{className:"truss-estimator__step-title",children:"Fence height"}),(0,Y.jsx)("p",{className:"truss-estimator__step-sub",children:"Select the nearest available panel height."}),(0,Y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--pitch",children:Sa.heights.filter(x=>Kv(n.range,x)).map(x=>(0,Y.jsx)("button",{type:"button",className:`truss-estimator__visual-card${n.height===x?" is-selected":""}`,onClick:()=>o(_=>({..._,height:x,mountingType:_.mountingType&&Pv(_.mountingType,x)?_.mountingType:null})),children:(0,Y.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--tall",src:It(`/fencing/height/${x}.webp`),alt:""})},x))}),(0,Y.jsx)("div",{className:"truss-estimator__section-heading",children:"Gravel board?"}),(0,Y.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(x=>(0,Y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card truss-estimator__visual-card--wide${n.gravelBoard===x.id?" is-selected":""}`,onClick:()=>o(_=>({..._,gravelBoard:x.id})),children:[(0,Y.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--mid",src:It(x.img),alt:""}),(0,Y.jsx)("span",{children:x.label})]},x.id))})]}):null,u==="gate"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ei.length]}),(0,Y.jsx)("h2",{className:"truss-estimator__step-title",children:"Do you need a gate?"}),(0,Y.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,Y.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(x=>(0,Y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card${n.gateType===x.id?" is-selected":""}`,onClick:()=>o(_=>({..._,gateType:x.id,gateWidthM:x.id==="none"?"":String(Sa.gate[x.id].widthDefault)})),children:[(0,Y.jsx)("img",{className:"truss-estimator__visual-card-img truss-estimator__visual-card-img--mid",src:It(x.img),alt:""}),(0,Y.jsx)("span",{children:x.label})]},x.id))}),n.gateType&&n.gateType!=="none"?(0,Y.jsxs)("label",{className:"truss-estimator__field truss-estimator__field--compact",children:[(0,Y.jsx)("span",{children:"Gate width (m)"}),(0,Y.jsx)("input",{type:"text",inputMode:"decimal",value:n.gateWidthM,onChange:x=>o(_=>({..._,gateWidthM:x.target.value}))})]}):null]}):null,u==="posts"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{className:"truss-estimator__step-label",children:["Step ",r+1," of ",Ei.length]}),(0,Y.jsx)("h2",{className:"truss-estimator__step-title",children:"Posts and fixing type"}),(0,Y.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose how the posts will be set."}),(0,Y.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Object.entries(Sa.mounting).filter(([x])=>Pv(x,n.height)).map(([x,_])=>(0,Y.jsxs)("button",{type:"button",className:`truss-estimator__option-card${n.mountingType===x?" is-selected":""}`,onClick:()=>o(q=>({...q,mountingType:x})),children:[(0,Y.jsx)("div",{className:"truss-estimator__option-title",children:_.label}),(0,Y.jsx)("div",{className:"truss-estimator__option-copy",children:_.blurb})]},x))})]}):null]}),(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:ve,children:"Back"}),(0,Y.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:Ye,disabled:!Nt(),children:[(0,Y.jsx)("span",{children:Z}),(0,Y.jsx)("span",{className:"arrow",children:(0,Y.jsx)(Qt,{})})]})]})]})]})})}var wc=$(He()),he=$(F()),Jv={floor:{label:"Floor between rooms",product:"Knauf Acoustic Roll",thickness:"100mm",coverage:12.36},ground:{label:"Ground floor",product:"Rigid PIR insulation board",thickness:"100mm",coverage:2.88},wall:{label:"Cavity wall",product:"Celotex CW4100",thickness:"100mm",coverage:3.24},roof:{label:"Pitched roof",product:"Kingspan K107",thickness:"100mm",coverage:8.64},loft:{label:"Loft",product:"Knauf Loft Roll 44",thickness:"100mm",coverage:13.89}};function tm({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,wc.useState)("floor"),[n,o]=(0,wc.useState)(""),[l,c]=(0,wc.useState)(""),p=Number.parseFloat(n)*Number.parseFloat(l)||0,m=Jv[r],g=Math.ceil(p/m.coverage),d=[{key:`insulation-${r}`,label:`${m.product} ${m.thickness}`,qty:Math.round(p*100)/100,unit:"m2",query:m.product,category:"insulation"}],b=Object.entries(Jv);return(0,he.jsx)(he.Fragment,{children:(0,he.jsxs)("div",{className:"truss-estimator",children:[(0,he.jsxs)("div",{className:"quick-order-hero",children:[(0,he.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,he.jsx)("h1",{children:"Insulation Calculator"}),(0,he.jsx)("p",{children:"Estimate insulation coverage and pack quantities for floors, walls, roofs and lofts."})]}),(0,he.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,he.jsx)("h2",{className:"truss-estimator__step-title",children:"Where and what you are insulating"}),(0,he.jsx)("p",{className:"truss-estimator__step-sub",children:"Choose the application and product, and enter the area, for coverage and pack quantities."}),(0,he.jsxs)("div",{className:"materials-calculator__section",children:[(0,he.jsx)("div",{className:"truss-estimator__section-heading",children:"Application"}),(0,he.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:b.map(([v,E])=>(0,he.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===v?" is-selected":""}`,onClick:()=>i(v),children:[(0,he.jsx)("div",{className:"truss-estimator__option-title",children:E.label}),(0,he.jsxs)("div",{className:"truss-estimator__option-copy",children:[E.product,", ",E.thickness]})]},v))})]}),(0,he.jsxs)("div",{className:"materials-calculator__section",children:[(0,he.jsx)("div",{className:"truss-estimator__section-heading",children:"Area"}),(0,he.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,he.jsxs)("label",{className:"truss-estimator__field",children:[(0,he.jsx)("span",{children:"Length (m)"}),(0,he.jsx)("input",{type:"number",min:"0",step:"0.01",value:n,onChange:v=>o(v.target.value)})]}),(0,he.jsxs)("label",{className:"truss-estimator__field",children:[(0,he.jsx)("span",{children:"Width (m)"}),(0,he.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:v=>c(v.target.value)})]})]})]}),(0,he.jsxs)("div",{className:"materials-calculator__totals",children:[(0,he.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,he.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("span",{children:"Insulated area"}),(0,he.jsxs)("strong",{children:[p.toFixed(2)," m\xB2"]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)("span",{children:m.product}),(0,he.jsxs)("strong",{children:[g," packs"]})]})]}),(0,he.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,he.jsxs)("div",{className:"materials-calculator__actions",children:[(0,he.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,he.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(d),disabled:p<=0,children:a})]})]})]})})}var Vn=$(He());var K=$(F()),bx=10,wx=1.9*.762,vx=1.9*1.524,vc=()=>({height:"",width:""}),yc=e=>Number.parseFloat(e)||0,Iv=({height:e,width:t})=>yc(e)*yc(t);function am({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Vn.useState)([vc()]),[n,o]=(0,Vn.useState)([vc()]),[l,c]=(0,Vn.useState)("0"),[p,m]=(0,Vn.useState)("0"),[g,d]=(0,Vn.useState)(1),b=r.reduce((k,z)=>k+Iv(z),0),v=n.reduce((k,z)=>k+Iv(z),0),E=yc(l)*wx+yc(p)*vx,O=Math.max(0,b-v-E),f=O*g/bx,u={key:"paint-emulsion",label:"Matt emulsion, brilliant white",qty:Math.round(f*10)/10,unit:"litres",query:"matt emulsion brilliant white"},h=dl("paint",u)!=null,w=(k,z,A,U)=>{k(R=>R.map((H,oe)=>oe===z?{...H,[A]:U}:H))};return(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)("div",{className:"truss-estimator",children:[(0,K.jsxs)("div",{className:"quick-order-hero",children:[(0,K.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,K.jsx)("h1",{children:"Paint Calculator"}),(0,K.jsx)("p",{children:"Estimate how much paint you need for your walls, including multiple coats and excluded areas."})]}),(0,K.jsxs)("div",{className:"truss-estimator__card paint-calculator",children:[(0,K.jsx)("h2",{className:"truss-estimator__step-title",children:"Walls, exclusions and coats"}),(0,K.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,K.jsxs)("div",{className:"paint-calculator__section",children:[(0,K.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall dimensions"}),(0,K.jsx)("p",{className:"paint-calculator__hint",children:"Enter the height and width of each wall you want to paint."}),(0,K.jsxs)("div",{className:"paint-calculator__dimensions-header","aria-hidden":"true",children:[(0,K.jsx)("span",{}),(0,K.jsx)("span",{children:"Height (m)"}),(0,K.jsx)("span",{children:"Width (m)"}),(0,K.jsx)("span",{})]}),r.map((k,z)=>(0,K.jsxs)("div",{className:"paint-calculator__row",children:[(0,K.jsxs)("span",{className:"paint-calculator__row-label",children:["Wall ",z+1]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{className:"sr-only",children:"Height (m)"}),(0,K.jsx)("input",{"aria-label":`Wall ${z+1} height in metres`,type:"number",min:"0",step:"0.01",value:k.height,onChange:A=>w(i,z,"height",A.target.value)})]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{className:"sr-only",children:"Width (m)"}),(0,K.jsx)("input",{"aria-label":`Wall ${z+1} width in metres`,type:"number",min:"0",step:"0.01",value:k.width,onChange:A=>w(i,z,"width",A.target.value)})]}),r.length>1?(0,K.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>i(A=>A.filter((U,R)=>R!==z)),children:"Remove"}):null]},`wall-${z}`)),(0,K.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>i(k=>[...k,vc()]),children:"+ Add another wall"})]}),(0,K.jsxs)("div",{className:"paint-calculator__section",children:[(0,K.jsx)("div",{className:"truss-estimator__section-heading",children:"Areas to exclude"}),(0,K.jsx)("p",{className:"paint-calculator__hint",children:"Add windows, sockets, skirting boards or other areas that will not be painted."}),(0,K.jsxs)("div",{className:"paint-calculator__dimensions-header","aria-hidden":"true",children:[(0,K.jsx)("span",{}),(0,K.jsx)("span",{children:"Height (m)"}),(0,K.jsx)("span",{children:"Width (m)"}),(0,K.jsx)("span",{})]}),n.map((k,z)=>(0,K.jsxs)("div",{className:"paint-calculator__row",children:[(0,K.jsxs)("span",{className:"paint-calculator__row-label",children:["Area ",z+1]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{className:"sr-only",children:"Height (m)"}),(0,K.jsx)("input",{"aria-label":`Area ${z+1} height in metres`,type:"number",min:"0",step:"0.01",value:k.height,onChange:A=>w(o,z,"height",A.target.value)})]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{className:"sr-only",children:"Width (m)"}),(0,K.jsx)("input",{"aria-label":`Area ${z+1} width in metres`,type:"number",min:"0",step:"0.01",value:k.width,onChange:A=>w(o,z,"width",A.target.value)})]}),n.length>1?(0,K.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>o(A=>A.filter((U,R)=>R!==z)),children:"Remove"}):null]},`excluded-${z}`)),(0,K.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>o(k=>[...k,vc()]),children:"+ Add another area"})]}),(0,K.jsxs)("div",{className:"paint-calculator__section",children:[(0,K.jsx)("div",{className:"truss-estimator__section-heading",children:"Doors and coats"}),(0,K.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,K.jsxs)("div",{className:"truss-estimator__field-grid paint-calculator__small-fields",children:[(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{children:"Doors"}),(0,K.jsx)("input",{type:"number",min:"0",step:"1",value:l,onChange:k=>c(k.target.value)})]}),(0,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{children:"Double doors"}),(0,K.jsx)("input",{type:"number",min:"0",step:"1",value:p,onChange:k=>m(k.target.value)})]})]}),(0,K.jsxs)("div",{className:"paint-calculator__coat-field",children:[(0,K.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,K.jsxs)("label",{className:"truss-estimator__field",children:[(0,K.jsx)("span",{children:"Number of coats"}),(0,K.jsxs)("select",{value:g,onChange:k=>d(Number(k.target.value)),children:[(0,K.jsx)("option",{value:"1",children:"1 coat"}),(0,K.jsx)("option",{value:"2",children:"2 coats"}),(0,K.jsx)("option",{value:"3",children:"3 coats"})]})]})]})]}),(0,K.jsxs)("div",{className:"paint-calculator__totals",children:[(0,K.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,K.jsxs)("div",{className:"paint-calculator__result-grid",children:[(0,K.jsxs)("div",{children:[(0,K.jsx)("span",{children:"Paintable area"}),(0,K.jsxs)("strong",{children:[O.toFixed(2)," m\xB2"]})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("span",{children:"Coverage"}),(0,K.jsxs)("strong",{children:[g," ",g===1?"coat":"coats"]})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("span",{children:"Paint required"}),(0,K.jsxs)("strong",{children:[f.toFixed(1)," litres"]})]})]}),(0,K.jsx)("p",{className:"paint-calculator__note",children:h?"Based on paint coverage of 10 m\xB2 per litre. Ordered as brilliant white matt emulsion, rounded up to whole tins.":"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,K.jsxs)("div",{className:"paint-calculator__actions",children:[(0,K.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),h?(0,K.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.([u]),disabled:f<=0,children:a}):(0,K.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",disabled:!0,children:"Paint products unavailable"})]})]})]})})}var fr=$(He()),te=$(F()),_c=e=>Number.parseFloat(e)||0,rm={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 im({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,fr.useState)("paving"),[n,o]=(0,fr.useState)("council"),[l,c]=(0,fr.useState)(""),[p,m]=(0,fr.useState)(""),[g,d]=(0,fr.useState)("100"),[b,v]=(0,fr.useState)("50"),[E,O]=(0,fr.useState)(!0),[f,u]=(0,fr.useState)(!0),h=_c(l)*_c(p),w=h,k=h*(_c(g)/1e3),z=h*.04,A=h*(_c(b)/1e3),U=Math.ceil(w/.36),R=Math.ceil(w/.1),H=Math.ceil(k*1700/800),oe=Math.ceil(z*1600/800),Te=Math.ceil(A*1600/800),je=r==="paving"?{qty:U,unit:"each"}:r==="block"?{qty:w,unit:"m2"}:{qty:Te,unit:"bag"},Ve={paving:"paving slab",block:"block paver",gravel:"decorative gravel"}[r],Ne=[{key:`surface-${n}`,label:rm[r].find(le=>le.id===n)?.label??"Surface material",qty:je.qty,unit:je.unit,query:Ve,category:"landscaping"},...E?[{key:"sub-base",label:"MOT Type 1 sub-base",qty:H,unit:"bag",query:"MOT Type 1 sub base",category:"aggregate"}]:[],...f?[{key:"bedding",label:"Sharp sand bedding",qty:oe,unit:"bag",query:"sharp sand",category:"aggregate"}]:[]];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:"Paving and Driveway Calculator"}),(0,te.jsx)("p",{children:"Estimate paving, block paving, sub-base and bedding materials for outdoor areas."})]}),(0,te.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,te.jsx)("h2",{className:"truss-estimator__step-title",children:"Surface and ground build-up"}),(0,te.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,te.jsxs)("div",{className:"materials-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Surface material"}),(0,te.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(([le,Fe,Ee])=>(0,te.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===le?" is-selected":""}`,onClick:()=>{i(le),o(rm[le][0].id)},children:[(0,te.jsx)("div",{className:"truss-estimator__option-title",children:Fe}),(0,te.jsx)("div",{className:"truss-estimator__option-copy",children:Ee})]},le))}),(0,te.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,te.jsx)("span",{children:"Finish"}),(0,te.jsx)("select",{value:n,onChange:le=>o(le.target.value),children:rm[r].map(le=>(0,te.jsx)("option",{value:le.id,children:le.label},le.id))})]})]}),(0,te.jsxs)("div",{className:"materials-calculator__section",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Area and groundwork"}),(0,te.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,te.jsxs)("label",{className:"truss-estimator__field",children:[(0,te.jsx)("span",{children:"Length (m)"}),(0,te.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:le=>c(le.target.value)})]}),(0,te.jsxs)("label",{className:"truss-estimator__field",children:[(0,te.jsx)("span",{children:"Width (m)"}),(0,te.jsx)("input",{type:"number",min:"0",step:"0.01",value:p,onChange:le=>m(le.target.value)})]})]}),r==="gravel"&&(0,te.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,te.jsx)("span",{children:"Gravel depth (mm)"}),(0,te.jsx)("input",{type:"number",min:"0",step:"10",value:b,onChange:le=>v(le.target.value)})]}),E&&(0,te.jsxs)("label",{className:"truss-estimator__field materials-calculator__depth",children:[(0,te.jsx)("span",{children:"Sub-base depth (mm)"}),(0,te.jsx)("input",{type:"number",min:"0",step:"10",value:g,onChange:le=>d(le.target.value)})]}),(0,te.jsxs)("label",{className:"brick-calculator__checkbox materials-calculator__waste",children:[(0,te.jsx)("input",{type:"checkbox",checked:E,onChange:le=>O(le.target.checked)}),(0,te.jsx)("span",{children:"Include MOT Type 1 sub-base"})]}),(0,te.jsxs)("label",{className:"brick-calculator__checkbox materials-calculator__waste",children:[(0,te.jsx)("input",{type:"checkbox",checked:f,onChange:le=>u(le.target.checked)}),(0,te.jsx)("span",{children:"Include sharp sand bedding"})]})]}),(0,te.jsxs)("div",{className:"materials-calculator__totals",children:[(0,te.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,te.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"Surface area"}),(0,te.jsxs)("strong",{children:[h.toFixed(2)," m\xB2"]})]}),(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:r==="paving"?"Paving slabs":r==="block"?"Block paving":"Gravel"}),(0,te.jsx)("strong",{children:r==="paving"?`${U} slabs`:r==="block"?`${w.toFixed(2)} m\xB2`:`${Te} bulk bags`})]}),E&&(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"MOT Type 1"}),(0,te.jsxs)("strong",{children:[H," bulk bags"]})]}),f&&(0,te.jsxs)("div",{children:[(0,te.jsx)("span",{children:"Sharp sand"}),(0,te.jsxs)("strong",{children:[oe," bulk bags"]})]})]}),(0,te.jsx)("p",{className:"materials-calculator__note",children:"Slab and block quantities use typical sizes. Confirm pack coverage and laying pattern before ordering."})]}),(0,te.jsxs)("div",{className:"materials-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?.(Ne),disabled:h<=0,children:a})]})]})]})})}var ml=$(He()),re=$(F()),yx=2.88,Fv=[{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"}],Wv=()=>({length:"",height:""}),nm=e=>Number.parseFloat(e)||0;function om({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,ml.useState)([Wv()]),[n,o]=(0,ml.useState)(""),[l,c]=(0,ml.useState)("standard"),[p,m]=(0,ml.useState)("screws"),g=r.reduce((z,A)=>z+nm(A.length)*nm(A.height),0),d=Math.max(0,g-nm(n)),b=Math.ceil(d/yx),v=Math.ceil(d*12),E=Math.ceil(v/1e3),O=Math.ceil(d*1.2),f=Math.ceil(O/90),u=Math.ceil(d/3.5),h=Fv.find(z=>z.id===l)?.label??"Standard",w=[{key:"board",label:`${h} plasterboard`,qty:b,unit:"sheet",query:`${h} plasterboard`,category:"plasterboard"},...p==="screws"?[{key:"screws",label:"Drywall screws",qty:E,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:f,unit:"roll",query:"plasterboard joint tape",category:"plasterboard"}],k=(z,A,U)=>{i(R=>R.map((H,oe)=>oe===z?{...H,[A]:U}:H))};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:"Plasterboard and Drylining Calculator"}),(0,re.jsx)("p",{children:"Estimate boards, fixings and jointing materials for walls and ceilings."})]}),(0,re.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,re.jsx)("h2",{className:"truss-estimator__step-title",children:"Boards, fixings and jointing"}),(0,re.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,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Board type"}),(0,re.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--two",children:Fv.map(z=>(0,re.jsxs)("button",{type:"button",className:`truss-estimator__option-card${l===z.id?" is-selected":""}`,onClick:()=>c(z.id),children:[(0,re.jsx)("div",{className:"truss-estimator__option-title",children:z.label}),(0,re.jsx)("div",{className:"truss-estimator__option-copy",children:z.blurb})]},z.id))})]}),(0,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Fixing method"}),(0,re.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(([z,A,U])=>(0,re.jsxs)("button",{type:"button",className:`truss-estimator__option-card${p===z?" is-selected":""}`,onClick:()=>m(z),children:[(0,re.jsx)("div",{className:"truss-estimator__option-title",children:A}),(0,re.jsx)("div",{className:"truss-estimator__option-copy",children:U})]},z))})]}),(0,re.jsxs)("div",{className:"materials-calculator__section",children:[(0,re.jsx)("div",{className:"truss-estimator__section-heading",children:"Wall and ceiling areas"}),(0,re.jsx)("p",{className:"materials-calculator__hint",children:"Add each surface separately so different wall sizes are easy to measure."}),(0,re.jsxs)("div",{className:"materials-calculator__dimensions-header",children:[(0,re.jsx)("span",{children:"Surface"}),(0,re.jsx)("span",{children:"Length (m)"}),(0,re.jsx)("span",{children:"Height (m)"}),(0,re.jsx)("span",{})]}),r.map((z,A)=>(0,re.jsxs)("div",{className:"materials-calculator__surface-row",children:[(0,re.jsxs)("span",{children:["Surface ",A+1]}),(0,re.jsx)("input",{"aria-label":`Surface ${A+1} length`,type:"number",min:"0",step:"0.01",value:z.length,onChange:U=>k(A,"length",U.target.value)}),(0,re.jsx)("input",{"aria-label":`Surface ${A+1} height`,type:"number",min:"0",step:"0.01",value:z.height,onChange:U=>k(A,"height",U.target.value)}),r.length>1?(0,re.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>i(U=>U.filter((R,H)=>H!==A)),children:"Remove"}):null]},`surface-${A}`)),(0,re.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>i(z=>[...z,Wv()]),children:"+ Add another surface"}),(0,re.jsxs)("label",{className:"truss-estimator__field materials-calculator__openings",children:[(0,re.jsxs)("span",{children:["Openings to deduct (m\xB2) ",(0,re.jsx)("small",{children:"optional"})]}),(0,re.jsx)("input",{type:"number",min:"0",step:"0.01",value:n,onChange:z=>o(z.target.value)})]})]}),(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:"Board area"}),(0,re.jsxs)("strong",{children:[d.toFixed(2)," m\xB2"]})]}),(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"2.4 x 1.2 m boards"}),(0,re.jsx)("strong",{children:b})]}),(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:p==="screws"?"Drywall screws":"Board adhesive"}),(0,re.jsx)("strong",{children:p==="screws"?`${v} (${E} boxes)`:`${u} bags`})]}),(0,re.jsxs)("div",{children:[(0,re.jsx)("span",{children:"Joint tape"}),(0,re.jsxs)("strong",{children:[O," m (",f," rolls)"]})]})]}),(0,re.jsx)("p",{className:"materials-calculator__note",children:"Figures are estimates. Confirm board specification, fixing patterns and fire or acoustic requirements 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?.(w),disabled:d<=0,children:a})]})]})]})})}var fl=$(He());var y=$(F()),At={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}}}},xc=["range","pitchAndDimensions","quantityAndGirders","bracing"],_x={range:null,pitch:null,spanMM:"",overhangMM:"",roofLengthM:"",centres:null,girderCount:0,bracing:null,treatment:null,contact:{name:"",email:""}};function xx({degrees:e}){let a=e*Math.PI/180,i=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,${i}`,fill:"var(--accent-light)",stroke:"var(--accent)",strokeWidth:"3",strokeLinejoin:"round"})]})}function kx({type:e}){let t="#b3835a",a="#5c3b22",r="#d9b48f",i="#d3d8de",n="#7c8494",o=(m,g,d,b,v=8,E)=>{let O=d-m,f=b-g,u=Math.hypot(O,f)||1,h=-f/u,w=O/u,k=v*.2;return(0,y.jsxs)("g",{children:[(0,y.jsx)("line",{x1:m,y1:g,x2:d,y2:b,stroke:a,strokeWidth:v+3,strokeLinecap:"square"}),(0,y.jsx)("line",{x1:m,y1:g,x2:d,y2:b,stroke:t,strokeWidth:v,strokeLinecap:"square"}),(0,y.jsx)("line",{x1:m-h*k,y1:g-w*k,x2:d-h*k,y2:b-w*k,stroke:r,strokeWidth:Math.max(1.5,v*.24),strokeLinecap:"round",opacity:"0.9"})]},E)},l=(m,g,d)=>(0,y.jsxs)("g",{children:[(0,y.jsx)("rect",{x:m-7.5,y:g-5.5,width:"15",height:"11",rx:"2",fill:i,stroke:n,strokeWidth:"1"}),(0,y.jsx)("circle",{cx:m-4,cy:g-2.5,r:"1",fill:n}),(0,y.jsx)("circle",{cx:m+4,cy:g-2.5,r:"1",fill:n}),(0,y.jsx)("circle",{cx:m-4,cy:g+2.5,r:"1",fill:n}),(0,y.jsx)("circle",{cx:m+4,cy:g+2.5,r:"1",fill:n}),(0,y.jsx)("circle",{cx:m,cy:g,r:"1",fill:n})]},d),c=(m,g)=>(0,y.jsx)("rect",{x:m-9,y:"110",width:"18",height:"10",fill:a},g),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 Sx({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 e0({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 lm({onBack:e}){let[t,a]=(0,fl.useState)(0),[r,i]=(0,fl.useState)(_x),[n,o]=(0,fl.useState)(!1),[l,c]=(0,fl.useState)(!1),p=()=>{let f=Number.parseFloat(r.roofLengthM)||0,u=Number.parseFloat(r.centres??"");return f<=0||!u?0:Math.ceil(f*1e3/u)+1},g=(()=>{let f=r.range?At.ranges[r.range]:At.ranges.standard,u=r.pitch??"22.5",h=At.pitchMultipliers[u],w=(Number.parseFloat(r.spanMM)||0)/1e3,z=(Number.parseFloat(r.overhangMM)||0)>At.overhang.thresholdMM,A=p(),U=A+r.girderCount,R=Number.parseFloat(r.roofLengthM)||0,H=r.treatment?At.treatment[r.treatment]:At.treatment.untreated,oe=At.estimate.ranges[r.range??"standard"],Te=oe.supplyAt8m*Math.max(.7,w/8)*h*(1+H.surchargePct)+(z?At.overhang.surchargePerTruss:0),je=A*Te,Ve=r.girderCount*Te*At.estimate.girderMultiplier,Ne=r.bracing==="yes"?R*At.estimate.bracingPerMetre:0,we=je+Ve+Ne+At.estimate.delivery,le=At.estimate.design+A*oe.installPerTruss+r.girderCount*40,Fe=we+le,Ee=Fe*.2;return{range:f,count:A,girderCount:r.girderCount,overhangApplies:z,overhangUnits:U,roofLengthM:R,treatment:H,trussSupply:je,bracingMaterials:Ne,delivery:At.estimate.delivery,labour:le,subtotal:Fe,vat:Ee,total:Fe+Ee}})(),d=()=>{let f=xc[t];return f==="range"?!!r.range:f==="pitchAndDimensions"?!!r.pitch&&r.spanMM.trim()!==""&&r.overhangMM.trim()!=="":f==="quantityAndGirders"?r.roofLengthM.trim()!==""&&!!r.centres:f==="bracing"?!!r.bracing&&!!r.treatment:!0},b=t===xc.length-1?"View truss request":"Next",v=()=>{n?o(!1):t===0?e():a(f=>f-1)},E=()=>{d()&&(t===xc.length-1?(c(!1),o(!0)):a(f=>f+1))},O=()=>{let f=xc[t];return f==="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(At.ranges).map(([u,h])=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r.range===u?" is-selected":""}`,onClick:()=>i(w=>({...w,range:u})),children:[(0,y.jsx)(kx,{type:u}),(0,y.jsxs)("div",{className:"truss-estimator__option-info",children:[(0,y.jsx)("div",{className:"truss-estimator__option-title",children:h.label}),(0,y.jsx)("div",{className:"truss-estimator__option-copy",children:h.blurb})]})]},u))})]}):f==="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=>i(h=>({...h,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=>i(h=>({...h,overhangMM:u.target.value}))}),(0,y.jsxs)("small",{children:["Overhangs beyond ",At.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:At.pitches.map(u=>(0,y.jsxs)("button",{type:"button",className:`truss-estimator__visual-card${r.pitch===u?" is-selected":""}`,onClick:()=>i(h=>({...h,pitch:u})),children:[(0,y.jsx)(xx,{degrees:Number.parseFloat(u)}),(0,y.jsxs)("span",{children:[u,"\xB0"]})]},u))})]}):f==="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=>i(h=>({...h,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:At.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:()=>i(h=>({...h,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:()=>i(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:()=>i(u=>({...u,girderCount:Math.min(3,u.girderCount+1)})),children:"+"})]})]}):f==="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:()=>i(h=>({...h,bracing:u.id})),children:[(0,y.jsx)(Sx,{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:()=>i(u=>({...u,treatment:"untreated"})),children:[(0,y.jsx)(e0,{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:()=>i(u=>({...u,treatment:"treated"})),children:[(0,y.jsx)(e0,{treated:!0}),(0,y.jsx)("span",{children:"Treated (+8% cost)"}),(0,y.jsx)("small",{children:"Applies to trusses, girders and overhang"})]})]})]}):null};return n?(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:[g.range.label," roof trusses"]})]}),(0,y.jsxs)("strong",{children:[g.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:g.treatment.label})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Girder trusses"}),(0,y.jsx)("strong",{children:g.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(g.trussSupply)})]}),g.bracingMaterials>0&&(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Bracing materials allowance"}),(0,y.jsx)("strong",{children:nt(g.bracingMaterials)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Delivery allowance"}),(0,y.jsx)("strong",{children:nt(g.delivery)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Design and installation labour"}),(0,y.jsx)("strong",{children:nt(g.labour)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"Subtotal (ex. VAT)"}),(0,y.jsx)("strong",{children:nt(g.subtotal)})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{children:"VAT (20%)"}),(0,y.jsx)("strong",{children:nt(g.vat)})]}),(0,y.jsxs)("div",{className:"truss-request__price-total",children:[(0,y.jsx)("span",{children:"Estimated total"}),(0,y.jsx)("strong",{children:nt(g.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:v,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:O()}),(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:v,children:"Back"}),(0,y.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:"0 1 70%",marginTop:0},onClick:E,disabled:!d(),children:[(0,y.jsx)("span",{children:b}),(0,y.jsx)("span",{className:"arrow",children:(0,y.jsx)(Qt,{})})]})]})]})]})})}var Mi=$(He()),I=$(F()),r0=e=>Number.parseFloat(e)||0,kc=(e,t)=>r0(e)*(t==="m"?1:.3048),t0=()=>({length:"",width:""}),a0=[{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 Nx({profile:e}){return(0,I.jsxs)("svg",{className:"skirting-calculator__profile-diagram",viewBox:"0 0 120 84","aria-hidden":"true",children:[(0,I.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,I.jsx)("line",{x1:"12",y1:"70",x2:"108",y2:"70"})]})}function sm({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Mi.useState)("total"),[n,o]=(0,Mi.useState)("m"),[l,c]=(0,Mi.useState)(""),[p,m]=(0,Mi.useState)([t0()]),[g,d]=(0,Mi.useState)(""),[b,v]=(0,Mi.useState)("chamfered"),E="4.4",O=r==="total"?kc(l,n):p.reduce((k,z)=>k+2*(kc(z.length,n)+kc(z.width,n)),0),f=Math.max(0,O-kc(g,n)),u=Math.ceil(f/r0(E)),h=[{key:`skirting-${b}`,label:`${a0.find(k=>k.id===b)?.label} skirting board`,qty:f,unit:"m",query:"skirting board",category:"skirting"}],w=(k,z,A)=>{m(U=>U.map((R,H)=>H===k?{...R,[z]:A}:R))};return(0,I.jsx)(I.Fragment,{children:(0,I.jsxs)("div",{className:"truss-estimator",children:[(0,I.jsxs)("div",{className:"quick-order-hero",children:[(0,I.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,I.jsx)("h1",{children:"Skirting Board Calculator"}),(0,I.jsx)("p",{children:"Work out how many skirting board lengths you need for one room or a whole project."})]}),(0,I.jsxs)("div",{className:"truss-estimator__card skirting-calculator",children:[(0,I.jsx)("h2",{className:"truss-estimator__step-title",children:"Measure by room or total length"}),(0,I.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,I.jsxs)("div",{className:"skirting-calculator__section",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"How would you like to measure?"}),(0,I.jsxs)("div",{className:"brick-calculator__unit-toggle skirting-calculator__mode-toggle",role:"group","aria-label":"Calculation method",children:[(0,I.jsx)("button",{type:"button",className:r==="total"?"is-selected":"",onClick:()=>i("total"),children:"Total length"}),(0,I.jsx)("button",{type:"button",className:r==="rooms"?"is-selected":"",onClick:()=>i("rooms"),children:"Room by room"})]})]}),(0,I.jsxs)("div",{className:"skirting-calculator__section",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"Measurements"}),(0,I.jsxs)("div",{className:"skirting-calculator__unit-row",children:[(0,I.jsx)("span",{children:"Units"}),(0,I.jsxs)("div",{className:"brick-calculator__unit-toggle",role:"group","aria-label":"Measurement units",children:[(0,I.jsx)("button",{type:"button",className:n==="m"?"is-selected":"",onClick:()=>o("m"),children:"Metres"}),(0,I.jsx)("button",{type:"button",className:n==="ft"?"is-selected":"",onClick:()=>o("ft"),children:"Feet"})]})]}),r==="total"?(0,I.jsxs)("label",{className:"truss-estimator__field skirting-calculator__single-field",children:[(0,I.jsxs)("span",{children:["Total skirting length (",n,")"]}),(0,I.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:k=>c(k.target.value)})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"skirting-calculator__dimensions-header",children:[(0,I.jsx)("span",{children:"Room"}),(0,I.jsxs)("span",{children:["Length (",n,")"]}),(0,I.jsxs)("span",{children:["Width (",n,")"]}),(0,I.jsx)("span",{})]}),p.map((k,z)=>(0,I.jsxs)("div",{className:"skirting-calculator__room-row",children:[(0,I.jsxs)("span",{className:"skirting-calculator__room-label",children:["Room ",z+1]}),(0,I.jsx)("input",{"aria-label":`Room ${z+1} length in ${n}`,type:"number",min:"0",step:"0.01",value:k.length,onChange:A=>w(z,"length",A.target.value)}),(0,I.jsx)("input",{"aria-label":`Room ${z+1} width in ${n}`,type:"number",min:"0",step:"0.01",value:k.width,onChange:A=>w(z,"width",A.target.value)}),p.length>1?(0,I.jsx)("button",{type:"button",className:"paint-calculator__remove",onClick:()=>m(A=>A.filter((U,R)=>R!==z)),children:"Remove"}):null]},`room-${z}`)),(0,I.jsx)("button",{type:"button",className:"paint-calculator__add",onClick:()=>m(k=>[...k,t0()]),children:"+ Add another room"})]}),(0,I.jsxs)("label",{className:"truss-estimator__field skirting-calculator__single-field",children:[(0,I.jsxs)("span",{children:["Openings and doorways to deduct (",n,") ",(0,I.jsx)("small",{children:"optional"})]}),(0,I.jsx)("input",{type:"number",min:"0",step:"0.01",value:g,onChange:k=>d(k.target.value)})]})]}),(0,I.jsxs)("div",{className:"skirting-calculator__section",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"Profile"}),(0,I.jsx)("p",{className:"skirting-calculator__hint",children:"Choose the finish you want for the fixed 4.4m white-primed MDF boards."}),(0,I.jsx)("div",{className:"architrave-calculator__profiles",children:a0.map(k=>(0,I.jsxs)("button",{type:"button",className:`truss-estimator__option-card${b===k.id?" is-selected":""}`,onClick:()=>v(k.id),children:[(0,I.jsx)(Nx,{profile:k.id}),(0,I.jsx)("div",{className:"truss-estimator__option-title",children:k.label}),(0,I.jsx)("div",{className:"truss-estimator__option-copy",children:k.blurb})]},k.id))})]}),(0,I.jsxs)("div",{className:"skirting-calculator__section",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"Board and waste"}),(0,I.jsx)("div",{className:"truss-estimator__field-grid skirting-calculator__options-grid",children:(0,I.jsxs)("label",{className:"truss-estimator__field",children:[(0,I.jsx)("span",{children:"Board length"}),(0,I.jsx)("input",{value:"4.40 m",disabled:!0})]})}),(0,I.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,I.jsxs)("div",{className:"skirting-calculator__totals",children:[(0,I.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,I.jsxs)("div",{className:"skirting-calculator__result-grid",children:[(0,I.jsxs)("div",{children:[(0,I.jsx)("span",{children:"Net skirting"}),(0,I.jsxs)("strong",{children:[f.toFixed(2)," m"]})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("span",{children:"Board lengths"}),(0,I.jsx)("strong",{children:u})]})]}),(0,I.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,I.jsxs)("div",{className:"skirting-calculator__actions",children:[(0,I.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,I.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(h),disabled:f<=0,children:a})]})]})]})})}var Xn=$(He()),ne=$(F()),hl=e=>Number.parseFloat(e)||0;function cm({onBack:e,onReview:t,submitLabel:a="Add to basket"}){let[r,i]=(0,Xn.useState)("studs"),[n,o]=(0,Xn.useState)(""),[l,c]=(0,Xn.useState)(""),[p,m]=(0,Xn.useState)("600"),[g,d]=(0,Xn.useState)("2.4"),b=n&&l&&p?Math.ceil(hl(l)/(hl(p)/1e3))+1:0,v=b*hl(n),E=hl(g)>0?Math.ceil(v/hl(g)):0,O=[{key:r,label:{studs:"Stud timber",joists:"Joist timber",battens:"Batten timber"}[r],qty:v,unit:"m",query:{studs:"cls studwork timber",joists:"timber joist",battens:"roofing batten"}[r],category:"timber"}],f={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"]},h={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,ne.jsx)(ne.Fragment,{children:(0,ne.jsxs)("div",{className:"truss-estimator",children:[(0,ne.jsxs)("div",{className:"quick-order-hero",children:[(0,ne.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,ne.jsx)("h1",{children:"Timber Calculator"}),(0,ne.jsx)("p",{children:"Estimate studs, joists or battens from a run length, width and spacing."})]}),(0,ne.jsxs)("div",{className:"truss-estimator__card materials-calculator",children:[(0,ne.jsx)("h2",{className:"truss-estimator__step-title",children:"Member size and spacing"}),(0,ne.jsxs)("p",{className:"truss-estimator__step-sub",children:[h.help," Enter the member length and centres to estimate the number of pieces and stock lengths."]}),(0,ne.jsxs)("div",{className:"materials-calculator__section",children:[(0,ne.jsx)("div",{className:"truss-estimator__section-heading",children:"Timber use"}),(0,ne.jsx)("div",{className:"truss-estimator__option-grid truss-estimator__option-grid--three",children:Object.keys(f).map(w=>(0,ne.jsxs)("button",{type:"button",className:`truss-estimator__option-card${r===w?" is-selected":""}`,onClick:()=>i(w),children:[(0,ne.jsx)("div",{className:"truss-estimator__option-title",children:f[w][0]}),(0,ne.jsx)("div",{className:"truss-estimator__option-copy",children:f[w][1]})]},w))})]}),(0,ne.jsxs)("div",{className:"materials-calculator__section",children:[(0,ne.jsx)("div",{className:"truss-estimator__section-heading",children:"Dimensions and spacing"}),(0,ne.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,ne.jsxs)("label",{className:"truss-estimator__field",children:[(0,ne.jsxs)("span",{children:[h.member," (m)"]}),(0,ne.jsx)("input",{type:"number",min:"0",step:"0.01",value:n,onChange:w=>o(w.target.value)})]}),(0,ne.jsxs)("label",{className:"truss-estimator__field",children:[(0,ne.jsxs)("span",{children:[h.overall," (m)"]}),(0,ne.jsx)("input",{type:"number",min:"0",step:"0.01",value:l,onChange:w=>c(w.target.value)})]})]}),(0,ne.jsxs)("div",{className:"truss-estimator__field-grid",children:[(0,ne.jsxs)("label",{className:"truss-estimator__field",children:[(0,ne.jsx)("span",{children:"Centres (mm)"}),(0,ne.jsxs)("select",{value:p,onChange:w=>m(w.target.value),children:[(0,ne.jsx)("option",{value:"300",children:"300 mm"}),(0,ne.jsx)("option",{value:"400",children:"400 mm"}),(0,ne.jsx)("option",{value:"450",children:"450 mm"}),(0,ne.jsx)("option",{value:"600",children:"600 mm"})]})]}),(0,ne.jsxs)("label",{className:"truss-estimator__field",children:[(0,ne.jsx)("span",{children:"Stock length (m)"}),(0,ne.jsxs)("select",{value:g,onChange:w=>d(w.target.value),children:[(0,ne.jsx)("option",{value:"2.4",children:"2.40 m"}),(0,ne.jsx)("option",{value:"3.6",children:"3.60 m"}),(0,ne.jsx)("option",{value:"4.8",children:"4.80 m"})]})]})]})]}),(0,ne.jsxs)("div",{className:"materials-calculator__totals",children:[(0,ne.jsx)("div",{className:"truss-estimator__section-heading",children:"Totals"}),(0,ne.jsxs)("div",{className:"materials-calculator__result-grid",children:[(0,ne.jsxs)("div",{children:[(0,ne.jsx)("span",{children:h.count}),(0,ne.jsx)("strong",{children:b})]}),(0,ne.jsxs)("div",{children:[(0,ne.jsx)("span",{children:"Linear metres"}),(0,ne.jsxs)("strong",{children:[v.toFixed(2)," m"]})]}),(0,ne.jsxs)("div",{children:[(0,ne.jsxs)("span",{children:[g," m lengths"]}),(0,ne.jsx)("strong",{children:E})]})]}),(0,ne.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,ne.jsxs)("div",{className:"materials-calculator__actions",children:[(0,ne.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary estimator-actions__back",onClick:e,children:"Back"}),(0,ne.jsx)("button",{type:"button",className:"cta-btn estimator-actions__calculate",onClick:()=>t?.(O),disabled:v<=0,children:a})]})]})]})})}var um=[{id:"truss",title:"Roof Truss Calculator",desc:"Estimate trusses, girders and roof structure costs.",imageUrl:"/tool-images/truss.webp",Component:lm},{id:"fencing",title:"Fencing Calculator",desc:"Estimate fence panels, posts, gravel boards and fixings.",imageUrl:"/tool-images/fencing.webp",Component:em},{id:"decking",title:"Decking Calculator",desc:"Estimate boards, substructure and fixing quantities.",imageUrl:"/tool-images/decking.webp",Component:Fd},{id:"brick-block",title:"Brick and Block Calculator",desc:"Estimate masonry units and ready-mixed mortar for a wall.",imageUrl:"/tool-images/brick-block.webp",Component:Kd},{id:"paint",title:"Paint Calculator",desc:"Estimate paint for walls, doors and multiple coats.",imageUrl:"/tool-images/paint.webp",Component:am},{id:"skirting",title:"Skirting Board Calculator",desc:"Estimate skirting lengths for rooms and wall runs.",imageUrl:"/tool-images/skirting.webp",Component:sm},{id:"architrave",title:"Architrave Calculator",desc:"Estimate architrave lengths for door and window openings.",imageUrl:"/tool-images/architrave.webp",Component:Zd},{id:"concrete-aggregate",title:"Concrete and Aggregate Calculator",desc:"Estimate concrete, MOT, sand and gravel quantities.",imageUrl:"/tool-images/concrete-aggregate.webp",Component:Jd},{id:"plasterboard",title:"Plasterboard Calculator",desc:"Estimate plasterboard sheets, screws, tape and adhesive.",imageUrl:"/tool-images/plasterboard.webp",Component:om},{id:"insulation",title:"Insulation Calculator",desc:"Estimate insulation packs for floors, walls, roofs and lofts.",imageUrl:"/tool-images/insulation.webp",Component:tm},{id:"timber",title:"Timber Calculator",desc:"Estimate studs, joists and battens from spacing and lengths.",imageUrl:"/tool-images/timber.webp",Component:cm},{id:"paving",title:"Paving and Driveway Calculator",desc:"Estimate paving, block paving, MOT and sharp sand.",imageUrl:"/tool-images/paving.webp",Component:im}];var pm=$(He());var Cx=new Set(["bag","box","roll","pack"]),qx=new Set(["each","bag","box","roll","pack","tub"]);function gl(e,t){let r=(t?.conversion?.request_uoms_supported??"").split(",").map(o=>o.trim().toLowerCase()).includes("sales_unit");if(e==="each"){let o=(t?.uoi_count??1)===1&&(t?.conversion?.sales_unit_size??1)===1;return r&&o?"sales_unit":e}if(!Cx.has(e))return e;if(r)return"sales_unit";let i=t?.uoi;return i!=null&&qx.has(i.toLowerCase())&&(t?.uoi_count??1)===1?i:e}var i0=new Map;function Ex(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 Ti(e,t,a=12,r){let i=`${Ot().client??""}||${e}||${t??""}||${a}||${r??""}`,n=i0.get(i);if(n)return n;let o=new URLSearchParams({q:e,limit:String(a)});t&&o.set("category",t),r&&o.set("account",r);let l=await fetch(Ta(`/api/catalogue/search?${o.toString()}`),{headers:bi()}),c=await Ga(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(Ex):[];return i0.set(i,p),p}async function n0(e,t,a){return await Promise.all(e.map(async i=>{try{let n=a?dl(a,i):null,[o,l]=await Promise.all([n?Ti(n,void 0,void 0,t).then(p=>p.find(m=>m.product_id===n.split(" ")[0]),()=>{}):void 0,Ti(i.query,i.category,void 0,t)]),c=o?[o,...l.filter(p=>p.product_id!==o.product_id)]:l;return{requirement:i,candidates:c}}catch{return{requirement:i,candidates:[]}}}))}async function o0(){let e=await fetch(Ta("/api/catalogue"),{headers:bi()});if(!e.ok)return{itemCount:0,uploadedAt:null};let t=await Ga(e);return{itemCount:Number(t?.itemCount)||0,uploadedAt:t?.uploadedAt??null}}var Wt=$(F()),Mx=1500;function l0(e){let{addManyToCart:t,clearCart:a,openBasket:r}=Dn(),[i,n]=(0,pm.useState)(!1),[o,l]=(0,pm.useState)(null);return{adding:i,basketError:o,addToBasket:async(p,m)=>{let g=Date.now();n(!0),l(null);try{let d=await Promise.all(p.filter(v=>v.qty>0).map(async v=>{let E=(await Ti(v.search)).find(O=>O.product_id===v.productId);if(!E)throw new Error("A selected product is no longer available in this catalogue.");return On(E,{lineId:`${e}:${v.key}`,description:E.description,unit:gl(v.unit??"each",E),qty:v.qty,calculatorWasteIncluded:m})})),b=Mx-(Date.now()-g);b>0&&await new Promise(v=>window.setTimeout(v,b)),a(),t(d),r()}catch(d){l(d instanceof Error?d.message:"Could not add the products to your basket.")}finally{n(!1)}}}}function s0({toolTitle:e}){return(0,Wt.jsx)(Wt.Fragment,{children:(0,Wt.jsxs)("div",{className:"truss-estimator",children:[(0,Wt.jsxs)("div",{className:"quick-order-hero",children:[(0,Wt.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Wt.jsx)("h1",{children:"Your Materials"}),(0,Wt.jsxs)("p",{children:["Calculating quantities from the ",e,"."]})]}),(0,Wt.jsx)("div",{className:"truss-estimator__card",children:(0,Wt.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{flex:1,justifyContent:"center"},children:[(0,Wt.jsx)(wi,{}),(0,Wt.jsx)("p",{className:"banter-message is-visible",children:"Preparing your materials\u2026"})]})})]})})}var Nc=$(He());var Le=$(He());var C=$(F()),Tx=[{dir:"asc",label:"Description (A-Z)"},{dir:"desc",label:"Description (Z-A)"}],dm={wasteFactorEnabled:!0},zx=3e3,c0=null;function Sc(e,t){let a=ol(t);return a?`${e.toFixed(2)} ${a}`:e.toFixed(2)}function Rx(e){return e&&e.length>0?e.join(" x "):"-"}function mm({toolId:e,requirements:t,ready:a,onBack:r,onTotalChange:i}){let n=vv(),o=`${e}~${t.map(N=>`${N.key}|${N.query}|${N.category??""}|${N.qty}`).join("~")}`,l=o!==c0,[c,p]=(0,Le.useState)(null),[m,g]=(0,Le.useState)([]),[d,b]=(0,Le.useState)(l),[v,E]=(0,Le.useState)(null),[O,f]=(0,Le.useState)("tile"),[u,h]=(0,Le.useState)(null),[w,k]=(0,Le.useState)(""),[z,A]=(0,Le.useState)(null),[U,R]=(0,Le.useState)(""),[H,oe]=(0,Le.useState)([]),[Te,je]=(0,Le.useState)(new Set),[Ve,Ne]=(0,Le.useState)(null),[we,le]=(0,Le.useState)(""),[Fe,Ee]=(0,Le.useState)([]),Nt=(0,Le.useRef)(null),Z=(0,Le.useRef)(!1),ge=N=>`${e}:${N}`,Re=N=>On(N.chosen,{lineId:ge(N.requirement.key),description:N.requirement.label,unit:gl(N.requirement.unit,N.chosen),qty:N.requirement.qty}),bt=(0,Le.useMemo)(()=>t.map(N=>`${N.key}|${N.query}|${N.category??""}`).join("~"),[t]);(0,Le.useEffect)(()=>{let N=!1;return o0().then(L=>{N||p(L.itemCount>0)}).catch(()=>{N||p(!1)}),()=>{N=!0}},[]),(0,Le.useEffect)(()=>{if(!a||!c)return;let N=!1,L;l&&b(!0),E(null);let X=Date.now();return(async()=>{let ue=null;try{ue=(await n0(t,void 0,e)).map(({requirement:vt,candidates:mt})=>({requirement:vt,candidates:mt,chosen:mt[0]??null}))}catch(ke){N||E(ke instanceof Error?ke.message:"Could not load products")}if(!N){if(c0=o,l){let ke=zx-(Date.now()-X);ke>0&&await new Promise(vt=>{L=window.setTimeout(vt,ke)})}N||(ue&&(g(ue),!Z.current&&n&&(Z.current=!0,n.addManyToCart(ue.filter(ke=>ke.chosen).map(Re)))),b(!1))}})(),()=>{N=!0,window.clearTimeout(L)}},[a,c,bt]),(0,Le.useEffect)(()=>{if(!z)return;let N=U.trim();if(!N){oe([]);return}let L=!1,X=window.setTimeout(()=>{Ti(N).then(ue=>{L||oe(ue)}).catch(()=>{L||oe([])})},250);return()=>{L=!0,window.clearTimeout(X)}},[z,U]),(0,Le.useEffect)(()=>{if(!Ve)return;let N=we.trim();if(!N){Ee([]);return}let L=!1,X=window.setTimeout(()=>{Ti(N).then(ue=>{L||Ee(ue)}).catch(()=>{L||Ee([])})},250);return()=>{L=!0,window.clearTimeout(X)}},[Ve,we]);let jt=(0,Le.useMemo)(()=>{let N=w.trim().toLowerCase(),L=N?m.filter(X=>X.requirement.label.toLowerCase().includes(N)||(X.chosen?.description??"").toLowerCase().includes(N)||(X.chosen?.product_id??"").toLowerCase().includes(N)):m;return u?[...L].sort((X,ue)=>{let ke=X.requirement.label.localeCompare(ue.requirement.label);return u==="asc"?ke:-ke}):L},[m,w,u]),Ct=jt.filter(N=>N.chosen),wt=jt.filter(N=>!N.chosen),be=m.filter(N=>N.chosen),de=be.filter(N=>N.chosen?.price==null).length,tt=be.reduce((N,L)=>N+(Ft(Re(L),dm).lineTotal??0),0);if((0,Le.useEffect)(()=>{i?.(tt)},[tt,i]),!a||c===!1)return null;let T=n?be.filter(N=>n.cart[ge(N.requirement.key)]).length:0,G=Ve?m.find(N=>N.requirement.key===Ve)??null:null,ce=we.trim()?Fe:G?.candidates??[],ve=N=>{let L=z===N.requirement.key;A(L?null:N.requirement.key),R(L?"":N.requirement.query)},Ye=(N,L)=>{let X=m.find(ue=>ue.requirement.key===N);g(ue=>ue.map(ke=>ke.requirement.key===N?{...ke,chosen:L}:ke)),n&&X&&n.cart[ge(N)]&&n.addToCart(Re({...X,chosen:L})),A(null),R("")},qe=N=>{g(L=>L.map(X=>X.requirement.key===N?{...X,chosen:null}:X)),n?.cart[ge(N)]&&n.removeFromCart(ge(N))},x=N=>{Ne(N.requirement.key),le(""),Ee([])},_=()=>{Ne(null),le(""),Ee([])},q=N=>{if(!n)return;let L=ge(N.requirement.key);n.cart[L]?n.removeFromCart(L):n.addToCart(Re(N))},D=N=>{je(L=>{let X=new Set(L);return X.has(N)?X.delete(N):X.add(N),X})},V=N=>{let L=H.length>0?H:N.candidates;return(0,C.jsxs)("div",{className:"estimator-products__picker",children:[(0,C.jsx)("input",{type:"text",className:"results-search-input",value:U,autoFocus:!0,placeholder:"Search products in catalogue...",onChange:X=>R(X.target.value),"aria-label":`Search a product for ${N.requirement.label}`}),(0,C.jsxs)("div",{className:"estimator-products__options",children:[L.map(X=>(0,C.jsxs)("button",{type:"button",className:`estimator-products__option${X.product_id===N.chosen?.product_id?" is-selected":""}`,onClick:()=>Ye(N.requirement.key,X),children:[(0,C.jsx)("span",{children:X.description}),(0,C.jsxs)("span",{className:"results-row-meta",children:[X.product_id,X.price!=null&&` \xB7 ${nt(X.price)}`]})]},X.product_id)),L.length===0&&(0,C.jsx)("p",{className:"results-empty-hint",children:"No matching products."})]})]})};return(0,C.jsxs)("section",{className:"estimator-products results-tile-section","aria-label":"Matched products",children:[!d&&(0,C.jsxs)("div",{className:"estimator-products__head",children:[(0,C.jsxs)("div",{className:"results-tile-section__head",children:[(0,C.jsx)("h3",{children:"Matched Products"}),(0,C.jsx)("p",{children:"Products matched to your estimate, check before adding to your basket."})]}),!G&&(0,C.jsx)("div",{className:"results-summary estimator-products__toolbar",children:(0,C.jsxs)("div",{className:"estimator-products__controls",children:[(0,C.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search description...",value:w,onChange:N=>k(N.target.value),"aria-label":"Search matched products"}),(0,C.jsxs)("div",{className:"results-view-toggle","aria-label":"Results view",children:[(0,C.jsx)("button",{type:"button",className:`results-view-toggle__btn${O==="tile"?" is-active":""}`,"aria-pressed":O==="tile","aria-label":"Tile view",title:"Tile view",onClick:()=>f("tile"),children:(0,C.jsxs)("svg",{width:"18",height:"12",viewBox:"0 0 15 10",fill:"currentColor",children:[(0,C.jsx)("rect",{x:"0.5",y:"0.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"5.5",y:"0.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"10.5",y:"0.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"0.5",y:"5.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"5.5",y:"5.5",width:"4",height:"4"}),(0,C.jsx)("rect",{x:"10.5",y:"5.5",width:"4",height:"4"})]})}),(0,C.jsx)("button",{type:"button",className:`results-view-toggle__btn${O==="list"?" is-active":""}`,"aria-pressed":O==="list","aria-label":"List view",title:"List view",onClick:()=>f("list"),children:(0,C.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 15 15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,C.jsx)("line",{x1:"0.5",y1:"2.5",x2:"14.5",y2:"2.5"}),(0,C.jsx)("line",{x1:"0.5",y1:"7.5",x2:"14.5",y2:"7.5"}),(0,C.jsx)("line",{x1:"0.5",y1:"12.5",x2:"14.5",y2:"12.5"})]})})]}),(0,C.jsxs)("details",{ref:Nt,style:{position:"relative"},children:[(0,C.jsx)("summary",{className:"bom-toolbar-btn sort-menu-summary","aria-label":"Sort materials",style:{fontSize:16},children:"\u21C5"}),(0,C.jsx)("div",{className:"sort-menu-panel",children:Tx.map(N=>{let L=u===N.dir;return(0,C.jsxs)("button",{type:"button",className:`sort-menu-item${L?" is-active":""}`,onClick:()=>{h(L?null:N.dir),Nt.current?.removeAttribute("open")},children:[(0,C.jsx)("span",{className:"sort-menu-item__check",children:L?"\u2713":""}),N.label]},N.dir)})})]})]})})]}),G&&(0,C.jsxs)("div",{className:"results-review-page",children:[(0,C.jsxs)("div",{className:"results-review-page__top",children:[(0,C.jsxs)("button",{type:"button",className:"bom-toolbar-btn bom-toolbar-btn--accent",onClick:_,children:[(0,C.jsx)(Vr,{}),"Back to results"]}),(0,C.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,C.jsx)("div",{className:"results-review-searchbar",children:(0,C.jsx)("input",{type:"text",className:"results-search-input",placeholder:"Search products in catalogue...",value:we,onChange:N=>le(N.target.value),"aria-label":`Search a product for ${G.requirement.label}`})}),G.chosen&&(0,C.jsx)("div",{className:"results-candidate-actions",children:(0,C.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>qe(G.requirement.key),children:"Clear selected product"})})]})]}),(0,C.jsxs)("div",{className:"results-review-page__hero",children:[(0,C.jsx)("div",{className:"results-review-page__image-wrap",children:(0,C.jsx)(za,{className:"fill-img results-review-page__image",description:G.chosen?.description||G.requirement.label,photoUrl:G.chosen?.pdp_photo_url})}),(0,C.jsxs)("div",{className:"results-review-page__summary",children:[(0,C.jsx)("h2",{children:G.requirement.label}),(0,C.jsxs)("p",{className:"results-review-page__meta",children:[vi(G.requirement.qty)," ",xa(G.requirement.unit,G.requirement.qty)]}),G.chosen?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"results-review-page__product",children:G.chosen.description}),(0,C.jsxs)("div",{className:"results-row-meta",children:[G.chosen.product_id,G.chosen.price!=null?` \xB7 ${Sc(G.chosen.price,G.chosen.price_basis)}`:""]})]}):(0,C.jsx)("div",{className:"results-empty-hint",children:"No product currently selected for this line."}),(0,C.jsx)("div",{className:"results-review-page__actions",children:(0,C.jsx)("button",{type:"button",className:`bom-toolbar-btn${n?.cart[ge(G.requirement.key)]?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>q(G),disabled:!G.chosen||!n,children:n?.cart[ge(G.requirement.key)]?"\u2713 Added":"+ Add to basket"})})]})]}),ce.length===0?(0,C.jsx)("p",{className:"results-empty-hint",children:"No matching products."}):(0,C.jsxs)("table",{className:"score-breakdown-table",children:[(0,C.jsx)("thead",{children:(0,C.jsxs)("tr",{children:[(0,C.jsx)("th",{children:"Product"}),(0,C.jsx)("th",{children:"Dims (mm)"}),(0,C.jsx)("th",{children:"Price"}),(0,C.jsx)("th",{"aria-label":"Actions"})]})}),(0,C.jsx)("tbody",{children:ce.map(N=>{let L=N.product_id===G.chosen?.product_id;return(0,C.jsxs)("tr",{className:L?"score-breakdown-row--best":"",children:[(0,C.jsxs)("td",{children:[(0,C.jsx)("div",{children:N.description}),(0,C.jsx)("div",{className:"results-row-meta",children:N.product_id})]}),(0,C.jsx)("td",{children:(0,C.jsx)("span",{className:"unit-badge",children:Rx(N.measurements_mm)})}),(0,C.jsx)("td",{children:N.price!=null?Sc(N.price,N.price_basis):"-"}),(0,C.jsx)("td",{children:(0,C.jsxs)("label",{className:"switch-toggle",title:L?"Currently selected":"Use this candidate",children:[(0,C.jsx)("input",{type:"checkbox",checked:L,onChange:()=>{L?qe(G.requirement.key):Ye(G.requirement.key,N)},"aria-label":L?`${N.description} selected`:`Use ${N.description}`}),(0,C.jsx)("span",{className:"switch-toggle-track","aria-hidden":"true"})]})})]},N.product_id)})})]})]}),!G&&d&&(0,C.jsxs)("div",{className:"processing-container processing-variant-banter",role:"status","aria-label":"Loading",style:{padding:"32px 24px"},children:[(0,C.jsx)(wi,{}),(0,C.jsx)("p",{className:"banter-message is-visible",style:{fontSize:15,minHeight:0},children:"Matching your materials against the catalogue\u2026"})]}),!G&&v&&(0,C.jsx)("p",{className:"results-empty-hint estimator-products__error",children:v}),!G&&!d&&!v&&jt.length===0&&m.length>0&&(0,C.jsx)("p",{className:"results-empty-hint",children:"No materials match the current search."}),!G&&!d&&!v&&O==="tile"&&Ct.length>0&&(0,C.jsx)("div",{className:"results-tile-grid",children:Ct.map(N=>{let{requirement:L,chosen:X}=N,ue=X?Ft(Re(N),dm):null,ke=n?!!n.cart[ge(L.key)]:!1;return(0,C.jsxs)("article",{className:"results-tile-card",children:[(0,C.jsxs)("button",{type:"button",className:"results-tile-card__surface",onClick:()=>x(N),"aria-label":`Review match for ${L.label}`,children:[(0,C.jsx)("div",{className:"results-tile-card__media",children:(0,C.jsx)(za,{className:"fill-img results-tile-card__image",description:X?.description||L.label,photoUrl:X?.pdp_photo_url})}),(0,C.jsxs)("div",{className:"results-tile-card__body",children:[X?(0,C.jsxs)("div",{className:"results-tile-card__heading",children:[(0,C.jsx)("div",{className:"results-tile-card__title",children:X.description}),(0,C.jsxs)("div",{className:"results-tile-card__match-meta",children:[(0,C.jsx)("span",{children:X.product_id}),X.price!=null?(0,C.jsx)("span",{children:Sc(X.price,X.price_basis)}):null]})]}):(0,C.jsx)("div",{className:"results-empty-hint",children:"No product matched for this line."}),(0,C.jsxs)("div",{className:"results-tile-card__match",children:[(0,C.jsx)("div",{className:"results-tile-card__match-label",children:"\u21B3 calculated as"}),(0,C.jsx)("div",{className:"results-tile-card__match-name",children:L.label}),(0,C.jsxs)("div",{className:"results-tile-card__meta",children:[vi(L.qty)," ",xa(L.unit,L.qty)]}),ue?.requiredSellUnits!=null?(0,C.jsxs)("div",{className:"results-tile-card__meta estimator-products__order",children:["Order ",ue.requiredSellUnits," ",ue.sellUnit,ue.lineTotal!=null?` \xB7 ${nt(ue.lineTotal)}`:""]}):X?(0,C.jsx)("div",{className:"results-row-meta",children:"Quantity needs review"}):null]})]})]}),(0,C.jsxs)("div",{className:"results-tile-card__actions",children:[(0,C.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>x(N),children:"Review"}),(0,C.jsx)("button",{type:"button",className:`bom-toolbar-btn${ke?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>q(N),disabled:!X||!n,children:ke?"\u2713 Added":"+ Add"})]})]},L.key)})}),!G&&!d&&!v&&O==="list"&&Ct.length>0&&(0,C.jsx)("div",{className:"bom-table-wrap",children:(0,C.jsxs)("table",{className:"bom-table results-table","aria-label":"Matched materials",children:[(0,C.jsxs)("colgroup",{children:[(0,C.jsx)("col",{style:{width:"56px"}}),(0,C.jsx)("col",{className:"col-item"}),(0,C.jsx)("col",{style:{width:"90px"}}),(0,C.jsx)("col",{style:{width:"80px"}}),(0,C.jsx)("col",{style:{width:"220px"}}),(0,C.jsx)("col",{style:{width:"110px"}})]}),(0,C.jsx)("thead",{children:(0,C.jsxs)("tr",{className:"bom-col-header",children:[(0,C.jsx)("th",{"aria-label":"Expand"}),(0,C.jsx)("th",{style:{textAlign:"left"},children:"Description"}),(0,C.jsx)("th",{style:{textAlign:"center"},children:"Qty"}),(0,C.jsx)("th",{style:{textAlign:"center"},children:"Unit"}),(0,C.jsx)("th",{style:{textAlign:"center"},children:"Product Matched"}),(0,C.jsx)("th",{style:{textAlign:"center"},children:"Basket"})]})}),(0,C.jsx)("tbody",{children:Ct.map(N=>{let{requirement:L,chosen:X}=N,ue=X?Ft(Re(N),dm):null,ke=n?!!n.cart[ge(L.key)]:!1,vt=Te.has(L.key);return(0,C.jsxs)(Le.Fragment,{children:[(0,C.jsxs)("tr",{className:"bom-row",children:[(0,C.jsx)("td",{className:"bom-actions",style:{textAlign:"center",paddingLeft:0,paddingRight:0},children:(0,C.jsx)("button",{type:"button",className:"link-btn",onClick:()=>D(L.key),"aria-expanded":vt,"aria-label":vt?"Collapse product options":"Expand product options",children:vt?"\u25BE":"\u25B8"})}),(0,C.jsxs)("td",{style:{paddingLeft:0},children:[(0,C.jsx)("div",{className:"bom-component-name",children:L.label}),ue?.requiredSellUnits!=null&&(0,C.jsxs)("div",{className:"results-row-meta",children:["Order ",ue.requiredSellUnits," ",ue.sellUnit,ue.lineTotal!=null?` \xB7 ${nt(ue.lineTotal)}`:""]})]}),(0,C.jsx)("td",{className:"bom-qty col-order",style:{textAlign:"center"},children:vi(L.qty)}),(0,C.jsx)("td",{style:{textAlign:"center"},children:xa(L.unit,L.qty)}),(0,C.jsx)("td",{style:{textAlign:"center"},children:X?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"bom-component-name",children:X.description}),(0,C.jsxs)("div",{className:"results-row-meta",children:[X.product_id,X.price!=null&&` \xB7 ${Sc(X.price,X.price_basis)}`]})]}):(0,C.jsx)("span",{className:"results-empty-hint",children:"No match"})}),(0,C.jsx)("td",{style:{textAlign:"center"},children:(0,C.jsx)("button",{type:"button",className:`bom-toolbar-btn${ke?" bom-toolbar-btn--added":" bom-toolbar-btn--accent"}`,onClick:()=>q(N),disabled:!X||!n,children:ke?"\u2713 Added":"+ Add"})})]}),vt&&(0,C.jsx)("tr",{children:(0,C.jsx)("td",{colSpan:6,style:{paddingLeft:0,paddingRight:0},children:z===L.key?V(N):(0,C.jsxs)("div",{className:"estimator-products__picker",children:[(0,C.jsxs)("div",{className:"estimator-products__options",children:[N.candidates.map(mt=>(0,C.jsxs)("button",{type:"button",className:`estimator-products__option${mt.product_id===X?.product_id?" is-selected":""}`,onClick:()=>Ye(L.key,mt),children:[(0,C.jsx)("span",{children:mt.description}),(0,C.jsxs)("span",{className:"results-row-meta",children:[mt.product_id,mt.price!=null&&` \xB7 ${nt(mt.price)}`]})]},mt.product_id)),N.candidates.length===0&&(0,C.jsx)("p",{className:"results-empty-hint",children:"No candidates found."})]}),(0,C.jsx)("button",{type:"button",className:"bom-toolbar-btn",onClick:()=>ve(N),children:"Search the catalogue"})]})})})]},L.key)})})]})}),!G&&!d&&!v&&wt.length>0&&(0,C.jsxs)("section",{className:"results-tile-section results-tile-section--unmatched","aria-label":"Items requiring matching",children:[(0,C.jsxs)("div",{className:"results-tile-section__head",children:[(0,C.jsx)("h3",{children:"Require Matching"}),(0,C.jsx)("p",{children:"We couldn\u2019t confidently match these to a product. Open one to pick from the closest options."})]}),(0,C.jsx)("div",{className:"results-unmatched-list",children:wt.map(N=>(0,C.jsxs)("button",{type:"button",className:"results-unmatched-card",onClick:()=>x(N),children:[(0,C.jsxs)("span",{className:"results-unmatched-card__main",children:[(0,C.jsx)("span",{className:"results-unmatched-card__title",children:N.requirement.label}),(0,C.jsxs)("span",{className:"results-row-meta",children:[vi(N.requirement.qty)," ",xa(N.requirement.unit,N.requirement.qty)]})]}),(0,C.jsx)("span",{className:"bom-toolbar-btn results-unmatched-card__prompt",children:"Review"})]},N.requirement.key))})]}),!d&&!v&&m.length>0&&(0,C.jsxs)("div",{className:"disclaimer-box",style:{alignItems:"center"},children:[(0,C.jsx)("span",{className:"disclaimer-icon",children:"\u26A0\uFE0F"}),(0,C.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."})]}),!G&&!d&&!v&&(r||T>0)&&(0,C.jsxs)("div",{className:"btn-row estimator-products__footer",children:[r&&(0,C.jsx)("button",{type:"button",className:"cta-btn cta-btn-secondary",style:{flex:"0 1 30%",justifyContent:"center",marginTop:0},onClick:r,children:"Back"}),T>0&&n&&(0,C.jsxs)("button",{type:"button",className:"cta-btn",style:{flex:r?"0 1 70%":1,marginTop:0},onClick:n.openBasket,children:[(0,C.jsxs)("span",{children:["View Basket (",T,")"]}),(0,C.jsx)("span",{className:"arrow",children:(0,C.jsx)(Qt,{})})]})]})]})}var Gt=$(F());function fm({toolId:e,toolTitle:t,requirements:a,onBack:r}){let[i,n]=(0,Nc.useState)(0),o=(0,Nc.useCallback)(l=>n(l),[]);return(0,Gt.jsx)(Gt.Fragment,{children:(0,Gt.jsxs)("div",{className:"truss-estimator",children:[(0,Gt.jsxs)("div",{className:"quick-order-hero",children:[(0,Gt.jsx)("div",{className:"quick-order-eyebrow",children:"Estimating Tools"}),(0,Gt.jsxs)("div",{className:"quick-order-hero-title-row",children:[(0,Gt.jsx)("h1",{children:"Your Materials"}),i>0&&(0,Gt.jsxs)("span",{className:"summary-chip summary-chip--scope",children:[(0,Gt.jsx)("strong",{children:nt(i)})," Est. total"]})]}),(0,Gt.jsxs)("p",{children:["Quantities from the ",t,", matched against your merchant\u2019s catalogue."]})]}),(0,Gt.jsx)("div",{className:"truss-estimator__card",style:{minHeight:0},children:(0,Gt.jsx)(mm,{toolId:e,requirements:a,ready:!0,onBack:r,onTotalChange:o})})]})})}var ze=$(F());function Cc(e){let[t,a]=(0,$a.useState)(!1);return(0,ze.jsx)(lc,{onOpenBasket:()=>a(!0),children:(0,ze.jsx)(Ax,{...e,showBasket:t,onShowBasket:a})})}function Ax({fullPage:e=!1,hideHeader:t=!1,internal:a=!1,showBasket:r,onShowBasket:i}){let[n,o]=(0,$a.useState)(null),[l,c]=(0,$a.useState)(null),p=um.find(U=>U.id===n),{cart:m,updateCartQty:g,updateCartSellUnits:d,updateCartConversions:b,removeFromCart:v,clearCart:E}=Dn(),{adding:O,basketError:f,addToBasket:u}=l0(p?.title??"calculator"),h=(0,$a.useRef)(null),w=Js("estimating-tools",h);(0,$a.useEffect)(()=>{w("viewed")},[w]);let k=r?"basket":O?"adding":l?"review":n??"list",z=(0,$a.useRef)(k);(0,$a.useEffect)(()=>{z.current!==k&&(z.current=k,window.scrollTo(0,0))},[k]);let A=U=>{if(!p)return;w("estimate_completed",{calculator:p.id,lines:U.length});let R=Bv(p.id,U);R?u(R,U[0]?.calculatorWasteIncluded??!1):c(U)};return(0,ze.jsx)(tl.Provider,{value:w,children:(0,ze.jsx)("div",{ref:h,className:`app-wrapper${e?"":" app-wrapper--embedded"}${t?" app-wrapper--no-header":""}${a?"":" estimating-tools--customer"}`,style:Ot().theme,children:(0,ze.jsx)("main",{className:"main-content",children:r?(0,ze.jsx)(ul,{cart:m,onUpdateQty:g,onUpdateSellUnits:d,onResolveConversions:b,onRemove:v,onBack:()=>i(!1),onStartNewQuote:()=>{E(),o(null),c(null),i(!1)},internal:a}):O&&p?(0,ze.jsx)(s0,{toolTitle:p.title}):p?(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)("div",{hidden:l!==null,children:(0,ze.jsx)(p.Component,{onBack:()=>o(null),onReview:A})}),f&&(0,ze.jsx)("p",{className:"results-empty-hint estimator-products__error",children:f}),l!==null&&(0,ze.jsx)(fm,{toolId:p.id,toolTitle:p.title,requirements:l,onBack:()=>c(null)})]}):(0,ze.jsx)(ze.Fragment,{children:(0,ze.jsxs)("div",{className:"quick-order-card",children:[(0,ze.jsxs)("div",{className:"quick-order-hero",children:[(0,ze.jsx)("div",{className:"quick-order-eyebrow",children:"Construction Services"}),(0,ze.jsx)("h1",{children:"Estimating Tools"}),(0,ze.jsx)("p",{children:"Trade-specific calculators for trusses, fencing, decking, masonry and painting. Dial in your specs and get an instant material estimate."})]}),(0,ze.jsxs)("div",{className:"quick-order-alt",children:[(0,ze.jsx)("div",{className:"quick-order-alt-title",children:"Choose a Calculator"}),(0,ze.jsx)("div",{className:"estimator-tools-grid",children:um.map(U=>(0,ze.jsxs)("button",{type:"button",className:"estimator-tool-card",onClick:()=>{w("calculator_selected",{calculator:U.id}),o(U.id),c(null)},children:[(0,ze.jsx)("span",{className:"estimator-tool-card__image-wrap",children:(0,ze.jsx)("img",{className:"fill-img estimator-tool-card__image",src:It(U.imageUrl),alt:""})}),(0,ze.jsxs)("span",{className:"estimator-tool-card__content",children:[(0,ze.jsx)("span",{className:"estimator-tool-card__title",children:U.title}),(0,ze.jsx)("span",{className:"estimator-tool-card__desc",children:U.desc})]})]},U.id))})]})]})})})})})}var qc=$(F());function hm({config:e,children:t}){return vw(e),(0,qc.jsx)(qc.Fragment,{children:t})}var gm=$(F()),Ux="https://api.metronlabs.ai",Dx=["client","api-key","api-url","theme","hide-header","analytics"],Ox=["all","events-only","none"];function p0(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.70",this.id||(this.id=e),this.setAttribute("data-turbo-permanent",""),this.setAttribute("data-turbolinks-permanent",""),!this.root){let i=document.createElement("div"),n=document.createElement("style");n.textContent=`:host { display: block; }
|
|
6975
6975
|
:host > div { all: initial; display: block; }
|
|
6976
6976
|
${ww}`,this.shadowRoot.replaceChildren(n,i),this.root=(0,u0.createRoot)(i)}this.renderWidget()}disconnectedCallback(){queueMicrotask(()=>{this.isConnected||!this.root||(this.root.unmount(),this.root=null)})}attributeChangedCallback(){this.root&&this.renderWidget()}renderWidget(){let i=this.getAttribute("client")??void 0,n=this.getAttribute("api-key")??void 0;(!i||!n)&&console.error(`<${e}> needs client and api-key attributes.`);let o={apiBaseUrl:this.getAttribute("api-url")||Ux,client:i,apiKey:n,theme:Lx(e,this.getAttribute("theme")),analytics:Bx(this.getAttribute("analytics"))};this.root.render((0,gm.jsx)(hm,{config:o,children:(0,gm.jsx)(t,{hideHeader:this.hasAttribute("hide-header")})}))}},a.observedAttributes=Dx,a))}function Bx(e){return Ox.find(t=>t===e)??"all"}function Lx(e,t){if(t)try{return JSON.parse(t)}catch{console.error(`<${e}> theme attribute isn't valid JSON; using the default colours.`);return}}p0("metron-labs-quick-quote",uc);p0("metron-labs-estimating-tools",Cc);
|
|
6977
6977
|
/*! Bundled license information:
|