PageSourceSearch

https://pvcpipecalc.replit.app/assets/PVCBuilder-C0DpJ6NO.js

js pvcpipecalc.replit.app collected 2026-10-03 03:57:06 UTC 12,841 bytes, 1 lines download raw bytes

1import{r as n,j as e,A as Q,m as L}from"./vendor-motion-D7tqbIxK.js";import{m as i,s as U,u as W,e as K,C as E,a as O,b as X,h as Z,c as q,d as j,p as J}from"./index-CY8dd0ap.js";import{L as o}from"./label-Bktk3moZ.js";import{R,a as p}from"./radio-group-BQ-J70Jg.js";import{S as Y,a as ee,b as te,c as se,d as ae}from"./select-Dih7pzBY.js";import{I as V}from"./input-jK0G5tKj.js";import{I as z}from"./info-Cr-VJwHh.js";import{R as re}from"./ruler-DrMAxa0C.js";import{P as le}from"./plus-C1fYnY_j.js";import{T as ne}from"./trash-2-0pj5vk7b.js";import{L as ie}from"./loader-circle-BBl2Mm2h.js";import"./vendor-react-Bzgz95E1.js";import"./vendor-query-DzVW2h6_.js";import"./vendor-radix-wRl3KeJQ.js";import"./chevron-up-DoS_bQLV.js";const oe=U("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),$=n.forwardRef(({className:s,variant:d,...r},f)=>e.jsx("div",{ref:f,role:"alert",className:i(oe({variant:d}),s),...r}));$.displayName="Alert";const ce=n.forwardRef(({className:s,...d},r)=>e.jsx("h5",{ref:r,className:i("mb-1 font-medium leading-none tracking-tight",s),...d}));ce.displayName="AlertTitle";const _=n.forwardRef(({className:s,...d},r)=>e.jsx("div",{ref:r,className:i("text-sm [&_p]:leading-relaxed",s),...d}));_.displayName="AlertDescription";const de=['1/2"','3/4"','1"','1-1/4"','1-1/2"','2"'],me={'1/2"':17.95,'3/4"':19.95,'1"':21.95,'1-1/4"':24.95,'1-1/2"':27.95,'2"':39.95},N=120,v=.125,xe=2;function Ae(){const[s,d]=n.useState("white"),[r,f]=n.useState('1"'),[c,y]=n.useState("Standard (Sch 40)"),[l,g]=n.useState([]),[w,H]=n.useState("12"),[C,S]=n.useState("1"),[k,T]=n.useState(!1),{addToCart:B}=W(),{toast:A}=K(),D=async()=>{if(!(l.length===0||u)){T(!0);try{const t=l.map(h=>({length:h.length,quantity:h.qty})),a=m>0?m:0;await B.mutateAsync({productId:null,productName:`Custom Cut PVC Pipe (${r} ${s})`,price:F.toFixed(2),quantity:1,size:r,color:s,grade:c==="Thinwall"?"thinwall":"furniture",isCustomCut:!0,customCutData:{pipeSize:r,color:s,wallType:c==="Thinwall"?"thinwall":"standard",cuts:t,totalLength:b,wasteLength:a}}),A({title:"Added to Cart",description:`Custom cut ${r} ${s} PVC pipe added to your cart.`}),g([])}catch(t){A({title:"Failed to Add",description:t.message||"Something went wrong. Please try again.",variant:"destructive"})}finally{T(!1)}}};n.useEffect(()=>{s==="black"&&c==="Thinwall"&&y("Standard (Sch 40)")},[s,c]);const b=l.reduce((t,a)=>t+(a.length+v)*a.qty,0),m=N-b,u=m<0,I=l.reduce((t,a)=>t+a.qty,0),G=()=>{const t=parseFloat(w),a=parseInt(C);if(isNaN(t)||t<=0||isNaN(a)||a<=0)return;const h={id:Math.random().toString(36).substr(2,9),length:t,qty:a};g([...l,h]),S("1")},M=t=>{g(l.filter(a=>a.id!==t))};let x=me[r];s==="black"?x=x*1.1:c==="Thinwall"&&(x=x*.95);const P=I*xe,F=x+P;return e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8 font-sans",children:[e.jsx("div",{className:"lg:col-span-5 space-y-6",children:e.jsxs(E,{className:"border-none shadow-lg bg-card/50 backdrop-blur-sm",children:[e.jsxs(O,{children:[e.jsxs(X,{className:"font-mono uppercase tracking-wider text-lg flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-primary rounded-full"}),"Pipe Configuration"]}),e.jsx(Z,{children:"Select specifications for your furniture grade PVC."})]}),e.jsxs(q,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(o,{className:"text-xs uppercase font-bold text-muted-foreground tracking-widest",children:"Color"}),e.jsxs(R,{value:s,onValueChange:t=>d(t),className:"flex gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(p,{value:"white",id:"white",className:"peer sr-only"}),e.jsxs(o,{htmlFor:"white",className:i("flex flex-col items-center justify-center w-24 h-24 rounded-lg border-2 cursor-pointer transition-all hover:bg-accent/50",s==="white"?"border-primary bg-accent":"border-border"),children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-white border border-gray-200 shadow-sm mb-2"}),e.jsx("span",{className:"font-medium",children:"White"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(p,{value:"black",id:"black",className:"peer sr-only"}),e.jsxs(o,{htmlFor:"black",className:i("flex flex-col items-center justify-center w-24 h-24 rounded-lg border-2 cursor-pointer transition-all hover:bg-accent/50",s==="black"?"border-primary bg-accent":"border-border"),children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-neutral-900 border border-gray-800 shadow-sm mb-2"}),e.jsx("span",{className:"font-medium",children:"Black"})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(o,{className:"text-xs uppercase font-bold text-muted-foreground tracking-widest",children:"Size (IPS)"}),e.jsxs(Y,{value:r,onValueChange:t=>f(t),children:[e.jsx(ee,{className:"h-12 font-mono text-lg",children:e.jsx(te,{placeholder:"Select size"})}),e.jsx(se,{children:de.map(t=>e.jsx(ae,{value:t,className:"font-mono",children:t},t))})]}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(z,{className:"w-3 h-3"})," Measurements are nominal IPS sizes."]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(o,{className:"text-xs uppercase font-bold text-muted-foreground tracking-widest",children:"Wall Thickness"}),e.jsxs(R,{value:c,onValueChange:t=>y(t),className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{value:"Standard (Sch 40)",id:"sch40",className:"peer sr-only"}),e.jsxs(o,{htmlFor:"sch40",className:i("flex flex-col p-4 rounded-lg border-2 cursor-pointer transition-all hover:bg-accent/50 h-full",c==="Standard (Sch 40)"?"border-primary bg-accent":"border-border"),children:[e.jsx("span",{className:"font-bold mb-1",children:"Standard (Sch 40)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Heavy duty, structural applications."})]})]}),e.jsxs("div",{children:[e.jsx(p,{value:"Thinwall",id:"thinwall",className:"peer sr-only",disabled:s==="black"}),e.jsxs(o,{htmlFor:"thinwall",className:i("flex flex-col p-4 rounded-lg border-2 transition-all h-full",s==="black"?"opacity-50 cursor-not-allowed border-border bg-muted/20":"cursor-pointer hover:bg-accent/50",c==="Thinwall"&&s!=="black"?"border-primary bg-accent":"border-border"),children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("span",{className:"font-bold mb-1",children:"Thinwall"}),s==="black"&&e.jsx("span",{className:"text-[10px] font-mono text-destructive uppercase font-bold",children:"N/A"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s==="black"?"Not available in Black":"Lighter weight, sleek appearance."})]})]})]})]})]})]})}),e.jsx("div",{className:"lg:col-span-7 space-y-6",children:e.jsxs(E,{className:"border-none shadow-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-neutral-100 dar
1k:bg-neutral-900 p-8 border-b border-border relative min-h-[200px] flex flex-col justify-center items-center",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",style:{backgroundImage:"linear-gradient(#000 1px, transparent 1px), linear-gradient(90deg, #000 1px, transparent 1px)",backgroundSize:"20px 20px"}}),e.jsxs("div",{className:"relative w-full h-16 bg-neutral-200 rounded-full shadow-inner overflow-hidden flex items-center max-w-2xl mx-auto ring-1 ring-black/5",children:[e.jsx("div",{className:i("absolute inset-0 transition-colors duration-500",s==="white"?"bg-gradient-to-b from-white via-gray-100 to-gray-200":"bg-gradient-to-b from-neutral-800 via-neutral-900 to-black")}),e.jsx("div",{className:"absolute inset-x-0 top-[10%] h-[30%] bg-gradient-to-b from-white/40 to-transparent pointer-events-none mix-blend-overlay"}),e.jsxs("div",{className:"relative w-full h-full flex",children:[e.jsx(Q,{mode:"popLayout",children:l.map((t,a)=>e.jsxs(L.div,{initial:{width:0,opacity:0},animate:{width:`${t.length*t.qty/N*100}%`,opacity:1},exit:{width:0,opacity:0},className:"h-full border-r-2 border-dashed border-black/20 relative group shrink-0 flex items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-black/5 dark:bg-white/5 opacity-0 group-hover:opacity-100 transition-opacity"}),e.jsxs("span",{className:i("text-xs font-mono font-bold z-10 drop-shadow-md whitespace-nowrap px-1",s==="black"?"text-white":"text-black"),children:[t.length,'"',t.qty>1?` x${t.qty}`:""]})]},t.id))}),m>0&&e.jsx("div",{className:"flex-1 h-full flex items-center justify-center opacity-30",children:e.jsxs("span",{className:i("text-xs font-mono font-bold",s==="black"?"text-white":"text-black"),children:[m.toFixed(2),'" Left']})})]})]}),e.jsxs("div",{className:"w-full max-w-2xl mx-auto mt-4 flex justify-between px-1 font-mono text-[10px] text-muted-foreground",children:[e.jsx("span",{children:'0"'}),e.jsx("span",{children:'24"'}),e.jsx("span",{children:'48"'}),e.jsx("span",{children:'72"'}),e.jsx("span",{children:'96"'}),e.jsx("span",{children:'120"'})]})]}),e.jsxs(q,{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-end",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(o,{children:"Segment Length (Inches)"}),e.jsxs("div",{className:"relative",children:[e.jsx(V,{type:"number",value:w,onChange:t=>H(t.target.value),className:"font-mono pl-8",min:"0.1",max:N}),e.jsx(re,{className:"w-4 h-4 absolute left-2.5 top-3 text-muted-foreground"})]})]}),e.jsxs("div",{className:"w-24 space-y-2",children:[e.jsx(o,{children:"Qty"}),e.jsx(V,{type:"number",value:C,onChange:t=>S(t.target.value),className:"font-mono",min:"1"})]}),e.jsxs(j,{onClick:G,disabled:m<=0,className:"bg-primary text-primary-foreground hover:bg-primary/90 font-medium",children:[e.jsx(le,{className:"w-4 h-4 mr-2"})," Add Cut"]})]}),u&&e.jsxs($,{variant:"destructive",children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(_,{children:"Total length exceeds 120 inches (10 ft). Please remove segments."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center pb-2 border-b border-border",children:[e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wide text-muted-foreground",children:"Cut List"}),e.jsxs("span",{className:"text-sm font-mono",children:[l.length," cuts"]})]}),e.jsxs("div",{className:"bg-muted/50 p-3 rounded-md text-xs text-muted-foreground flex items-center gap-2 mb-2",children:[e.jsx(z,{className:"w-4 h-4"}),e.jsxs("span",{children:["Calculation includes ",v,'" saw blade kerf per cut.']})]}),e.jsxs("div",{className:"space-y-2 max-h-[200px] overflow-y-auto pr-2",children:[l.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground italic py-4 text-center",children:"No cuts added yet. Add a segment above."}),l.map((t,a)=>e.jsxs(L.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"flex items-center justify-between bg-muted/30 p-3 rounded border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"font-mono text-xs bg-primary/10 text-primary px-2 py-1 rounded",children:["#",a+1]}),e.jsxs("span",{className:"font-medium text-sm",children:[t.length," inches"]}),t.qty>1&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["x ",t.qty," pcs"]})]}),e.jsx(j,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>M(t.id),children:e.jsx(ne,{className:"w-4 h-4"})})]},t.id))]})]}),e.jsxs("div",{className:"pt-4 border-t border-border flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsxs("p",{children:["Total Usage: ",e.jsxs("span",{className:u?"text-destructive font-bold":"font-mono font-medium",children:[b.toFixed(2),'"']}
1),' / 120"']}),e.jsxs("p",{className:"text-xs mt-1 opacity-70",children:["(Includes ",v,'" kerf/cut)']})]}),e.jsxs("div",{className:"text-left sm:text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Estimated Price"}),e.jsxs("p",{className:"text-2xl font-bold font-mono",children:["$",F.toFixed(2)]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Includes ",I>0?`$${P.toFixed(2)} cut fees`:"base price"]})]})]}),e.jsx(j,{className:"w-full h-12 text-lg",disabled:u||l.length===0||k,onClick:D,"data-testid":"button-add-custom-cut-to-cart",children:k?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),"Adding..."]}):"Add to Cart"})]})]})})]})}export{Ae as PVCBuilder};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.