1import{j as e,A as es,m as Xe}from"./vendor-motion-Duc-aMVH.js";import{r,M as Rr,aL as Yl,m as qa,ae as yo,ar as an,X as ot,d as hl,aa as Ue,a1 as Ot,af as No,ah as jl,Q as ts,F as za,b5 as vo,S as wo,bP as So,bF as $s,bc as ce,c2 as Mn,x as bl,a5 as rn,by as St,h as Bn,i as Va,O as Xl,bn as On,f as _a,e as ss,ac as El,a4 as ko,bb as ln,c3 as Co,n as _n,p as nn,c4 as on,U as vr,c5 as Fl,c0 as Tl,as as cl,z as Dl,bs as xl,ad as Cr,a0 as dn,aK as pl,bQ as Vl,b as cn,bd as Po,P as xn,c6 as Ro,bY as Ao,bZ as Lo,c7 as Eo,l as Fo,c8 as To,y as Do,c9 as Io,Z as pn,b7 as Uo,ca as zl,I as qn,aY as Vn,b8 as Hl,a6 as Il,ag as mn,bm as un}from"./vendor-icons-Dr6X4NZb.js";import{H as $o,M as hn,I as Ul,R as bn,L as Mo,J as Bo}from"./UnifiedDashboard-BHjznfHm.js";import{bM as gn,L as sa,a as fn,bN as Oo,O as _o,bO as qo,N as Vo,bP as zo,bQ as Ho,bR as Wo,bS as Ko,bT as Go,aj as jn,bU as Yo,bV as zn,bW as Ar,bX as Xo,bY as Zo,bZ as Jo,b_ as Qo,b$ as ei,b as ml,v as rt,b7 as ti,b8 as Lr,c0 as yn,c1 as si,c2 as ai,c3 as ri,c4 as li,c5 as ni,c6 as oi,c7 as ii,c8 as Hn,c9 as di,ca as ci,cb as Wn,cc as xi,cd as pi,ce as mi,M as ra,cf as Kn,cg as Nn,ch as ui,ci as hi,cj as bi,_ as wr,a8 as $l,l as gi,j as fi,m as ji,k as yi,d as yl,g as Ni,a_ as Ml,ck as vi,cl as Bl,cm as vn,cn as wi,co as Si,cp as Gn,f as ki,C as Ci,a0 as Pi,cq as Ri,E as Ai,a4 as Li,cr as Ei,aJ as Fi,cs as Ti,ct as Di}from"./index-DU-5aOBY.js";import{a as wl,c as Ii}from"./pricing-ChK8SSUe.js";import{W as Ui}from"./WalkthroughClipPlanner-BTa1jJFJ.js";import{L as wn,P as $i,R as Mi}from"./PostPropertyWizard-C_6KaeuU.js";import"./RoleRequestStatusCard-BSd_uGJN.js";import"./vendor-firebase-po7RPG55.js";import"./vendor-charts-D6VOWIoW.js";import"./reelApi-Cy1Fqzjc.js";const Bt=[{name:"Kokapet",region:"West Hyderabad",lat:17.3986,lng:78.3283,desc:"Hyderabad's premium Golden Mile - skyscraper commercial towers, Neopolis SEZ, and high-end residential."},{name:"Financial District",region:"West Hyderabad",lat:17.4173,lng:78.3414,desc:"The commercial epicentre with world-class office absorption and ultra-luxury developments."},{name:"Tellapur",region:"West Hyderabad",lat:17.4566,lng:78.2858,desc:"Planned eco-friendly luxury villa & gated community corridor with massive space reserves."},{name:"Gachibowli",region:"West Hyderabad",lat:17.4401,lng:78.3489,desc:"The heart of West Hyderabad's software landscape with premium high-rises."},{name:"Kondapur",region:"West Hyderabad",lat:17.4622,lng:78.3568,desc:"Prime IT hub residential node adjacent to Botanical Garden and HITEC City."},{name:"Nallagandla",region:"West Hyderabad",lat:17.4827,lng:78.3039,desc:"Premium residential zone with clean green belts and immediate transit connectivity."},{name:"Kukatpally",region:"West Hyderabad",lat:17.4837,lng:78.4015,desc:"An extremely active residential & commercial market with robust appreciation history."},{name:"Miyapur",region:"West Hyderabad",lat:17.4966,lng:78.3516,desc:"High-density terminal hub connecting key transit corridors with mature social infrastructure."},{name:"Bachupally",region:"North Hyderabad",lat:17.5367,lng:78.3751,desc:"A rapidly growing affordable-luxury residential pocket favored by IT professionals."},{name:"Kompally",region:"North Hyderabad",lat:17.5342,lng:78.4872,desc:"Rapidly appreciating northern residential corridor with excellent highway connectivity."},{name:"Begumpet",region:"Central Hyderabad",lat:17.4448,lng:78.4682,desc:"Sought-after central residential and commercial hub with prime mature infrastru
1cture."},{name:"Banjara Hills",region:"Central Hyderabad",lat:17.4156,lng:78.4347,desc:"Ultra-prime central estate zone with iconic commercial avenues and luxury residences."},{name:"Uppal",region:"East Hyderabad",lat:17.3984,lng:78.5582,desc:"The primary eastern growth hub, hosting key stadiums, metro connections, and tech parks."},{name:"Rajendranagar",region:"South Hyderabad",lat:17.3184,lng:78.4012,desc:"Scenic southern villa development district, featuring rich green covers and lake vistas."},{name:"Shamshabad",region:"South Hyderabad",lat:17.2403,lng:78.4294,desc:"Strategic international airport corridor with rapid logistics and eco-township growth."},{name:"Kollur",region:"West Hyderabad",lat:17.4519,lng:78.2661,desc:"High-density transit corridor along the Outer Ring Road, favored for competitively-priced high-rise developments close to the Financial District."}];function Bi({user:a,onSelectProperty:l,onSuccessNotification:j,backendProjects:u=[],mini:E=!1,selectedLocalityName:y,onLocalityChange:F}){const[b,K]=r.useState(y||"Financial District"),v=y!==void 0?y:b,[te,V]=r.useState(!1),[g,M]=r.useState([]),[i,O]=r.useState(!1),[U,ie]=r.useState(!1),[I,R]=r.useState("locality"),[G,re]=r.useState("Financial District"),[x,D]=r.useState("Financial District"),[q,de]=r.useState(!0),[J,me]=r.useState(!0),[Q,Ie]=r.useState(""),[Ae,Ce]=r.useState(""),[Le,Je]=r.useState(!1),$e=r.useRef(null),ve=r.useRef(null),qe=r.useRef({}),Pe=r.useRef([]);r.useEffect(()=>{a?(O(!0),Ce(a.email||""),gn(a).then(N=>{M(N),O(!1)}).catch(N=>{console.error("Error fetching alerts:",N),O(!1)})):M([])},[a]),r.useEffect(()=>{I==="locality"&&(re(v),D(v))},[v,I]);const Ve=N=>{F?F(N):K(N)};r.useEffect(()=>{if(!$e.current)return;const N=$e.current;if(N._leaflet_id&&delete N._leaflet_id,N.innerHTML="",ve.current){try{ve.current.remove()}catch(h){console.warn("Leaflet cleanup error:",h)}ve.current=null}const ue=Bt.find(h=>h.name===v)||Bt[1],m=sa.map(N,{center:[ue.lat,ue.lng],zoom:12,zoomControl:!1,scrollWheelZoom:!1});sa.control.zoom({position:"topright"}).addTo(m),sa.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',subdomains:"abc",maxZoom:19}).addTo(m),ve.current=m,ie(!0);const C=new ResizeObserver(()=>{ve.current&&ve.current.invalidateSize()});C.observe(N);const Y=[setTimeout(()=>m.invalidateSize(),100),setTimeout(()=>m.invalidateSize(),400),setTimeout(()=>m.invalidateSize(),1e3)];return()=>{if(ie(!1),C.disconnect(),Y.forEach(clearTimeout),ve.current){try{ve.current.remove()}catch(h){console.warn("Map cleanup warning:",h)}ve.current=null}}},[]),r.useEffect(()=>{const N=Bt.find(ue=>ue.name===v);N&&ve.current&&ve.current.flyTo([N.lat,N.lng],13.5,{animate:!0,duration:1.2})},[v]),r.useEffect(()=>{const N=ve.current;if(!N)return;Object.values(qe.current).forEach(m=>m.remove()),qe.current={},Pe.current.forEach(m=>m.remove()),Pe.current=[],Bt.forEach(m=>{const C=m.name===v,Y=u.filter(xe=>{var z,se;return((z=xe.location)==null?void 0:z.toLowerCase())===m.name.toLowerCase()||((se=xe.district)==null?void 0:se.toLowerCase())===m.name.toLowerCase()}),h=Y.filter(xe=>xe.latitude&&xe.longitude);if(C){let xe=1800;h.forEach(Ge=>{const o=(Ge.latitude-m.lat)*111e3,L=(Ge.longitude-m.lng)*111e3*Math.cos(m.lat*Math.PI/180),je=Math.sqrt(o*o+L*L);je>xe&&(xe=je)});const z=xe+350,se=sa.circle([m.lat,m.lng],{radius:z,fillColor:"#00b5f8",fillOpacity:.14,color:"#0284c7",weight:2,dashArray:"5, 8"}).addTo(N);qe.current[`${m.name}-boundary`]=se}const w=Y.length;let T="#cbd5e1";w>=6?T="#0284c7":w>=3?T="#00b5f8":w>=1&&(T="#7dd3fc");const B=sa.circleMarker([m.lat,m.lng],{radius:C?18:12,fillColor:T,fillOpacity:C?.95:.75,color:C?"#0f172a":"#ffffff",weight:C?3:1.5}).addTo(N),H=` 2 <div style="font-family: 'Poppins', sans-serif; text-align: left; padding: 2px;"> 3 <strong style="color: #0f172a; font-size: 11px; display: block; margin-bottom: 2px;">${m.name} Zone</strong> 4 <span style="font-size: 9.5px; color: #0284c7; font-weight: bold;"> 5 ${w} verified listing${w===1?"":"s"} 6 </span> 7 </div> 8 `;B.bindTooltip(H,{direction:"top",opacity:.95,offset:[0,-5]}),B.on("click",()=>{Ve(m.name)}
8),qe.current[m.name]=B}),u.filter(m=>{var C,Y;return m.latitude&&m.longitude&&(((C=m.location)==null?void 0:C.toLowerCase())===v.toLowerCase()||((Y=m.district)==null?void 0:Y.toLowerCase())===v.toLowerCase())}).forEach(m=>{const C=sa.divIcon({className:"custom-project-pin",html:` 9 <div class="relative flex items-center justify-center"> 10 <span class="absolute inline-flex h-3.5 w-3.5 rounded-full bg-brand-400 opacity-75 animate-ping"></span> 11 <div class="w-4 h-4 rounded-full bg-brand-500 border-2 border-white shadow-md flex items-center justify-center"> 12 <div class="w-1.5 h-1.5 rounded-full bg-white"></div> 13 </div> 14 </div> 15 `,iconSize:[24,24],iconAnchor:[12,12]}),Y=sa.marker([m.latitude,m.longitude],{icon:C,title:`${m.name} - ${m.location}`}).addTo(N),h=m.basePricePerSqFt?`â¹${m.basePricePerSqFt.toLocaleString("en-IN")}/sqft`:m.priceRange||"Price on request";Y.bindPopup(` 16 <div style="font-family: 'Poppins', sans-serif; text-align: left; max-width: 180px; padding: 2px;"> 17 <strong style="color: #0f172a; font-size: 11px; display: block; margin-bottom: 2px;">${m.name}</strong> 18 <span style="font-size: 9px; color: #0284c7; font-weight: bold; display: block;">${h}</span> 19 </div> 20 `,{maxWidth:200}),Y.on("mouseover",()=>Y.openPopup()),Y.on("click",()=>{l(fn(m))}),Pe.current.push(Y)})},[v,u,U]);const et=Bt.find(N=>N.name===v)||Bt[1],Fe=u.filter(N=>{var ue,m;return((ue=N.location)==null?void 0:ue.toLowerCase())===v.toLowerCase()||((m=N.district)==null?void 0:m.toLowerCase())===v.toLowerCase()}),$=Fe.filter(N=>N.basePricePerSqFt!=null),le=$.length>0?Math.round($.reduce((N,ue)=>N+(ue.basePricePerSqFt||0),0)/$.length):null,ne=async N=>{if(N.preventDefault(),!a){j("ð Sign in to set verified Price Alerts!");return}if(!Ae){j("ð§ Please enter a valid email address.");return}Je(!0);try{await Oo(a,{targetType:I,targetId:G,targetName:x,alertOnPriceFluctuation:q,alertOnNewInventory:J,triggerPrice:Q?parseInt(Q):void 0,userEmail:Ae});const ue=await gn(a);M(ue),Je(!1),V(!1),Ie(""),j(`Price & Inventory Alert active for ${x}. We'll notify you when changes occur!`)}catch(ue){console.error("Failed to store price alert:",ue),Je(!1),j("â Error storing alert preference.")}};return e.jsxs("div",{id:"locality-interactive-map-section",className:"space-y-6 text-left max-w-7xl mx-auto py-6 font-sans",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 pb-4 border-b border-slate-200",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-0.5 bg-brand-50 border border-brand-100 text-brand-700 text-[10px] font-mono rounded-full font-bold uppercase tracking-wider",children:[e.jsx(Rr,{className:"w-3.5 h-3.5 text-brand-500"}),"HYDERABAD MICRO-MARKET MAP"]}),e.jsx("h2",{className:"text-xl md:text-2xl font-extrabold text-slate-900 tracking-tight font-display",children:"Hyderabad Hotspots Interactive Density Map"}),e.jsx("p",{className:"text-xs text-slate-500 max-w-xl leading-relaxed",children:"Explore verified RERA project pins across Hyderabad's micro-markets, with listed pricing shown wherever a builder has confirmed it."})]}),e.jsxs("div",{className:"flex items-center gap-2 bg-white border border-slate-300 rounded-2xl px-3.5 py-2 shadow-xs hover:border-brand-500 transition-colors shrink-0",children:[e.jsx(Rr,{className:"w-4 h-4 text-brand-500 shrink-0"}),e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"text-[8px] font-mono font-bold text-slate-400 uppercase tracking-wider",children:"SELECT MICRO-MARKET"}),e.jsxs("select",{value:v,onChange:N=>Ve(N.target.value),className:"bg-transparent text-xs font-extrabold text-slate-900 focus:outline-none cursor-pointer pr-3 font-sans",children:[e.jsx("optgroup",{label:"West Hyderabad",children:Bt.filter(N=>N.region==="West Hyderabad").map(N=>e.jsx("option",{value:N.name,children:N.name},N.name))}),e.jsx("optgroup",{label:"North Hyderabad",children:Bt.filter(N=>N.region==="North Hyderabad").map(N=>e.jsx("option",{value:N.name,children:N.name},N.name))}),e.jsx("optgroup",{label:"Central Hyderabad",children:Bt.filter(N=>N.region==="Central Hyderabad").map(N=>e.jsx("option",{value:N.name,children:N.name},N.name))}),e.jsx("optgroup",{label:"East Hyderabad",children:Bt.filter(N=>N.region==="East Hyderabad").map(N=>e.jsx("option",{value:N.name,children:N.name},N.name))}),e.jsx("optgroup",{label:"South Hyderabad",children:Bt.filter(N=>N.region==="South Hyderabad").map(N=>e.jsx("option",{value:N.name,children:N.name},N.name))})]})]})]})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl overflow-hidden shadow-lg grid grid-cols-1 lg:grid-cols-12 items-stretch min-h-[560px]",children:[e.jsxs("div",{className:"lg:col-span-7 relative bg-slate-100 min-h-[420px] lg:min-h-[560px]",children:[e.jsx("div",{ref:$e,className:"w-full h-full min-h-[420px] lg:min-h-[560px] relative z-0"}),e.jsxs("div",{className:"absolute top-4 left-4 z-10 flex bg-white/95 backdrop-blur-md border border-slate-200 px-3 py-1.5 rounded-2xl shadow-md gap-1.5 items-center",children:[e.jsx(Yl,{className:"w-3.5 h-3.5 text-brand-500"}),e.jsx("span",{className:"text-[9.5px] font-mono font-bold uppercase tracking-wider text-slate-600",children:"Verified Listing Density"})]})]}),e.jsxs("div",{className:"lg:col-span-5 bg-slate-50/70 border-t lg:border-t-0 lg:border-l border-slate-200 p-6 md:p-8 flex flex-col justify-between space-y-6",children:[e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"px-3 py-1 bg-brand-50 border border-brand-200 text-brand-700 font-mono text-[9.5px] font-bold rounded-full uppercase tracking-wider",children:et.region}),e.jsxs("span",{className:"px-3 py-1 bg-slate-900 text-white font-mono text-[9.5px] font-extrabold rounded-full",children:[Fe.length," VERIFIED LISTING",Fe.length===1?"":"S"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-xl md:text-2xl font-extrabold text-slate-900 font-display",children:[v," Corri
20dor"]}),e.jsx("p",{className:"text-xs text-slate-500 leading-relaxed font-sans",children:et.desc})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 pt-1",children:[e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-2xl shadow-xs space-y-1",children:[e.jsx("span",{className:"text-[8.5px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"AVG LISTED RATE"}),le!==null?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-extrabold text-slate-900 font-mono block",children:["â¹",le.toLocaleString("en-IN")]}),e.jsxs("span",{className:"text-[9px] font-mono text-slate-400 block",children:["Across ",$.length," priced listing",$.length===1?"":"s"]})]}):e.jsx("span",{className:"text-xs font-semibold text-slate-400 block pt-1",children:"Not available yet"})]}),e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-2xl shadow-xs space-y-1",children:[e.jsx("span",{className:"text-[8.5px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"ACTIVE RERA PROJECTS"}),e.jsxs("span",{className:"text-lg font-extrabold text-slate-900 font-mono block flex items-center gap-0.5",children:[Fe.length,e.jsx(qa,{className:"w-4 h-4 text-brand-500"})]}),e.jsx("span",{className:"text-[9px] font-mono text-slate-400 block",children:"Registered in this zone"})]})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-bold text-slate-800",children:[e.jsxs("span",{className:"font-mono text-[10px] text-slate-400 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(qa,{className:"w-3.5 h-3.5 text-brand-500"}),"RERA LISTINGS IN ",v.toUpperCase()]}),e.jsxs("span",{className:"text-[10px] font-mono text-brand-600 bg-brand-50 px-2.5 py-0.5 rounded-full font-bold",children:[Fe.length," Verified"]})]}),e.jsx("div",{className:"space-y-2.5",children:Fe.length===0?e.jsx("div",{className:"text-center py-6 bg-white border border-slate-200/80 rounded-2xl text-xs text-slate-400",children:"No active RERA listings registered in this zone."}):Fe.slice(0,3).map(N=>{const ue=N.basePricePerSqFt?`â¹${N.basePricePerSqFt.toLocaleString("en-IN")}/sqft`:N.priceRange||"Price on request",m=N.imageUrl||"https://images.unsplash.com/photo-1545324418-cc1a3fa10c00?auto=format&fit=crop&w=120&q=80";return e.jsxs("div",{onClick:()=>l(fn(N)),className:"p-3 bg-white border border-slate-200 hover:border-brand-500/60 rounded-2xl transition-all duration-300 cursor-pointer flex items-center justify-between gap-3 group shadow-xs hover:shadow-md",children:[e.jsxs("div",{className:"flex items-center gap-3.5 min-w-0",children:[e.jsx("img",{src:m,alt:N.name,className:"w-12 h-12 rounded-xl object-cover border border-slate-200 shrink-0 group-hover:scale-105 transition-transform"}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("h4",{className:"text-xs md:text-sm font-extrabold text-slate-900 truncate group-hover:text-brand-600 transition-colors",children:N.name}),e.jsx("p",{className:"text-[11px] font-mono text-brand-600 font-bold",children:ue})]})]}),e.jsx("div",{className:"w-8 h-8 rounded-xl bg-slate-100 group-hover:bg-brand-500 group-hover:text-white flex items-center justify-center transition-all shrink-0",children:e.jsx(yo,{className:"w-4 h-4 transition-transform group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})})]},N.id)})})]})]}),e.jsx("div",{className:"pt-4 border-t border-slate-200",children:e.jsxs("button",{onClick:()=>V(!0),className:"w-full py-3.5 bg-brand-500 hover:bg-brand-600 text-white font-extrabold text-xs rounded-2xl transition-all shadow-md hover:shadow-lg flex items-center justify-center gap-2 cursor-pointer",children:[e.jsx(an,{className:"w-4 h-4"}),"Track Price Movements in ",v]})})]})]}),e.jsx(es,{children:te&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/60 backdrop-blur-xs",children:e.jsxs(Xe.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white border border-slate-200 rounded-3xl p-6 max-w-md w-full shadow-2xl text-left space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-100 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(an,{className:"w-5 h-5 text-brand-500"}),e.jsx("h3",{className:"text-base font-extrabold text-slate-900",children:"Set Price Movement Trigger"})]}),e.jsx("button",{onClick:()=>V(!1),className:"w-7 h-7 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-slate-500 transition-colors",children:e.jsx(ot,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:ne,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"TRACKED MICRO-MARKET"}),e.jsx("input",{type:"text",readOnly:!0,value:x,className:"w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs font-bold text-slate-800"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"ALERT NOTIFICATION EMAIL"}),e.jsx("input",{type:"email",required:!0,placeholder:"[email protected]",value:Ae,onChange:N=>Ce(N.target.value),className:"w-full px-3 py-2 bg-white border border-slate-300 rounded-xl text-xs text-slate-900 focus:border-brand-500 focus:outline-none"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"TRIGGER PRICE THRESHOLD (OPTIONAL â¹/SQFT)"}),e.jsx("input",{type:"number",placeholder:"e.g. 9500",value:Q,onChange:N=>Ie(N.target.value),className:"w-full px-3 py-2 bg-white border border-slate-300 rounded-xl text-xs text-slate-900 focus:border-brand-500 focus:outline-none font-mono"})]}),e.jsxs("div",{className:"pt-2 flex justify-end gap-2 border-t border-slate-100",children:[e.jsx("button",{type:"button",onClick:()=>V(!1),className:"px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-700 text-xs font-bold rounded-xl transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:Le,className:"px-5 py-2 bg-brand-500 hover:bg-brand-600 text-white text-xs font-extrabold rounded-xl shadow-md transition-colors disabled:opacity-50",children:Le?"Saving Trigger...":"Activate Trigger"})]})]})]})})})]})}function Oi({user:a,bookingId:l,buyerEmail:j,onSuccessNotification:u,onClose:E}){var qe,Pe,Ve,et,Fe,$,le,ne,N,ue;const[y,F]=r.useState("ledger"),[b,K]=r.useState(null),[v,te]=r.useState(!0),[V,g]=r.useState(null),[M,i]=r.useState(!1),[O,U]=r.useState(null),[ie,I]=r.useState({milestoneName:"",amountDue:"",percentageDue:"",dueDate:"",reraTaskNo:""}),[R,G]=r.useState({}
20),[re,x]=r.useState(!1),[D,q]=r.useState({description:"",area:"",severity:"medium"}),[de,J]=r.useState({registrationDocumentNo:"",registrationStatus:"registered"}),me=r.useCallback(async()=>{te(!0),g(null);try{const m=await _o(a,l);K(m)}catch(m){g(m.message||"Failed to retrieve transaction details.")}finally{te(!1)}},[a,l]);r.useEffect(()=>{me()},[me]);const Q=async m=>{if(m.preventDefault(),!ie.milestoneName||!ie.amountDue){U("Milestone Name and Amount are required.");return}i(!0),U(null);try{await qo(a,l,{milestoneName:ie.milestoneName,amountDue:parseFloat(ie.amountDue),percentageDue:ie.percentageDue?parseFloat(ie.percentageDue):void 0,dueDate:ie.dueDate||void 0,reraTaskNo:ie.reraTaskNo?parseInt(ie.reraTaskNo,10):void 0}),u("Billing demand generated and shared with buyer!"),x(!1),I({milestoneName:"",amountDue:"",percentageDue:"",dueDate:"",reraTaskNo:""}),me()}catch(C){U(C.message||"Failed to generate demand.")}finally{i(!1)}},Ie=async m=>{const C=R[m];if(!(C!=null&&C.clearedReceiptUrl)){U("Cleared Receipt Reference or URL is required.");return}i(!0),U(null);try{await Vo(a,l,m,{clearedReceiptUrl:C.clearedReceiptUrl}),u("Payment receipt validated and cleared!"),G(Y=>{const h={...Y};return delete h[m],h}),me()}catch(Y){U(Y.message||"Failed to log payment receipt.")}finally{i(!1)}},Ae=async m=>{if(m.preventDefault(),!de.registrationDocumentNo){U("Deed Document Number is required.");return}i(!0),U(null);try{await zo(a,l,{registrationDocumentNo:de.registrationDocumentNo,registrationStatus:de.registrationStatus}),u("Agreement registration details uploaded!"),me()}catch(C){U(C.message||"Failed to record registration.")}finally{i(!1)}},Ce=async m=>{i(!0),U(null);try{await Ho(a,l,{toIndex:m}),u("Construction stage advanced successfully!"),me()}catch(C){U(C.message||"Failed to update construction stage.")}finally{i(!1)}},Le=async()=>{i(!0),U(null);try{await Wo(a,l),u("Handover and Possession status updated!"),me()}catch(m){U(m.message||"Failed to progress handover status.")}finally{i(!1)}},Je=async m=>{if(m.preventDefault(),!D.description){U("Snag description is required.");return}i(!0),U(null);try{await Ko(a,l,{description:D.description,area:D.area||void 0,severity:D.severity}),u("New snag logged successfully!"),q({description:"",area:"",severity:"medium"}),me()}catch(C){U(C.message||"Failed to log snag.")}finally{i(!1)}},$e=async m=>{i(!0),U(null);try{await Go(a,m,{status:"resolved_unverified"}),u("Snag marked as resolved. Awaiting verification."),me()}catch(C){U(C.message||"Failed to update snag.")}finally{i(!1)}},ve=m=>isFinite(m)?m>=1e7?`â¹${(m/1e7).toFixed(2)} Cr`:m>=1e5?`â¹${(m/1e5).toFixed(2)} L`:`â¹${Math.round(m).toLocaleString("en-IN")}`:"â¹0";return e.jsxs("div",{className:"border border-slate-200 rounded-3xl bg-slate-50/50 p-6 space-y-6 text-left font-sans",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200/60 pb-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"Active Transaction desk"}),e.jsxs("h3",{className:"text-sm font-extrabold text-slate-900 mt-0.5",children:["Deal Workspace: ",j]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:me,disabled:v,"aria-label":"Refresh deal journey",className:"p-2 bg-white hover:bg-slate-50 border border-slate-200 rounded-xl transition-all cursor-pointer disabled:opacity-50",children:e.jsx(hl,{className:`w-3.5 h-3.5 text-slate-600 ${v?"animate-spin":""}`})}),e.jsx("button",{onClick:E,"aria-label":"Close deal workspace",className:"p-2 bg-white hover:bg-slate-50 border border-slate-200 rounded-xl transition-all cursor-pointer",children:e.jsx(ot,{className:"w-3.5 h-3.5 text-slate-600"})})]})]}),v&&e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"bg-slate-100 rounded-2xl animate-pulse h-24 w-full"}),e.jsx("div",{className:"bg-slate-100 rounded-2xl animate-pulse h-40 w-full"})]}),V&&e.jsxs("div",{className:"flex items-center gap-2 p-4 bg-rose-50 border border-rose-200 rounded-2xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"})," ",V,e.jsx("button",{onClick:me,className:"ml-auto font-bold font-mono text-[10px] cursor-pointer",children:"RETRY"})]}),O&&e.jsxs("div",{className:"flex items-center gap-2 p-4 bg-rose-50 border border-rose-200 rounded-2xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"})," ",O,e.jsx("button",{onClick:()=>U(null),className:"ml-auto font-bold font-mono text-[10px] cursor-pointer",children:"DISMISS"})]}),!v&&!V&&b&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex bg-slate-100/80 p-1 rounded-2xl border border-slate-200 select-none",children:[e.jsx("button",{onClick:()=>F("ledger"),className:`flex-1 py-2 text-center text-xs font-bold rounded-xl transition-all cursor-pointer ${y==="ledger"?"bg-white text-slate-900 shadow-sm":"text-slate-500 hover:text-slate-800"}`,children:"Ledger & Dues"}),e.jsx("button",{onClick:()=>F("lifecycle"),className:`flex-1 py-2 text-center text-xs font-bold rounded-xl transition-all cursor-pointer ${y==="lifecycle"?"bg-white text-slate-900 shadow-sm":"text-slate-500 hover:text-slate-800"}`,children:"Transaction Progress"}),e.jsxs("button",{onClick:()=>F("snags"),className:`flex-1 py-2 text-center text-xs font-bold rounded-xl transition-all cursor-pointer ${y==="snags"?"bg-white text-slate-900 shadow-sm":"text-slate-500 hover:text-slate-800"}`,children:["Snag Board (",((qe=b.snagItems)==null?void 0:qe.length)||0,")"]})]}),y==="ledger"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-2xl text-left",children:[e.jsx("span",{className:"text-[9px] font-mono text-slate-400 uppercase tracking-wider block",children:"Agreement Value"}),e.jsx("span",{className:"text-sm font-bold font-mono text-slate-800",children:ve(parseFloat(((Pe=b.ledger)==null?void 0:Pe.totalAgreementValue)||"0"))})]}),e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-2xl text-left",children:[e.jsx("span",{className:"text-[9px] font-mono text-slate-400 uppercase tracking-wider block",children:"Paid to Date"}),e.jsx("span",{className:"text-sm font-bold font-mono text-emerald-600",children:ve(parseFloat(((Ve=b.ledger)==null?void 0:Ve.amountCleared)||"0"))})]}),e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-2xl text-left",children:[e.jsx("span",{className:"text-[9px] font-mono text-slate-400 uppercase tracking-wider block",children:"Outstanding Dues"}),e.jsx("span",{className:"text-sm font-bold font-mono text-amber-600",children:ve(parseFloat(((et=b.ledger)==null?void 0:et.totalAgreementValue)||"0")-parseFloat(((Fe=b.ledger)==null?void 0:Fe.amountCleared)||"0"))})]})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-slate-100 flex items-center justify-between",children:[e.jsx("h4",{className:"text-xs font-extrabold text-slate-900 font-display",children:"Collections Milestones"}),e.jsxs("button",{onClick:()=>x(!re),disabled:M,className:"flex items-center gap-1 px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white text-[10px] font-bold rounded-xl transition-all shadow-md shadow-brand-500/10 cursor-pointer disabled:opacity-50",children:[e.jsx(Ot,{className:"w-3 h-3"}),"New Demand"]})]}),re&&e.jsxs("form",{onSubmit:Q,className:"p-4 bg-slate-50 border-b border-slate-100 space-y-3",children:[e.jsx("h5",{className:"text-[10px] font-mono font-bold text-slate-500 uppercase tracking-wider",children:"Generate Milestone Demand"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase",children:"Milestone Description"}),e.jsx("input",{type:"text",required:!0,placeholder:"e.g. Agreement Stamp Duty / Plinth level check",value:ie.milestoneName,onChange:m=>I(C=>({...C,milestoneName:m.target.value})),className:"w-full text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase",children:"Amount (INR)"}),e.jsx("input",{type:"number",required:!0,placeholder:"e.g. 500000",value:ie.amountDue,onChange:m=>I(C=>({...C,amountDue:m.target.value})),className:"w-full text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none font-mono"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase",children:"Share
20% (Optional)"}),e.jsx("input",{type:"number",placeholder:"e.g. 10",value:ie.percentageDue,onChange:m=>I(C=>({...C,percentageDue:m.target.value})),className:"w-full text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none font-mono"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase",children:"Due Date (Optional)"}),e.jsx("input",{type:"date",value:ie.dueDate,onChange:m=>I(C=>({...C,dueDate:m.target.value})),className:"w-full text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none font-mono"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase",children:"RERA Milestone Index"}),e.jsx("input",{type:"number",placeholder:"e.g. 3",value:ie.reraTaskNo,onChange:m=>I(C=>({...C,reraTaskNo:m.target.value})),className:"w-full text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none font-mono"})]})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>x(!1),className:"px-3 py-1.5 border border-slate-200 rounded-xl text-xs font-bold text-slate-500 hover:bg-slate-100 cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:M,className:"px-4 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded-xl text-xs font-bold shadow-xs cursor-pointer disabled:opacity-50",children:M?"Posting...":"Submit Demand"})]})]}),e.jsx("div",{className:"divide-y divide-slate-100",children:!(($=b.ledger)!=null&&$.milestones)||b.ledger.milestones.length===0?e.jsx("div",{className:"p-8 text-center text-xs text-slate-400",children:"No milestones registered on this booking ledger."}):b.ledger.milestones.map(m=>{var Y;const C=((Y=R[m.id])==null?void 0:Y.clearedReceiptUrl)||"";return e.jsxs("div",{className:"p-4 flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-xs text-slate-800",children:m.milestoneName}),e.jsx("span",{className:`px-1.5 py-0.5 text-[8px] font-mono font-bold rounded border uppercase ${m.paymentStatus==="paid_cleared"?"bg-emerald-50 border-emerald-200 text-emerald-800":m.paymentStatus==="demand_sent"?"bg-amber-50 border-amber-200 text-amber-800":"bg-slate-100 border-slate-200 text-slate-500"}`,children:m.paymentStatus==="paid_cleared"?"Cleared":m.paymentStatus==="demand_sent"?"Billed":m.paymentStatus})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono text-slate-400",children:[e.jsxs("span",{children:["Due Amount: ",e.jsx("strong",{className:"text-slate-600",children:ve(m.amountDue)})," ",m.percentageDue&&`(${m.percentageDue}%)`]}),m.dueDate&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(No,{className:"w-3 h-3"}),"Due: ",new Date(m.dueDate).toLocaleDateString()]})]})]}),m.paymentStatus!=="paid_cleared"&&e.jsxs("div",{className:"flex items-center gap-2 shrink-0 max-w-sm w-full sm:w-auto",children:[e.jsx("input",{type:"text",placeholder:"Receipt Ref / Document Link",value:C,onChange:h=>G(w=>({...w,[m.id]:{clearedReceiptUrl:h.target.value}})),className:"flex-1 text-xs p-1.5 bg-slate-50 border border-slate-200 rounded-xl outline-none"}),e.jsx("button",{onClick:()=>Ie(m.id),disabled:M||!C,className:"px-3 py-1.5 bg-emerald-500 hover:bg-emerald-600 text-white rounded-xl text-[10px] font-bold shadow-xs cursor-pointer disabled:opacity-50 whitespace-nowrap",children:"Log Clearance"})]})]},m.id)})})]})]}),y==="lifecycle"&&e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-5 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider flex items-center gap-1",children:[e.jsx(jl,{className:"w-3.5 h-3.5 text-brand-500"})," Stitched linear milestones status"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:(ne=(le=b.journey)==null?void 0:le.stages)==null?void 0:ne.map((m,C)=>{const Y=m.status==="done",h=m.status==="current";return e.jsxs("div",{className:`p-3 rounded-2xl border text-left flex flex-col justify-between h-20 transition-all ${Y?"bg-emerald-50/40 border-emerald-200 text-emerald-800":h?"bg-brand-50/30 border-brand-300 ring-2 ring-brand-500/10":"bg-slate-50 border-slate-200 text-slate-400"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[8px] font-mono font-bold uppercase tracking-wider",children:["Stage ",C+1]}),Y&&e.jsx(ts,{className:"w-3 h-3 text-emerald-600"}),h&&e.jsx("span",{className:"w-1.5 h-1.5 bg-brand-500 rounded-full animate-ping"})]}),e.jsx("span",{className:"font-extrabold text-[10.5px] font-sans truncate capitalize",children:m.stage.replace(/_/g," ")})]},m.stage)})})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-5 space-y-3",children:[e.jsxs("h4",{className:"text-xs font-extrabold text-slate-900 font-display flex items-center gap-1",children:[e.jsx(za,{className:"w-4 h-4 text-brand-500"}),"Deed Agreement Registration Manager"]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Log statutory registration information to move status from agreement stage into construction."}),e.jsxs("form",{onSubmit:Ae,className:"bg-slate-50 p-4 rounded-2xl border border-slate-200 flex flex-col sm:flex-row items-end gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase block",children:"Registered Document Reference Number"}),e.jsx("input",{type:"text",required:!0,placeholder:"e.g. Doc No 12053/2026, SRO Kondapur",value:de.registrationDocumentNo,onChange:m=>J(C=>({...C,registrationDocumentNo:m.target.value})),className:"w-full text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none font-mono"})]}),e.jsxs("div",{className:"space-y-1 shrink-0",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase block",children:"State"}),e.jsxs("select",{value:de.registrationStatus,onChange:m=>J(C=>({...C,registrationStatus:m.target.value})),className:"text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none",children:[e.jsx("option",{value:"registered",children:"Registered (Complete)"}),e.jsx("option",{value:"pending",children:"Pending Validation"})]})]}),e.jsx("button",{type:"submit",disabled:M,className:"px-4 py-2 bg-brand-500 hover:bg-brand-600 text-white text-xs font-bold rounded-xl shadow-xs shrink-0 cursor-pointer disabled:opacity-50",children:"Confirm Registration"})]})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-5 space-y-3",children:[e.jsxs("h4",{className:"text-xs font-extrabold text-slate-900 font-display flex items-center gap-1",children:[e.jsx(vo,{className:"w-4 h-4 text-emerald-600"}),"RERA Milestone Progress Advance"]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Advance construction milestones dynamically. Each index aligns with a project footprint task."}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5",children:[{label:"Foundation Check",index:1},{label:"Slab Casting",index:2},{label:"Brickwork Plaster",index:3},{label:"Handover Readiness",index:4}].map(m=>{var h;const C=((h=b.bookingDetails)==null?void 0:h.constructionMilestoneIndex)||0,Y=C>=m.index;return e.jsxs("button",{type:"button",disabled:M||C===m.index,onClick:()=>Ce(m.index),className:`p-3 rounded-2xl border text-left flex flex-col justify-between h-16 transition-all cursor-pointer ${Y?"bg-emerald-50 border-emerald-200 text-emerald-800 font-bold":"bg-white border-slate-200 text-slate-400 hover:border-slate-300"}`,children:[e.jsxs("span",{className:"text-[8px] font-mono",children:["Stage #",m.index]}),e.jsx("span",{className:"text-[10px] block truncate font-sans",children:m.label})]},m.index)})})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-5 space-y-3",children:[e.jsxs("h4",{className:"text-xs font-extrabold text-slate-900 font-display flex items-center gap-1",children:[e.jsx(wo,{className:"w-4 h-4 text-brand-500"}),"Final Handover & Possession Close"]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Trigger final handover workflow. Requires snag resolution and zero outstanding ledger dues."}),((N=b.bookingDetails)==null?void 0:N.handoverStatus)==="completed"?e.jsxs("div",{className:"p-5 bg-gradient-to-r from-emerald-50 to-teal-50 border border-emerald-200 rounded-3xl space-y-3 text-left shadow-xs",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-emerald-500 flex items-center justify-center text-white font-bold text-sm shrink-0",children:"â"}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-extrabold text-emerald-950 font-display",children:"Congratulations! Home Possession Handover Completed"}),e.jsx("p",{className:"text-[10px] text-emerald-700 font-mono",children:"Keys Dispatched · Snag Verification Complete · Funds Released"})]})]}),e.jsx("p",{className:"text-xs text-emerald-800 leading-relaxed font-sans",children:"Your home keys, legal occupancy certificate, and registered deed documents have been formally handed over. Our dedicated Concierge Team remains available for ongoing property management."}),e.jsxs("div",{className:"pt-2 border-t border-emerald-200/60 flex items-center justify-between text-[10px] font-mono text-emerald-700 flex-wrap gap-2",children:[e.jsx("span",{children:"Need post-possession assistance?"}),e.jsx("span",{className:"font-bold",children:"Contact Relationship Advisor: +91 40 6900 8800"})]})]}):e.jsx("button",{type:"button",disabled:M,onClick:Le,className:"px-5 py-2.5 bg-brand-500 hover:bg-brand-600 text-white rounded-xl text-xs font-bold transition-all shadow-md shadow-brand-500/10 cursor-pointer disabled:opacity-50",children:"Approve & Trigger Possession"})]})]}),y==="snags"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-5 space-y-4",children:[e.jsxs("h4",{className:"text-xs font-extrabold text-slate-900 font-display flex items-center gap-1.5",children:[e.jsx(So,{className:"w-4 h-4 text-slate-700"}),"Log New Construction Defect (Snag)"]}),e.jsxs("form",{onSubmit:Je,className:"grid grid-cols-1 sm:grid-cols-3 gap-3 items-end",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase",children:"Defect Description"}),e.jsx("input",{type:"text",required:!0,placeholder:"e.g. Hairline cracks in bathroom tiling",value:D.description,onChange:m=>q(C=>({...C,description:m.target.value})),className:"w-full text-xs p-2 bg-slate-50 border border-slate-200 rounded-xl outline-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase",children:"Room / Area"}),e.jsx("input",{type:"text",placeholder:"e.g. Master Bedroom",value:D.area,onChange:m=>q(C=>({...C,area:m.target.value})),className:"w-full text-xs p-2 bg-slate-50 border border-slate-200 rounded-xl outline-none"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase",children:"Severity"}),e.jsxs("select",{value:D.severity,onChange:m=>q(C=>({...C,severity:m.target.value})),className:"w-full text-xs p-2 bg-slate-50 border border-slate-200 rounded-xl outline-none",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})]})]}),e.jsx("button",{type:"submit",disabled:M,className:"w-full py-2 bg-brand-500 hover:bg-brand-600 text-white text-xs font-bold rounded-xl transition-all shadow-xs cursor-pointer disabled:opacity-50",children:"Log Defect"})]})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-5",children:[e.jsxs("h4",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider mb-3",children:["Defects Registry (",((ue=b.snagItems)==null?void 0:ue.length)||0,")"]}
20),!b.snagItems||b.snagItems.length===0?e.jsx("div",{className:"py-8 text-center bg-slate-50 border border-dashed border-slate-200 rounded-2xl text-slate-400 text-xs",children:"No open snags logged for this unit."}):e.jsx("div",{className:"divide-y divide-slate-100",children:b.snagItems.map(m=>e.jsxs("div",{className:"py-3.5 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-xs text-slate-800",children:m.description}),e.jsx("span",{className:`px-1.5 py-0.5 text-[8px] font-mono font-bold rounded border uppercase ${m.status==="closed"?"bg-emerald-50 border-emerald-200 text-emerald-800":m.status==="resolved_unverified"?"bg-indigo-50 border-indigo-200 text-indigo-700":"bg-rose-50 border-rose-200 text-rose-700"}`,children:m.status==="resolved_unverified"?"Resolved (Unverified)":m.status})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono text-slate-400",children:[m.area&&e.jsxs("span",{children:["Area: ",e.jsx("strong",{className:"text-slate-500",children:m.area})]}),e.jsxs("span",{children:["Severity: ",e.jsx("strong",{className:"text-slate-500 capitalize",children:m.severity})]}),e.jsxs("span",{children:["Logged: ",new Date(m.createdAt).toLocaleDateString()]})]})]}),m.status==="open"&&e.jsx("button",{onClick:()=>$e(m.id),disabled:M,className:"px-3.5 py-1.5 bg-emerald-500 hover:bg-emerald-600 text-white rounded-xl text-[10px] font-bold shadow-xs cursor-pointer disabled:opacity-50 whitespace-nowrap",children:"Mark Fixed"})]},m.id))})]})]})]})]})}const Yn=30;function Ol(a,l=Yn){return!Number.isFinite(a)||a<0?0:Math.round(a*((100-l)/100)*100)/100}function _i(a,l,j){const u=`â¹${j.toLocaleString("en-IN")}/sqft`;return(a==null?void 0:a.commercialStatus)==="pending"?{status:"Submitted for review",message:`Base rate for ${l} (${u}) submitted for review. Buyers see it once Realtified approves it.`}:{status:"Applied",message:`Base rate for ${l} saved as ${u}.`}}function qi(a){return a.map(l=>{const j={label:l.label,url:l.url||void 0};l.posterUrl&&(j.posterUrl=l.posterUrl);const u=l.startSec,E=l.endSec;return typeof u=="number"&&typeof E=="number"&&Number.isFinite(u)&&Number.isFinite(E)&&u>=0&&E>u&&(j.startSec=u,j.endSec=E),j})}function Sn(a){if(!a||!a.trim())return;const l=Number(a);return Number.isFinite(l)&&l>=0?Math.round(l):void 0}function Vi(a){return a.reduce((l,j)=>l+(Number(j.percentage)||0),0)}function zi(a){return!!a&&typeof a.id=="number"}const gl={clp:{label:"Construction-linked (6 stages)",rows:[{name:"Booking Token",percentage:10,isCore:!0},{name:"Foundation Slab",percentage:15,isCore:!1},{name:"Plinth Level Casting",percentage:15,isCore:!1},{name:"5th Floor Roof Slab",percentage:20,isCore:!1},{name:"Superstructure Brickwork",percentage:20,isCore:!1},{name:"Possession & Handover",percentage:20,isCore:!0}]},plp:{label:"Possession-linked (4 stages)",rows:[{name:"Booking Token",percentage:20,isCore:!0},{name:"Superstructure Slabs",percentage:30,isCore:!1},{name:"Plastering & Flooring",percentage:20,isCore:!1},{name:"Possession & Handover",percentage:30,isCore:!0}]}};let kn=0;function Wl(){return kn+=1,`m-${Date.now().toString(36)}-${kn}`}function Hi(a){return gl[a].rows.map(l=>({id:Wl(),...l}))}function Xn(a){const l=/^([A-Za-z][A-Za-z0-9]{0,3})\s*[-/ ]\s*\S/.exec((a||"").trim());return l?l[1].toUpperCase():null}function Wi(a,l){const j=new Map(l.map(y=>[y.id,y.name])),u=new Map;for(const y of a)y.towerId!=null&&j.has(y.towerId)&&u.set(`id:${y.towerId}`,j.get(y.towerId));if(u.size>0)return[...u.entries()].map(([y,F])=>({key:y,label:F})).sort((y,F)=>y.label.localeCompare(F.label,void 0,{numeric:!0}));const E=new Set;for(const y of a){const F=Xn(y.number);F&&E.add(F)}return E.size<2?[]:[...E].sort().map(y=>({key:`prefix:${y}`,label:`Tower ${y}`}))}function Cn(a,l){if(l.length===0)return null;if(a.towerId!=null&&l.some(u=>u.key===`id:${a.towerId}`))return`id:${a.towerId}`;const j=Xn(a.number);return j&&l.some(u=>u.key===`prefix:${j}`)?`prefix:${j}`:null}function Ki(a){const l=new Set;for(const j of a){const u=/^(\d+(?:\.\d+)?)\s*BHK/i.exec((j||"").trim());u&&l.add(parseFloat(u[1]))}return[...l].sort((j,u)=>j-u).map(j=>`${j}`)}function Sr(a){return a==="Available"?"available":a==="Hold"?"hold":a==="Blocked"?"blocked":"sold"}function Gi(a){const l=a.facing&&a.facing.trim()?a.facing.trim():void 0,j=a.isCorner===!0,u=a.hasViewPremium===!0;return{onFile:!!l||j||u,facing:l,isCorner:j,hasViewPremium:u}}const Yi="Agent referrals will appear here once agents start bringing buyers to your projects.";
20class Ns extends Error{constructor(l,j){super(j),this.kind=l,this.name="PdfBrochureLoadError"}}const Xi=1600;let _l=null;async function Zi(){return _l||(_l=(async()=>{const a=await jn(()=>import("./vendor-pdf-DL7mhE2w.js").then(j=>j.p),[]),l=(await jn(async()=>{const{default:j}=await import("./vendor-pdf-DL7mhE2w.js").then(u=>u.a);return{default:j}},[])).default;return a.GlobalWorkerOptions.workerSrc=l,a})()),_l}async function Ji(a){const l=await Zi(),j=await a.arrayBuffer();let u;try{u=await l.getDocument({data:j,isEvalSupported:!1}).promise}catch(F){throw(F==null?void 0:F.name)==="PasswordException"?new Ns("encrypted","This PDF is password-protected. Remove the password (e.g. re-export it without one) and upload it again."):(F==null?void 0:F.name)==="InvalidPDFException"?new Ns("corrupt","This file could not be read as a PDF. It may be corrupted, truncated, or not actually a PDF â try re-exporting it."):new Ns("unknown",`This PDF could not be opened (${(F==null?void 0:F.message)||"unknown error"}). Try re-exporting it and uploading again.`)}if(!u.numPages||u.numPages<1)throw new Ns("empty","This PDF has no pages to extract.");const E=new Map;async function y(F){let b=E.get(F);return b||(b=await u.getPage(F),E.set(F,b)),b}return{numPages:u.numPages,async renderPage(F,b){let K;try{K=await y(F)}catch(O){throw new Ns("unknown",`Page ${F} could not be loaded (${(O==null?void 0:O.message)||"unknown error"}).`)}const v=K.getViewport({scale:1}),te=(b==null?void 0:b.maxDimensionPx)??Xi,V=Math.min(te/v.width,te/v.height,3),g=K.getViewport({scale:Math.max(V,.1)}),M=document.createElement("canvas");M.width=Math.max(1,Math.round(g.width)),M.height=Math.max(1,Math.round(g.height));const i=M.getContext("2d");if(!i)throw new Ns("unknown","This browser could not create a canvas to render the PDF.");try{await K.render({canvasContext:i,viewport:g}).promise}catch(O){throw new Ns("unknown",`Page ${F} could not be rendered (${(O==null?void 0:O.message)||"unknown error"}).`)}return{pageNumber:F,canvas:M,widthPx:M.width,heightPx:M.height}},destroy(){E.clear(),u.destroy()}}}function Qi(a){const l=a.getContext("2d");if(!l)return!1;const{width:j,height:u}=a;if(j===0||u===0)return!0;const E=Math.min(j,64),y=Math.min(u,64),F=l.getImageData(0,0,E,y).data;let b=-1;for(let K=0;K<F.length;K+=4){const v=F[K]<<16|F[K+1]<<8|F[K+2];if(b===-1)b=v;else if(v!==b)return!1}return!0}async function ed(a,l,j={}){const{maxOutputDimensionPx:u=2e3,mimeType:E="image/png",quality:y=.92}=j,F=Math.max(1,Math.round(l.width)),b=Math.max(1,Math.round(l.height)),K=Math.max(0,Math.round(l.x)),v=Math.max(0,Math.round(l.y)),te=Math.min(1,u/Math.max(F,b)),V=Math.max(1,Math.round(F*te)),g=Math.max(1,Math.round(b*te)),M=document.createElement("canvas");M.width=V,M.height=g;const i=M.getContext("2d");if(!i)throw new Error("This browser could not create a canvas to export the crop.");return i.drawImage(a,K,v,F,b,0,0,V,g),new Promise((O,U)=>{M.toBlob(ie=>ie?O(ie):U(new Error("Failed to export the crop as an image.")),E,E==="image/jpeg"?y:void 0)})}const Pn=.04,td=.02,sd=.08,ad=.02,rd=.08;function kr(a){const l=Math.min(1,Math.max(Pn,a.width)),j=Math.min(1,Math.max(Pn,a.height)),u=Math.min(1-l,Math.max(0,a.x)),E=Math.min(1-j,Math.max(0,a.y));return{x:u,y:E,width:l,height:j}}const ld=({imageSrc:a,naturalWidth:l,naturalHeight:j,value:u,onChange:E,label:y})=>{const F=r.useRef(null),b=r.useRef(null),[K,v]=r.useState(!1),te=r.useCallback((R,G)=>{var x;const re=(x=F.current)==null?void 0:x.getBoundingClientRect();return!re||re.width===0||re.height===0?{fx:0,fy:0}:{fx:(R-re.left)/re.width,fy:(G-re.top)/re.height}},[]),V=r.useCallback(R=>{const G=b.current;if(!G)return;const{fx:re,fy:x}=te(R.clientX,R.clientY),D=te(G.startX,G.startY),q=re-D.fx,de=x-D.fy;if(G.type==="move"){E(kr({...G.origin,x:G.origin.x+q,y:G.origin.y+de}));return}const J=G.origin;let me={...J};G.corner==="se"?me={x:J.x,y:J.y,width:J.width+q,height:J.height+de}:G.corner==="sw"?me={x:J.x+q,y:J.y,width:J.width-q,height:J.height+de}:G.corner==="ne"?me={x:J.x,y:J.y+de,width:J.width+q,height:J.height-de}:G.corner==="nw"&&(me={x:J.x+q,y:J.y+de,width:J.width-q,height:J.height-de}),E(kr(me))},[E,te]),g=r.useCallback(()=>{b.current=null,v(!1),window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",g)},[V]),M=R=>{R.preventDefault(),b.current={type:"move",startX:R.clientX,startY:R.clientY,origin:u},v(!0),window.addEventListener("pointermove",V),window.addEventListener("pointerup",g)},i=R=>G=>{G.preventDefault(),G.stopPropagation(),b.current={type:"resize",corner:R,startX:G.clientX,startY:G.clientY,origin:u},v(!0),window.addEventListener("pointermove",V),window.addEventListener("pointerup",g)},O=R=>
20{const G=R.shiftKey?sd:td;let re=0,x=0;if(R.key==="ArrowLeft")re=-G;else if(R.key==="ArrowRight")re=G;else if(R.key==="ArrowUp")x=-G;else if(R.key==="ArrowDown")x=G;else if(R.key==="Home"){R.preventDefault(),E(kr({x:0,y:0,width:1,height:1}));return}else return;R.preventDefault(),E(kr({...u,x:u.x+re,y:u.y+x}))},U=R=>G=>{const re=G.shiftKey?rd:ad;let x=0,D=0;if(G.key==="ArrowLeft")x=-re;else if(G.key==="ArrowRight")x=re;else if(G.key==="ArrowUp")D=-re;else if(G.key==="ArrowDown")D=re;else return;G.preventDefault();const q=u;let de={...q};R==="se"?de={x:q.x,y:q.y,width:q.width+x,height:q.height+D}:R==="sw"?de={x:q.x+x,y:q.y,width:q.width-x,height:q.height+D}:R==="ne"?de={x:q.x,y:q.y+D,width:q.width+x,height:q.height-D}:R==="nw"&&(de={x:q.x+x,y:q.y+D,width:q.width-x,height:q.height-D}),E(kr(de))},ie=l>0&&j>0?`${l} / ${j}`:void 0,I=[{key:"nw",style:{left:0,top:0,cursor:"nwse-resize"},name:"top-left"},{key:"ne",style:{right:0,top:0,cursor:"nesw-resize"},name:"top-right"},{key:"sw",style:{left:0,bottom:0,cursor:"nesw-resize"},name:"bottom-left"},{key:"se",style:{right:0,bottom:0,cursor:"nwse-resize"},name:"bottom-right"}];return e.jsxs("div",{ref:F,className:"relative w-full select-none rounded-xl overflow-hidden bg-slate-100 border border-slate-200",style:{aspectRatio:ie,touchAction:"none"},children:[e.jsx("img",{src:a,alt:`${y} â full page`,className:"absolute inset-0 w-full h-full object-contain pointer-events-none",draggable:!1}),e.jsxs("div",{className:"absolute inset-0 pointer-events-none","aria-hidden":"true",children:[e.jsx("div",{className:"absolute bg-slate-900/45",style:{left:0,top:0,right:0,height:`${u.y*100}%`}}),e.jsx("div",{className:"absolute bg-slate-900/45",style:{left:0,bottom:0,right:0,height:`${(1-u.y-u.height)*100}%`}}),e.jsx("div",{className:"absolute bg-slate-900/45",style:{left:0,top:`${u.y*100}%`,width:`${u.x*100}%`,height:`${u.height*100}%`}}),e.jsx("div",{className:"absolute bg-slate-900/45",style:{right:0,top:`${u.y*100}%`,width:`${(1-u.x-u.width)*100}%`,height:`${u.height*100}%`}})]}),e.jsx("div",{role:"group",tabIndex:0,"aria-label":`${y}. Use arrow keys to move the crop, or Home to reset it to the full page.`,onPointerDown:M,onKeyDown:O,className:`absolute border-2 border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-1 ${K?"cursor-grabbing":"cursor-grab"}`,style:{left:`${u.x*100}%`,top:`${u.y*100}%`,width:`${u.width*100}%`,height:`${u.height*100}%`,boxShadow:"0 0 0 1px rgba(255,255,255,0.6)"},children:I.map(R=>e.jsx("button",{type:"button","aria-label":`Resize ${y} â ${R.name} corner. Use arrow keys to resize from this corner.`,onPointerDown:i(R.key),onKeyDown:U(R.key),className:"absolute w-3.5 h-3.5 -m-1.5 rounded-full bg-white border-2 border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-1",style:R.style},R.key))})]})},Rn={x:.1,y:.1,width:.8,height:.8},nd=({uploadListingAsset:a,assetPathPrefix:l,galleryImages:j,floorPlans:u,onGalleryImagesChange:E,onFloorPlansChange:y})=>{var Fe;const[F,b]=r.useState(null),[K,v]=r.useState(null),[te,V]=r.useState(!1),[g,M]=r.useState(null),[i,O]=r.useState(0),[U,ie]=r.useState({}),[I,R]=r.useState(null),[G,re]=r.useState(Rn),[x,D]=r.useState("gallery"),[q,de]=r.useState(""),[J,me]=r.useState(!1),[Q,Ie]=r.useState(null),[Ae,Ce]=r.useState(0),Le=r.useRef(null);r.useEffect(()=>()=>{var $;($=Le.current)==null||$.destroy()},[]);const Je=Object.values(U).filter($=>$.status==="rendered"||$.status==="error").length,$e=r.useCallback(()=>{var $;($=Le.current)==null||$.destroy(),Le.current=null,M(null),O(0),ie({}),R(null),v(null),Ce(0)},[]),ve=r.useCallback(async $=>{if($){if($e(),b($.name),$.type&&$.type!=="application/pdf"&&!$.name.toLowerCase().endsWith(".pdf")){v("That file does not look like a PDF. Please select a .pdf brochure file.");return}V(!0);try{const le=await Ji($);Le.current=le,M(le),O(le.numPages);const ne={};for(let N=1;N<=le.numPages;N++)ne[N]={status:"pending"};ie(ne)}catch(le){le instanceof Ns?v(le.message):v("This PDF could not be opened. Please try a different file.")}finally{V(!1)}}},[$e]),qe=r.useCallback(async $=>{const le=Le.current;if(le){ie(ne=>{const N=ne[$];return N&&N.status!=="pending"?ne:{...ne,[$]:{status:"rendering"}}});try{const ne=await le.renderPage($,{maxDimensionPx:1400}),N=ne.canvas.toDataURL("image/jpeg",.85),ue=Qi(ne.canvas);ie(m=>({...m,[$]:{status:"rendered",dataUrl:N,canvas:ne.canvas,widthPx:ne.widthPx,heightPx:ne.heightPx,looksBlank:ue}}))}catch(ne){const N=ne instanceof Ns?ne.message:`Page ${$} failed to render.`;ie(ue=>({...ue,[$]:{status:"error",error:N}}))}}},[]),Pe=$=>{R($),re(Rn),D("gallery"),de(""),Ie(null)},Ve=()=>{R(null),Ie(null)},et=async()=>
20{if(I==null)return;const $=U[I];if($!=null&&$.canvas){if(x==="floorPlan"&&!q.trim()){Ie('Add a label for this floor plan (e.g. "3 BHK â Tower A") before saving.');return}me(!0),Ie(null);try{const le=$.canvas,ne={x:G.x*le.width,y:G.y*le.height,width:G.width*le.width,height:G.height*le.height},N=await ed(le,ne,{maxOutputDimensionPx:2e3,mimeType:"image/jpeg",quality:.9}),ue=new File([N],`brochure-p${I}-crop.jpg`,{type:"image/jpeg"}),m=await a(ue,`${l}-p${I}-${Date.now()}`);x==="gallery"?E([...j,m]):y(x==="floorPlan"?[...u,{label:q.trim(),url:m}]:[...u,{label:q.trim()||"Master Plan",url:m}]),Ce(C=>C+1),Ve()}catch(le){Ie((le==null?void 0:le.message)||"Failed to upload this crop. Please try again.")}finally{me(!1)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h5",{className:"text-xs font-mono font-bold text-slate-500 uppercase text-left",children:"Brochure Page Extractor"}),i>0&&e.jsxs("span",{className:"text-xs font-mono text-slate-400",children:[Je,"/",i," pages rendered"]})]}),e.jsxs("label",{htmlFor:"brochure-pdf-input",onDragOver:$=>$.preventDefault(),onDrop:$=>{var ne;$.preventDefault();const le=(ne=$.dataTransfer.files)==null?void 0:ne[0];ve(le)},className:"flex items-center gap-2 justify-center border border-dashed border-slate-300 rounded-xl p-4 text-center cursor-pointer hover:border-brand-400 hover:bg-brand-50/30 transition-all",children:[e.jsx($s,{className:"w-4 h-4 text-slate-400 shrink-0"}),e.jsx("span",{className:"text-xs text-slate-500",children:F?e.jsx("span",{className:"font-bold text-slate-700",children:F}):"Drop a brochure PDF here, or click to select one"}),e.jsx("input",{id:"brochure-pdf-input",type:"file",accept:"application/pdf,.pdf",className:"sr-only",onChange:$=>{var le;ve((le=$.target.files)==null?void 0:le[0]),$.target.value=""}})]}),te&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500",children:[e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"})," Opening PDFâ¦"]}),K&&e.jsxs("div",{className:"p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700 font-semibold flex items-start gap-2",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsx("span",{children:K})]}),Ae>0&&e.jsxs("div",{className:"p-2.5 bg-emerald-50 border border-emerald-200 rounded-xl text-xs text-emerald-700 font-semibold flex items-center gap-2",children:[e.jsx(ts,{className:"w-3.5 h-3.5 shrink-0"}),Ae," crop",Ae===1?"":"s"," added to this listing."]}),i>0&&e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 max-h-[280px] overflow-y-auto pr-0.5",children:Array.from({length:i},($,le)=>le+1).map($=>e.jsx(od,{pageNumber:$,state:U[$]??{status:"pending"},onVisible:()=>void qe($),onCrop:()=>Pe($)},$))}),I!=null&&((Fe=U[I])==null?void 0:Fe.dataUrl)&&e.jsxs("div",{className:"border border-slate-200 rounded-2xl p-3 bg-white space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-bold text-slate-700 uppercase",children:["Crop page ",I]}),e.jsx("button",{type:"button",onClick:Ve,"aria-label":"Close crop editor",className:"text-slate-400 hover:text-slate-700 cursor-pointer",children:e.jsx(ot,{className:"w-4 h-4"})})]}),e.jsx(ld,{imageSrc:U[I].dataUrl,naturalWidth:U[I].widthPx||1,naturalHeight:U[I].heightPx||1,value:G,onChange:re,label:`Crop selection, page ${I}`}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crop-purpose",className:"text-xs font-mono font-bold text-slate-400 uppercase block mb-1",children:"Use this crop as"}),e.jsxs("select",{id:"crop-purpose",value:x,onChange:$=>D($.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-sm",children:[e.jsx("option",{value:"gallery",children:"Gallery photo"}),e.jsx("option",{value:"floorPlan",children:"Floor plan"}),e.jsx("option",{value:"masterPlan",children:"Master plan"})]})]}),(x==="floorPlan"||x==="masterPlan")&&e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"crop-label",className:"text-xs font-mono font-bold text-slate-400 uppercase block mb-1",children:["Label ",x==="floorPlan"?"(required)":'(optional, defaults to "Master Plan")']}),e.jsx("input",{id:"crop-label",type:"text",placeholder:x==="floorPlan"?"e.g. 3 BHK â Tower A":"e.g. Master Plan â Phase 1",value:q,onChange:$=>de($.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-sm"})]})]}),Q&&e.jsx("div",{className:"p-2 bg-rose-50 border border-rose-200 rounded-lg text-xs text-rose-700 font-semibold",children:Q}),e.jsx("button",{type:"button",onClick:()=>void et(),disabled:J,className:"w-full py-2 bg-brand-500 hover:bg-brand-600 text-white text-sm font-bold rounded-lg transition-all disabled:opacity-50 flex items-center justify-center gap-1.5",children:J?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"})," Uploadingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Mn,{className:"w-3.5 h-3.5"})," Save this crop to the listing"]})})]})]})},od=({pageNumber:a,state:l,onVisible:j,onCrop:u})=>{const E=r.useRef(null),y=r.useRef(!1);return r.useEffect(()=>{const F=E.current;if(!F||y.current)return;const b=new IntersectionObserver(K=>{var v;(v=K[0])!=null&&v.isIntersecting&&!y.current&&(y.current=!0,j(),b.disconnect())},{rootMargin:"200px"});return b.observe(F),()=>b.disconnect()},[j]),e.jsxs("div",{ref:E,className:"border border-slate-200 rounded-xl overflow-hidden bg-slate-50 flex flex-col",children:[e.jsxs("div",{className:"relative aspect-[3/4] bg-slate-100 flex items-center justify-center",children:[l.status==="rendered"&&l.dataUrl?e.jsx("img",{src:l.dataUrl,alt:`Brochure page ${a}`,className:"w-full h-full object-contain"}):l.status==="error"?e.jsxs("div",{className:"p-2 text-center",children:[e.jsx(Ue,{className:"w-4 h-4 text-amber-500 mx-auto mb-1"}),e.jsx("p",{className:"text-xs text-amber-600 leading-tight",children:l.error||"Could not render this page."})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[l.status==="rendering"?e.jsx(ce,{className:"w-4 h-4 text-slate-300 animate-spin"}):e.jsx(za,{className:"w-4 h-4 text-slate-300"}),e.jsxs("span",{className:"text-xs text-slate-400 font-mono",children:["Page ",a]})]}),l.status==="rendered"&&l.looksBlank&&e.jsx("span",{className:"absolute top-1 left-1 bg-amber-100 text-amber-700 text-xs font-bold px-1.5 py-0.5 rounded-full",children:"Looks blank"})]}),e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-slate-200 bg-white",children:[e.jsxs("span",{className:"text-xs font-mono text-slate-400",children:["Page ",a]}),e.jsxs("button",{type:"button",onClick:u,disabled:l.status!=="rendered","aria-label":`Crop page ${a}`,className:"flex items-center gap-1 text-xs font-bold text-brand-600 hover:text-brand-700 disabled:opacity-30 disabled:cursor-not-allowed cursor-pointer",children:[e.jsx(Mn,{className:"w-3 h-3"})," Crop"]})]})]})},ul=10,Nl=2e3,id=200,fl=5,dd=500,cd=/^https:\/\/[^\s<>"']+\.[^\s<>"']+$/i;function xd(a){const l=[];for(const j of(a||"").split(/\r?\n/)){const u=j.trim();if(u){if(u.length>
20dd||!cd.test(u))return{ok:!1,error:`"${u.length>40?u.slice(0,40)+"â¦":u}" is not a valid https:// link.`,urls:l};l.includes(u)||l.push(u)}}return l.length>fl?{ok:!1,error:`Add at most ${fl} links.`,urls:l.slice(0,fl)}:{ok:!0,urls:l}}function Zn(a){const l=(a||"").trim().length;return l===0?{length:l,valid:!1,label:`At least ${ul} characters`}:l<ul?{length:l,valid:!1,label:`${l}/${ul} characters, ${ul-l} more needed`}:l>Nl?{length:l,valid:!1,label:`${l}/${Nl} characters, too long`}:{length:l,valid:!0,label:`${l} characters`}}function pd(a){const l={},j=(a.companyName||"").trim();!j&&!a.hasApprovedCompany&&(l.company="Enter the company you are claiming for."),j.length>id&&(l.company="Company name is too long.");const u=(a.note||"").trim();Zn(u).valid||(l.note=u.length>Nl?"This is too long. Please shorten it.":"Tell us how you are connected to this project.");const y=xd(a.evidenceText);return y.ok===!1&&(l.evidence=y.error),Object.keys(l).length>0||y.ok===!1?{ok:!1,errors:l}:{ok:!0,value:{...j?{companyName:j}:{},note:u,evidenceUrls:y.urls}}}const An="Claim sent for review",md="Our team will check that you are connected to this project, usually within 1 business day. It will appear under My Listings once approved.",ud="Claims are temporarily unavailable. Please try again in a little while.";function Jn(a){const l=(a==null?void 0:a.code)??null;return l==="already_owner"?"You already own this project.":l==="already_owned"?"This project already has an owner. If that is wrong, contact [email protected].":l==="claim_pending"?"You already have a claim for this project under review.":l==="migration_pending"||(a==null?void 0:a.status)===503?ud:(a==null?void 0:a.message)||"We could not send your claim. Please try again."}function hd(a){const l=(a==null?void 0:a.code)??null,j=l==="claim_pending"?"pending":l==="already_owned"?"owned":l==="already_owner"?"yours":null;return!j||!l?null:{kind:j,code:l,message:Jn(a)}}function Kl(a){return a==="approved"?{label:"Approved",tone:"emerald"}:a==="rejected"?{label:"Not approved",tone:"rose"}:a==="pending"?{label:"Under review",tone:"amber"}:{label:"Under review",tone:"slate"}}function bd(a){return a.status!=="rejected"?null:(a.reviewNote||"").trim()||null}function gd(a){var u;const l=(a==null?void 0:a.ownershipPending)===!0,j=(u=a==null?void 0:a.claimRequest)==null?void 0:u.promoterNameMatch;return{pending:l,promoterNameMatch:typeof j=="boolean"?j:null}}function fd(a){return a===!0?"Your company name looks similar to the promoter name on the TS-RERA record.":a===!1?"Your company name does not look like the promoter name on the TS-RERA record, so we may ask you for more detail.":null}const Pr="Name, RERA number and location come from TS-RERA and can't be changed here. Contact support if they're wrong.";function jd(a,l=!1){return!a||l?!1:(a.listingKind??"rera_project")==="rera_project"&&Yo(a.reraNumber)}function yd(a){return(a==null?void 0:a.code)==="rera_identity_locked"?Pr:null}function vl(a,l){return yd(a)??((a==null?void 0:a.message)||l)}function Ln(a,l,j){var y,F;if(!a)return null;let u="";if(a.includes("youtube.com/watch"))try{u=new URL(a).searchParams.get("v")||""}catch{const b=a.match(/[?&]v=([^&#]+)/);u=b?b[1]:""}else a.includes("youtu.be/")?u=((y=a.split("youtu.be/")[1])==null?void 0:y.split("?")[0])||"":a.includes("youtube.com/embed/")&&(u=((F=a.split("youtube.com/embed/")[1])==null?void 0:F.split("?")[0])||"");return u?`https://www.youtube.com/embed/${u}?rel=0&modestbranding=1`:null}const Nd=({user:a,listingId:l,initialData:j,onClose:u,onSuccess:E,loadListings:y,uploadListingAsset:F,identityLocked:b=!1})=>{const[K,v]=r.useState(1),[te,V]=r.useState("overview"),[g,M]=r.useState(l),[i,O]=r.useState(j),[U,ie]=r.useState(!1),[I,R]=r.useState(!1),[G,re]=r.useState(null),[x,D]=r.useState([]),[q,de]=r.useState([]),[J,me]=r.useState(""),[Q,Ie]=r.useState(""),[Ae,Ce]=r.useState(""),[Le,Je]=r.useState(""),[$e,ve]=r.useState("3"),[qe,Pe]=r.useState(""),[Ve,et]=r.useState(""),[Fe,$]=r.useState(""),[le,ne]=r.useState("East"),[N,ue]=r.useState(!1),[m,C]=r.useState(!1),[Y,h]=r.useState("Type A"),[w,T]=r.useState(""),B=zn(w),H=B.areaFields.find(s=>s.key===B.primaryAreaKey)||B.areaFields[0],z=B.areaFields.filter(s=>s.key!==B.primaryAreaKey).find(s=>s.key==="udsArea"||s.key==="plotArea")||null,[se,Ge]=r.useState([]),[o,L]=r.useState(""),[je,pe]=r.useState(""),[he,xt]=r.useState(""),[as,Ms]=r.useState(""),[vs,la]=r.useState(""),[ws,Ha]=r.useState(""),[rs,Bs]=r.useState(""),[kt,Ct]=r.useState(null),[Ss,Os]=r.useState(!1),[ke,bt]=r.useState(""),[Te,ks]=r.useState(""),[ls,_s]=r.useState(""),[Ft,_t]=r.useState([]),[Tt,ns]=r.useState(""),[Dt,na]=r.useState({}),[tt,oa]=r.useState(null),[it,qs]=r.useState(null),[ge,qt]=r.useState(""),[Vt,zt]=r.useState(""),[os,Cs]=r.useState(""),[Pt,It]=r.useState(""),[is,Ht]=r.useState(""),[Rt,Wt]=r.useState([]),[ia,Kt]=r.useState(!1),[Gt,mt]=r.useState(null),[Ps,Vs]=r.useState(""),[ds,da]=r.useState(""),[cs,ca]=r.useState([]),[xa,zs]=r.useState(!1),[Yt,d]=r.useState(null),[Z,ee]=r.useState(""),[Ee,ze]=r.useState("not_uploaded"),[Ye,pt]=r.useState([]),[At,Lt]=r.useState(!1),[xs,Ut]=r.useState(null),[pa,Hs]=r.useState("1"),[Er,Fr]=r.useState(""),[dt,Wa]=r.useState(""),[Ka,Sl]=r.useState("not_started"),[Rs,ma]=r.useState([]),[gt,ua]=r.useState(""),[Tr,W]=r.useState(""),[De,He]=r.useState(null),[As,Ws]=r.useState(!1),[Ga,ps]=r.useState(null),[Dr,Ir]=r.useState(!1),[Ks,Ls]=r.useState([]),[ha,ba]=r.useState(""),[ga,fa]=r.useState(""),[ja,Gs]=r.useState(""),[ya,Ur]=r.useState(""),[Ya,Ys]=r.useState(""),[Na,Me]=r.useState(""),[ft,Xa]=r.useState(""),[Xt,Za]=r.useState(""),[va,$r]=r.useState(""),[jt,$t]=r.useState(""),[Ja,wa]=r.useState(""),[Sa,Qa]=r.useState(""),[ka,yt]=r.useState(""),[Ca,er]=r.useState(""),[Pa,Mr]=r.useState("facing"),[tr,Xs]=r.useState(""),[ms,sr]=r.useState(""),[Ra,ar]=r.useState(""),[Aa,La]=r.useState(""),[us,rr]=r.useState(""),[Es,Br]=r.useState("5"),[Ea,lr]=r.useState("East"),[Or,_r]=r.useState(!1),[Fa,qr]=r.useState(!1),[Ta,Vr]=r.useState("1800"),[Fs,zr]=r.useState(null),[Da,Hr]=r.useState(!1),[Wr,Ts]=r.useState(null),[Re,Kr]=r.useState(null),[Ds,nr]=r.useState(!1),[Is,or]=r.useState(null),[ir,dr]=r.useState(!1),[hs,Zs]=r.useState(null),[ut,Gr]=r.useState(!1),[cr,Ia]=r.useState(null),[Js,xr]=r.useState(null),Nt=async s=>{nr(!0),or(null);try{const p=await rt(a),P=await fetch(`/api/listings/${s}/readiness`,{headers:p}),we=await P.json().catch(()=>null);if(!P.ok)throw new Error((we==null?void 0:we.error)||`Could not load readiness (${P.status}).`);Kr({checks:(we==null?void 0:we.checks)??[],summary:we==null?void 0:we.summary})}catch(p){Kr(null),or(p.message||"Could not load readiness for this listing.")}finally{nr(!1)}};r.useEffect(()=>{typeof g=="number"&&(Mt(g),Qs(g),Ua(g),Yr(g),Nt(g),pr(g),We(g),Ma(g),Jr(g))},[g]),r.useEffect(()=>{te==="locality"&&typeof g=="number"&&Fs===null&&!Da&&(Hr(!0),Ts(null),fetch(`/api/listing/${g}/overview`).then(s=>{if(!s.ok)throw new Error(`overview (${s.status})`);return s.json()}).then(s=>{var p;return zr(((p=s==null?void 0:s.founderReportContent)==null?void 0:p.pointsOfInterest)??[])}).catch(()=>Ts("Could not load location data for this listing.")).finally(()=>Hr(!1)))},[te,g,Fs,Da]);const Yr=async s=>{var p;try{const P={},we=await a.getIdToken().catch(()=>null);we&&(P.Authorization=`Bearer ${we}`);const fe=await fetch(`/api/projects/${s}`,{headers:P});if(!fe.ok)return;const _=await fe.json(),gs=(p=_==null?void 0:_.media)==null?void 0:p.floorPlans;Array.isArray(gs)&&O(nt=>nt.floorPlans===void 0?{...nt,floorPlans:gs}:nt),typeof(_==null?void 0:_.approvalStatus)=="string"&&Zs(_.approvalStatus),typeof(_==null?void 0:_.propertyType)=="string"&&_.propertyType&&T(_.propertyType),typeof(_==null?void 0:_.district)=="str
20ing"&&_.district&&O(nt=>nt.district===void 0?{...nt,district:_.district}:nt),typeof(_==null?void 0:_.pincode)=="string"&&_.pincode&&O(nt=>nt.pincode===void 0?{...nt,pincode:_.pincode}:nt),typeof(_==null?void 0:_.sizeRange)=="string"&&_.sizeRange&&ks(_.sizeRange),typeof(_==null?void 0:_.priceRange)=="string"&&_.priceRange&&_s(_.priceRange),Array.isArray(_==null?void 0:_.amenities)&&_t(_.amenities);const Oe=(_==null?void 0:_.reraDetails)||{};na(Oe),Oe.possessionDate&&(oa(Oe.possessionDate),/^\d{4}-\d{2}-\d{2}$/.test(Oe.possessionDate)&&bt(Oe.possessionDate)),Oe.commencementDate&&(qs(Oe.commencementDate),/^\d{4}-\d{2}-\d{2}$/.test(Oe.commencementDate)&&It(Oe.commencementDate)),Oe.promoterName&&qt(Oe.promoterName),Oe.totalUnits!=null&&zt(String(Oe.totalUnits)),Oe.openSpacePct!=null&&Cs(String(Oe.openSpacePct)),Oe.constructionProgressPct!=null&&Ht(String(Oe.constructionProgressPct)),Array.isArray(Oe.landOwners)&&ma(Oe.landOwners)}catch(P){console.error(P)}},Mt=async s=>{try{const p=await fetch(`/api/projects/${s}/towers`);p.ok&&D(await p.json())}catch(p){console.error(p)}},Qs=async s=>{try{const p=await Ar(a,s);de(p)}catch(p){console.error(p)}},Ua=async s=>{try{const p=await Xo(a,s);Ge(p)}catch(p){console.error(p)}},pr=async s=>{Kt(!0),mt(null);try{Wt(await Zo(a,s))}catch(p){mt(p.message||"Could not load specifications.")}finally{Kt(!1)}},st=async()=>{if(typeof g!="number"){mt("Save the basics first â this listing doesn't exist yet.");return}const s=Ps.trim(),p=ds.trim();if(!(!s||!p)){mt(null);try{const P=Rt.find(we=>we.category.toLowerCase()===s.toLowerCase());P?await yn(a,P.id,{items:[...P.items,p]}):await si(a,g,{category:s,items:[p]}),da(""),await pr(g)}catch(P){mt(P.message||"Failed to add specification.")}}},$a=async(s,p)=>{if(typeof g=="number"){mt(null);try{const P=s.items.filter((we,fe)=>fe!==p);P.length===0?await ai(a,s.id):await yn(a,s.id,{items:P}),await pr(g)}catch(P){mt(P.message||"Failed to update specification.")}}},We=async s=>{zs(!0),d(null);try{ca(await Jo(a,s))}catch(p){d(p.message||"Could not load approvals.")}finally{zs(!1)}},Zt=async()=>{if(typeof g!="number"){d("Save the basics first â this listing doesn't exist yet.");return}const s=Z.trim();if(s){d(null);try{await ri(a,g,{docName:s,status:Ee}),ee(""),await We(g)}catch(p){d(p.message||"Failed to add approval.")}}},Xr=async s=>{if(typeof g=="number"){d(null);try{await li(a,s),await We(g)}catch(p){d(p.message||"Failed to delete approval.")}}},Ma=async s=>{Lt(!0),Ut(null);try{pt(await Qo(a,s))}catch(p){Ut(p.message||"Could not load construction milestones.")}finally{Lt(!1)}},Zr=async()=>{if(typeof g!="number"){Ut("Save the basics first â this listing doesn't exist yet.");return}const s=parseInt(pa,10),p=Er.trim();if(!(!p||!Number.isInteger(s)||s<1||s>10)){Ut(null);try{const P=dt.trim()?parseFloat(dt):void 0;await ni(a,g,{taskNo:s,label:p,pct:P!==void 0&&!isNaN(P)?P:void 0,status:Ka}),Fr(""),Wa(""),await Ma(g)}catch(P){Ut(P.message||"Failed to record milestone.")}}},mr=async s=>{if(typeof g=="number"){Ut(null);try{await oi(a,s),await Ma(g)}catch(p){Ut(p.message||"Failed to delete milestone.")}}},Jr=async s=>{var p,P,we,fe;Ws(!0),ps(null);try{const _=await ei(a,s);He(_),_&&(Ls(_.surveyNos??[]),fa(_.totalSqm!=null?String(_.totalSqm):""),Gs(_.netSqm!=null?String(_.netSqm):""),Ur(_.deductionsSqm!=null?String(_.deductionsSqm):""),Ys(((p=_.boundaries)==null?void 0:p.north)??""),Me(((P=_.boundaries)==null?void 0:P.south)??""),Xa(((we=_.boundaries)==null?void 0:we.east)??""),Za(((fe=_.boundaries)==null?void 0:fe.west)??""),$r(_.landUse??""),$t(_.authority??""),wa(_.planApprovalNo??""))}catch(_){ps(_.message||"Could not load land details.")}finally{Ws(!1)}},Qr=()=>{ha.trim()&&(Ls(s=>[...s,ha.trim()]),ba(""))},el=async()=>{if(typeof g!="number"){ps("Save the basics first â this listing doesn't exist yet.");return}Ir(!0),ps(null);try{const s={};if(Ks.length>0&&(s.surveyNos=Ks),ga.trim()&&!isNaN(parseFloat(ga))&&(s.totalSqm=parseFloat(ga)),ja.trim()&&!isNaN(parseFloat(ja))&&(s.netSqm=parseFloat(ja)),ya.trim()&&!isNaN(parseFloat(ya))&&(s.deductionsSqm=parseFloat(ya)),(Ya.trim()||Na.trim()||ft.trim()||Xt.trim())&&(s.boundaries={north:Ya.trim()||void 0,south:Na.trim()||void 0,east:ft.trim()||void 0,west:Xt.trim()||void 0}),va.trim()&&(s.landUse=va.trim()),jt.trim()&&(s.authority=jt.trim()),Ja.trim()&&(s.planApprovalNo=Ja.trim()),Object.keys(s).length===0){ps("Enter at least one field before saving.");return}const p=await ii(a,g,s);He(p),E("Land & legal details saved.")}catch(s){ps(s.message||"Failed to save land details.")}finally{Ir(!1)}},kl=async()=>
20{if(typeof g!="number"){re("Save the basics first â this listing doesn't exist yet.");return}if(!(!J||!Q))try{(await fetch(`/api/projects/${g}/towers`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${await a.getIdToken()}`},body:JSON.stringify({name:J.trim(),totalFloors:parseInt(Q,10)})})).ok&&(me(""),Ie(""),Mt(g))}catch(s){console.error(s)}},tl=async s=>{if(typeof g=="number")try{(await fetch(`/api/towers/${s}`,{method:"DELETE",headers:{Authorization:`Bearer ${await a.getIdToken()}`}})).ok&&Mt(g)}catch(p){console.error(p)}},Be=async()=>{if(typeof g!="number"){re("Save the basics first â this listing doesn't exist yet.");return}if(!(!Ae||!qe))try{await ci(a,{projectId:g,unitNumber:Ae.trim(),floor:parseInt(Le||"1",10),bhk:parseInt($e,10),sizeSqFt:parseInt(qe,10),status:"Available"});const p=(await Ar(a,g)).find(P=>P.unitNumber===Ae.trim()&&String(P.floor)===Le);p&&await Wn(a,p.id,{status:"Available",unitNumber:p.unitNumber,floor:p.floor,bhk:p.bhk,sizeSqFt:p.sizeSqFt,carpetArea:parseFloat(Ve)||null,udsArea:parseFloat(Fe)||null,facing:le,isCorner:N,hasViewPremium:m,planVariant:Y}),Ce(""),Je(""),Pe(""),et(""),$(""),ue(!1),C(!1),Qs(g)}catch(s){console.error(s)}},Qe=async()=>{if(typeof g!="number"){Ct("Save the basics first â this listing doesn't exist yet.");return}Ct(null);const s=parseFloat(he);if(!o.trim()){Ct('A code/name for this configuration is required (e.g. "3BHK-E-1800" or "Plot-200").');return}if(!he||isNaN(s)||s<=0){Ct(`${H.label} must be a positive number â this is what unlocks submission.`);return}Os(!0);try{const p={code:o.trim(),saleableSqft:s};if(B.hasBhk&&je.trim()){const P=parseFloat(je);!isNaN(P)&&P>0&&(p.bhk=P)}if(rs&&(p.facing=rs),as.trim()){const P=parseFloat(as);!isNaN(P)&&P>0&&(p.carpetSqft=P)}if(B.primaryAreaKey==="builtUpArea")p.builtUpSqft=s;else if(vs.trim()){const P=parseFloat(vs);!isNaN(P)&&P>0&&(p.builtUpSqft=P)}if(ws.trim()){const P=parseFloat(ws);!isNaN(P)&&P>0&&(p.udsSqft=P)}await Hn(a,g,p),L(""),pe(""),xt(""),Ms(""),la(""),Ha(""),Bs(""),await Ua(g),Nt(g)}catch(p){Ct(p.message||"Failed to add configuration.")}finally{Os(!1)}},Ke=async s=>{if(typeof g=="number")try{await di(a,s),await Ua(g),Nt(g)}catch(p){console.error(p)}},lt=async(s,p)=>{var we;const P=(we=s.target.files)==null?void 0:we[0];if(!(!P||typeof g!="number"))try{const fe=await F(P,`projects/${g}/${p}-${Date.now()}`);O(_=>({..._,[p]:fe})),E(`${p} uploaded successfully!`)}catch(fe){re(`Upload failed: ${fe.message}`)}},ht=async s=>{var Oe,nt;s.preventDefault();const p=parseFloat(i.basePricePerSqFt);if(!i.name.trim()||!i.location.trim()||isNaN(p)||p<=0){re("Name, location, and a valid base rate are required.");return}ie(!0),re(null);const P={name:i.name.trim(),location:i.location.trim(),district:((Oe=i.district)==null?void 0:Oe.trim())||void 0,pincode:((nt=i.pincode)==null?void 0:nt.trim())||void 0,region:i.region,reraNumber:i.reraNumber.trim()||void 0,status:i.status,basePricePerSqFt:p,latitude:i.latitude?parseFloat(i.latitude):void 0,longitude:i.longitude?parseFloat(i.longitude):void 0},we={brochureUrl:i.brochureUrl||void 0,walkthroughVideoUrl:i.walkthroughVideoUrl||void 0,reraApplicationUrl:i.reraApplicationUrl||void 0,priceSheetUrl:i.priceSheetUrl||void 0,galleryImages:i.galleryImages,floorPlans:i.floorPlans,videoClips:i.videoClips},fe={...Dt};ke&&(fe.possessionDate=ke),Pt&&(fe.commencementDate=Pt),ge.trim()&&(fe.promoterName=ge.trim()),Vt.trim()&&!isNaN(parseInt(Vt,10))&&(fe.totalUnits=parseInt(Vt,10)),os.trim()&&!isNaN(parseFloat(os))&&(fe.openSpacePct=parseFloat(os)),is.trim()&&!isNaN(parseFloat(is))&&(fe.constructionProgressPct=parseFloat(is)),Rs.length>0&&(fe.landOwners=Rs);const _={propertyType:w||void 0,sizeRange:Te.trim()||void 0,priceRange:ls.trim()||void 0,amenities:Ft.length>0?Ft:void 0,reraDetails:fe},gs=async ct=>{if(!I)return null;const Us=await rt(a),ta=await fetch(`/api/projects/${ct}/price-sheet`,{headers:Us}),fs=ta.ok?await ta.json().catch(()=>null):null,Et=fs&&typeof fs=="object"&&"priceSheet"in fs?fs.priceSheet:fs;if(!Et||!Array.isArray(Et.plans)||Et.plans.length===0)return" Your floor-rise, premium and parking rules were not saved: this project has no price sheet yet (create one under Inventory & Pricing, then Price Sheets).";const hr=Et.plans.map((Ze,br)=>br===0?{...Ze,floorRise:i.floorRiseStartFloor?{startFloor:parseInt(i.floorRiseStartFloor,10),ratePerSftPerFloor:parseFloat(i.floorRiseRatePerSft||"0")}:null,premiums:i.premiums,parkingRules:i.parkingRules}:Ze),ye=await fetch(`/api/projects/${ct}/price-sheet`,{method:"PUT",headers:{"Content-Type":"application/json",...Us},body:JSON.stringify({plans:hr,charges:Et.charges,taxes:Et.taxes,areaBasis:Et.areaBasis,notes:Et.notes??void 0})});if(!ye.ok){const Ze=await ye.json().catch(()=>({}));return` Your pricing rules were not saved: ${(Ze==null?void 0:Ze.error)||"the price sheet could not be updated."}`}return R(!1)," Pricing rules were saved to your price sheet and sent for review."};try{let ct;if(g==="new"){ct=(await ti(a,P)).id,await Lr(a,ct,{media:we,..._});const ta=await gs(ct);E(`Listing created successfully! Proceeding to units config.${ta??""}`),M(ct),v(3)}else{ct=g,await Lr(a,ct,{...P,media:we,..._});const Us=await gs(ct);E(`Listing changes saved successfully.${Us??""}`),Nt(ct),u()}y()}catch(ct){re(vl(ct,"Failed to save details."))}finally{ie(!1)}}
20,ur=async()=>{if(typeof g=="number"){Gr(!0),Ia(null),xr(null);try{const s=await rt(a),p=await fetch(`/api/listings/${g}/submit`,{method:"POST",headers:s}),P=await p.json().catch(()=>null);if(p.status===422){Ia((P==null?void 0:P.message)||"This listing is not ready to submit."),xr(Array.isArray(P==null?void 0:P.failingChecks)?P.failingChecks:null),Nt(g);return}if(!p.ok)throw new Error((P==null?void 0:P.error)||`Failed to submit listing (${p.status}).`);Zs((P==null?void 0:P.approvalStatus)||"legal_review"),E(`"${i.name||"Listing"}" submitted for legal review.`),y()}catch(s){Ia(s.message||"Failed to submit listing for review.")}finally{Gr(!1)}}},bs=parseFloat(i.basePricePerSqFt),ea=Number.isFinite(bs)&&bs>0,Jt=(()=>{try{const s=parseFloat(Ta);if(isNaN(s)||s<=0||!ea)return null;const p={areaBasis:"saleable",plans:[{id:"standard",name:"Standard Payment Plan",tagline:"",baseRatePerSft:bs,floorRise:i.floorRiseStartFloor?{startFloor:parseInt(i.floorRiseStartFloor,10),ratePerSftPerFloor:parseFloat(i.floorRiseRatePerSft||"0")}:null,premiums:i.premiums,parkingRules:i.parkingRules,milestones:[]}],charges:[],taxes:{gstPct:0,stampDuty:"govt",registration:"govt"}},P={saleableArea:s,floor:parseInt(Es,10)||1,facing:Ea,isCorner:Or,hasViewPremium:Fa};return wl(p,"standard",P)}catch{return null}})();return e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6 items-start",children:[e.jsxs("div",{className:"lg:col-span-7 bg-white border border-slate-200 rounded-3xl p-6 shadow-xs relative",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6 border-b border-slate-100 pb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-extrabold text-slate-900 font-display",children:g==="new"?"Create New Listing":"Edit Listing Workflow"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-mono mt-0.5",children:"Configure project metadata, complex price rules, and claim unit mapping"})]}),e.jsx("button",{type:"button",onClick:u,className:"text-slate-400 hover:text-slate-700 cursor-pointer p-1.5 hover:bg-slate-50 rounded-lg transition-all",children:e.jsx(ot,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center justify-between border border-slate-100 rounded-2xl p-1 mb-6 bg-slate-50/50",children:[e.jsx("button",{type:"button",onClick:()=>v(1),className:`flex-1 py-2 px-3 text-[10px] font-bold rounded-xl transition-all cursor-pointer text-center ${K===1?"bg-white text-slate-800 shadow-sm border border-slate-200/40":"text-slate-400 hover:text-slate-700"}`,children:"1. Basic & Media"}),e.jsx("button",{type:"button",onClick:()=>{if(typeof g!="number"){re("Save the basics first â this listing doesn't exist yet.");return}v(2)},"aria-disabled":typeof g!="number",title:typeof g!="number"?"Save the project's basic details in Step 1 first â this listing doesn't exist yet.":void 0,className:`flex-1 py-2 px-3 text-[10px] font-bold rounded-xl transition-all text-center ${K===2?"bg-white text-slate-800 shadow-sm border border-slate-200/40":"text-slate-400 hover:text-slate-700"} ${typeof g!="number"?"opacity-40 cursor-not-allowed":"cursor-pointer"}`,children:"2. Pricing & Rules"}),e.jsx("button",{type:"button",onClick:()=>{if(typeof g!="number"){re("Save the basics first â this listing doesn't exist yet.");return}v(3)},"aria-disabled":typeof g!="number",title:typeof g!="number"?"Save the project's basic details in Step 1 first â this listing doesn't exist yet.":void 0,className:`flex-1 py-2 px-3 text-[10px] font-bold rounded-xl transition-all text-center ${K===3?"bg-white text-slate-800 shadow-sm border border-slate-200/40":"text-slate-400 hover:text-slate-700"} ${typeof g!="number"?"opacity-40 cursor-not-allowed":"cursor-pointer"}`,children:"3. Towers & Units"})]}),typeof g!="number"?e.jsx("div",{className:"mb-6 p-3.5 bg-slate-50 border border-slate-200 rounded-2xl text-[10px] text-slate-500 leading-relaxed",children:"Save the project's basic details first â listing readiness is checked once this listing exists."}):e.jsxs("div",{className:"mb-6 border border-slate-100 rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"p-4 bg-slate-50/60 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("h4",{className:"text-[10px] font-mono font-extrabold text-slate-700 uppercase",children:"Listing Readiness"}),Re&&!Ds&&!Is&&e.jsx("span",{className:`text-[9px] font-mono font-bold px-2 py-0.5 rounded-md shrink-0 ${Re.summary.requiredFailing===0?"text-emerald-700 bg-emerald-50":"text-rose-700 bg-rose-50"}`,children:Re.summary.requiredFailing===0?`${Re.summary.requiredTotal}/${Re.summary.requiredTotal} required complete`:`${Re.summary.requiredFailing} required item${Re.summary.requiredFailing===1?"":"s"} missing`})]}),Ds&&e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-slate-400",children:[e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"})," Checking listing readinessâ¦"]}),!Ds&&Is&&e.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-rose-50 border border-rose-200 rounded-xl text-[10px] text-rose-700",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 shrink-0"}),e.jsx("span",{className:"flex-1",children:Is}),e.jsx("button",{type:"button",onClick:()=>Nt(g),className:"font-bold underline shrink-0 cursor-pointer",children:"Retry"})]}),!Ds&&!Is&&Re&&e.jsxs(e.Fragment,{children:[Re.summary.requiredFailing===0?e.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-emerald-50 border border-emerald-100 rounded-xl text-[10px] text-emerald-700 font-semibold",children:[e.jsx(ts,{className:"w-3.5 h-3.5 shrink-0"}),"All required checks are complete â nothing here blocks submission."]}):e.jsx("div",{className:"space-y-1.5",children:Re.summary.failingRequired.map(s=>e.jsxs("div",{className:"flex items-start gap-2 p-2.5 bg-rose-50 border border-rose-100 rounded-xl",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 text-rose-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-[10px] leading-relaxed",children:[e.jsx("span",{className:"inline-block text-[8px] font-mono font-bold text-rose-500 uppercase tracking-wide mr-1.5",children:s.section}),e.jsx("span",{className:"text-rose-700",children:s.whenFailing})]})]},s.key))}),e.jsxs("div",{className:"pt-1",children:[e.jsxs("button",{type:"button",onClick:()=>dr(s=>!s),className:"flex items-center gap-1 text-[9px] font-mono font-bold text-slate-400 hover:text-slate-600 cursor-pointer",children:[e.jsx(bl,{className:`w-3 h-3 transition-transform ${ir?"rotate-180":""}`}),Re.summary.recommendedFailing===0?"All recommended checks are also complete":`${Re.summary.recommendedFailing} recommended item${Re.summary.recommendedFailing===1?"":"s"} â won't block submission`]}),ir&&Re.summary.recommendedFailing>0&&e.jsx("div",{className:"space-y-1.5 pt-2",children:Re.summary.failingRecommended.map(s=>e.jsxs("div",{className:"flex items-start gap-2 p-2.5 bg-white border border-slate-100 rounded-xl",children:[e.jsx(rn,{className:"w-3.5 h-3.5 text-slate-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-[10px] leading-relaxed",children:[e.jsx("span",{className:"inline-block text-[8px] font-mono font-bold text-slate-400 uppercase tracking-wide mr-1.5",children:s.section}),e.jsx("span",{className:"text-slate-500",children:s.whenFailing}),e.jsx("span",{className:"block text-[8px] text-slate-400 mt-0.5 italic",children:"Recommended â does not block submission."})]})]},s.key))})]}),e.jsx("p",{className:"text-[8px] text-slate-400 italic leading-relaxed border-t border-slate-100 pt-2",children:"This checks completeness â whether each field is present â not correctness. A listing can pass every check here and still contain the wrong data."})]})]}),e.jsxs("div",{className:"p-4 border-t border-slate-100 space-y-2",children:[hs==="approved"?e.jsx("p",{className:"text-[10px] text-slate-500",children:"This listing is approved and live. Edits save immediately."}):hs==="legal_review"?e.jsx("p",{className:"text-[10px] text-slate-500",children:"Already submitted â pending legal review."}):hs==="pending_approval"?e.jsx("p",{className:"text-[10px] text-slate-500",children:"Cleared legal â pending final Realtified approval."}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:ut||Ds||!!Re&&Re.summary.requiredFailing>0,onClick:ur,className:"w-full py-2 bg-slate-900 hover:bg-slate-800 text-white text-[10px] font-bold rounded-xl transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center gap-1.5",children:ut?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"})," Submittingâ¦"]}):hs==="rejected"?"Resubmit for Review":"Submit for Review"}),Re&&!Ds&&!Is&&Re.summary.requiredFailing>0&&e.jsxs("p",{className:"text-[9px] text-slate-400",children:["Fix the required item",Re.summary.requiredFailing===1?"":"s"," above before submitting."]}),Is&&e.jsx("p",{className:"text-[9px] text-slate-400",children:"We couldn't check this listing for missing items. You can still submit â the same check runs when you do, and we'll tell you then if anything is missing."})]}),cr&&e.jsxs("div",{className:"p-2.5 bg-rose-50 border border-rose-200 rounded-xl text-[10px] text-rose-700 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"font-semibold",children:cr})]}),Js&&Js.length>0&&e.jsx("ul",{className:"pl-5 list-disc space-y-0.5",children:Js.map(s=>e.jsxs("li",{children:[e.jsxs("span",{className:"font-mono text-[8px] uppercase text-rose-500",children:[s.section,":"]})," ",s.missing]},s.key))})]})]})]}),e.jsxs("form",{onSubmit:ht,className:"space-y-6",children:[K===1&&e.jsxs("div",{className:"space-y-4 text-left",children:[b&&e.jsx("p",{className:"text-[10px] text-slate-500 bg-slate-50 border border-slate-200 rounded-xl px-3 py-2",children:Pr}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Project Name *"}),e.jsx("input",{type:"text",placeholder:"e.g. Vajra Skyline",value:i.name,onChange:s=>O(p=>({...p,name:s.target.value})),disabled:b,title:b?Pr:void 0,className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500 disabled:bg-slate-50 disabled:text-slate-500 disabled:cursor-not-allowed",required:!0})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Property Type"}),e.jsxs("select",{value:w,onChange:s=>T(s.target.value),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs bg-white cursor-pointer",children:[e.jsx("option",{value:"",children:"Select a typeâ¦"}),e.jsx("option",{value:"Apartment",children:"Apartment"}),e.jsx("option",{value:"Villa",children:"Villa"}),e.jsx("option",{value:"Gated Community",children:"Gated Community"}),e.jsx("option",{value:"Independent House",children:"Independent House"}),e.jsx("option",{value:"Plot",children:"Plot / Layout"})]}),e.jsxs("p",{className:"text-[8px] text-slate-400 mt-1",children:["Drives the rest of this form â a Plot listing isn't asked for towers or floor-rise pricing, and its"," ",B.configurationNoun.toLowerCase()," editor asks for ",H.label.toLowerCase()," instead of BHK."]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Location / Micro-market *"}),e.jsx("input",{type:"text",placeholder:"e.g. Kokapet, Hyderabad",value:i.location,onChange:s=>O(p=>({...p,location:s.target.value})),disabled:b,title:b?Pr:void 0,className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs outline-none focus:ring-1 focus:ring-brand-500 disabled:bg-slate-50 disabled:text-slate-500 disabled:cursor-not-allowed",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"District"}),e.jsx("input",{type:"text",placeholder:"e.g. Rangareddy",value:i.district||"",onChange:s=>O(p=>({...p,district:s.target.value})),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs outline-none focus:ring-1 focus:ring-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Pincode"}),e.jsx("input",{type:"text",placeholder:"e.g. 500084",inputMode:"numeric",value:i.pincode||"",onChange:s=>O(p=>({...p,pincode:s.target.value})),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-mono outline-none focus:ring-1 focus:ring-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Region *"}),e.jsx("select",{value:i.region,onChange:s=>O(p=>({...p,region:s.target.value})),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs bg-white cursor-pointer",children:["West","East","North","South","Central"].map(s=>e.jsx("option",{value:s,children:s},s))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"RERA Number"}),e.jsx("input",{type:"text",placeholder:"e.g. P02400012345",value:i.reraNumber,onChange:s=>O(p=>({...p,reraNumber:s.target.value})),disabled:b,title:b?Pr:void 0,className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-mono disabled:bg-slate-50 disabled:text-slate-500 disabled:cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Construction Status"}),e.jsx("select",{value:i.status,onChange:s=>O(p=>({...p,status:s.target.value})),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs bg-white cursor-pointer",children:["Under Construction","Ready to Move","New L
20aunch","Pre-launch"].map(s=>e.jsx("option",{value:s,children:s},s))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Base Price / Sq.Ft (â¹) *"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 font-bold text-xs",children:"â¹"}),e.jsx("input",{type:"number",placeholder:"e.g. 8500",value:i.basePricePerSqFt,onChange:s=>O(p=>({...p,basePricePerSqFt:s.target.value})),className:"w-full pl-7 pr-3 py-2 border border-slate-200 rounded-xl text-xs font-mono",required:!0,min:1})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Latitude"}),e.jsx("input",{type:"number",step:"any",value:i.latitude,onChange:s=>O(p=>({...p,latitude:s.target.value})),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Longitude"}),e.jsx("input",{type:"number",step:"any",value:i.longitude,onChange:s=>O(p=>({...p,longitude:s.target.value})),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Possession Date *"}),e.jsx("input",{type:"date",value:ke,onChange:s=>bt(s.target.value),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-mono"}),tt&&!ke&&e.jsxs("p",{className:"text-[8px] text-slate-400 mt-1",children:["On file: ",ml(tt)||tt]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Size Range *"}),e.jsx("input",{type:"text",placeholder:`e.g. 1200-2400 ${H.unit}`,value:Te,onChange:s=>ks(s.target.value),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-mono"})]})]}),e.jsx("p",{className:"text-[8px] text-slate-400 -mt-2",children:"* Possession Date and Size Range are two of the six checks that must pass before this listing can be submitted for review."}),e.jsxs("div",{className:"border-t border-slate-100 pt-4 space-y-3",children:[e.jsx("h4",{className:"text-[10px] font-mono font-extrabold text-slate-700 uppercase text-left",children:"Documents & Walkthroughs"}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Walkthrough Video URL (YouTube)"}),e.jsx("input",{type:"text",placeholder:"https://www.youtube.com/watch?v=...",value:i.walkthroughVideoUrl,onChange:s=>O(p=>({...p,walkthroughVideoUrl:s.target.value})),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs"})]}),typeof g=="number"?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Brochure PDF"}),e.jsx("input",{type:"file",accept:".pdf",onChange:s=>lt(s,"brochureUrl"),className:"text-[10px] text-slate-500 file:mr-2 file:py-1 file:px-2.5 file:rounded-lg file:border-0 file:text-[10px] file:bg-slate-100 file:text-slate-700 hover:file:bg-slate-200 cursor-pointer w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Price Sheet PDF"}),e.jsx("input",{type:"file",accept:".pdf",onChange:s=>lt(s,"priceSheetUrl"),className:"text-[10px] text-slate-500 file:mr-2 file:py-1 file:px-2.5 file:rounded-lg file:border-0 file:text-[10px] file:bg-slate-100 file:text-slate-700 hover:file:bg-slate-200 cursor-pointer w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"RERA PDF"}),e.jsx("input",{type:"file",accept:".pdf",onChange:s=>lt(s,"reraApplicationUrl"),className:"text-[10px] text-slate-500 file:mr-2 file:py-1 file:px-2.5 file:rounded-lg file:border-0 file:text-[10px] f
20ile:bg-slate-100 file:text-slate-700 hover:file:bg-slate-200 cursor-pointer w-full"})]})]}):e.jsx("div",{className:"p-3 bg-slate-50 rounded-xl text-[10px] text-slate-500",children:"Save basic details to unlock brochure, price sheet, and RERA file upload buttons."}),typeof g=="number"&&e.jsx("div",{className:"border-t border-slate-100 pt-4",children:e.jsx(nd,{uploadListingAsset:F,assetPathPrefix:`projects/${g}/brochure-crop`,galleryImages:i.galleryImages,floorPlans:i.floorPlans||[],onGalleryImagesChange:s=>O(p=>({...p,galleryImages:s})),onFloorPlansChange:s=>O(p=>({...p,floorPlans:s}))})}),typeof g=="number"&&e.jsx("div",{className:"border-t border-slate-100 pt-4",children:e.jsx(Ui,{projectId:g,user:a,walkthroughVideoUrl:i.walkthroughVideoUrl})}),e.jsxs("div",{className:"border-t border-slate-100 pt-4",children:[e.jsx("h5",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase mb-2 text-left",children:"Configure Contextual Video Clips (legacy)"}),e.jsx("p",{className:"text-[8px] text-amber-600 -mt-1.5 mb-2",children:`Heads up: clips added here save into this project's local media record, which the buyer-facing listing page does not read clips from. Use "Walkthrough Clips from Timestamped Description" above for clips that need to appear on the live listing.`}),e.jsxs("div",{className:"bg-slate-50/50 border border-slate-100 rounded-2xl p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 text-left",children:[e.jsx("input",{type:"text",placeholder:"e.g. Gym, Entrance",value:Sa,onChange:s=>Qa(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]"}),e.jsx("input",{type:"number",placeholder:"Start Sec (e.g. 15)",value:ka,onChange:s=>yt(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),e.jsx("input",{type:"number",placeholder:"End Sec (e.g. 45)",value:Ca,onChange:s=>er(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"})]}),e.jsx("button",{type:"button",onClick:()=>{!Sa||!ka||!Ca||(O(s=>({...s,videoClips:[...s.videoClips,{label:Sa.trim(),url:s.walkthroughVideoUrl,startSec:parseInt(ka,10),endSec:parseInt(Ca,10)}]})),Qa(""),yt(""),er(""))},className:"w-full py-1.5 bg-brand-500 hover:bg-brand-600 text-white text-[10px] font-bold rounded-lg transition-all",children:"+ Add Walkthrough Video Clip Cut"}),i.videoClips.length>0&&e.jsx("div",{className:"space-y-1.5 max-h-[140px] overflow-y-auto pt-1",children:i.videoClips.map((s,p)=>e.jsxs("div",{className:"flex items-center justify-between bg-white border border-slate-100 p-2 rounded-xl text-[10px] font-mono",children:[e.jsxs("span",{children:[s.label," (",s.startSec,"s - ",s.endSec,"s)"]}),e.jsx("button",{type:"button",onClick:()=>O(P=>({...P,videoClips:P.videoClips.filter((we,fe)=>fe!==p)})),className:"text-rose-500 hover:text-rose-700",children:e.jsx(St,{className:"w-3.5 h-3.5"})})]},p))})]})]})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-4 space-y-3",children:[e.jsx("h4",{className:"text-[10px] font-mono font-extrabold text-slate-700 uppercase text-left",children:"Additional Project Details"}),e.jsx("p",{className:"text-[8px] text-slate-400 -mt-2",children:"Optional â fill in what you have. Everything here matches what an auto-extracted RERA listing shows."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Developer / Promoter Name"}),e.jsx("input",{type:"text",value:ge,onChange:s=>qt(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Price Range"}),e.jsx("input",{type:"text",placeholder:"e.g. â¹85 L - â¹1.2 Cr",value:ls,onChange:s=>_s(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:["Total ",B.unitNounPlural]}),e.jsx("input",{type:"number",min:0,value:Vt,onChange:s=>zt(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Open Space (%)"}),e.jsx("input",{type:"number",min:0,max:100,value:os,onChange:s=>Cs(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Construction Progress (%)"}),e.jsx("input",{type:"number",min:0,max:100,value:is,onChange:s=>Ht(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Commencement Date"}
20),e.jsx("input",{type:"date",value:Pt,onChange:s=>It(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"}),it&&!Pt&&e.jsxs("p",{className:"text-[8px] text-slate-400 mt-1",children:["On file: ",ml(it)||it]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Amenities"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{type:"text",placeholder:"e.g. Clubhouse",value:Tt,onChange:s=>ns(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),Tt.trim()&&(_t(p=>[...p,Tt.trim()]),ns("")))},className:"flex-1 px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{Tt.trim()&&(_t(s=>[...s,Tt.trim()]),ns(""))},className:"px-3 py-1.5 bg-brand-50 hover:bg-brand-100 text-brand-700 text-[10px] font-bold rounded-lg",children:"+ Add"})]}),Ft.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ft.map((s,p)=>e.jsxs("span",{className:"flex items-center gap-1 bg-white border border-slate-200 px-2 py-1 rounded-lg text-[10px]",children:[s,e.jsx("button",{type:"button",onClick:()=>_t(P=>P.filter((we,fe)=>fe!==p)),className:"text-rose-500 hover:text-rose-700",children:e.jsx(ot,{className:"w-3 h-3"})})]},p))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Specifications"}),typeof g!="number"?e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"Save this listing below to add specifications."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 mb-2",children:[e.jsx("input",{type:"text",placeholder:"Category, e.g. Flooring",value:Ps,onChange:s=>Vs(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"}),e.jsx("input",{type:"text",placeholder:"e.g. Vitrified tiles in living/dining",value:ds,onChange:s=>da(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),st())},className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"}),e.jsx("button",{type:"button",onClick:st,className:"px-3 py-1.5 bg-brand-50 hover:bg-brand-100 text-brand-700 text-[10px] font-bold rounded-lg",children:"+ Add"})]}),Gt&&e.jsx("p",{className:"text-[9px] text-rose-600 mb-1.5",children:Gt}),ia?e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"Loadingâ¦"}):Rt.length>0?e.jsx("div",{className:"space-y-2",children:Rt.map(s=>e.jsxs("div",{className:"bg-white border border-slate-100 rounded-lg p-2",children:[e.jsx("p",{className:"text-[9px] font-bold text-slate-600 uppercase mb-1",children:s.category}),e.jsx("ul",{className:"space-y-1",children:s.items.map((p,P)=>e.jsxs("li",{className:"flex items-center justify-between text-[10px]",children:[e.jsx("span",{children:p}),e.jsx("button",{type:"button",onClick:()=>$a(s,P),className:"text-rose-500 hover:text-rose-700",children:e.jsx(St,{className:"w-3.5 h-3.5"})})]},P))})]},s.id))}):e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"No specifications entered yet."})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Approvals & Clearances"}),typeof g!="number"?e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"Save this listing below to add approvals."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 mb-2",children:[e.jsx("input",{type:"text",placeholder:"e.g. Environmental Clearance",value:Z,onChange:s=>ee(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"}),e.jsxs("select",{value:Ee,onChange:s=>ze(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]",children:[e.jsx("option",{value:"uploaded",children:"Uploaded"}),e.jsx("option",{value:"not_uploaded",children:"Not uploaded"}),e.jsx("option",{value:"after_shortfall",children:"After shortfall"})]}),e.jsx("button",{type:"button",onClick:Zt,className:"px-3 py-1.5 bg-brand-50 hover:bg-brand-100 text-brand-700 text-[10px] font-bold rounded-lg",children:"+ Add"})]}),Yt&&e.jsx("p",{className:"text-[9px] text-rose-600 mb-1.5",children:Yt}),xa?e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"Loadingâ¦"}):cs.length>0?e.jsx("ul",{className:"space-y-1",children:cs.map(s=>e.jsxs("li",{className:"flex items-center justify-between bg-white border border-slate-100 px-2.5 py-1.5 rounded-lg text-[10px]",children:[e.jsxs("span",{children:[s.docName," â ",e.jsx("span",{className:"uppercase font-bold",children:s.status.replace(/_/g," ")}),s.verified&&e.jsx("span",{className:"ml-1.5 text-emerald-600 font-bold",children:"· Verified"})]}),e.jsx("button",{type:"button",onClick:()=>Xr(s.id),className:"text-rose-500 hover:text-rose-700",children:e.jsx(St,{className:"w-3.5 h-3.5"})})]},s.id))}):e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"No approvals recorded yet."}),e.jsx("p",{className:"text-[8px] text-slate-400 mt-1.5",children:"âVerifiedâ is set by a Realtified admin after review â not editable here."})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Construction Milestones"}),typeof g!="number"?e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"Save this listing below to record progress."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mb-2",children:[e.jsx("select",{value:pa,onChange:s=>Hs(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]",children:Array.from({length:10},(s,p)=>p+1).map(s=>e.jsxs("option",{value:s,children:["Task ",s]},s))}),e.jsx("input",{type:"text",placeholder:"e.g. Foundation Complete",value:Er,onChange:s=>Fr(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"}),e.jsx("input",{type:"number",min:0,max:100,placeholder:"% complete",value:dt,onChange:s=>Wa(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"}),e.jsxs("select",{value:Ka,onChange:s=>Sl(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]",children:[e.jsx("option",{value:"not_started",children:"Not started"}),e.jsx("option",{value:"in_progress",children:"In progress"}),e.jsx("option",{value:"completed",children:"Completed"})]})]}),e.jsx("button",{type:"button",onClick:Zr,className:"px-3 py-1.5 bg-brand-50 hover:bg-brand-100 text-brand-700 text-[10px] font-bold rounded-lg mb-2",children:"+ Record reading"}),xs&&e.jsx("p",{className:"text-[9px] text-rose-600 mb-1.5",children:xs}),At?e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"Loadingâ¦"}):Ye.length>0?e.jsx("ul",{className:"space-y-1",children:Ye.map(s=>e.jsxs("li",{className:"flex items-center justify-between bg-white border border-slate-100 px-2.5 py-1.5 rounded-lg text-[10px]",children:[e.jsxs("span",{children:["Task ",s.taskNo," · ",s.label,s.pct!=null?` â ${s.pct}%`:""," ",e.jsx("span",{className:"uppercase font-bold text-slate-500",children:s.status.replace(/_/g," ")})]}),e.jsx("button",{type:"button",onClick:()=>mr(s.id),className:"text-rose-500 hover:text-rose-700",children:e.jsx(St,{className:"w-3.5 h-3.5"})})]},s.id))}):e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"No progress readings recorded yet."})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Land Owners"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 mb-2",children:[e.jsx("input",{type:"text",placeholder:"Owner name",value:gt,onCh
20ange:s=>ua(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"}),e.jsx("input",{type:"text",placeholder:"e.g. Joint Development Agreement",value:Tr,onChange:s=>W(s.target.value),className:"px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{gt.trim()&&(ma(s=>[...s,{name:gt.trim(),agreementType:Tr.trim()}]),ua(""),W(""))},className:"px-3 py-1.5 bg-brand-50 hover:bg-brand-100 text-brand-700 text-[10px] font-bold rounded-lg",children:"+ Add"})]}),Rs.length>0&&e.jsx("ul",{className:"space-y-1",children:Rs.map((s,p)=>e.jsxs("li",{className:"flex items-center justify-between bg-white border border-slate-100 px-2.5 py-1.5 rounded-lg text-[10px]",children:[e.jsxs("span",{children:[s.name,s.agreementType?` â ${s.agreementType}`:""]}),e.jsx("button",{type:"button",onClick:()=>ma(P=>P.filter((we,fe)=>fe!==p)),className:"text-rose-500 hover:text-rose-700",children:e.jsx(St,{className:"w-3.5 h-3.5"})})]},p))})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-3",children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Land & Legal"}),typeof g!="number"?e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"Save this listing below to add land details."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"Survey Numbers"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{type:"text",placeholder:"e.g. 240/P",value:ha,onChange:s=>ba(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),Qr())},className:"flex-1 px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"}),e.jsx("button",{type:"button",onClick:Qr,className:"px-3 py-1.5 bg-brand-50 hover:bg-brand-100 text-brand-700 text-[10px] font-bold rounded-lg",children:"+ Add"})]}),Ks.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:Ks.map((s,p)=>e.jsxs("span",{className:"flex items-center gap-1 bg-white border border-slate-200 px-2 py-1 rounded-lg text-[10px] font-mono",children:[s,e.jsx("button",{type:"button",onClick:()=>Ls(P=>P.filter((we,fe)=>fe!==p)),className:"text-rose-500 hover:text-rose-700",children:e.jsx(ot,{className:"w-3 h-3"})})]},p))})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"Total Extent â sq. metres (not acres)"}),e.jsx("input",{type:"number",min:0,step:"any",placeholder:"e.g. 20234",value:ga,onChange:s=>fa(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"Net Extent â sq. metres (not acres)"}),e.jsx("input",{type:"number",min:0,step:"any",placeholder:"e.g. 18500",value:ja,onChange:s=>Gs(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"Deductions (sqm)"}),e.jsx("input",{type:"number",min:0,step:"any",placeholder:"road widening / FTL / nala",value:ya,onChange:s=>Ur(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"North boundary"}),e.jsx("input",{type:"text",value:Ya,onChange:s=>Ys(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"South boundary"}),e.jsx("input",{type:"text",value:Na,onChange:s=>Me(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"East boundary"}
20),e.jsx("input",{type:"text",value:ft,onChange:s=>Xa(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"West boundary"}),e.jsx("input",{type:"text",value:Xt,onChange:s=>Za(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"Land Use"}),e.jsx("input",{type:"text",placeholder:"e.g. Residential",value:va,onChange:s=>$r(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"Sanctioning Authority"}),e.jsx("input",{type:"text",placeholder:"e.g. HMDA, DTCP, GHMC",value:jt,onChange:s=>$t(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-1",children:"Plan Approval No."}),e.jsx("input",{type:"text",value:Ja,onChange:s=>wa(s.target.value),className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-[11px] font-mono"})]})]}),Ga&&e.jsx("p",{className:"text-[9px] text-rose-600 mb-1.5",children:Ga}),e.jsx("button",{type:"button",onClick:el,disabled:Dr,className:"px-3 py-1.5 bg-brand-50 hover:bg-brand-100 text-brand-700 text-[10px] font-bold rounded-lg disabled:opacity-60",children:Dr?"Savingâ¦":De?"Update Land & Legal Details":"Save Land & Legal Details"}),As&&e.jsx("p",{className:"text-[9px] text-slate-400 italic mt-1.5",children:"Loadingâ¦"})]})]})]})]}),K===2&&e.jsxs("div",{className:"space-y-5 text-left animate-fadeIn",children:[B.hasFloorRise&&e.jsxs("div",{className:"border border-slate-100 p-4 rounded-2xl bg-slate-50/50",children:[e.jsx("h4",{className:"text-[10px] font-mono font-extrabold text-slate-700 uppercase mb-2",children:"1. Threshold Floor-Rise Charge"}),e.jsx("p",{className:"text-[9px] text-slate-400 mb-3",children:"Allocated incrementally above a floor limit. e.g., starting at the 5th floor, â¹20/sft per floor rise."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Start Floor"}),e.jsx("input",{type:"number",placeholder:"e.g. 5",value:i.floorRiseStartFloor,onChange:s=>{R(!0),O(p=>({...p,floorRiseStartFloor:s.target.value}))},className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-xs"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block mb-1",children:"Rate per Floor (â¹ / Sft)"}),e.jsx("input",{type:"number",placeholder:"e.g. 20",value:i.floorRiseRatePerSft,onChange:s=>{R(!0),O(p=>({...p,floorRiseRatePerSft:s.target.value}))},className:"w-full px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-xs"})]})]})]}),e.jsxs("div",{className:"border border-slate-100 p-4 rounded-2xl bg-slate-50/50",children:[e.jsx("h4",{className:"text-[10px] font-mono font-extrabold text-slate-700 uppercase mb-2",children:"2. Stacking Premiums (Facing / Corner / View)"}),e.jsx("p",{className:"text-[9px] text-slate-400 mb-3",children:"Add stacked condition-gated premiums (e.g. East Facing + Corner unit premiums, which apply additively)."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 mb-3 text-left",children:[e.jsxs("select",{value:Pa,onChange:s=>Mr(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-sans",children:[e.jsx("option",{value:"facing",children:"Facing Premium"}),e.jsx("option",{value:"corner",children:"Corner Premium"}),e.jsx("option",{value:"view",children:"View Premium"})]}),e.jsx("input",{type:"text",placeholder:"Value (e.g. East, Lake View)",value:tr,onChange:s=>Xs(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]"}),e.jsx("input",{type:"number",placeholder:"â¹ Rate / Sft (e.g. 100)",value:ms,onChange:s=>sr(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]"})]}),e.jsx("button",{type:"button",onClick:()=>{ms&&(R(!0),O(s=>({...s,premiums:[...s.premiums,{type:Pa,value:Pa==="corner"?"Corner":tr.trim(),ratePerSft:parseFloat(ms)}]})),Xs(""),sr(""))},className:"w-full py-1.5 bg-brand-50 hover:bg-brand-100 text-brand-700 text-[10px] font-bold rounded-lg transition-all",children:"+ Add Stacking Premium Rate"}),i.premiums.length>0&&e.jsx("div",{className:"space-y-1.5 max-h-[140px] overflow-y-auto pt-3",children:i.premiums.map((s,p)=>e.jsxs("div",{className:"flex items-center justify-between bg-white border border-slate-100 p-2 rounded-xl text-[10px] font-mono",children:[e.jsxs("span",{children:[s.type.toUpperCase(),": ",s.value," â â¹",s.ratePerSft,"/sft"]}),e.jsx("button",{type:"button",onClick:()=>{R(!0),O(P=>({...P,premiums:P.premiums.filter((we,fe)=>fe!==p)}))},"aria-label":"Remove premium",className:"text-rose-500 hover:text-rose-700",children:e.jsx(St,{className:"w-3.5 h-3.5"})})]},p))})]}),e.jsxs("div",{className:"border border-slate-100 p-4 rounded-2xl bg-slate-50/50",children:[e.jsx("h4",{className:"text-[10px] font-mono font-extrabold text-slate-700 uppercase mb-2",children:"3. Size-driven Parking Tiers"}),e.jsx("p",{className:"text-[9px] text-slate-400 mb-3",children:"Allocate parking slots and flat rates based on unit size thresholds (e.g. units >= 1420sft get 1 slot at â¹4L)."}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-3 text-left",children:[e.jsx("input",{type:"number",placeholder:"Min Size Sft (e.g. 1420)",value:Ra,onChange:s=>ar(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]"}),e.jsx("input",{type:"number",placeholder:"Slots (e.g. 2)",value:Aa,onChange:s=>La(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]"}),e.jsx("input",{type:"number",placeholder:"â¹ Cost (e.g. 500000)",value:us,onChange:s=>rr(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]"})]}),e.jsx("button",{type:"button",onClick:()=>
20{!Ra||!Aa||!us||(R(!0),O(s=>({...s,parkingRules:[...s.parkingRules,{minSizeSqFt:parseInt(Ra,10),slots:parseInt(Aa,10),chargeFlat:parseFloat(us)}]})),ar(""),La(""),rr(""))},className:"w-full py-1.5 bg-brand-50 hover:bg-brand-100 text-brand-700 text-[10px] font-bold rounded-lg transition-all",children:"+ Add Size-driven Parking Allocation"}),i.parkingRules.length>0&&e.jsx("div",{className:"space-y-1.5 max-h-[140px] overflow-y-auto pt-3",children:i.parkingRules.map((s,p)=>e.jsxs("div",{className:"flex items-center justify-between bg-white border border-slate-100 p-2 rounded-xl text-[10px] font-mono",children:[e.jsxs("span",{children:["Unit size >= ",s.minSizeSqFt,"sft â ",s.slots," slots at â¹",s.chargeFlat.toLocaleString()]}),e.jsx("button",{type:"button",onClick:()=>{R(!0),O(P=>({...P,parkingRules:P.parkingRules.filter((we,fe)=>fe!==p)}))},"aria-label":"Remove parking rule",className:"text-rose-500 hover:text-rose-700",children:e.jsx(St,{className:"w-3.5 h-3.5"})})]},p))})]})]}),K===3&&e.jsxs("div",{className:"space-y-6 text-left animate-fadeIn",children:[B.hasTowers&&e.jsxs("div",{className:"border border-slate-100 p-4 rounded-2xl bg-slate-50/50",children:[e.jsx("h4",{className:"text-[10px] font-mono font-extrabold text-slate-700 uppercase mb-2",children:"Claimed Towers / Blocks"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsx("input",{type:"text",placeholder:"Tower / Block Name (e.g. Tower A)",value:J,onChange:s=>me(s.target.value),className:"flex-2 px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-xs"}),e.jsx("input",{type:"number",placeholder:"Total Floors",value:Q,onChange:s=>Ie(s.target.value),className:"flex-1 px-2.5 py-1.5 bg-white border border-slate-200 rounded-lg text-xs font-mono"}),e.jsx("button",{type:"button",onClick:kl,className:"px-4 py-1.5 bg-brand-500 text-white hover:bg-brand-600 text-xs font-bold rounded-lg cursor-pointer",children:"Add"})]}),x.length>0?e.jsx("div",{className:"flex flex-wrap gap-2 pt-1 max-h-[140px] overflow-y-auto",children:x.map((s,p)=>e.jsxs("div",{className:"flex items-center gap-2 bg-white border border-slate-100 px-3 py-1.5 rounded-xl text-[10px] font-mono shadow-2xs",children:[e.jsxs("span",{children:[s.name," (",s.totalFloors," Floors)"]}),e.jsx("button",{type:"button",onClick:()=>tl(s.id),className:"text-rose-500 hover:text-rose-700 cursor-pointer",children:e.jsx(ot,{className:"w-3.5 h-3.5"})})]},p))}):e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No towers added yet."})]}),e.jsxs("div",{className:"border border-brand-200 p-4 rounded-2xl bg-brand-50/30",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("h4",{className:"text-[10px] font-mono font-extrabold text-slate-700 uppercase",children:[B.configurationNoun,"s"]}),e.jsx("span",{className:"text-[8px] font-mono font-bold text-brand-600 bg-white px-2 py-0.5 rounded-md border border-brand-200",children:"unit_plans â home types, not physical instances"})]}),e.jsxs("p",{className:"text-[9px] text-slate-500 mb-3",children:[B.kind==="plot"?'A plot type this layout sells (e.g. "200 sq yd corner plot"). Add one row per distinct size/type.':`A home type this project sells (e.g. "3 BHK, 1,800 sqft, East facing"). Add one row per distinct ${B.unitNoun.toLowerCase()} type â not one row per physical ${B.unitNoun.toLowerCase()}.`," ","At least one needs a ",H.label.toLowerCase()," before this listing can be submitted."]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mb-3",children:[e.jsx("input",{type:"text",placeholder:B.kind==="plot"?"Code (e.g. Plot-200)":"Code (e.g. 3BHK-E-1800)",value:o,onChange:s=>L(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]"}),B.hasBhk&&e.jsx("input",{type:"number",step:"0.5",min:"0.5",placeholder:"BHK (e.g. 2.5)",value:je,onChange:s=>pe(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),e.jsx("input",{type:"number",min:"1",placeholder:`${H.label} (${H.unit}) *`,value:he,onChange:s=>xt(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),B.areaFields.some(s=>s.key==="carpetArea")&&e.jsx("input",{type:"number",min:"1",placeholder:"Carpet Area (sqft)",value:as,onChange:s=>Ms(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),z&&e.jsx("input",{type:"number",min:"1",placeholder:`${z.label} (${z.unit})`,value:ws,onChange:s=>Ha(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),B.primaryAreaKey!=="builtUpArea"&&B.kind!=="plot"&&e.jsx("input",{type:"number",min:"1",placeholder:"Built-up Area (sqft, optional)",value:vs,onChange:s=>la(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),e.jsxs("select",{value:rs,onChange:s=>Bs(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]",children:[e.jsx("option",{value:"",children:"Facing (optional)"}),e.jsx("option",{value:"E",children:"East"}),e.jsx("option",{value:"W",children:"West"}),e.jsx("option",{value:"N",children:"North"}),e.jsx("option",{value:"S",children:"South"})]})]}),e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("button",{type:"button",onClick:Qe,disabled:Ss,className:"px-4 py-1.5 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-lg transition-all cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:[Ss?e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"}):null,"Add ",B.configurationNoun]})}),kt&&e.jsxs("div",{className:"mb-3 p-2.5 bg-rose-50 border border-rose-200 rounded-xl text-[10px] text-rose-700 flex items-center gap-2",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 shrink-0"}),kt]}),se.length>0?e.jsx("div",{className:"border border-slate-200 rounded-xl overflow-hidden max-h-[200px] overflow-y-auto bg-white",children:e.jsxs("table",{className:"w-full border-collapse text-left text-[9px] font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 border-b border-slate-200 text-slate-500 uppercase font-extrabold text-[8px]",children:[e.jsx("th",{className:"p-2",children:"Code"}),B.hasBhk&&e.jsx("th",{className:"p-2",children:"BHK"}),e.jsx("th",{className:"p-2",children:H.label}),e.jsx("th",{className:"p-2",children:"Facing"}),e.jsx("th",{className:"p-2",children:"Source"}),e.jsx("th",{className:"p-2"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 text-slate-700",children:se.map(s=>e.jsxs("tr",{className:"hover:bg-slate-50",children:[e.jsx("td",{className:"p-2 font-bold",children:s.code}),B.hasBhk&&e.jsx("td",{className:"p-2",children:s.bhk??"â"}),e.jsx("td",{className:"p-2",children:s.saleableSqft!=null?`${s.saleableSqft} ${H.unit}`:"â"}),e.jsx("td",{className:"p-2",children:s.facing||"â"}),e.jsx("td",{className:"p-2 text-slate-400",children:s.source}),e.jsx("td",{className:"p-2 text-right",children:e.jsx("button",{type:"button",onClick:()=>Ke(s.id),className:"text-rose-500 hover:text-rose-700 cursor-pointer",children:e.jsx(St,{className:"w-3.5 h-3.5"})})})]},s.id))})]})}):e.jsxs("p",{className:"text-[10px] text-rose-500 italic",children:["No ",B.configurationNoun.toLowerCase(),"s added yet â this listing cannot be submitted until at least one has a ",H.label.toLowerCase(),"."]})]}),e.jsxs("div",{className:"border border-slate-100 p-4 rounded-2xl bg-slate-50/50",children:[e.jsx("h4",{className:"text-[10px] font-mono font-extrabold text-slate-700 uppercase mb-2",children:"Inventory Units Mapping"}),e.jsxs("p",{className:"text-[8px] text-slate-400 -mt-1.5 mb-2",children:["One physical ",B.unitNoun.toLowerCase()," instance (e.g. a real unit number and floor) â different from the ",B.configurationNoun.toLowerCase()," types above."]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mb-3 text-left",children:[e.jsx("input",{type:"text",placeholder:"Unit Number",value:Ae,onChange:s=>Ce(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]"}),e.jsx("input",{type:"number",placeholder:"Floor",value:Le,onChange:s=>Je(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),e.jsxs("select",{value:$e,onChange:s=>ve(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]",children:[e.jsx("option",{value:"1",children:"1 BHK"}),e.jsx("option",{value:"2",children:"2 BHK"}),e.jsx("option",{value:"3",children:"3 BHK"}),e.jsx("option",{value:"4",children:"4 BHK"})]}),e.jsx("input",{type:"number",placeholder:"Saleable Area Sft",value:qe,onChange:s=>Pe(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),e.jsx("input",{type:"number",placeholder:"Carpet Area Sft",value:Ve,onChange:s=>et(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),e.jsx("input",{type:"number",placeholder:"UDS Area Sft",value:Fe,onCh
20ange:s=>$(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px] font-mono"}),e.jsxs("select",{value:le,onChange:s=>ne(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]",children:[e.jsx("option",{value:"East",children:"East Facing"}),e.jsx("option",{value:"West",children:"West Facing"}),e.jsx("option",{value:"North",children:"North Facing"}),e.jsx("option",{value:"South",children:"South Facing"})]}),e.jsx("input",{type:"text",placeholder:"Plan Variant",value:Y,onChange:s=>h(s.target.value),className:"px-2 py-1.5 bg-white border border-slate-200 rounded-lg text-[10px]"})]}),e.jsxs("div",{className:"flex items-center gap-4 mb-3 text-left",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-slate-600 font-bold cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:N,onChange:s=>ue(s.target.checked),className:"rounded text-brand-500 focus:ring-brand-500"}),"Corner Unit"]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-slate-600 font-bold cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:s=>C(s.target.checked),className:"rounded text-brand-500 focus:ring-brand-500"}),"View Premium Unit"]}),e.jsx("button",{type:"button",onClick:Be,className:"ml-auto px-4 py-1.5 bg-slate-800 text-white hover:bg-slate-900 text-xs font-bold rounded-lg transition-all cursor-pointer",children:"Add Unit"})]}),q.length>0?e.jsx("div",{className:"border border-slate-200 rounded-xl overflow-hidden max-h-[220px] overflow-y-auto bg-white",children:e.jsxs("table",{className:"w-full border-collapse text-left text-[9px] font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 border-b border-slate-200 text-slate-500 uppercase font-extrabold text-[8px]",children:[e.jsx("th",{className:"p-2",children:"Unit"}),e.jsx("th",{className:"p-2",children:"BHK / Size"}),e.jsx("th",{className:"p-2",children:"Carpet / UDS"}),e.jsx("th",{className:"p-2",children:"Facing / Premiums"}),e.jsx("th",{className:"p-2",children:"Status"}),e.jsx("th",{className:"p-2"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 text-slate-700",children:q.map((s,p)=>e.jsxs("tr",{className:"hover:bg-slate-50",children:[e.jsxs("td",{className:"p-2 font-bold",children:[s.unitNumber," (F",s.floor,")"]}),e.jsxs("td",{className:"p-2",children:[s.bhk," BHK â ",s.sizeSqFt,"sft"]}),e.jsxs("td",{className:"p-2",children:[s.carpetArea||s.sizeSqFt,"sft / ",s.udsArea||"â","sft"]}),e.jsxs("td",{className:"p-2 text-slate-500",children:[s.facing," ",s.isCorner?"[Corner]":""," ",s.hasViewPremium?"[View]":""]}),e.jsx("td",{className:"p-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded-full text-[8px] font-bold ${s.status==="Available"?"bg-emerald-50 text-emerald-700":s.status==="Blocked"?"bg-amber-50 text-amber-700":"bg-slate-100 text-slate-500"}`,children:s.status})}),e.jsx("td",{className:"p-2 text-right",children:e.jsx("button",{type:"button",onClick:async()=>{try{await fetch(`/api/inventory/${s.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${await a.getIdToken()}`}}),Qs(g)}catch(P){console.error(P)}},className:"text-rose-500 hover:text-rose-700 cursor-pointer",children:e.jsx(St,{className:"w-3.5 h-3.5"})})})]},p))})]})}):e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No units mapped yet."})]})]}),G&&e.jsxs("div",{className:"p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700 font-semibold flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"}),G]}),e.jsxs("div",{className:"flex items-center gap-3 border-t border-slate-100 pt-4",children:[K>1&&e.jsxs("button",{type:"button",onClick:()=>v(s=>s-1),className:"px-4 py-2.5 border border-slate-200 hover:bg-slate-50 text-slate-600 text-xs font-bold rounded-xl transition-all cursor-pointer flex items-center gap-1",children:[e.jsx(Bn,{className:"w-4 h-4"})," Back"]}),K<3?e.jsxs("button",{type:"button",onClick:()=>{if(K===1&&typeof g!="number"){re("Please save the project details in Step 1 first.");return}v(s=>s+1)},className:"ml-auto px-4 py-2.5 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-xl transition-all cursor-pointer flex items-center gap-1",children:["Next ",e.jsx(Va,{className:"w-4 h-4"})]}):e.jsx("button",{type:"submit",disabled:U,className:"ml-auto py-2.5 px-6 bg-brand-500 hover:bg-brand-600 text-white text-xs font-bold rounded-xl transition-all cursor-pointer disabled:opacity-50 flex items-center justify-center gap-1.5",children:U?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Savingâ¦"]}):g==="new"?"Create Listing":"Save & Exit"})]})]})]}),e.jsxs("div",{className:"lg:col-span-5 sticky top-6 bg-slate-50 border border-slate-200 rounded-3xl p-4 shadow-sm h-[780px] flex flex-col overflow-hidden relative text-left",children:[e.jsx("div",{className:"absolute inset-0 bg-repeat opacity-[0.03] pointer-events-none",style:{backgroundImage:"url('/blueprint_background.png')",backgroundSize:"600px 600px"}}),e.jsxs("div",{className:"bg-slate-900 text-white p-4 rounded-2xl relative overflow-hidden shadow-sm shrink-0",children:[e.jsx("div",{className:"absolute top-2 right-2 bg-brand-500/80 backdrop-blur-xs text-[8px] font-mono font-bold text-white px-2 py-0.5 rounded-full z-20",children:"LIVE PREVIEW MOCKUP"}),e.jsxs("span",{className:"text-[8px] font-mono tracking-widest text-brand-300 font-extrabold uppercase",children:[i.region.toUpperCase()," HYDERABAD"]}),e.jsx("h4",{className:"text-sm font-extrabold font-display leading-tight mt-1 truncate",children:i.name||"Untitled Project"}),e.jsx("p",{className:"text-[10px] text-slate-300 mt-0.5 truncate",children:i.location||"Location details"}),e.jsxs("div",{className:"mt-3 flex items-center justify-between border-t border-slate-800 pt-2.5",children:[e.jsx("span",{className:"text-[9px] text-slate-400 font-mono",children:"BASE RATE"}),e.jsxs("span",{className:"text-xs font-extrabold text-brand-400 font-mono",children:["â¹",parseFloat(i.basePricePerSqFt||"0").toLocaleStr
20ing(),"/sft"]})]})]}),e.jsx("div",{className:"flex border-b border-slate-200 mt-4 shrink-0 text-[10px] font-bold relative z-10",children:["overview","pricing","tour","locality","legal"].map(s=>e.jsx("button",{type:"button",onClick:()=>V(s),className:`flex-1 pb-2 border-b-2 text-center transition-all capitalize ${te===s?"border-brand-500 text-slate-900 font-extrabold":"border-transparent text-slate-400 font-medium"}`,children:s},s))}),e.jsxs("div",{className:"flex-1 overflow-y-auto pt-3 space-y-4 text-xs font-sans text-slate-600 relative z-10",children:[te==="overview"&&e.jsxs("div",{className:"space-y-3 text-left",children:[e.jsxs("div",{className:"bg-white border border-slate-200/50 p-3.5 rounded-2xl shadow-2xs space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-900",children:"TS-RERA REGISTRATION"}),e.jsx("span",{className:`ml-auto text-[9px] font-mono px-2 py-0.5 rounded-md font-bold ${i.reraNumber&&hs==="approved"?"text-emerald-600 bg-emerald-50":"text-amber-600 bg-amber-50"}`,children:i.reraNumber?hs==="approved"?"VERIFIED":"Entered â not yet verified":"PENDING"})]}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 leading-relaxed bg-slate-50 p-2 rounded-xl",children:["RERA ID: ",i.reraNumber||"Not provided"," ",e.jsx("br",{}),"Project Status: ",i.status," ",e.jsx("br",{}),"Coordinates: ",i.latitude||"â",", ",i.longitude||"â"," ",e.jsx("br",{}),"Property Type: ",w||"â"," ",e.jsx("br",{}),"Possession: ",ke&&ml(ke)||tt&&ml(tt)||"â"," ",e.jsx("br",{}),"Size Range: ",Te||"â"]})]}),e.jsxs("div",{className:"bg-white border border-slate-200/50 p-3.5 rounded-2xl shadow-2xs space-y-1.5",children:[e.jsxs("span",{className:"text-[10px] font-bold text-slate-900 uppercase",children:[B.configurationNoun,"s"]}),se.length>0?e.jsx("ul",{className:"space-y-1",children:se.map(s=>e.jsxs("li",{className:"text-[10px] font-mono text-slate-600 bg-slate-50 px-2 py-1.5 rounded-lg flex justify-between",children:[e.jsxs("span",{children:[s.code,B.hasBhk&&s.bhk?` â ${s.bhk} BHK`:""]}),e.jsx("span",{children:s.saleableSqft!=null?`${s.saleableSqft} ${H.unit}`:"â"})]},s.id))}):e.jsxs("p",{className:"text-[10px] text-slate-400 italic",children:["No ",B.configurationNoun.toLowerCase(),"s added yet."]})]}),e.jsxs("div",{className:"bg-white border border-slate-200/50 p-3.5 rounded-2xl shadow-2xs space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-900 uppercase",children:"Project Specifications"}),Rt.length>0?e.jsx("ul",{className:"list-disc pl-4 space-y-1 text-[10px] text-slate-500",children:Rt.flatMap(s=>s.items.map((p,P)=>e.jsxs("li",{children:[s.category,": ",p]},`${s.id}-${P}`)))}):e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No specifications entered yet."})]}),Ft.length>0&&e.jsxs("div",{className:"bg-white border border-slate-200/50 p-3.5 rounded-2xl shadow-2xs space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-900 uppercase",children:"Amenities"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ft.map((s,p)=>e.jsx("span",{className:"text-[9px] font-mono bg-slate-50 px-2 py-1 rounded-lg text-slate-600",children:s},p))})]})]}),te==="pricing"&&e.jsx("div",{className:"space-y-4 text-left",children:e.jsxs("div",{className:"bg-white border border-slate-200/50 p-3.5 rounded-2xl shadow-2xs space-y-3",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-900 uppercase",children:"Live Cost Calculator"}),e.jsx("p",{className:"text-[9px] text-slate-400",children:"Base rate plus the rules you set in Step 2. Charges and taxes come from your price sheet and are not included."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[10px]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-0.5",children:"Floor Number"}),e.jsx("input",{type:"number",value:Es,onChange:s=>Br(s.target.value),className:"w-full px-2 py-1 bg-slate-50 border border-slate-200 rounded-lg font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-0.5",children:"Unit Facing"}),e.jsxs("select",{value:Ea,onChange:s=>lr(s.target.value),className:"w-full px-2 py-1 bg-slate-50 border border-slate-200 rounded-lg",children:[e.jsx("option",{value:"East",children:"East"}),e.jsx("option",{value:"West",children:"West"}),e.jsx("option",{value:"North",children:"North"}),e.jsx("option",{value:"South",children:"South"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] text-slate-400 block mb-0.5",children:"Saleable Size (Sft)"}),e.jsx("input",{type:"number",value:Ta,onChange:s=>Vr(s.target.value),className:"w-full px-2 py-1 bg-slate-50 border border-slate-200 rounded-lg font-mono"})]}),e.jsxs("div",{className:"flex flex-col justify-end pb-1 space-y-1",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[8px] text-slate-600 font-bold cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:Or,onChange:s=>_r(s.target.checked),className:"rounded text-brand-500 focus:ring-brand-500"}),"Corner Unit"]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[8px] text-slate-600 font-bold cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:Fa,onChange:s=>qr(s.target.checked),className:"rounded text-brand-500 focus:ring-brand-500"}),"View Premium"]})]})]}),Jt?e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-1.5",children:[e.jsx("span",{className:"text-[9px] font-mono font-extrabold text-slate-500 uppercase",children:"Agreement Cost Details"}),e.jsxs("div",{className:"bg-slate-50/50 p-2.5 rounded-xl space-y-1.5 text-[10px] font-mono",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Base Rate Per/Sft:"}
20),e.jsxs("span",{children:["â¹",Jt.baseRatePerSft.toLocaleString(),"/sft"]})]}),e.jsxs("div",{className:"flex justify-between font-bold",children:[e.jsx("span",{children:"Base Consideration:"}),e.jsxs("span",{children:["â¹",Jt.baseConsideration.toLocaleString()]})]}),Jt.lineItems.map((s,p)=>e.jsxs("div",{className:"flex justify-between text-slate-500",children:[e.jsxs("span",{children:[s.label,":"]}),e.jsxs("span",{children:["â¹",s.amount.toLocaleString()]})]},p)),e.jsxs("div",{className:"flex justify-between border-t border-slate-200/80 pt-1.5 text-brand-600 font-bold text-xs",children:[e.jsx("span",{children:"Estimated total (before charges & taxes):"}),e.jsxs("span",{children:["â¹",Jt.grandTotal.toLocaleString()]})]})]})]}):ea?e.jsx("p",{className:"text-[9px] text-rose-500 italic",children:"Invalid inputs for pricing calculation."}):e.jsx("p",{className:"text-[9px] text-slate-500 italic",children:"Base rate: Not set. Enter a base price in Step 1 to preview a cost."})]})}),te==="tour"&&e.jsx("div",{className:"space-y-3 text-left",children:i.walkthroughVideoUrl?e.jsxs("div",{className:"bg-white border border-slate-200/50 p-3.5 rounded-2xl shadow-2xs space-y-3",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-900 uppercase block",children:"Contextual Walkthrough Slices"}),e.jsx("p",{className:"text-[9px] text-slate-400 leading-normal",children:"Clicking a slice seeks the player directly to the timestamp boundary cut."}),e.jsx("div",{className:"aspect-video w-full rounded-xl overflow-hidden border border-slate-200 bg-slate-950 flex items-center justify-center relative",children:Ln(i.walkthroughVideoUrl)?e.jsx("iframe",{src:Ln(i.walkthroughVideoUrl)||"",className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):e.jsx("span",{className:"text-[9px] text-slate-400 font-mono",children:"Invalid Walkthrough Video Link"})}),i.videoClips.length>0?e.jsx("div",{className:"grid grid-cols-2 gap-2 pt-1",children:i.videoClips.map((s,p)=>e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 p-2 bg-slate-50 border border-slate-200 rounded-xl text-[9px] font-bold text-slate-700 hover:bg-slate-100 transition-all text-left",children:[e.jsx(Xl,{className:"w-3 h-3 text-brand-500 shrink-0"}),e.jsxs("div",{className:"truncate",children:[e.jsx("p",{className:"truncate leading-tight font-extrabold",children:s.label}),e.jsxs("p",{className:"text-[8px] text-slate-400 font-mono mt-0.5",children:[s.startSec,"s - ",s.endSec,"s"]})]})]},p))}):e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"No timestamp clip slices defined yet."})]}):e.jsxs("div",{className:"bg-white border border-slate-200/50 p-4 rounded-2xl text-center",children:[e.jsx(On,{className:"w-8 h-8 text-slate-300 mx-auto mb-2"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-medium",children:"Add a YouTube walkthrough video link in Step 1 to test slices."})]})}),te==="locality"&&e.jsx("div",{className:"space-y-3 text-left",children:typeof g!="number"?e.jsx("div",{className:"bg-slate-50 border border-slate-200 p-3.5 rounded-xl text-[10px] text-slate-500 leading-relaxed",children:"Micro-market scores are computed from this project's points of interest once it has been saved and published â not available yet for a new, unsaved listing."}):Da?e.jsx("div",{className:"bg-slate-50 border border-slate-200 p-3.5 rounded-xl text-[10px] text-slate-400",children:"Loading location dataâ¦"}):Wr?e.jsx("div",{className:"bg-red-50 border border-red-200 p-3.5 rounded-xl text-[10px] text-red-600",children:Wr}):(()=>{const s=Ii((Fs??[]).map(p=>({...p,distance:p.distance??void 0})));return!Fs||Fs.length===0?e.jsx("div",{className:"bg-slate-50 border border-slate-200 p-3.5 rounded-xl text-[10px] text-slate-500 leading-relaxed",children:"No points of interest on file yet for this location â scores will appear here once they're added."}):s.length===0?e.jsx("div",{className:"bg-slate-50 border border-slate-200 p-3.5 rounded-xl text-[10px] text-slate-500 leading-relaxed",children:"Points of interest are on file, but none fall into a scorable category yet (transit, schools, healthcare, daily needs, or workplaces)."}):e.jsxs("div",{className:"bg-white border border-slate-200/50 p-3.5 rounded-2xl shadow-2xs space-y-3",children:[e.jsxs("span",{className:"text-[10px] font-bold text-slate-900 uppercase",children:["Micro-market Scoreboard (",i.location||"this location",")"]}),e.jsxs("p",{className:"text-[9px] text-slate-400 leading-relaxed",children:["Computed from ",Fs.length," points of interest on file, by straight-line distance to the nearest in each category."]}),e.jsx("div",{className:"space-y-2 text-[10px]",children:s.map(p=>e.jsxs("div",{className:"flex justify-between items-center border-b border-slate-50 pb-1.5 last:border-b-0 last:pb-0",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-slate-500 font-medium",children:[p.title,": "]}),e.jsx("span",{className:"text-slate-400",children:p.verdict.toLowerCase()})]}),e.jsxs("span",{className:`font-bold ${p.score>=8?"text-emerald-600":p.score>=6?"text-brand-600":"text-amber-600"}`,children:[p.score.toFixed(1)," / 10"]})]}
20,p.id))})]})})()}),te==="legal"&&e.jsx("div",{className:"space-y-3 text-left",children:typeof g!="number"?e.jsx("div",{className:"bg-slate-50 border border-slate-200 p-3.5 rounded-xl text-[10px] text-slate-500 leading-relaxed",children:"The approvals checklist is tracked once this listing is saved â add clearances from Step 1 afterward."}):xa?e.jsx("div",{className:"bg-slate-50 border border-slate-200 p-3.5 rounded-xl text-[10px] text-slate-400",children:"Loading approvalsâ¦"}):Yt?e.jsx("div",{className:"bg-red-50 border border-red-200 p-3.5 rounded-xl text-[10px] text-red-600",children:Yt}):cs.length===0?e.jsx("div",{className:"bg-slate-50 border border-slate-200 p-3.5 rounded-xl text-[10px] text-slate-500 leading-relaxed",children:"No approvals or clearances recorded yet. Add them from Step 1."}):e.jsxs("div",{className:"bg-white border border-slate-200/50 p-3.5 rounded-2xl shadow-2xs space-y-3.5",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-900 uppercase",children:"Approvals & Clearances"}),e.jsx("p",{className:"text-[9px] text-slate-400 leading-relaxed",children:"Builder-entered status; a green check means a Realtified admin has independently verified it."}),e.jsx("div",{className:"space-y-2",children:cs.map(s=>e.jsxs("div",{className:"flex items-start gap-2",children:[s.verified?e.jsx(ts,{className:"w-3.5 h-3.5 text-emerald-500 shrink-0 mt-0.5"}):s.status==="uploaded"||s.status==="after_shortfall"?e.jsx(rn,{className:"w-3.5 h-3.5 text-amber-500 shrink-0 mt-0.5"}):e.jsx("span",{className:"w-3.5 h-3.5 flex items-center justify-center text-slate-300 shrink-0 mt-0.5 text-[10px]",children:"â"}),e.jsxs("div",{className:"text-[10px]",children:[e.jsx("p",{className:"font-extrabold text-slate-800",children:s.docName}),e.jsxs("p",{className:"text-[9px] text-slate-400 mt-0.5 font-mono uppercase",children:[s.status.replace(/_/g," "),s.verified?" · verified":""]})]})]},s.id))})]})})]})]})]})},ql="w-full px-3 py-2 border border-slate-200 rounded-xl text-xs outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500";function Qn({user:a,projectId:l,projectName:j,defaultCompanyName:u,onSent:E,onSettled:y,onClose:F,onNotify:b}){const[K,v]=r.useState((u||"").trim()),[te,V]=r.useState(""),[g,M]=r.useState(""),[i,O]=r.useState({}),[U,ie]=r.useState(null),[I,R]=r.useState(!1),[G,re]=r.useState(null),[x,D]=r.useState(null),q=Zn(te),de=async J=>{J.preventDefault(),ie(null);const me=pd({companyName:K,note:te,evidenceText:g,hasApprovedCompany:!!(u||"").trim()});if(me.ok===!1){O(me.errors);return}O({}),R(!0);try{const Q=await xi(l,me.value,a);re(Q.claimRequest),E==null||E(Q.claimRequest),b==null||b(An)}catch(Q){const Ie=hd(Q);Ie?(D(Ie),y==null||y(Ie.code)):ie(Jn(Q))}finally{R(!1)}};if(G){const J=Kl(G.status);return e.jsxs("div",{className:"p-5 bg-emerald-50 border border-emerald-200 rounded-2xl text-center space-y-2",role:"status",children:[e.jsx(_a,{className:"w-8 h-8 text-emerald-600 mx-auto"}),e.jsx("p",{className:"text-sm font-extrabold text-slate-900",children:An}),e.jsxs("p",{className:"text-xs text-slate-600 max-w-sm mx-auto",children:[e.jsx("span",{className:"font-semibold",children:j}),": ",md]}),e.jsx("span",{className:"inline-block text-xs font-bold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700 border border-amber-200",children:J.label}),e.jsx("div",{children:e.jsx("button",{onClick:F,className:"mt-2 min-h-[40px] sm:min-h-0 px-4 py-2 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 text-xs font-bold rounded-xl cursor-pointer",children:"Done"})})]})}if(x){const J=x.kind==="pending";return e.jsxs("div",{className:`p-5 border rounded-2xl text-center space-y-2 ${J?"bg-amber-50 border-amber-200":"bg-slate-50 border-slate-200"}`,role:"status",children:[e.jsx(ss,{className:`w-8 h-8 mx-auto ${J?"text-amber-600":"text-slate-500"}`}),e.jsx("p",{className:"text-sm font-extrabold text-slate-900",children:j}),e.jsx("p",{className:"text-xs text-slate-600 max-w-sm mx-auto",children:x.message}),J&&e.jsx("span",{className:"inline-block text-xs font-bold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700 border border-amber-200",children:Kl("pending").label}),e.jsx("div",{children:e.jsx("button",{onClick:F,className:"mt-2 min-h-[40px] sm:min-h-0 px-4 py-2 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 text-xs font-bold rounded-xl cursor-pointer",children:"Done"})})]})}return e.jsxs("form",{onSubmit:de,className:"space-y-3",noValidate:!0,children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-extrabold text-slate-900",children:['Claim "',j,'"']}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Tell us how you are connected to this project. Our team checks this before the project is added to your account."})]}),U&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700 font-semibold",role:"alert",children:[e.jsx(ss,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsx("span",{children:U})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:`claim-company-${l}`,className:"block text-xs font-bold text-slate-700 mb-1",children:"Company name"}),e.jsx("input",{id:`claim-company-${l}`,type:"text",value:K,onChange:J=>v(J.target.value),placeholder:"The company you are claiming for",maxLength:200,className:ql}),i.company&&e.jsx("p",{className:"text-xs text-rose-600 mt-1",children:i.company})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:`claim-note-${l}`,className:"block text-xs font-bold text-slate-700 mb-1",children:"How are you connected to this project?"}),e.jsx("textarea",{id:`claim-note-${l}`,value:te,onChange:J=>V(J.target.value),rows:3,maxLength:Nl+200,placeholder:"For example: I am a director of the promoter company, or I handle sales for this project.",className:ql,"aria-describedby":`claim-note-count-${l}`}),e.jsxs("div",{className:"flex items-start justify-between gap-2 mt-1",children:[e.jsx("p",{className:"text-xs text-rose-600",children:i.note||""}),e.jsx("p",{id:`claim-note-count-${l}`,className:`text-xs font-mono shrink-0 ${q.valid?"text-slate-400":"text-amber-600"}`,children:q.label})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`claim-evidence-${l}`,className:"block text-xs font-bold text-slate-700 mb-1",children:["Links that show the connection ",e.jsx("span",{className:"font-normal text-slate-400",children:"(optional)"})]}),e.jsx("textarea",{id:`claim-evidence-${l}`,value:g,onChange:J=>M(J.target.value),rows:2,placeholder:"https://your-company-website.com/projects/this-project",className:`${ql} font-mono`}),e.jsxs("p",{className:"text-xs text-slate-400 mt-1",children:["Up to ",fl," links, one per line. Each must start with https://"]}),i.evidence&&e.jsx("p",{className:"text-xs text-rose-600 mt-1",children:i.evidence})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"submit",disabled:I,className:"flex items-center justify-center gap-1.5 min-h-[40px] sm:min-h-0 px-4 py-2 bg-indigo-500 hover:bg-indigo-600 disabled:opacity-40 text-white text-xs font-bold rounded-xl cursor-pointer disabled:cursor-not-allowed",children:I?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"})," Sendingâ¦"]}):"Send claim for review"}),e.jsx("button",{type:"button",onClick:F,disabled:I,className:"min-h-[40px] sm:min-h-0 px-4 py-2 text-slate-500 hover:text-slate-800 text-xs font-bold cursor-pointer",children:"Cancel"})]})]})}const vd="That does not look like a TS-RERA project registration number. It starts with P0 followed by 8 to 10 digits, for example P02400011233.",wd="We couldn't reach the TS-RERA portal. Please try again in a few minutes.";function Sd(a){const l=(a||"").trim().toUpperCase();return l?pi.test(l)||mi.test(l)?{ok:!0,value:l}:{ok:!1,error:vd}:{ok:!1,error:"Enter the TS-RERA registration number."}}const kd=/^(fetch failed|failed to fetch|network ?error|load failed|econn\w*|etimedout|timeout)/i;function En(a,l){const j=(l||"").trim();return a===null||a===502||a===503||a===504?wd:!j||kd.test(j)?a===404?"No TS-RERA registration was found for this number.":"Could not fetch this TS-RERA registration.":j}const Cd={name:"project.name",district:"project.district",pincode:"project.pincode",location:"project.location",possessionDate:"project.possessionDate"};function Pd(a){if(!a)return"";try{return new Date(a).toLocaleDateString("en-IN",{day:"2-digit",month:"short"})}catch{return""}}async function Rd(a,l){const j=await rt(l);return(await fetch(a,{headers:j})).json()}function Ad({user:a,onClose:l,onSubmitted:j,companyName:u,onClaimFiled:E}){const[y,F]=r.useState(1),[b,K]=r.useState(""),[v,te]=r.useState(!1),[V,g]=r.useState(null),[M,i]=r.useState(null),[O,U]=r.useState(!1),[ie,I]=r.useState(null),[R,G]=r.useState(null),[re,x]=r.useState({}),[D,q]=r.useState([]),[de,J]=r.useState(0),[me,Q]=r.useState(0),[Ie,Ae]=r.useState([]),[Ce,Le]=r.useState(""),[Je,$e]=r.useState(""),[ve,qe]=r.useState(""),[Pe,Ve]=r.useState(""),[et,Fe]=r.useState(""),[$,le]=r.useState(""),[ne,N]=r.useState(""),[ue,m]=r.useState(null),[C,Y]=r.useState(null),[h,w]=r.useState({}),[T,B]=r.useState(!1),[H,xe]=r.useState(null),[z,se]=r.useState([]),[Ge,o]=r.useState(!1),[L,je]=r.useState(null),pe=r.useRef(null),[he,xt]=r.useState(!1),[as,Ms]=r.useState(null),[vs,la]=r.useState(null),ws=async()=>{const d=Sd(b);
20if(d.ok===!1){g(d.error),i(null),U(!1);return}const Z=d.value;te(!0),g(null),i(null),U(!1);try{const ee=await rt(a),Ee=await fetch("/api/listings/intake/rera",{method:"POST",headers:{"Content-Type":"application/json",...ee},body:JSON.stringify({reraNumber:Z})}),ze=await Ee.json().catch(()=>({}));Ee.status===201?Ha(ze):Ee.status===200&&ze.existing?i(ze):g(En(Ee.status,ze.error))}catch{g(En(null))}finally{te(!1)}},Ha=d=>{var ee,Ee;const Z=gd(d);if(Z.pending){I({name:((ee=d.fields)==null?void 0:ee.name)||((Ee=d.project)==null?void 0:Ee.name)||"This project",promoterNameMatch:Z.promoterNameMatch,claimFiled:!!d.claimRequest}),E==null||E();return}G(d.projectId),x(d.provenance||{}),q(d.towers||[]),J(d.unitTypesCount||0),Q(d.approvalsCount||0),Ae(d.warnings||[]),Le(d.fields.name||d.project.name||""),$e(d.fields.location||d.project.location||""),qe(d.fields.district||d.project.district||""),Ve(d.fields.pincode||d.project.pincode||""),Fe(d.fields.status||d.project.status||""),le(d.fields.possessionDate||""),N(d.project.sizeRange||""),m(d.project.latitude??null),Y(d.project.longitude??null),w(d.project.reraDetails||{}),F(2)},rs=d=>{E==null||E(),U(!1),i(Z=>Z&&(d==="already_owner"?{...Z,claimable:!1,ownedByYou:!0}:d==="already_owned"?{...Z,claimable:!1,ownedByAnother:!0}:Z)),d==="claim_pending"&&M&&I({name:M.project.name,promoterNameMatch:null,claimFiled:!0})},Bs=()=>{M&&(E==null||E(),I({name:M.project.name,promoterNameMatch:null,claimFiled:!0}))},kt=d=>{const Z=Cd[d],ee=Z?re[Z]:void 0;return ee?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-brand-600 bg-brand-50 border border-brand-200 rounded-full px-2 py-0.5",children:[e.jsx(jl,{className:"w-3 h-3"})," from TS-RERA filing, fetched ",Pd(ee.fetchedAt)]}):null}
20,Ct=ue!=null&&C!=null,Ss=r.useMemo(()=>Ie.map(d=>({text:d,isMapPin:/set the map pin/i.test(d)})),[Ie]),Os=async()=>{if(R){B(!0),xe(null);try{await Lr(a,R,{name:Ce.trim(),location:Je.trim(),district:ve.trim()||void 0,pincode:Pe.trim()||void 0,status:et||void 0,sizeRange:ne.trim()||void 0,latitude:ue??void 0,longitude:C??void 0,reraDetails:{...h,possessionDate:$||void 0}}),F(3)}catch(d){xe(vl(d,"Failed to save your changes."))}finally{B(!1)}}},[ke,bt]=r.useState(null),[Te,ks]=r.useState(null),[ls,_s]=r.useState(null),[Ft,_t]=r.useState(null),[Tt,ns]=r.useState(new Set),Dt=async(d,Z)=>{if(R){_t(null),_s(d);try{const ee=`listing-intake/${R}/${d}/${Date.now()}-${Z.name}`,Ee=await ra(Z,ee),ze=await rt(a),Ye=await fetch(`/api/listings/${R}/intake/documents`,{method:"POST",headers:{"Content-Type":"application/json",...ze},body:JSON.stringify({kind:d,fileUrl:Ee})}),pt=await Ye.json();if(!Ye.ok)throw new Error(pt.error||"Failed to start extraction.");(d==="brochure"?bt:ks)(pt.job)}catch(ee){_t((ee==null?void 0:ee.message)||"Upload failed â check your connection and try again.")}finally{_s(null)}}};r.useEffect(()=>{if(!R||(ke==null?void 0:ke.status)!=="running"&&(Te==null?void 0:Te.status)!=="running")return;const d=setInterval(async()=>{try{const ee=(await Rd(`/api/listings/${R}/intake`,a)).jobs||[],Ee=ee.find(Ye=>Ye.kind==="brochure"&&Ye.id===(ke==null?void 0:ke.id)),ze=ee.find(Ye=>Ye.kind==="price_sheet"&&Ye.id===(Te==null?void 0:Te.id));Ee&&bt(Ee),ze&&ks(ze)}catch{}},2e3);return()=>clearInterval(d)},[R,ke==null?void 0:ke.id,ke==null?void 0:ke.status,Te==null?void 0:Te.id,Te==null?void 0:Te.status,a]);const na=async(d,Z)=>{if(!(!R||Z.length===0)){ns(ee=>new Set([...ee,...Z]));try{const ee=await rt(a),Ye=(await(await fetch(`/api/listings/${R}/intake/${d.id}/accept`,{method:"POST",headers:{"Content-Type":"application/json",...ee},body:JSON.stringify({itemIds:Z})})).json()).accepted||[];(d.kind==="brochure"?bt:ks)(At=>{if(!At)return At;const Lt={...At.result};for(const xs of Object.keys(Lt))Array.isArray(Lt[xs])&&(Lt[xs]=Lt[xs].filter(Ut=>!Ye.includes(Ut.id)));return{...At,result:Lt}})}finally{ns(ee=>{const Ee=new Set(ee);for(const ze of Z)Ee.delete(ze);return Ee})}}},[tt,oa]=r.useState(""),[it,qs]=r.useState(""),[ge,qt]=r.useState(""),[Vt,zt]=r.useState(!1),[os,Cs]=r.useState(null),[Pt,It]=r.useState([]),is=async()=>{if(!(!R||!tt.trim()||!it)){zt(!0),Cs(null);try{const d=await Hn(a,R,{code:tt.trim(),saleableSqft:Number(it),facing:ge||null});It(Z=>[...Z,{code:d.code,saleableSqft:d.saleableSqft||0,facing:d.facing}]),oa(""),qs(""),qt("")}catch(d){Cs((d==null?void 0:d.message)||"Failed to add this unit plan.")}finally{zt(!1)}}},[Ht,Rt]=r.useState(""),[Wt,ia]=r.useState(""),[Kt,Gt]=r.useState(!1),[mt,Ps]=r.useState(null),[Vs,ds]=r.useState([]),da=async()=>{if(!(!R||!Ht.trim()||!Wt)){Gt(!0),Ps(null);try{const d=await rt(a),ee=await(await fetch(`/api/projects/${R}/price-sheet`,{headers:d})).json().catch(()=>({})),Ee=Array.isArray(ee==null?void 0:ee.plans)?ee.plans:[],ze={id:`manual-${Date.now()}`,name:Ht.trim(),tagline:"",baseRatePerSft:Number(Wt),milestones:[]},Ye=await fetch(`/api/projects/${R}/price-sheet`,{method:"PUT",headers:{"Content-Type":"application/json",...d},body:JSON.stringify({areaBasis:(ee==null?void 0:ee.areaBasis)||"saleable",plans:[...Ee,ze],charges:(ee==null?void 0:ee.charges)||[],taxes:(ee==null?void 0:ee.taxes)||{gstPct:5,stampDuty:"",registration:""}})});if(!Ye.ok){const pt=await Ye.json().catch(()=>({}));throw new Error(pt.error||"Failed to add this price-sheet row.")}ds(pt=>[...pt,{name:ze.name,rate:ze.baseRatePerSft}]),Rt(""),ia("")}catch(d){Ps((d==null?void 0:d.message)||"Failed to add this price-sheet row.")}finally{Gt(!1)}}},cs=async d=>{if(!(!d||d.length===0||!R)){je(null),o(!0);try{const Z=[];for(const ee of Array.from(d)){if(!ee.type.startsWith("image/"))continue;const Ee=`listing-intake/${R}/gallery/${Date.now()}-${ee.name}`;Z.push(await ra(ee,Ee))}se(ee=>[...ee,...Z])}catch(Z){je((Z==null?void 0:Z.message)||"Photo upload failed â check your connection and try again.")}finally{o(!1),pe.current&&(pe.current.value="")}}},ca=d=>se(Z=>Z.filter(ee=>ee!==d)),xa=d=>se(Z=>[d,...Z.filter(ee=>ee!==d)]),zs=async()=>
20{if(R){xt(!0),Ms(null);try{z.length>0&&await Lr(a,R,{media:{galleryImages:z}});const d=await Kn(a,R);la(d),j==null||j(R)}catch(d){Ms(vl(d,"Failed to submit this project for review."))}finally{xt(!1)}}};if(ie){const d=fd(ie.promoterNameMatch);return e.jsx("div",{className:"max-w-2xl mx-auto px-4 py-12",children:e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-amber-50 text-amber-600 flex items-center justify-center mx-auto mb-4",children:e.jsx(El,{className:"w-7 h-7"})}),e.jsx("h2",{className:"text-2xl font-extrabold text-slate-900",children:"Awaiting ownership review"}),e.jsxs("p",{className:"text-xs text-slate-400 mt-2 font-mono",children:['"',ie.name,'"']}),e.jsxs("p",{className:"text-sm text-slate-500 mt-3 max-w-md mx-auto",children:["Our team will verify that you are connected to this RERA project, usually within 1 business day. You can't edit or submit it until then. Once approved, the project will appear under ",e.jsx("span",{className:"font-semibold text-slate-700",children:"My Listings"}),"."]}),d&&e.jsx("p",{className:"text-xs text-slate-500 mt-3 max-w-md mx-auto",children:d}),e.jsx("button",{onClick:()=>l==null?void 0:l(),className:"mt-6 px-5 py-2.5 bg-brand-500 hover:bg-brand-600 text-white text-sm font-bold rounded-xl transition-all cursor-pointer",children:"Back to my listings"})]})})}if(vs)return e.jsx("div",{className:"max-w-2xl mx-auto px-4 py-12",children:e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-50 text-emerald-600 flex items-center justify-center mx-auto mb-4",children:e.jsx(_a,{className:"w-7 h-7"})}),e.jsx("h2",{className:"text-2xl font-extrabold text-slate-900",children:"Submitted for review"}),e.jsxs("p",{className:"text-sm text-slate-500 mt-2 max-w-md mx-auto",children:["Our team checks it within 1 working day. You'll see it under ",e.jsx("span",{className:"font-semibold text-slate-700",children:"My listings"})," once it's live."]}),e.jsxs("p",{className:"text-xs text-slate-400 mt-3 font-mono",children:['"',vs.name,'"']}),e.jsx("button",{onClick:()=>l==null?void 0:l(),className:"mt-6 px-5 py-2.5 bg-brand-500 hover:bg-brand-600 text-white text-sm font-bold rounded-xl transition-all cursor-pointer",children:"Back to my listings"})]})});const Yt=["TS-RERA number","Review","Documents","Photos & submit"];return e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-8 sm:py-10",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-extrabold text-slate-900",children:"Add a new-launch (RERA) project"}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:"Enter the TS-RERA registration number â we fetch the filing and pre-fill the rest."})]}),y>1&&e.jsx("div",{className:"flex items-center gap-1.5 mb-8",children:Yt.map((d,Z)=>{const ee=Z+1,Ee=y===ee,ze=y>ee;return e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1.5",children:[e.jsx("div",{className:`w-full h-1.5 rounded-full ${ze?"bg-emerald-500":Ee?"bg-brand-500":"bg-slate-200"}`}),e.jsx("span",{className:`text-xs font-semibold hidden sm:block ${Ee?"text-brand-700":ze?"text-emerald-600":"text-slate-400"}`,children:d})]},d)})}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-5 sm:p-7",children:[y===1&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("label",{htmlFor:"rera-number",className:"text-sm font-bold text-slate-800 block",children:"TS-RERA registration number (starts with P0â¦)"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2.5",children:[e.jsx("input",{id:"rera-number",type:"text",value:b,onChange:d=>{K(d.target.value),g(null)},onKeyDown:d=>d.key==="Enter"&&!v&&ws(),placeholder:"P02400011233",className:"flex-1 px-4 py-2.5 border border-slate-200 rounded-xl text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand-200 focus:border-brand-400"}),e.jsxs("button",{onClick:ws,disabled:v||!b.trim(),className:"flex items-center justify-center gap-1.5 px-6 py-2.5 bg-brand-500 hover:bg-brand-600 disabled:opacity-40 text-white text-sm font-bold rounded-xl transition-all cursor-pointer",children:[v?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):null," Fetch"]})]}),v&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 py-2",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin text-brand-500"})," Fetching the TS-RERA filingâ¦"]}),V&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-sm text-rose-700",children:[e.jsx(ss,{className:"w-4 h-4 shrink-0"})," ",V]}),M&&e.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-2xl space-y-3",children:[e.jsxs("p",{className:"text-sm text-amber-800",children:[e.jsx("span",{className:"font-bold",children:M.project.name})," is already on Realtified (",M.project.location,")."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("a",{href:`/projects/${M.project.slug}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-4 py-2 bg-white border border-amber-300 hover:bg-amber-100 text-amber-800 text-xs font-bold rounded-xl transition-all cursor-pointer",children:[e.jsx(ko,{className:"w-3.5 h-3.5"})," Open it"]}),M.claimable&&!O&&e.jsx("button",{onClick:()=>U(!0),className:"flex items-center gap-1.5 px-4 py-2 bg-brand-500 hover:bg-brand-600 text-white text-xs font-bold rounded-xl transition-all cursor-pointer",children:"Ask to claim it"})]}),M.ownedByYou&&e.jsxs("p",{className:"text-xs text-amber-800",children:["This project is already yours. Find it under ",e.jsx("span",{className:"font-semibold",children:"My Listings"}),"."]}),M.ownedByAnother&&e.jsx("p",{className:"text-xs text-amber-800",children:"It already has an owner. If that is wrong, contact [email protected]."}),M.claimable&&O&&e.jsx("div",{className:"bg-white border border-amber-200 rounded-xl p-4",children:e.jsx(Qn,{user:a,projectId:M.projectId,projectName:M.project.name,defaultCompanyName:u,onSent:Bs,onSettled:rs,onClose:()=>U(!1)})})]})]}),y===2&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("h2",{className:"text-lg font-extrabold text-slate-900",children:"Review what we found"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Every field below is editable â fix anything the filing got wrong or left blank."}),e.jsx(aa,{label:"Project name",tag:kt("name"),children:e.jsx("input",{value:Ce,onChange:d=>Le(d.target.value),className:"w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-brand-200 focus:border-brand-400"})}),e.jsx(aa,{label:"Location",tag:kt("location"),children:e.jsx("input",{value:Je,onChange:d=>$e(d.target.value),className:"w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-brand-200 focus:border-brand-400"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(aa,{label:"District",tag:kt("district"),children:e.jsx("input",{value:ve,onChange:d=>qe(d.target.value),className:"w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-brand-200 focus:border-brand-400"})}),e.jsx(aa,{label:"Pincode",tag:kt("pincode"),children:e.jsx("input",{value:Pe,onChange:d=>Ve(d.target.value),className:"w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-brand-200 focus:border-brand-400"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(aa,{label:"Status",children:e.jsxs("select",{value:et,onChange:d=>Fe(d.target.value),className:"w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-brand-200 focus:border-brand-400",children:[e.jsx("option",{value:"",children:"Not set"}),e.jsx("option",{value:"Pre-launch",children:"Pre-launch"}),e.jsx("option",{value:"Under Construction",children:"Under Construction"}),e.jsx("option",{value:"Ready to Move",children:"Ready to Move"})]})}),e.jsx(aa,{label:"Possession date",tag:kt("possessionDate"),children:e.jsx("input",{value:$,onChange:d=>le(d.target.value),placeholder:"DD/MM/YYYY",className:"w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-brand-200 focus:border-brand-400"})})]}),e.jsx(aa,{label:"Size range (shown on the listing card)",children:e.jsx("input",{value:ne,onChange:d=>N(d.target.value),placeholder:"e.g. 1,450 - 1,800 sq ft",className:"w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-brand-200 focus:border-brand-400"})}),D.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-bold text-slate-800 mb-2",children:["Towers (",D.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:D.map(d=>e.jsxs("div",{className:"p-3 border border-slate-200 rounded-xl text-xs text-slate-600",children:[e.jsx("p",{className:"font-bold text-slate-800",children:d.name}),e.jsxs("p",{children:[d.totalFloors!=null?`${d.totalFloors} floors`:"Floors not stated",d.proposedCompletion?` · Due ${d.proposedCompletion}`:""]}),d.overallCompletionPct!=null&&e.jsxs("p",{className:"text-emerald-600 font-bold mt-0.5",children:[d.overallCompletionPct,"% complete"]})]},d.name))})]}),(de>0||me>0)&&e.jsxs("div",{className:"flex gap-4 text-sm text-slate-600",children:[de>0&&e.jsxs("span",{children:[e.jsx("span",{className:"font-bold text-slate-900",children:de})," unit types filed"]}),me>0&&e.jsxs("span",{children:[e.jsx("span",{className:"font-bold text-slate-900",children:me})," approvals on file"]})]}),Ss.length>0&&e.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-2xl space-y-3",children:[e.jsx("p",{className:"text-xs font-bold text-amber-800 uppercase tracking-wide",children:"To-dos before you continue"}),e.jsx("ul",{className:"space-y-1.5",children:Ss.map((d,Z)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-amber-800",children:[d.isMapPin&&Ct?e.jsx(_a,{className:"w-4 h-4 text-emerald-600 shrink-0 mt-0.5"}):e.jsx(El,{className:"w-4 h-4 shrink-0 mt-0.5"}),d.text]},Z))}),Ss.some(d=>d.isMapPin)&&e.jsx("div",{className:"pt-1",children:e.jsx(wn,{latitude:ue,longitude:C,onChange:(d,Z)=>{m(d),Y(Z)}})})]}),!Ss.some(d=>d.isMapPin)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 mb-2",children:"Map pin"}),e.jsx(wn,{latitude:ue,longitude:C,onChange:(d,Z)=>{m(d),Y(Z)}})]}),H&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-sm text-rose-700",children:[e.jsx(ss,{className:"w-4 h-4 shrink-0"})," ",H]})]}),y===3&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-lg font-extrabold text-slate-900",children:"Documents"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Upload the brochure and price sheet â we'll try to read floor plans, prices and amenities automatically."}),Ft&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-sm text-rose-700",children:[e.jsx(ss,{className:"w-4 h-4 shrink-0"})," ",Ft]}),e.jsx(Fn,{label:"Brochure",job:ke,uploading:ls==="brochure",onUpload:d=>Dt("brochure",d),onAccept:d=>ke&&na(ke,d),acceptingIds:Tt}),e.jsx(Fn,{label:"Price sheet",job:Te,uploading:ls==="price_sheet",onUpload:d=>Dt("price_sheet",d),onAccept:d=>Te&&na(Te,d),acceptingIds:Tt}),((ke==null?void 0:ke.status)==="unavailable"||(Te==null?void 0:Te.status)==="unavailable"||!ke&&!Te)&&e.jsxs("div",{className:"p-4 bg-slate-50 border border-slate-200 rounded-2xl space-y-5",children:[e.jsxs("p",{className:"text-sm text-slate-600 flex items-start gap-2",children:[e.jsx(El,{className:"w-4 h-4 shrink-0 mt-0.5 text-slate-400"}),"Automatic reading isn't switched on yet â you can add floor plans and prices by hand below."]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 mb-2",children:"Add a unit plan"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsx("input",{value:tt,onCh
20ange:d=>oa(d.target.value),placeholder:"Configuration (3BHK-A)",className:"px-3 py-2 border border-slate-200 rounded-lg text-sm col-span-2 sm:col-span-1"}),e.jsx("input",{value:it,onChange:d=>qs(d.target.value),type:"number",placeholder:"Size (sq ft)",className:"px-3 py-2 border border-slate-200 rounded-lg text-sm"}),e.jsxs("select",{value:ge,onChange:d=>qt(d.target.value),className:"px-3 py-2 border border-slate-200 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Facing"}),e.jsx("option",{value:"E",children:"East"}),e.jsx("option",{value:"W",children:"West"}),e.jsx("option",{value:"N",children:"North"}),e.jsx("option",{value:"S",children:"South"})]})]}),e.jsx("button",{onClick:is,disabled:Vt||!tt.trim()||!it,className:"mt-2 px-4 py-1.5 bg-brand-500 hover:bg-brand-600 disabled:opacity-40 text-white text-xs font-bold rounded-lg transition-all cursor-pointer",children:Vt?"Addingâ¦":"Add unit plan"}),os&&e.jsx("p",{className:"text-xs text-rose-600 mt-1.5",children:os}),Pt.length>0&&e.jsx("ul",{className:"mt-2 space-y-1",children:Pt.map((d,Z)=>e.jsxs("li",{className:"text-xs text-emerald-700 flex items-center gap-1.5",children:[e.jsx(_a,{className:"w-3.5 h-3.5"})," ",d.code," â ",d.saleableSqft," sq ft",d.facing?` · ${d.facing}`:""]},Z))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 mb-2",children:"Add a price-sheet row"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("input",{value:Ht,onChange:d=>Rt(d.target.value),placeholder:"Configuration (3BHK-A)",className:"px-3 py-2 border border-slate-200 rounded-lg text-sm"}),e.jsx("input",{value:Wt,onChange:d=>ia(d.target.value),type:"number",placeholder:"Rate per sq ft (â¹)",className:"px-3 py-2 border border-slate-200 rounded-lg text-sm"})]}),e.jsx("button",{onClick:da,disabled:Kt||!Ht.trim()||!Wt,className:"mt-2 px-4 py-1.5 bg-brand-500 hover:bg-brand-600 disabled:opacity-40 text-white text-xs font-bold rounded-lg transition-all cursor-pointer",children:Kt?"Addingâ¦":"Add price row"}),mt&&e.jsx("p",{className:"text-xs text-rose-600 mt-1.5",children:mt}),Vs.length>0&&e.jsx("ul",{className:"mt-2 space-y-1",children:Vs.map((d,Z)=>e.jsxs("li",{className:"text-xs text-emerald-700 flex items-center gap-1.5",children:[e.jsx(_a,{className:"w-3.5 h-3.5"})," ",d.name," â â¹",d.rate,"/sq ft"]},Z))})]})]})]}),y===4&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("h2",{className:"text-lg font-extrabold text-slate-900",children:"Photos & cover"}),L&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-sm text-rose-700",children:[e.jsx(ss,{className:"w-4 h-4 shrink-0"})," ",L]}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-3",children:[z.map((d,Z)=>e.jsxs("div",{className:"relative aspect-square rounded-xl overflow-hidden border border-slate-200 group",children:[e.jsx("img",{src:d,alt:`Photo ${Z+1}`,className:"w-full h-full object-cover"}),Z===0&&e.jsxs("span",{className:"absolute top-1.5 left-1.5 flex items-center gap-1 bg-brand-500 text-white text-xs font-bold px-1.5 py-0.5 rounded-full",children:[e.jsx(ln,{className:"w-3 h-3 fill-current"})," Cover"]}),e.jsxs("div",{className:"absolute inset-0 md:bg-slate-900/0 md:group-hover:bg-slate-900/40 transition-colors flex items-end justify-end p-1.5 md:p-0 md:items-center md:justify-center gap-2 md:opacity-0 md:group-hover:opacity-100 md:focus-within:opacity-100",children:[Z!==0&&e.jsx("button",{onClick:()=>xa(d),className:"p-1.5 bg-white/90 rounded-full cursor-pointer",children:e.jsx(ln,{className:"w-3.5 h-3.5 text-slate-700"})}),e.jsx("button",{onClick:()=>ca(d),className:"p-1.5 bg-white/90 rounded-full cursor-pointer",children:e.jsx(ot,{className:"w-3.5 h-3.5 text-rose-600"})})]})]},d)),e.jsxs("button",{onClick:()=>{var d;return(d=pe.current)==null?void 0:d.click()},disabled:Ge,className:"aspect-square rounded-xl border-2 border-dashed border-slate-300 hover:border-brand-400 flex flex-col items-center justify-center gap-1.5 text-slate-400 hover:text-brand-500 transition-colors cursor-pointer disabled:opacity-50",children:[Ge?e.jsx(ce,{className:"w-5 h-5 animate-spin"}):e.jsx(Co,{className:"w-5 h-5"}),e.jsx("span",{className:"text-xs font-bold",children:"Add photos"})]})]}),e.jsx("input",{ref:pe,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:d=>cs(d.target.files)}),as&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-sm text-rose-700",children:[e.jsx(ss,{className:"w-4 h-4 shrink-0"})," ",as]})]})]}),y>1&&e.jsxs("div",{className:"flex items-center justify-between mt-6",children:[e.jsxs("button",{onClick:()=>y===2?l==null?void 0:l():F(y-1),className:"flex items-center gap-1.5 px-4 py-2.5 text-sm font-bold text-slate-600 hover:text-slate-900 cursor-pointer",children:[e.jsx(Bn,{className:"w-4 h-4"})," ",y===2?"Cancel":"Back"]}),y<4?e.jsxs("button",{onClick:()=>y===2?Os():F(y+1),disabled:y===2&&(T||!Ct||!ne.trim()),title:y===2&&!Ct?"Set the map pin before continuing":y===2&&!ne.trim()?"Enter a size range before continuing":void 0,className:"flex items-center gap-1.5 px-6 py-2.5 bg-brand-500 hover:bg-brand-600 disabled:opacity-40 text-white text-sm font-bold rounded-xl transition-all cursor-pointer",children:[T?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):null," Next ",e.jsx(Va,{className:"w-4 h-4"})]}):e.jsxs("button",{onClick:zs,disabled:he,className:"flex items-center gap-1.5 px-6 py-2.5 bg-emerald-600 hover:bg-emerald-700 disabled:opacity-40 text-white text-sm font-bold rounded-xl transition-all cursor-pointer",children:[he?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):e.jsx(_a,{className:"w-4 h-4"})," Submit for review"]})]})]})}function aa({label:a,tag:l,children:j}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"text-sm font-bold text-slate-800",children:a}),l]}),j]})}function Fn({label:a,job:l,uploading:j,onUpload:u,onAccept:E,acceptingIds:y}){const F=r.useRef(null);return e.jsxs("div",{className:"p-4 border border-slate-200 rounded-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(za,{className:"w-4 h-4 text-slate-400"})," ",a]}),e.jsxs("button",{onClick:()=>{var b;return(b=F.current)==null?void 0:b.click()},disabled:j,className:"flex items-center gap-1.5 px-3 py-1.5 bg-slate-50 hover:bg-slate-100 border border-slate-200 text-slate-700 text-xs font-bold rounded-lg transition-all cursor-pointer disabled:opacity-50",children:[j?e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx($s,{className:"w-3.5 h-3.5"})," ",l?"Replace":"Upload"]}),e.jsx("input",{ref:F,type:"file",accept:"application/pdf,image/*",hidden:!0,onChange:b=>{var K;return((K=b.target.files)==null?void 0:K[0])&&u(b.target.files[0])}})]}),(l==null?void 0:l.status)==="running"&&e.jsxs("p",{className:"text-xs text-slate-500 flex items-center gap-1.5 mt-2",children:[e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"})," Reading documentâ¦"]}),(l==null?void 0:l.status)==="unavailable"&&e.jsx("p",{className:"text-xs text-slate-400 mt-2",children:"Uploaded â automatic reading isn't switched on yet (see manual entry below)."}),(l==null?void 0:l.status)==="failed"&&e.jsx("p",{className:"text-xs text-rose-600 mt-2",children:l.error||"Could not read this document."}),(l==null?void 0:l.status)==="done"&&l.result&&e.jsx("div",{className:"mt-3 space-y-3",children:Object.entries(l.result).map(([b,K])=>!Array.isArray(K)||K.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wide",children:b}),e.jsx("button",{onClick:()=>E(K.map(v=>v.id)),className:"text-xs font-bold text-brand-600 hover:text-brand-700 cursor-pointer",children:"Accept all"})]}),e.jsx("ul",{className:"mt-1 space-y-1",children:K.map(v=>e.jsxs("li",{className:"flex items-center justify-between gap-2 text-xs text-slate-600 p-2 bg-slate-50 rounded-lg",children:[e.jsxs("span",{className:"truncate",children:[JSON.stringify(v).slice(0,80),v.page?` (p.${v.page})`:""]}),e.jsx("button",{onClick:()=>E([v.id]),disabled:y.has(v.id),className:"shrink-0 text-emerald-600 font-bold cursor-pointer disabled:opacity-40",children:y.has(v.id)?"â¦":"Accept"})]},v.id))})]},b))})]})}const Ld={amber:"bg-amber-50 text-amber-700 border-amber-200",emerald:"bg-emerald-50 text-emerald-700 border-emerald-200",rose:"bg-rose-50 text-rose-700 border-rose-200",slate:"bg-slate-100 text-slate-600 border-slate-200"};function Ed(a){if(!a)return"";const l=new Date(a);return Number.isNaN(l.getTime())?"":l.toLocaleDateString("en-IN",{day:"2-digit",month:"short"})}function Fd({claims:a}){return!a||a.length===0?null:e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-5 shadow-xs",children:[e.jsx("p",{className:"text-sm font-extrabold text-slate-900 font-display",children:"My claims"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Projects you have asked to add to your account."}),e.jsx("ul",{className:"mt-3 divide-y divide-slate-100",children:a.map(l
20=>{const j=Kl(l.status),u=bd(l);return e.jsxs("li",{className:"py-2.5 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-slate-800 truncate",children:l.projectName||`Project #${l.projectId}`}),e.jsxs("p",{className:"text-xs text-slate-400 font-mono",children:["Sent ",Ed(l.createdAt)]}),u&&e.jsxs("p",{className:"text-xs text-slate-600 mt-1",children:["Our team said: ",u]})]}),e.jsx("span",{className:`shrink-0 text-xs font-bold px-2 py-0.5 rounded-full border ${Ld[j.tone]}`,children:j.label})]},l.id)})})]})}async function Tn(a,l={}){const j=await rt(a??null),u=new URLSearchParams({paged:"1"});l.limit&&u.set("limit",String(l.limit)),l.offset&&u.set("offset",String(l.offset));const E=await fetch(`/api/listings/mine?${u.toString()}`,{headers:j});if(!E.ok){const y=await E.json().catch(()=>({}));throw new Error(y.error||"Failed to fetch listings")}return E.json()}async function Td(a,l){const j=[...new Set(l)].slice(0,50);if(j.length===0)return{};const u=await rt(a??null),E=await fetch(`/api/listings/readiness?ids=${j.join(",")}`,{headers:u});if(!E.ok)return{};const y=await E.json(),F={};for(const[b,K]of Object.entries((y==null?void 0:y.items)??{}))F[Number(b)]=K;return F}function Dn(a,l){const j=new Map(l.map(y=>[String(y.id),y])),u=a.map(y=>j.get(String(y.id))??y),E=new Set(a.map(y=>String(y.id)));for(const y of l)E.has(String(y.id))||u.push(y);return u}function In(a,l){const j=a;return{id:`backend-${a.id}`,number:a.unitNumber,floor:a.floor??1,type:a.bhk?`${a.bhk} BHK`:"",size:a.sizeSqFt,status:a.status??"Available",assignedLead:a.assignedLeadId!=null?String(a.assignedLeadId):void 0,towerId:j.towerId??null,facing:j.facing??null,isCorner:j.isCorner??null,hasViewPremium:j.hasViewPremium??null}}function Dd(a){if(a.startsWith("backend-")){const l=parseInt(a.replace("backend-",""),10);return isNaN(l)?null:l}return null}function Id(a){switch(a){case"draft":return{label:"Draft â continue",cls:"bg-slate-100 text-slate-600 border border-slate-200"};case"legal_review":return{label:"In Legal Review",cls:"bg-amber-50 text-amber-700 border border-amber-200"};case"pending_approval":return{label:"Cleared Legal â Pending Final Approval",cls:"bg-amber-50 text-amber-700 border border-amber-200"};case"approved":return{label:"Approved",cls:"bg-emerald-50 text-emerald-700 border border-emerald-200"};case"rejected":return{label:"Rejected",cls:"bg-rose-50 text-rose-700 border border-rose-200"};case"registry":return{label:"Public Registry Record",cls:"bg-slate-100 text-slate-600 border border-slate-200"}}}function Ud(a){switch(a){case"draft":return{label:"Draft",tone:"draft"};case"legal_review":return{label:"In review",tone:"review",title:"In legal review"};case"pending_approval":return{label:"In review",tone:"review",title:"Cleared legal, awaiting final approval"};case"approved":return{label:"Live",tone:"live"};case"rejected":return{label:"Rejected",tone:"rejected"};default:return{label:"Public registry record",tone:"neutral"}}}function $d(a){return a==="resale_flat"||a==="independent_house"||a==="villa"||a==="plot"}function Un(a){const l=Date.now()-new Date(a).getTime();if(!isFinite(l)||l<0)return"just now";const j=Math.floor(l/6e4);if(j<1)return"just now";if(j<60)return`${j}m ago`;const u=Math.floor(j/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}const Md=["West","East","North","South","Central"],Bd=["Under Construction","Ready to Move","New Launch","Pre-launch"],Od=()=>({name:"",location:"",region:"West",reraNumber:"",status:"Under Construction",basePricePerSqFt:"",latitude:"",longitude:"",brochureUrl:"",walkthroughVideoUrl:"",reraApplicationUrl:"",priceSheetUrl:"",galleryImages:[],videoClips:[],floorRiseStartFloor:"",floorRiseRatePerSft:"",premiums:[],parkingRules:[]});function xc({user:a,leads:l,setLeads:j,units:u,setUnits:E,basePriceMap:y,setBasePriceMap:F,onSuccessNotification:b,hideBanner:K=!1,setActiveSection:v,initialClaimIntent:te=!1,onClaimIntentConsumed:V,onOpenProject:g,companyName:M}){const[i,O]=r.useState(null),[U,ie]=r.useState([]),[I,R]=r.useState(!1),[G,re]=r.useState(null),[x,D]=r.useState("home"),[q,de]=r.useState("matrix"),[J,me]=r.useState(!1),[Q,Ie]=r.useState(!1),[Ae,Ce]=r.useState("offers-bookings"),[Le,Je]=r.useState([]),[$e,ve]=r.useState(!1),[qe,Pe]=r.useState(null),[Ve,et]=r.useState({}),[Fe,$]=r.useState({}),[le,ne]=r.useState({}),[N,ue]=r.useState(null),[m,C]=r.useState([]);r.useEffect(()=>{const t=()=>{try{const n=JSON.parse(localStorage.getItem("realtified_deal_proposals")||"[]");C(n)}catch{C([])}};return t(),window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[Y,h]=r.useState(!1),[w,T]=r.useState({}),[B,H]=r.useState(null),xe=()=>{a&&(R(!0),re(null),vi(a).then(t=>{ie(t),t.length>0&&i===null&&O(t[0].id)}).catch(t=>{console.warn("Could not load my listings:",t),re("Could not load your claimed listings. Please try again.")}).finally(()=>R(!1)))};r.useEffect(()=>{xe()},[a]);const z=U.length;U.filter(t=>t.commercialStatus==="approved").length,U.filter(t=>t.commercialStatus==="pending").length,Object.values(u).flat().length;const se=U.filter(t=>t.approvalStatus==="approved").length,Ge=U.filter(t=>t.approvalStatus==="pending_approval"||t.approvalStatus==="legal_review").length,o=U.filter(t=>t.approvalStatus==="draft").length,L=U.find(t=>
20t.approvalStatus==="draft")||null,je=U.find(t=>t.approvalStatus==="rejected")||null,pe=U.find(t=>t.approvalStatus==="approved"&&t.commercialStatus==="none")||null,[he,xt]=r.useState(null),[as,Ms]=r.useState(!1);r.useEffect(()=>{if(!a)return;let t=!1;return $o(a).then(n=>{t||"unitsByStatus"in n&&xt({available:n.unitsByStatus.Available,total:n.totalUnits})}).catch(()=>{}).finally(()=>{t||Ms(!0)}),()=>{t=!0}},[a]);const vs=he?he.available:U.reduce((t,n)=>t+(u[n.id]||[]).filter(c=>c.status==="Available").length,0),la=he?he.total:U.reduce((t,n)=>t+(u[n.id]||[]).length,0),ws=new Set(U.map(t=>String(t.id)));l.filter(t=>ws.has(t.selectedProjectId)).filter(t=>t.status==="Registered").length;const rs=t=>{!a||t===null||(h(!0),H(null),Ar(a,t).then(n=>{E(c=>({...c,[t]:n.map(S=>In(S))})),T(c=>({...c,[t]:!0}))}).catch(n=>{console.warn("Could not load inventory from backend:",n),H("Could not load inventory. Please try again."),T(c=>({...c,[t]:!0}))}).finally(()=>h(!1)))},Bs=_n.useRef(new Set);r.useEffect(()=>{!a||U.length===0||!as||he||U.forEach(t=>{w[t.id]||Bs.current.has(t.id)||(Bs.current.add(t.id),Ar(a,t.id).then(n=>{E(c=>({...c,[t.id]:n.map(S=>In(S,String(t.id)))})),T(c=>({...c,[t.id]:!0}))}).catch(n=>{console.warn(`Could not background-load inventory for listing #${t.id}:`,n),T(c=>({...c,[t.id]:!0}))}))})},[a,U,as,he]);const[kt,Ct]=r.useState(null),[Ss,Os]=r.useState(!1),[ke,bt]=r.useState("introduced"),[Te,ks]=r.useState(0),[ls,_s]=r.useState([]),[Ft,_t]=r.useState(!1),[Tt,ns]=r.useState(null),[Dt,na]=r.useState("all"),[tt,oa]=r.useState(null),[it,qs]=r.useState(null),[ge,qt]=r.useState(null),[Vt,zt]=r.useState([]),[os,Cs]=r.useState(!1),[Pt,It]=r.useState(null),[is,Ht]=r.useState(!1),[Rt,Wt]=r.useState(""),[ia,Kt]=r.useState(!1),[Gt,mt]=r.useState(""),[Ps,Vs]=r.useState(!1),ds=r.useCallback(t=>{const n=a||null;n&&(_t(!0),ns(null),Nn(n,t==="all"?void 0:{quick:t}).then(c=>_s(c.leads||[])).catch(c=>ns(c.message||"Failed to load your leads.")).finally(()=>_t(!1)),ui(n).then(oa).catch(()=>{}))},[a]);r.useEffect(()=>{ke==="introduced"&&ds(Dt)},[ke,Dt,ds]);const da=t=>{qs(t),It(null),Kt(!1),Wt(""),mt("");const n=a||null;n&&(Cs(!0),Bl(n,t).then(c=>{qt(c.lead),zt(c.timeline||[])}).catch(c=>It(c.message||"Failed to load this lead.")).finally(()=>Cs(!1)))},cs=()=>{qs(null),qt(null),zt([])},ca=async(t,n)=>{if(!ge||!it)return;const c=a||null;if(c){Ht(!0),It(null);try{const S=await vn(c,it,{status:t,reason:n});qt(ae=>ae?{...ae,...S.lead}:S.lead),Kt(!1),Wt("");const k=await Bl(c,it);zt(k.timeline||[]),ds(Dt),b("Lead status updated.")}catch(S){It(S.message||"Failed to update this lead.")}finally{Ht(!1)}}},xa=async()=>{if(!Gt.trim()||!it)return;const t=a||null;if(t){Vs(!0),It(null);try{await vn(t,it,{note:Gt.trim()}),mt("");const n=await Bl(t,it);qt(n.lead),zt(n.timeline||[]),ds(Dt)}catch(n){It(n.message||"Failed to add note.")}finally{Vs(!1)}}},zs={new:["contacted","not_interested"],contacted:["site_visit_booked","negotiating","not_interested"],site_visit_booked:["negotiating","booked","not_interested"],negotiating:["booked","not_interested"],booked:[],not_interested:[]},Yt={new:"New",contacted:"Contacted",site_visit_booked:"Site visit booked",negotiating:"Negotiating",booked:"Booked",not_interested:"Not interested"},[d,Z]=r.useState([]),[ee,Ee]=r.useState(!1),[ze,Ye]=r.useState(null),[pt,At]=r.useState(null),[Lt,xs]=r.useState({}),[Ut,pa]=r.useState(null),Hs=r.useCallback(()=>{a&&(Ee(!0),Ye(null),hi(a).then(t=>Z(i===null?t:t.filter(n=>n.projectId===i))).catch(t=>Ye(t.message||"Failed to load booking claims.")).finally(()=>Ee(!1)))},[a,i]);r.useEffect(()=>{ke==="booking-claims"&&Hs()},[ke,Hs]);const Er=async t=>{if(a){At(t);try{await wi(a,t),b("Booking claim confirmed â a real booking has been created. Commission accrues once the buyer completes the token payment."),pa(null),Hs()}catch(n){Ye(n.message||"Failed to confirm booking claim.")}finally{At(null)}}},Fr=async t=>{if(!a)return;const n=(Lt[t]||"").trim();if(!n){Ye("A rejection reason is required.");return}At(t);try{await Si(a,t,n),b("Booking claim rejected."),xs(c=>({...c,[t]:""})),Hs()}catch(c){Ye(c.message||"Failed to reject booking claim.")}finally{At(null)}},[dt,Wa]=r.useState({loaded:!1,error:null,companyName:null,phone:null,requestStatus:null});r.useEffect(()=>{if(x!=="account"||!a||dt.loaded)return;let t=!1;return(async()=>{try{const n=await rt(a),[c,S]=await Promise.all([fetch("/api/user/builder-access-request/mine",{headers:n}),fetch("/api/user/me",{headers:n})]),k=c.ok?await c.json():null,ae=S.ok?await S.json():null;if(t)return;Wa({loaded:!0,error:c.ok||c.status===404?null:"Could not load your company details.",companyName:(k==null?void 0:k.companyName)??null,phone:(k==null?void 0:k.phone)??(ae==null?void 0:ae.phone)??(ae==null?void 0:ae.phoneE164)??null,requestStatus:(k==null?void 0:k.status)??null})}catch{t||Wa(n=>({...n,loaded:!0,error:"Could not load your company details."}))}})(),()=>{t=!0}},[x,a]);const[Ka,Sl]=r.useState([]),[Rs,ma]=r.useState(!1),[gt,ua]=r.useState("activity"),Tr=t=>{a&&(Os(!0),Gn(a,t).then(n=>{Ct(n)}).catch(()=>{Ct(null)}).finally(()=>{Os(!1)}))};r.useEffect(()=>{i!==null&&(rs(i),Tr(i))},[a,i]),r.useEffect(()=>{if(ha([]),Ks(null),!a||i===null)return;let t=!1;return(async()=>{try{const n=await rt(a),c=await fetch(`/api/projects/${i}/towers`,{headers:n});if(!c.ok)return;const S=await c.json();!t&&Array.isArray(S)&&ha(S.filter(k=>typeof(k==null?void 0:k.id)=="number").map(k=>({id:k.id,name:String(k.name??`Tower ${k.id}`)})))}catch{}})(),()=>{t=!0}},[a,i]);const W=U.find(t=>
20t.id===i)??null,De=zn(W==null?void 0:W.propertyType),[He,As]=r.useState(null),[Ws,Ga]=r.useState(""),[ps,Dr]=r.useState([]),[Ir,Ks]=r.useState(null),[Ls,ha]=r.useState([]),[ba,ga]=r.useState("All"),[fa,ja]=r.useState("All"),[Gs,ya]=r.useState(!0),Ur=l.filter(t=>i!==null&&t.selectedProjectId===String(i)),[Ya,Ys]=r.useState(!1),Na={unitNumber:"",floor:"",bhk:"",sizeSqFt:"",towerId:"",facing:"",isCorner:!1,hasView:!1},[Me,ft]=r.useState(Na),[Xa,Xt]=r.useState(null),[Za,va]=r.useState(!1),$r=async t=>{if(t.preventDefault(),!Me.unitNumber.trim()||!Me.sizeSqFt.trim()){Xt("Unit number and size are required.");return}if(i===null){Xt("No project selected.");return}va(!0),Xt(null);try{const n={projectId:i,unitNumber:Me.unitNumber.trim(),sizeSqFt:parseInt(Me.sizeSqFt,10),status:"Available",isCorner:Me.isCorner,hasViewPremium:Me.hasView};Me.floor&&(n.floor=parseInt(Me.floor,10)),Me.bhk&&(n.bhk=parseInt(Me.bhk,10)),Me.facing&&(n.facing=Me.facing),Me.towerId&&(n.towerId=parseInt(Me.towerId,10));const c=await rt(a),S=await fetch("/api/inventory",{method:"POST",headers:{"Content-Type":"application/json",...c},body:JSON.stringify(n)});if(!S.ok){const k=await S.json().catch(()=>({}));throw new Error(k.error||"Failed to add unit.")}ft(Na),Ys(!1),b("Unit added successfully!"),rs(i)}catch(n){Xt(n.message||"Failed to add unit. Please try again.")}finally{va(!1)}},[jt,$t]=r.useState([]),[Ja,wa]=r.useState(!1),[Sa,Qa]=r.useState(!1),[ka,yt]=r.useState(null),[Ca,er]=r.useState(!1);r.useEffect(()=>{if($t([]),wa(!1),!a||i===null)return;let t=!1;return er(!0),yt(null),(async()=>{try{const n=await rt(a),c=await fetch(`/api/projects/${i}/payment-plan`,{headers:n});if(!c.ok)throw new Error("Could not load the saved payment plan.");const S=await c.json();if(t)return;zi(S)&&Array.isArray(S.milestones)&&S.milestones.length>0&&($t(S.milestones.map(k=>({id:Wl(),name:String(k.name??""),percentage:Number(k.percentage)||0,isCore:!!k.isCore}))),wa(!0))}catch(n){t||yt((n==null?void 0:n.message)||"Could not load the saved payment plan.")}finally{t||er(!1)}})(),()=>{t=!0}},[a,i]);const[Pa,Mr]=r.useState(!1),[tr,Xs]=r.useState(null),[ms,sr]=r.useState(""),[Ra,ar]=r.useState(!1),[Aa,La]=r.useState(null),[us,rr]=r.useState([]),[Es,Br]=r.useState(!1),[Ea,lr]=r.useState(null),[Or,_r]=r.useState(0),[Fa,qr]=r.useState(null),[Ta,Vr]=r.useState(!1),Fs=Fa!==null,[zr,Da]=r.useState(null),[Hr,Wr]=r.useState(!1),[Ts,Re]=r.useState(null),[Kr,Ds]=r.useState(Od()),[,nr]=r.useState(null),[Is,or]=r.useState(null),[ir,dr]=r.useState(null),[hs,Zs]=r.useState(!1),[ut,Gr]=r.useState([]),[cr,Ia]=r.useState(!1),[Js,xr]=r.useState(null),[Nt,Yr]=r.useState(""),[Mt,Qs]=r.useState(null),[Ua,pr]=r.useState([]),[st,$a]=r.useState(null),[We,Zt]=r.useState({status:"Under Construction",basePricePerSqFt:"",propertyType:"",imageUrl:"",sizeRange:"",priceRange:"",amenities:""}),[Xr,Ma]=r.useState(!1),[Zr,mr]=r.useState(null),[Jr,Qr]=r.useState(!1),[el,kl]=r.useState(!1),tl=[{name:"RERA Registration",status:"pending"},{name:"HMDA/GHMC Building Permission",status:"pending"},{name:"NALA Conversion",status:"pending"},{name:"Environmental Clearance",status:"pending"},{name:"Fire NOC",status:"pending"},{name:"Occupancy Certificate",status:"na"}],[Be,Qe]=r.useState({brochureUrl:"",walkthroughVideoUrl:"",reraApplicationUrl:"",galleryImages:[],floorPlans:[],videoClips:[]}),[Ke,lt]=r.useState({}),[ht,ur]=r.useState({}),[bs,ea]=r.useState(""),[Jt,s]=r.useState(""),[p,P]=r.useState(""),[we,fe]=r.useState(""),[_,gs]=r.useState(""),[Oe,nt]=r.useState(""),[ct,Us]=r.useState(""),[ta,fs]=r.useState(""),[Et,hr]=r.useState(!1),[ye,Ze]=r.useState({promoterName:"",totalLandAreaAcre:"",openSpacePct:"",towers:"",totalUnits:"",commencementDate:"",possessionDate:"",constructionProgressPct:"",specifications:"",approvals:tl}),br=async(t,n,c,S)=>{const k=c;lt(ae=>({...ae,[k]:"uploading"})),ur(ae=>{const Se={...ae};return delete Se[k],Se});try{const ae=await ra(t,`projects/${n}/${c}-${Date.now()}`);S(ae),lt(Se=>({...Se,[k]:"done"}))}catch(ae){lt(Se=>({...Se,[k]:"error"})),ur(Se=>({...Se,[k]:(ae==null?void 0:ae.message)||"Upload failed"}))}},sl=t=>{$a(t.id),Zt({status:t.status||"Under Construction",basePricePerSqFt:t.basePricePerSqFt!=null?String(t.basePricePerSqFt):"",propertyType:t.propertyType||"",imageUrl:t.imageUrl||"",sizeRange:t.sizeRange||"",priceRange:t.priceRange||"",amenities:t.amenities?t.amenities.join(", "):""});const n=t.media;Qe({brochureUrl:(n==null?void 0:n.brochureUrl)||"",walkthroughVideoUrl:(n==null?void 0:n.walkthroughVideoUrl)||"",reraApplicationUrl:(n==null?void 0:n.reraApplicationUrl)||"",galleryImages:n!=null&&n.galleryImages?[...n.galleryImages]:[],floorPlans:n!=null&&n.floorPlans?n.floorPlans.map(S=>({label:S.label,url:S.url})):[],videoClips:n!=null&&n.videoClips?n.videoClips.map(S=>({label:S.label,url:S.url||"",startSec:S.startSec,endSec:S.endSec})):[]});const c=t.reraDetails;Ze({promoterName:(c==null?void 0:c.promoterName)||"",totalLandAreaAcre:(c==null?void 0:c.totalLandAreaAcre)!=null?String(c.totalLandAreaAcre):"",openSpacePct:(c==null?void 0:c.openSpacePct)!=null?String(c.openSpacePct):"",towers:(c==null?void 0:c.towers)!=null?String(c.towers):"",totalUnits:(c==null?void 0:c.totalUnits)!=null?String(c.totalUnits):"",commencementDate:(c==null?void 0:c.commencementDate)||"",possessionDate:(c==null?void 0:c.possessionDate)||"",constructionProgressPct:(c==null?void 0:c.constructionProgressPct)!=null?String(c.constructionProgressPct):"",specifications:c!=null&&c.specifications?c.specifications.join(", "):"",approvals:c!=null&&c.approvals&&c.approvals.length>0?c.approvals.map(S=>({name:S.name,status:S.status,docUrl:S.docUrl})):tl}),lt({}),ur({}),ea(""),s(""),P(""),fe(""),gs(""),mr(null)},to=async t=>{if(t.preventDefault(),!!st){Ma(!0),mr(null);try{const n={};Be.brochureUrl.trim()&&(n.brochureUrl=Be.brochureUrl.trim()),Be.walkthroughVideoUrl.trim()&&(n.walkthroughVideoUrl=Be.walkthroughVideoUrl.trim()),Be.reraApplicationUrl.trim()&&(n.reraApplicationUrl=Be.reraApplicationUrl.trim()),Be.galleryImages.length>0&&(n.galleryImages=Be.galleryImages),Be.floorPlans.length>0&&(n.floorPlans=Be.floorPlans),Be.videoClips.length>0&&(n.videoClips=qi(Be.videoClips));const c=Object.keys(n).length>0,S={};ye.promoterName.trim()&&(S.promoterName=ye.promoterName.trim()),ye.totalLandAreaAcre&&(S.totalLandAreaAcre=parseFloat(ye.totalLandAreaAcre)),ye.openSpacePct&&(S.openSpacePct=parseFloat(ye.openSpacePct)),ye.towers&&(S.towers=p
20arseInt(ye.towers)),ye.totalUnits&&(S.totalUnits=parseInt(ye.totalUnits)),ye.commencementDate.trim()&&(S.commencementDate=ye.commencementDate.trim()),ye.possessionDate.trim()&&(S.possessionDate=ye.possessionDate.trim()),ye.constructionProgressPct&&(S.constructionProgressPct=parseInt(ye.constructionProgressPct)),ye.specifications.trim()&&(S.specifications=ye.specifications.split(",").map(ae=>ae.trim()).filter(Boolean)),ye.approvals.length>0&&(S.approvals=ye.approvals);const k=Object.keys(S).length>0;await Lr(a,st,{status:We.status,basePricePerSqFt:We.basePricePerSqFt?parseFloat(We.basePricePerSqFt):void 0,...We.propertyType?{propertyType:We.propertyType}:{},...We.imageUrl?{imageUrl:We.imageUrl}:{},...We.sizeRange?{sizeRange:We.sizeRange}:{},...We.priceRange?{priceRange:We.priceRange}:{},...We.amenities?{amenities:We.amenities.split(",").map(ae=>ae.trim()).filter(Boolean)}:{},...c?{media:n}:{},...k?{reraDetails:S}:{}}),b("Commercial details (incl. media & RERA details) submitted â pending admin approval."),$a(null),js()}catch(n){mr(vl(n,"Failed to save commercial details."))}finally{Ma(!1)}}},gr=()=>{Ia(!0),xr(null),ki().then(Gr).catch(t=>xr(t.message||"Failed to load RERA projects.")).finally(()=>Ia(!1))},fr=r.useCallback(()=>{a&&bi(a).then(pr).catch(t=>console.warn("Could not load project claims:",t))},[a]);r.useEffect(()=>{fr()},[fr]);const so=()=>{Zs(!1),Yr(""),Qs(null)};r.useEffect(()=>{te&&(D("my-listings"),Zs(!0),ut.length===0&&gr(),V==null||V())},[te]);const al=ut.filter(t=>{if(!Nt.trim())return!0;const n=Nt.toLowerCase();return t.name.toLowerCase().includes(n)||(t.location||"").toLowerCase().includes(n)||(t.district||"").toLowerCase().includes(n)||(t.reraNumber||"").toLowerCase().includes(n)}).slice(0,25);function ao(t){switch(t){case"none":return{label:"No Commercial Details",cls:"bg-slate-100 text-slate-500 border border-slate-200"};case"pending":return{label:"Commercial Pending Review",cls:"bg-amber-50 text-amber-700 border border-amber-200"};case"approved":return{label:"Commercial Approved",cls:"bg-emerald-50 text-emerald-700 border border-emerald-200"};case"rejected":return{label:"Commercial Rejected",cls:"bg-rose-50 text-rose-700 border border-rose-200"}}}const js=()=>{const t=a||null;t&&(Br(!0),lr(null),Tn(t,{limit:50}).then(n=>{const c=n.listings;_r(n.pagination.total),qr(n.pagination.nextOffset);const S=Array.isArray(c)?c:[];rr(S),ie(k=>Dn(k,S)),S.length>0&&i===null&&O(S[0].id)}).catch(n=>lr(n.message||"Failed to load listings.")).finally(()=>Br(!1)))},ro=()=>{if(Fa===null||Ta)return;const t=a||null;t&&(Vr(!0),Tn(t,{limit:50,offset:Fa}).then(n=>{rr(c=>{const S=new Set(c.map(k=>k.id));return[...c,...n.listings.filter(k=>!S.has(k.id))]}),ie(c=>Dn(c,n.listings)),_r(n.pagination.total),qr(n.pagination.nextOffset)}).catch(n=>lr(n.message||"Failed to load more listings.")).finally(()=>Vr(!1)))},[Cl,lo]=r.useState({});r.useEffect(()=>{const t=us.map(c=>c.id).filter(c=>Cl[c]===void 0).slice(0,50);if(t.length===0)return;let n=!1;return Td(a||null,t).then(c=>{if(n)return;const S={};for(const[k,ae]of Object.entries(c))ae.completenessPct!=null&&(S[Number(k)]=ae.completenessPct);Object.keys(S).length>0&&lo(k=>({...k,...S}))}).catch(()=>{}),()=>{n=!0}},[us]);const Ba={};for(const t of l){const n=Number(t.selectedProjectId);n&&(Ba[n]=(Ba[n]||0)+1)}if(Dt==="all")for(const t of ls)Ba[t.projectId]=(Ba[t.projectId]||0)+1;const jr=()=>{const t=a||null;t&&(ve(!0),Ci(t).then(n=>{Je(n)}).catch(n=>console.error("Failed to load builder concierge requests:",n)).finally(()=>ve(!1)))},Pl=()=>{const t=a||null;t&&(ma(!0),Pi(t,15).then(n=>{Sl(n||[])}).catch(n=>console.error("Failed to load builder activities:",n)).finally(()=>ma(!1)))};r.useEffect(()=>{js(),x==="deal-desk"&&jr(),Pl();const t=a||null;t&&Nn(t,{quick:"new"}).then(n=>ks(n.count)).catch(()=>{})},[a,x]),r.useEffect(()=>{gt==="map"&&ut.length===0&&gr()},[gt,ut.length]);const Rl=t=>{var n,c,S,k,ae,Se,_e,at,f,A,oe,be,X,Ne,ll,nl,ol,il,dl,Nr;Ds({name:t.name,location:t.location,region:t.region,reraNumber:t.reraNumber,status:t.status||"Under Construction",basePricePerSqFt:String(t.basePricePerSqFt||""),latitude:t.latitude!=null?String(t.latitude):"",longitude:t.longitude!=null?String(t.longitude):"",brochureUrl:((n=t.media)==null?void 0:n.brochureUrl)||"",walkthroughVideoUrl:((c=t.media)==null?void 0:c.walkthroughVideoUrl)||"",reraApplicationUrl:((S=t.media)==null?void 0:S.reraApplicationUrl)||"",priceSheetUrl:((k=t.media)==null?void 0:k.priceSheetUrl)||"",galleryImages:((ae=t.media)==null?void 0:ae.galleryImages)||[],videoClips:((Se=t.media)==null?void 0:Se.videoClips)||[],floorRiseStartFloor:(A=(f=(at=(_e=t.priceSheet)==null?void 0:_e.plans)==null?void 0:at[0])==null?void 0:f.floorRise)!=null&&A.startFloor?String(t.priceSheet.plans[0].floorRise.startFloor):"",floorRiseRatePerSft:(Ne=(X=(be=(oe=t.priceSheet)==null?void 0:oe.plans)==null?void 0:be[0])==null?void 0:X.floorRise)!=null&&Ne.ratePerSftPerFloor?String(t.priceSheet.plans[0].floorRise.ratePerSftPerFloor):"",premiums:((ol=(nl=(ll=t.priceSheet)==null?void 0:ll.plans)==null?void 0:nl[0])==null?void 0:ol.premiums)||[],parkingRules:((Nr=(dl=(il
20=t.priceSheet)==null?void 0:il.plans)==null?void 0:dl[0])==null?void 0:Nr.parkingRules)||[]}),nr(null),Wr(jd(t)),Da(t.id)},no=async t=>{or(t.id),dr(null);try{await Kn(a,t.id),b(`"${t.name}" submitted for Realtified admin review.`),js()}catch(n){dr(n.message||"Failed to submit for review.")}finally{or(null)}},Al=async(t,n)=>{if(i===null)return;const c=i,S=Dd(t),k=(u[c]||[]).find(_e=>_e.id===t);if(!a||S===null||!k){b("Could not update this unit: it is not synced with the server.");return}const ae=k.status,Se=_e=>{E(at=>({...at,[c]:(at[c]||[]).map(f=>f.id===t?{...f,status:_e}:f)})),As(at=>at&&at.id===t?{...at,status:_e}:at)};Se(n);try{await Wn(a,S,{status:n}),b(`Unit ${k.number} marked ${n}.`)}catch(_e){Se(ae),b(`Could not mark unit ${k.number} as ${n}: ${(_e==null?void 0:_e.message)||"the server rejected the change"}. It is still ${ae}.`)}},Zl=async(t,n)=>{const c=await rt(a),S=await fetch(`/api/projects/${t}/price`,{method:"PATCH",headers:{"Content-Type":"application/json",...c},body:JSON.stringify(n)}),k=await S.json().catch(()=>({}));if(!S.ok)throw new Error((k==null?void 0:k.error)||"Failed to save.");return k},oo=async t=>{t.preventDefault();const n=parseInt(Ws);if(isNaN(n)||n<=0){Xs("Please enter a valid price.");return}if(i===null||!a){Xs("Select a project first.");return}Xs(null),Mr(!0);try{const c=await Zl(i,{basePricePerSqFt:n}),S=_i(c,(W==null?void 0:W.name)??"project",n);F({...y,[i]:n}),Dr(k=>[{date:new Date().toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),rate:n,status:S.status,author:"Builder Console"},...k]),b(S.message),Ga(""),js()}catch(c){Xs(c.message||"Failed to update price. Please try again.")}finally{Mr(!1)}},io=async t=>{t.preventDefault();const n=parseFloat(ms);if(isNaN(n)||n<0||n>10){La("Commission must be between 0 and 10.");return}if(!(i===null||!a)){La(null),ar(!0);try{const c=await Zl(i,{commissionPct:n});b(`Commission for ${(W==null?void 0:W.name)??"project"} set to ${n}%${c.commercialStatus==="pending"?" and submitted for review":""}. Partners receive ${Ol(n)}% after the platform share.`),sr(""),js()}catch(c){La(c.message||"Failed to save commission rate.")}finally{ar(!1)}}},Jl=(t,n)=>{$t(c=>c.map(S=>S.id===t?{...S,percentage:n}:S))},co=(t,n)=>{$t(c=>c.map(S=>S.id===t?{...S,name:n}:S))},xo=()=>{$t(t=>[...t,{id:Wl(),name:"",percentage:0,isCore:!1}])},po=t=>{$t(n=>n.filter(c=>c.id!==t))},mo=()=>{$t([]),yt(null)},uo=t=>{$t(Hi(t)),yt(null),b(`Loaded the ${gl[t].label} template. Edit the stages, then save.`)},ys=Vi(jt),ho=async()=>{if(jt.length===0){yt("Add at least one stage before saving.");return}if(jt.some(t=>!t.name.trim())){yt("Every stage needs a name.");return}if(Math.abs(ys-100)>.01){yt(`Percentages must sum to 100% â currently ${ys}%.`);return}if(i===null||!a){yt("Cannot save: no project selected or not authenticated.");return}yt(null),Qa(!0);try{const t=await rt(a),n=await fetch(`/api/projects/${i}/payment-plan`,{method:"PUT",headers:{"Content-Type":"application/json",...t},body:JSON.stringify({milestones:jt.map(c=>({name:c.name.trim(),percentage:c.percentage,isCore:c.isCore}))})});if(!n.ok){const c=await n.json().catch(()=>({}));throw new Error(c.error||"Failed to save payment plan.")}wa(!0),b("Payment plan saved.")}catch(t){yt(t.message||"Failed to save payment plan. Ensure percentages sum to 100%.")}finally{Qa(!1)}},vt=(i!==null?u[i]:void 0)||[],Ql=vt.map(t=>({number:t.number,towerId:t.towerId})),yr=Wi(Ql,Ls),rl=yr.length>0&&Ql.some(t=>Cn(t,yr)===null)?[...yr,{key:"none",label:"No tower"}]:yr,Qt=rl.find(t=>t.key===Ir)??rl[0]??null,en=Ki(vt.map(t=>t.type)),bo=vt.filter(t=>t.status==="Available").length,go=vt.filter(t=>t.status==="Blocked").length;vt.filter(t=>t.status==="Hold").length;const fo=vt.filter(t=>t.status==="Sold").length,jo=vt.length,Ll=Math.round(fo/jo*100)||0;return new Set(vt.map(t=>t.floor)).size,Ur.length,U.length,e.jsx("div",{className:"w-full h-full flex flex-col overflow-hidden",children:e.jsxs("div",{className:"flex flex-col lg:flex-row h-full bg-slate-50 overflow-hidden",children:[e.jsxs("div",{className:`hidden lg:flex ${Q?"lg:w-[72px]":"lg:w-64"} lg:shrink-0 bg-white lg:border-r border-slate-200 flex-col p-4 space-y-4 overflow-hidden text-left transition-all duration-200`,children:[e.jsxs("div",{className:`flex items-center justify-between pb-3.5 border-b border-slate-100 shrink-0 select-none ${Q?"flex-col gap-2":""}`,children:[e.jsx("div",{className:"cursor-pointer",onClick:()=>v==null?void 0:v("home"),children:Q?e.jsx("img",{src:"/icon.png",alt:"Realtified",className:"h-7 w-7 object-contain"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/logo.png?v=2026",alt:"Realtified",className:"h-[28px] object-contain"}),e.jsx("span",{className:"text-[9.5px] bg-brand-50 text-brand-700 border border-brand-100 px-1.5 py-0.5 rounded-md font-mono font-extrabold select-none leading-none",children:"BUILDER"})]})}),e.jsx("button",{onClick:()=>Ie(!Q),className:"p-1.5 hover:bg-slate-100 border border-slate-200/60 rounded-lg text-slate-400 hover:text-slate-600 cursor-pointer hidden lg:flex shrink-0 items-center justify-center",title:Q?"Expand Sidebar":"Collapse Sidebar",children:e.jsx(Va,{className:`w-3.5 h-3.5 transition-transform duration-200 ${Q?"":"rotate-180"}`})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-none space-y-4",children:[!Q&&x==="pricing-inventory"&&e.jsxs("div",{className:"bg-slate-950 p-2.5 border border-slate-900 rounded-xl flex flex-col gap-1 text-left shrink-0",children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-500 uppercase tracking-wider",children:"ACTIVE PROJECT"}),I?e.jsx("span",{className:"text-[10px] text-slate-400 font-mono",children:"Loading projectsâ¦"}):U.length===0?e.jsx("span",{className:"text-[10px] text-amber-400 font-mono",children:"No claimed projects. Claim one in My Listings."}):e.jsx("select",{value:i??"",onChange:t=>{const n=parseInt(t.target.value,10);O(isNaN(n)?null:n),As(null)},className:"px-2 py-1 bg-slate-900 border border-slate-800 hover:border-slate-700 rounded-lg text-[11px] font-bold text-white w-full outline-none cursor-pointer focus:border-brand-500 transition-colors",children:U.map(t=>e.jsxs("option",{value:t.id,children:[t.name," (",t.location,")"]},t.id))})]}),e.jsxs("div",{className:"space-y-1 text-left flex-1 shrink-0",children:[!Q&&e.jsx("span",{className:"text-[9px] text-slate-400 font-mono font-bold uppercase tracking-wider px-2 block mb-1",children:"BUILDER MENU"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("button",{onClick:()=>D("home"),className:`w-full p-1.5 rounded-lg text-left text-xs font-bold transition-all flex items-center gap-2 cursor-pointer ${x==="home"?"bg-brand-500 text-white shadow-md shadow-brand-500/10":"text-slate-600 hover:bg-slate-50 border border-transparent"} ${Q?"justify-center px-2":""}`,title:"Overview",children:[e.jsx(nn,{className:`w-4 h-4 shrink-0 ${x==="home"?"text-white":"text-slate-400"}`}),!Q&&e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate leading-tight font-sans",children:"Overview"}),e.jsx("p",{className:`text-[8px] font-mono font-normal uppercase mt-0.5 truncate leading-none ${x==="home"?"text-brand-100":"text-slate-400"}`,children:"Performance & activity"})]})]}),e.jsxs("button",{onClick:()=>D("my-listings"),className:`w-full p-1.5 rounded-lg text-left text-xs font-bold transition-all flex items-center gap-2 cursor-pointer ${x==="my-listings"||x==="pricing-inventory"?"bg-brand-500 text-white shadow-md shadow-brand-500/10":"text-slate-600 hover:bg-slate-50 border border-transparent"} ${Q?"justify-center px-2":""}`,title:"Listings",children:[e.jsx(on,{className:`w-4 h-4 shrink-0 ${x==="my-listings"||x==="pricing-inventory"?"text-white":"text-slate-400"}`}),!Q&&e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate leading-tight font-sans",children:"Listings"}),e.jsx("p",{className:`text-[8px] font-mono font-normal uppercase mt-0.5 truncate leading-none ${x==="my-listings"||x==="pricing-inventory"?"text-brand-100":"text-slate-400"}`,children:"Your projects & inventory"})]})]}),e.jsxs("button",{onClick:()=>D("leads"),className:`w-full p-1.5 rounded-lg text-left text-xs font-bold transition-all flex items-center gap-2 cursor-pointer ${x==="leads"?"bg-brand-500 text-white shadow-md shadow-brand-500/10":"text-slate-600 hover:bg-slate-50 border border-transparent"} ${Q?"justify-center px-2":""}`,title:"Leads",children:[e.jsx(vr,{className:`w-4 h-4 shrink-0 ${x==="leads"?"text-white":"text-slate-400"}`}),!Q&&e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate leading-tight font-sans",children:"Leads"}),e.jsx("p",{className:`text-[8px] font-mono font-normal uppercase mt-0.5 truncate leading-none ${x==="leads"?"text-brand-100":"text-slate-400"}`,children:"Buyer enquiries & agent referrals"})]})]}),e.jsxs("button",{onClick:()=>D("team"),className:`w-full p-1.5 rounded-lg text-left text-xs font-bold transition-all flex items-center gap-2 cursor-pointer ${x==="team"?"bg-brand-500 text-white shadow-md shadow-brand-500/10":"text-slate-600 hover:bg-slate-50 border border-transparent"} ${Q?"justify-center px-2":""}`,title:"Team",children:[e.jsx(Fl,{className:`w-4 h-4 shrink-0 ${x==="team"?"text-white":"text-slate-400"}`}),!Q&&e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate leading-tight font-sans",children:"Team"}),e.jsx("p",{className:`text-[8px] font-mono font-normal uppercase mt-0.5 truncate leading-none ${x==="team"?"text-brand-100":"text-slate-400"}`,children:"Invite teammates â coming soon"})]})]}),e.jsxs("button",{onClick:()=>D("account"),className:`w-full p-1.5 rounded-lg text-left text-xs font-bold transition-all flex items-center gap-2 cursor-pointer ${x==="account"?"bg-brand-500 text-white shadow-md shadow-brand-500/10":"text-slate-600 hover:bg-slate-50 border border-transparent"} ${Q?"justify-center px-2":""}`,title:"Account",children:[e.jsx(Tl,{className:`w-4 h-4 shrink-0 ${x==="account"?"text-white":"text-slate-400"}`}),!Q&&e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate leading-tight font-sans",children:"Account"}),e.jsx("p",{className:`text-[8px] font-mono font-normal uppercase mt-0.5 truncate leading-none ${x==="account"?"text-brand-100":"text-slate-400"}`,children:"Profile & sign out"})]})]}),wr("dealRoom")&&e.jsxs("button",{onClick:()=>D("deal-desk"),className:`w-full p-1.5 rounded-lg text-left text-xs font-bold transition-all flex items-center gap-2 cursor-pointer ${x==="deal-desk"?"bg-brand-500 text-white shadow-md shadow-brand-500/10":"text-slate-600 hover:bg-slate-50 border border-transparent"} ${Q?"justify-center px-2":""}`,title:"Sales & Deals",children:[e.jsx(qa,{className:`w-4 h-4 shrink-0 ${x==="deal-desk"?"text-white":"text-slate-400"}`}),!Q&&e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate leading-tight font-sans",children:"Sales & Deals"}),e.jsx("p",{className:`text-[8px] font-mono font-normal uppercase mt-0.5 truncate leading-none ${x==="deal-desk"?"text-brand-100":"text-slate-400"}`,children:"Kanban board & offers"})]})]})]})]})]}),e.jsxs("div",{className:"pt-3 border-t border-slate-100 flex flex-col gap-1 shrink-0 text-left",children:[e.jsxs("button",{onClick:()=>v==null?void 0:v("home"),className:`w-full py-2 px-3 border border-slate-200 hover:bg-slate-50 text-slate-700 font-bold rounded-xl text-xs flex items-center justify-start gap-2 cursor-pointer transition-colors ${Q?"
20justify-center px-2":""}`,title:"Back to Realtified",children:[e.jsx(cl,{className:"w-4 h-4 shrink-0 text-slate-400"}),!Q&&e.jsx("span",{children:"Back to Realtified"})]}),e.jsxs("button",{onClick:async()=>{try{await $l()}catch(t){console.error(t)}},className:`w-full py-2 px-3 border border-rose-200 hover:bg-rose-50 text-rose-600 font-bold rounded-xl text-xs flex items-center justify-start gap-2 cursor-pointer transition-colors ${Q?"justify-center px-2":""}`,title:"Sign Out",children:[e.jsx(Dl,{className:"w-4 h-4 shrink-0 text-rose-500"}),!Q&&e.jsx("span",{children:"Sign Out"})]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col h-full overflow-hidden p-4 lg:p-6 pb-[calc(4.25rem+env(safe-area-inset-bottom))] lg:pb-6 bg-slate-50/50 min-w-0",children:[e.jsxs("div",{className:"pb-4 border-b border-slate-200/60 flex flex-col lg:flex-row lg:items-center lg:justify-between gap-2 shrink-0",children:[e.jsxs("div",{className:"text-left w-full lg:w-auto",children:[e.jsx("h2",{className:"text-lg font-extrabold tracking-tight text-slate-900",children:x==="home"?"Overview":x==="pricing-inventory"?W?W.name:"Listing Inventory & Pricing":x==="leads"?"Leads":x==="my-listings"?"Listings":x==="team"?"Team":x==="account"?"Account":"Sales & Deals"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-0.5",children:x==="home"?"Your listings, new leads, and what needs your attention.":x==="pricing-inventory"?"Flat matrix, price sheets, rate rules, and RERA profile for this listing.":x==="leads"?"Buyers interested in your listings.":x==="my-listings"?"Your projects â open one to manage its inventory, pricing, and RERA profile.":x==="team"?"Invite teammates to your builder workspace.":x==="account"?"Your profile, workspace, and sign out.":"Review active negotiations, compose custom proposals, and audit booking status."})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-left",children:[e.jsxs("button",{type:"button",onClick:()=>{const t=!Gs;ya(t),t&&Pl()},className:`hidden lg:flex items-center gap-1.5 px-3 py-1.5 border rounded-xl hover:bg-slate-50 transition-all cursor-pointer text-xs font-bold ${Gs?"border-brand-500 bg-brand-50/20 text-brand-600 shadow-xs":"border-slate-200 text-slate-500"}`,title:"Toggle Workspace Tools Sidebar",children:[e.jsx(xl,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:Gs?"Hide Sidebar":"Show Sidebar"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>me(!J),className:"flex items-center gap-2.5 bg-white hover:bg-slate-50 px-3 py-2 border border-slate-200 rounded-xl transition-all cursor-pointer text-left shadow-xs active:scale-[0.98]",children:[e.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center font-bold text-xs text-white shadow-xs bg-brand-500 shrink-0 font-mono",children:((a==null?void 0:a.displayName)||(a==null?void 0:a.email)||"D").charAt(0).toUpperCase()}),e.jsx("div",{className:"flex flex-col text-left leading-none",children:e.jsxs("span",{className:"text-xs font-black text-slate-700 flex items-center gap-1 leading-none truncate max-w-[110px]",children:[(a==null?void 0:a.displayName)||"Account",e.jsx(bl,{className:"w-3 h-3 text-slate-400 shrink-0"})]})})]}),J&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>me(!1)}),e.jsxs("div",{className:"absolute right-0 mt-2 bg-white border border-slate-200/80 rounded-2xl shadow-xl p-2 z-40 text-slate-800 w-56 origin-top-right animate-in fade-in slide-in-from-top-1 duration-100",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-100 mb-1.5 text-left font-sans",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-800 truncate",children:(a==null?void 0:a.displayName)||"Developer Exec"}),e.jsx("p",{className:"text-[8.5px] text-slate-500 font-mono truncate",children:a==null?void 0:a.email})]}),e.jsx("span",{className:"text-[8px] font-mono font-bold text-slate-400 uppercase tracking-wider px-3 block mb-1",children:"Your workspace"}),e.jsxs("div",{className:"w-full flex items-center gap-2 px-3 py-2 text-xs font-bold rounded-xl bg-emerald-50 text-emerald-700 text-left mt-0.5 font-sans",children:[e.jsx("div",{className:"w-5 h-5 bg-emerald-100 text-emerald-700 rounded-md flex items-center justify-center text-[10px] font-bold shrink-0",children:"D"}),"Builder Console"]}),!1,e.jsx("div",{className:"border-t border-slate-100 my-1.5"}),e.jsxs("button",{onClick:async()=>{me(!1);try{await $l()}catch(t){console.error(t)}},className:"w-full flex items-center gap-2 px-3 py-2 text-xs font-bold text-rose-600 hover:bg-rose-50 hover:text-rose-700 rounded-xl transition-all cursor-pointer text-left mt-0.5 font-sans",children:[e.jsx(Dl,{className:"w-3.5 h-3.5 shrink-0"}
20),"Sign Out"]})]})]})]})]})]}),W&&x==="pricing-inventory"&&(()=>{const t=i!==null?y[i]||W.basePricePerSqFt:null;return e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-slate-500 font-semibold py-2 px-3 bg-white border border-slate-200/50 rounded-xl shadow-xs shrink-0 w-fit text-left",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(qa,{className:"w-3.5 h-3.5 text-brand-500"})," ",e.jsx("span",{className:"font-bold text-slate-800",children:W.name})]}),e.jsx("span",{className:"h-3 w-[1px] bg-slate-200 hidden sm:inline"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Cr,{className:"w-3.5 h-3.5 text-emerald-600"})," RERA: ",e.jsx("span",{className:"font-mono font-bold text-slate-700",children:gi(W.reraNumber,{fallbackLabel:yi(W.reraNumber)?ji:"Pending",registeredLabel:fi})})]}),e.jsx("span",{className:"h-3 w-[1px] bg-slate-200 hidden sm:inline"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Rr,{className:"w-3.5 h-3.5 text-slate-400"})," ",W.location,Md.includes(W.region)?` (${W.region} Hyderabad)`:""]}),t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-3 w-[1px] bg-slate-200 hidden sm:inline"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(dn,{className:"w-3.5 h-3.5 text-emerald-600 shrink-0"}),"Base Rate: ",e.jsxs("span",{className:"font-mono font-bold text-slate-800",children:["â¹",t.toLocaleString(),"/sqft"]})]})]}):null]})})(),e.jsxs("div",{className:"flex-1 flex overflow-hidden gap-6 mt-4 min-w-0",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-6 pr-1 scrollbar-none min-w-0",children:[x==="pricing-inventory"&&e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-4 shadow-xs text-left",children:[e.jsxs("button",{onClick:()=>D("my-listings"),className:"flex items-center gap-1 min-h-[40px] sm:min-h-0 -mt-2 mb-1 sm:mt-0 sm:mb-3 text-[10px] font-bold text-slate-400 hover:text-slate-700 cursor-pointer",children:[e.jsx(Va,{className:"w-3 h-3 rotate-180"})," Back to Listings"]}),e.jsxs("div",{className:"flex items-center gap-1 bg-slate-100 rounded-xl p-1 w-fit flex-wrap",children:[[{key:"matrix",label:"Flat Matrix",icon:pl},{key:"price-sheets",label:"Price Sheets",icon:Vl},{key:"pricing-rules",label:"Rate Rules",icon:dn},{key:"payment-milestones",label:"Milestone Schedules",icon:xl}].map(({key:t,label:n,icon:c})=>e.jsxs("button",{onClick:()=>de(t),className:`flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-bold rounded-lg transition-all cursor-pointer font-mono uppercase ${q===t?"bg-brand-500 text-white shadow-sm":"text-slate-500 hover:text-slate-800"}`,children:[e.jsx(c,{className:"w-3.5 h-3.5"})," ",n]},t)),e.jsxs("button",{onClick:()=>{W&&sl(W),D("my-listings")},disabled:!W,className:"flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-bold rounded-lg transition-all cursor-pointer font-mono uppercase text-slate-500 hover:text-slate-800 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Cr,{className:"w-3.5 h-3.5"})," RERA Profile"]})]}),i===null&&e.jsx("p",{className:"mt-3 text-[11px] text-amber-600 font-mono font-semibold",children:"No project selected â open a listing from the Listings tab."})]}),e.jsxs(es,{mode:"wait",children:[x==="home"&&(()=>{const t=[];return L&&t.push({key:"draft",text:`Finish your draft listing for ${L.name}.`,onClick:()=>{D("my-listings"),Rl(L)}}),Te>0&&t.push({key:"leads",text:`Respond to ${Te} new lead${Te===1?"":"s"}.`,onClick:()=>{D("leads"),bt("introduced")}}),pe&&t.push({key:"commercial",text:`Add pricing details for ${pe.name}.`,onClick:()=>{D("my-listings"),sl(pe)}}),je&&t.push({key:"rejected",text:`${je.name} was sent back â review the feedback and resubmit.`,onClick:()=>{D("my-listings"),Rl(je)}}),U.length===0&&t.push({key:"first-listing",text:"Add your first listing to get started.",onClick:()=>{D("my-listings"),Re("choose")}}),e.jsxs(Xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},className:"space-y-4 text-left",children:[e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-5 shadow-xs",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-slate-900 tracking-tight",children:["Welcome back, ",(a==null?void 0:a.displayName)||"there"]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Here's where things stand across your listings."})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-4 shadow-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-mono text-slate-400 uppercase tracking-wider font-extrabold",children:"Your listings"}),e.jsx(qa,{className:"w-4 h-4 text-slate-400"})]}),e.jsx("h4",{className:"text-2xl font-black text-slate-900 mt-1",children:z}),e.jsxs("div",{className:"flex items-center gap-2.5 mt-2 text-[10.5px] text-slate-500 font-semibold flex-wrap",children:[e.jsxs("span",{children:[se," live"]}),e.jsx("span",{className:"text-slate-300",children:"·"}),e.jsxs("span",{children:[Ge," under review"]}),e.jsx("span",{className:"text-slate-300",children:"·"}),e.jsxs("span",{children:[o," draft",o===1?"":"s"]})]})]}),e.jsxs("button",{onClick:()=>{D("leads"),bt("introduced")},className:"bg-white border border-slate-200 hover:border-indigo-300 rounded-2xl p-4 shadow-xs text-left transition-all cursor-pointer",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-mono text-slate-400 uppercase tracking-wider font-extrabold",children:"New leads"}),e.jsx(vr,{className:"w-4 h-4 text-indigo-500"})]}),e.jsx("h4",{className:"text-2xl font-black text-slate-900 mt-1",children:Te}),e.jsx("p",{className:"text-[10.5px] text-slate-500 mt-2",children:"Introduced buyers you haven't responded to yet"})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-4 shadow-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-mono text-slate-400 uppercase tracking-wider font-extrabold",children:"Homes available"}),e.jsx(cl,{className:"w-4 h-4 text-emerald-500"})]}),e.jsxs("h4",{className:"text-2xl font-black text-slate-900 mt-1",children:[vs," ",e.jsxs("span",{className:"text-sm font-semibold text-slate-400",children:["/ ",la]})]}),e.jsx("p",{className:"text-[10.5px] text-slate-500 mt-2",children:"Units available across your listings"})]})]}),e.jsxs("button",{onClick:()=>{D("my-listings"),Re("choose")},className:"flex items-center gap-2 px-5 py-3 bg-brand-500 hover:bg-brand-600 text-white text-sm font-bold rounded-2xl transition-all cursor-pointer shadow-xs",children:[e.jsx(Ot,{className:"w-4 h-4"}),"Add listing"]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-5 shadow-xs",children:[e.jsx("h4",{className:"text-sm font-extrabold text-slate-900",children:"What to do next"}),t.length===0?e.jsx("p",{className:"text-xs text-slate-400 mt-3",children:"Nothing waiting â you're all caught up."}):e.jsx("div",{className:"mt-3 space-y-2",children:t.map(n=>e.jsxs("button",{onClick:n.onClick,className:"w-full flex items-center gap-3 bg-slate-50 hover:bg-slate-100/70 border border-slate-200/60 rounded-xl px-4 py-3 text-left transition-all cursor-pointer",children:[e.jsx("span",{className:"flex-1 min-w-0 text-xs font-semibold text-slate-700",children:n.text}),e.jsx(Va,{className:"w-3.5 h-3.5 text-slate-300 shrink-0"})]},n.key))})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-5 shadow-xs",children:[e.jsx("h4",{className:"text-sm font-extrabold text-slate-900 mb-1",children:"Recent activity"}),e.jsx(hn,{activities:Ka,loading:Rs,emptyText:"No recent activity yet.",maxRows:6})]})]},"dashboard-home")})(),x==="pricing-inventory"&&q==="matrix"&&e.jsxs(Xe.div,{initial:{opacity:0,y:10}
20,animate:{opacity:1,y:0},exit:{opacity:0},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4 text-left",children:[e.jsx(Ul,{label:"Available Units",value:bo,sublabel:"Ready for booking",icon:pl,accent:"emerald"}),e.jsx(Ul,{label:"Blocked Units",value:go,sublabel:"Under discussion / soft block",icon:cn,accent:"brand"}),e.jsx(Ul,{label:(W==null?void 0:W.approvalStatus)==="draft"?"Base rate (draft)":(W==null?void 0:W.approvalStatus)==="approved"&&W.commercialStatus==="approved"?"Published Base Rate":"Base rate (not yet published)",value:i!==null&&(y[i]||W!=null&&W.basePricePerSqFt)?`â¹${(y[i]||W.basePricePerSqFt).toLocaleString()}/sqft`:"â",sublabel:(W==null?void 0:W.approvalStatus)==="approved"&&W.commercialStatus==="approved"?"Standard rate card":"Not visible to buyers yet",icon:Po,accent:"slate"}),e.jsxs("div",{className:"bg-white border border-slate-200/60 rounded-2xl p-4 shadow-xs flex flex-col justify-between",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 font-mono uppercase tracking-wider",children:"Sellout Ratio"}),e.jsxs("span",{className:"text-[10px] font-mono font-bold text-emerald-600",children:[Ll,"%"]})]}),e.jsx("div",{className:"mt-2.5 flex-1 flex flex-col justify-center",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xl font-extrabold text-slate-800 font-mono tracking-tight leading-none",children:[Ll,"%"]}),e.jsx("div",{className:"flex-1 h-2 bg-slate-100 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500 h-full rounded-full transition-all duration-500",style:{width:`${Ll}%`}})})]})})]})]}),N&&e.jsxs("div",{className:"flex items-start gap-3 p-3.5 bg-amber-50 border border-amber-200 rounded-2xl text-xs text-amber-800",children:[e.jsx(Ue,{className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-bold text-amber-900",children:"Booking Conflict Detected"}),e.jsxs("p",{className:"mt-0.5",children:[N," The inventory has been refreshed to reflect the current availability."]})]}),e.jsx("button",{onClick:()=>ue(null),className:"text-amber-500 hover:text-amber-700 font-bold text-[10px] font-mono shrink-0 cursor-pointer",children:"DISMISS"})]}),B&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-2xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{children:B}),e.jsx("button",{onClick:()=>rs(i),className:"ml-auto text-rose-600 hover:text-rose-800 font-bold font-mono text-[10px] cursor-pointer",children:"RETRY"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6",children:[e.jsxs("div",{className:"md:col-span-8 bg-white border border-slate-200 rounded-3xl p-5 shadow-xs space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-100 pb-3",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-extrabold text-slate-900 font-display",children:[De.unitNounPlural," Inventory Grid"]}),e.jsxs("p",{className:"text-[10px] text-slate-400 font-mono uppercase mt-0.5",children:[De.hasTowers&&Qt?`${Qt.label.toUpperCase()} ⢠`:"",De.hasFloors?"GROUPED BY FLOOR ⢠":"","CLICK A ",De.unitNoun.toUpperCase()," TO EDIT STATUS"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>{Ys(t=>!t),Xt(null)},className:"flex items-center gap-1.5 px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white text-[10px] font-bold font-mono rounded-xl transition-all cursor-pointer",children:[e.jsx(Ot,{className:"w-3.5 h-3.5"}),"Add Unit"]}),e.jsxs("div",{className:"flex items-center gap-2.5 font-mono text-[9px] font-bold",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 bg-emerald-50 border border-emerald-300 rounded"}),e.jsx("span",{className:"text-emerald-700",children:"AVAIL"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 bg-sky-50 border border-sky-300 rounded"}),e.jsx("span",{className:"text-sky-700",children:"HOLD"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 bg-amber-50 border border-amber-300 rounded animate-pulse"}),e.jsx("span",{className:"text-amber-700",children:"BLOCK"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 bg-rose-50 border border-rose-300 rounded"}),e.jsx("span",{className:"text-rose-600",children:"SOLD"})]})]})]})]}),e.jsx(es,{children:Ya&&e.jsx(Xe.div,{initial:{opacity:0,height:0}
20,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:e.jsxs("form",{onSubmit:$r,className:"p-4 bg-brand-50 border border-brand-100 rounded-2xl space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-brand-700 uppercase tracking-wider",children:"Add New Unit"}),e.jsx("button",{type:"button",onClick:()=>{Ys(!1),Xt(null)},className:"text-slate-400 hover:text-slate-600 cursor-pointer",children:e.jsx(ot,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[De.hasTowers&&Ls.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Tower"}),e.jsxs("select",{value:Me.towerId,onChange:t=>ft(n=>({...n,towerId:t.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none bg-white font-mono cursor-pointer",children:[e.jsx("option",{value:"",children:"â None â"}),Ls.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:[De.unitNoun," Number *"]}),e.jsx("input",{type:"text",placeholder:"e.g. 101",value:Me.unitNumber,onChange:t=>ft(n=>({...n,unitNumber:t.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500 font-mono",required:!0})]}),De.hasFloors&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Floor"}),e.jsx("input",{type:"number",placeholder:"e.g. 5",value:Me.floor,onChange:t=>ft(n=>({...n,floor:t.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500 font-mono",min:1})]}),De.kind!=="plot"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"BHK"}),e.jsx("input",{type:"number",placeholder:"e.g. 3",value:Me.bhk,onChange:t=>ft(n=>({...n,bhk:t.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500 font-mono",min:1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Size (Sq.Ft.) *"}),e.jsx("input",{type:"number",placeholder:"e.g. 1200",value:Me.sizeSqFt,onChange:t=>ft(n=>({...n,sizeSqFt:t.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500 font-mono",required:!0,min:1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Facing"}),e.jsxs("select",{value:Me.facing,onChange:t=>ft(n=>({...n,facing:t.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none bg-white font-mono cursor-pointer",children:[e.jsx("option",{value:"",children:"â Not set â"}),eo.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("div",{className:"flex items-end gap-3 pb-1.5",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] font-mono font-bold text-slate-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:Me.isCorner,onChange:t=>ft(n=>({...n,isCorner:t.target.checked})),className:"accent-brand-500"}),"Corner"]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] font-mono font-bold text-slate-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:Me.hasView,onChange:t=>ft(n=>({...n,hasView:t.target.checked})),className:"accent-brand-500"}),"View"]}
20)]})]}),Xa&&e.jsx("p",{className:"text-[10px] text-rose-600 font-semibold",children:Xa}),e.jsx("button",{type:"submit",disabled:Za,className:"w-full py-2 bg-brand-500 hover:bg-brand-600 text-white text-[10px] font-bold rounded-xl transition-all cursor-pointer disabled:opacity-50 flex items-center justify-center gap-1.5",children:Za?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"})," Savingâ¦"]}):"Add Unit to Inventory"})]})})}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 bg-slate-50/50 p-3 rounded-2xl border border-slate-200",children:[De.hasTowers&&rl.length>0?e.jsx("div",{className:"flex items-center gap-1 bg-white p-1 rounded-xl border border-slate-200/60 w-fit shrink-0 flex-wrap",children:rl.map(t=>e.jsx("button",{type:"button",onClick:()=>{Ks(t.key),As(null)},className:`px-3.5 py-1 text-[10px] font-extrabold rounded-lg transition-all cursor-pointer font-sans ${(Qt==null?void 0:Qt.key)===t.key?"bg-brand-500 text-white shadow-sm":"text-slate-500 hover:text-slate-800"}`,children:t.label},t.key))}):De.hasTowers?e.jsx("span",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase",children:vt.length>0?`${De.unitNounPlural} · no tower data on file`:De.unitNounPlural}):e.jsxs("span",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase",children:[De.unitNounPlural," · no tower grouping"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("div",{className:"flex items-center gap-1",children:["All","Available","Hold","Blocked","Sold"].map(t=>e.jsx("button",{type:"button",onClick:()=>{ga(t),As(null)},className:`px-2 py-0.5.5 text-[9px] font-bold rounded-md border transition-all cursor-pointer font-mono ${ba===t?"bg-brand-500 text-white border-brand-500 shadow-xs":"bg-white border-slate-200 text-slate-500 hover:text-slate-800 hover:bg-slate-50"}`,children:t==="All"?"ALL STATUS":t.toUpperCase()},t))}),De.kind!=="plot"&&en.length>0&&e.jsx("div",{className:"flex items-center gap-1 border-l border-slate-200 pl-2",children:["All",...en.map(t=>`${t} BHK`)].map(t=>{const n=t==="All"?"All":t.split(" ")[0];return e.jsx("button",{type:"button",onClick:()=>{ja(n),As(null)},className:`px-2 py-0.5.5 text-[9px] font-bold rounded-md border transition-all cursor-pointer font-mono ${fa===n?"bg-brand-500 text-white border-brand-500 shadow-xs":"bg-white border-slate-200 text-slate-500 hover:text-slate-800 hover:bg-slate-50"}`,children:t.toUpperCase()},t)})})]})]}),Y&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs py-10 justify-center",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Loading inventoryâ¦"})]}),!Y&&w[i]&&vt.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pl,{className:"w-10 h-10 text-slate-200 mb-3"}),e.jsx("p",{className:"text-sm font-bold text-slate-700",children:"No units yet"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1 max-w-[220px]",children:"Add your first unit to start managing this project's inventory."}),e.jsxs("button",{onClick:()=>Ys(!0),className:"mt-4 flex items-center gap-1.5 px-4 py-2 bg-brand-500 hover:bg-brand-600 text-white text-[10px] font-bold rounded-xl transition-all cursor-pointer",children:[e.jsx(Ot,{className:"w-3.5 h-3.5"}),"Add First Unit"]})]}),!Y&&vt.length>0&&(()=>{const t=De.hasTowers&&Qt?vt.filter(k=>{const ae=k;return(Cn({number:ae.number,towerId:ae.towerId},yr)??"none")===Qt.key}):vt,n=t.filter(k=>{const ae=ba==="All"||k.status===ba,Se=De.kind==="plot"||fa==="All"||k.type.split(" ")[0]===fa;return ae&&Se});if(t.length===0)return e.jsx("div",{className:"py-12 text-center text-slate-400 text-xs italic",children:De.hasTowers?`No units added for ${(Qt==null?void 0:Qt.label)??"this tower"} yet. Switch to another tower or use "Add Unit".`:`No ${De.unitNounPlural.toLowerCase()} added yet. Use "Add Unit" to get started.`});if(n.length===0)return e.jsxs("div",{className:"py-12 text-center text-slate-400 text-xs italic",children:["No ",De.unitNounPlural.toLowerCase()," match the selected filters."]});const c=k=>{var _e;const ae=(He==null?void 0:He.id)===k.id,Se=De.kind==="plot"?`${k.size||0}
20 sft`:`${((_e=k.type)==null?void 0:_e.split(" ")[0])||"â"}${k.type?" BHK":""} ⢠${k.size||0} sft`;return e.jsxs("button",{type:"button",onClick:()=>As(k),className:`p-3.5 border rounded-2xl text-center transition-all cursor-pointer relative overflow-hidden group ${Sr(k.status)==="available"?"bg-emerald-50/40 hover:bg-emerald-50/90 border-emerald-200/80 text-emerald-700 hover:border-emerald-500 hover:shadow-xs":Sr(k.status)==="hold"?"bg-sky-50/40 hover:bg-sky-50/90 border-sky-200 text-sky-700 hover:border-sky-500 hover:shadow-xs":Sr(k.status)==="blocked"?"bg-amber-50/40 hover:bg-amber-50/90 border-amber-200 text-amber-700 hover:border-amber-500 hover:shadow-xs animate-pulse-subtle":"bg-rose-50/40 hover:bg-rose-50/90 border-rose-200 text-rose-700 hover:border-rose-400"} ${ae?"ring-2 ring-slate-900 ring-offset-1 border-slate-950 bg-slate-50 shadow-sm":""}`,children:[e.jsx("span",{className:"font-mono text-xs font-extrabold block",children:De.hasFloors?k.number:Ri(De,{unitNumber:k.number})}),e.jsx("span",{className:"text-[8px] font-mono font-bold block uppercase tracking-wider text-slate-400 mt-0.5",children:Se}),Sr(k.status)==="sold"&&e.jsx("div",{className:"absolute top-0 right-0 w-2.5 h-2.5 bg-rose-400 rounded-bl-sm"}),Sr(k.status)==="hold"&&e.jsx("div",{className:"absolute top-0 right-0 w-2.5 h-2.5 bg-sky-400 rounded-bl-sm"}),k.status==="Blocked"&&e.jsx("div",{className:"absolute top-0 right-0 w-2.5 h-2.5 bg-amber-400 rounded-bl-sm animate-pulse"})]},k.id)};if(!De.hasFloors)return e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:n.map(c)});const S=Math.max(6,...t.map(k=>k.floor??1));return e.jsx("div",{className:"space-y-2",children:Array.from({length:S}).map((k,ae)=>{const Se=S-ae,_e=n.filter(at=>at.floor===Se);return _e.length===0?null:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"w-12 text-left font-mono text-[10px] font-bold text-slate-400 shrink-0",children:[Se,"F"]}),e.jsx("div",{className:"flex-1 grid grid-cols-2 sm:grid-cols-4 gap-2",children:_e.map(c)})]},Se)})})})()]}),e.jsx("div",{className:"md:col-span-4 space-y-4",children:He?e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-5 shadow-xs space-y-4 relative overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 pb-2",children:[e.jsxs("span",{className:"font-mono text-[10px] font-bold text-brand-600",children:[De.unitNoun.toUpperCase()," PROFILE"]}),e.jsxs("span",{className:"font-sans text-xs font-extrabold text-slate-900",children:[De.unitNoun," No. ",He.number]})]}),e.jsxs("div",{className:"space-y-3 font-mono text-[11px] text-slate-600",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-slate-400 block",children:"AREA SIZE"}),e.jsxs("span",{className:"text-slate-800 font-bold block mt-0.5",children:[He.size," Sq.Ft."]})]}),De.kind!=="plot"&&He.type&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-slate-400 block",children:"TYPOLOGY"}),e.jsxs("span",{className:"text-slate-800 font-bold block mt-0.5",children:[He.type," Layout"]})]}),(()=>{var S;const t=He,c=[t.towerId!=null?(S=Ls.find(k=>k.id===t.towerId))==null?void 0:S.name:null,t.facing?`${t.facing} facing`:null,t.isCorner?"Corner":null,t.hasViewPremium?"View":null].filter(Boolean);return c.length>0?e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-slate-400 block",children:"ON FILE"}),e.jsx("span",{className:"text-slate-800 font-bold block mt-0.5",children:c.join(" · ")})]}):null})(),He.assignedCp&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-slate-400 block",children:"ASSIGNED CHANNEL PARTNER"}),e.jsx("span",{className:"text-indigo-600 font-bold block mt-0.5 font-sans text-xs",children:He.assignedCp})]}),He.assignedLead&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-slate-400 block",children:"PROSPECTIVE BUYER"}),e.jsx("span",{className:"text-slate-800 font-bold block mt-0.5 font-sans text-xs",children:He.assignedLead})]})]}),(()=>{var n;if(!kt)return null;const t=(n=kt.plans[0])==null?void 0:n.id;if(!t)return null;try{const c=Gi(He),S=wl(kt,t,{saleableArea:He.size,floor:He.floor??void 0,facing:c.facing,isCorner:c.isCorner,hasViewPremium:c.hasViewPremium,config:He.type?He.type.replace(/\s+/g,""):void 0});return e.jsxs("div",{className:"pt-3 border-t border-slate-200 space-y-2 text-left bg-slate-50/50 p-2.5 rounded-xl border border-slate-200/50",children:[e.jsx("span",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"Est. Price Quote"}),e.jsxs("div",{className:"space-y-1 text-[11px] font-mono",children:[e.jsxs("div",{className:"flex justify-between text-slate-500",children:[e.jsx("span",{children:"Base Price:"}),e.jsxs("span",{className:"font-bold text-slate-800",children:["â¹",(S.baseConsideration/1e5).toFixed(2)," L"]})]}),e.jsxs("div",{className:"flex justify-between text-slate-500",children:[e.jsx("span",{children:"Extra Charges:"}),e.jsxs("span",{className:"font-bold text-slate-800",children:["â¹",(S.chargesTotal/1e5).toFixed(2)," L"]})]}),e.jsxs("div",{className:"flex justify-between text-slate-500",children:[e.jsxs("span",{children:["GST (",S.gstPct,"%):"]}),e.jsxs("span",{className:"font-bold text-slate-800",children:["â¹",(S.gst/1e5).toFixed(2)," L"]})]}),e.jsxs("div",{className:"flex justify-between pt-1 border-t border-dashed border-slate-200 text-slate-900 font-bold",children:[e.jsx("span",{className:"text-[9px] uppercase font-sans font-extrabold text-slate-500 mt-0.5",children:"Grand Total:"}),e.jsxs("span",{className:"text-brand-600",children:["â¹",(S.grandTotal/1e7).toFixed(3)," Cr"]})]})]}),!c.onFile&&e.jsx("p",{className:"text-[9px] text-slate-400 leading-snug",children:"Facing, corner and view premiums are not on file for this unit, so this is the base price only."})]})}catch(c){return e.jsxs("p",{className:"text-[9px] font-mono text-rose-500 italic",children:["Pricing calculation error: ",c.message]})}})(),e.jsxs("div",{className:"pt-3 border-t border-slate-100 space-y-2",children:[e.jsx("span",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"MODIFY UNIT STATUS"}),e.jsxs("button",{onClick:()=>Al(He.id,"Available"),className:"w-full py-1.5 bg-emerald-50 hover:bg-emerald-100 border border-emerald-200 text-emerald-700 text-[10px] font-bold rounded-lg transition-all cursor-pointer flex items-center justify-center gap-1",children:[e.jsx(ts,{className:"w-3.5 h-3.5"}),"Mark Available (Release Unit)"]}),e.jsxs("button",{onClick:()=>Al(He.id,"Blocked"),className:"w-full py-1.5 bg-brand-50 hover:bg-brand-100 border border-brand-200 text-brand-700 text-[10px] font-bold rounded-lg transition-all cursor-pointer flex items-center justify-center gap-1",children:[e.jsx(cn,{className:"w-3.5 h-3.5 text-brand-500 animate-pulse"}),"Block Unit (Pending Payout)"]}),e.jsxs("button",{onClick:()=>Al(He.id,"Sold"),className:"w-full py-1.5 bg-slate-900 hover:bg-slate-950 text-white text-[10px] font-bold rounded-lg transition-all cursor-pointer flex items-center justify-center gap-1",children:[e.jsx(Cr,{className:"w-3.5 h-3.5 text-emerald-400"}),"Mark Sold (Agreement Locked)"]})]})]}):e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-3xl p-8 text-center text-slate-400 flex flex-col items-center justify-center h-full",children:[e.jsx(pl,{className:"w-8 h-8 text-slate-300 mb-2"}),e.jsx("p",{className:"text-xs font-semibold",children:"No unit selected"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 max-w-[200px]",children:"Click any unit in the inventory tower to inspect details & manage status."})]})})]})]},"inventory-ws"),x==="leads"&&e.jsx(Xe.div,{initial:{opacity:0,y:10}
20,animate:{opacity:1,y:0},exit:{opacity:0},className:"bg-white border border-slate-200 rounded-3xl p-6 shadow-xs space-y-6 animate-fade-in",children:ke==="introduced"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-extrabold text-slate-900 font-display",children:"Leads"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Buyers who agreed to be contacted, introduced to you by the Realtified team."})]}),tt&&tt.totalIntroduced>0&&tt.responseRate!=null&&e.jsxs("p",{className:"text-xs text-slate-500 bg-slate-50 border border-slate-100 rounded-xl px-3 py-2",children:["You responded to ",tt.respondedCount," of ",tt.totalIntroduced," leads",tt.medianFirstResponseMinutes!=null&&e.jsxs(e.Fragment,{children:[" · typical first response ",Math.round(tt.medianFirstResponseMinutes)," min"]})]}),e.jsx("div",{className:"flex items-center gap-1.5 bg-slate-50 border border-slate-200 rounded-xl p-1 w-fit",children:[["all","All"],["new","New"],["not_responded","Not responded"],["today","Today"]].map(([t,n])=>e.jsx("button",{onClick:()=>na(t),className:`px-3 py-1.5 text-[10px] font-bold font-mono uppercase rounded-lg transition-all cursor-pointer ${Dt===t?"bg-slate-900 text-white":"text-slate-500 hover:bg-white"}`,children:n},t))}),Tt&&e.jsxs("div",{className:"flex items-center gap-2 bg-rose-50 border border-rose-200 text-rose-700 rounded-xl px-4 py-3 text-xs font-semibold",children:[e.jsx(ss,{className:"w-4 h-4 shrink-0"}),Tt]}),Ft?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsx("div",{className:"bg-slate-100/60 border border-slate-200/50 rounded-2xl p-5 h-24 animate-pulse"},t))}):ls.length===0?e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-12 text-center text-slate-400 space-y-2",children:[e.jsx(vr,{className:"w-10 h-10 mx-auto text-slate-300 border border-slate-200 p-2.5 rounded-xl"}),e.jsx("p",{className:"text-xs font-semibold",children:"No leads yet."}),e.jsx("p",{className:"text-[11px] text-slate-500 max-w-sm mx-auto",children:"When a buyer enquires about one of your listings and agrees to be contacted, they'll appear here."})]}):e.jsx("div",{className:"space-y-2.5",children:ls.map(t=>{const n={new:"bg-amber-50 text-amber-700 border-amber-200",contacted:"bg-brand-50 text-brand-700 border-brand-200",site_visit_booked:"bg-indigo-50 text-indigo-700 border-indigo-200",negotiating:"bg-amber-50 text-amber-700 border-amber-200",booked:"bg-emerald-50 text-emerald-700 border-emerald-200",not_interested:"bg-slate-100 text-slate-500 border-slate-200"};return e.jsxs("button",{onClick:()=>da(t.id),className:"w-full text-left bg-white border border-slate-200 hover:border-brand-300 rounded-2xl p-4 shadow-xs transition-all cursor-pointer flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"text-sm font-bold text-slate-900",children:t.contactVisible?t.name:"Buyer"}),e.jsx("span",{className:`px-2 py-0.5 rounded-md text-[8px] font-bold font-mono uppercase border ${n[t.builderStatus]}`,children:Yt[t.builderStatus]}),t.registeredByRealtified&&e.jsx(bn,{})]}),t.contactVisible&&t.phone&&e.jsxs("a",{href:`tel:${t.phone}`,onClick:c=>c.stopPropagation(),className:"flex items-center gap-1.5 text-xs font-mono font-bold text-slate-700 hover:text-brand-600 w-fit",children:[e.jsx(xn,{className:"w-3 h-3 text-slate-400 shrink-0"}),t.phone]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:t.projectName||`Project #${t.projectId}`}),(t.configuration||t.budgetMinInr||t.budgetMaxInr||t.timeline)&&e.jsx("p",{className:"text-[10.5px] text-slate-400 font-mono",children:[t.configuration||null,t.budgetMinInr||t.budgetMaxInr?`â¹${t.budgetMinInr?(t.budgetMinInr/1e5).toFixed(0):"â"}â${t.budgetMaxInr?(t.budgetMaxInr/1e5).toFixed(0):"â"} L`:null,t.timeline?t.timeline.replace("_","â").replace("m"," months"):null].filter(Boolean).join(" · ")})]}),e.jsxs("span",{className:"text-[10px] font-mono text-slate-400 shrink-0",children:["introduced ",t.introducedAt?Un(t.introducedAt):"â"]})]},t.id)})}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap pt-2 border-t border-slate-100",children:[e.jsx("button",{onClick:()=>bt("cp-pipeline"),className:"text-[11px] font-bold text-slate-500 hover:text-brand-600 cursor-pointer underline-offset-2 hover:underline",children:"Agent referrals"}),wr("dealRoom")&&e.jsxs("button",{onClick:()=>{bt("booking-claims"),Hs()},className:"text-[11px] font-bold text-slate-500 hover:text-brand-600 cursor-pointer underline-offset-2 hover:underline",children:["Offline booking claims",d.filter(t=>t.status==="pending").length>0&&e.jsx("span",{className:"ml-1.5 px-1.5 py-0.5 text-[9px] font-mono rounded-full bg-amber-100 text-amber-700",children:d.filter(t=>t.status==="pending").length})]})]})]}):ke==="cp-pipeline"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("button",{onClick:()=>bt("introduced"),className:"text-[11px] font-bold text-brand-600 hover:text-brand-700 cursor-pointer mb-2",children:"â Back to Leads"}),e.jsx("h3",{className:"text-base font-extrabold text-slate-900 font-display",children:"Agent referrals"})]}),e.jsxs("div",{className:"bg-white border border-dashed border-slate-200 rounded-2xl p-12 text-center text-slate-400 space-y-2",children:[e.jsx(vr,{className:"w-10 h-10 mx-auto text-slate-300 border border-slate-200 p-2.5 rounded-xl"}),e.jsx("p",{className:"text-xs font-semibold text-slate-600",children:"No agent referrals yet"}),e.jsx("p",{className:"text-[11px] text-slate-500 max-w-sm mx-auto",children:Yi})]})]}):wr("dealRoom")?e.jsxs("div",{className:"space-y-5 text-left font-sans animate-fade-in",children:[e.jsxs("div",{children:[e.jsx("button",{onClick:()=>bt("introduced"),className:"text-[11px] font-bold text-brand-600 hover:text-brand-700 cursor-pointer mb-2",children:"â Back to Leads"}),e.jsx("h3",{className:"text-base font-extrabold text-slate-900 font-display",children:"Offline Booking Claims"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Channel partners submit these when a sale happens in person at the site. Confirming creates a real booking through the same path as any other booking â commission only accrues once the buyer completes the token payment."})]}),ze&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"})," ",ze]}),ee?e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs py-6 justify-center",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Loading booking claimsâ¦"]}):d.filter(t=>t.status==="pending").length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ro,{className:"w-10 h-10 text-slate-200 mb-3"}),e.jsx("p",{className:"text-sm font-bold text-slate-600",children:"No pending booking claims"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1",children:"Claims submitted by channel partners for this project will appear here for review."})]}):e.jsx("div",{className:"space-y-4",children:d.filter(t=>t.status==="pending").map(t=>e.jsxs("div",{className:"border border-slate-200 rounded-2xl p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-bold text-slate-800",children:["Claim #",t.id," · Lead #",t.leadId]}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500",children:["Claimed agreement value: ",e.jsx("span",{className:"font-bold text-slate-800",children:wt(parseFloat(t.claimedAgreementValue))}),t.unitId?` · Unit #${t.unitId}`:""]}),t.note&&e.jsxs("p",{className:"text-[10px] text-slate-500 italic",children:['"',t.note,'"']}),e.jsxs("p",{className:"text-[9px] font-mono text-slate-400",children:["Submitted ",new Date(t.createdAt).toLocaleDateString("en-IN")]})]}),e.jsx("span",{className:"px-2 py-0.5 text-[9px] font-mono font-bold rounded-md uppercase bg-amber-50 text-amber-600 border border-amber-100",children:"Pending Review"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap pt-2 border-t border-slate-100",children:[Ut===t.id?e.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-emerald-50 border border-emerald-200 rounded-xl flex-wrap",children:[e.jsx("span",{className:"text-[10px] text-emerald-700 font-semibold",children:"Confirm this booking? This creates a real booking and cannot be undone."}),e.jsxs("button",{disabled:pt===t.id,onClick:()=>Er(t.id),className:"px-2.5 py-1 bg-emerald-500 hover:bg-emerald-600 text-white text-[10px] font-bold rounded-lg cursor-pointer disabled:opacity-50 flex items-center gap-1",children:[pt===t.id?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(ts,{className:"w-3 h-3"})," Yes, Confirm"]}),e.jsx("button",{disabled:pt===t.id,onClick:()=>pa(null),className:"px-2.5 py-1 bg-white border border-slate-200 text-slate-600 text-[10px] font-bold rounded-lg cursor-pointer",children:"Cancel"})]}):e.jsxs("button",{onClick:()=>pa(t.id),className:"px-3 py-1.5 bg-emerald-50 hover:bg-emerald-100 border border-emerald-200 text-emerald-700 text-[10px] font-bold rounded-lg transition-all cursor-pointer flex items-center gap-1",children:[e.jsx(ts,{className:"w-3.5 h-3.5"})," Confirm Booking"]}),e.jsx("input",{type:"text",placeholder:"Rejection reasonâ¦",value:Lt[t.id]??"",onChange:n=>xs(c=>({...c,[t.id]:n.target.value})),className:"flex-1 min-w-[160px] px-2.5 py-1.5 border border-slate-200 rounded-lg text-[10px] outline-none focus:ring-1 focus:ring-rose-500 focus:border-rose-500"}),e.jsx("button",{disabled:pt===t.id||!Lt[t.id],onClick:()=>Fr(t.id),className:"px-3 py-1.5 bg-rose-50 hover:bg-rose-100 border border-rose-200 text-rose-600 text-[10px] font-bold rounded-lg transition-all cursor-pointer disabled:opacity-50 flex items-center gap-1",children:pt===t.id?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):"Reject"})]})]},t.id))}),d.filter(t=>t.status!=="pending").length>0&&e.jsxs("div",{className:"pt-4 border-t border-slate-100 space-y-2",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider",children:"Recently Reviewed"}),d.filter(t=>t.status!=="pending").slice(0,10).map(t=>e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-500 py-1.5 border-b border-slate-50",children:[e.jsxs("span",{children:["Claim #",t.id," · Lead #",t.leadId," · ",wt(parseFloat(t.claimedAgreementValue))]}),e.jsx("span",{className:`px-2 py-0.5 font-mono font-bold rounded uppercase ${t.status==="confirmed"?"bg-emerald-50 text-emerald-600":"bg-rose-50 text-rose-600"}`,children:t.status})]},t.id))]})]}):null},"leads-ws"),e.jsx(es,{children:it!=null&&e.jsx(Xe.div,{initial:{opacity:0}
20,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 bg-slate-900/40 flex justify-end",onClick:cs,children:e.jsxs(Xe.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.2},onClick:t=>t.stopPropagation(),className:"w-full sm:max-w-md h-full bg-white overflow-y-auto shadow-2xl flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-slate-100 flex items-center justify-between shrink-0",children:[e.jsx("h3",{className:"text-sm font-extrabold text-slate-900",children:"Lead detail"}),e.jsx("button",{onClick:cs,className:"p-1.5 text-slate-400 hover:text-slate-700 rounded-lg hover:bg-slate-50 cursor-pointer",children:e.jsx(ot,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:os?e.jsx("div",{className:"flex items-center justify-center py-16 text-slate-400",children:e.jsx(ce,{className:"w-5 h-5 animate-spin"})}):Pt&&!ge?e.jsxs("div",{className:"text-xs text-rose-600 font-semibold flex items-center gap-1.5",children:[e.jsx(ss,{className:"w-4 h-4"}),Pt]}):ge?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-extrabold text-slate-900",children:ge.contactVisible?ge.name:"Buyer"}),e.jsx("p",{className:"text-xs text-slate-500",children:ge.projectName||`Project #${ge.projectId}`}),ge.registeredByRealtified&&e.jsx("div",{className:"mt-1.5",children:e.jsx(bn,{})})]}),ge.contactVisible&&ge.phone&&e.jsxs("a",{href:`tel:${ge.phone}`,className:"flex items-center gap-2 text-sm font-mono font-bold text-brand-600 w-fit",children:[e.jsx(xn,{className:"w-4 h-4"})," ",ge.phone]}),(ge.configuration||ge.budgetMinInr||ge.budgetMaxInr||ge.timeline)&&e.jsxs("div",{className:"bg-slate-50 border border-slate-100 rounded-xl p-3 text-xs text-slate-600 space-y-1",children:[ge.configuration&&e.jsxs("p",{children:[e.jsx("span",{className:"text-slate-400 uppercase text-[10px] font-mono",children:"Configuration "}),ge.configuration]}),(ge.budgetMinInr||ge.budgetMaxInr)&&e.jsxs("p",{children:[e.jsx("span",{className:"text-slate-400 uppercase text-[10px] font-mono",children:"Budget "}),"â¹",ge.budgetMinInr?(ge.budgetMinInr/1e5).toFixed(0):"â","â",ge.budgetMaxInr?(ge.budgetMaxInr/1e5).toFixed(0):"â"," L"]}),ge.timeline&&e.jsxs("p",{children:[e.jsx("span",{className:"text-slate-400 uppercase text-[10px] font-mono",children:"Timeline "}),ge.timeline.replace("_","â").replace("m"," months")]})]}),ge.note&&e.jsxs("p",{className:"text-xs text-slate-500 italic",children:["â",ge.note,"â"]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider",children:"Status"}),Pt&&e.jsxs("p",{className:"text-[11px] text-rose-600 font-semibold flex items-center gap-1.5",children:[e.jsx(ss,{className:"w-3 h-3"}),Pt]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:zs[ge.builderStatus].length===0?e.jsxs("span",{className:"text-[11px] text-slate-400 italic",children:["No further status changes â ",Yt[ge.builderStatus].toLowerCase()," is final."]}):zs[ge.builderStatus].map(t=>e.jsxs("button",{onClick:()=>t==="not_interested"?Kt(!0):ca(t),disabled:is,className:"px-3 py-1.5 bg-white border border-slate-200 hover:border-brand-400 text-slate-700 text-[10px] font-bold rounded-lg transition-all cursor-pointer disabled:opacity-50",children:["Mark ",Yt[t]]},t))}),ia&&e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded-xl p-3 space-y-2",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-rose-600 uppercase",children:"Reason (required)"}),e.jsx("textarea",{value:Rt,onChange:t=>Wt(t.target.value),rows:2,placeholder:"e.g. Buyer chose another project",className:"w-full px-2.5 py-1.5 border border-rose-200 rounded-lg text-xs bg-white resize-none outline-none focus:ring-1 focus:ring-rose-400"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>ca("not_interested",Rt.trim()),disabled:is||!Rt.trim(),className:"px-3 py-1.5 bg-rose-600 hover:bg-rose-700 disabled:opacity-50 text-white text-[10px] font-bold rounded-lg transition-all cursor-pointer",children:"Confirm"}),e.jsx("button",{onClick:()=>Kt(!1),className:"px-3 py-1.5 text-slate-500 text-[10px] font-bold cursor-pointer",children:"Cancel"})]})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider",children:"Add a note"}
20),e.jsx("textarea",{value:Gt,onChange:t=>mt(t.target.value),rows:2,placeholder:"Share an update with Realtified supportâ¦",className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs bg-white resize-none outline-none focus:ring-1 focus:ring-brand-400"}),e.jsxs("button",{onClick:xa,disabled:Ps||!Gt.trim(),className:"flex items-center gap-1.5 px-3 py-1.5 bg-brand-500 hover:bg-brand-600 disabled:opacity-50 text-white text-[10px] font-bold rounded-lg transition-all cursor-pointer",children:[e.jsx(Ao,{className:"w-3 h-3"}),Ps?"Savingâ¦":"Save note"]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-slate-100",children:[e.jsxs("p",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(Lo,{className:"w-3 h-3"})," Timeline"]}),Vt.length===0?e.jsx("p",{className:"text-[11px] text-slate-400",children:"No activity yet."}):e.jsx("div",{className:"space-y-2",children:Vt.map(t=>e.jsxs("div",{className:"flex items-start gap-2 text-[11px] border-b border-slate-50 last:border-0 pb-2 last:pb-0",children:[e.jsx("span",{className:"mt-0.5 shrink-0 w-1.5 h-1.5 rounded-full bg-brand-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-slate-700",children:t.note||t.eventType.replace(/_/g," ")}),e.jsxs("p",{className:"text-[9px] font-mono text-slate-400 mt-0.5",children:[t.actorRole||"system"," · ",Un(t.createdAt)]})]})]},t.id))})]})]}):null})]})},"lead-detail-overlay")},"lead-detail-presence"),x==="pricing-inventory"&&q==="pricing-rules"&&e.jsxs(Xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},className:"bg-white border border-slate-200 rounded-3xl p-6 shadow-xs space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-extrabold text-slate-900 font-display",children:"Project Pricing"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Update this project's base rate and the commission partners earn. Changes to an approved listing are submitted for Realtified review before buyers see them."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 items-center pt-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-slate-50 border border-slate-200 rounded-2xl text-xs space-y-1",children:[e.jsx("p",{className:"font-semibold text-slate-700",children:"Selected Project Profile"}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Project: ",e.jsx("strong",{children:(W==null?void 0:W.name)??"â"})]}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Current Base Rate: ",e.jsx("strong",{className:"text-brand-600",children:i!==null&&(y[i]||W!=null&&W.basePricePerSqFt)?`â¹${(y[i]||W.basePricePerSqFt).toLocaleString()}/sqft`:"Not set yet"})]})]}),e.jsxs("form",{onSubmit:oo,className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-mono font-bold text-slate-400 uppercase tracking-wider",children:"New Base Rate (â¹ per Square Foot) *"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-slate-400 font-bold text-xs",children:"â¹"}),e.jsx("input",{type:"number",required:!0,placeholder:"e.g. 8450",value:Ws,onChange:t=>Ga(t.target.value),className:"w-full pl-8 pr-3.5 py-2 border border-slate-200 rounded-xl text-xs outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500 font-mono font-bold text-slate-800"})]})]}),tr&&e.jsx("div",{className:"p-2.5 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700 font-semibold",children:tr}),e.jsx("button",{type:"submit",disabled:Pa,className:"w-full py-2.5 bg-brand-500 hover:bg-brand-600 text-white text-xs font-bold rounded-xl transition-all shadow-md shadow-brand-500/10 flex items-center justify-center gap-1.5 cursor-pointer disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:outline-none",children:Pa?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 text-white animate-spin"}),e.jsx("span",{children:"Saving to backendâ¦"})]}):e.jsxs(e.Fragment,{children:[e.jsx(hl,{className:"w-4 h-4 text-white"}),e.jsx("span",{children:"Submit Rate Update"})]})})]})]}),e.jsxs("div",{className:"p-4 bg-slate-50 border border-slate-200 rounded-2xl space-y-3",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-slate-500 uppercase tracking-wider",children:"Channel-Partner Commission %"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Set the commission rate (0â10% of the sale price) on completed bookings for this project. Realtified keeps a platform share of it (30% by default); the channel partner receives the rest."}),W&&W.commissionPct!=null&&e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Current rate: ",e.jsxs("strong",{className:"text-brand-600 font-mono",children:[W.commissionPct,"%"]})," ","· Partner receives ",e.jsxs("strong",{className:"font-mono",children:[Ol(Number(W.commissionPct)),"%"]})," of the sale price"]}),ms!==""&&!isNaN(parseFloat(ms))&&e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Partner receives ",e.jsxs("strong",{className:"font-mono text-slate-700",children:[Ol(parseFloat(ms)),"%"]})," of this (",Yn,"% platform share at the default setting)."]}),e.jsxs("form",{onSubmit:io,className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{type:"number",step:"0.1",min:"0",max:"10",placeholder:"e.g. 2.5",value:ms,onChange:t=>sr(t.target.value),className:"w-full pl-3 pr-8 py-2 border border-slate-200 rounded-xl text-xs outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500 font-mono font-bold text-slate-800",required:!0}),e.jsx("span",{className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 font-bold text-xs",children:"%"})]}),e.jsxs("button",{type:"submit",disabled:Ra,className:"px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-white text-[10px] font-bold rounded-xl transition-all cursor-pointer disabled:opacity-50 flex items-center gap-1.5 shrink-0",children:[Ra?e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Eo,{className:"w-3.5 h-3.5"}),"Save"]})]}),Aa&&e.jsx("p",{className:"text-[10px] text-rose-600 font-semibold",children:Aa})]}),e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-2xl p-5 text-slate-600 text-xs space-y-3",children:[e.jsxs("h4",{className:"font-bold text-slate-900 font-mono uppercase text-[10px] tracking-wider flex items-center gap-1.5 text-brand-600",children:[e.jsx(jl,{className:"w-4 h-4 text-brand-500"})," PRICE SANITY CHECK"]}),e.jsx("p",{className:"text-[11px] leading-relaxed",children:"A simple, informational comparison against this project's own currently published base price â not a regulatory check, and it does not block your update."}),(()=>{const t=Ws?parseInt(Ws,10):i!==null?y[i]||((W==null?void 0:W.basePricePerSqFt)??0):0,n=(W==null?void 0:W.basePricePerSqFt)??null;if(!n||!t)return e.jsx("div",{className:"p-3 bg-slate-100 border border-slate-200 rounded-xl text-left",children:e.jsx("span",{className:"text-[10px] font-mono font-bold text-slate-500",children:"No published base price on file yet to compare against."})});const c=(t-n)/n*100;return Math.abs(c)>15?e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded-xl flex items-start gap-2",children:[e.jsx(Ue,{className:"w-4.5 h-4.5 text-amber-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-amber-800 uppercase leading-none",children:"Large Price Change"}),e.jsxs("p",{className:"text-[9px] text-amber-700 leading-normal mt-1",children:[c>0?"Up":"Down"," ",Math.abs(c).toFixed(1),"% from this project's currently published base price of â¹",n.toLocaleStr
20ing(),"/sqft. Informational only â nothing stops you from proceeding."]})]})]}):e.jsxs("div",{className:"p-3 bg-emerald-50 border border-emerald-200 rounded-xl flex items-center gap-2 text-left",children:[e.jsx(Cr,{className:"w-4.5 h-4.5 text-emerald-600 shrink-0"}),e.jsxs("span",{className:"text-[10px] font-mono font-bold text-emerald-700",children:["Within 15% of this project's published base price (â¹",n.toLocaleString(),"/sqft)."]})]})})()]}),e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-2xl p-4 text-left space-y-3 md:col-span-2",children:[e.jsx("span",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"Price Updates This Session"}),e.jsx("p",{className:"text-[9px] text-slate-400 leading-relaxed",children:"Not persisted server-side yet â this list resets on refresh and only shows updates made in this browser session."}),ps.length===0?e.jsx("p",{className:"text-[10px] text-slate-400 italic py-3 text-center",children:"No price updates yet this session."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-200 text-slate-400 uppercase tracking-wider text-[9px] font-mono",children:[e.jsx("th",{className:"pb-2 font-bold text-left",children:"Date"}),e.jsx("th",{className:"pb-2 font-bold text-left",children:"Rate (Per Sft)"}),e.jsx("th",{className:"pb-2 font-bold text-left",children:"Source/Author"}),e.jsx("th",{className:"pb-2 font-bold text-right",children:"Status"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 font-mono text-[11px]",children:ps.map((t,n)=>e.jsxs("tr",{className:"text-slate-700 hover:bg-slate-100/40",children:[e.jsx("td",{className:"py-2.5 text-left font-sans",children:t.date}),e.jsxs("td",{className:"py-2.5 text-left font-bold text-slate-900",children:["â¹",t.rate.toLocaleString()]}),e.jsx("td",{className:"py-2.5 text-left text-slate-500 font-sans",children:t.author}),e.jsx("td",{className:"py-2.5 text-right",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[9px] font-bold uppercase ${t.status==="Applied"?"bg-emerald-50 text-emerald-700 border border-emerald-100":"bg-amber-50 text-amber-700 border border-amber-100"}`,children:t.status})})]},n))})]})})]})]})]},"pricing-ws"),x==="pricing-inventory"&&q==="price-sheets"&&e.jsx(Xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},children:e.jsx(Xd,{user:a,onSuccessNotification:b,projectId:i,projectName:(W==null?void 0:W.name)??null,projectsLoading:I,projectsError:G,onRetryProjects:xe})},"price-sheet-ws"),x==="pricing-inventory"&&q==="payment-milestones"&&e.jsxs(Xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},className:"bg-white border border-slate-200 rounded-3xl p-6 shadow-xs space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-extrabold text-slate-900 font-display",children:"Milestone Payment Plan Modeler"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Set the payment stages for this project. Percentages must add up to exactly 100%."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[jt.length>0&&e.jsx("button",{onClick:mo,className:"px-3.5 py-1.5 bg-slate-50 hover:bg-slate-100 border border-slate-200 rounded-xl text-[10px] font-mono font-bold text-slate-600 hover:text-slate-800 cursor-pointer",children:"Clear"}),e.jsx("button",{onClick:ho,disabled:Sa||jt.length===0,className:"px-3.5 py-1.5 bg-brand-500 hover:bg-brand-600 text-white border border-brand-500 rounded-xl text-[10px] font-mono font-bold cursor-pointer disabled:opacity-50 flex items-center gap-1.5 focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:outline-none",children:Sa?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"})," Savingâ¦"]}):"Save Plan"})]})]}),Ca&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Loading plan from backendâ¦"})]}),ka&&e.jsx("div",{className:"p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700 font-semibold",children:ka}),!Ca&&!Ja&&e.jsx("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded-xl text-xs text-amber-800 font-semibold",children:jt.length>0?"Not saved yet â review the stages, then press Save Plan.":"No plan saved yet â start from a template."}),e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-2xl p-4 text-left space-y-2",children:[e.jsx("span",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider block",children:"Start from a template"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Object.keys(gl).map(t=>e.jsxs("button",{onClick:()=>uo(t),className:"flex items-center gap-1.5 px-3 py-1.5 bg-white hover:bg-slate-100 border border-slate-200 text-slate-700 text-[10px] font-bold rounded-xl cursor-pointer shadow-xs active:scale-[0.98] transition-all",children:[t==="clp"?e.jsx(Yl,{className:"w-3.5 h-3.5 text-slate-500"}):e.jsx(xl,{className:"w-3.5 h-3.5 text-slate-500"}),gl[t].label]},t)),e.jsxs("button",{onClick:xo,className:"flex items-center gap-1.5 px-3 py-1.5 bg-white hover:bg-slate-100 border border-dashed border-slate-300 text-slate-700 text-[10px] font-bold rounded-xl cursor-pointer",children:[e.jsx(Ot,{className:"w-3.5 h-3.5"})," Add a stage"]})]})]}),jt.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`p-4 rounded-2xl flex items-center justify-between gap-4 text-xs font-mono font-bold border transition-all ${ys===100?"bg-emerald-50/50 border-emerald-100 text-emerald-700":"bg-amber-50/50 border-amber-100 text-amber-700"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-3 h-3 rounded-full ${ys===100?"bg-emerald-500":"bg-amber-500"}`}),e.jsxs("span",{children:["TOTAL: ",ys,"%"]})]}),e.jsx("span",{children:ys===100?"Totals 100%":ys>100?`${ys-100}% over`:`${100-ys}% remaining`})]}),e.jsx("div",{className:"space-y-3",children:jt.map((t,n)=>e.jsxs("div",{className:"border border-slate-200 p-3 rounded-2xl flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] font-mono text-slate-400 w-
205 shrink-0",children:[n+1,"."]}),e.jsx("input",{type:"text",value:t.name,placeholder:"Stage name, e.g. Foundation complete",onChange:c=>co(t.id,c.target.value),"aria-label":`Name of stage ${n+1}`,className:"flex-1 min-w-0 px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs font-bold text-slate-800 outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500"})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("input",{type:"range",min:0,max:100,step:1,value:t.percentage,onChange:c=>Jl(t.id,parseInt(c.target.value)),"aria-label":`Percentage for stage ${n+1}`,className:"w-28 h-1 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-brand-500"}),e.jsx("input",{type:"number",min:0,max:100,value:t.percentage,onChange:c=>Jl(t.id,Math.max(0,Math.min(100,parseFloat(c.target.value)||0))),"aria-label":`Percentage for stage ${n+1} (number)`,className:"w-16 px-2 py-1 border border-slate-200 rounded-lg text-xs text-center font-mono font-extrabold text-slate-800 outline-none focus:ring-1 focus:ring-brand-500"}),e.jsx("span",{className:"font-mono text-xs text-slate-400",children:"%"}),e.jsx("button",{type:"button",onClick:()=>po(t.id),title:"Remove stage","aria-label":`Remove stage ${n+1}`,className:"p-1.5 text-slate-300 hover:text-rose-500 cursor-pointer",children:e.jsx(St,{className:"w-4 h-4"})})]})]},t.id))})]})]},"payment-plans-ws"),x==="my-listings"&&e.jsxs(Xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},className:"space-y-4",children:[Ts!==null?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:()=>Re(null),className:"flex items-center gap-1.5 min-h-[40px] sm:min-h-0 text-xs font-bold text-slate-500 hover:text-slate-800 transition-all cursor-pointer",children:[e.jsx(Fo,{className:"w-3.5 h-3.5"}),"Back to Listings"]}),e.jsxs(es,{mode:"wait",children:[Ts==="choose"&&e.jsxs(Xe.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"bg-white border border-slate-200 rounded-3xl p-6",children:[e.jsx("div",{className:"mb-4",children:e.jsx("h4",{className:"text-sm font-extrabold text-slate-900",children:"What are you listing?"})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("button",{onClick:()=>Re("resale"),className:"flex flex-col items-start gap-2 p-5 border-2 border-slate-200 hover:border-brand-400 rounded-2xl text-left transition-all cursor-pointer",children:[e.jsx(cl,{className:"w-6 h-6 text-brand-500"}),e.jsx("span",{className:"text-sm font-extrabold text-slate-900",children:"Resale / plot"}),e.jsx("span",{className:"text-xs text-slate-500",children:"A flat, independent house, villa or plot â no RERA fetch, just fill in the details."})]}),e.jsxs("button",{onClick:()=>Re("rera"),className:"flex flex-col items-start gap-2 p-5 border-2 border-slate-200 hover:border-brand-400 rounded-2xl text-left transition-all cursor-pointer",children:[e.jsx(qa,{className:"w-6 h-6 text-brand-500"}),e.jsx("span",{className:"text-sm font-extrabold text-slate-900",children:"New RERA project"}),e.jsx("span",{className:"text-xs text-slate-500",children:"Enter a TS-RERA number and we fetch the filing for you."})]})]})]},"choose"),Ts==="resale"&&e.jsx(Xe.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"bg-white border border-slate-200 rounded-3xl overflow-hidden",children:e.jsx($i,{user:a,onClose:()=>Re(null),onSubmitted:()=>{Re(null),js(),b("Listing submitted for review.")}})},"resale"),Ts==="rera"&&e.jsx(Xe.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"bg-white border border-slate-200 rounded-3xl overflow-hidden",children:e.jsx(Ad,{user:a,companyName:M,onClaimFiled:fr,onClose:()=>Re(null),onSubmitted:()=>{Re(null),js(),b("Project submitted for review.")}})},"rera")]})]}):e.jsx(e.Fragment,{children:e.jsx("div",{className:"bg-white border border-slate-200 rounded-3xl p-6 shadow-xs",children:e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-extrabold text-slate-900 font-display",children:"My Listings"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Create and manage your project listings. Listings go live only after Realtified admin approval."}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 px-3 py-1.5 bg-amber-50 border border-amber-200 rounded-xl w-fit",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),e.jsx("span",{className:"text-[10px] font-mono text-amber-700 font-semibold",children:"Beta â listings require admin review before going live"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 flex-wrap",children:[e.jsxs("button",{onClick:()=>{Zs(t=>!t),!hs&&ut.length===0&&gr()},className:"flex items-center justify-center gap-1.5 min-h-[40px] sm:min-h-0 px-4 py-2 bg-indigo-500 hover:bg-indigo-600 text-white text-[10px] font-bold rounded-xl transition-all cursor-pointer",children:[e.jsx(Rr,{className:"w-3.5 h-3.5"}),"Claim RERA Project"]}),e.jsxs("button",{onClick:()=>Re("choose"),className:"flex items-center justify-center gap-1.5 min-h-[40px] sm:min-h-0 px-4 py-2 bg-brand-500 hover:bg-brand-600 text-white text-[10px] font-bold rounded-xl transition-all cursor-pointer",children:[e.jsx(Ot,{className:"w-3.5 h-3.5"}),"Add listing"]})]})]})})}),Ts===null&&e.jsxs(e.Fragment,{children:[e.jsx(es,{children:hs&&e.jsxs(Xe.div,{initial:{opacity:0,y:-8}
20,animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"bg-white border border-indigo-100 rounded-3xl p-6 shadow-xs space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-extrabold text-slate-900",children:"Claim a RERA Project"}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-0.5",children:["Search from ",ut.length," RERA-registered projects. Ask to claim one, and our team checks the connection before it is added to your account."]})]}),e.jsx("button",{onClick:so,"aria-label":"Close",className:"inline-flex items-center justify-center min-h-[40px] min-w-[40px] sm:min-h-0 sm:min-w-0 -m-2.5 sm:m-0 text-slate-400 hover:text-slate-700 cursor-pointer",children:e.jsx(ot,{className:"w-4 h-4"})})]}),Mt&&e.jsx(Qn,{user:a,projectId:Mt.id,projectName:Mt.name,defaultCompanyName:M,onSent:()=>{fr()},onSettled:()=>{fr(),gr()},onNotify:b,onClose:()=>Qs(null)}),!Mt&&e.jsx("div",{className:"relative",children:e.jsx("input",{type:"text",placeholder:"Search by project name, locality, district, or RERA numberâ¦",value:Nt,onChange:t=>Yr(t.target.value),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500"})}),!Mt&&cr&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs py-4 justify-center",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Loading RERA projectsâ¦"})]}),!Mt&&Js&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{children:Js}),e.jsx("button",{onClick:gr,className:"ml-auto font-bold font-mono text-[10px] cursor-pointer",children:"RETRY"})]}),!Mt&&!cr&&!Js&&e.jsxs("div",{className:"space-y-2 max-h-[320px] overflow-y-auto pr-1",children:[al.length===0&&Nt.trim()&&e.jsx("p",{className:"text-xs text-slate-400 text-center py-6",children:"No projects match your search."}),al.length===0&&!Nt.trim()&&ut.length>0&&e.jsxs("p",{className:"text-xs text-slate-400 text-center py-6",children:["Type to search ",ut.length," projects."]}),al.map(t=>{const n=!!t.isClaimed,c=n&&U.some(k=>k.id===t.id),S=Ua.some(k=>k.projectId===t.id&&k.status==="pending");return e.jsxs("div",{className:"flex items-start justify-between gap-3 p-3 border border-slate-200 rounded-xl hover:border-indigo-200 transition-all bg-slate-50/40",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsx("p",{className:"text-xs font-bold text-slate-800 truncate",children:t.name}),e.jsxs("p",{className:"text-[10px] text-slate-500 font-mono",children:[t.location,t.district?` · ${t.district}`:""]}),yl(t.reraNumber)&&e.jsxs("p",{className:"text-[9px] font-mono text-slate-400",children:["RERA: ",yl(t.reraNumber)]}),n&&e.jsx("span",{className:`inline-block text-[9px] font-mono font-bold px-1.5 py-0.5 rounded mt-0.5 ${c?"bg-emerald-50 text-emerald-700 border border-emerald-200":"bg-slate-100 text-slate-500"}`,children:c?"â Claimed by you":"Claimed by another builder"})]}),c?e.jsx("button",{onClick:()=>{Zs(!1),D("my-listings"),sl(t)},className:"flex items-center justify-center gap-1 min-h-[40px] sm:min-h-0 px-3 py-1.5 bg-emerald-600 hover:bg-emerald-700 text-white text-[10px] font-bold rounded-lg transition-all cursor-pointer shrink-0",children:"Edit Listing"}):e.jsx("button",{disabled:n||S,onClick:()=>Qs(t),className:"flex items-center justify-center gap-1 min-h-[40px] sm:min-h-0 px-3 py-1.5 bg-indigo-500 hover:bg-indigo-600 text-white text-[10px] font-bold rounded-lg transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed shrink-0",children:S?"Under review":"Claim"})]},t.id)}),ut.length>0&&Nt.trim()&&al.length===25&&e.jsx("p",{className:"text-[10px] text-slate-400 text-center font-mono py-1",children:"Showing first 25 results â refine your search"})]})]})}),e.jsx(Fd,{claims:Ua}),e.jsx(es,{children:zr!==null&&e.jsx(Xe.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"w-full",children:e.jsx(Nd,{user:a,listingId:zr,identityLocked:Hr,initialData:Kr,onClose:()=>{Da(null),nr(null)},onSuccess:b,loadListings:js,uploadListingAsset:ra})})}),ir&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-2xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{children:ir}),e.jsx("button",{onClick:()=>dr(null),className:"ml-auto font-bold font-mono text-[10px] cursor-pointer",children:"DISMISS"})]}),e.jsxs("div",{className:"space-y-3",children:[Es&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs py-8 justify-center",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Loading your listingsâ¦"})]}),!Es&&Ea&&e.jsxs("div",{className:"flex items-center gap-2 p-4 bg-rose-50 border border-rose-200 rounded-2xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{children:Ea}),e.jsx("button",{onClick:js,className:"ml-auto font-bold font-mono text-[10px] cursor-pointer",children:"RETRY"})]}),!Es&&!Ea&&us.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center bg-white border border-slate-200 rounded-3xl",children:[e.jsx(za,{className:"w-10 h-10 text-slate-200 mb-3"}),e.jsx("p",{className:"text-sm font-bold text-slate-700",children:"No listings yet"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1 max-w-[220px]",children:"Create your first listing and submit it for Realtified admin review to go live."}),e.jsxs("button",{onClick:()=>Re("choose"),className:"mt-4 flex items-center gap-1.5 px-4 py-2 bg-brand-500 hover:bg-brand-600 text-white text-[10px] font-bold rounded-xl transition-all cursor-pointer",children:[e.jsx(Ot,{className:"w-3.5 h-3.5"}),"New Listing"]})]}),!Es&&us.map(t=>{var ae,Se,_e,at;Id(t.approvalStatus);const n=ao(t.commercialStatus),c=t.approvalStatus==="draft"||t.approvalStatus==="rejected",S=Is===t.id,k=st===t.id;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Mo,{layout:"row",isLive:t.approvalStatus==="approved"&&!!g,onOpen:()=>g==null?void 0:g({id:t.id,slug:t.slug}),identity:{name:t.name,image:t.imageUrl||((Se=(ae=t.media)==null?void 0:ae.galleryImages)==null?void 0:Se[0])||null,pageImages:((_e=t.media)==null?void 0:_e.galleryImages)??null,videoUrl:((at=t.media)==null?void 0:at.walkthroughVideoUrl)??null,developer:t.developer,locality:t.location,city:t.district,reraNumber:t.reraNumber,reraVerified:t.approvalStatus==="approved",propertyType:t.propertyType}
20,status:Ud(t.approvalStatus),meta:[...Cl[t.id]!=null?[{label:"Completeness",value:`${Cl[t.id]}%`}]:[],...Ba[t.id]?[{label:"Leads",value:Ba[t.id]}]:[],...t.basePricePerSqFt!=null?[{label:"Price",value:`â¹${t.basePricePerSqFt.toLocaleString()}/sqft`}]:[],...t.hasCommercialDetails?[{label:"Commercial",value:n.label.replace(/^Commercial /,"")}]:[]],actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>Rl(t),className:"flex items-center justify-center gap-1 min-h-[40px] sm:min-h-0 px-3 py-1.5 bg-slate-50 hover:bg-slate-100 border border-slate-200 text-slate-700 text-[10px] font-bold rounded-xl transition-all cursor-pointer",children:[e.jsx(To,{className:"w-3 h-3"}),t.approvalStatus==="draft"?"Continue":"Edit"]}),e.jsxs("button",{onClick:()=>k?$a(null):sl(t),className:"flex items-center justify-center gap-1 min-h-[40px] sm:min-h-0 px-3 py-1.5 bg-indigo-50 hover:bg-indigo-100 border border-indigo-200 text-indigo-700 text-[10px] font-bold rounded-xl transition-all cursor-pointer",children:[e.jsx(Do,{className:"w-3 h-3"}),k?"Close Form":"Commercial Details"]}),e.jsxs("button",{onClick:()=>{O(t.id),de("matrix"),D("pricing-inventory")},className:"flex items-center justify-center gap-1 min-h-[40px] sm:min-h-0 px-3 py-1.5 bg-emerald-50 hover:bg-emerald-100 border border-emerald-200 text-emerald-700 text-[10px] font-bold rounded-xl transition-all cursor-pointer",children:[e.jsx(xl,{className:"w-3 h-3"}),"Inventory & Pricing"]}),c&&e.jsx("button",{disabled:S,onClick:()=>no(t),className:"flex items-center justify-center gap-1 min-h-[40px] sm:min-h-0 px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white text-[10px] font-bold rounded-xl transition-all cursor-pointer disabled:opacity-50",children:S?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 animate-spin"})," Submittingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Xl,{className:"w-3 h-3"})," Submit for Review"]})}),t.approvalStatus==="pending_approval"&&e.jsx("span",{className:"text-[10px] font-mono text-amber-600 font-semibold",children:"Cleared legal â awaiting final approval"})]}),footer:e.jsxs("div",{className:"space-y-2",children:[t.approvalStatus==="rejected"&&t.rejectionReason&&e.jsxs("div",{className:"p-2.5 bg-rose-50 border border-rose-200 rounded-xl text-[10px] text-rose-700 font-semibold",children:["Rejected",t.rejectedStage==="legal"?" at legal review":t.rejectedStage==="ops"?" at final approval":"",": ",t.rejectionReason]}),t.commercialStatus==="rejected"&&t.commercialReason&&e.jsxs("div",{className:"p-2.5 bg-rose-50 border border-rose-200 rounded-xl text-[10px] text-rose-700 font-semibold",children:["Commercial rejected: ",t.commercialReason]}),t.commercialStatus==="pending"&&e.jsx("p",{className:"text-[10px] text-amber-600 font-mono font-semibold",children:"Commercial details go live to buyers only after admin approval."}),$d(t.listingKind)&&a&&e.jsx(Mi,{user:a,listingId:t.id,compact:!0})]})}),e.jsx(es,{children:k&&e.jsx(Xe.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:e.jsxs("form",{onSubmit:to,className:"mt-3 p-4 bg-indigo-50 border border-indigo-100 rounded-2xl space-y-3",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-indigo-700 uppercase tracking-wider",children:"Complete / Edit Commercial Details"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Construction Status"}),e.jsx("select",{value:We.status,onChange:f=>Zt(A=>({...A,status:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500 bg-white cursor-pointer",children:Bd.map(f=>e.jsx("option",{value:f,children:f},f))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Base Price / Sq.Ft (â¹)"}),e.jsx("input",{type:"number",placeholder:"e.g. 8500",value:We.basePricePerSqFt,onChange:f=>
20Zt(A=>({...A,basePricePerSqFt:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500 font-mono",min:1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Property Type"}),e.jsx("input",{type:"text",placeholder:"e.g. Apartment, Villa",value:We.propertyType,onChange:f=>Zt(A=>({...A,propertyType:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Image URL"}),e.jsx("input",{type:"url",placeholder:"https://...",value:We.imageUrl,onChange:f=>Zt(A=>({...A,imageUrl:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Size Range"}),e.jsx("input",{type:"text",placeholder:"e.g. 1200â2400 sq.ft.",value:We.sizeRange,onChange:f=>Zt(A=>({...A,sizeRange:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Price Range"}),e.jsx("input",{type:"text",placeholder:"e.g. 1.2â2.8 Cr",value:We.priceRange,onChange:f=>Zt(A=>({...A,priceRange:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Amenities (comma-separated)"}),e.jsx("input",{type:"text",placeholder:"e.g. Gym, Clubhouse, Swimming Pool",value:We.amenities,onChange:f=>Zt(A=>({...A,amenities:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"})]})]}),e.jsxs("div",{className:"border border-slate-200 rounded-xl overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>Qr(f=>!f),className:"w-full flex items-center justify-between px-4 py-3 bg-slate-50 hover:bg-slate-100 text-left transition-all cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[10px] font-mono font-bold text-slate-700 uppercase tracking-wider",children:[e.jsx(Io,{className:"w-3.5 h-3.5 text-brand-500"}),"Media â Brochure · Walkthrough Video · Gallery · Floor Plans · Scene Clips"]}),Jr?e.jsx(pn,{className:"w-3.5 h-3.5 text-slate-400"}):e.jsx(bl,{className:"w-3.5 h-3.5 text-slate-400"})]}),e.jsx(es,{children:Jr&&e.jsx(Xe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:e.jsxs("div",{className:"p-4 space-y-4 bg-white",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block",children:"Brochure (PDF)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"url",placeholder:"https://... (PDF URL)",value:Be.brochureUrl,onChange:f=>Qe(A=>({...A,brochureUrl:f.target.value})),className:"flex-1 px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"}),e.jsxs("label",{className:`flex items-center gap-1 px-3 py-1.5 border rounded-lg text-[10px] font-bold cursor-pointer transition-all ${Ke.brochure==="uploading"?"bg-slate-100 border-slate-200 text-slate-400":"bg-indigo-50 border-indigo-200 text-indigo-700 hover:bg-indigo-100"}`,children:[Ke.brochure==="uploading"?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx($s,{className:"w-3 h-3"}),"Upload",e.jsx("input",{type:"file",accept:".pdf,application/pdf",className:"hidden",disabled:Ke.brochure==="uploading",onCh
20ange:f=>{var oe;const A=(oe=f.target.files)==null?void 0:oe[0];!A||!st||(br(A,st,"brochure",be=>Qe(X=>({...X,brochureUrl:be}))),f.target.value="")}})]})]}),Ke.brochure==="done"&&e.jsx("p",{className:"text-[10px] text-emerald-600 font-mono",children:"Upload complete."}),ht.brochure&&e.jsxs("p",{className:"text-[10px] text-amber-600 font-mono",children:[ht.brochure," â URL input still usable."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block",children:"Walkthrough Video"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"url",placeholder:"https://... (video URL)",value:Be.walkthroughVideoUrl,onChange:f=>Qe(A=>({...A,walkthroughVideoUrl:f.target.value})),className:"flex-1 px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"}),e.jsxs("label",{className:`flex items-center gap-1 px-3 py-1.5 border rounded-lg text-[10px] font-bold cursor-pointer transition-all ${Ke.walkthrough==="uploading"?"bg-slate-100 border-slate-200 text-slate-400":"bg-indigo-50 border-indigo-200 text-indigo-700 hover:bg-indigo-100"}`,children:[Ke.walkthrough==="uploading"?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx($s,{className:"w-3 h-3"}),"Upload",e.jsx("input",{type:"file",accept:"video/*",className:"hidden",disabled:Ke.walkthrough==="uploading",onChange:f=>{var oe;const A=(oe=f.target.files)==null?void 0:oe[0];!A||!st||(br(A,st,"walkthrough",be=>Qe(X=>({...X,walkthroughVideoUrl:be}))),f.target.value="")}})]})]}),Ke.walkthrough==="done"&&e.jsx("p",{className:"text-[10px] text-emerald-600 font-mono",children:"Upload complete."}),ht.walkthrough&&e.jsxs("p",{className:"text-[10px] text-amber-600 font-mono",children:[ht.walkthrough," â URL input still usable."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block",children:"RERA Application Document (PDF)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"url",placeholder:"https://... (PDF URL)",value:Be.reraApplicationUrl,onChange:f=>Qe(A=>({...A,reraApplicationUrl:f.target.value})),className:"flex-1 px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"}),e.jsxs("label",{className:`flex items-center gap-1 px-3 py-1.5 border rounded-lg text-[10px] font-bold cursor-pointer transition-all ${Ke["rera-doc"]==="uploading"?"bg-slate-100 border-slate-200 text-slate-400":"bg-indigo-50 border-indigo-200 text-indigo-700 hover:bg-indigo-100"}`,children:[Ke["rera-doc"]==="uploading"?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx($s,{className:"w-3 h-3"}),"Upload",e.jsx("input",{type:"file",accept:".pdf,application/pdf",className:"hidden",disabled:Ke["rera-doc"]==="uploading",onChange:f=>{var oe;const A=(oe=f.target.files)==null?void 0:oe[0];!A||!st||(br(A,st,"rera-doc",be=>Qe(X=>({...X,reraApplicationUrl:be}))),f.target.value="")}})]})]}),Ke["rera-doc"]==="done"&&e.jsx("p",{className:"text-[10px] text-emerald-600 font-mono",children:"Upload complete."}),ht["rera-doc"]&&e.jsxs("p",{className:"text-[10px] text-amber-600 font-mono",children:[ht["rera-doc"]," â URL input still usable."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block",children:"Gallery Images"}),Be.galleryImages.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Be.galleryImages.map((f,A)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:Ni(f,{width:80}),alt:`Gallery ${A+1}`,loading:"lazy",decoding:"async",className:"w-16 h-16 object-cover rounded-lg border border-slate-200",onError:oe=>{oe.target.src=""}}),e.jsx("button",{type:"button",onClick:()=>Qe(oe=>({...oe,galleryImages:oe.galleryImages.filter((be,X)=>X!==A)})),"aria-label":`Remove gallery image ${A+1}`,className:"absolute -top-2 -right-2 w-6 h-6 md:w-4 md:h-4 md:-top-1.5 md:-right-1.5 bg-rose-500 text-white rounded-full flex items-center justify-center opacity-100 md:opacity-0 md:group-hover:opacity-100 focus-visible:opacity-100 transition-opacity cursor-pointer",children:e.jsx(ot,{className:"w-3 h-3 md:w-2.5 md:h-2.5"})})]},A))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"url",placeholder:"https://... (image URL)",value:bs,onChange:f=>ea(f.target.value),className:"flex-1 px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500",onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),bs.trim()&&(Qe(A=>({...A,galleryImages:[...A.galleryImages,bs.trim()]})),ea("")))}}),e.jsx("button",{type:"button",onClick:()=>{bs.trim()&&(Qe(f=>({...f,galleryImages:[...f.galleryImages,bs.trim()]})),ea(""))},className:"px-3 py-1.5 bg-indigo-50 border border-indigo-200 text-indigo-700 text-[10px] font-bold rounded-lg hover:bg-indigo-100 cursor-pointer",children:"+ Add"}),e.jsxs("label",{className:`flex items-center gap-1 px-3 py-1.5 border rounded-lg text-[10px] font-bold cursor-pointer transition-all ${Ke["gallery-upload"]==="uploading"?"bg-slate-100 border-slate-200 text-slate-400":"bg-indigo-50 border-indigo-200 text-indigo-700 hover:bg-indigo-100"}`,children:[Ke["gallery-upload"]==="uploading"?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx($s,{className:"w-3 h-3"}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",disabled:Ke["gallery-upload"]==="uploading",onCh
20ange:async f=>{const A=Array.from(f.target.files||[]);if(!(!A.length||!st)){lt(oe=>({...oe,"gallery-upload":"uploading"}));try{const oe=await Promise.all(A.map(be=>ra(be,`projects/${st}/gallery-${Date.now()}-${Math.random().toString(36).slice(2)}`)));Qe(be=>({...be,galleryImages:[...be.galleryImages,...oe]})),lt(be=>({...be,"gallery-upload":"done"}))}catch(oe){lt(be=>({...be,"gallery-upload":"error"})),b((oe==null?void 0:oe.message)||"Upload failed")}f.target.value=""}}})]})]}),ht["gallery-upload"]&&e.jsxs("p",{className:"text-[10px] text-amber-600 font-mono",children:[ht["gallery-upload"]," â use URL input instead."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block",children:"Floor Plans"}),Be.floorPlans.length>0&&e.jsx("div",{className:"space-y-1.5",children:Be.floorPlans.map((f,A)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-slate-50 border border-slate-200 rounded-lg",children:[e.jsx(za,{className:"w-3.5 h-3.5 text-slate-400 shrink-0"}),e.jsx("span",{className:"text-[10px] font-mono font-bold text-slate-700 flex-1 truncate",children:f.label}),e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-600 font-mono hover:underline truncate max-w-[120px]",children:f.url}),e.jsx("button",{type:"button",onClick:()=>Qe(oe=>({...oe,floorPlans:oe.floorPlans.filter((be,X)=>X!==A)})),className:"text-rose-400 hover:text-rose-600 cursor-pointer shrink-0",children:e.jsx(ot,{className:"w-3 h-3"})})]},A))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Label (e.g. 3BHK Type A)",value:Jt,onChange:f=>s(f.target.value),className:"w-1/3 px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"}),e.jsx("input",{type:"url",placeholder:"https://... (image/PDF URL)",value:p,onChange:f=>P(f.target.value),className:"flex-1 px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"}),e.jsx("button",{type:"button",onClick:()=>{Jt.trim()&&p.trim()&&(Qe(f=>({...f,floorPlans:[...f.floorPlans,{label:Jt.trim(),url:p.trim()}]})),s(""),P(""))},className:"px-3 py-1.5 bg-indigo-50 border border-indigo-200 text-indigo-700 text-[10px] font-bold rounded-lg hover:bg-indigo-100 cursor-pointer",children:"+ Add"}),e.jsxs("label",{className:`flex items-center gap-1 px-3 py-1.5 border rounded-lg text-[10px] font-bold cursor-pointer transition-all ${Ke["fp-upload"]==="uploading"?"bg-slate-100 border-slate-200 text-slate-400":"bg-indigo-50 border-indigo-200 text-indigo-700 hover:bg-indigo-100"}`,children:[Ke["fp-upload"]==="uploading"?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx($s,{className:"w-3 h-3"}),e.jsx("input",{type:"file",accept:"image/*,.pdf",className:"hidden",disabled:Ke["fp-upload"]==="uploading",onChange:async f=>{var be;const A=(be=f.target.files)==null?void 0:be[0];if(!A||!st)return;const oe=Jt.trim()||A.name;lt(X=>({...X,"fp-upload":"uploading"}));try{const X=await ra(A,`projects/${st}/floorplan-${Date.now()}`);Qe(Ne=>({...Ne,floorPlans:[...Ne.floorPlans,{label:oe,url:X}]})),s(""),lt(Ne=>({...Ne,"fp-upload":"done"}))}catch(X){lt(Ne=>({...Ne,"fp-upload":"error"})),b((X==null?void 0:X.message)||"Upload failed")}f.target.value=""}})]})]}),ht["fp-upload"]&&e.jsxs("p",{className:"text-[10px] text-amber-600 font-mono",children:[ht["fp-upload"]," â use URL input instead."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block",children:"Immersive Scene Clips (Video)"}),Be.videoClips.length>0&&e.jsx("div",{className:"space-y-1.5",children:Be.videoClips.map((f,A)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-slate-50 border border-slate-200 rounded-lg",children:[e.jsx(On,{className:"w-3.5 h-3.5 text-slate-400 shrink-0"}),e.jsxs("span",{className:"text-[10px] font-mono font-bold text-slate-700 flex-1 truncate",children:[f.label,f.startSec!==void 0&&f.endSec!==void 0&&` (${f.startSec}s - ${f.endSec}s)`]}),f.url&&e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-600 font-mono hover:underline truncate max-w-[120px]",children:f.url}),e.jsx("button",{type:"button",onClick:()=>Qe(oe=>({...oe,videoClips:oe.videoClips.filter((be,X)=>X!==A)})),className:"text-rose-400 hover:text-rose-600 cursor-pointer shrink-0",children:e.jsx(ot,{className:"w-3 h-3"})})]},A))}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-2",children:[e.jsx("input",{type:"text",placeholder:"Scene label (e.g. Swimming Pool)",value:we,onChange:f=>fe(f.target.value),className:"px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"}),e.jsx("input",{type:"url",placeholder:"Video URL (defaults to Walkthrough Video)",value:_,onCh
20ange:f=>gs(f.target.value),className:"px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"}),e.jsxs("div",{className:"flex gap-2 col-span-2",children:[e.jsx("input",{type:"number",placeholder:"Start (s)",value:Oe,onChange:f=>nt(f.target.value),className:"w-1/4 px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"}),e.jsx("input",{type:"number",placeholder:"End (s)",value:ct,onChange:f=>Us(f.target.value),className:"w-1/4 px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"}),e.jsx("button",{type:"button",onClick:()=>{const f=we.trim(),A=_.trim()||Be.walkthroughVideoUrl.trim(),oe=Sn(Oe),be=Sn(ct);if(oe===void 0!=(be===void 0)||oe!==void 0&&be!==void 0&&be<=oe){b("Enter both a start and an end time (end after start), or leave both blank.");return}f&&A&&(Qe(X=>({...X,videoClips:[...X.videoClips,{label:f,url:A,startSec:oe,endSec:be}]})),fe(""),gs(""),nt(""),Us(""))},className:"flex-1 px-3 py-1.5 bg-indigo-50 border border-indigo-200 text-indigo-700 text-[10px] font-bold rounded-lg hover:bg-indigo-100 cursor-pointer",children:"+ Add Clip"}),e.jsxs("label",{className:`flex items-center justify-center gap-1 px-3 py-1.5 border rounded-lg text-[10px] font-bold cursor-pointer transition-all shrink-0 ${Ke["clip-upload"]==="uploading"?"bg-slate-100 border-slate-200 text-slate-400":"bg-indigo-50 border-indigo-200 text-indigo-700 hover:bg-indigo-100"}`,children:[Ke["clip-upload"]==="uploading"?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx($s,{className:"w-3 h-3"}),e.jsx("input",{type:"file",accept:"video/*",className:"hidden",disabled:Ke["clip-upload"]==="uploading",onChange:async f=>{var be;const A=(be=f.target.files)==null?void 0:be[0];if(!A||!st)return;const oe=we.trim()||A.name;lt(X=>({...X,"clip-upload":"uploading"}));try{const X=await ra(A,`projects/${st}/clip-${Date.now()}`);Qe(Ne=>({...Ne,videoClips:[...Ne.videoClips,{label:oe,url:X}]})),fe(""),lt(Ne=>({...Ne,"clip-upload":"done"}))}catch(X){lt(Ne=>({...Ne,"clip-upload":"error"})),b((X==null?void 0:X.message)||"Upload failed")}f.target.value=""}})]})]})]}),ht["clip-upload"]&&e.jsxs("p",{className:"text-[10px] text-amber-600 font-mono",children:[ht["clip-upload"]," â use URL input instead."]}),e.jsxs("div",{className:"mt-4 pt-3 border-t border-slate-100",children:[e.jsxs("button",{type:"button",onClick:()=>hr(!Et),className:"flex items-center gap-1 text-[10px] font-bold text-slate-500 hover:text-slate-800 transition-colors cursor-pointer",children:[Et?"â¼":"âº"," Bulk Import Clips from Shot Breakdown"]}),Et&&e.jsxs("div",{className:"mt-2.5 flex flex-col gap-2 bg-slate-50 p-2.5 rounded-lg border border-slate-200",children:[e.jsxs("p",{className:"text-[10px] text-slate-500",children:["Paste a timestamped shot breakdown list (e.g. from your video producer or editor). Format: ",e.jsx("code",{className:"bg-slate-200 px-1 rounded text-slate-700",children:"MM:SS - MM:SS | Scene Label"})," (one per line)."]}),e.jsx("textarea",{rows:4,placeholder:`Example: 210:23 - 0:29 | Rooftop Skybridge 220:33 - 0:36 | Yoga Deck`,value:ta,onChange:f=>fs(f.target.value),className:"w-full p-2 border border-slate-200 rounded-lg text-xs font-mono outline-none focus:ring-1 focus:ring-brand-500 bg-white"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>
22{fs(""),hr(!1)},className:"px-2.5 py-1 text-[10px] border border-slate-200 text-slate-600 rounded-md hover:bg-slate-100 cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>{const f=ta.split(` 23`),A=[],oe=Be.walkthroughVideoUrl.trim(),be=/(?:(?:\*\*|\[)?(\d{1,2}):(\d{2})\s*(?:-|to)\s*(\d{1,2}):(\d{2})(?:\*\*|\])?)(?:\s*[\|:-]\s*)(.+)/i;for(const X of f){const Ne=X.match(be);if(Ne){const ll=parseInt(Ne[1],10),nl=parseInt(Ne[2],10),ol=parseInt(Ne[3],10),il=parseInt(Ne[4],10),dl=Ne[5].trim(),Nr=ll*60+nl,tn=ol*60+il,sn=dl.replace(/[\*\`\[\]"']/g,"").trim();Nr<tn&&sn&&A.push({label:sn,url:oe,startSec:Nr,endSec:tn})}}A.length>0?(Qe(X=>({...X,videoClips:[...X.videoClips,...A]})),fs(""),hr(!1),b(`Successfully imported ${A.length} clips!`)):b("No valid timestamped clips found. Please check format: 'MM:SS - MM:SS | Scene Label'")},className:"px-2.5 py-1 text-[10px] bg-brand-500 border border-brand-600 text-white rounded-md hover:bg-brand-600 font-bold cursor-pointer",children:"Import Clips"})]})]})]})]})]})})})]}),e.jsxs("div",{className:"border border-slate-200 rounded-xl overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>kl(f=>!f),className:"w-full flex items-center justify-between px-4 py-3 bg-slate-50 hover:bg-slate-100 text-left transition-all cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[10px] font-mono font-bold text-slate-700 uppercase tracking-wider",children:[e.jsx(Uo,{className:"w-3.5 h-3.5 text-emerald-500"}),"Structured RERA Details â Promoter · Progress · Approvals"]}),el?e.jsx(pn,{className:"w-3.5 h-3.5 text-slate-400"}):e.jsx(bl,{className:"w-3.5 h-3.5 text-slate-400"})]}),e.jsx(es,{children:el&&e.jsx(Xe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:e.jsxs("div",{className:"p-4 space-y-4 bg-white",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Promoter / Developer Name"}),e.jsx("input",{type:"text",placeholder:"e.g. XYZ Developers Pvt. Ltd.",value:ye.promoterName,onChange:f=>Ze(A=>({...A,promoterName:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Total Land Area (Acres)"}),e.jsx("input",{type:"number",step:"0.01",placeholder:"e.g. 4.5",value:ye.totalLandAreaAcre,onChange:f=>Ze(A=>({...A,totalLandAreaAcre:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Open Space %"}),e.jsx("input",{type:"number",step:"0.1",min:"0",max:"100",placeholder:"e.g. 33",value:ye.openSpacePct,onChange:f=>Ze(A=>({...A,openSpacePct:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Number of Towers"}),e.jsx("input",{type:"number",min:"1",placeholder:"e.g. 4",value:ye.towers,onChange:f=>Ze(A=>({...A,towers:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Total Units"}),e.jsx("input",{type:"number",min:"1",placeholder:"e.g. 320",value:ye.totalUnits,onChange:f=>Ze(A=>({...A,totalUnits:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Commencement Date"}),e.jsx("input",{type:"date",value:ye.commencementDate,onChange:f=>Ze(A=>({...A,commencementDate:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Possession Date"}),e.jsx("input",{type:"date",value:ye.possessionDate,onChange:f=>Ze(A=>({...A,possessionDate:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500 font-mono"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block",children:["Construction Progress â ",ye.constructionProgressPct||0,"%"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"range",min:"0",max:"100",step:"1",value:ye.constructionProgressPct||0,onChange:f=>Ze(A=>({...A,constructionProgressPct:f.target.value})),className:"flex-1 h-1.5 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-emerald-500"}),e.jsx("input",{type:"number",min:"0",max:"100",value:ye.constructionProgressPct,onChange:f=>Ze(A=>({...A,constructionProgressPct:f.target.value})),className:"w-16 px-2 py-1 border border-slate-200 rounded-lg text-xs text-center outline-none focus:ring-1 focus:ring-indigo-500 font-mono"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1",children:"Specifications (comma-separated)"}),e.jsx("input",{type:"text",placeholder:"e.g. Vitrified flooring, RCC framed structure, UPVC windows",value:ye.specifications,onChange:f=>Ze(A=>({...A,specifications:f.target.value})),className:"w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-indigo-500"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-500 uppercase block",children:"Approvals & Clearances"}),e.jsx("div",{className:"space-y-2",children:ye.approvals.map((f,A)=>e.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-slate-50 border border-slate-200 rounded-lg",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${f.status==="verified"?"bg-emerald-500":f.status==="pending"?"bg-amber-400":"bg-slate-300"}`}),e.jsx("span",{className:"text-[10px] font-mono font-bold text-slate-700 flex-1",children:f.name}),f.status==="verified"?e.jsx("span",{className:"px-2 py-1 border border-emerald-200 bg-emerald-50 text-emerald-700 rounded-lg text-[10px] font-mono font-bold",title:"Verified by Realtified",children:"Verified by Realtified"}):e.jsxs("select",{value:f.status,onChange:oe=>Ze(be=>({...be,approvals:be.approvals.map((X,Ne)=>Ne===A?{...X,status:oe.target.value}:X)})),className:"px-2 py-1 border border-slate-200 rounded-lg text-[10px] font-mono outline-none focus:ring-1 focus:ring-indigo-500 bg-white cursor-pointer",children:[e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"na",children:"N/A"})]}),e.jsx("button",{type:"button",onClick:()=>Ze(oe=>({...oe,approvals:oe.approvals.filter((be,X)=>X!==A)})),className:"text-rose-400 hover:text-rose-600 cursor-pointer shrink-0",children:e.jsx(ot,{className:"w-3 h-3"})})]},A))}),e.jsxs("button",{type:"button",onClick:()=>Ze(f=>({...f,approvals:[...f.approvals,{name:"New Clearance",status:"pending"}]})),className:"flex items-center gap-1.5 px-3 py-1.5 border border-dashed border-slate-300 text-slate-500 text-[10px] font-mono rounded-lg hover:border-indigo-300 hover:text-indigo-600 transition-all cursor-pointer",children:[e.jsx(Ot,{className:"w-3 h-3"}),"Add Clearance"]})]})]})})})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-amber-50 border border-amber-200 rounded-xl",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 text-amber-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[10px] text-amber-700 font-mono leading-relaxed",children:"Commercial details including media and RERA details go live to buyers only after Realtified admin verification."})]}),Zr&&e.jsx("p",{className:"text-[10px] text-rose-600 font-semibold",children:Zr}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"submit",disabled:Xr,className:"flex items-center gap-1.5 px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-bold rounded-xl cursor-pointer disabled:opacity-50",children:Xr?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 animate-spin"})," Savingâ¦"]}):"Save & Submit for Review"}),e.jsx("button",{type:"button",onClick:()=>$a(null),className:"px-4 py-2 bg-white border border-slate-200 text-slate-600 text-[10px] font-bold rounded-xl cursor-pointer",children:"Cancel"})]})]})})})]},t.id)}),!Es&&Fs&&e.jsx("div",{className:"flex justify-center pt-1",children:e.jsx("button",{type:"button",onClick:ro,disabled:Ta,className:"px-4 py-2 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 text-[11px] font-bold rounded-xl cursor-pointer disabled:opacity-60",children:Ta?"Loa
23dingâ¦":`Load more (${us.length} of ${Or})`})})]})]})]},"my-listings-ws"),x==="team"&&e.jsx(Xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},className:"flex items-center justify-center py-20",children:e.jsxs("div",{className:"max-w-sm w-full bg-white border border-slate-200 rounded-3xl shadow-xs p-8 text-center space-y-4",children:[e.jsx("div",{className:"w-12 h-12 mx-auto rounded-2xl bg-brand-50 border border-brand-100 flex items-center justify-center",children:e.jsx(Fl,{className:"w-6 h-6 text-brand-600"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-sm font-extrabold text-slate-900 font-display",children:"Invite teammates â coming soon"}),e.jsx("p",{className:"text-xs text-slate-500 leading-relaxed",children:"Team accounts aren't built yet, so there's nothing to invite into today. When they launch, you'll be able to add colleagues to this builder workspace from here."})]})]})},"team-ws"),x==="account"&&e.jsx(Xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},className:"space-y-4 max-w-xl",children:e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-6 shadow-xs space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-100 pb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand-500 text-white flex items-center justify-center font-bold shrink-0",children:((a==null?void 0:a.displayName)||(a==null?void 0:a.email)||"B").charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-extrabold text-slate-900 truncate",children:(a==null?void 0:a.displayName)||"Builder"}),e.jsx("p",{className:"text-[11px] text-slate-500 font-mono truncate",children:a==null?void 0:a.email})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{className:"p-3 bg-slate-50 rounded-xl border border-slate-200/70 col-span-2",children:[e.jsx("span",{className:"text-[9px] font-mono text-slate-400 uppercase block",children:"Company"}),e.jsx("span",{className:"font-bold text-slate-800",children:dt.loaded?dt.companyName??"Not on file":"Loadingâ¦"}),dt.loaded&&!dt.companyName&&e.jsx("span",{className:"block text-[10px] text-slate-400 mt-0.5",children:dt.error??"No builder access request is linked to this account, so there is no company name on record."}),dt.companyName&&dt.requestStatus&&dt.requestStatus!=="approved"&&e.jsxs("span",{className:"block text-[10px] text-amber-600 mt-0.5",children:["From your builder access request (",dt.requestStatus,")."]})]}),e.jsxs("div",{className:"p-3 bg-slate-50 rounded-xl border border-slate-200/70",children:[e.jsx("span",{className:"text-[9px] font-mono text-slate-400 uppercase block",children:"Phone"}),e.jsx("span",{className:"font-bold text-slate-800 font-mono",children:dt.loaded?dt.phone??"Not on file":"Loadingâ¦"})]}),e.jsxs("div",{className:"p-3 bg-slate-50 rounded-xl border border-slate-200/70",children:[e.jsx("span",{className:"text-[9px] font-mono text-slate-400 uppercase block",children:"Listings"}),e.jsxs("span",{className:"font-bold text-slate-800",children:[U.length," claimed"]})]}),e.jsxs("div",{className:"p-3 bg-slate-50 rounded-xl border border-slate-200/70",children:[e.jsx("span",{className:"text-[9px] font-mono text-slate-400 uppercase block",children:"Workspace"}),e.jsx("span",{className:"font-bold text-slate-800",children:"Builder Console"})]})]}),v&&e.jsxs("button",{onClick:()=>v("account-settings"),className:"w-full py-2.5 border border-slate-200 hover:bg-slate-50 text-slate-700 font-bold rounded-xl text-xs flex items-center justify-center gap-2 cursor-pointer transition-colors",children:[e.jsx(Tl,{className:"w-4 h-4"})," Account settings"]}),v&&e.jsxs("button",{onClick:()=>v("home"),className:"lg:hidden w-full py-2.5 border border-slate-200 hover:bg-slate-50 text-slate-700 font-bold rounded-xl text-xs flex items-center justify-center gap-2 cursor-pointer transition-colors",children:[e.jsx(cl,{className:"w-4 h-4"})," Back to Realtified"]}),e.jsxs("button",{onClick:async()=>{try{await $l()}catch(t){console.error(t)}},className:"w-full py-2.5 border border-rose-200 hover:bg-rose-50 text-rose-600 font-bold rounded-xl text-xs flex items-center justify-center gap-2 cursor-pointer transition-colors",children:[e.jsx(Dl,{className:"w-4 h-4"})," Sign Out"]})]})},"account-ws"),x==="deal-desk"&&e.jsxs(Xe.div,{initial:{opacity:0,y:10}
23,animate:{opacity:1,y:0},exit:{opacity:0},className:"space-y-6 text-left",children:[e.jsxs("div",{className:"flex border-b border-slate-200",children:[e.jsx("button",{onClick:()=>Ce("offers-bookings"),className:`px-6 py-3 font-sans font-extrabold text-xs transition-all border-b-2 cursor-pointer ${Ae==="offers-bookings"?"border-brand-500 text-brand-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:"Offers & Bookings Console"}),e.jsx("button",{onClick:()=>Ce("buyer-journeys"),className:`px-6 py-3 font-sans font-extrabold text-xs transition-all border-b-2 cursor-pointer ${Ae==="buyer-journeys"?"border-brand-500 text-brand-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:"Client Journeys Control Desk (Site Visits / Dossiers)"})]}),Ae==="offers-bookings"?e.jsx(zd,{user:a,selectedProjectId:i,selectedListing:W,onSuccessNotification:b,localProposals:m}):e.jsxs("div",{className:"space-y-6 text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-extrabold text-slate-900 tracking-tight font-sans",children:"Active Client Journeys"}),e.jsx("p",{className:"text-[10px] text-slate-500 font-sans mt-0.5",children:"Manage buyer physical site visits, legal dossier compliance packages, and handover milestones"})]}),e.jsxs("button",{onClick:jr,className:"p-1.5 text-slate-400 hover:text-brand-600 hover:bg-brand-50 border border-slate-200 hover:border-brand-100 rounded-xl transition-all cursor-pointer flex items-center gap-1 text-[10px] font-bold",children:[e.jsx(hl,{className:`w-3.5 h-3.5 ${$e?"animate-spin":""}`})," Refresh Lists"]})]}),$e?e.jsxs("div",{className:"py-20 text-center",children:[e.jsx(ce,{className:"w-8 h-8 text-brand-500 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-slate-400 font-mono",children:"Fetching latest concierge records..."})]}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-6 space-y-4 shadow-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-slate-100 pb-3 text-left",children:[e.jsx(Rr,{className:"w-4 h-4 text-brand-500"}),e.jsxs("h4",{className:"text-sm font-extrabold text-slate-900 font-sans",children:["Site Visit Schedules (",Le.filter(t=>t.tier==="site_visit").length,")"]})]}),Le.filter(t=>t.tier==="site_visit").length===0?e.jsx("div",{className:"p-8 text-center bg-slate-50 border border-dashed border-slate-200 rounded-2xl text-slate-400 text-xs",children:"No active walkthrough requests."}):e.jsx("div",{className:"space-y-4",children:Le.filter(t=>t.tier==="site_visit").map(t=>{var at,f,A,oe,be;const n=((f=(at=t.requirement)==null?void 0:at.notes)==null?void 0:f.match(/requested for (.*?) on (.*?) at (.*?)\. Notes: (.*)/))||[],c=n[1]||"Project",S=n[4]||((A=t.requirement)==null?void 0:A.notes)||"No extra notes.",k=qe===t.id,ae=Ve[t.id]||"",Se=Fe[t.id]||n[2]||"",_e=le[t.id]||n[3]||"";return e.jsxs("div",{className:"border border-slate-200 rounded-2xl p-4 space-y-3 hover:border-slate-300 transition-all text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h5",{className:"font-extrabold text-xs text-slate-900",children:c}),e.jsx("span",{className:`text-[9px] font-mono font-bold px-2 py-0.5 rounded border uppercase ${t.status==="fulfilled"?"bg-emerald-50 border-emerald-200 text-emerald-800":t.status==="in_progress"?"bg-brand-50 border-brand-200 text-brand-700":"bg-amber-50 border-amber-200 text-amber-800"}`,children:t.status==="fulfilled"?"Completed":t.status==="in_progress"?"Assigned":"Awaiting RM"})]}),e.jsxs("div",{className:"text-[10px] text-slate-600 space-y-1 bg-slate-50 p-3 rounded-xl border border-slate-200",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-bold text-slate-700 font-sans",children:"Client:"})," ",t.buyerName||"Not provided",t.buyerPhone?` (${t.buyerPhone})`:""]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-bold text-slate-700 font-sans",children:"Message:"}
23)," ",S]})]}),t.status==="new"?e.jsxs("div",{className:"space-y-3 pt-2 border-t border-slate-100",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block uppercase",children:"Scheduled Date"}),e.jsx("input",{type:"date",value:Se,onChange:X=>$(Ne=>({...Ne,[t.id]:X.target.value})),className:"w-full text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block uppercase",children:"Slot Time"}),e.jsx("input",{type:"time",value:_e,onChange:X=>ne(Ne=>({...Ne,[t.id]:X.target.value})),className:"w-full text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[8px] font-mono font-bold text-slate-400 block uppercase",children:"Assign Relationship Manager"}),e.jsx("input",{type:"text",value:ae,onChange:X=>et(Ne=>({...Ne,[t.id]:X.target.value})),placeholder:"Name and phone of the RM handling this visit",className:"w-full text-xs p-2 bg-white border border-slate-200 rounded-xl outline-none"})]}),e.jsx("button",{disabled:k,onClick:async()=>{if(!ae||!Se){b("Please select a date and choose an RM.");return}Pe(t.id);try{const X=`Site visit requested for ${c} on ${Se} at ${_e||"10:00 AM"}. Notes: ${S}`,Ne=[{task:"Confirm walkthrough date",done:!0,note:`Confirmed for ${Se}`},{task:"Assign local relationship manager",done:!0,note:`Assigned to ${ae}`},{task:"Physical site walkthrough",done:!1,note:"Pending actual visit"},{task:"Share feedback & rates matrix",done:!1}];await Ml(a,t.id,{status:"in_progress",assignedToUid:"me",checklist:Ne}),b(`Site visit confirmed with RM ${ae}!`),jr()}catch(X){b(X.message||"Operation failed.")}finally{Pe(null)}},className:"w-full text-xs font-bold py-2 bg-brand-500 hover:bg-brand-600 text-white rounded-xl transition-all shadow-md shadow-brand-500/10 cursor-pointer disabled:opacity-50",children:"Confirm Walkthrough Slot"})]}):t.status==="in_progress"?e.jsxs("div",{className:"pt-2 border-t border-slate-100 flex items-center justify-between text-[10px]",children:[e.jsxs("span",{className:"text-slate-500 font-sans",children:["RM: ",e.jsx("span",{className:"font-bold text-slate-700",children:((be=(oe=(t.checklist||[]).find(X=>X.task==="Assign local relationship manager"))==null?void 0:oe.note)==null?void 0:be.replace(/^Assigned to /,""))||"Not on record"})]}),e.jsx("button",{disabled:k,onClick:async()=>{Pe(t.id);try{const X=(t.checklist||[]).map(Ne=>({...Ne,done:!0}));await Ml(a,t.id,{status:"fulfilled",checklist:X}),b("Site visit marked as completed!"),jr()}catch(X){b(X.message||"Operation failed.")}finally{Pe(null)}},className:"text-[10px] font-bold text-emerald-600 hover:underline cursor-pointer disabled:opacity-50",children:"Mark Visit Done"})]}):e.jsxs("div",{className:"pt-2 border-t border-slate-100 text-[10px] text-emerald-700 font-bold font-sans flex items-center gap-1",children:[e.jsx(ts,{className:"w-3.5 h-3.5"})," Walkthrough feedback logged"]})]},t.id)})})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-6 space-y-4 shadow-xs text-left",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-slate-100 pb-3",children:[e.jsx(zl,{className:"w-4 h-4 text-brand-500"}),e.jsxs("h4",{className:"text-sm font-extrabold text-slate-900 font-sans",children:["Legal Dossier Reviews (",Le.filter(t=>t.tier==="legal").length,")"]})]}),Le.filter(t=>t.tier==="legal").length===0?e.jsx("div",{className:"p-8 text-center bg-slate-50 border border-dashed border-slate-200 rounded-2xl text-slate-400 text-xs",children:"No active title verification requests."}):e.jsx("div",{className:"space-y-4",children:Le.filter(t=>t.tier==="legal").map(t=>{var k,ae,Se;const n=qe===t.id,S=(((ae=(k=t.requirement)==null?void 0:k.notes)==null?void 0:ae.match(/requested for (.*?)\./))||[])[1]||((Se=t.requirement)==null?void 0:Se.notes)||"Project";return e.jsxs("div",{className:"border border-slate-200 rounded-2xl p-4 space-y-3 hover:border-slate-300 transition-all text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h5",{className:"font-extrabold text-xs text-slate-900",children:S}),e.jsx("span",{className:`text-[9px] font-mono font-bold px-2 py-0.5 rounded border uppercase ${t.status==="fulfilled"?"bg-emerald-50 border-emerald-200 text-emerald-800":"bg-amber-50 border-amber-200 text-amber-800"}`,children:t.status==="fulfilled"?"Dossier Uploaded":"Awaiting Review"})]}),e.jsxs("p",{className:"text-[10.5px] text-slate-600 leading-snug",children:[e.jsx("span",{className:"font-bold text-slate-700",children:"Buyer:"})," ",t.buyerName||"Not provided",t.buyerPhone?` (${t.buyerPhone})`:""]}),t.status!=="fulfilled"?e.jsx("button",{disabled:n,onClick:async()=>{Pe(t.id);try{await Ml(a,t.id,{status:"fulfilled"}),b("Certified legal dossier approved & compiled!"),jr()}catch(_e){b(_e.message||"Operation failed.")}finally{Pe(null)}},className:"w-full text-xs font-bold py-2 bg-brand-500 hover:bg-brand-600 text-white rounded-xl transition-all shadow-md shadow-brand-500/10 cursor-pointer disabled:opacity-50",children:"Approve & Compile Legal Dossier"}):e.jsxs("div",{className:"pt-2 border-t border-slate-100 text-[10px] text-emerald-700 font-bold font-sans flex items-center gap-1",children:[e.jsx(ts,{className:"w-3.5 h-3.5"})," Certified RERA Legal Dossier sent to client."]})]},t.id)})})]})]})]})]},"deal-desk-ws")]})]})," ",Gs&&x!=="home"&&e.jsxs("div",{className:"hidden xl:flex w-[340px] bg-white border border-slate-200 rounded-3xl flex-col h-full overflow-hidden shrink-0 select-none text-left shadow-xs",children:[e.jsxs("div",{className:"p-3 border-b border-slate-200 bg-slate-50 flex items-center justify-between shrink-0 font-sans",children:[e.jsxs("div",{className:"flex items-center gap-1 bg-slate-200/50 border border-slate-200/20 p-0.5 rounded-xl",children:[e.jsx("button",{type:"button",onClick:()=>ua("activity"),className:`px-2 py-1 text-[10px] font-extrabold rounded-lg cursor-pointer transition-all active:scale-[0.96] ${gt==="activity"?"bg-white text-slate-900 shadow-2xs":"text-slate-500 hover:text-slate-800"}`,children:"Activity"}),wr("aiCopilot")&&e.jsxs("button",{type:"button",onClick:()=>ua("ai"),className:`px-2.5 py-1 text-[10px] font-extrabold rounded-lg cursor-pointer transition-all flex items-center gap-1 active:scale-[0.96] ${gt==="ai"?"bg-white text-slate-900 shadow-2xs":"text-slate-500 hover:text-slate-800"}`,children:[e.jsx(jl,{className:"w-2.5 h-2.5 text-brand-500"}),"AI Copilot"]}),wr("geoMap")&&e.jsx("button",{type:"button",onClick:()=>ua("map"),className:`px-2 py-1 text-[10px] font-extrabold rounded-lg cursor-pointer transition-all active:scale-[0.96] ${gt==="map"?"bg-white text-slate-900 shadow-2xs":"text-slate-500 hover:text-slate-800"}`,children:"Geo-Map"})]}),gt==="activity"&&e.jsx("button",{type:"button",onClick:Pl,"aria-label":"Refresh Activity",className:"p-1 text-slate-400 hover:text-brand-600 rounded hover:bg-slate-200/50 cursor-pointer transition-colors",title:"Refresh Activity",children:e.jsx(hl,{className:`w-3 h-3 ${Rs?"animate-spin":""}`})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto bg-white flex flex-col min-h-0",children:[gt==="activity"&&e.jsx("div",{className:"p-4 flex-1",children:e.jsx(hn,{activities:Ka,loading:Rs,emptyText:"No recent activities recorded for your projects."})}),gt==="ai"&&e.jsx(Jd,{user:a,selectedProject:W}),gt==="map"&&e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 relative h-full",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-slate-100 shrink-0 bg-slate-50/50",children:[e.jsx("span",{className:"text-[10px] font-mono text-slate-500 uppercase font-bold tracking-wider",children:"Hyderabad RERA Grid"}),e.jsx("span",{className:"text-[9px] bg-emerald-50 text-emerald-700 px-1.5 py-0.5 rounded font-bold",children:"GPS Sync Active"})]}),e.jsx("div",{className:"flex-1 min-h-0 h-full relative",children:e.jsx(Bi,{user:a,onSuccessNotification:b,onSelectProperty:t=>{if(t.dbId){const n=U.find(c=>c.id===t.dbId);n?(O(n.id),b(`Switched active workspace to "${n.name}"`)):b(`Selected "${t.name}" (unclaimed/competitor)`)}},backendProjects:ut.length>0?ut:U,mini:!0})})]})]})]})]})," "]}),e.jsx(Bo,{className:"lg:hidden",items:[{id:"home",label:"Overview",icon:nn,isActive:x==="home",onSelect:()=>D("home")},{id:"my-listings",label:"Listings",icon:on,isActive:x==="my-listings"||x==="pricing-inventory",onSelect:()=>D("my-listings")},{id:"leads",label:"Leads",icon:vr,isActive:x==="leads",onSelect:()=>D("leads")},{id:"team",label:"Team",icon:Fl,isActive:x==="team",onSelect:()=>D("team")},{id:"account",label:"Account",icon:Tl,isActive:x==="account",onSelect:()=>D("account")}]})]})})}const eo=["East","West","North","South","North-East","North-West","South-East","South-West"];function wt(a){if(!isFinite(a))return"â¹0";const l=Math.abs(a);return l>=1e7?`â¹${(a/1e7).toFixed(2)} Cr`:l>=1e5?`â¹${(a/1e5).toFixed(2)}
23 L`:`â¹${Math.round(a).toLocaleString("en-IN")}`}function _d(a){return{token_pending:{label:"Token Pending",cls:"bg-amber-50 text-amber-700 border border-amber-200"},token_paid:{label:"Token Paid",cls:"bg-brand-50 text-brand-700 border border-brand-200"},agreement:{label:"Agreement",cls:"bg-indigo-50 text-indigo-700 border border-indigo-200"},registered:{label:"Registered",cls:"bg-emerald-50 text-emerald-700 border border-emerald-200"},completed:{label:"Completed",cls:"bg-emerald-100 text-emerald-800 border border-emerald-300"},cancelled:{label:"Cancelled",cls:"bg-rose-50 text-rose-700 border border-rose-200"},expired:{label:"Expired",cls:"bg-slate-100 text-slate-500 border border-slate-200"}}[a]??{label:a,cls:"bg-slate-100 text-slate-500 border border-slate-200"}}function qd(a){return{sent:{label:"Sent",cls:"bg-brand-50 text-brand-700 border border-brand-200"},accepted:{label:"Accepted",cls:"bg-emerald-50 text-emerald-700 border border-emerald-200"},declined:{label:"Declined",cls:"bg-rose-50 text-rose-700 border border-rose-200"},expired:{label:"Expired",cls:"bg-slate-100 text-slate-500 border border-slate-200"},withdrawn:{label:"Withdrawn",cls:"bg-slate-100 text-slate-500 border border-slate-200"}}[a]??{label:a,cls:"bg-slate-100 text-slate-500 border border-slate-200"}}const Vd={token_paid:["agreement","cancelled"],agreement:["registered","cancelled"],registered:["completed","cancelled"]};function zd({user:a,selectedProjectId:l,selectedListing:j,onSuccessNotification:u,localProposals:E}){var Ge;const[y,F]=r.useState("deal-desk"),[b,K]=r.useState(null),[v,te]=r.useState(null),[V,g]=r.useState(!1),[M,i]=r.useState(null),[O,U]=r.useState([]),[ie,I]=r.useState(!1),R=r.useCallback(()=>{!a||l===null||(g(!0),i(null),Gn(a,l).then(te).catch(()=>{te(null),i(null)}).finally(()=>g(!1)))},[a,l]),G=r.useCallback(()=>{!a||l===null||(I(!0),Ar(a,l).then(U).catch(()=>U([])).finally(()=>I(!1)))},[a,l]);r.useEffect(()=>{R(),G()},[R,G]);const re=()=>({buyerEmail:"",planId:"",selectedUnitId:"",saleableArea:"",floor:"",facing:"",config:"",isCorner:!1,hasViewPremium:!1,baseRateOverride:"",freebies:"",tokenAmount:"100000",expires
23InDays:"7",chargeOverrides:{}}),[x,D]=r.useState(re()),[q,de]=r.useState(null),[J,me]=r.useState(!1);r.useEffect(()=>{if(!x.selectedUnitId)return;const o=O.find(L=>String(L.id)===x.selectedUnitId);o&&D(L=>({...L,saleableArea:String(o.sizeSqFt),floor:o.floor!=null?String(o.floor):L.floor,config:o.bhk?`${o.bhk}BHK`:L.config,facing:o.facing||L.facing,isCorner:o.isCorner||!1,hasViewPremium:o.hasViewPremium||!1}))},[x.selectedUnitId]);const Q=(()=>{if(!v||!x.planId||!x.saleableArea||!v.plans.find(pe=>pe.id===x.planId))return null;const L=parseFloat(x.saleableArea);if(!L||L<=0)return null;const je={areaBasis:v.areaBasis,plans:v.plans.map(pe=>pe.id===x.planId&&x.baseRateOverride?{...pe,baseRatePerSft:parseFloat(x.baseRateOverride)||pe.baseRatePerSft}:pe),charges:v.charges.filter(pe=>{const he=x.chargeOverrides[pe.id];return!(he!=null&&he.waived)}).map(pe=>{const he=x.chargeOverrides[pe.id];return he!=null&&he.amountOverride&&parseFloat(he.amountOverride)>0?{...pe,amount:parseFloat(he.amountOverride)}:pe}),taxes:v.taxes};try{const pe={saleableArea:L,floor:x.floor?parseInt(x.floor):void 0,facing:x.facing||void 0,config:x.config||void 0,isCorner:x.isCorner,hasViewPremium:x.hasViewPremium};return wl(je,x.planId,pe)}catch{return null}})(),Ie=async o=>{if(o.preventDefault(),!l||!a){de("No project selected.");return}if(!x.buyerEmail.trim()){de("Buyer email is required.");return}if(!x.planId){de("Select a payment plan.");return}const L=parseFloat(x.saleableArea);if(!L||L<=0){de("Saleable area is required.");return}const je=parseFloat(x.tokenAmount);if(!je||je<=0){de("Token amount is required.");return}me(!0),de(null);try{const pe=Object.entries(x.chargeOverrides).filter(([,he])=>he.waived||he.amountOverride&&parseFloat(he.amountOverride)>0).map(([he,xt])=>({chargeId:he,waived:xt.waived||void 0,amountOverride:!xt.waived&&xt.amountOverride&&parseFloat(xt.amountOverride)>0?parseFloat(xt.amountOverride):void 0}));await Ei(a,{projectId:l,unitId:x.selectedUnitId?parseInt(x.selectedUnitId):void 0,buyerEmail:x.buyerEmail.trim(),planId:x.planId,baseRateOverride:x.baseRateOverride?parseFloat(x.baseRateOverride):void 0,chargeOverrides:pe.length>0?pe:void 0,freebies:x.freebies.trim()||void 0,tokenAmount:je,unit:{saleableArea:L,floor:x.floor?parseInt(x.floor):void 0,facing:x.facing||void 0,config:x.config||void 0,isCorner:x.isCorner,hasViewPremium:x.hasViewPremium},expiresInDays:x.expiresInDays?parseInt(x.expiresInDays):void 0}),u(`Offer sent to ${x.buyerEmail}!`),D(re()),F("sent-offers")}catch(pe){de(pe.message||"Failed to send offer.")}finally{me(!1)}},[Ae,Ce]=r.useState([]),[Le,Je]=r.useState(!1),[$e,ve]=r.useState(null),[qe,Pe]=r.useState(null),Ve=r.useCallback(()=>{a&&(Je(!0),ve(null),Ai(a).then(o=>Ce(o.filter(L=>l===null||L.projectId===l))).catch(o=>ve(o.message||"Failed to load offers.")).finally(()=>Je(!1)))},[a,l]);r.useEffect(()=>{y==="sent-offers"&&Ve()},[y,Ve]);const et=async o=>{Pe(o);try{await Fi(a,o),u("Offer withdrawn."),Ve()}catch(L){ve(L.message||"Failed to withdraw offer.")}finally{Pe(null)}},[Fe,$]=r.useState([]),[le,ne]=r.useState(!1),[N,ue]=r.useState(null),[m,C]=r.useState(null),Y=r.useCallback(()=>{a&&(ne(!0),ue(null),Li(a).then(o=>$(o.filter(L=>l===null||L.projectId===l))).catch(o=>ue(o.message||"Failed to load bookings.")).finally(()=>ne(!1)))},[a,l]);r.useEffect(()=>{y==="bookings"&&Y()},[y,Y]);const h=async(o,L)=>{C(o);try{await Ti(a,o,L),u(`Booking advanced to "${L}".`),Y()}catch(je){ue(je.message||"Failed to advance booking.")}finally{C(null)}},[w,T]=r.useState(null),[B,H]=r.useState(null),xe=async o=>{T(o);try{await Di(a,o),u("Commission marked as released. Make sure the payout has actually been sent to the channel partner â this only updates the record."),H(null),Y()}catch(L){ue(L.message||"Failed to release commission.")}finally{T(null)}},z="w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500",se="text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-4 shadow-xs",children:[e.jsx("div",{className:"flex items-center gap-1 bg-slate-100 rounded-xl p-1 w-fit",children:[{key:"deal-desk",label:"Negotiations Board",icon:zl},{key:"compose",label:"Compose Offer",icon:Il},{key:"sent-offers",label:"Sent Offers",icon:qn},{key:"bookings",label:"Bookings",icon:mn}].map(({key:o,label:L,icon:je})=>e.jsxs("button",{onClick:()=>F(o),className:`flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-bold rounded-lg transition-all cursor-pointer font-mono uppercase ${y===o?"bg-brand-500 text-white shadow-sm":"text-slate-500 hover:text-slate-800"}`,children:[e.jsx(je,{className:"w-3.5 h-3.5"})," ",L]},o))}),l===null&&e.jsx("p",{className:"mt-3 text-[11px] text-amber-600 font-mono font-semibold",children:"No project selected â switch a project from the header dropdown."})]}),y==="deal-desk"&&e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-6 shadow-xs space-y-4 text-left",children:[e.jsxs("div",{className:"border-b border-slate-100 pb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-extrabold text-slate-900 font-display",children:"Negotiations Board"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Review, counter, and approve custom package deals submitted by CPs and buyers."})]}),e.jsx("span",{className:"px-2 py-0.5 text-[9px] font-mono font-bold rounded-full bg-slate-100 text-slate-500 border border-slate-200",children:"Local Drafts (This Device)"})]}),e.jsx("div",{className:"p-3 bg-slate-50 border border-slate-200 rounded-xl text-[10px] text-slate-500 leading-relaxed",children:`These are local drafts stored in this browser only â not yet synced across devices or to the CP/buyer's own session. Approving one does not create a booking; it flips the draft to "approved" so the buyer can proceed to token payment from their own device.`}),e.jsx("div",{className:"space-y-3",children:E.length===0?e.jsxs("div",{className:"p-8 text-center bg-slate-50 rounded-2xl border border-dashed border-slate-200",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-700",children:"No custom deal proposals"}),e.jsx("p",{className:"text-[10px] text-slate-400 mt-0.5",children:"Proposals submitted from this device will appear here for review."})]}):E.map(o=>e.jsx(Zd,{deal:o,onSuccessNotification:u},o.id))})]}),y==="compose"&&e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-4 items-start",children:[e.jsxs("div",{className:"xl:col-span-7 bg-white border border-slate-200 rounded-3xl p-6 shadow-xs space-y-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-extrabold text-slate-900 font-display",children:"Custom Offer Composer"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Send a negotiated offer to a buyer after a site visit. Uses the project's approved price sheet."})]}),V&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs py-4",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Loading price sheetâ¦"]}),!V&&!v&&e.jsx("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-2xl text-[11px] text-amber-700 font-semibold",children:'No approved price sheet for this project. Create and get your price sheet approved first under "Pricing / Price Sheet".'}),v&&v.status!=="approved"&&e.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-2xl text-[11px] text-amber-700 font-semibold",children:["Price sheet status: ",e.jsx("strong",{children:v.status}),". It must be approved before you can compose offers."]}),v&&v.status==="approved"&&e.jsxs("form",{onSubmit:Ie,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:se,children:"Buyer Email *"}),e.jsx("input",{type:"email",placeholder:"[email protected]",value:x.buyerEmail,onChange:o=>D(L=>({...L,buyerEmail:o.target.value})),className:z,required:!0})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:se,children:"Unit (optional â select to prefill)"}),ie?e.jsxs("div",{className:"flex items-center gap-1.5 text-slate-400 text-xs",children:[e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"})," Loadingâ¦"]}):e.jsxs("select",{value:x.selectedUnitId,onChange:o=>D(L=>({...L,selectedUnitId:o.target.value})),className:`${z} bg-white cursor-pointer`,children:[e.jsx("option",{value:"",children:"-- No specific unit --"}),O.map(o=>e.jsxs("option",{value:String(o.id),children:[o.unitNumber,o.floor!=null?` · Floor ${o.floor}`:"",o.bhk?` · ${o.bhk}BHK`:""," · ",o.sizeSqFt," sqft [",o.status,"]"]},o.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:se,children:"Payment Plan *"}),e.jsxs("select",{value:x.planId,onChange:o=>D(L=>({...L,planId:o.target.value})),className:`${z} bg-white cursor-pointer`,required:!0,children:[e.jsx("option",{value:"",children:"-- Select plan --"}),v.plans.map(o=>
23e.jsxs("option",{value:o.id,children:[o.name," (â¹",o.baseRatePerSft,"/sqft)"]},o.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:se,children:"Saleable Area (sqft) *"}),e.jsx("input",{type:"number",placeholder:"e.g. 1450",value:x.saleableArea,onChange:o=>D(L=>({...L,saleableArea:o.target.value})),className:`${z} font-mono`,required:!0,min:1})]}),e.jsxs("div",{children:[e.jsx("label",{className:se,children:"Floor"}),e.jsx("input",{type:"number",placeholder:"e.g. 8",value:x.floor,onChange:o=>D(L=>({...L,floor:o.target.value})),className:`${z} font-mono`})]}),e.jsxs("div",{children:[e.jsx("label",{className:se,children:"Facing"}),e.jsxs("select",{value:x.facing,onChange:o=>D(L=>({...L,facing:o.target.value})),className:`${z} bg-white cursor-pointer`,children:[e.jsx("option",{value:"",children:"-- Any --"}),eo.map(o=>e.jsx("option",{value:o,children:o},o))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:se,children:"Config (e.g. 3BHK)"}),e.jsx("input",{placeholder:"3BHK",value:x.config,onChange:o=>D(L=>({...L,config:o.target.value})),className:z})]}),e.jsxs("div",{className:"sm:col-span-2 flex items-center gap-6 mt-1",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-slate-700 font-bold cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:x.isCorner,onChange:o=>D(L=>({...L,isCorner:o.target.checked})),className:"rounded text-brand-500 focus:ring-brand-500"}),"Corner Unit Premium"]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-slate-700 font-bold cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:x.hasViewPremium,onChange:o=>D(L=>({...L,hasViewPremium:o.target.checked})),className:"rounded text-brand-500 focus:ring-brand-500"}),"View Premium Unit"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:se,children:"Base Rate Override (â¹/sqft) â optional"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-slate-400 font-bold text-xs",children:"â¹"}),e.jsx("input",{type:"number",placeholder:`Leave blank to use plan rate${x.planId?` (â¹${((Ge=v.plans.find(o=>o.id===x.planId))==null?void 0:Ge.baseRatePerSft)??""})`:""}`,value:x.baseRateOverride,onChange:o=>D(L=>({...L,baseRateOverride:o.target.value})),className:`${z} pl-6 font-mono`,min:1})]})]}),v.charges.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:se,children:"Charge Overrides"}),e.jsx("div",{className:"border border-slate-200 rounded-xl divide-y divide-slate-100",children:v.charges.map(o=>{var je;const L=x.chargeOverrides[o.id]??{waived:!1,amountOverride:""};return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-[10px] font-mono font-semibold text-slate-600 flex-1 min-w-0",children:[e.jsx("input",{type:"checkbox",checked:L.waived,onChange:pe=>D(he=>({...he,chargeOverrides:{...he.chargeOverrides,[o.id]:{...L,waived:pe.target.checked}}})),className:"accent-rose-500 shrink-0"}),e.jsx("span",{className:L.waived?"line-through text-slate-400":"",children:o.name}),e.jsx("span",{className:"text-slate-400 ml-1 shrink-0",children:o.basis!=="govt"&&o.amount!=null?`(${o.basis==="per_sft"?`â¹${o.amount}/sqft`:`â¹${(je=o.amount)==null?void 0:je.toLocaleString()}`})`:"(govt)"})]}),!L.waived&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("span",{className:"text-[9px] text-slate-400 font-mono",children:"Override:"}),e.jsx("input",{type:"number",placeholder:"â¹",value:L.amountOverride,onChange:pe=>D(he=>({...he,chargeOverrides:{...he.chargeOverrides,[o.id]:{...L,amountOverride:pe.target.value}}})),className:"w-24 px-2 py-1 border border-slate-200 rounded-lg text-xs font-mono outline-none focus:ring-1 focus:ring-brand-500",min:0})]})]},o.id)})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx("label",{className:se,children:"Freebies / Sweeteners (optional)"}),e.jsx("input",{placeholder:"e.g. Free modular kitchen, 1 year maintenance waived",value:x.freebies,onChange:o=>D(L=>({...L,freebies:o.target.value})),className:z})]}),e.jsxs("div",{children:[e.jsx("label",{className:se,children:"Token Amount (â¹) *"}),e.jsx("input",{type:"number",placeholder:"e.g. 100000",value:x.tokenAmount,onChange:o=>D(L=>({...L,tokenAmount:o.target.value})),className:`${z} font-mono`,required:!0,min:1})]}),e.jsxs("div",{children:[e.jsx("label",{className:se,children:"Expires In (days)"}),e.jsx("input",{type:"number",placeholder:"7",value:x.expiresInDays,onChange:o=>D(L=>({...L,expiresInDays:o.target.value})),className:`${z} font-mono`,min:1})]})]}),q&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700 font-semibold",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"})," ",q]}),e.jsx("button",{type:"submit",disabled:J,className:"w-full py-2.5 bg-brand-500 hover:bg-brand-600 text-white text-xs font-bold rounded-xl transition-all cursor-pointer disabled:opacity-50 flex items-center justify-center gap-1.5",children:J?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Sendingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Il,{className:"w-4 h-4"})," Send Offer to Buyer"]})})]})]}),e.jsx("div",{className:"xl:col-span-5 xl:sticky xl:top-4",children:Q?e.jsxs("div",{className:"bg-slate-900 text-white border border-slate-800 rounded-3xl p-5 shadow-xs space-y-4",children:[e.jsxs("p",{className:"text-xs font-extrabold font-mono uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(Hl,{className:"w-4 h-4 text-brand-400"})," Negotiated Value Preview"]}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-400",children:"Base Consideration"}),e.jsx("span",{className:"font-mono font-bold",children:wt(Q.baseConsideration)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-400",children:"Charges"}),e.jsx("span",{className:"font-mono font-bold",children:wt(Q.chargesTotal)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-slate-400",children:["GST (",Q.gstPct,"%)"]}),e.jsx("span",{className:"font-mono font-bold",children:wt(Q.gst)})]}),Q.govtItems.length>0&&e.jsx("div",{className:"text-[10px] text-slate-500 font-mono",children:"+ govt charges (stamp duty, registration)"}),e.jsxs("div",{className:"flex justify-between pt-2 border-t border-slate-700",children:[e.jsx("span",{className:"font-extrabold uppercase font-mono text-[10px] tracking-wider text-slate-300",children:"Grand Total"}),e.jsx("span",{className:"font-extrabold text-brand-400 font-mono text-base",children:wt(Q.grandTotal)})]}),v&&v.plans.find(o=>o.id===x.planId)&&(()=>{const o=v.plans.find(xt=>xt.id===x.planId),L=parseFloat(x.saleableArea)||0,je=o.baseRatePerSft,pe=x.baseRateOverride?parseFloat(x.baseRateOverride):je,he=Math.round((je-pe)*L);return he>0?e.jsxs("div",{className:"flex justify-between pt-1",children:[e.jsx("span",{className:"text-emerald-400 text-[10px] font-mono font-semibold",children:"Buyer savings vs. list"}),e.jsxs("span",{className:"text-emerald-400 font-mono font-bold text-[10px]",children:["â",wt(he)]})]}):null})()]}),x.freebies&&e.jsxs("div",{className:"p-3 bg-slate-800 rounded-xl text-[10px] text-slate-300 font-mono",children:["Freebies: ",x.freebies]}),e.jsxs("div",{className:"flex justify-between text-[10px] font-mono text-slate-400",children:[e.jsx("span",{children:"Token"}),e.jsx("span",{className:"text-white font-bold",children:wt(parseFloat(x.tokenAmount)||0)})]})]}):e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-3xl p-8 text-center text-slate-400 flex flex-col items-center gap-3",children:[e.jsx(Hl,{className:"w-8 h-8 text-slate-300"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-600",children:"Live Preview"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1",children:"Select a plan and enter area to see the negotiated value."})]})]})})]}),y==="sent-offers"&&e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-6 shadow-xs space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-extrabold text-slate-900 font-display",children:"Sent Offers"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Custom offers sent to buyers for this project."})]}),e.jsxs("button",{onClick:Ve,className:"flex items-center gap-1.5 px-3 py-1.5 bg-slate-50 hover:bg-slate-100 border border-slate-200 text-slate-600 text-[10px] font-bold rounded-xl transition-all cursor-pointer font-mono",children:[e.jsx(un,{className:"w-3 h-3"})," Refresh"]})]}),Le&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs py-6 justify-center",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Loading offersâ¦"]}),$e&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"})," ",$e,e.jsx("button",{onClick:Ve,className:"ml-auto font-bold font-mono text-[10px] cursor-pointer",children:"RETRY"})]}),!Le&&!$e&&Ae.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Il,{className:"w-10 h-10 text-slate-200 mb-3"}),e.jsx("p",{className:"text-sm font-bold text-slate-600",children:"No offers yet"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1",children:'Compose your first offer for a buyer in the "Compose Offer" tab.'})]}),!Le&&Ae.length>0&&e.jsx("div",{className:"space-y-3",children:Ae.map(o=>{const L=qd(o.status);return e.jsxs("div",{className:"border border-slate-200 rounded-2xl p-4 space-y-2 hover:border-slate-300 transition-all",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"space-y-0.5 flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-xs font-bold text-slate-800",children:o.buyerEmail}),e.jsx("span",{className:`px-2 py-0.5 text-[9px] font-mono font-bold rounded-md uppercase ${L.cls}`,children:L.label})]}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500",children:["Plan: ",o.planName," ⢠Negotiated: ",e.jsx("strong",{className:"text-brand-600",children:wt(parseFloat(o.negotiatedValue))})]}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-400",children:["Token: ",wt(o.tokenAmount),o.expiresAt&&` · Expires: ${new Date(o.expiresAt).toLocaleDateString("en-IN")}`,o.freebies&&` · Freebies: ${o.freebies}`]})]}),o.status==="sent"&&e.jsxs("button",{disabled:qe===o.id,onClick:()=>et(o.id),className:"flex items-center gap-1 px-3 py-1.5 bg-slate-50 hover:bg-rose-50 border border-slate-200 hover:border-rose-200 text-slate-600 hover:text-rose-600 text-[10px] font-bold rounded-xl transition-all cursor-pointer disabled:opacity-50 shrink-0",children:[qe===o.id?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(ot,{className:"w-3 h-3"}),"Withdraw"]})]}),e.jsxs("p",{className:"text-[9px] text-slate-400 font-mono",children:["Sent: ",new Date(o.createdAt).toLocaleStr
23ing("en-IN")]})]},o.id)})})]}),y==="bookings"&&e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-6 shadow-xs space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-extrabold text-slate-900 font-display",children:"Bookings Tracker"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Track and advance bookings for your projects through the transaction state machine."})]}),e.jsxs("button",{onClick:Y,className:"flex items-center gap-1.5 px-3 py-1.5 bg-slate-50 hover:bg-slate-100 border border-slate-200 text-slate-600 text-[10px] font-bold rounded-xl transition-all cursor-pointer font-mono",children:[e.jsx(un,{className:"w-3 h-3"})," Refresh"]})]}),le&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs py-6 justify-center",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Loading bookingsâ¦"]}),N&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"})," ",N,e.jsx("button",{onClick:Y,className:"ml-auto font-bold font-mono text-[10px] cursor-pointer",children:"RETRY"})]}),!le&&!N&&Fe.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mn,{className:"w-10 h-10 text-slate-200 mb-3"}),e.jsx("p",{className:"text-sm font-bold text-slate-600",children:"No bookings yet"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1",children:"Bookings appear here when buyers accept your offers and pay the token amount."})]}),!le&&Fe.length>0&&e.jsx("div",{className:"space-y-4",children:Fe.map(o=>{const L=_d(o.status),je=Vd[o.status]??[];return e.jsxs("div",{className:"border border-slate-200 rounded-2xl p-5 space-y-3 hover:border-slate-300 transition-all",children:[e.jsx("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:e.jsxs("div",{className:"space-y-1 flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-xs font-bold text-slate-800",children:o.buyerEmail}),e.jsx("span",{className:`px-2 py-0.5 text-[9px] font-mono font-bold rounded-md uppercase ${L.cls}`,children:L.label}),o.unitId&&e.jsxs("span",{className:"text-[9px] font-mono text-slate-500 bg-slate-100 px-1.5 py-0.5 rounded",children:["Unit #",o.unitId]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-[10px] font-mono text-slate-500 mt-1",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] uppercase tracking-wider block text-slate-400",children:"Agreement Value"}),e.jsx("span",{className:"font-bold text-slate-800",children:wt(parseFloat(o.agreementValue))})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] uppercase tracking-wider block text-slate-400",children:"Token"}),e.jsx("span",{className:"font-bold text-slate-800",children:wt(o.tokenAmount)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] uppercase tracking-wider block text-slate-400",children:"Funds"}),e.jsx("span",{className:`font-bold capitalize ${o.escrowStatus==="held"?"text-brand-600":o.escrowStatus==="released"?"text-emerald-600":"text-slate-600"}`,children:o.escrowStatus})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] uppercase tracking-wider block text-slate-400",children:"Commission"}),e.jsxs("span",{className:`font-bold ${o.commissionStatus==="released"?"text-emerald-600":"text-slate-600"}`,children:[o.commissionTotal?wt(parseFloat(o.commissionTotal)):"â"," ",e.jsxs("span",{className:"text-slate-400 font-normal capitalize",children:["(",o.commissionStatus,")"]})]})]})]}),e.jsxs("p",{className:"text-[9px] font-mono text-slate-400",children:["Booking #",o.id," · Plan: ",o.planId," · Created: ",new Date(o.createdAt).toLocaleDateString("en-IN")]})]})}),e.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-slate-100 flex-wrap",children:[e.jsxs("button",{onClick:()=>K(b===o.id?null:o.id),className:"px-3 py-1.5 bg-white hover:bg-slate-50 border border-slate-200 text-slate-600 hover:text-slate-800 text-[10px] font-bold rounded-xl transition-all cursor-pointer flex items-center gap-1 shadow-xs",children:[e.jsx(zl,{className:"w-3.5 h-3.5 text-slate-400"}),b===o.id?"Hide Deal Workspace":"Open Deal Workspace"]}),je.length>0&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider",children:"Advance:"}),je.map(pe=>e.jsxs("button",{disabled:m===o.id,onClick:()=>h(o.id,pe),className:`flex items-center gap-1 px-3 py-1.5 text-[10px] font-bold rounded-lg transition-all cursor-pointer disabled:opacity-50 ${pe==="cancelled"?"bg-rose-50 hover:bg-rose-100 border border-rose-200 text-rose-600 hover:text-rose-700":"bg-brand-50 hover:bg-brand-100 border border-brand-200 text-brand-700"}`,children:[m===o.id?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(Va,{className:"w-3 h-3"}),pe.charAt(0).toUpperCase()+pe.slice(1)]},pe))]}),o.commissionStatus==="accrued"&&o.channelPartnerId&&(B===o.id?e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-emerald-50 border border-emerald-200 rounded-xl flex-wrap max-w-full",children:[e.jsx("span",{className:"text-[10px] text-emerald-700 font-semibold",children:"This records the commission as paid out to the channel partner outside the platform â it does not move any money itself. Only confirm after you've actually sent the payment."}),e.jsxs("button",{disabled:w===o.id,onClick:()=>xe(o.id),className:"px-2.5 py-1 bg-emerald-500 hover:bg-emerald-600 text-white text-[10px] font-bold rounded-lg cursor-pointer disabled:opacity-50 flex items-center gap-1 shrink-0",children:[w===o.id?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(ts,{className:"w-3 h-3"})," Confirm Release"]}),e.jsx("button",{disabled:w===o.id,onClick:()=>H(null),className:"px-2.5 py-1 bg-white border border-slate-200 text-slate-600 text-[10px] font-bold rounded-lg cursor-pointer shrink-0",children:"Cancel"})]}):e.jsxs("button",{onClick:()=>H(o.id),className:"flex items-center gap-1 px-3 py-1.5 bg-brand-50 hover:bg-brand-100 border border-brand-200 text-brand-700 text-[10px] font-bold rounded-lg transition-all cursor-pointer",children:[e.jsx(Vn,{className:"w-3.5 h-3.5"})," Mark Commission Released"]}))]}),b===o.id&&e.jsx("div",{className:"mt-4 pt-4 border-t border-slate-200/60",children:e.jsx(Oi,{user:a,bookingId:o.id,buyerEmail:o.buyerEmail,onSuccessNotification:u,onClose:()=>K(null)})}),o.timeline&&o.timeline.length>0&&e.jsxs("div",{className:"space-y-1 pt-1 border-t border-slate-100",children:[e.jsx("p",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider",children:"Timeline"}),e.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5",children:o.timeline.map((pe,he)=>e.jsxs("span",{className:"text-[9px] font-mono text-slate-500",children:[e.jsx("span",{className:"font-bold text-slate-700 capitalize",children:pe.state})," ","· ",new Date(pe.at).toLocaleDateString("en-IN")]},he))})]})]},o.id)})})]})]})}function Oa(a){if(!isFinite(a))return"â¹0";const l=Math.abs(a);return l>=1e7?`â¹${(a/1e7).toFixed(2)} Cr`:l>=1e5?`â¹${(a/1e5).toFixed(2)}
23 L`:`â¹${Math.round(a).toLocaleString("en-IN")}`}const Hd=["per_sft","flat","per_unit","govt"],$n=["booking","handover","registration"];let Wd=0;const Gl=a=>`${a}-${Date.now()}-${Wd++}`;function Kd(a){return{areaBasis:a.areaBasis,plans:a.plans??[],charges:a.charges??[],taxes:a.taxes??{gstPct:0,stampDuty:"govt",registration:"govt"},notes:a.notes??"",priceSheetUrl:a.priceSheetUrl||void 0}}function Gd(){return{areaBasis:"saleable",plans:[{id:Gl("plan"),name:"Standard Plan",tagline:"",baseRatePerSft:0,milestones:[{stage:"Agreement for Sale",trigger:"At Booking",pct:100}]}],charges:[],taxes:{gstPct:0,stampDuty:"govt",registration:"govt"},notes:""}}function Yd(a){switch(a){case"approved":return{label:"Approved · Live",cls:"bg-emerald-50 text-emerald-700 border border-emerald-200"};case"pending":return{label:"Pending Review",cls:"bg-amber-50 text-amber-700 border border-amber-200"};case"rejected":return{label:"Rejected",cls:"bg-rose-50 text-rose-700 border border-rose-200"};default:return{label:"Draft",cls:"bg-slate-100 text-slate-600 border border-slate-200"}}}function Xd({user:a,onSuccessNotification:l,projectId:j,projectName:u,projectsLoading:E,projectsError:y,onRetryProjects:F}){const b=j,[K,v]=r.useState(!1),[te,V]=r.useState(null),[g,M]=r.useState(!1),[i,O]=r.useState(void 0),[U,ie]=r.useState(null),[I,R]=r.useState(null),[G,re]=r.useState(!1),[x,D]=r.useState(null),[q,de]=r.useState({saleableArea:"1500",floor:"8",facing:"East",config:"3BHK"}),[J,me]=r.useState(""),Q=h=>{v(!0),V(null),M(!1),R(null),O(void 0),ie(null),(async()=>{var T;try{const B=await rt(a),H=await fetch(`/api/projects/${h}/price-sheet`,{headers:B});if(!H.ok){V("Could not load the price sheet. Please try again."),v(!1);return}const xe=await H.json(),z=xe&&typeof xe=="object"&&"priceSheet"in xe?xe.priceSheet:xe;if(z&&Array.isArray(z.plans)&&z.plans.length>0){const se=Kd(z);R(se),O(z.status),ie(z.rejectionReason??null),me(((T=se.plans[0])==null?void 0:T.id)??""),v(!1);return}}catch{V("Could not load the price sheet. Please try again."),v(!1);return}M(!0),v(!1)})()};r.useEffect(()=>{b!=null&&Q(b)},[b,a]);const Ie=()=>{var w;const h=Gd();R(h),O("draft"),M(!1),me(((w=h.plans[0])==null?void 0:w.id)??"")},Ae=h=>R(w=>w&&{...w,...h}),Ce=(h,w)=>R(T=>T&&{...T,plans:T.plans.map((B,H)=>H===h?{...B,...w}:B)}),Le=()=>R(h=>h&&{...h,plans:[...h.plans,{id:Gl("plan"),name:"New Plan",tagline:"",baseRatePerSft:0,milestones:[{stage:"Booking",trigger:"At Booking",pct:100}]}]}),Je=h=>R(w=>w&&{...w,plans:w.plans.filter((T,B)=>B!==h)}),$e=(h,w,T)=>R(B=>B&&{...B,plans:B.plans.map((H,xe)=>xe===h?{...H,milestones:H.milestones.map((z,se)=>se===w?{...z,...T}:z)}:H)}),ve=h=>R(w=>w&&{...w,plans:w.plans.map((T,B)=>B===h?{...T,milestones:[...T.milestones,{stage:"",trigger:"",pct:0}]}:T)}),qe=(h,w)=>R(T=>T&&{...T,plans:T.plans.map((B,H)=>H===h?{...B,milestones:B.milestones.filter((xe,z)=>z!==w)}:B)}),Pe=(h,w)=>R(T=>T&&{...T,charges:T.charges.map((B,H)=>H===h?{...B,...w}:B)}),Ve=()=>R(h=>h&&{...h,charges:[...h.charges,{id:Gl("charge"),name:"New Charge",basis:"per_sft",amount:0,due:"booking",condition:"",note:"",refundable:!1}]}),et=h=>R(w=>w&&{...w,charges:w.charges.filter((T,B)=>B!==h)}),Fe=((I==null?void 0:I.plans)??[]).map(h=>h.milestones.reduce((w,T)=>w+(Number(T.pct)||0),0)),$=Fe.every(h=>Math.abs(h-100)<.001),le=I?{areaBasis:I.areaBasis,plans:I.plans,charges:I.charges,taxes:I.taxes,notes:I.notes}:null;let ne=null,N=null;if(le&&J&&le.plans.some(h=>h.id===J)){const h={saleableArea:parseFloat(q.saleableArea)||0,floor:q.floor?parseInt(q.floor,10):void 0,facing:q.facing||void 0,config:q.config||void 0};try{h.saleableArea>0&&(ne=wl(le,J,h))}catch(w){N=w.message||"Could not compute preview."}}const ue=async()=>{if(!(!I||b==null)){if(!$){D("Each planâs milestones must sum to exactly 100% before submitting.");return}re(!0),D(null);try{const h=await rt(a),w=await fetch(`/api/projects/${b}/price-sheet`,{method:"PUT",headers:{"Content-Type":"application/json",...h},body:JSON.stringify({plans:I.plans,charges:I.charges,taxes:I.taxes,areaBasis:I.areaBasis,notes:I.notes})}),T=await w.json().catch(()=>({}));if(!w.ok)throw new Error((T==null?void 0:T.error)||"Failed to save price sheet.");O(T.status),ie(T.rejectionReason),l("Price sheet submitted for Realtified admin review.")}catch(h){D(h.message||"Failed to save price sheet.")}finally{re(!1)}}},m=Yd(i),C="w-full px-2.5 py-1.5 border border-slate-200 rounded-lg text-xs outline-none focus:ring-1 focus:ring-brand-500 focus:border-brand-500",Y="text-[9px] font-mono font-bold text-slate-500 uppercase block mb-1";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-6 shadow-xs space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-extrabold text-slate-900 font-display flex items-center gap-2",children:[e.jsx(Vl,{className:"w-4.5 h-4.5 text-brand-600"})," Price Sheet Editor"]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 max-w-xl",children:"Build a full builder price sheet â payment plans, conditional charges, and taxes â for one of your claimed projects."}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 px-3 py-1.5 bg-amber-50 border border-amber-200 rounded-xl w-fit",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),e.jsx("span",{className:"text-[10px] font-mono text-amber-700 font-semibold",children:"Pricing goes live to buyers only after admin a
23pproval."})]})]}),i&&I&&e.jsx("span",{className:`px-2.5 py-1 text-[9px] font-mono font-bold rounded-md uppercase ${m.cls}`,children:m.label})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Project"}),E?e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs py-2",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Loading your projectsâ¦"]}):y?e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"})," ",y,e.jsx("button",{onClick:F,className:"ml-auto font-bold font-mono text-[10px] cursor-pointer",children:"RETRY"})]}):b==null?e.jsx("p",{className:"text-xs text-slate-400 italic",children:"No project selected â open a listing from the Listings tab."}):e.jsxs("p",{className:"text-sm font-extrabold text-slate-900",children:[u??`Project #${b}`," ",e.jsxs("span",{className:"text-[10px] font-mono text-slate-400 font-normal",children:["#",b]})]})]}),(I==null?void 0:I.priceSheetUrl)&&/^(https?:\/\/|\/)/.test(I.priceSheetUrl)&&e.jsxs("div",{className:"pt-3 border-t border-slate-100 flex items-center justify-between gap-3 bg-slate-50 p-3.5 rounded-2xl border border-slate-200/80",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-brand-50 text-brand-600 rounded-xl border border-brand-100",children:e.jsx(za,{className:"w-5 h-5"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("h4",{className:"text-xs font-bold text-slate-800",children:"Price sheet document"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-mono",children:"Document linked to this price sheet"})]})]}),e.jsxs("a",{href:I.priceSheetUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 bg-white hover:bg-slate-100 text-slate-700 text-[10px] font-mono font-bold rounded-xl border border-slate-200 transition-all cursor-pointer shrink-0",children:[e.jsx(qn,{
23className:"w-3.5 h-3.5 text-brand-500"})," Open document"]})]})]}),b!=null&&K&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-xs py-8 justify-center",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Loading price sheetâ¦"]}),te&&e.jsxs("div",{className:"flex items-center gap-2 p-4 bg-rose-50 border border-rose-200 rounded-2xl text-xs text-rose-700",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"})," ",te]}),!K&&g&&!I&&e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-8 text-center space-y-4",children:[e.jsx(Vl,{className:"w-10 h-10 text-slate-200 mx-auto"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-700",children:"No price sheet for this project yet"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1",children:"Start from a blank sheet and enter your own plans, charges and taxes."})]}),e.jsx("div",{className:"flex items-center justify-center gap-3 flex-wrap",children:e.jsxs("button",{onClick:Ie,className:"flex items-center gap-1.5 px-4 py-2 bg-slate-900 hover:bg-slate-950 text-white text-[10px] font-bold rounded-xl transition-all cursor-pointer",children:[e.jsx(Ot,{className:"w-3.5 h-3.5"})," Start from blank"]})})]}),I&&e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-4 items-start",children:[e.jsxs("div",{className:"xl:col-span-7 space-y-4",children:[e.jsx("div",{className:"bg-white border border-slate-200 rounded-2xl p-5 shadow-xs space-y-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-extrabold text-slate-900 font-mono uppercase tracking-wider",children:"Area Basis"}),e.jsx("div",{className:"flex items-center gap-1 bg-slate-100 rounded-xl p-1",children:["saleable","carpet"].map(h=>e.jsx("button",{onClick:()=>Ae({areaBasis:h}),className:`px-3 py-1.5 text-[10px] font-bold rounded-lg transition-all cursor-pointer uppercase font-mono ${I.areaBasis===h?"bg-brand-500 text-white shadow-sm":"text-slate-500 hover:text-slate-800"}`,children:h},h))})]})}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-5 shadow-xs space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-extrabold text-slate-900 font-mono uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(Yl,{className:"w-4 h-4 text-brand-600"})," Payment Plans"]}),e.jsxs("button",{onClick:Le,className:"flex items-center gap-1 px-3 py-1.5 bg-brand-50 hover:bg-brand-100 border border-brand-200 text-brand-700 text-[10px] font-bold rounded-lg cursor-pointer",children:[e.jsx(Ot,{className:"w-3 h-3"})," Add Plan"]})]}),I.plans.map((h,w)=>{const T=Fe[w],B=Math.abs(T-100)<.001;return e.jsxs("div",{className:"border border-slate-200 rounded-2xl p-4 space-y-3 bg-slate-50/40",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 flex-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Plan Name"}),e.jsx("input",{value:h.name,onChange:H=>Ce(w,{name:H.target.value}),className:C})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Tagline"}),e.jsx("input",{value:h.tagline,onChange:H=>Ce(w,{tagline:H.target.value}),className:C})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Base Rate / Sq.Ft (â¹)"}),e.jsx("input",{type:"number",value:h.baseRatePerSft,onChange:H=>Ce(w,{baseRatePerSft:parseFloat(H.target.value)||0}),className:`${C} font-mono`,min:0})]})]}),I.plans.length>1&&e.jsx("button",{onClick:()=>Je(w),className:"text-slate-300 hover:text-rose-500 cursor-pointer mt-4",title:"Remove plan",children:e.jsx(St,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider",children:"Milestones"}),e.jsxs("span",{className:`text-[9px] font-mono font-bold px-2 py-0.5 rounded ${B?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-700"}`,children:["Σ ",T,"% ",B?"â":"(must = 100%)"]})]}),h.milestones.map((H,xe)=>e.jsxs("div",{className:"grid grid-cols-12 gap-1.5 items-center",children:[e.jsx("input",{placeholder:"Stage",value:H.stage,onChange:z=>$e(w,xe,{stage:z.target.value}),className:`${C} col-span-4`}),e.jsx("input",{placeholder:"Trigger",value:H.trigger,onChange:z=>$e(w,xe,{trigger:z.target.value}),className:`${C} col-span-5`}),e.jsx("input",{type:"number",placeholder:"%",value:H.pct,onChange:z=>$e(w,xe,{pct:parseFloat(z.target.value)||0}),className:`${C} col-span-2 font-mono text-right`}),e.jsx("button",{onClick:()=>qe(w,xe),className:"col-span-1 text-slate-300 hover:text-rose-500 cursor-pointer flex justify-center",title:"Remove",children:e.jsx(ot,{className:"w-3.5 h-3.5"})})]},xe)),e.jsx("button",{onClick:()=>ve(w),className:"text-[10px] font-mono font-bold text-brand-600 hover:text-brand-700 cursor-pointer",children:"+ Add milestone"})]}),e.jsxs("div",{className:"border-t border-slate-200/60 pt-3 text-left space-y-2",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-slate-500 uppercase tracking-wider",children:"Floor-Rise Premium Engine"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 items-center",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-slate-600 cursor-pointer font-sans",children:[e.jsx("input",{type:"checkbox",checked:!!h.floorRise,onChange:H=>{H.target.checked?Ce(w,{floorRise:{startFloor:5,ratePerSftPerFloor:20}}):Ce(w,{floorRise:null})},className:"accent-brand-500"}),"Enable Floor Rise"]}),h.floorRise&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono text-slate-400 uppercase block mb-0.5",children:"Start Floor"}),e.jsx("input",{type:"number",value:h.floorRise.startFloor,onChange:H=>Ce(w,{floorRise:{...h.floorRise,startFloor:parseInt(H.target.value,10)||1}}),className:C})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono text-slate-400 uppercase block mb-0.5",children:"Rate (â¹/sft per floor)"}),e.jsx("input",{type:"number",value:h.floorRise.ratePerSftPerFloor,onChange:H=>Ce(w,{floorRise:{...h.floorRise,ratePerSftPerFloor:parseInt(H.target.value,10)||0}}),className:C})]})]})]})]}),e.jsxs("div",{className:"border-t border-slate-200/60 pt-3 text-left space-y-2",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-slate-500 uppercase tracking-wider",children:"Stacking Premiums (â¹/sft)"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:(()=>{const H=(z,se)=>{var Ge,o;return((o=(Ge=h.premiums)==null?void 0:Ge.find(L=>
23L.type===z&&(!se||L.value===se)))==null?void 0:o.ratePerSft)??0},xe=(z,se,Ge)=>{let o=h.premiums?[...h.premiums]:[];const L=o.findIndex(je=>je.type===z&&(!se||je.value===se));L>=0?Ge===0?o.splice(L,1):o[L]={...o[L],ratePerSft:Ge}:Ge>0&&o.push({type:z,value:se,ratePerSft:Ge}),Ce(w,{premiums:o})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono text-slate-400 uppercase block mb-0.5",children:"East Facing"}),e.jsx("input",{type:"number",value:H("facing","East"),onChange:z=>xe("facing","East",parseInt(z.target.value,10)||0),className:C})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono text-slate-400 uppercase block mb-0.5",children:"Corner Unit"}),e.jsx("input",{type:"number",value:H("corner","Corner"),onChange:z=>xe("corner","Corner",parseInt(z.target.value,10)||0),className:C})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[8px] font-mono text-slate-400 uppercase block mb-0.5",children:"View Premium"}),e.jsx("input",{type:"number",value:H("view","View"),onChange:z=>xe("view","View",parseInt(z.target.value,10)||0),className:C})]})]})})()})]}),e.jsxs("div",{className:"border-t border-slate-200/60 pt-3 text-left space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-[10px] font-mono font-bold text-slate-500 uppercase tracking-wider",children:"Car Parking Allocation Matrix"}),e.jsx("button",{type:"button",onClick:()=>{const H=h.parkingRules?[...h.parkingRules]:[];H.push({minSizeSqFt:0,slots:1,chargeFlat:4e5}),Ce(w,{parkingRules:H})},className:"text-[9px] font-mono font-bold text-brand-600 hover:text-brand-700 cursor-pointer",children:"+ Add Rule"})]}),e.jsx("div",{className:"space-y-1.5",children:(h.parkingRules||[]).map((H,xe)=>e.jsxs("div",{className:"grid grid-cols-12 gap-1 items-center bg-slate-100/50 p-1.5 rounded-lg border border-slate-200",children:[e.jsxs("div",{className:"col-span-4 text-left",children:[e.jsx("label",{className:"text-[7px] font-mono text-slate-400 block uppercase leading-none mb-0.5",children:"Min
23size (sft)"}),e.jsx("input",{type:"number",value:H.minSizeSqFt,onChange:z=>{const se=[...h.parkingRules];se[xe]={...se[xe],minSizeSqFt:parseInt(z.target.value,10)||0},Ce(w,{parkingRules:se})},className:C})]}),e.jsxs("div",{className:"col-span-3 text-left",children:[e.jsx("label",{className:"text-[7px] font-mono text-slate-400 block uppercase leading-none mb-0.5",children:"Slots"}),e.jsx("input",{type:"number",value:H.slots,onChange:z=>{const se=[...h.parkingRules];se[xe]={...se[xe],slots:parseInt(z.target.value,10)||0},Ce(w,{parkingRules:se})},className:C})]}),e.jsxs("div",{className:"col-span-4 text-left",children:[e.jsx("label",{className:"text-[7px] font-mono text-slate-400 block uppercase leading-none mb-0.5",children:"Flat cost (â¹)"}),e.jsx("input",{type:"number",value:H.chargeFlat,onChange:z=>{const se=[...h.parkingRules];se[xe]={...se[xe],chargeFlat:parseInt(z.target.value,10)||0},Ce(w,{parkingRules:se})},className:C})]}),e.jsx("button",{type:"button",onClick:()=>{const z=h.parkingRules.filter((se,Ge)=>Ge!==xe);Ce(w,{parkingRules:z})},className:"col-span-1 text-slate-300 hover:text-rose-500 cursor-pointer text-center mt-2.5",children:e.jsx(St,{className:"w-3.5 h-3.5 mx-auto"})})]},xe))})]})]},h.id)})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-5 shadow-xs space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-extrabold text-slate-900 font-mono uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(Vn,{className:"w-4 h-4 text-emerald-600"})," Charges"]}),e.jsxs("button",{onClick:Ve,className:"flex items-center gap-1 px-3 py-1.5 bg-emerald-50 hover:bg-emerald-100 border border-emerald-200 text-emerald-700 text-[10px] font-bold rounded-lg cursor-pointer",children:[e.jsx(Ot,{className:"w-3 h-3"})," Add Charge"]})]}),I.charges.length===0&&e.jsx("p",{className:"text-[11px] text-slate-400 italic",children:"No charges yet. Add infra, parking, PLC, corpus, govt charges, etc."}),I.charges.map((h,w)=>e.jsxs("div",{className:"border border-slate-200 rounded-2xl p-4 space-y-3 bg-slate-50/40",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 flex-1",children:[e.jsxs("div",{className:"col-span-2 sm:col-span-1",children:[e.jsx("label",{className:Y,children:"Name"}),e.jsx("input",{value:h.name,onChange:T=>Pe(w,{name:T.target.value}),className:C})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Basis"}),e.jsx("select",{value:h.basis,onChange:T=>Pe(w,{basis:T.target.value,amount:T.target.value==="govt"?null:h.amount??0}),className:`${C} bg-white cursor-pointer`,children:Hd.map(T=>e.jsx("option",{value:T,children:T},T))})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Amount (â¹)"}),e.jsx("input",{type:"number",disabled:h.basis==="govt",value:h.amount??"",onChange:T=>Pe(w,{amount:T.target.value===""?null:parseFloat(T.target.value)}),className:`${C} font-mono disabled:bg-slate-100 disabled:text-slate-400`})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Due"}),e.jsx("select",{value:h.due,onChange:T=>Pe(w,{due:T.target.value}),className:`${C} bg-white cursor-pointer`,children:$n.map(T=>e.jsx("option",{value:T,children:T},T))})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Condition"}),e.jsx("input",{placeholder:"e.g. floor>=5",value:h.condition??"",onChange:T=>Pe(w,{condition:T.target.value}),className:`${C} font-mono`})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Note"}),e.jsx("input",{value:h.note??"",onChange:T=>Pe(w,{note:T.target.value}),className:C})]})]}),e.jsx("button",{onClick:()=>et(w),className:"text-slate-300 hover:text-rose-500 cursor-pointer mt-4",title:"Remove charge",children:e.jsx(St,{className:"w-4 h-4"})})]}),e.jsxs("label",{className:"flex items-center gap-2 text-[10px] font-mono text-slate-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!h.refundable,onChange:T=>Pe(w,{refundable:T.target.checked}),className:"accent-brand-500"}),"Refundable"]})]}
23,h.id))]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-5 shadow-xs space-y-3",children:[e.jsxs("p",{className:"text-xs font-extrabold text-slate-900 font-mono uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(Cr,{className:"w-4 h-4 text-brand-600"})," Taxes"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"GST %"}),e.jsx("input",{type:"number",value:I.taxes.gstPct,onChange:h=>Ae({taxes:{...I.taxes,gstPct:parseFloat(h.target.value)||0}}),className:`${C} font-mono`,min:0})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Stamp Duty"}),e.jsx("input",{value:I.taxes.stampDuty,onChange:h=>Ae({taxes:{...I.taxes,stampDuty:h.target.value}}),className:C})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Registration"}),e.jsx("input",{value:I.taxes.registration,onChange:h=>Ae({taxes:{...I.taxes,registration:h.target.value}}),className:C})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:Y,children:"Notes"}),e.jsx("textarea",{value:I.notes,onChange:h=>Ae({notes:h.target.value}),rows:2,className:`${C} resize-none`})]})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl p-5 shadow-xs space-y-3",children:[!$&&e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded-xl text-[11px] text-amber-700 font-semibold flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"}),"One or more plans don't sum to 100%. Fix milestones before submitting."]}),x&&e.jsxs("div",{className:"p-3 bg-rose-50 border border-rose-200 rounded-xl text-[11px] text-rose-700 font-semibold flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4 shrink-0"})," ",x]}),e.jsx("button",{onClick:ue,disabled:G||!$,className:"w-full py-2.5 bg-brand-500 hover:bg-brand-600 text-white text-xs font-bold rounded-xl transition-all cursor-pointer disabled:opacity-50 flex items-center justify-center gap-1.5",children:G?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Submittingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Xl,{className:"w-4 h-4"})," Save & Submit for Review"]})}),e.jsx("p",{className:"text-[10px] text-slate-400 text-center font-mono",children:"Pricing goes live to buyers only after admin approval."})]})]}),e.jsxs("div",{className:"xl:col-span-5 space-y-4 xl:sticky xl:top-4",children:[e.jsxs("div",{className:"bg-slate-900 text-white border border-slate-800 rounded-3xl p-5 shadow-xs space-y-4",children:[e.jsxs("p",{className:"text-xs font-extrabold font-mono uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(Hl,{className:"w-4 h-4 text-brand-400"})," Preview a Unit"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase block mb-1",children:"Saleable Area (sqft)"}),e.jsx("input",{type:"number",value:q.saleableArea,onChange:h=>de(w=>({...w,saleableArea:h.target.value})),className:"w-full px-2.5 py-1.5 bg-slate-950 border border-slate-800 rounded-lg text-xs font-mono text-white outline-none focus:border-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase block mb-1",children:"Floor"}),e.jsx("input",{type:"number",value:q.floor,onChange:h=>de(w=>({...w,floor:h.target.value})),className:"w-full px-2.5 py-1.5 bg-slate-950 border border-slate-800 rounded-lg text-xs font-mono text-white outline-none focus:border-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase block mb-1",children:"Facing"}),e.jsx("input",{value:q.facing,onChange:h=>de(w=>({...w,facing:h.target.value})),className:"w-full px-2.5 py-1.5 bg-slate-950 border border-slate-800 rounded-lg text-xs text-white outline-none focus:border-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase block mb-1",children:"Config"}),e.jsx("input",{value:q.config,onChange:h=>de(w=>({...w,config:h.target.value})),className:"w-full px-2.5 py-1.5 bg-slate-950 border border-slate-800 rounded-lg text-xs text-white outline-none focus:border-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase block mb-1",children:"Plan"}),e.jsx("select",{value:J,onChange:h=>me(h.target.value),className:"w-full px-2.5 py-1.5 bg-slate-950 border border-slate-800 rounded-lg text-xs font-bold text-white outline-none cursor-pointer focus:border-brand-500",children:I.plans.map(h=>e.jsx("option",{value:h.id,children:h.name},h.id))})]})]}),N&&e.jsx("div",{className:"p-3 bg-rose-50 border border-rose-200 rounded-xl text-[11px] text-rose-700 font-semibold",children:N}),ne&&e.jsxs("div",{className:"bg-white border border-slate-200 rounded-3xl p-5 shadow-xs space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Base Consideration"}),e.jsx("span",{className:"font-extrabold text-slate-900 font-mono",children:Oa(ne.baseConsideration)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Charges Total"}),e.jsx("span",{className:"font-bold text-slate-800 font-mono",children:Oa(ne.chargesTotal)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-slate-500",children:["GST (",ne.gstPct,"%)"]}),e.jsx("span",{className:"font-bold text-slate-800 font-mono",children:Oa(ne.gst)})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-slate-200",children:[e.jsx("span",{className:"font-extrabold text-slate-900 uppercase font-mono text-[10px] tracking-wider",children:"Grand Total"}),e.jsx("span",{className:"font-extrabold text-brand-600 font-mono text-sm",children:Oa(ne.grandTotal)})]})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[$n.map(h=>{const w=ne.chargesByStage[h];return w.length===0?null:e.jsxs("div",{className:"border border-slate-100 rounded-xl p-3 bg-slate-50/50",children:[e.jsx("p",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider mb-1.5",children:h}),w.map((T,B)=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] py-0.5",children:[e.jsxs("span",{className:"text-slate-600",children:[T.label,T.refundable?" (refundable)":""]}),e.jsx("span",{className:"font-mono font-bold text-slate-800",children:Oa(T.amount)})]},B))]},h)}),ne.govtItems.length>0&&e.jsxs("div",{className:"border border-slate-100 rounded-xl p-3 bg-slate-50/50",children:[e.jsx("p",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider mb-1.5",children:"Govt Charges"}),ne.govtItems.map((h,w)=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] py-0.5",children:[e.jsx("span",{className:"text-slate-600",children:h.label}),e.jsx("span",{className:"font-mono text-slate-400",children:h.note})]},w))]})]}),e.jsxs("div",{className:"pt-1",children:[e.jsx("p",{className:"text-[9px] font-mono font-bold text-slate-400 uppercase tracking-wider mb-2",children:"Milestone Payment Schedule"}),e.jsx("div",{className:"space-y-1",children:ne.paymentSchedule.map((h,w)=>e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] border-b border-slate-100 pb-1",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-bold text-slate-800 truncate",children:[h.stage," ",e.jsxs("span",{className:"text-slate-400 font-mono font-normal",children:["(",h.pct,"%)"]})]}),e.jsx("p",{className:"text-[9px] text-slate-400 font-mono truncate",children:h.trigger})]}),e.jsx("span",{className:"font-mono font-bold text-slate-800 shrink-0",children:Oa(h.amount)})]},w))})]})]})]})]})]})}function Zd({deal:a,onSuccessNotification:l}){const[j,u]=r.useState(a.status),[E,y]=r.useState(""),F=a.sizeSqFt*a.originalBsp,b=a.sizeSqFt*a.proposedBsp,K=F-b,v=(te,V)=>{if(u(te),l(V),a.id&&String(a.id).startsWith("proposal_"))try{const M=JSON.parse(localStorage.getItem("realtified_deal_proposals")||"[]").map(i=>i.id===a.id?{...i,status:te,proposedBsp:te==="countered"&&E?Number(E):i.proposedBsp}:i);localStorage.setItem("realtified_deal_proposals",JSON.stringify(M)),window.dispatchEvent(new Event("storage"))}catch(g){console.warn("Failed to update deal proposal in localStorage:",g)}};return e.jsxs("div",{className:"border border-slate-200 rounded-2xl p-4 hover:border-brand-500/25 transition-all text-xs text-left bg-white",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-3 pb-3 border-b border-slate-100",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-bold text-slate-900",children:a.clientName}),e.jsxs("span",{className:"text-[10px] text-slate-400 font-mono",children:["via ",a.cpName]})]}
23),e.jsxs("p",{className:"text-slate-500 font-medium mt-0.5",children:["Project: ",e.jsx("strong",{children:a.projectName})," ⢠Unit: ",e.jsxs("strong",{children:[a.unitType," (",a.sizeSqFt," SFT)"]})]})]}),e.jsx("span",{className:`px-2 py-0.5 text-[9px] font-mono font-bold rounded-full uppercase ${j==="approved"?"bg-emerald-50 text-emerald-600 border border-emerald-100":j==="countered"?"bg-amber-50 text-amber-700 border border-amber-200":"bg-slate-100 text-slate-500 border border-slate-200"}`,children:j.replace("_"," ")})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-3 text-slate-600",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-slate-400 block font-mono",children:"BASE PRICE (SFT)"}),e.jsxs("span",{className:"font-bold text-slate-700",children:["â¹",a.originalBsp.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-slate-400 block font-mono",children:"PROPOSED BSP (SFT)"}),e.jsxs("span",{className:"font-bold text-brand-600 font-mono",children:["â¹",a.proposedBsp.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-slate-400 block font-mono",children:"EST. DISCOUNT SAVINGS"}),e.jsxs("span",{className:"font-bold text-emerald-600 font-mono",children:["â¹",K.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-slate-400 block font-mono",children:"PROPOSED AGREEMENT VALUE"}),e.jsxs("span",{className:"font-bold text-slate-800 font-mono",children:["â¹",b.toLocaleString()]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 pt-3 border-t border-slate-100",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.waivers.map((te,V)=>e.jsx("span",{className:"px-2 py-0.5 bg-brand-50 text-brand-700 rounded text-[9px] font-mono font-bold",children:te},V)),a.addons.map((te,V)=>e.jsx("span",{className:"px-2 py-0.5 bg-indigo-50 text-indigo-700 rounded text-[9px] font-mono font-bold",children:te},V))]}),j==="pending_review"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",placeholder:"Counter BSP",value:E,onChange:te=>y(te.target.value),className:"w-24 px-2 py-1 border border-slate-200 rounded text-right font-mono"}),e.jsx("button",{onClick:()=>{v("countered",`Counter offer of â¹${E}/sf saved to this draft. It will only appear if the buyer reopens Realtified on this same device.`)},disabled:!E,className:"px-3 py-1 bg-amber-500 hover:bg-amber-600 text-white rounded font-bold cursor-pointer disabled:opacity-40",children:"Counter"}),e.jsx("button",{onClick:()=>{v("approved","Deal package approved. No booking has been created yet â the buyer can now proceed to token payment on their device to generate one.")},className:"px-3 py-1 bg-emerald-500 hover:bg-emerald-600 text-white rounded font-bold cursor-pointer",children:"Approve"})]})]})]})}function Jd({user:a,selectedProject:l}){const[j,u]=r.useState([{role:"assistant",content:"Hello! I am your Realtified Builder Copilot. Ask me anything about your project's sales, pricing, walkthrough check-ins, or TS-RERA directory sync status."}]),[E,y]=r.useState(""),[F,b]=r.useState(!1),K=_n.useRef(null);r.useEffect(()=>{var V;(V=K.current)==null||V.scrollIntoView({behavior:"smooth"})},[j,F]);const v=V=>{V.trim()&&(u(g=>[...g,{role:"user",content:V}]),y(""),b(!0),setTimeout(()=>{let g="I don't have live query access to your account data yet â check the relevant tab in this console (Inventory, Enquiries, Pricing, or Legal & RERA) for exact, up-to-date figures.";const M=V.toLowerCase();M.includes("occupancy")||M.includes("inventory")||M.includes("flat")?g="I can't pull live occupancy or unit-status figures â open the Inventory tab for your project's real unit-by-unit status.":M.includes("enquiry")||M.includes("lead")?g="I don't have live access to your enquiry or channel-partner pipeline â check the Enquiries tab for your real leads and their status.":M.includes("rera")||M.includes("registration")||M.includes("sync")?g=yl(l==null?void 0:l.reraNumber)?`The RERA number on file for "${(l==null?void 0:l.name)||"this project"}" is ${yl(l==null?void 0:l.reraNumber)} â open the Legal & RERA tab to review the actual filing and sync status.`:`I don't see a RERA number on file for "${(l==null?void 0:l.name)||"this project"}" yet â open the Legal & RERA tab to check its actual filing status.`:(M.includes("price")||M.includes("rates"))&&(g="I can't
23confirm live pricing or price-sheet approval status â open the Pricing tab for your project's actual base rate and any pending changes."),u(i=>[...i,{role:"assistant",content:g}]),b(!1)},600))},te=["Audit my inventory occupancy","Check RERA registration status","Summarize active enquiries","Review base pricing & PLC"];return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-slate-50/50 font-sans",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-3.5 space-y-3 scrollbar-thin min-h-0",children:[j.map((V,g)=>e.jsx("div",{className:`flex ${V.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] rounded-2xl p-2.5 text-xs ${V.role==="user"?"bg-brand-500 text-white font-semibold rounded-br-none shadow-xs":"bg-white border border-slate-200 text-slate-700 rounded-bl-none shadow-2xs"}`,children:e.jsx("p",{className:"leading-relaxed whitespace-pre-wrap",children:V.content})})},g)),F&&e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl rounded-bl-none p-2.5 text-xs text-slate-400 shadow-2xs flex items-center gap-1.5 font-bold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-300 animate-bounce"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-300 animate-bounce delay-100"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-300 animate-bounce delay-200"})]})}),e.jsx("div",{ref:K})]}),j.length===1&&e.jsxs("div",{className:"p-3 border-t border-slate-100 bg-white/70 space-y-1.5 shrink-0",children:[e.jsx("p",{className:"text-[9px] font-mono text-slate-400 uppercase font-bold tracking-wider mb-1 block",children:"Quick Questions"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:te.map((V,g)=>e.jsx("button",{onClick:()=>v(V),className:"text-[10px] bg-slate-50 hover:bg-slate-100 text-slate-600 hover:text-slate-900 border border-slate-200/65 px-2 py-1 rounded-full font-bold cursor-pointer transition-all active:scale-[0.98]",children:V},g))})]}),e.jsxs("form",{onSubmit:V=>{V.preventDefault(),v(E)},className:"p-2 border-t border-slate-200 bg-white flex items-center gap-1.5 shrink-0",children:[e.jsx("input",{type:"text",value:E,onChange:V=>y(V.target.value),placeholder:"Ask AI Copilot...",className:"flex-1 border border-slate-200 rounded-xl px-3 py-1.5 text-xs focus:outline-none focus:border-brand-500 bg-slate-50/50"}),e.jsx("button",{type:"submit",disabled:!E.trim(),className:"bg-brand-500 hover:bg-brand-600 disabled:opacity-50 text-white rounded-xl px-3 py-1.5 text-xs font-bold transition-all cursor-pointer flex items-center justify-center active:scale-[0.97]",children:"Send"})]})]})}export{xc as default};
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.