PageSourceSearch

https://freightcompare.ai/assets/CalculatorPage-ylPu00SV.js

js freightcompare.ai collected 2026-10-02 01:10:58 UTC 335,887 bytes, 73 lines download raw bytes

1import{c as Ct,i as Ql,r as n,u as Gl,f as Yl,L as Qn,j as e,a as Zl,m as Xl,b as Jl,d as Ki,e as ql,g as eo,h as to,k as so,s as ao,p as ro,V as no,l as io,n as lo,o as oo,S as co,H as mo,v as Ba,q as ho,t as uo,w as xo,x as po,y as fo,z as Ui,A as Kt,B as W,X as Vt,U as go,P as bo,M as vo,C as yo,D as Dt,E as Hr,F as kt,G as Jt,I as Or,Z as It,J as ca,K as me,N as Lt,O as wo,Q as Ds,T as Re,R as ut,W as No,Y as _s,_ as Va,$ as Ns,a0 as Ka,a1 as $s,a2 as Gn,a3 as Yn,a4 as Hi,a5 as jo,a6 as ko,a7 as Zn,a8 as Co,a9 as So,aa as Br,ab as To,ac as Po,ad as Lo,ae as Io,af as Eo,ag as Fo,ah as Ro,ai as Mo,aj as Vs,ak as Qi,al as Gi,am as Ao,an as Rs,ao as _o,ap as $o,aq as Cr,ar as Do,as as Xn,at as Vo,au as Sa,av as da,aw as zo,ax as Oo,ay as Bo,az as Wo,aA as Jn,aB as Ko,aC as Uo}from"./index-BFYamPZN.js";import{l as vt,a as Ho,s as Qo,f as Sr,p as Ta,c as Go,b as Yo,r as Zo,d as Xo,m as qn,L as Jo,w as qo}from"./mover-D5ejL8KK.js";import{B as ei}from"./building-2-U2uqivYG.js";import{H as Qr}from"./help-circle-CvYKLBrY.js";import{S as ec}from"./SubscriptionPaywall-xhH1l_0E.js";import{loadCentroids as ti}from"./mapProjection-BoeLmytC.js";import{ensureQBData as Pa,resolvePincode as fs,weightToVehicleClass as Tr}from"./quickBookingResolve-B7MMNdgN.js";import{f as si,a as tc}from"./individualFtl-Bt5Pc2Pk.js";import{u as Ua,T as sc}from"./use-reduced-motion-CspvBkHN.js";import{C as Pr}from"./calendar-BHyQ1bB5.js";import{S as ws}from"./star-DTD-HJdX.js";import{C as ac}from"./copy-Cd62ofMh.js";import{I as Gr}from"./info-CQ4LeTEy.js";import{B as Lr,i as rc,p as nc,f as ic,S as La,a as ai,b as lc,u as oc,c as cc,d as dc,g as Ia}from"./wheelseye-DjErgsg9.js";import{A as Xt}from"./alert-circle-Cy-MNOhZ.js";import{C as za}from"./check-circle-DPMESBDo.js";import{i as Oa,P as mc,T as hc,S as ri,g as uc,a as xc,p as pc}from"./excelConverter-C1MreWHg.js";import{P as ni}from"./PincodeAutocomplete-Ci2kCTLf.js";import{U as fc}from"./users-QGKUDhGe.js";import{E as ii}from"./earth-DOBaqbU0.js";import{A as gc}from"./arrow-right-left-BjV2h0JV.js";import{M as bc}from"./message-square-C57qFAk3.js";import{C as vc}from"./chevron-up-wsqDDVKp.js";import{F as Yi}from"./StarIcon-O2qsYKFT.js";import{r as yc}from"./transporterLogo-BMddevCP.js";import{T as gs}from"./trash-2-B04TDMPX.js";import{P as Ea}from"./package-search-CXcVp5E_.js";import{P as wc}from"./plus-CLUKPh2X.js";import{U as Nc}from"./upload-CTtH1oD6.js";import{D as li}from"./download--ZTl6XPZ.js";import{R as jc}from"./route-YHRkyCND.js";import{S as kc}from"./scale-Kw__sh0g.js";import{C as Fa}from"./chevron-right-BQMONOUr.js";import{F as Cc}from"./filter-BcKvWKkc.js";import{I as oi}from"./xlsx-Bw6bjxR0.js";import{S as Sc}from"./shield-CzxhoIwv.js";import"./leaflet-uR8xTtQN.js";import"./useSubscriptionStatus-BuUl6RMG.js";import"./gift-DfBlcq4y.js";import"./rivigo-KEkLWQGm.js";/**
2 * @license lucide-react v0.344.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ci=Ct("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/**
7 * @license lucide-react v0.344.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ir=Ct("Award",[["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}],["path",{d:"M15.477 12.89 17 22l-5-3-5 3 1.523-9.11",key:"em7aur"}]]);/**
12 * @license lucide-react v0.344.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const Tc=Ct("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
17 * @license lucide-react v0.344.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const Pc=Ct("CloudRain",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v6",key:"1j4efv"}],["path",{d:"M8 14v6",key:"17c4r9"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/**
22 * @license lucide-react v0.344.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const Lc=Ct("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
27 * @license lucide-react v0.344.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const Ic=Ct("Milestone",[["path",{d:"M18 6H5a2 2 0 0 0-2 2v3a2 2 0 0 0 2 2h13l4-3.5L18 6Z",key:"1mp5s7"}],["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}]]);/**
32 * @license lucide-react v0.344.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const Ec=Ct("MousePointerClick",[["path",{d:"m9 9 5 12 1.8-5.2L21 14Z",key:"1b76lo"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}]]);/**
37 * @license lucide-react v0.344.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const Er=Ct("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/**
42 * @license lucide-react v0.344.0 - ISC
43 *
44 * This source code is licensed under the ISC license.
45 * See the LICENSE file in the root directory of this source tree.
46 */const Fc=Ct("PiggyBank",[["path",{d:"M19 5c-1.5 0-2.8 1.4-3 2-3.5-1.5-11-.3-11 5 0 1.8 0 3 2 4.5V20h4v-2h3v2h4v-4c1-.5 1.7-1 2-2h2v-4h-2c0-1-.5-1.5-1-2h0V5z",key:"uf6l00"}],["path",{d:"M2 9v1c0 1.1.9 2 2 2h1",key:"nm575m"}],["path",{d:"M16 11h0",key:"k2aug8"}]]);/**
47 * @license lucide-react v0.344.0 - ISC
48 *
49 * This source code is licensed under the ISC license.
50 * See the LICENSE file in the root directory of this source tree.
51 */const na=Ct("PlusCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
52 * @license lucide-react v0.344.0 - ISC
53 *
54 * This source code is licensed under the ISC license.
55 * See the LICENSE file in the root directory of this source tree.
56 */const Zi=Ct("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/**
57 * @license lucide-react v0.344.0 - ISC
58 *
59 * This source code is licensed under the ISC license.
60 * See the LICENSE file in the root directory of this source tree.
61 */const Rc=Ct("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22h0a3.13 3.13 0 0 1-3-3.88Z",key:"s6e0r"}]]);/**
62 * @license lucide-react v0.344.0 - ISC
63 *
64 * This source code is licensed under the ISC license.
65 * See the LICENSE file in the root directory of this source tree.
66 */const Mc=Ct("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2h0a3.13 3.13 0 0 1 3 3.88Z",key:"y3tblf"}]]);/**
67 * @license lucide-react v0.344.0 - ISC
68 *
69 * This source code is licensed under the ISC license.
70 * See the LICENSE file in the root directory of this source tree.
71 */const Ac=Ct("TimerReset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]),_c=(t,l,c)=>{const r=l-t;return((c-t)%r+r)%r+t};function Xi(t,l){return Ql(t)?t[_c(0,t.length,l)]:t}class $c{constructor(l){this.stop=()=>this.runAll("stop"),this.animations=l.filter(Boolean)}get finished(){return Promise.all(this.animations.map(l=>l.finished))}getAll(l){return this.animations[0][l]}setAll(l,c){for(let r=0;r<this.animations.length;r++)this.animations[r][l]=c}attachTimeline(l){const c=this.animations.map(r=>r.attachTimeline(l));return()=>{c.forEach((r,u)=>{r&&r(),this.animations[u].stop()})}}get time(){return this.getAll("time")}set time(l){this.setAll("time",l)}get speed(){return this.getAll("speed")}set speed(l){this.setAll("speed",l)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return di(this.animations,"duration")}get iterationDuration(){return di(this.animations,"iterationDuration")}runAll(l){this.animations.forEach(c=>c[l]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function di(t,l){let c=0;for(let r=0;r<t.length;r++){const u=t[r][l];u!==null&&u>c&&(c=u)}return c}class Dc extends $c{then(l,c){return this.finished.finally(l).then(()=>{})}}const Vc=n.createContext(null);function zc(){const t=n.useRef(!1);return Gl(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Oc(){const t=zc(),[l,c]=n.useState(0),r=n.useCallback(()=>{t.current&&c(l+1)},[l]);return[n.useCallback(()=>Yl.postRender(r),[r]),l]}const Bc=t=>!t.isLayoutDirty&&t.willUpdate(!1);function mi(){const t=new Set,l=new WeakMap,c=()=>t.forEach(Bc);return{add:r=>{t.add(r),l.set(r,r.addEventListener("willUpdate",c))},remove:r=>{t.delete(r);const u=l.get(r);u&&(u(),l.delete(r)),c()},dirty:c}}const Ji=t=>t===!0,Wc=t=>Ji(t===!0)||t==="id",Kc=({children:t,id:l,inherit:c=!0})=>{const r=n.useContext(Qn),u=n.useContext(Vc),[x,b]=Oc(),h=n.useRef(null),g=r.id||u;h.current===null&&(Wc(c)&&g&&(l=l?g+"-"+l:g),h.current={id:l,group:Ji(c)&&r.group||mi()});const y=n.useMemo(()=>({...h.current,forceRender:x}),[b]);return e.jsx(Qn.Provider,{value:y,children:t})};function Yr(t){return typeof t=="object"&&!Array.isArray(t)}function qi(t,l,c,r){return typeof t=="string"&&Yr(l)?Zl(t,c,r):t instanceof NodeList?Array.from(t):Array.isArray(t)?t:[t]}function Uc(t,l,c){return t*(l+1)}function hi(t,l,c,r){return typeof l=="number"?l:l.startsWith("-")||l.startsWith("+")?Math.max(0,t+parseFloat(l)):l==="<"?c:l.startsWith("<")?Math.max(0,c+parseFloat(l.slice(1))):r.get(l)??t}function Hc(t,l,c){for(let r=0;r<t.length;r++){const u=t[r];u.at>l&&u.at<c&&(Jl(t,u),r--)}}function Qc(t,l,c,r,u,x){Hc(t,u,x);for(let b=0;b<l.length;b++)t.push({value:l[b],at:Xl(u,x,r[b]),easing:Xi(c,b)})}function Gc(t,l){for(let c=0;c<t.length;c++)t[c]=t[c]/(l+1)}function Yc(t,l){return t.at===l.at?t.value===null?1:l.value===null?-1:0:t.at-l.at}const Zc="easeInOut";function Xc(t,{defaultTransition:l={},...c}={},r,u){const x=l.duration||.3,b=new Map,h=new Map,g={},y=new Map;let j=0,f=0,L=0;for(let R=0;R<t.length;R++){const k=t[R];if(typeof k=="string"){y.set(k,f);continue}else if(!Array.isArray(k)){y.set(k.name,hi(f,k.at,j,y));continue}let[P,T,I={}]=k;I.at!==void 0&&(f=hi(f,I.at,j,y));let M=0;const B=(H,Z,_,ae=0,q=0)=>
71{const re=Jc(H),{delay:K=0,times:C=ql(re),type:ce="keyframes",repeat:X,repeatType:Oe,repeatDelay:st=0,...He}=Z;let{ease:z=l.ease||"easeOut",duration:ne}=Z;const S=typeof K=="function"?K(ae,q):K,Se=re.length,Qe=so(ce)?ce:u?.[ce||"keyframes"];if(Se<=2&&Qe){let De=100;if(Se===2&&td(re)){const Te=re[1]-re[0];De=Math.abs(Te)}const Me={...He};ne!==void 0&&(Me.duration=ao(ne));const E=eo(Me,De,Qe);z=E.ease,ne=E.duration}ne??(ne=x);const lt=f+S;C.length===1&&C[0]===0&&(C[1]=1);const at=C.length-re.length;if(at>0&&to(C,at),re.length===1&&re.unshift(null),X){ne=Uc(ne,X);const De=[...re],Me=[...C];z=Array.isArray(z)?[...z]:[z];const E=[...z];for(let Te=0;Te<X;Te++){re.push(...De);for(let Be=0;Be<De.length;Be++)C.push(Me[Be]+(Te+1)),z.push(Be===0?"linear":Xi(E,Be-1))}Gc(C,X)}const ot=lt+ne;Qc(_,re,z,C,lt,ot),M=Math.max(S+ne,M),L=Math.max(ot,L)};if(Ki(P)){const H=ui(P,h);B(T,I,xi("default",H))}else{const H=qi(P,T,r,g),Z=H.length;for(let _=0;_<Z;_++){T=T,I=I;const ae=H[_],q=ui(ae,h);for(const re in T)B(T[re],qc(I,re),xi(re,q),_,Z)}}j=f,f+=M}return h.forEach((R,k)=>{for(const P in R){const T=R[P];T.sort(Yc);const I=[],M=[],B=[];for(let Z=0;Z<T.length;Z++){const{at:_,value:ae,easing:q}=T[Z];I.push(ae),M.push(ro(0,L,_)),B.push(q||"easeOut")}M[0]!==0&&(M.unshift(0),I.unshift(I[0]),B.unshift(Zc)),M[M.length-1]!==1&&(M.push(1),I.push(null)),b.has(k)||b.set(k,{keyframes:{},transition:{}});const H=b.get(k);H.keyframes[P]=I,H.transition[P]={...l,duration:L,ease:B,times:M,...c}}}),b}function ui(t,l){return!l.has(t)&&l.set(t,{}),l.get(t)}function xi(t,l){return l[t]||(l[t]=[]),l[t]}function Jc(t){return Array.isArray(t)?t:[t]}function qc(t,l){return t&&t[l]?{...t,...t[l]}:{...t}}const ed=t=>typeof t=="number",td=t=>t.every(ed);function sd(t,l){return t in l}class ad extends no{constructor(){super(...arguments),this.type="object"}readValueFromInstance(l,c){if(sd(c,l)){const r=l[c];if(typeof r=="string"||typeof r=="number")return r}}getBaseTargetFromProps(){}removeValueFromRenderState(l,c){delete c.output[l]}measureInstanceViewportBox(){return io()}build(l,c){Object.assign(l.output,c)}renderInstance(l,{output:c}){Object.assign(l,c)}sortInstanceNodePosition(){return 0}}function rd(t){const l={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},c=lo(t)&&!oo(t)?new co(l):new mo(l);c.mount(t),Ba.set(t,c)}function nd(t){const l={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},c=new ad(l);c.mount(t),Ba.set(t,c)}function id(t,l){return Ki(t)||typeof t=="number"||typeof t=="string"&&!Yr(l)}function el(t,l,c,r){const u=[];if(id(t,l))u.push(ho(t,Yr(l)&&l.default||l,c&&(c.default||c)));else{const x=qi(t,l,r),b=x.length;for(let h=0;h<b;h++){const g=x[h],y=g instanceof Element?rd:nd;Ba.has(g)||y(g);const j=Ba.get(g),f={...c};"delay"in f&&typeof f.delay=="function"&&(f.delay=f.delay(h,b)),u.push(...uo(j,{...l,transition:f},{}))}}return u}function ld(t,l,c){const r=[];return Xc(t,l,c,{spring:xo}).forEach(({keyframes:x,transition:b},h)=>{r.push(...el(h,x,b))}),r}function od(t){return Array.isArray(t)&&t.some(Array.isArray)}function cd(t){function l(c,r,u){let x=[],b;if(od(c))x=ld(c,r,t);else{const{onComplete:g,...y}=u||{};typeof g=="function"&&(b=g),x=el(c,r,y,t)}const h=new Dc(x);return b&&h.finished.then(b),h}return l}const dd=cd();function md(){const t=n.useRef(null);return n.useEffect(()=>{const l=t.current;if(!l)return;const c=dd(0,21934,{duration:2,ease:"easeOut",onUpdate(r){l.textContent=Math.round(r).toLocaleString("en-IN")}});return()=>c.stop()},[]),e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 px-3 py-2 shadow-sm",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[9px] font-medium text-slate-500 uppercase tracking-wide truncate",children:"Pincodes covered"}),e.jsx("p",{className:"text-[9px] text-slate-400",children:"98% of India's FTL"})]}),e.jsxs("div",{className:"text-right flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{ref:t,className:"text-2xl font-black text-slate-800 font-mono tabular-nums",children:"0"}),e.jsx("span",{className:"text-base",children:"📍"})]})]})})}const Wa=({children:t,className:l="",style:c,as:r="span",maxFontSizePx:u=24,minFontSizePx:x=11})=>{const b=n.useRef(null),[h,g]=n.useState(u);return n.useLayoutEffect(()=>{const y=b.current;if(!y)return;let j=u;for(y.style.fontSize=`${j}px`;y.scrollWidth>y.clientWidth&&j>x;)j-=1,y.style.fontSize=`${j}px`;g(j)},[t,u,x]),e.jsx(r,{ref:b,className:`${l} whitespace-nowrap overflow-hidden block`,style:{...c,fontSize:`${h}px`},children:t})};function hd({isOpen:t,onClose:l,vendorType:c,vendorId:r,companyName:u,canBookNow:x,onBo
71okNow:b,staticContact:h}){const[g,y]=n.useState(!1),[j,f]=n.useState({});if(n.useEffect(()=>{if(!t)return;if(h){f({contactPerson:h.contactPerson,phone:h.phone,email:h.email,resolvedCompanyName:h.companyName}),y(!1);return}if(!r)return;y(!0),(c==="temporaryTransporter"?po(r):fo(r)).then(P=>{P&&f({contactPerson:P.contactPersonName||P.contactPerson||"",phone:P.vendorPhoneNumber||P.vendorPhone||P.phone||"",email:P.vendorEmailAddress||P.vendorEmail||P.email||"",resolvedCompanyName:P.companyName||u})}).catch(()=>Ui.error("Could not load vendor contact details")).finally(()=>y(!1))},[t,r,c,h]),!t)return null;const L=j.resolvedCompanyName||u||"Vendor",R=j.phone||j.email;return Kt.createPortal(e.jsx(W.div,{initial:{opacity:0},animate:{opacity:1},className:"fixed inset-0 z-[10000] bg-slate-900/40 backdrop-blur-sm flex items-center justify-center p-4 overflow-x-hidden",onClick:l,children:e.jsxs(W.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white w-[94vw] max-w-lg rounded-3xl shadow-2xl overflow-hidden max-h-[90vh] overflow-y-auto scrollbar-hide",onClick:k=>k.stopPropagation(),children:[e.jsxs("div",{className:"bg-slate-900 px-6 py-4 text-white relative",children:[e.jsx("button",{onClick:l,className:"absolute top-3.5 right-4 text-slate-400 hover:text-white transition-colors",children:e.jsx(Vt,{size:20})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-blue-500/20 p-1.5 rounded-lg",children:e.jsx(ei,{className:"text-blue-400",size:20})}),e.jsx("h3",{className:"text-lg font-bold",children:L})]})]}),e.jsx("div",{className:"p-6 space-y-4",children:g?e.jsx("div",{className:"text-center text-sm text-slate-400 py-8",children:"Loading contact details..."}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[j.contactPerson&&e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-slate-50 rounded-lg",children:[e.jsx(go,{className:"text-blue-600 mt-1 flex-shrink-0",size:20}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500",children:"Contact Person"}),e.jsx("p",{className:"text-base text-slate-900 font-medium",children:j.contactPerson})]})]}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-slate-50 rounded-lg",children:[e.jsx(ei,{className:"text-blue-600 mt-1 flex-shrink-0",size:20}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500",children:"Company Name"}),e.jsx("p",{className:"text-base text-slate-900 font-medium",children:L})]})]}),j.phone&&e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-slate-50 rounded-lg sm:col-span-2",children:[e.jsx(bo,{className:"text-blue-600 mt-1 flex-shrink-0",size:20}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 mb-1",children:"Phone Number"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("a",{href:`tel:+91${j.phone}`,className:"text-base text-blue-600 font-medium hover:underline",children:["+91 ",j.phone]}),e.jsxs("a",{href:`https://wa.me/91${String(j.phone).replace(/\D/g,"")}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-green-500 text-white text-xs font-semibold rounded-full hover:bg-green-600 transition-colors",children:[e.jsx(vo,{size:14}),"WhatsApp"]})]})]})]}),j.email&&e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-slate-50 rounded-lg sm:col-span-2",children:[e.jsx(yo,{className:"text-blue-600 mt-1 flex-shrink-0",size:20}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500",children:"Email Address"}),e.jsx("a",{href:`mailto:${j.email}`,className:"text-base text-blue-600 font-medium hover:underline break-all",children:j.email})]})]}),!R&&e.jsx("div",{className:"sm:col-span-2 bg-amber-50 border border-amber-200 rounded-lg p-4 text-sm text-amber-700",children:"Contact details for this vendor are not available at the moment."})]})}),e.jsxs("div",{className:"bg-slate-50 px-6 py-4 border-t flex items-center justify-between gap-4",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Need to reach out? Use the contact information above."}),x&&e.jsxs("button",{onClick:b,className:"px-6 py-2.5 bg-slate-900 text-white font-bold rounded-xl hover:bg-slate-700 transition-colors inline-flex items-center gap-2 text-sm whitespace-nowrap flex-shrink-0",children:[e.jsx(Dt,{size:14}),"Book Now"]})]})]})}),document.body)}const Ms=t=>new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:0,maximumFractionDigits:2}).format(Math.round((t||0)*100)/100),ud=[{label:"Docket Charge",keys:["docketCharge","breakdown.docketCharge"]},{label:"Fuel Surcharge",keys:["fuelCharges","breakdown.fuelCharges"]},{label:"ROV / Insurance",keys:["rovCharges","breakdown.rovCharges"]},{label:"Insurance Charges",keys:["insuaranceCharges","insuranceCharges"]},{label:"ODA Charges",keys:["odaCharges"]},{label:"Handling Charges",keys:["handlingCharges"]},{label:"FM Charges",keys:["fmCharges"]},{label:"Appointment Charges",keys:["appointmentCharges"]},{label:"Green Tax",keys:["greenTax","breakdown.greenTax"]},{label:"DACC Charges",keys:["daccCharges","breakdown.daccCharge"]},{label:"Miscellaneous Charges",keys:["miscCharges","breakdown.miscCharge"]},{label:"Hamali Charges",keys:["hamaliCharges","breakdown.hamaliCharge"]},{label:"OS/OW Charges",keys:["osOwCharges","breakdown.osOwCharge"]},{label:"Single Piece Charges",keys:["singlePieceCharges","breakdown.singlePieceCharge"]},{label:"DOD Charges",keys:["dodCharges","breakdown.dodCharge"]},{label:"COD Charges",keys:["codCharges"]},{label:"To-Pay Charges",keys:["topayCharges"]},{label:"Cheque Handling",keys:["chequeHandlingCharges"]},{label:"Invoice Value Charge",keys:["invoiceAddon","invoiceValueCharge"]},{label:"Custom Surcharges",keys:["customSurcharges"]}];function pi(t,l){const c=Array.from({length:t.length+1},(r,u)=>[u,...Array(l.length).fill(0)]);for(let r=0;r<=l.length;r++)c[0][r]=r;for(let r=1;r<=t.length;r++)for(let u=1;u<=l.length;u++)c[r][u]=t[r-1]===l[u-1]?c[r-1][u-1]:1+Math.min(c[r-1][u-1],c[r-1][u],c[r][u-1]);return c[t.length][l.length]}function Wr(t,l){if(l.includes(t))return!0;const c=t.length<=4?1:2,r=pi(t,l),u=l.slice(0,t.length+1),x=pi(t,u);return Math.min(r,x)<=c}function xd(t,l){const c=l.toLowerCase();if(c.includes(t))return!0;
71const r=c.split(/[^a-z]+/).filter(Boolean);return t.split(/[^a-z]+/).filter(Boolean).every(x=>r.some(b=>Wr(x,b)))}function fi(t,l){for(const c of l)if(c.includes(".")){const[r,u]=c.split("."),x=t?.[r]?.[u];if(x!=null&&x>0)return x}else{const r=t?.[c]!==void 0&&t?.[c]!==null?t[c]:t?.breakdown?.[c];if(r!=null&&r>0)return r}return 0}const pd=t=>!!t&&t.companyName!=="FTL"&&t.companyName!=="Wheelseye FTL"&&t.companyName!=="LOCAL FTL"&&!t.isMoverLive&&!t.isPorterLive;function tl({quote:t,onClose:l}){const c=t?.originZone||t?.effectiveOriginZone,r=t?.destZone||t?.effectiveDestZone,u=t?.unitPrice,x=t?.weightBreakdown?.chargeableWeight??t?.chargeableWeight,b=t?.effectiveBaseFreight??t?.baseFreight,h=t?.breakdown?.gstPercent,g=fi(t,["gstAmount","breakdown.gstAmount"]),y=t?.totalCharges,j=ud.map(f=>({...f,value:fi(t,f.keys)})).filter(f=>f.value>0);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-3",children:[e.jsx("h3",{className:"text-base font-black text-slate-900 leading-tight",children:t?.companyName||"This vendor"}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xl font-black text-slate-900 whitespace-nowrap",children:Ms(y)}),l&&e.jsx("button",{type:"button",onClick:l,className:"p-1 rounded-full hover:bg-slate-100 text-slate-400 hover:text-slate-700 transition-colors flex-shrink-0","aria-label":"Close",children:e.jsx(Vt,{size:18})})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 mb-3",children:[t?.originPincode," → ",t?.destinationPincode]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-3 bg-slate-50/50",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx(Jt,{size:13,className:"text-blue-500 flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-bold text-slate-800 uppercase tracking-wide",children:"1. Zone rate → base freight"})]}),c&&r?e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-700 mb-1",children:[e.jsxs("span",{children:["Zone ",c," → ",r]}),e.jsxs("span",{className:"font-bold",children:["₹",u,"/kg"]})]}):e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-700 mb-1",children:[e.jsx("span",{children:"Rate for this route"}),e.jsxs("span",{className:"font-bold",children:["₹",u,"/kg"]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-700 border-t border-slate-200 pt-1 mt-1",children:[e.jsxs("span",{children:["× ",x," kg chargeable weight"]}),e.jsx("span",{className:"font-bold",children:Ms(b)})]})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx(Zi,{size:13,className:"text-emerald-500 flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-bold text-slate-800 uppercase tracking-wide",children:"2. Charges + total"})]}),e.jsxs("div",{className:"rounded-xl bg-slate-50 border border-slate-100 overflow-hidden text-[11px]",children:[e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 text-slate-700",children:[e.jsx("span",{children:"Base freight"}),e.jsx("span",{className:"font-semibold",children:Ms(b)})]}),j.map(f=>e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 border-t border-slate-100 text-slate-700",children:[e.jsx("span",{children:f.label}),e.jsx("span",{className:"font-semibold",children:Ms(f.value)})]},f.label)),g>0&&e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 border-t border-slate-100 text-slate-700",children:[e.jsxs("span",{children:["GST",h?` (${h}%)`:""]}),e.jsx("span",{className:"font-semibold",children:Ms(g)})]}),e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 border-t border-slate-200 bg-blue-50 text-blue-900 font-black",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:Ms(y)})]})]})]})]})]})}function gi({quote:t}){const[l,c]=n.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),c(!0)},className:"inline-flex items-center justify-center rounded-full text-slate-400 hover:text-blue-600 hover:bg-blue-50 transition-colors flex-shrink-0",style:{width:"1em",height:"1em"},"aria-label":"How was this price calculated?",title:"How was this price calculated?",children:e.jsx(Qr,{size:"1em"})}),l&&Kt.createPortal(e.jsx(kt,{children:e.jsx(W.div,{initial:{opacity:0}
71,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-[9998] flex items-center justify-center p-4",onClick:()=>c(!1),children:e.jsx(W.div,{initial:{opacity:0,y:16,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.97},transition:{type:"spring",stiffness:320,damping:28},onClick:r=>r.stopPropagation(),className:"bg-white rounded-3xl shadow-2xl w-full max-w-sm max-h-[92vh] overflow-y-auto",children:e.jsxs("div",{className:"p-5",children:[e.jsx(tl,{quote:t,onClose:()=>c(!1)}),e.jsx("button",{type:"button",onClick:()=>c(!1),className:"mt-4 w-full py-2.5 rounded-xl bg-slate-900 text-white text-sm font-bold hover:bg-slate-800 transition-colors",children:"Got it"})]})},"modal")},"backdrop")}),document.body)]})}const fd=[{pincode:"110020",zone:"N1",oda:!1},{pincode:"560001",zone:"S1",oda:!1},{pincode:"790001",zone:"NE2",oda:!0}],gd=[{label:"Docket Charges",value:"₹50 flat"},{label:"Fuel Surcharge",value:"8% on base freight"},{label:"ROV / FOV",value:"1% on freight (min ₹20)"},{label:"Handling Charges",value:"₹0.50/kg above 50kg"},{label:"GST",value:"5% on subtotal"}],ia={zones:["N1","S1","W1","E1"],from:"N1",rates:[6,10.5,8.1,10.5]},sl=60,bd=t=>t.replace(/[^a-zA-Z ]/g,"").slice(0,sl);function vd(t){const l=(t||[]).find(c=>c?.originPincode&&c?.destinationPincode);return l?`${l.originPincode} → ${l.destinationPincode}`:"this route"}const yd=["porter","rapido","ola","mover"];function wd({quotes:t,quickBookingParams:l}){const c=Hr(),[r,u]=n.useState(null),[x,b]=n.useState(""),[h,g]=n.useState(!1),[y,j]=n.useState(""),[f,L]=n.useState(null),[R,k]=n.useState(!1),[P,T]=n.useState(null),I=vd(t),M=()=>u("explain"),B=()=>{u(null),b(""),j(""),L(null),k(!1),T(null)},H=()=>u("rate"),Z=()=>{B();const C=l;C?.from&&C?.to?c(`/quick-booking?from=${C.from}&to=${C.to}&weight=${C.weight??0}&dim=${C.dim??0}&distance=${C.distance??0}`):document.getElementById("quick-booking-section")?.scrollIntoView({behavior:"smooth",block:"start"})},_=()=>{const C=y.trim().toLowerCase();if(!C)return;const ce=(t||[]).find(Oe=>pd(Oe)&&xd(C,String(Oe?.companyName||"")));if(ce){L(ce),k(!1),T(null);return}const X=yd.find(Oe=>Wr(C,Oe)||Wr(Oe,C));if(X){L(null),k(!1),T(X);return}L(null),T(null),k(!0)},ae=async(C,ce)=>{g(!0);try{await Lt.post("/api/price-explainer-feedback",{helpful:C,comment:ce||"",url:window.location.href})}catch(X){console.error("[PriceExplainer] Failed to submit feedback",X)}finally{g(!1)}},q=async()=>{await ae(!0),me.success("Thanks for the feedback!"),B()},re=()=>u("elaborate"),K=async()=>{await ae(!1,x),u("done")};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:M,className:"w-full flex items-center gap-2 text-left px-3 py-2 rounded-2xl border border-slate-200 bg-white hover:border-blue-300 hover:bg-blue-50/50 transition-colors group flex-shrink-0",children:[e.jsx(Qr,{size:15,className:"text-blue-500 flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-semibold text-slate-600 group-hover:text-blue-700",children:"How is this price calculated?"})]}),r&&Kt.createPortal(e.jsx(kt,{children:e.jsx(W.div,{initial:{opacity:0}
71,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-[9998] flex items-center justify-center p-4",onClick:r==="explain"?H:void 0,children:e.jsxs(W.div,{initial:{opacity:0,y:16,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.97},transition:{type:"spring",stiffness:320,damping:28},onClick:C=>C.stopPropagation(),className:"bg-white rounded-3xl shadow-2xl w-full max-w-4xl max-h-[92vh] overflow-y-auto",children:[r==="explain"&&e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-black text-slate-900",children:"How is this price calculated?"}),e.jsx("button",{type:"button",onClick:H,className:"p-1.5 rounded-full hover:bg-slate-100 text-slate-400 hover:text-slate-700 transition-colors flex-shrink-0","aria-label":"Close",children:e.jsx(Vt,{size:18})})]}),e.jsx("p",{className:"text-sm text-slate-600 mb-5",children:"Every price you see is built from three things a vendor sets up in their profile. Here's what each one means, in plain terms — with sample values (not this quote's actual numbers)."}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-3.5 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Jt,{size:15,className:"text-blue-500 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-bold text-slate-800",children:"1. Serviceability"})]}),e.jsx("p",{className:"text-xs text-slate-500 mb-3",children:"Do they even go there? A vendor lists which pincodes they deliver to/from, and whether each counts as a remote/extra-charge (ODA) area. Off their list = they won't appear as an option."}),e.jsxs("div",{className:"rounded-xl bg-slate-50 border border-slate-100 overflow-hidden text-[11px]",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-1 px-2.5 py-1.5 font-bold text-slate-500 uppercase tracking-wide",children:[e.jsx("span",{children:"Pincode"}),e.jsx("span",{children:"Zone"}),e.jsx("span",{children:"ODA"})]}),fd.map(C=>e.jsxs("div",{className:"grid grid-cols-3 gap-1 px-2.5 py-1.5 border-t border-slate-100 text-slate-700",children:[e.jsx("span",{children:C.pincode}),e.jsx("span",{children:C.zone}),e.jsx("span",{children:C.oda?"Yes":"No"})]},C.pincode))]})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-3.5 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Lc,{size:15,className:"text-purple-500 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-bold text-slate-800",children:"2. Zone rates"})]}),e.jsx("p",{className:"text-xs text-slate-500 mb-3",children:"The base ₹/kg. India is split into zones (N1, S1, W1...) and every vendor sets a rate for each origin → destination zone pair. Your route picks which cell of this grid starts the calculation."}),e.jsxs("div",{className:"rounded-xl bg-slate-50 border border-slate-100 overflow-hidden text-[11px]",children:[e.jsxs("div",{className:"grid gap-1 px-2.5 py-1.5 font-bold text-slate-500 uppercase tracking-wide",style:{gridTemplateColumns:`1fr repeat(${ia.zones.length}, 1fr)`},children:[e.jsx("span",{children:"From\\To"}),ia.zones.map(C=>e.jsx("span",{children:C},C))]}),e.jsxs("div",{className:"grid gap-1 px-2.5 py-1.5 border-t border-slate-100 text-slate-700",style:{gridTemplateColumns:`1fr repeat(${ia.zones.length}, 1fr)`},children:[e.jsx("span",{className:"font-semibold",children:ia.from}),ia.rates.map((C,ce)=>e.jsxs("span",{children:["₹",C]},ce))]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-3.5 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Zi,{size:15,className:"text-emerald-500 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-bold text-slate-800",children:"3. Charges"})]}),e.jsx("p",{className:"text-xs text-slate-500 mb-3",children:"Everything added on top. Zone rate × chargeable weight = base freight. Vendors add their docket fee, fuel surcharge, ROV, handling, GST and any optional charges you selected on top of that base."}),e.jsx("div",{className:"rounded-xl bg-slate-50 border border-slate-100 overflow-hidden text-[11px]",children:gd.map(C=>e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 border-t border-slate-100 first:border-t-0 text-slate-700",children:[e.jsx("span",{children:C.label}),e.jsx("span",{className:"font-semibold",children:C.value})]},C.label))})]})]}),e.jsx("div",{className:"mt-5 rounded-2xl bg-blue-50 border border-blue-100 p-3.5 text-xs text-blue-800 leading-relaxed",children:"Think of it like a taxi fare: serviceability decides if the driver will take you there at all, the zone rate is the per-km fare, and charges are the tolls, waiting time and surge pricing added on top — every vend
71or sets all three independently."}),e.jsxs("button",{type:"button",onClick:()=>u("search"),className:"mt-5 w-full py-2.5 rounded-xl bg-slate-900 text-white text-sm font-bold hover:bg-slate-800 transition-colors flex items-center justify-center gap-2",children:[e.jsx(Or,{size:15}),"Check a specific vendor's real price"]})]}),r==="search"&&e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("h3",{className:"text-lg font-black text-slate-900",children:"Check a vendor's real calculation"}),e.jsx("button",{type:"button",onClick:H,className:"p-1.5 rounded-full hover:bg-slate-100 text-slate-400 hover:text-slate-700 transition-colors flex-shrink-0","aria-label":"Close",children:e.jsx(Vt,{size:18})})]}),e.jsx("p",{className:"text-xs text-slate-500 mb-4",children:"Type a vendor's name to see their actual rate and charges for this route."}),e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("input",{type:"text",value:y,onChange:C=>j(bd(C.target.value)),onKeyDown:C=>{C.key==="Enter"&&_()},placeholder:"e.g. Delhivery",maxLength:sl,className:"flex-1 rounded-xl border border-slate-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsxs("button",{type:"button",onClick:_,disabled:!y.trim(),className:"px-4 py-2 rounded-xl bg-blue-600 text-white text-sm font-bold hover:bg-blue-700 transition-colors disabled:opacity-40 flex items-center gap-1.5",children:[e.jsx(Or,{size:14}),"Search"]})]}),f&&e.jsx(tl,{quote:f}),P&&e.jsxs("div",{className:"rounded-2xl bg-blue-50 border border-blue-200 p-4 text-sm text-blue-900",children:[e.jsxs("div",{className:"flex items-start gap-2.5 mb-3",children:[e.jsx(It,{size:16,className:"text-blue-600 flex-shrink-0 mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-bold capitalize",children:P})," is a live Quick Booking option — its price comes straight from their own app, not a fixed rate formula, so there's nothing to break down here. Open the ",e.jsx("span",{className:"font-bold",children:"Quick Booking"})," section above and tap ",e.jsx("span",{className:"font-bold",children:'"View More"'})," on their card for their live price and vehicle details."]})]}),e.jsx("button",{type:"button",onClick:Z,className:"w-full py-2 rounded-xl bg-blue-600 text-white text-xs font-bold hover:bg-blue-700 transition-colors",children:"Go to Quick Booking"})]}),R&&e.jsxs("div",{className:"rounded-2xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-900 flex items-start gap-2.5",children:[e.jsx(ca,{size:16,className:"text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("span",{children:[e.jsxs("span",{className:"font-bold",children:['"',y.trim(),'"']})," doesn't serve this route, or isn't one of your vendors for this search. Check the spelling, or look at the results list for vendors that do cover ",I,"."]})]}),e.jsx("button",{type:"button",onClick:H,className:"mt-5 w-full py-2.5 rounded-xl bg-slate-900 text-white text-sm font-bold hover:bg-slate-800 transition-colors",children:"Got it"})]}),r==="rate"&&e.jsxs("div",{className:"p-6 text-center",children:[e.jsx("h3",{className:"text-lg font-black text-slate-900 mb-1",children:"Was this explanation helpful?"}),e.jsx("p",{className:"text-sm text-slate-500 mb-6",children:"Let us know so we can make it clearer."}),e.jsxs("div",{className:"flex items-center justify-center gap-4",children:[e.jsxs("button",{type:"button",disabled:h,onClick:q,className:"flex flex-col items-center gap-1.5 px-6 py-3 rounded-2xl border border-slate-200 hover:border-emerald-400 hover:bg-emerald-50 transition-colors disabled:opacity-50",children:[e.jsx(Mc,{size:22,className:"text-emerald-600"}),e.jsx("span",{className:"text-xs font-semibold text-slate-600",children:"Yes"})]}),e.jsxs("button",{type:"button",disabled:h,onClick:re,className:"flex flex-col items-center gap-1.5 px-6 py-3 rounded-2xl border border-slate-200 hover:border-red-400 hover:bg-red-50 transition-colors disabled:opacity-50",children:[e.jsx(Rc,{size:22,className:"text-red-500"}),e.jsx("span",{className:"text-xs font-semibold text-slate-600",children:"No"})]})]}),e.jsx("button",{type:"button",onClick:B,className:"mt-6 text-xs text-slate-400 hover:text-slate-600",children:"Skip"})]}
71),r==="elaborate"&&e.jsxs("div",{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-black text-slate-900 mb-1",children:"Sorry about that — what was missing?"}),e.jsx("p",{className:"text-sm text-slate-500 mb-4",children:"Tell us what wasn't clear so we can improve this explanation."}),e.jsx("textarea",{value:x,onChange:C=>b(C.target.value),rows:4,placeholder:"e.g. I still don't understand why fuel surcharge is added...",className:"w-full rounded-xl border border-slate-300 p-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"}),e.jsxs("div",{className:"mt-4 rounded-2xl bg-amber-50 border border-amber-100 p-3.5 text-xs text-amber-900 leading-relaxed",children:["If you think a charge on a specific vendor's quote is missing or looks extra, check that vendor's full rate setup under ",e.jsx("span",{className:"font-bold",children:"My Vendors"})," — every charge shown there is exactly what feeds into the price here. If it's still not clear, reach out via the ",e.jsx("span",{className:"font-bold",children:'"May I help you?"'})," chat in the bottom-right corner and we'll walk you through it."]}),e.jsxs("div",{className:"mt-5 flex gap-3",children:[e.jsx("button",{type:"button",onClick:B,className:"flex-1 py-2.5 rounded-xl border border-slate-300 text-slate-600 text-sm font-bold hover:bg-slate-50 transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",disabled:h,onClick:K,className:"flex-1 py-2.5 rounded-xl bg-slate-900 text-white text-sm font-bold hover:bg-slate-800 transition-colors disabled:opacity-50",children:"Submit"})]})]}),r==="done"&&e.jsxs("div",{className:"p-6 text-center",children:[e.jsx("h3",{className:"text-lg font-black text-slate-900 mb-1",children:"Thanks for the feedback"}),e.jsxs("p",{className:"text-sm text-slate-500 mb-5",children:["We've noted this down. If you need help right now, the"," ",e.jsx("span",{className:"font-bold text-slate-700",children:'"May I help you?"'})," chat in the bottom-right corner can get you a quicker answer."]}),e.jsx("button",{type:"button",onClick:B,className:"w-full py-2.5 rounded-xl bg-slate-900 text-white text-sm font-bold hover:bg-slate-800 transition-colors",children:"Close"})]})]},"modal")},"backdrop")}),document.body)]})}const bi=t=>t?t.startsWith("0")?"Cannot start with zero":/^[1-9][0-9]{9}$/.test(t)?"":"Enter a valid 10-digit phone number":"",vi=t=>t.replace(/[^a-zA-Z0-9\s,.\-/#]/g,"").slice(0,300);function Nd(t,l,c,r){const u=h=>h.trim().toLowerCase(),x=u(t);if(!x)return null;const b=u(l);if(b&&x===b)return"This is identical to your Pickup Address above — did you mean to type the drop-off address here instead?";if(c){const h=u(c),g=r?u(r):"",y=(j,f)=>f.length>0&&new RegExp(`\\b${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(j);if(y(x,h)&&!(g&&y(x,g)))return`This looks like your pickup location (${c}), not the drop-off — please enter the address in ${r||"the destination city"} instead.`}return null}const jd=t=>/doesn'?t service this route/i.test(t),kd={searching:"Searching for a truck",found:"Truck found — action needed",tracking:"Live tracking",details:"Booking details",rate_limited:"Paused by Wheelseye",not_found:"Truck not found — retrying"},Pt=[{message:"Opening Wheelseye…",label:"Opening Wheelseye",emoji:"🚪"},{message:"Filling pickup & drop…",label:"Filling pickup & drop",emoji:"📍"},{message:"Selecting weight…",label:"Selecting weight",emoji:"⚖️"}
71,{message:"Choosing truck…",label:"Choosing truck",emoji:"🚛"},{message:"Confirming truck search mode…",label:"Confirming truck search mode",emoji:"🔎"},{message:"Filling loading address…",label:"Filling loading address",emoji:"🏠"},{message:"Filling drop address & contact…",label:"Filling drop address & contact",emoji:"📦"},{message:"Selecting payment & confirming…",label:"Selecting payment & confirming",emoji:"💳"}],yi=Pt.map(t=>t.message);let Cd=0;const Sd=()=>`ws-book-${Date.now()}-${Cd++}`,wi="fc_ws_last_pickup_address",Ni="fc_ws_last_delivery_address",ji=t=>{try{return localStorage.getItem(t)||""}catch{return""}},ki=(t,l)=>{try{localStorage.setItem(t,l)}catch{}};function Td({isOpen:t,onClose:l,onEditSearch:c,vehicleName:r,price:u,route:x,defaultPhone:b="",defaultName:h=""}){const g=Ua(),[y,j]=n.useState("form"),[f,L]=n.useState(""),[R,k]=n.useState(!1),[P,T]=n.useState(""),[I,M]=n.useState(!1),[B,H]=n.useState(b),[Z,_]=n.useState(!1),[ae,q]=n.useState(h),[re,K]=n.useState(""),[C,ce]=n.useState(""),[X,Oe]=n.useState(""),[st,He]=n.useState(!1),[z,ne]=n.useState(-1),[S,Se]=n.useState(null),[Qe,lt]=n.useState(!1),[at,ot]=n.useState(!1),[De,Me]=n.useState(!1),[E,Te]=n.useState(!1),[Be,Ae]=n.useState(null),Ve=n.useRef(""),xt=n.useRef(-1),Ge=n.useRef("form"),Ye=n.useRef(!1);if(n.useEffect(()=>{t&&(j("form"),Ge.current="form",L(ji(wi)),T(ji(Ni)),M(!1),H(b),_(!1),q(h),K(""),ce(""),Oe(""),He(!1),ne(-1),xt.current=-1,Ve.current="",Se(null),Ae(null),lt(!1),Te(!1),ot(!1),Ye.current=!1,Me(!1))},[t]),n.useEffect(()=>{if(Be===null)return;const U=setInterval(()=>Ae(J=>J!==null&&J>0?J-1:J),1e3);return()=>clearInterval(U)},[Be!==null]),n.useEffect(()=>{if(!t)return;const U=J=>{if(!J.data?.__fc_ext_reply__||J.data.type!=="FC_BOOKING_UPDATE"||J.data.bookingId!==Ve.current)return;const xe=J.data.stage;if(ce(J.data.detail||""),xe==="starting"||xe==="vehicle_selecting"||xe==="address_filling"||xe==="booking_now"){if(Ge.current==="truck_search")return;j(xe),Ge.current=xe,K(J.data.message||"Working…");const ie=yi.indexOf(J.data.message);ie>-1&&(ne(ie),xt.current=ie,console.log(`🔵 [FC-WS-BOOKING][checkpoint] Step ${ie+1}/${Pt.length} started — "${Pt[ie].label}"`))}else if(xe==="truck_search"){if(Ye.current)return;try{const ie=JSON.parse(J.data.detail||"{}");Se(ie),ie.phase==="found"&&typeof ie.holdSecondsLeft=="number"?Ae(ie.holdSecondsLeft):Ae(null)}catch{}j("truck_search"),Ge.current="truck_search",K(J.data.message||"Tracking your booking…"),Me(!1)}else if(xe==="booked"){j("truck_search"),Ge.current="truck_search",lt(!0),Me(!1),K(J.data.message||"Booked!");try{const ie=JSON.parse(J.data.detail||"{}");ie.rows&&Se(ie)}catch{}Ae(null),console.log(`✅ [FC-WS-BOOKING][checkpoint] Booked — all ${Pt.length} steps completed.`)}else if(xe==="cancelling")K(J.data.message||"Cancelling your booking…");else if(xe==="cancelled")ot(!1),Ye.current=!1,me.success(J.data.message||"Booking cancelled successfully"),l();else if(xe==="cancel_failed")ot(!1),Ye.current=!1,me.error(J.data.message||"Could not auto-cancel — try again");else if(xe==="accepting")K(J.data.message||"Accepting your truck…");else if(xe==="needs_attention"){ot(!1),Ye.current=!1,Me(!1),j("needs_attention"),K(J.data.message||"Finish the last step in the Wheelseye tab"),Oe(J.data.addressToType||""),He(!1);const ie=Pt[xt.current]?.label||"an unknown step";console.log(`🛑 [FC-WS-BOOKING][checkpoint] Stuck at step ${xt.current+1}/${Pt.length} — "${ie}". Reason: ${J.data.message}`,J.data.detail||"")}else if(xe==="error"){ot(!1),Ye.current=!1,Me(!1);const ie=J.data.message||"Something went wrong";if(K(ie),jd(ie))j("not_serviceable"),console.log(`ℹ️ [FC-WS-BOOKING][checkpoint] Route not serviceable. Reason: ${ie}`,J.data.detail||"");else{j("error");const ke=Pt[xt.current]?.label||"an unknown step";console.log(`❌ [FC-WS-BOOKING][checkpoint] Errored at step ${xt.current+1}/${Pt.length} — "${ke}". Reason: ${ie}`,J.data.detail||"")}}};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[t]),!t)return null;const qt=(U,J=!1)=>
71{if(J&&U!==void 0){const xe=Pt[U];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-400 font-medium",children:[U," of ",Pt.length," steps completed"]}),e.jsxs("div",{className:"flex items-center gap-3 text-base text-red-600 font-bold bg-red-50 rounded-xl px-3 py-2.5",children:[e.jsx(ca,{size:20,className:"text-red-500 flex-shrink-0"}),e.jsx("span",{"aria-hidden":"true",children:xe.emoji}),e.jsx("span",{children:xe.label}),e.jsx("span",{className:"ml-auto text-[10px] font-black uppercase tracking-wider text-red-500 flex-shrink-0",children:"Stuck here"})]})]})}return e.jsx("div",{className:"space-y-3.5",children:Pt.map((xe,ie)=>{const ke=U!==void 0&&ie===U,ma=!ke&&z>ie,ts=!ke&&z===ie;return e.jsxs(W.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.25,delay:Math.min(ie,6)*.03},className:`flex items-center gap-3 text-sm transition-colors duration-300 ${ke?"text-red-600 font-bold":ma?"text-slate-400":ts?"text-slate-900 font-semibold":"text-slate-300"}`,children:[e.jsx("span",{className:"w-5 flex-shrink-0 flex items-center justify-center",children:ke?e.jsx(ca,{size:16,className:"text-red-500"}):ma?e.jsx(Ds,{size:16,className:"text-emerald-500"}):ts?e.jsx(ut,{size:16,className:"animate-spin text-blue-500"}):e.jsx(Tc,{size:16,className:"text-slate-200"})}),e.jsx("span",{"aria-hidden":"true",children:xe.emoji}),e.jsx("span",{children:xe.label}),ke&&e.jsx("span",{className:"ml-auto text-[10px] font-black uppercase tracking-wider text-red-500",children:"Stuck here"})]},xe.message)})})},es=8,pt=R&&f.trim()&&f.trim().length<es?"Looks incomplete — leave blank to use your saved location, or enter the full address":"",le=P.trim()?Nd(P,f,x.fromCity,x.toCity):null,Ue=I?P.trim()?P.trim().length<es?"Delivery address looks incomplete — enter the full address":le||"":"Delivery address is required":"",de=Z?bi(B)||(B?"":"Phone number is required"):"",rt=y==="starting"||y==="vehicle_selecting"||y==="address_filling"||y==="booking_now",Q=()=>{k(!0),M(!0),_(!0);const U=f.trim()&&f.trim().length<es;if(!P.trim()||P.trim().length<es||bi(B)||!B||le||U)return;const J=Sd();Ve.current=J,j("starting"),K("Opening Wheelseye…"),window.postMessage({type:"FC_START_BOOKING",bookingId:J,platform:"wheelseye",from:x.fromPincode,to:x.toPincode,weight:x.weight,tonnage:x.tonnage,pickupAddress:f.trim()||void 0,address:P.trim(),addressTag:"Other",phone:`${B}`,name:ae.trim()||"FreightCompare Customer"},"*")},G=U=>{window.postMessage({type:"FC_WHEELSEYE_ACTION",label:U},"*"),/^accept your truck|^cancel booking/i.test(U)&&Ae(null)},ue=()=>{ot(!0),Ye.current=!0,window.postMessage({type:"FC_CANCEL_SEARCH_BOOKING"},"*"),Ae(null)},$e=()=>{Me(!0),window.postMessage({type:"FC_ACCEPT_FOUND_TRUCK"},"*"),Ae(null)},Je=U=>{const J=Math.floor(U/60),xe=U%60;return`${J}:${xe.toString().padStart(2,"0")}`};return Kt.createPortal(e.jsx(W.div,{initial:{opacity:0}
71,animate:{opacity:1},className:"fixed inset-0 z-[10000] bg-slate-900/40 backdrop-blur-sm flex items-center justify-center p-2",onClick:rt?void 0:l,children:e.jsxs(W.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:`bg-white w-[96vw] ${y==="truck_search"?"max-w-3xl":"max-w-md"} max-h-[90vh] rounded-3xl shadow-2xl overflow-hidden flex flex-col transition-[max-width] duration-200`,onClick:U=>U.stopPropagation(),children:[e.jsxs("div",{className:"bg-slate-900 px-6 py-4 text-white relative flex-shrink-0",children:[!rt&&e.jsx("button",{onClick:l,className:"absolute top-3.5 right-4 text-slate-400 hover:text-white transition-colors",children:e.jsx(Vt,{size:20})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-blue-500/20 p-1.5 rounded-lg flex-shrink-0",children:e.jsx(wo,{className:"text-blue-400",size:20})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold",children:"Book with Wheelseye"}),e.jsxs("p",{className:"text-slate-400 text-xs",children:[r?`${r} · `:"","₹",u," — real booking on your connected account"]})]})]})]}),e.jsxs("div",{className:"p-6 overflow-y-auto flex-1 min-h-0",children:[y==="form"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-slate-500",children:"We'll open your real Wheelseye account and drive the checkout — pickup uses your saved/current location by default, so we just need where this is going and who to reach there."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-black uppercase tracking-widest text-slate-400",children:"Pickup Address (optional)"}),e.jsxs("div",{className:"relative",children:[e.jsx(Jt,{size:14,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none"}),e.jsx("input",{type:"text",maxLength:300,value:f,onChange:U=>{const J=vi(U.target.value);L(J),ki(wi,J)},onBlur:()=>k(!0),placeholder:"Only needed if your account has no saved pickup location",className:`w-full bg-slate-50 border ${pt?"border-red-300":"border-slate-200"} rounded-xl pl-9 pr-3.5 py-2.5 text-sm font-semibold focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all outline-none`})]}),pt?e.jsx("p",{className:"text-xs text-red-600",children:pt}):e.jsx("p",{className:"text-[11px] text-slate-400",children:"Leave blank to use your account's saved or current location — fill it in if Wheelseye ever asks you to type a pickup address manually."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-black uppercase tracking-widest text-slate-400",children:"Delivery Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(Jt,{size:14,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none"}),e.jsx("input",{type:"text",maxLength:300,autoFocus:!0,value:P,onChange:U=>{const J=vi(U.target.value);T(J),ki(Ni,J)},onBlur:()=>M(!0),placeholder:"House/Plot no., Street, Locality, City",className:`w-full bg-slate-50 border ${Ue?"border-red-300":"border-slate-200"} rounded-xl pl-9 pr-3.5 py-2.5 text-sm font-semibold focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all outline-none`})]}),Ue&&e.jsx("p",{className:"text-xs text-red-600",children:Ue})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-black uppercase tracking-widest text-slate-400",children:"Contact Phone"}),e.jsx("input",{type:"text",inputMode:"numeric",maxLength:10,value:B,onChange:U=>H(U.target.value.replace(/\D/g,"").slice(0,10)),onBlur:()=>_(!0),placeholder:"10-digit number",className:`w-full bg-slate-50 border ${de?"border-red-300":"border-slate-200"} rounded-xl px-3.5 py-2.5 text-sm font-semibold focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all outline-none`}),de&&e.jsx("p",{className:"text-xs text-red-600",children:de})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-black uppercase tracking-widest text-slate-400",children:"Contact Name"}),e.jsx("input",{type:"text",maxLength:60,value:ae,onChange:U=>q(U.target.value),placeholder:"Receiver's name",className:"w-full bg-slate-50 border border-slate-200 rounded-xl px-3.5 py-2.5 text-sm font-semibold focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all outline-none"})]})]}),e.jsx("button",{onClick:Q,className:"w-full bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-xl text-sm font-bold shadow-lg shadow-blue-100 transition-all active:scale-95 inline-flex items-center justify-center gap-2",children:"Confirm & Book"})]}),rt&&e.jsxs("div",{className:"flex flex-col gap-4 py-3",children:[e.jsx("p",{className:"text-xs font-bold text-blue-600 text-center tracking-wide",children:"✨ Driving your real Wheelseye checkout…"}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"h-1.5 flex-1 rounded-full bg-slate-100 overflow-hidden",children:e.jsx(W.div,{className:"h-full rounded-full bg-gradient-to-r from-blue-400 to-blue-600",animate:{width:`${Math.max(6,(z+1)/Pt.length*100)}%`},transition:{duration:.4,ease:"easeOut"}})}),e.jsxs("span",{className:"text-[11px] font-bold text-slate-400 tabular-nums flex-shrink-0",children:[Math.max(1,z+1),"/",Pt.length]})]}),qt(),re&&!yi.includes(re)&&e.jsxs("p",{className:"text-xs text-slate-500 text-center italic",children:["🔄 ",re]}),e.jsx("p",{className:"text-xs text-slate-400 text-center pt-1 border-t border-slate-100",children:"🤖 This runs in the background on your Wheelseye account — stay right here, no need to switch tabs."})]}),y==="truck_search"&&S&&e.jsxs("div",{className:"flex flex-col gap-4 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[S.route&&e.jsx("p",{className:"text-base font-bold text-slate-900",children:S.route}),Qe?e.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-black uppercase tracking-wider text-emerald-600 bg-emerald-50 px-2.5 py-1 rounded-full flex-shrink-0",children:[e.jsx(Ds,{size:12})," Booked"]}):e.jsx("span",{className:"text-[11px] font-black uppercase tracking-wider text-slate-400 flex-shrink-0",children:kd[S.phase]})]}),S.phase==="searching"&&e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-2xl bg-gradient-to-br from-blue-600 to-blue-700 text-white p-5 flex flex-col items-center justify-center text-center gap-3 overflow-hidden",children:[e.jsxs("div",{className:"relative w-full h-6",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 border-t-2 border-dashed border-blue-300/50"}),e.jsx(W.div,{className:"absolute top-1/2 -translate-y-1/2",animate:g?{}:{left:["0%","82%"]},transition:{duration:2.2,repeat:1/0,ease:"easeInOut"},style:g?{left:"40%"}:void 0,children:e.jsx(Re,{size:20,className:"text-white drop-shadow"})})]}),e.jsx("p",{className:"text-xs font-semibold text-blue-100 uppercase tracking-wide",children:"Searching for the best truck"}),S.searching?.etaText&&e.jsxs("p",{className:"text-xl font-black",children:["By ",S.searching.etaText]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[S.searching?.priceMin&&S.searching?.priceMax&&e.jsxs("div",{className:"rounded-xl border border-slate-200 p-4",children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-slate-400 mb-2",children:"Estimated price range"}),e.jsxs("div",{className:"flex justify-between text-sm font-bold text-slate-900 mb-2",children:[e.jsxs("span",{children:["₹",S.searching.priceMin]}),e.jsxs("span",{children:["₹",S.searching.priceMax]})]}),e.jsxs("div",{className:"h-2 rounded-full bg-slate-100 overflow-hidden relative",children:[e.jsx("div",{className:"h-full w-1/3 rounded-full bg-gradient-to-r from-blue-400 to-blue-600"}),!g&&e.jsx(W.div,{className:"absolute inset-y-0 left-0 w-8 bg-gradient-to-r from-transparent via-white/60 to-transparent",animate:{left:["-10%","110%"]},transition:{duration:1.6,repeat:1/0,ease:"linear",repeatDelay:.4}})]})]}),(S.searching?.vehicleSpecs||S.searching?.vehicleName)&&e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-slate-200 p-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0",children:e.jsx(Re,{size:18,className:"text-slate-500"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-slate-400",children:"Vehicle type"}),S.searching.vehicleName&&e.jsx("p",{className:"font-bold text-sm text-slate-900 truncate",children:S.searching.vehicleName}),S.searching.vehicleSpecs&&e.jsx("p",{className:"text-xs text-slate-500 truncate",children:S.searching.vehicleSpecs})]})]}),S.searching?.requestedSlot&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-600 px-1",children:[e.jsx(Pr,{size:14,className:"text-slate-400 flex-shrink-0"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-slate-400",children:"Requested loading:"}
71)," ",S.searching.requestedSlot]})]})]})]}),S.phase==="rate_limited"&&e.jsxs("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-5 flex flex-col items-center text-center gap-2.5",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-amber-100 flex items-center justify-center",children:e.jsx(Ac,{className:"text-amber-600",size:22})}),e.jsx("h4",{className:"text-sm font-bold text-slate-900",children:"Wheelseye has temporarily paused this search"}),e.jsx("p",{className:"text-xs text-slate-600 max-w-sm",children:"Their servers are rate-limiting requests right now — this isn't your booking failing, it's Wheelseye slowing things down on their end. It usually clears on its own within a few minutes."}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[S.actions.includes("Refresh")&&e.jsx("button",{onClick:()=>G("Refresh"),className:"px-4 py-2 rounded-xl text-sm font-bold text-white bg-amber-600 hover:bg-amber-700 transition-colors",children:"Refresh"}),e.jsx("button",{onClick:()=>window.postMessage({type:"FC_REVEAL_BOOKING"},"*"),className:"px-4 py-2 rounded-xl text-sm font-bold text-slate-700 bg-white border border-amber-200 hover:bg-amber-100/50 transition-colors",children:"Open Wheelseye tab"})]})]}),S.phase==="not_found"&&e.jsxs("div",{className:"rounded-2xl border border-red-200 bg-red-50 p-5 flex flex-col items-center text-center gap-2.5",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 flex items-center justify-center",children:e.jsx(Re,{className:"text-red-500",size:22})}),e.jsx("h4",{className:"text-sm font-bold text-slate-900",children:"Truck not found"}),e.jsx("p",{className:"text-xs text-slate-600 max-w-sm",children:"Apologies for the inconvenience — Wheelseye couldn't match a truck this time. It's retrying automatically."}),(S.notFound?.vehicleSpecs||S.notFound?.vehicleName)&&e.jsxs("div",{className:"w-full flex items-center gap-3 rounded-xl border border-red-100 bg-white p-3 text-left",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0",children:e.jsx(Re,{size:18,className:"text-slate-500"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-slate-400",children:"Vehicle type"}),S.notFound.vehicleName&&e.jsx("p",{className:"font-bold text-sm text-slate-900 truncate",children:S.notFound.vehicleName}),S.notFound.vehicleSpecs&&e.jsx("p",{className:"text-xs text-slate-500 truncate",children:S.notFound.vehicleSpecs})]})]}),S.notFound?.requestedSlot&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-600",children:[e.jsx(Pr,{size:14,className:"text-slate-400 flex-shrink-0"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-slate-400",children:"Requested loading:"})," ",S.notFound.requestedSlot]})]}),e.jsx("div",{className:"flex gap-2 mt-1",children:S.actions.includes("Try again")&&e.jsx("button",{onClick:()=>G("Try again"),className:"px-4 py-2 rounded-xl text-sm font-bold text-white bg-red-600 hover:bg-red-700 transition-colors",children:"Try Again"})})]}),S.phase==="found"&&e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[Be!==null&&e.jsxs("div",{className:`rounded-2xl bg-gradient-to-br from-emerald-600 to-emerald-700 text-white p-5 text-center space-y-1 ${Be<=60&&!g?"animate-pulse":""}`,children:[e.jsx("p",{className:"text-xs font-semibold text-emerald-100 uppercase tracking-wide",children:"Truck on hold"}),e.jsx("p",{className:`text-3xl font-black tabular-nums ${Be<=60?"text-amber-200":""}`,children:Je(Be)}),e.jsx("p",{className:"text-xs text-emerald-100",children:"Confirm soon to lock this price"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:$e,disabled:De,className:"flex-1 bg-emerald-600 hover:bg-emerald-700 text-white px-4 py-3.5 rounded-xl text-sm font-bold transition-colors shadow-lg shadow-emerald-100 disabled:opacity-60 disabled:cursor-not-allowed inline-flex items-center justify-center gap-2",children:[De&&e.jsx(ut,{size:16,className:"animate-spin"}),De?"Accepting…":"Accept your truck"]}),e.jsx("button",{onClick:()=>G("Cancel booking"),disabled:De,className:"px-4 py-3.5 rounded-xl text-sm font-bold text-red-600 bg-red-50 hover:bg-red-100 transition-colors disabled:opacity-60 disabled:cursor-not-allowed",children:"Decline"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[S.found?.foundPrice&&e.jsxs("div",{className:"rounded-xl bg-emerald-50 border border-emerald-100 p-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-emerald-600 font-bold uppercase tracking-wide",children:"Truck foun
71d at"}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-2xl font-black text-emerald-700",children:["₹",S.found.foundPrice]}),S.found.originalPrice&&e.jsxs("span",{className:"text-sm text-slate-400 line-through",children:["₹",S.found.originalPrice]})]}),S.found.savedAmount&&e.jsxs("p",{className:"text-xs font-bold text-emerald-600 mt-0.5",children:["You saved ₹",S.found.savedAmount," (",S.found.savedPercent,"%)"]})]}),e.jsx(It,{size:22,className:"text-emerald-400 flex-shrink-0"})]}),S.found?.vehiclePlate&&e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-slate-200 p-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0",children:e.jsx(Re,{size:18,className:"text-slate-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-bold text-sm text-slate-900",children:S.found.vehiclePlate}),S.found.vehicleRating&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs font-bold text-amber-500",children:[e.jsx(ws,{size:11,fill:"currentColor"})," ",S.found.vehicleRating]})]}),e.jsx("p",{className:"text-xs text-slate-500 truncate",children:S.found.vehicleSpecs})]})]}),S.found?.requestedSlot&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-600",children:[e.jsx(Pr,{size:14,className:"text-slate-400 flex-shrink-0"}),e.jsx("span",{children:S.found.requestedSlot})]})]})]}),S.phase==="tracking"&&e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"rounded-2xl bg-gradient-to-br from-emerald-600 to-emerald-700 text-white p-4 flex items-center gap-3",children:[e.jsx(Ds,{size:22,className:"flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-sm",children:"Truck confirmed"}),e.jsx("p",{className:"text-xs text-emerald-100",children:"Your driver is on the way"})]})]}),S.tracking?.arrivalEstimate&&e.jsxs("div",{className:"rounded-xl border border-slate-200 p-3.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-slate-400 font-bold uppercase tracking-wide",children:"Arrival estimate"}),e.jsx("p",{className:"font-bold text-sm text-slate-900",children:S.tracking.arrivalEstimate})]}),S.tracking.arrivalStatus&&e.jsx("span",{className:"text-[11px] font-bold text-emerald-600 bg-emerald-50 px-2 py-1 rounded-full flex-shrink-0",children:S.tracking.arrivalStatus})]}),S.tracking?.vehicleDistanceText&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-600",children:[e.jsx(Re,{size:14,className:"text-slate-400 flex-shrink-0"}),e.jsxs("span",{children:["Vehicle ",S.tracking.vehicleDistanceText," away"]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[S.tracking?.weatherNote&&e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-3 flex gap-2.5 items-start",children:[e.jsx(Pc,{size:16,className:"text-blue-500 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-blue-700 leading-snug",children:S.tracking.weatherNote})]}),S.tracking?.locationLine&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-slate-600",children:[e.jsx(Jt,{size:14,className:"text-slate-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"leading-snug",children:S.tracking.locationLine}),S.tracking.locationTime&&e.jsx("p",{className:"text-slate-400 mt-0.5",children:S.tracking.locationTime})]})]}),S.actions.includes("Call Driver")&&e.jsxs("button",{onClick:()=>G("Call Driver"),className:"flex items-center justify-center gap-2 border border-emerald-200 text-emerald-700 bg-emerald-50 hover:bg-emerald-100 px-4 py-2.5 rounded-xl text-sm font-bold transition-colors",children:[e.jsx(No,{size:15})," Call Driver"]})]})]}),S.actions.filter(U=>!/^accept your truck|^cancel booking|^call driver/i.test(U)||S.phase!=="found").filter(U=>!(S.phase==="tracking"&&/^call driver/i.test(U))).filter(U=>!(S.phase==="not_found"&&/^try again/i.test(U))).length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:S.actions.filter(U=>!(S.phase==="found"&&/^accept your truck|^cancel booking/i.test(U))).filter(U=>!(S.phase==="tracking"&&/^call driver/i.test(U))).filter(U=>!(S.phase==="not_found"&&/^try again/i.test(U))).map(U=>{const J=/^cancel booking/i.test(U);return e.jsxs("button",{onClick:()=>J?ue():G(U),disabled:J&&at,className:"px-3.5 py-2 rounded-lg text-xs font-bold text-blue-700 bg-blue-50 hover:bg-blue-100 transition-colors disabled:opacity-60 disabled:cursor-not-allowed inline-flex items-center gap-1.5",children:[J&&at&&e.jsx(ut,{size:12,className:"animate-spin"}),J&&at?"Cancelling…":U]},U)})}),(()=>{const U=/insur|coverage|^(cancel booking|view order details|view pricing)$/i,J=S.rows.filter(ie=>ie.value.trim()&&!U.test(ie.label.trim())),xe=S.notes.filter(ie=>!U.test(ie.trim()));return!J.length&&!xe.length?null:e.jsxs("div",{className:"border-t border-slate-100 pt-3",children:[S.phase!=="details"&&e.jsxs("button",{onClick:()=>Te(ie=>!ie),className:"flex items-center gap-1.5 text-xs font-bold text-blue-600 hover:text-blue-700",children:[E?"Hide":"Show"," freight & trip details",e.jsx(_s,{size:14,className:`transition-transform ${E?"rotate-180":""}`})]}),(E||S.phase==="details")&&e.jsxs("div",{className:"mt-3 space-y-3",children:[J.length>0&&e.jsx("div",{className:"rounded-xl border border-slate-200 overflow-hidden",children:e.jsx("table",{className:"w-full text-xs border-collapse",children:e.jsx("tbody",{children:J.map((ie,ke)=>e.jsxs("tr",{className:ke%2===1?"bg-slate-50":"bg-white",children:[e.jsx("td",{className:"px-3.5 py-2 text-slate-500 border-b border-slate-100 last:border-b-0 w-1/2 align-top",children:ie.label}),e.jsx("td",{className:"px-3.5 py-2 font-semibold text-slate-900 text-right border-b border-slate-100 last:border-b-0 align-top",children:ie.value})]},ke))})})}),xe.length>0&&e.jsx("div",{className:"space-y-1",children:xe.map((ie,ke)=>e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:ie},ke))})]})]})})(),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-slate-100",children:[e.jsxs("p",{className:"text-[11px] text-slate-400 flex items-center gap-1.5",children:[e.jsxs("span",{className:"relative flex h-2 w-2 flex-shrink-0",children:[!g&&e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]}),"Live from your Wheelseye account — updates automatically."]}),e.jsx("button",{onClick:l,className:"text-xs font-semibold text-slate-400 hover:text-slate-600 flex-shrink-0",children:"Close"})]})]}),y==="needs_attention"&&e.jsxs("div",{className:"flex flex-col items-center text-center gap-2.5 py-2",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-amber-50 border-4 border-amber-100 flex items-center justify-center",children:e.jsx(ca,{className:"text-amber-500",size:20})}),e.jsx("h4",{className:"text-base font-bold text-slate-900",children:"Almost there"}),e.jsx("p",{className:"text-xs text-slate-500",children:"We got you most of the way there but hit a step we don't automate yet. Nothing's lost — the draft is still sitting there on your account if you'd rather finish it yourself."}),e.jsx("div",{className:"w-full text-left bg-slate-50 rounded-xl p-3.5 my-1",children:qt(z,!0)}),e.jsxs("p",{className:"text-xs text-slate-600 font-semibold",children:["Reason: ",re]}),X&&e.jsxs("div",{className:"w-full bg-slate-50 border border-slate-200 rounded-xl p-3 flex items-center gap-2 text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 flex-1 break-words",children:X}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(X).then(()=>{He(!0),setTimeout(()=>He(!1),2e3)})},className:"flex-shrink-0 p-2 rounded-lg text-slate-500 hover:bg-slate-200 transition-colors",title:"Copy address",children:st?e.jsx(Va,{size:16,className:"text-emerald-500"}):e.jsx(ac,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 mt-1",children:[e.jsx("button",{onClick:()=>{X&&navigator.clipboard.writeText(X).catch(()=>{}),window.postMessage({type:"FC_REVEAL_BOOKING"},"*")},className:"px-4 py-2 rounded-xl text-sm font-bold text-white bg-blue-600 hover:bg-blue-700 transition-colors",children:X?"Copy address & open Wheelseye":"Open Wheelseye to finish it"}),e.jsx("button",{onClick:()=>j("form"),className:"px-4 py-2 rounded-xl text-sm font-bold text-slate-700 bg-slate-100 hover:bg-slate-200 transition-colors",children:"Edit & Try Again"}),e.jsx("button",{onClick:()=>c?c():l(),className:"px-4 py-2 rounded-xl text-sm font-semibold text-slate-500 hover:bg-slate-50 transition-colors",children:"Got it"})]})]}),y==="error"&&e.jsxs("div",{className:"flex flex-col items-center text-center gap-2.5 py-2",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-red-50 border-4 border-red-100 flex items-center justify-center",children:e.jsx(ca,{className:"text-red-500",size:20})}),e.jsx("h4",{className:"text-base font-bold text-slate-900",children:"Couldn't complete this"}),e.jsx("div",{className:"w-full text-left bg-slate-50 rounded-xl p-3.5 my-1",children:qt(z,!0)}),e.jsx("p",{className:"text-sm text-slate-500",children:re}),e.jsx("button",{onClick:()=>j("form"),className:"mt-2 px-6 py-2 rounded-xl text-sm font-bold text-white bg-blue-600 hover:bg-blue-700 transition-colors",children:"Try Again"})]}),y==="not_serviceable"&&e.jsxs("div",{className:"flex flex-col items-center text-center gap-3 py-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-blue-50 border-4 border-blue-100 flex items-center justify-center",children:e.jsx(Gr,{className:"text-blue-500",size:20})}),e.jsx("h4",{className:"text-base font-bold text-slate-900",children:"Route not available on Wheelseye"}),e.jsx("p",{className:"text-sm text-slate-500 max-w-xs",children:"Wheelseye doesn't cover this pickup–drop combination right now. Try a different pincode, or book with another vendor."}),e.jsx("button",{onClick:()=>c?c():j("form"),className:"mt-2 px-6 py-2 rounded-xl text-sm font-bold text-white bg-blue-600 hover:bg-blue-700 transition-colors",children:"Try a Different Route"}),e.jsx("button",{onClick:l,className:"px-4 py-2 rounded-xl text-sm font-semibold text-slate-500 hover:bg-slate-50 transition-colors",children:"Close"})]})]})]})}),document.body)}const Ci=[{kind:"math",question:"7 × 8 = ?",answer:56,hint:"Think 7 × 8…"},{kind:"math",question:"23 + 19 = ?",answer:42,hint:"Add the tens, then units"},{kind:"math",question:"100 ÷ 4 = ?",answer:25,hint:"Quarter of 100"},{kind:"math",question:"15% of 200 = ?",answer:30,hint:"10% + 5% of 200"},{kind:"math",question:"Square root of 144?",answer:12,hint:"12 × 12 = ?"},{kind:"math",question:"6 parcels cost ₹72 total. Cost per parcel?",answer:12,hint:"72 ÷ 6"},{kind:"math",question:"12 × 5 = ?",answer:60,hint:"Think dozen × 5"},{kind:"math",question:"81 ÷ 9 = ?",answer:9,hint:"9 × 9 = ?"},{kind:"math",question:"3 boxes each weigh 8 kg. Total weight?",answer:24,hint:"3 × 8"},{kind:"math",question:"50 + 37 = ?",answer:87,hint:"Add tens then units"},{kind:"math",question:"200 − 64 = ?",answer:136,hint:"200 − 60 − 4"},{kind:"math",question:"9 × 9 = ?",answer:81,hint:"Classic times table"},{kind:"math",question:"How many hours in 3 days?",answer:72,hint:"24 × 3"},{kind:"math",question:"40% of 50 = ?",answer:20,hint:"Half of 40"},{kind:"math",question:"A box is 2 m long, 1 m wide, 1 m tall. Volume in m³?",answer:2,hint:"L × W × H"}],Si=[{kind:"mcq",question:"What do you usually ship?",options:["Electronics","Clothing & Textiles","Documents","Pharmaceuticals","Industrial Parts","FMCG / Food"],prefKey:"shipmentCategory",icon:Dt},{kind:"mcq",question:"How often do you compare shipping rates?",options:["Daily","A few times a week","Weekly","Monthly","Occasionally"],prefKey:"c
71ompareFrequency",icon:Lr},{kind:"mcq",question:"What matters most when picking a courier?",options:["Lowest price","Fastest delivery","Reliability / tracking","Weight limits","Pickup availability"],prefKey:"topPriority",icon:It},{kind:"mcq",question:"How many shipments do you send per month?",options:["1–10","11–50","51–200","201–500","500+"],prefKey:"monthlyVolume",icon:Ns},{kind:"mcq",question:"Which best describes your business?",options:["E-commerce seller","Manufacturer / Exporter","Logistics provider","Retail chain","Freelancer / Individual"],prefKey:"businessType",icon:Lr},{kind:"mcq",question:"Which region do you ship to most?",options:["Within same state","North India","South India","East India","West India","Pan India"],prefKey:"primaryRegion",icon:It},{kind:"mcq",question:"What's your typical shipment weight?",options:["Under 1 kg","1–5 kg","5–20 kg","20–100 kg","100 kg+"],prefKey:"typicalWeight",icon:Dt},{kind:"mcq",question:"How do you usually book shipments?",options:["Directly with courier","Through aggregator/platform","Our own logistics team","Third-party 3PL"],prefKey:"bookingMethod",icon:Lr}],Pd=t=>t[Math.floor(Math.random()*t.length)],al=()=>{try{return JSON.parse(localStorage.getItem("fcUserPrefs")||"{}")}catch{return{}}},Ld=(t,l)=>{const c=al();c[t]=l,localStorage.setItem("fcUserPrefs",JSON.stringify(c))},rl=()=>parseInt(sessionStorage.getItem("fcSearchCount")||"0",10),Id=()=>{const t=rl()+1;return sessionStorage.setItem("fcSearchCount",String(t)),t},Ed=()=>{const t=rl();return t>0&&t%5===0},Fd=(t,l)=>l||t<2?!1:!localStorage.getItem("fcPreferredVendorNudgeShown"),Rd=()=>{localStorage.setItem("fcPreferredVendorNudgeShown","true")};let Ti=-1,Pi="";const Md=()=>{const t=Ci.map((c,r)=>r).filter(c=>c!==Ti),l=t[Math.floor(Math.random()*t.length)];return Ti=l,Ci[l]},Ad=t=>{const l=t.filter(r=>r.prefKey!==Pi),c=Pd(l.length>0?l:t);return Pi=c.prefKey,c},_d=t=>{const{onPass:l,onClose:c}=t,[r,u]=n.useState(null),[x,b]=n.useState(""),[h,g]=n.useState(null),[y,j]=n.useState("idle"),f=n.useRef(null);n.useEffect(()=>{if(t.ownVendors&&t.ownVendors.length>0&&!t.hasPreferredVendor){u({kind:"preferred-vendor-pick",question:"Which of your vendors do you use most often?"});return}const I=al(),M=Si.filter(H=>!I[H.prefKey]),B=M.length>0?M:Si;Math.random()>.35?u(Ad(B)):u(Md())},[]),n.useEffect(()=>{r?.kind==="math"&&setTimeout(()=>f.current?.focus(),300)},[r]);const L=n.useCallback(()=>{!r||r.kind!=="math"||(parseInt(x,10)===r.answer?(j("pass"),setTimeout(l,900)):(j("wrong"),setTimeout(()=>j("idle"),1200),b("")))},[r,x,l]),R=n.useCallback(()=>{!r||r.kind!=="mcq"||!h||(Ld(r.prefKey,h),j("pass"),setTimeout(l,800))},[r,h,l]),k=n.useCallback(()=>{if(!r||r.kind!=="preferred-vendor-pick"||!h)return;const I=(t.ownVendors||[]).find(M=>M.vendorId===h);I&&t.onPreferredVendorPicked?.(I.vendorId,I.companyName,I.source),Rd(),j("pass"),setTimeout(l,800)},[r,h,t,l]),P=n.useCallback(()=>{r?.kind==="preferred-vendor-pick"?l():c()},[r,l,c]);if(!r)return null;const T=r.kind==="mcq"?r.icon:Ns;return e.jsx(kt,{children:e.jsx(W.div,{initial:{opacity:0}
71,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[100] flex items-center justify-center p-4",style:{background:"rgba(2, 6, 23, 0.85)",backdropFilter:"blur(12px)"},children:e.jsxs(W.div,{initial:{opacity:0,scale:.92,y:24},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},transition:{duration:.35,ease:[.16,1,.3,1]},className:"relative w-full max-w-md bg-slate-900 border border-white/10 rounded-2xl shadow-2xl overflow-hidden",children:[e.jsx("div",{className:"h-0.5 w-full bg-gradient-to-r from-transparent via-yellow-400 to-transparent"}),e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-4 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-yellow-400/10 border border-yellow-400/20 rounded-xl",children:e.jsx(T,{className:"w-5 h-5 text-yellow-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold text-yellow-400 uppercase tracking-widest",children:r.kind==="math"?"Quick Check":"One quick question"}),e.jsx("p",{className:"text-xs text-white/40 mt-0.5",children:r.kind==="math"?"Just proving you're human 🙂":"Your answer helps us improve FreightCompare"})]})]}),e.jsx("button",{onClick:P,className:"p-1.5 rounded-lg text-white/30 hover:text-white hover:bg-white/5 transition-all",children:e.jsx(Vt,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"px-6 py-6",children:[e.jsx("p",{className:"text-white font-semibold text-base mb-5 leading-snug",children:r.question}),r.kind==="math"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`flex items-center gap-2 bg-white/5 border rounded-xl px-4 py-3 transition-all ${y==="wrong"?"border-red-500/60 bg-red-500/5":"border-white/10 focus-within:border-yellow-400/50"}`,children:[e.jsx("input",{ref:f,type:"number",value:x,onChange:I=>b(I.target.value),onKeyDown:I=>I.key==="Enter"&&L(),placeholder:"Your answer…",className:"flex-1 bg-transparent text-white text-sm font-bold outline-none placeholder:text-white/20"}),y==="wrong"&&e.jsx(Xt,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y==="pass"&&e.jsx(za,{className:"w-4 h-4 text-green-400 flex-shrink-0"})]}),y==="wrong"&&e.jsxs("p",{className:"text-red-400 text-xs font-medium",children:["Not quite — try again! ",r.hint&&e.jsxs("span",{className:"text-white/30",children:["(",r.hint,")"]})]})]}),r.kind==="mcq"&&e.jsx("div",{className:"grid grid-cols-1 gap-2",children:r.options.map(I=>e.jsx(W.button,{whileHover:{x:3},whileTap:{scale:.98},onClick:()=>g(I),className:`w-full text-left px-4 py-2.5 rounded-xl border text-sm font-medium transition-all duration-200 ${h===I?"bg-yellow-400/15 border-yellow-400/70 text-yellow-300":"bg-white/3 border-white/8 text-white/70 hover:bg-white/8 hover:border-white/20 hover:text-white"}`,children:e.jsxs("span",{className:"flex items-center gap-2",children:[h===I&&e.jsx(za,{className:"w-3.5 h-3.5 text-yellow-400 flex-shrink-0"}),I]})},I))}),r.kind==="preferred-vendor-pick"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"grid grid-cols-1 gap-2 max-h-64 overflow-y-auto",children:(t.ownVendors||[]).map(I=>e.jsx(W.button,{whileHover:{x:3},whileTap:{scale:.98},onClick:()=>g(I.vendorId),className:`w-full text-left px-4 py-2.5 rounded-xl border text-sm font-medium transition-all duration-200 ${h===I.vendorId?"bg-yellow-400/15 border-yellow-400/70 text-yellow-300":"bg-white/3 border-white/8 text-white/70 hover:bg-white/8 hover:border-white/20 hover:text-white"}`,children:I.companyName},I.vendorId))}),e.jsx("button",{type:"button",onClick:()=>{c(),window.location.assign("/addvendor")},className:"text-xs text-white/40 hover:text-white/70 underline",children:"Not in this list? Add a vendor →"})]})]}),e.jsx("div",{className:"px-6 pb-6",children:y==="pass"?e.jsxs(W.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"flex items-center justify-center gap-2 py-3 bg-green-500/20 border border-green-500/30 rounded-xl",children:[e.jsx(za,{className:"w-4 h-4 text-green-400"}),e.jsx("span",{className:"text-green-400 text-sm font-semibold",children:r.kind==="mcq"?"Thanks! Loading your results…":"Correct! Loading results…"})]}):e.jsx(W.button,{whileHover:{scale:1.02},whileTap:{scale:.97},onClick:r.kind==="math"?L:r.kind==="mcq"?R:k,disabled:(r.kind==="mcq"||r.kind==="preferred-vendor-pick")&&!h,className:`w-full py-3 rounded-xl text-sm font-extrabold tracking-wide transition-all ${(r.kind==="mcq"||r.kind==="preferred-vendor-pick")&&!h?"bg-white/5 text-white/20 cursor-not-allowed":"bg-yellow-400 hover:bg-yellow-300 text-slate-900 shadow-lg hover:shadow-yellow-400/30"}`,children:r.kind==="math"?"Submit Answer →":"Continue →"})}),e.jsx("div",{className:"px-6 pb-4 text-center",children:e.jsx("p",{className:"text-white/20 text-[10px]",children:r.kind==="mcq"?"Your answer is anonymous and helps personalise your experience.":"This check appears occasionally to keep results accurate."})})]},"captcha-card")},"captcha-backdrop")})},Li=["copy","cut","paste","contextmenu","selectstart","dragstart"],$d=t=>{const l=t.ctrlKey||t.metaKey,c=t.shiftKey;return!!(l&&["c","x","v","a","p","s"].includes(t.key.toLowerCase())||l&&t.key==="Insert"||c&&t.key==="Insert"||c&&t.key==="Delete"||c&&t.key==="F10"||t.key==="ContextMenu")},Dd=t=>{const l=t.ctrlKey||t.metaKey,c=t.shiftKey,r=t.altKey;return!!(t.key==="F12"||l&&c&&["i","j","c"].includes(t.key.toLowerCase())||l&&r&&["i","j"].includes(t.key.toLowerCase())||t.metaKey&&c&&t.key.toLowerCase()==="c")},Ii=t=>!!(t.key==="PrintScreen"||t.key==="F13"||t.metaKey&&t.shiftKey&&["s"].includes(t.key.toLowerCase())||t.metaKey&&t.shiftKey&&["3","4","5"].includes(t.key)),Ra=(t,l)=>
71{Lt.post("/api/security/event",{route:"/compare",eventType:t,timestamp:new Date().toISOString(),userAgent:navigator.userAgent,...l}).catch(()=>{})};let Ei=0;const Fr=()=>{const t=Date.now();t-Ei<2e3||(Ei=t,Ui("Copying is disabled for results",{id:"secure-zone-blocked",duration:2e3,style:{fontSize:"13px"}}))};function Vd({active:t,watermarkLabel:l,children:c}){const r=n.useRef(null),u=n.useRef(null),x=n.useRef(null),b=n.useRef(null);n.useEffect(()=>{const g=document.createElement("div");return g.setAttribute("data-secure-overlay","1"),g.style.cssText=["position:fixed","inset:0","z-index:2147483647","background:#ffffff","opacity:0","pointer-events:none","will-change:opacity","transition:none"].join(";"),document.body.appendChild(g),x.current=g,()=>{g.remove(),x.current=null}},[]),n.useEffect(()=>(t?document.body.classList.add("compare-print-protected"):document.body.classList.remove("compare-print-protected"),()=>document.body.classList.remove("compare-print-protected")),[t]),n.useEffect(()=>{if(!t)return;const g=r.current;if(!g)return;const y=()=>x.current?.style.opacity==="1",j=()=>{x.current&&(x.current.style.opacity="1"),g.classList.add("prtsc-blanked")},f=()=>{x.current&&(x.current.style.opacity="0"),g.classList.remove("prtsc-blanked")},L=()=>{f(),u.current&&(clearTimeout(u.current),u.current=null)},R=(_,ae=1200)=>{j(),Ra(_),u.current&&clearTimeout(u.current),u.current=setTimeout(L,ae)},k=_=>{Ii(_)&&(_.preventDefault(),R("screenshot_keydown",1500))},P=_=>{Ii(_)&&R("screenshot_keyup",1500)},T=()=>R("screenshot_blur",1200),I=()=>{u.current||L()},M=()=>{document.visibilityState==="hidden"&&R("screenshot_visibility",2e3)},B=_=>{g.contains(_.target)&&(_.preventDefault(),_.stopPropagation(),Fr(),Ra(`blocked_${_.type}`))},H=_=>{const ae=_.ctrlKey||_.metaKey,q=_.key.toLowerCase();if(ae&&q==="s"){_.preventDefault(),_.stopPropagation(),R("blocked_save",3e3),Fr();return}if(!(!g.contains(document.activeElement)&&!g.matches(":focus-within")&&!(ae&&q==="p"))){if($d(_)){_.preventDefault(),_.stopPropagation(),Fr(),Ra(`blocked_keyboard_${q}`);return}Dd(_)&&(_.preventDefault(),Ra("blocked_devtools"))}};document.addEventListener("keydown",k,!0),document.addEventListener("keyup",P,!0),Li.forEach(_=>document.addEventListener(_,B,!0)),document.addEventListener("keydown",H,!0),window.addEventListener("blur",T),window.addEventListener("focus",I),document.addEventListener("visibilitychange",M);const Z=()=>{const _=document.hasFocus();!_&&!y()?R("focus_lost_raf"):_&&y()&&!u.current&&f(),b.current=requestAnimationFrame(Z)};return b.current=requestAnimationFrame(Z),document.hasFocus()||j(),()=>{b.current!==null&&cancelAnimationFrame(b.current),document.removeEventListener("keydown",k,!0),document.removeEventListener("keyup",P,!0),Li.forEach(_=>document.removeEventListener(_,B,!0)),document.removeEventListener("keydown",H,!0),window.removeEventListener("blur",T),window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",M),u.current&&clearTimeout(u.current),f()}},[t]);const h=l?(()=>{const g=l.split(" · ");return g.length>=2?`<svg xmlns="http://www.w3.org/2000/svg" width="340" height="130"><text x="170" y="58" text-anchor="middle" font-family="sans-serif" font-size="13" font-weight="700" fill="rgba(0,0,0,0.12)">${g[0]}</text><text x="170" y="76" text-anchor="middle" font-family="sans-serif" font-size="11" font-weight="600" fill="rgba(0,0,0,0.10)">${g[1]}</text></svg>`:`<svg xmlns="http://www.w3.org/2000/svg" width="340" height="130"><text x="170" y="72" text-anchor="middle" font-family="sans-serif" font-size="13" font-weight="600" fill="rgba(0,0,0,0.09)">${l}</text></svg>`})():null;return e.jsx("div",{ref:r,className:"secure-results-zone",style:{position:"relative",userSelect:t?"none":void 0,WebkitUserSelect:t?"none":void 0,...t&&h?{"--wm-svg":`url("data:image/svg+xml,${encodeURIComponent(h)}")`}:{}},onDragStart:g=>{t&&(g.preventDefault(),g.stopPropagation())},children:c})}const zd=(t,l)=>{const c=["fromPincode","toPincode","invoiceValue"];for(let r=0;r<l;r++)c.push(`preset-${r}`),t==="Heavy"?(c.push(`count-${r}`),c.push(`weight-${r}`)):(c.push(`length-${r}`),c.push(`width-${r}`),c.push(`height-${r}`),c.push(`count-${r}`),c.push(`weight-${r}`));return c.push("add-box-button"),c.push("calculate-button"),c.filter(r=>document.getElementById(r)!==null)},Ma=t=>document.getElementById(t),la=t=>t.tagName==="INPUT",Od=t=>t.tagName==="BUTTON";function Bd({containerRef:t,shipmentType:l,boxCount:c,onAddBox:r,onCalculate:u}){const x=n.useRef(0),b=n.useRef(""),h=750,g=n.useCallback(()=>zd(l,c),[l,c]),y=n.useCallback(k=>g().indexOf(k),[g]),j=n.useCallback(k=>{const P=g(),T=y(k);if(T===-1)return;if((B=>{const H=B.match(/^(weight|count)-(\d+)$/);if(!H)return!1;const[,Z,_]=H,ae=parseInt(_,10);return Z==="weight"?ae===c-1:!1})(k)){const B=T+1;if(P[B]==="add-box-button"){r(),setTimeout(()=>{const Z=Ma(`preset-${c}`);Z&&(Z.focus(),la(Z)&&Z.select())},50);return}}const M=T+1;if(M<P.length){const B=P[M],H=Ma(B);H&&(H.focus(),la(H)&&H.select())}},[g,y,l,c,r]),f=n.useCallback(k=>{const P=g(),T=y(k);if(T<=0)return;const I=T-1,M=P[I],B=Ma(M);B&&(B.focus(),la(B)&&B.select())},[g,y]),L=n.useCallback((k,P)=>{const T=Date.now();return P?b.current===k&&T-x.current<h?(x.current=0,b.current="",!0):(x.current=T,b.current=k,!1):(x.current=0,b.current="",!1)},[]),R=n.useCallback(k=>{const P=k.target,T=P.id;if(!(!T||!g().includes(T)))switch(k.key){case"Tab":k.shiftKey?(k.preventDefault(),f(T)):(k.preventDefault(),j(T));break;case"Enter":if(k.preventDefault(),Od(P)){T==="add-box-button"?(r(),setTimeout(()=>{const M=Ma(`preset-${c}`);M&&(M.focus(),la(M)&&M.select())},50)):T==="calculate-button"&&u();return}j(T);break;case"Backspace":if(la(P)){const M=P.value==="";L(T,M)&&(k.preventDefault(),f(T))}break}},[g,j,f,L,r,u,c]);return n.useEffect(()=>{const k=t.current;if(k)return k.addEventListener("keydown",R),()=>{k.removeEventListener("keydown",R)}},[t,R]),{focusNextField:j,focusPreviousField:f,getFieldOrder:g}}const Wd=2e4,Kr=({value:t,prefix:l="",suffix:c="",decimals:r=0})=>{const u=Ua(),[x,b]=n.useState(t),h=n.useRef(t);return n.useEffect(()=>{if(u){b(t),h.current=t;return}const g=h.current,y=t;if(g===y)return;const j=700,f=performance.now();let L=0;const R=k=>{const P=Math.min(1,(k-f)/j),T=1-Math.pow(1-P,3);b(g+(y-g)*T),P<1?L=requestAnimationFrame(R):h.current=y};return L=requestAnimationFrame(R),()=>cancelAnimationFrame(L)}
71,[t,u]),e.jsxs(e.Fragment,{children:[l,x.toLocaleString("en-IN",{maximumFractionDigits:r,minimumFractionDigits:r}),c]})},Fi=({icon:t,label:l,amount:c,percent:r,tone:u,isWin:x})=>{const b=c>0,h=u==="amber"?{box:"bg-amber-50 border-amber-200",text:"text-amber-700",textDim:"text-amber-600"}:{box:"bg-emerald-50 border-emerald-200",text:"text-emerald-700",textDim:"text-emerald-600"};return e.jsxs("div",{className:`flex-1 min-w-0 rounded-xl border px-3.5 py-3 ${h.box}`,children:[e.jsxs("div",{className:`flex items-start gap-1.5 text-[10px] font-bold uppercase tracking-widest mb-1.5 leading-tight ${h.text}`,children:[e.jsx("span",{className:"mt-px shrink-0",children:t}),e.jsx("span",{children:l})]}),b?e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:`text-xl font-black tracking-tight ${h.text}`,children:e.jsx(Kr,{value:c,prefix:"₹"})}),e.jsxs("span",{className:`text-xs font-bold ${h.textDim}`,children:["(",e.jsx(Kr,{value:r,decimals:1,suffix:"%"}),") ",x?"saved":"lost"]})]}):e.jsxs("div",{className:`flex items-center gap-1 font-bold text-sm ${h.text}`,children:[e.jsx(Ds,{size:14,className:"shrink-0"})," Winning here"]})]})};function Kd({isTransporter:t,isAdmin:l,refreshSignal:c}){const r=Ua(),{updateUser:u}=Ka(),[x,b]=n.useState(null),[h,g]=n.useState(null),[y,j]=n.useState(!1),[f,L]=n.useState(!1),R=!t&&!l,k=h?.bookNowClicks??0,P=h?.mode==="stats"?h.totalSaved:0,T=async()=>{const[ne,S]=await Promise.all([Gn(),Yn()]);ne&&b(ne),S&&g(S)};n.useEffect(()=>{if(!R)return;let ne=!1;const S=async()=>{const[Qe,lt]=await Promise.all([Gn(),Yn()]);ne||(Qe&&b(Qe),lt&&g(lt))};S();const Se=setInterval(S,Wd);return()=>{ne=!0,clearInterval(Se)}},[R,c]);const I=async(ne,S,Se)=>{if(!f){L(!0);try{if(!await Hi(ne,S,Se))throw new Error("Switch failed");u({preferredVendor:{vendorId:ne,companyName:S,source:Se}}),me.success(`Switched to ${S} as your preferred vendor`),await T()}catch(Qe){console.error("[SavingsWidget] switch vendor failed:",Qe),me.error("Failed to switch preferred vendor")}finally{L(!1)}}};if(!R||!x)return null;if(x.mode==="noData")return e.jsxs(W.div,{initial:r?void 0:{opacity:0,y:10},animate:r?void 0:{opacity:1,y:0},transition:{duration:.4,ease:[.16,1,.3,1]},className:"w-full mt-3 rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-5 py-4 text-center",children:[e.jsx(fc,{size:20,className:"mx-auto mb-1.5 text-slate-300"}),e.jsx("p",{className:"text-sm font-semibold text-slate-500",children:"Set a preferred vendor to start tracking savings"}),e.jsx($s,{to:"/my-vendors",className:"text-xs font-bold text-blue-600 hover:text-blue-700 hover:underline mt-1 inline-block",children:"Choose a Preferred Vendor →"})]});if(x.mode==="noSearchYet")return e.jsxs(W.div,{initial:r?void 0:{opacity:0,y:10},animate:r?void 0:{opacity:1,y:0},transition:{duration:.4,ease:[.16,1,.3,1]},className:"w-full mt-3 rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-5 py-4 text-center",children:[e.jsx(Er,{size:20,className:"mx-auto mb-1.5 text-slate-300"}),e.jsxs("p",{className:"text-sm font-semibold text-slate-500",children:[e.jsx("strong",{className:"text-slate-700",children:x.preferredVendorName})," is your preferred vendor."]}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Run a search to start tracking how much it saves you."})]});const M=x.overpaidVsOwn||0,B=x.overpaidVsOwnPercent||0,H=x.overpaidVsMarket||0,Z=x.overpaidVsMarketPercent||0,_=x.preferredVendorName||"your preferred vendor",ae=x.savedVsMostExpensive||0,q=x.savedVsMostExpensivePercent||0,re=x.suggestedVendorName,K=x.suggestedVendorSavings||0,C=x.suggestedVendorId,ce=x.suggestedVendorSource,X=x.suggestedVendorTimesCheapest||0,Oe=!!(C&&ce&&re),st=x.wonMajority??M===0,He=x.lossCount||0,z=(x.topOwnVendors||[]).find(ne=>ne.vendorName.trim().toLowerCase()!==_.trim().toLowerCase());return e.jsxs("div",{className:"w-full mt-3",children:[e.jsxs(W.button,{type:"button",onClick:()=>j(ne=>!ne),initial:r?void 0:{opacity:0,y:10},animate:r?void 0:{opacity:1,y:0},transition:{duration:.4,ease:[.16,1,.3,1]},className:"relative w-full overflow-hidden rounded-2xl border border-slate-200 bg-white text-left shadow-sm hover:border-slate-300 transition-colors",title:"Click to see the maths",children:[P>0&&e.jsxs("div",{className:"px-5 pt-4 pb-3 border-b border-slate-100 bg-gradient-to-br from-indigo-50/70 to-white",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-widest text-indigo-500 mb-1",children:[e.jsx(Fc,{size:12})," Estimated Savings ",e.jsx("span",{className:"font-medium normal-case text-slate-400",children:"· lifetime"})]}),e.jsx("span",{className:"text-2xl font-black tracking-tight text-indigo-700",children:e.jsx(Kr,{value:P,prefix:"₹"})})]}),e.jsxs("div",{className:"px-5 pt-4",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-400 mb-2",children:"vs. Preferred Vendor"}),e.jsxs("div",{className:"flex gap-2.5",children:[e.jsx(Fi,{icon:e.jsx(Re,{size:11}),label:"Your Vendors",amount:st?ae:M,percent:st?q:B,tone:"emerald",isWin:st}),e.jsx(Fi,{icon:e.jsx(ii,{size:11}),label:"Market Carriers",amount:H,percent:Z,tone:"amber"})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-nowrap px-5 pt-2.5 pb-4 text-[11px] font-semibold text-slate-400",children:[e.jsx("span",{className:"font-medium shrink-0",children:"Click to open →"}),e.jsxs("div",{className:"flex items-center gap-2.5 shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-1 whitespace-nowrap",children:[e.jsx(Er,{size:12})," ",x.searchCount," searches"]}),e.jsxs("span",{className:"flex items-center gap-1 whitespace-nowrap",children:[e.jsx(Ec,{size:12})," ",k," Book Now"]})]})]})]}),Kt.createPortal(e.jsx(kt,{children:y&&e.jsxs("div",{className:"fixed inset-0 z-[2000] flex items-center justify-center p-4",children:[e.jsx(W.div,{initial:{opacity:0}
71,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"absolute inset-0 bg-slate-900/50 backdrop-blur-sm",onClick:()=>j(!1)},"savings-backdrop"),e.jsxs(W.div,{role:"dialog","aria-modal":"true","aria-label":"How your savings are worked out",initial:r?{opacity:0}:{opacity:0,scale:.95,y:12},animate:r?{opacity:1}:{opacity:1,scale:1,y:0},exit:r?{opacity:0}:{opacity:0,scale:.95,y:12},transition:{duration:.22,ease:[.16,1,.3,1]},className:"relative z-10 w-full max-w-lg max-h-[88vh] overflow-y-auto rounded-2xl bg-white text-sm shadow-2xl",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-t-2xl bg-gradient-to-br from-indigo-600 via-indigo-600 to-blue-600 px-5 pt-4 pb-5",children:[e.jsx("div",{className:"pointer-events-none absolute -right-6 -top-10 h-32 w-32 rounded-full bg-white/10"}),e.jsx("div",{className:"pointer-events-none absolute -right-2 top-6 h-16 w-16 rounded-full bg-white/10"}),e.jsx("button",{type:"button",onClick:()=>j(!1),className:"absolute top-3 right-3 text-white/70 hover:text-white hover:bg-white/10 rounded-full p-1 transition-colors","aria-label":"Close",children:e.jsx(Vt,{size:16})}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-indigo-100 mb-1",children:"How this is worked out"}),e.jsx("p",{className:"text-white font-black text-lg leading-tight",children:_}),e.jsx("p",{className:"text-[12px] text-indigo-100 mt-0.5",children:"vs. your other vendors & the market"})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 items-stretch",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-400 mb-1.5 flex items-center gap-1",children:[e.jsx(Re,{size:11})," Your Vendors"]}),M>0&&!st?e.jsxs("div",{className:"flex-1 flex flex-col rounded-2xl border border-amber-200 bg-white shadow-sm overflow-hidden",children:[e.jsx("div",{className:"h-1 bg-gradient-to-r from-amber-400 to-orange-400"}),e.jsxs("div",{className:"p-3 bg-amber-50/50",children:[e.jsxs("p",{className:"text-2xl font-black text-amber-700 leading-none",children:["₹",M.toLocaleString("en-IN")]}),e.jsxs("p",{className:"text-[11px] font-bold text-amber-600 mt-1",children:[B.toFixed(1),"% more than cheapest"]})]}),re&&K>0&&e.jsxs("div",{className:"mt-auto border-t border-amber-100 bg-white p-3",children:[e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-wider text-slate-400",children:"Switch to"}),e.jsx("p",{className:"text-[13px] font-bold text-slate-800 truncate",children:re}),e.jsxs("div",{className:"flex items-center justify-between mt-0.5",children:[e.jsxs("p",{className:"text-[12px] font-bold text-emerald-600",children:["Save ₹",K.toLocaleString("en-IN")]}),X>0&&e.jsxs("p",{className:"text-[10px] text-slate-400",children:[X,"/",x.searchCount]})]}),Oe?e.jsxs("button",{type:"button",disabled:f,onClick:()=>I(C,re,ce),className:"mt-2 w-full inline-flex items-center justify-center gap-1.5 rounded-xl bg-gradient-to-r from-slate-900 to-slate-700 hover:from-slate-800 hover:to-slate-600 disabled:opacity-60 disabled:cursor-not-allowed text-white text-[12px] font-bold px-3 py-2 shadow-sm hover:shadow-md transition-all",children:[f?e.jsx(ut,{size:13,className:"animate-spin"}):e.jsx(gc,{size:13}),f?"Switching…":"Switch vendor"]}):e.jsx($s,{to:"/my-vendors",onClick:()=>j(!1),className:"mt-2 block text-center text-[11px] font-bold text-slate-500 hover:text-slate-700 underline",children:"Switch from My Vendors →"})]})]}):e.jsxs("div",{className:"relative flex-1 flex flex-col rounded-2xl border border-emerald-200 bg-white shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"absolute top-2 right-2 flex items-center gap-1 rounded-full bg-emerald-600 text-white text-[9px] font-bold uppercase tracking-wide px-2 py-0.5",children:[e.jsx(Ir,{size:10})," Winner"]}),e.jsx("div",{className:"h-1 bg-gradient-to-r from-emerald-400 to-teal-400"}),e.jsxs("div",{className:"p-3 bg-emerald-50/50",children:[e.jsxs("p",{className:"text-[11px] font-bold text-emerald-700 flex items-center gap-1",children:[e.jsx(Ds,{size:12,className:"shrink-0"})," Best overall"]}),ae>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-2xl font-black text-emerald-700 leading-none mt-1.5",children:["₹",ae.toLocaleStr
71ing("en-IN")]}),e.jsxs("p",{className:"text-[11px] font-bold text-emerald-600 mt-1",children:[q.toFixed(1),"% saved vs priciest"]})]})]}),z&&e.jsxs("div",{className:"mt-auto border-t border-emerald-100 bg-white px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-slate-300 text-white text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5",children:[e.jsx(Ir,{size:9})," #2"]}),e.jsx("p",{className:"text-[11px] font-bold text-slate-700 truncate",children:z.vendorName})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 mt-0.5",children:["Cheapest on ",z.timesCheapest," search",z.timesCheapest!==1?"es":"",He>0&&` · beat ${_} ${He}/${x.searchCount}`]})]})]})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-400 mb-1.5 flex items-center gap-1",children:[e.jsx(ii,{size:11})," Market Carriers"]}),H>0?e.jsxs("div",{className:"flex-1 flex flex-col rounded-2xl border border-amber-200 bg-white shadow-sm overflow-hidden",children:[e.jsx("div",{className:"h-1 bg-gradient-to-r from-amber-400 to-orange-400"}),e.jsxs("div",{className:"p-3 bg-amber-50/50 flex-1",children:[e.jsxs("p",{className:"text-2xl font-black text-amber-700 leading-none",children:["₹",H.toLocaleString("en-IN")]}),e.jsxs("p",{className:"text-[11px] font-bold text-amber-600 mt-1",children:[Z.toFixed(1),"% cheaper elsewhere"]})]}),e.jsx("div",{className:"mt-auto border-t border-amber-100 bg-white p-3",children:e.jsxs($s,{to:"/buy-subscription-plan",onClick:()=>j(!1),className:"w-full inline-flex items-center justify-center gap-1.5 rounded-xl bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white text-[12px] font-bold px-3 py-2 shadow-sm hover:shadow-md transition-all",children:[e.jsx(Ns,{size:13})," Unlock full list"]})})]}):e.jsxs("div",{className:"relative flex-1 flex flex-col rounded-2xl border border-emerald-200 bg-white shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"absolute top-2 right-2 flex items-center gap-1 rounded-full bg-emerald-600 text-white text-[9px] font-bold uppercase tracking-wide px-2 py-0.5",children:[e.jsx(Ir,{size:10})," Winner"]}),e.jsx("div",{className:"h-1 bg-gradient-to-r from-emerald-400 to-teal-400"}),e.jsx("div",{className:"p-3 bg-emerald-50/50 flex-1",children:e.jsxs("p",{className:"text-[11px] font-bold text-emerald-700 flex items-center gap-1",children:[e.jsx(Ds,{size:13})," Beats the market"]})})]})]})]}),e.jsxs($s,{to:"/recent-searches",onClick:()=>j(!1),className:"mt-3 flex items-center justify-center gap-1.5 text-[11px] text-slate-400 hover:text-slate-600 font-medium hover:underline transition-colors",children:[e.jsx(Er,{size:12}),"Based on ",x.searchCount," search",x.searchCount!==1?"es":""," →"]})]})]},"savings-modal")]})}),document.body)]})}const Ud=500,Ri="Just tell me what you're shipping — origin, destination, and weight — in English, Hindi, or however's easiest.",Hd=({isOpen:t,onClose:l,onResolved:c})=>{const[r,u]=n.useState([{id:"greeting",role:"assistant",content:Ri}]),[x,b]=n.useState(""),[h,g]=n.useState(!1),[y,j]=n.useState(!1),[f,L]=n.useState(null),R=jo(t),{originPick:k,destinationPick:P,unresolvedNote:T,beginResolution:I,pickOrigin:M,pickDestination:B,resolveBoth:H,reset:Z}=ko(E=>{u(Te=>[...Te,{id:`${Date.now()}-calc`,role:"assistant",content:"Got it — crunching the numbers now. This can take up to a minute for a full comparison."}]),L(null),j(!0),c(E)}),_=n.useRef(null),ae=n.useRef(null),q=()=>{u([{id:"greeting",role:"assistant",content:Ri}]),b(""),Z(),j(!1),L(null)};n.useEffect(()=>{t&&q()},[t]),n.useEffect(()=>{if(!y)return;const E=setTimeout(()=>{j(!1),L({status:"incomplete"})},65e3),Te=Be=>{const Ae=Be.detail;clearTimeout(E),j(!1),L(Ae)};return window.addEventListener(Zn,Te),()=>{window.removeEventListener(Zn,Te),clearTimeout(E)}},[y]),n.useEffect(()=>{T&&u(E=>[...E,{id:`${Date.now()}-note`,role:"assistant",content:T}])},[T]),n.useEffect(()=>{_.current?.scrollTo({top:_.current.scrollHeight,behavior:"smooth"})},[r,h,k,P]),n.useEffect(()=>{const E=Te=>{Te.key==="Escape"&&t&&l()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t,l]);const re=E=>b(E),K=E=>me.error(E),{status:C,elapsedMs:ce,isSupported:X,start:Oe,stop:st,cancel:He}=Co(re,K);n.useEffect(()=>{!h&&t&&C==="idle"&&ae.current?.focus()},[h,t,C]);const z=E=>(u(Te=>[...Te,{id:`${Date.now()}-a`,role:"assistant",content:E.reply}]),E.ready&&E.origin&&E.destination&&E.weightKg&&I({origin:E.origin,destination:E.destination,weightKg:E.weightKg,lengthCm:E.lengthCm,widthCm:E.widthCm,height
71Cm:E.heightCm,invoiceValue:E.invoiceValue}),E.reply),ne=async E=>{const Te={id:`${Date.now()}-u`,role:"user",content:E},Be=[...r,Te];u(Be);try{const Ae=await Ro(Be.map(({role:Ve,content:xt})=>({role:Ve,content:xt})));return z(Ae)}catch(Ae){const Ve=Mo(E);if(Ve.origin&&Ve.destination&&Ve.weightKg){const Ge="Our smart assistant hit a snag, but I picked out a shipment from your message — check below and I'll search it.";return u(Ye=>[...Ye,{id:`${Date.now()}-degraded`,role:"assistant",content:Ge}]),I({origin:Ve.origin,destination:Ve.destination,weightKg:Ve.weightKg}),Ge}if(Ve.origin||Ve.destination||Ve.weightKg){const Ge="Our smart assistant is briefly unavailable and I could only make out part of that — you can type the pincodes directly below, or try again in a moment.";return u(Ye=>[...Ye,{id:`${Date.now()}-degraded-partial`,role:"assistant",content:Ge}]),Ge}const xt=Ae?.response?.data?.message||Ae?.message||"FC AI couldn't process that.";return u(Ge=>[...Ge,{id:`${Date.now()}-e`,role:"assistant",content:xt,error:!0}]),xt}},{status:S,caption:Se,isMuted:Qe,startCall:lt,endCall:at,toggleMute:ot}=So({greeting:"Hi! Tell me what you're shipping — origin, destination, and weight.",onUserText:ne,onError:E=>me.error(E)}),De=async()=>{const E=x.trim();if(!(!E||h)){b(""),g(!0);try{await ne(E)}finally{g(!1)}}},Me=E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),De())};return t?Kt.createPortal(e.jsx(kt,{children:e.jsx(W.div,{initial:{opacity:0}
71,animate:{opacity:1},exit:{opacity:0},onClick:l,style:R>0?{height:window.innerHeight-R,bottom:"auto"}:void 0,className:"fixed inset-0 z-[10001] bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4",children:e.jsxs(W.div,{initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},onClick:E=>E.stopPropagation(),style:R>0?{maxHeight:window.innerHeight-R-32}:void 0,className:"w-full max-w-md bg-white rounded-3xl shadow-2xl overflow-hidden flex flex-col max-h-[80vh]",children:[e.jsxs("div",{className:"bg-gradient-to-br from-indigo-600 to-purple-600 px-5 py-4 text-white flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-white/20 border border-white/30 flex items-center justify-center",children:e.jsx(Ns,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black leading-none",children:"Just tell me what you're shipping"}),e.jsx("p",{className:"text-indigo-100 text-[11px] font-medium mt-1",children:"FC AI fills the form for you"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:q,title:"Start over",className:"p-1.5 hover:bg-white/20 rounded-full transition-colors","aria-label":"Start a new search",children:e.jsx(Br,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:l,className:"p-1.5 hover:bg-white/20 rounded-full transition-colors","aria-label":"Close",children:e.jsx(Vt,{className:"w-4 h-4"})})]})]}),S!=="idle"?e.jsx(To,{status:S,caption:Se,isMuted:Qe,onEndCall:at,onToggleMute:ot}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:_,className:"flex-1 overflow-y-auto px-4 py-4 space-y-3 bg-slate-50",children:[r.map(E=>e.jsx("div",{className:`flex ${E.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] rounded-2xl px-3.5 py-2.5 text-sm leading-relaxed whitespace-pre-wrap ${E.role==="user"?"bg-indigo-600 text-white rounded-br-sm":E.error?"bg-red-50 text-red-700 border border-red-100 rounded-bl-sm":"bg-white text-slate-700 border border-slate-200 rounded-bl-sm"}`,children:E.content})},E.id)),h&&e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"bg-white border border-slate-200 rounded-2xl rounded-bl-sm px-3.5 py-2.5 flex items-center gap-2",children:[e.jsx(ut,{className:"w-3.5 h-3.5 animate-spin text-indigo-500"}),e.jsx("span",{className:"text-xs text-slate-400 font-medium",children:"Thinking..."})]})}),k&&e.jsxs("div",{className:"bg-white border border-indigo-200 rounded-2xl p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs font-bold text-slate-500 flex items-center gap-1.5",children:[e.jsx(Jt,{className:"w-3.5 h-3.5"})," Which origin did you mean?"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:k.map(E=>e.jsxs("button",{onClick:()=>M(E),className:"text-[11px] font-semibold px-2.5 py-1.5 rounded-full bg-indigo-50 border border-indigo-200 text-indigo-700 hover:bg-indigo-100 transition-colors",children:[E.city,", ",E.state," — ",E.pincode]},E.pincode))})]}),P&&e.jsxs("div",{className:"bg-white border border-indigo-200 rounded-2xl p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs font-bold text-slate-500 flex items-center gap-1.5",children:[e.jsx(Jt,{className:"w-3.5 h-3.5"})," Which destination did you mean?"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(E=>e.jsxs("button",{onClick:()=>B(E),className:"text-[11px] font-semibold px-2.5 py-1.5 rounded-full bg-indigo-50 border border-indigo-200 text-indigo-700 hover:bg-indigo-100 transition-colors",children:[E.city,", ",E.state," — ",E.pincode]},E.pincode))})]}),y&&e.jsxs("div",{className:"bg-white border border-indigo-200 rounded-2xl p-3.5 flex items-center gap-2.5",children:[e.jsx(ut,{className:"w-4 h-4 animate-spin text-indigo-500 flex-shrink-0"}),e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"Crunching the numbers across every carrier — this can take up to a minute. I'll drop the result right here."})]}),f&&e.jsxs("div",{className:"bg-white border border-emerald-200 rounded-2xl p-3.5 space-y-2.5",children:[f.status==="ok"?e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:[f.ourLabel&&f.ourPrice!=null?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-bold text-emerald-700",children:"Your best rate:"}
71)," ",f.ourLabel," — ₹",f.ourPrice.toLocaleString("en-IN"),f.etaDays?`, about ${f.etaDays} day${f.etaDays===1?"":"s"}`:"","."]}):e.jsx("span",{className:"font-bold text-emerald-700",children:"Found some options for that route."}),f.marketPrice!=null&&e.jsxs(e.Fragment,{children:[" ",f.hasOwnVendors?"Other carriers we compared start around":"Cheapest option we found is around"," ","₹",f.marketPrice.toLocaleString("en-IN")," — full breakdown inside."]})]}):e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"That one's taking longer than usual, or hit a snag — tap below to check it out directly."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:l,className:"flex-1 flex items-center justify-center gap-2 bg-emerald-600 hover:bg-emerald-700 text-white text-xs font-bold py-2.5 rounded-xl transition-colors",children:[e.jsx(Or,{className:"w-3.5 h-3.5"})," View full results"]}),e.jsxs("button",{onClick:q,title:"Start a new search",className:"flex items-center justify-center gap-1.5 bg-slate-100 hover:bg-slate-200 text-slate-600 text-xs font-bold px-3 py-2.5 rounded-xl transition-colors",children:[e.jsx(Br,{className:"w-3.5 h-3.5"})," New search"]})]})]}),e.jsx("div",{children:e.jsx(Po,{onSubmit:(E,Te)=>H(E,Te)})})]}),e.jsx("div",{className:"p-3 border-t border-slate-100 bg-white flex-shrink-0",children:e.jsx("div",{className:"flex items-end gap-2",children:C!=="idle"?e.jsx(Lo,{status:C,elapsedMs:ce,onStop:st,onCancel:He}):e.jsxs(e.Fragment,{children:[e.jsx("textarea",{ref:ae,value:x,onChange:E=>b(E.target.value.slice(0,Ud)),onKeyDown:Me,rows:1,placeholder:"e.g. 50 kg Mumbai to Delhi",disabled:h,autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,"data-ms-editor":"false","data-gramm":"false","data-gramm_editor":"false","data-enable-grammarly":"false",style:{resize:"none",appearance:"none",WebkitAppearance:"none"},className:"flex-1 resize-none appearance-none [&::-webkit-resizer]:hidden [&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden placeholder-shown:overflow-hidden placeholder-shown:whitespace-nowrap placeholder-shown:text-ellipsis bg-slate-50 border border-slate-200 rounded-2xl px-3.5 py-2.5 text-sm outline-none focus:ring-2 focus:ring-indigo-400 focus:border-transparent disabled:opacity-60 max-h-24"}),e.jsx("button",{onClick:De,disabled:h||!x.trim(),className:"flex-shrink-0 w-10 h-10 rounded-full bg-indigo-600 text-white flex items-center justify-center hover:bg-indigo-700 disabled:bg-indigo-300 disabled:cursor-not-allowed transition-colors",children:e.jsx(Io,{className:"w-4 h-4"})}),X&&e.jsx(Eo,{onClick:Oe,disabled:h}),X&&e.jsx("button",{onClick:lt,disabled:h,title:"Talk Mode — have a spoken conversation","aria-label":"Start Talk Mode",className:"flex-shrink-0 w-10 h-10 rounded-full bg-gradient-to-br from-indigo-500 to-purple-600 hover:from-indigo-600 hover:to-purple-700 text-white flex items-center justify-center transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx(Fo,{size:18})})]})})})]})]})})}),document.body):null};function Rr({min:t,max:l,step:c=1,minValue:r,maxValue:u,onMinChange:x,onMaxChange:b}){const h=l<=t,g=h?1:l-t,y=h?0:(r-t)/g*100,j=h?100:(u-t)/g*100,[f,L]=n.useState(null),R=f?f==="min":r>t+g/2,k="9px",P=!h&&Math.abs(j-y)<.01;return e.jsxs("div",{className:"drs-track-row",children:[e.jsx("div",{className:"drs-track bg-slate-200",style:{left:k,right:k}}),e.jsx("div",{className:"drs-track bg-blue-600",style:{left:`calc(${y}% + ${k})`,width:`max(0px, calc(${Math.max(0,j-y)}% - 2 * ${k}))`}}),h?e.jsx("div",{className:"drs-thumb-static",style:{right:k}}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"range",min:t,max:l,step:c,value:r,onChange:T=>x(Math.min(Number(T.target.value),u)),onPointerDown:()=>L("min"),onPointerUp:()=>L(null),className:"drs-thumb",style:{zIndex:R?4:3,transform:P?"translateY(-50%) translateX(-7px)":void 0}}),e.jsx("input",{type:"range",min:t,max:l,step:c,value:u,onChange:T=>b(Math.max(Number(T.target.value),r)),onPointerDown:()=>L("max"),onPointerUp:()=>L(null),className:"drs-thumb",style:{zIndex:R?3:4,transform:P?"translateY(-50%) translateX(7px)":void 0}})]})]})}const Mi=({status:t,className:l=""})=>{const r={verified:{label:"Verified",icon:za,bgColor:"bg-green-50",textColor:"text-green-700",borderColor:"border-green-200"},unverified:{label:"Unverified",icon:Xt,bgColor:"bg-yellow-50",textColor:"text-yellow-700",borderColor:"border-yellow-200"},unverified_critical:{label:"Unverified",icon:Xt,bgColor:"bg-red-50",textColor:"text-red-700",borderColor:"border-red-200"},unknown:{label:"Status Unknown",icon:Qr,bgColor:"bg-gray-100",textColor:"text-gray-600",borderColor:"border-gray-200"}}[t],u=r.icon;return t==="unknown"?null:e.jsxs("span",{className:`inline-flex items-center gap-0.5 px-1 py-0 rounded-full border ${r.bgColor} ${r.textColor} ${r.borderColor} ${l}`,title:`This vendor is ${r.label.toLowerCase()}`,children:[e.jsx(u,{size:8}),r.label]})},Qd=[{key:"priceSupport",label:"Price Support",icon:"💰"},{key:"deliveryTime",label:"Delivery Time",icon:"🚚"},{key:"tracking",label:"Tracking",icon:"📍"}
71,{key:"salesSupport",label:"Sales Support",icon:"🎧"},{key:"damageLoss",label:"Damage/Loss",icon:"📦"}],Ai=({vendorRatings:t,totalRatings:l=0,overallRating:c=0,vendorId:r,isTemporaryVendor:u=!1,vendorType:x})=>{const[b,h]=n.useState(!1),[g,y]=n.useState({top:0,left:0}),[j,f]=n.useState(!1),[L,R]=n.useState([]),[k,P]=n.useState(!1),T=n.useRef(null),I=n.useRef(null),M=t&&Object.values(t).some(K=>K>0),B=x==="special"||(r?rc(r):!1),H=x||(B?"special":u?"temporary":"regular"),Z=n.useCallback(async()=>{if(!(!r||L.length>0)){P(!0);try{const K=Vs,C=new URLSearchParams({limit:"5"});H==="special"?C.set("vendorType","special"):C.set("isTemporary",String(u));const X=await(await fetch(`${K}/api/ratings/vendor/${r}?${C.toString()}`)).json();X.success&&X.ratings&&R(X.ratings)}catch(K){console.error("Failed to fetch reviews:",K)}finally{P(!1)}}},[r,u,H,L.length]),_=K=>{K.stopPropagation();const C=!j;f(C),C&&Z()},ae=K=>new Date(K).toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"}),q=n.useCallback(()=>{if(T.current&&b){const K=T.current.getBoundingClientRect(),C=256;let ce=K.left+K.width/2-C/2;const X=K.bottom+8;ce<8&&(ce=8),ce+C>window.innerWidth-8&&(ce=window.innerWidth-C-8),y({top:X,left:ce})}},[b]);n.useEffect(()=>(b&&(q(),window.addEventListener("scroll",q,!0),window.addEventListener("resize",q)),()=>{window.removeEventListener("scroll",q,!0),window.removeEventListener("resize",q)}),[b,q]),n.useEffect(()=>{const K=C=>{b&&T.current&&!T.current.contains(C.target)&&I.current&&!I.current.contains(C.target)&&h(!1)};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[b]);const re=b?e.jsxs("div",{ref:I,className:`fixed w-64 bg-white rounded-lg shadow-xl border p-4 animate-in fade-in-0 zoom-in-95 duration-200 ${B?"border-amber-200":"border-slate-200"}`,style:{top:g.top,left:g.left,zIndex:99999},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:[e.jsx("div",{className:`absolute -top-2 left-1/2 -translate-x-1/2 w-3 h-3 bg-white border-l border-t rotate-45 ${B?"border-amber-200":"border-slate-200"}`,style:{zIndex:-1}}),e.jsxs("h4",{className:"text-sm font-semibold text-slate-800 mb-3 flex items-center gap-2",children:["Rating Breakdown",B&&e.jsx("span",{className:"text-[10px] bg-amber-100 text-amber-700 px-1.5 py-0.5 rounded font-medium",children:"Partner"})]}),M?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2.5",children:Qd.map(K=>{const C=t?.[K.key]||0,ce=C/5*100;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm w-5 flex-shrink-0",children:K.icon}),e.jsx("span",{className:"text-xs text-slate-600 w-24 truncate",children:K.label}),e.jsx("div",{className:"flex-1 h-1.5 bg-slate-100 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-amber-400 rounded-full transition-all duration-300",style:{width:`${ce}%`}})}),e.jsx("span",{className:"text-xs font-medium text-slate-700 w-6 text-right",children:C>0?C.toFixed(1):"—"})]},K.key)})}),e.jsxs("div",{className:"mt-3 pt-2 border-t border-slate-100 flex justify-between items-center",children:[e.jsxs("span",{className:"text-xs text-slate-500",children:["Based on ",l," ",l===1?"rating":"ratings"]}),e.jsxs("span",{className:"text-xs font-semibold text-slate-700",children:["Overall: ",c.toFixed(1),"★"]})]}),r&&l>0&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{onClick:_,className:`w-full flex items-center justify-center gap-1.5 py-1.5 text-xs rounded transition-colors ${B?"text-amber-600 hover:text-amber-700 hover:bg-amber-50":"text-blue-600 hover:text-blue-700 hover:bg-blue-50"}`,children:[e.jsx(bc,{size:12}),e.jsx("span",{children:j?"Hide Reviews":"View Reviews"}),j?e.jsx(vc,{size:12}):e.jsx(_s,{size:12})]}),j&&e.jsx("div",{className:"mt-2 space-y-2 max-h-40 overflow-y-auto",children:k?e.jsx("div",{className:"text-center py-2",children:e.jsx("div",{className:`w-4 h-4 border-2 border-t-transparent rounded-full animate-spin mx-auto ${B?"border-amber-500":"border-blue-500"}`})}):L.length>0?L.map(K=>e.jsxs("div",{className:"p-2 bg-slate-50 rounded-md border border-slate-100",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-amber-500",children:[[...Array(5)].map((C,ce)=>e.jsx("span",{className:"text-xs",children:ce<Math.round(K.overallRating)?"★":"☆"},ce)),e.jsx("span",{className:"text-xs text-slate-600 ml-1",children:K.overallRating.toFixed(1)})]}),e.jsx("span",{className:"text-[10px] text-slate-400",children:ae(K.createdAt)})]}),K.comment?e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:['"',K.comment,'"']}):e.jsx("p",{className:"text-xs text-slate-400 italic",children:"No comment"})]},K._id)):e.jsx("p",{className:"text-xs text-slate-400 text-center py-2",children:"No reviews with comments yet"})})]})]}):e.jsxs("div",{className:"text-center py-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"No detailed ratings yet"}),e.jsxs("p",{className:"text-xs text-slate-400 mt-1",children:["Be the first to rate this ",B?"partner":"vendor","!"]})]})]}):null;return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:T,type:"button",className:`p-0.5 transition-colors focus:outline-none ${B?"text-amber-400 hover:text-amber-600":"text-slate-400 hover:text-slate-600"}`,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onClick:K=>{K.stopPropagation(),h(!b)},"aria-label":"View rating breakdown",children:e.jsx(Gr,{size:14})}),Kt.createPortal(re,document.body)]})};function Gd({title:t,titleId:l,...c},r){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":l},c),t?n.createElement("title",{id:l},t):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z"}))}const Yd=n.forwardRef(Gd),Zd=[{key:"priceSupport",label:"Price Support",description:"How fair and transparent was the pricing?",icon:"💰"},{key:"deliveryTime",label:"Delivery Time",description:"Was the delivery on time as promised?",icon:"🚚"},{key:"tracking",label:"Tracking",description:"How accurate and helpful was shipment tracking?",icon:"📍"}
71,{key:"salesSupport",label:"Sales Support",description:"How responsive and helpful was the support team?",icon:"🎧"},{key:"damageLoss",label:"Damage/Loss",description:"Was your package delivered safely without damage?",icon:"📦"}],Xd=({value:t,onChange:l,error:c})=>{const[r,u]=n.useState(0),x=r||t;return e.jsxs("div",{className:"flex items-center gap-0.5",children:[[1,2,3,4,5].map(b=>e.jsx("button",{type:"button",onClick:()=>l(b),onMouseEnter:()=>u(b),onMouseLeave:()=>u(0),className:`p-0.5 focus:outline-none focus:ring-2 focus:ring-indigo-400 focus:ring-offset-1 rounded transition-transform hover:scale-110 ${c&&t===0?"ring-1 ring-red-300":""}`,"aria-label":`Rate ${b} out of 5`,children:b<=x?e.jsx(Yi,{className:"w-6 h-6 text-amber-400 drop-shadow-sm"}):e.jsx(Yd,{className:"w-6 h-6 text-slate-300 hover:text-amber-200"})},b)),e.jsx("span",{className:"ml-2 text-sm font-medium text-slate-600 min-w-[2.5rem]",children:t>0?`${t}/5`:"—"})]})},Jd=t=>Object.values(t).reduce((r,u)=>r+u,0)/5,qd=({isOpen:t,onClose:l,vendorId:c,vendorName:r,isTemporaryVendor:u,vendorType:x,onRatingSubmitted:b})=>{const[h,g]=n.useState({priceSupport:0,deliveryTime:0,tracking:0,salesSupport:0,damageLoss:0}),[y,j]=n.useState(""),[f,L]=n.useState(!1),[R,k]=n.useState(null),[P,T]=n.useState(!1),I=x==="special";n.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]);const M=Object.values(h).every(q=>q>0),B=M?Jd(h):0,H=(q,re)=>{g(K=>({...K,[q]:re})),T(!1),k(null)},Z=async()=>{if(!M){T(!0),k("Please rate all 5 parameters");return}L(!0),k(null);try{const q={vendorId:c,isTemporaryVendor:u,vendorType:x||(u?"temporary":"regular"),ratings:h,comment:y.trim()||null,overallRating:Math.round(B*10)/10},re=await Qi.post(`${Vs}/api/ratings/submit`,q);re.data.success?(b&&b(re.data.newOverallRating||B,h),g({priceSupport:0,deliveryTime:0,tracking:0,salesSupport:0,damageLoss:0}),j(""),T(!1),l()):k(re.data.message||"Failed to submit rating")}catch(q){console.error("Rating submission error:",q),k(q.response?.data?.message||"Failed to submit rating. Please try again.")}finally{L(!1)}},_=()=>{f||(g({priceSupport:0,deliveryTime:0,tracking:0,salesSupport:0,damageLoss:0}),j(""),T(!1),k(null),l())};if(!t)return null;const ae=e.jsxs("div",{className:"fixed inset-0 flex items-center justify-center",style:{zIndex:99999},children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:_,style:{zIndex:99999}}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl w-full max-w-md mx-4 max-h-[90vh] overflow-hidden",style:{zIndex:1e5},children:[e.jsxs("div",{className:`flex items-center justify-between p-4 border-b ${I?"border-amber-200 bg-gradient-to-r from-amber-50 to-yellow-50":"border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ws,{className:`w-5 h-5 ${I?"text-amber-500":"text-amber-400"}`}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-slate-800",children:["Rate ",r]}),I&&e.jsx("span",{className:"text-xs text-amber-600 font-medium",children:"Our Partner"})]})]}),e.jsx("button",{onClick:_,disabled:f,className:"p-1 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors disabled:opacity-50","aria-label":"Close",children:e.jsx(Vt,{size:20})})]}),e.jsxs("div",{className:"p-4 overflow-y-auto max-h-[calc(90vh-140px)]",children:[e.jsx("div",{className:"space-y-4",children:Zd.map(q=>{const re=h[q.key],K=P&&re===0;return e.jsxs("div",{className:`p-3 rounded-lg transition-colors ${K?"bg-red-50 border border-red-200":"bg-slate-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-lg",children:q.icon}),e.jsx("span",{className:"text-sm font-semibold text-slate-700",children:q.label}),e.jsx("span",{className:"text-red-500 text-sm",children:"*"})]}),e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:q.description}),e.jsx(Xd,{value:re,onChange:C=>H(q.key,C),error:K})]},q.key)})}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-700 mb-1",children:["Comment ",e.jsx("span",{className:"text-slate-400",children:"(optional)"})]}),e.jsx("textarea",{value:y,onChange:q=>j(q.target.value),placeholder:"Share your experience with this vendor...",maxLength:500,rows:3,className:"w-full px-3 py-2 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-400 focus:border-transparent resize-none"}),e.jsxs("p",{className:"text-xs text-slate-400 text-right mt-1",children:[y.length,"/500"]})]}),M&&e.jsx("div",{className:`mt-4 p-3 rounded-lg border ${I?"bg-gradient-to-r from-amber-50 to-yellow-50 border-amber-300":"bg-gradient-to-r from-amber-50 to-orange-50 border-amber-200"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-slate-700",children:"Overall Rating"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Yi,{className:"w-5 h-5 text-amber-400"}),e.jsx("span",{className:"text-lg font-bold text-slate-800",children:B.toFixed(1)}),e.jsx("span",{className:"text-sm text-slate-500",children:"/ 5"})]})]})}),R&&e.jsx("div",{className:"mt-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("p",{className:"text-sm text-red-600",children:R})})]}),e.jsxs("div",{className:`flex items-center justify-between p-4 border-t ${I?"border-amber-200 bg-amber-50":"border-slate-200 bg-slate-50"}`,children:[e.jsxs("p",{className:"text-xs text-slate-500",children:[e.jsx("span",{className:"text-red-500",children:"*"})," All ratings required"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:_,disabled:f,className:"px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800 hover:bg-slate-100 rounded-lg transition-colors disabled:opacity-50",children:"Cancel"}),e.jsx("button",{onClick:Z,disabled:f||!M,className:`px-4 py-2 text-sm font-semibold text-white rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 ${I?"bg-amber-600 hover:bg-amber-700":"bg-indigo-600 hover:bg-indigo-700"}`,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ut,{size:16,className:"animate-spin"}),"Submitting..."]}):"Submit Rating"})]})]})]})]});return Kt.createPortal(ae,document.body)},em=Vs,tm=t=>t?{Authorization:`Bearer ${t}`}:void 0;async function sm(t,l,c,r,u,x){const b=`${em}/api/indiapost/pricing`;try{const h=await Qi.get(b,{params:{weight:t,distance:l},headers:tm(x)});if(h.data?.success&&h.data.data?.price)return{price:h.data.data.price,matchedWeight:h.data.data.matchedWeight,matchedDistance:h.data.data.matchedDistance}}catch(h){if(h.response?.status===403)return console.log("IndiaPost does not serve these pincodes.",{fromPincode:r,toPincode:u}),null;console.warn("IndiaPost pricing API failed:",h.response?.data?.message||h.message)}return null}async function am(t){const{fromPincode:l,toPincode:c,shipment:r,totalWeight:u,token:x,distanceKmOverride:b}=t;let h=nc(b);if(h<=0)return null;let g=0;r.forEach(I=>{const M=I.length*I.width*I.height*I.count/5e3;g+=M});const y=u,j=g,f=Math.max(y,j),L=await sm(f,h,r,l,c,x);if(!L)return null;const R=await ic(ai.INDIA_POST),k=I=>Math.ceil(I/300);return{...{actualWeight:y,volumetricWeight:j,chargeableWeight:f,matchedWeight:L.matchedWeight??f,matchedDistance:L.matchedDistance??h,distance:`${Math.round(h)} km`,originPincode:l,destinationPincode:c,isTiedUp:!1},message:"",isHidden:!1,transporterData:{_id:ai.INDIA_POST,rating:R.rating,
71name:La.INDIA_POST,type:"LTL"},companyName:La.INDIA_POST,transporterName:La.INDIA_POST,category:La.INDIA_POST,rating:R.rating,vendorRatings:R.vendorRatings,totalRatings:R.totalRatings,totalCharges:L.price,price:L.price,total:L.price,totalPrice:L.price,estimatedTime:k(h),estimatedDelivery:`${k(h)} Day${k(h)>1?"s":""}`,deliveryTime:`${k(h)} Day${k(h)>1?"s":""}`,vehicle:"IndiaPost Service",vehicleLength:"Box",loadSplit:null,vehicleBreakdown:null}}const nl="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2048%2048'%20width='48'%20height='48'%3e%3c!--%20Mover%20(BOXnMOVE)%20—%20package-on-the-move%20mark%20--%3e%3crect%20x='0'%20y='0'%20width='48'%20height='48'%20rx='12'%20fill='%237C2D12'/%3e%3c!--%20box%20body%20--%3e%3cg%3e%3cpath%20d='M14%2019.5%2024%2014l10%205.5v11L24%2036l-10-5.5v-11z'%20fill='%23F59E0B'/%3e%3cpath%20d='M24%2014l10%205.5L24%2025%2014%2019.5%2024%2014z'%20fill='%23FBBF24'/%3e%3cpath%20d='M24%2025v11l10-5.5v-11L24%2025z'%20fill='%23D97706'/%3e%3c!--%20tape%20line%20--%3e%3cpath%20d='M19%2016.75%2029%2022.25V27l-2%201.1v-4.75l-10-5.5%202-1.1z'%20fill='%23FEF3C7'%20opacity='0.9'/%3e%3c/g%3e%3c!--%20motion%20dashes%20--%3e%3cg%20stroke='%23FDE68A'%20stroke-width='2.4'%20stroke-linecap='round'%3e%3cline%20x1='6'%20y1='22'%20x2='10'%20y2='22'/%3e%3cline%20x1='4.5'%20y1='27'%20x2='9'%20y2='27'/%3e%3cline%20x1='6'%20y1='32'%20x2='10'%20y2='32'/%3e%3c/g%3e%3c/svg%3e",il="/assets/wheelseye-logo-0M3rpDxh.png",ll="/assets/porter-logo-CrA1dtKT.png",rm="/assets/rapido-logo-Dvt_yQmI.png",_i=!1,nm=[{key:"docket",label:"Docket Charges",description:"Booking & LR documentation fee per consignment"},{key:"fuel",label:"Fuel Surcharge",description:"Dynamic fuel cost adjustment applied on base freight"},{key:"fov",label:"FOV / Insurance",description:"Freight on Value — cargo risk coverage"},{key:"handling",label:"Handling Charges",description:"Loading, unloading & material handling at hub"},{key:"oda",label:"ODA Charges",description:"Out of Delivery Area surcharge"},{key:"greentax",label:"Green Tax",description:"Environmental & sustainability cess"},{key:"misc",label:"Miscellaneous",description:"Additional vendor-specific administrative fees"},{key:"hamali",label:"Hamali Charges",description:"Manual labour for loading/unloading at site"}],Mr=new Set(nm.map(t=>t.key)),Ar=1500,_r=300,$r=300,As=1e4,im=5e4,oa=1,bs=1e8,Ur=t=>t.replace(/\D/g,""),Aa=t=>t.replace(/[^a-zA-Z ]/g,"").slice(0,30),vs=t=>{[".",",","e","E","+","-"].includes(t.key)&&t.preventDefault()},ys=(t,l)=>{const c=Ur(t);if(c==="")return"";const r=Number(c);return Number.isFinite(r)?String(r):""},_a=t=>{[",","e","E","+","-"].includes(t.key)&&t.preventDefault()},Zt=t=>new Intl.NumberFormat("en-IN",{minimumFractionDigits:0,maximumFractionDigits:0}).format(Math.round(t)),lm=t=>{if(!Number.isFinite(t)||t<=0)return null;const l=t<=20?15:20,c=t<=20?20:25,r=y=>Math.round(y*60/5)*5,u=y=>{if(y<60)return`${y} min`;const j=Math.floor(y/60),f=y%60;return f===0?`${j} hr`:`${j}h ${f}m`},x=r(t/c),b=r(t/l),h=u(x),g=u(b);return h===g?`~${h}`:`~${h} – ${g}`},Ft=[1/24,2/24,3/24,4/24,5/24,6/24,1,2],Dr=["1hr","2hr","3hr","4hr","5hr","6hr","1 Day","2 Days"],Vr=t=>Number.isFinite(t)&&t>0&&t<=100,zr=t=>{for(let l=0;l<Ft.length;l++)if(t<=Ft[l]+1e-6)return l+1;return Ft.length},$i=t=>Ft[Math.max(1,Math.min(Ft.length,t))-1],ol=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const l=t.replace(/[^\d.]/g,""),c=Number(l);return Number.isFinite(c)?c:NaN}return NaN},Ne=t=>{const l=[t?.totalCharges,t?.totalPrice,t?.price,t?.quote?.price];for(const c of l){const r=ol(c);if(Number.isFinite(r)&&r>0)return r}return NaN};function $a(t,l,c,r){return!Number.isFinite(t)||t<=0?!1:!!(Number.isFinite(c)&&Number.isFinite(r)&&c>0&&c<r||Number.isFinite(l)&&l>=500&&t/l<4)}function Yt(t,l){const c=(()=>{const u=/([\d.]+)\s*ton/i.exec(String(l||""));if(u)return parseFloat(u[1])*1e3;const x=/([\d.]+)\s*kg/i.exec(String(l||""));return x?parseFloat(x[1]):null})(),r=tc(String(t||""))?.match.maxCapacityKg??null;return c!=null&&r!=null?Math.min(c,r):c??r}const Di=["TRANSPORTER","CARRIER","LOGISTICS","FREIGHT","EXPRESS","CARGO","COURIER","SHIPCO"],om=t=>{const l=(t||"").split("").reduce((c,r)=>c+r.charCodeAt(0),0);return Di[l%Di.length]+" "+String(100+l%900)},cm=({children:t,className:l=""})=>e.jsx("div",{className:`bg-white rounded-xl shadow-sm border border-slate-200 p-4 transition-all duration-300 ${l}`,children:t}),yt=({label:t,icon:l,error:c,className:r,placeholder:u,...x})=>e.jsxs("div",{className:"relative",children:[t&&e.jsx("label",{htmlFor:x.id,className:"block text-base font-semibold text-slate-700 uppercase tracking-wider mb-1.5",children:t}),e.jsxs("div",{className:"relative",children:[l&&e.jsx("div",{className:"absolute left-3.5 to
71p-1/2 -translate-y-1/2 h-5 w-5 text-slate-400",children:l}),e.jsx("input",{...x,placeholder:u,"aria-invalid":c?"true":"false",className:`block w-full ${r?.includes("py-")?"":"py-2.5"} bg-white border rounded-lg text-base placeholder:text-slate-400 text-slate-900 focus:outline-none focus:ring-4 focus:ring-blue-500/10 transition ${l?"pl-11":r?.includes("px-")?"":"px-4"} ${c?"border-red-300 focus:border-red-500 focus:ring-red-500/10":"border-slate-200 focus:border-blue-500 focus:ring-blue-500/10"} ${r||""}`})]}),!!c&&e.jsxs("p",{className:"absolute left-0 top-full mt-1 text-base text-red-600 font-medium flex items-center gap-1 whitespace-nowrap","aria-live":"polite",children:[e.jsx(Xt,{size:12}),c]})]}),Vi=()=>e.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-100 p-3 flex gap-3 shadow-sm",children:[e.jsx("div",{className:"h-11 bg-slate-100/80 rounded-xl flex-1 animate-pulse"}),e.jsx("div",{className:"h-11 bg-slate-100/80 rounded-xl flex-1 animate-pulse"}),e.jsx("div",{className:"h-11 bg-slate-100/80 rounded-xl flex-1 animate-pulse"}),e.jsx("div",{className:"h-11 w-11 bg-slate-100/80 rounded-xl animate-pulse"})]}),[1,2,3].map(t=>e.jsxs("div",{className:"relative bg-white rounded-2xl border border-slate-100 p-6 shadow-sm overflow-hidden space-y-5",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/40 to-transparent animate-pulse pointer-events-none"}),e.jsxs("div",{className:"flex justify-between items-start relative z-10",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-7 w-64 bg-slate-200/60 rounded-lg animate-pulse"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"h-5 w-16 bg-slate-100 rounded-md animate-pulse"}),e.jsx("div",{className:"h-5 w-24 bg-slate-100 rounded-md animate-pulse"})]})]}),e.jsx("div",{className:"h-10 w-32 bg-blue-50/50 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 relative z-10",children:[e.jsx("div",{className:"h-16 bg-slate-50 rounded-2xl animate-pulse"}),e.jsx("div",{className:"h-16 bg-slate-50 rounded-2xl animate-pulse"})]}),e.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-slate-50 relative z-10",children:[e.jsx("div",{className:"h-4 w-40 bg-slate-100 rounded-md animate-pulse"}),e.jsx("div",{className:"h-4 w-28 bg-slate-100 rounded-md animate-pulse"})]})]},t))]}),dm=[{id:"uber",name:"Uber",maxKg:15,maxCm:60,maxKm:50},{id:"rapido",name:"Rapido",maxKg:20,maxCm:60,maxKm:30},{id:"ola",name:"Ola",maxKg:15,maxCm:60,maxKm:25},{id:"porter_bike",name:"Porter (Bike)",maxKg:20,maxCm:40,maxKm:20},{id:"porter_eloader",name:"Porter (E Loader)",maxKg:310,maxCm:128,maxKm:30},{id:"porter_3w",name:"Porter (3W)",maxKg:500,maxCm:183,maxKm:35},{id:"porter_eeco",name:"Porter (Eeco)",maxKg:500,maxCm:158,maxKm:35},{id:"porter_minitruck",name:"Porter (Mini)",maxKg:750,maxCm:213,maxKm:100},{id:"porter_pickup8ft",name:"Porter (Pickup 8ft)",maxKg:1250,maxCm:244,maxKm:150},{id:"porter_10ft",name:"Porter (10ft)",maxKg:1700,maxCm:305,maxKm:200},{id:"porter_407",name:"Porter (407)",maxKg:2500,maxCm:366,maxKm:250},{id:"porter_14ft",name:"Porter (14ft)",maxKg:3500,maxCm:427,maxKm:300},{id:"porter_17ft",name:"Porter (17ft)",maxKg:4500,maxCm:518,maxKm:400},{id:"porter_19ft",name:"Porter (19ft)",maxKg:6e3,maxCm:579,maxKm:500}],mm={porter:"https://porter.in",rapido:"https://rapido.bike",ola:"https://ola-package-web-kcs-3000b.olacabs.com/",mover:"https://mover.delivery"};function zi(t,l){let c=0,r=0;for(const x of l){if(!x.count||!x.weight)continue;c+=x.count*x.weight;const b=Math.max(x.length||0,x.width||0,x.height||0);b>r&&(r=b)}c===0&&(c=1);const u=dm.filter(x=>t<=x.maxKm&&c<=x.maxKg&&(r===0||r<=x.maxCm)).map(x=>({...x,tier:x.id==="uber"?1:3}));return{eligible:u.length>0,eligiblePlatforms:u,distanceKm:t,totalWeightKg:c,maxDimCm:r}}const Da=!1,Oi=({value:t,decimals:l=0,reduceMotion:c})=>{const r=oc(t),u=cc(r,{stiffness:120,damping:20,mass:.6}),x=dc(u,g=>g.toFixed(l)),[b,h]=n.useState(t.toFixed(l));return n.useEffect(()=>{if(c){h(t.toFixed(l)),r.jump(t);return}r.set(t)},[t,c,l,r]),n.useEffect(()=>{if(c)return;const g=x.on("change",y=>h(y));return()=>g()},[x,c]),e.jsx(e.Fragment,{children:b})},rh=()=>e.jsx(hm,{}),hm=()=>{const{user:t,isSuperAdmin:l,isAdmin:c,loading:r}=Ka(),u=Gi.get("authToken"),x=Hr(),b=Ua(),h=()=>
71{if(!t)return null;const s=t;return s.customer||s},g=s=>`user_has_vendors_${s}`,[y,j]=n.useState(()=>{const s=h();return!!s?._id&&sessionStorage.getItem(g(s._id))==="true"}),[f,L]=n.useState(()=>{const s=h();return!!s?._id&&sessionStorage.getItem(g(s._id))==="true"});n.useEffect(()=>{const s=h();if(!s?._id)return;if(sessionStorage.getItem(g(s._id))==="true"){j(!0),L(!0);return}L(!1),Promise.all([fetch(`${Vs}/api/transporter/gettemporarytransporters?customerID=${s._id}`,{credentials:"include"}).then(i=>i.ok?i.json():null).catch(()=>null),fetch(`${Vs}/api/individual-ftl/mine`,{credentials:"include"}).then(i=>i.ok?i.json():null).catch(()=>null)]).then(([i,o])=>{const m=Array.isArray(i?.data)?i.data.length:0,p=Number(o?.count)||0,A=m+p>0;sessionStorage.setItem(g(s._id),String(A)),j(A),L(!0)}).catch(()=>{L(!0)})},[t]);const[R,k]=n.useState(()=>vt()?.sortBy||"price"),P=n.useRef(!1);n.useEffect(()=>{if(!f||P.current)return;if(y){k("price");return}const s=h(),a=l||Oa({isAdmin:s?.isAdmin,isSubscribed:s?.isSubscribed});k(a?"price":"time")},[f,y,l]);const[T,I]=n.useState(!1),[M,B]=n.useState(""),[H,Z]=n.useState(null),[_,ae]=n.useState(!1),{setSubscriptionPopupOpen:q}=Ao();n.useEffect(()=>(q(_),()=>q(!1)),[_,q]);const[re,K]=n.useState(!1),[C,ce]=n.useState(!1),[X,Oe]=n.useState(null),[st,He]=n.useState(null),[z,ne]=n.useState("hero"),[S,Se]=n.useState(!1),[Qe,lt]=n.useState(!1),[at,ot]=n.useState(0),De=n.useRef(null);n.useEffect(()=>{De.current&&clearTimeout(De.current);const s=h(),i=c||l?s?.screenshotProtectionEnabled!==!1:!0;return z==="results"&&i?De.current=setTimeout(()=>lt(!0),1500):lt(!1),()=>{De.current&&clearTimeout(De.current)}},[z,t,c,l]),n.useEffect(()=>{const s=a=>ne(a.state?.fcResults?"results":"hero");return window.addEventListener("popstate",s),()=>window.removeEventListener("popstate",s)},[]),n.useEffect(()=>{z==="results"&&(window.history.state?.fcResults||window.history.pushState({fcResults:!0},""))},[z]);const Me=Rs.useRef(null),[E,Te]=n.useState(null),[Be,Ae]=n.useState(!1),[Ve,xt]=n.useState(null),[Ge,Ye]=n.useState(!1),[qt,es]=n.useState(null),pt=Rs.useRef(0),[le,Ue]=n.useState(null),[de,rt]=n.useState(null),Q=Rs.useMemo(()=>{const s=new Set,a=[],i=[...le||[],...(de||[]).filter(o=>o.isTiedUp)];for(const o of i){const m=(o.companyName||"").trim();!m||s.has(m.toLowerCase())||(s.add(m.toLowerCase()),a.push({vendorId:o.transporterData?._id||o.transporterID||o.companyId||m,companyName:m,source:o.isIndividualFtl?"IndividualFTL":o.source==="UTSF"?"UTSF":"MongoDB"}))}return a},[le,de]),[G,ue]=n.useState(null),[$e,Je]=n.useState(!1),[U,J]=n.useState(!1),[xe,ie]=n.useState({}),[ke,ma]=n.useState(()=>document.documentElement.getAttribute("data-fc-extension")==="1"),ts=n.useRef(!1),zs=n.useRef(!1),[ft,Zr]=n.useState(null),Xr=n.useRef(""),[zt]=n.useState(()=>{try{const s=sessionStorage.getItem("fc_just_signed_up")==="1";return s&&sessionStorage.removeItem("fc_just_signed_up"),s}catch{return!1}}),[cl,dl]=n.useState(zt);n.useEffect(()=>{if(!zt)return;const s=setTimeout(()=>dl(!1),3200);return()=>clearTimeout(s)},[zt]);const[ml,Ha]=n.useState(!1);n.useEffect(()=>{if(ke){Ha(!1);return}if(!G?.eligible&&!zt)return;try{if(sessionStorage.getItem("fc_ext_modal_dismissed")==="1")return}catch{}const s=zt&&!G?.eligible?1800:0,a=setTimeout(()=>Ha(!0),s);return()=>clearTimeout(a)},[G?.eligible,ke,zt]);const hl=()=>{Ha(!1);try{sessionStorage.setItem("fc_ext_modal_dismissed","1")}catch{}},[ul,Jr]=n.useState(!1);n.useEffect(()=>{if(!(!zt||!ke)){try{if(sessionStorage.getItem("fc_wheelseye_nudge_dismissed")==="1")return}catch{}Jr(!0)}},[zt,ke]);const Qa=()=>{Jr(!1);try{sessionStorage.setItem("fc_wheelseye_nudge_dismissed","1")}catch{}},Os=n.useRef(null),[Bs,xl]=n.useState(!1),[Pe,qr]=n.useState(null),[Le,en]=n.useState(null);n.useEffect(()=>{let s=!0;return Pa().then(()=>_o()).then(a=>{if(!s)return;const i=new Map;for(const o of a)i.set(o.pincode,{city:o.city,state:o.state});Os.current=i,xl(!0)}).catch(()=>{}),()=>{s=!1}},[]);const[Ws,Rt]=n.useState(void 0),[Ga,Ya]=n.useState(void 0),tn={porter:"Porter",rapido:"Rapido Bike",ola:"Ola Parcel",mover:"Mover"},nt=n.useMemo(()=>{const s={...xe};Ws&&(s.mover=Ws);const a=[],i=[];for(const[o,m]of Object.entries(s))m?.status==="ok"&&typeof m.price=="number"?a.push({platform:o,name:tn[o]||o,price:m.price,vehicleName:m.vehicleName}):(m?.status==="fetching_bg"||m?.status==="progress")&&i.push({platform:o,name:tn[o]||o});return a.sort((o,m)=>o.price-m.price),{priced:a,pending:i}},[xe,Ws]),qe=nt.priced[0]??null,pl=new Set(["porter"]),[Ks,sn]=n.useState(null),ha=(s,a,i)=>{if(pl.has(s)&&Pe?.placeText&&Le?.placeText){sn({platform:s,vehicleName:a,price:i});return}window.open(mm[s]||"https://freightcompare.ai","_blank","noopener,noreferrer")},an=n.useMemo(()=>qe?!1:nt.pending.length>0,[nt,qe]),[We,rn]=n.useState(()=>vt()?.shipmentType||"Light"),[it,Za]=n.useState(()=>vt()?.dimensionUnit||"cm");n.useEffect(()=>{wt(s=>s.map(a=>!a.count||a.count<1?{...a,count:1}:a))},[We,it]);const[nn,fl]=n.useState({}),[Ot,ln]=n.useState(null),[ua,on]=n.useState(!1),[gl,cn]=n.useState(!1),[dn,Xa]=n.useState(null),[Ja,bl]=n.useState(!1),[ct,qa]=n.useState(()=>vt()?.modeOfTransport||"Road"),[N,Us]=n.useState(()=>vt()?.fromPincode||""),[F,os]=n.useState(()=>vt()?.toPincode||"");n.useEffect(()=>{if(!N||!F){qr(null),en(null);return}const s=Os.current||new Map;qr(fs(N,s)),en(fs(F,s))},[N,F,Bs]);const[St,Hs]=n.useState(()=>{const s=vt();return s?.invoiceValue?String(s.invoiceValue):""}),[er,tr]=n.useState(null),[cs,vl]=n.useState(()=>{const s=vt();return s?.selectedCharges&&Array.isArray(s.selectedCharges)?new Set([...Mr,...s.selectedCharges]):new Set([...Mr])}),yl=s=>{Mr.has(s)||vl(a=>
71{const i=new Set(a);return i.has(s)?i.delete(s):i.add(s),i})},[mn,Qs]=n.useState(null),[hn,Gs]=n.useState(null),[ss,wl]=n.useState(!1),[as,Nl]=n.useState(!1),sr=n.useRef(!1),ar=n.useRef(!1),[pm,un]=n.useState(!1),[fm,xn]=n.useState(!1),[Mt,rr]=n.useState(!1),[nr,pn]=n.useState(null);n.useEffect(()=>{rr(!1)},[ct,We]);const[ir,jl]=n.useState(()=>{const s=vt();return s&&Array.isArray(s.lightBoxes)&&s.lightBoxes.length>0?s.lightBoxes.map(a=>({...a,count:!a.count||a.count<1?1:a.count,id:a.id||`box-l-${Date.now()}-${Math.random()}`})):s&&s.shipmentType==="Light"&&Array.isArray(s.boxes)&&s.boxes.length>0?s.boxes.map(a=>({...a,id:a.id||`box-l-${Date.now()}-${Math.random()}`})):[{id:`box-l-${Date.now()}-${Math.random()}`,count:1,weight:void 0,description:""}]}),[lr,kl]=n.useState(()=>{const s=vt();return s&&Array.isArray(s.heavyBoxes)&&s.heavyBoxes.length>0?s.heavyBoxes.map(a=>({...a,count:!a.count||a.count<1?1:a.count,id:a.id||`box-h-${Date.now()}-${Math.random()}`})):s&&s.shipmentType==="Heavy"&&Array.isArray(s.boxes)&&s.boxes.length>0?s.boxes.map(a=>({...a,id:a.id||`box-h-${Date.now()}-${Math.random()}`})):[{id:`box-h-${Date.now()}-${Math.random()}`,count:1,weight:void 0,description:""}]}),V=We==="Light"?ir:lr,[Cl,fn]=n.useState(!1);n.useEffect(()=>{const s=h();s&&(s.averageLoadInDispatch||s.monthlyOrder)&&localStorage.setItem("pkg_spec_filled","true")},[t]);const Sl=async s=>{try{if((await Lt.put("/api/auth/profile/specs",s)).data?.success){me.success("Preferences saved! Your experience is now tailored."),localStorage.setItem("pkg_spec_filled","true");try{const i=localStorage.getItem("authUser");if(i){const o=JSON.parse(i),m=o?.customer||o;Object.assign(m,s),localStorage.setItem("authUser",JSON.stringify(o))}}catch{}}}catch(a){console.error("Failed to save package specs:",a),me.error("Couldn't save preferences, but you can continue.")}},wt=s=>{We==="Light"?jl(s):kl(s)},[Ut,Tl]=n.useState({}),[rs,Et]=n.useState({}),[Pl,gn]=n.useState({}),At=(s,a)=>{Tl(i=>({...i,[s]:{...i[s],[a]:!0}}))},[bn,vn]=n.useState(!1),js=n.useRef(null),[Ht,xa]=n.useState(null),[gm,or]=n.useState(!1);n.useEffect(()=>{if(!(N.length===6&&F.length===6&&ss&&as)){xa(null),or(!1);return}const s=new AbortController,a=setTimeout(async()=>{or(!0);try{const i=await Lt.post("/api/vendor/wheelseye-distance",{origin:N,destination:F,fromPincode:N,toPincode:F,originPincode:N,destinationPincode:F},{signal:s.signal}),o=i?.data?.distanceKm??i?.data?.distance??i?.data?.data?.distanceKm??null;typeof o=="number"&&Number.isFinite(o)?xa(Math.round(o)):xa(null)}catch(i){if(i?.name==="CanceledError"||i?.name==="AbortError")return;console.warn("[LiveDistance] backend lookup failed:",i?.message),xa(null)}finally{or(!1)}},400);return()=>{clearTimeout(a),s.abort()}},[N,F,ss,as]);const Ll=()=>{try{uc(),me.success("Template downloaded successfully")}catch(s){console.error("Failed to generate template:",s),me.error("Failed to download template")}},Il=async s=>{const a=s.target.files?.[0];if(a){if(!xc(a)){me.error("Please upload a valid Excel file (.xlsx or .xls)"),js.current&&(js.current.value="");return}vn(!0);try{const i=await pc(a);if(i.length===0){me.error("No valid boxes found in the file");return}const o=i.map(m=>({id:`box-${Date.now()}-${Math.random()}`,description:m.name,count:m.quantity||1,weight:m.weight,length:m.length,width:m.width,height:m.height}));wt(m=>m.length===1&&!m[0].description&&!m[0].weight?o:[...m,...o]),me.success(`Imported ${o.length} boxes from Excel`)}catch(i){console.error("Excel upload error:",i),me.error(i.message||"Failed to parse Excel file")}finally{vn(!1),js.current&&(js.current.value="")}}},[yn,El]=n.useState("all"),[pa,Fl]=n.useState([]),[_t,ks]=n.useState(null),[cr,Ys]=n.useState(""),fa=n.useRef([]),wn=n.useRef(null),Nn=n.useRef(null),ns=n.useRef(null),dr=n.useRef([]),jn=n.useRef(null),kn=n.useRef(null),[Cn,Rl]=n.useState({}),[ga,Sn]=n.useState(()=>vt()?.minPrice??0),[ba,mr]=n.useState(()=>vt()?.maxPrice??1e7),[Zs,Xs]=n.useState(()=>vt()?.minTime??0),[Cs,Js]=n.useState(()=>vt()?.maxTime??300),[va,hr]=n.useState(()=>Math.max(vt()?.minRating??2,2)),[Ml,Tn]=n.useState(null),[Pn,ur]=n.useState(!1),[ds,Ln]=n.useState({isOpen:!1,vendorId:"",vendorName:"",isTemporaryVendor:!1,vendorType:"regular"});n.useEffect(()=>{if(!le&&!de)return;const s=[...le||[],...de||[]].filter(o=>{const m=Ne(o);return Number.isFinite(m)&&m>0&&o?.message!=="service not available"}),a=s.map(o=>o.estimatedTime??0).filter(o=>o>0&&o<300);if(a.length>0){const o=Ht??le?.[0]?.distanceKm??0,m=Vr(o)?Math.min(Ft[0],...a):Math.min(...a);Xs(m),Js(Math.max(...a))}const i=s.map(o=>Ne(o)).filter(o=>Number.isFinite(o)&&o>0);i.length>0&&mr(Math.max(...i))},[le]);const In=s=>{Ln({isOpen:!0,...s})},Al=()=>{Ln(s=>({...s,isOpen:!1}))},[_l,En]=n.useState([]);n.useEffect(()=>{const s=h()?._id||"guest",a=localStorage.getItem(`freight_recent_routes_${s}`);if(a)try{En(JSON.parse(a))}catch(i){console.error("Failed to parse recent routes:",i)}},[t]);const xr=()=>{if(!N||!F)return;const a=[{id:Date.now().toString(),fromPincode:N,toPincode:F,invoiceValue:St||"50000",timestamp:Date.now()},..._l].filter((o,m,p)=>m===p.findIndex(A=>A.fromPincode===o.fromPincode&&A.toPincode===o.toPincode)).slice(0,4);En(a);const i=h()?._id||"guest";localStorage.setItem(`freight_recent_routes_${i}`,JSON.stringify(a))};n.useMemo(()=>V.some(s=>(s.length??0)>Ar||(s.width??0)>_r||(s.height??0)>$r||(s.count??0)>As||(s.weight??0)>im),[V]);const qs=V.reduce((s,a)=>s+(a.weight||0)*(a.count||0),0),Fn=We==="Light"?Math.ceil(V.reduce((s,a)=>{const i=it==="inch"?2.54:1,o=(a.length||0)*i,m=(a.width||0)*i,p=(a.height||0)*i;return s+o*m*p*(a.count||0)},0)/5e3):0,ms=V.reduce((s,a)=>s+(a.weight||0)*(a.count||0),0),ee=Math.max(ms,Fn),Ss=n.useRef(ee);n.useEffect(()=>{Ss.current=ee},[ee]);const Rn=n.useRef(G);n.useEffect(()=>{Rn.current=G},[G]);const Mn=V.reduce((s,a)=>
71s+(a.count||0),0),is=n.useMemo(()=>{if(!le||le.length===0)return null;const s=!!de&&de.length>0,a=nt.priced.length>0;if(!s&&!a)return null;const i=le.map(O=>Ne(O)).filter(O=>Number.isFinite(O)&&O>0);if(!i.length)return null;const o=Math.min(...i),m=ft?.status!=="ok"||!ft.vehicles?.length?[]:ft.vehicles.filter(ge=>Number.isFinite(ge.price)).filter(ge=>{const ye=Yt(ge.name,ge.weightLabel);return ye!=null&&ye>=ee-1}),p=m.length?[...m].sort((O,ge)=>O.price-ge.price)[0].price:null,A=h(),Y=l||Oa({isAdmin:A?.isAdmin,isSubscribed:A?.isSubscribed}),pe=["local ftl","wheelseye ftl","indiapost"];let se=null;const fe=(O,ge,ye,Ze="market")=>{!Number.isFinite(O)||O<=0||(!se||O<se.price)&&(se={price:O,name:ge,masked:ye,source:Ze})};for(const O of de||[]){const ge=String(O.companyName||O.transporterName||""),ye=pe.includes(ge.trim().toLowerCase()),Ze=!!O.isMoverLive;let ze=Ne(O);const et=Math.abs((Number(O.chargeableWeight)||0)-ee)<1;ge==="Wheelseye FTL"&&p!=null&&et&&(ze=p),fe(ze,ge,(!Y||!!O.isHidden)&&!ye&&!Ze,"market")}const te=Ga;ee>200&&te?.status==="ok"&&Number.isFinite(te.price)&&Array.isArray(te.options)&&te.options.length&&fe(te.price,"Porter",!1,"market");for(const O of nt.priced)fe(O.price,O.name,!1,"quickbooking");const he=se;return!he||he.price>=o?null:{...he,bestOwn:o,savings:o-he.price}},[le,de,ft,Ga,ee,l,nt]),An=pa.filter(s=>s.name.toLowerCase().includes(cr.toLowerCase())),$l=N.length===6&&F.length===6&&N===F,Ts=!!mn||!!hn||!ss||!as,Ps=n.useMemo(()=>V.some(s=>!s.count||s.count<=0||!s.weight||s.weight<=0),[V]);n.useEffect(()=>{H&&!Ps&&!Ts&&Z("")},[V,Ps,Ts]),n.useEffect(()=>{if(ke)return;const s=()=>ma(!0);return window.addEventListener("fc-extension-ready",s,{once:!0}),()=>window.removeEventListener("fc-extension-ready",s)},[ke]),n.useEffect(()=>{const s=a=>{if(a.data?.__fc_ext_reply__){if(a.data.type==="FC_PRICE_RESPONSE"&&ie(i=>{const o={...i};for(const[m,p]of Object.entries(a.data.prices||{}))i[m]?.status==="ok"&&p?.status!=="ok"||(o[m]=p?.status==="ok"?{...p,fetchedAt:Date.now()}:p);return o}),a.data.type==="FC_PRICE_UPDATE"){if(console.log(`[FC][UI] FC_PRICE_UPDATE received: platform=${a.data.platform} status=${a.data.price?.status} price=${a.data.price?.price} vehicleName=${a.data.price?.vehicleName} respWeight=${a.data.weight} currentWeightRef=${Ss.current} from=${a.data.from}(page:${N}) to=${a.data.to}(page:${F})`),a.data.from&&(a.data.from!==N||a.data.to!==F)){console.log("[FC][UI] FC_PRICE_UPDATE discarded: route mismatch");return}if(a.data.platform==="porter"&&a.data.weight!=null){const p=Number(a.data.weight);if(Number.isFinite(p)&&Math.abs(p-Ss.current)>1){console.log(`[FC][UI] FC_PRICE_UPDATE discarded: porter weight mismatch — response was for ${p}kg, page is now at ${Ss.current}kg`);return}}const i=a.data.price?.status==="ok"?{...a.data.price,fetchedAt:Date.now()}:a.data.price,m=[...new Set((Rn.current?.eligiblePlatforms||[]).map(p=>p.id))].some(p=>typeof p=="string"&&p.startsWith("porter_"));if(a.data.platform==="porter"&&!m){console.log(`[FC][UI] FC_PRICE_UPDATE routed to porterFtlPrice (weight=${Ss.current}kg not Quick-Booking-eligible for Porter): status=${i?.status} price=${i?.price}`),Ya(p=>p?.status==="ok"&&i?.status!=="ok"?p:i);return}console.log(`[FC][UI] FC_PRICE_UPDATE routed to qbExtPrices[${a.data.platform}]: status=${i?.status} price=${i?.price}`),ie(p=>p[a.data.platform]?.status==="ok"&&a.data.price?.status!=="ok"?p:{...p,[a.data.platform]:i})}if(a.data.type==="WHEELSEYE_PRICE_RESPONSE"){if(a.data.fromPincode!=null||a.data.toPincode!=null||a.data.tonnage!=null){if(a.data.fromPincode!==N||a.data.toPincode!==F)return;const i=Math.max(.1,Ss.current/1e3);if(Number.isFinite(a.data.tonnage)&&Math.abs(a.data.tonnage-i)>.01)return}Zr({...a.data,fetchedAt:Date.now()})}}};return window.addEventListener("message",s),()=>window.removeEventListener("message",s)},[N,F]),n.useEffect(()=>{if(!N||!F)return;const s=Ho(N,F,ee);if(s){ie(s);for(const a of Object.keys(s))a==="porter"&&(ts.current=!0),a==="rapido"&&(zs.current=!0)}},[]),n.useEffect(()=>{!N||!F||Qo(N,F,ee,xe)},[xe,N,F,ee]),n.useEffect(()=>{if(!ke||!N||!F||!le&&!de||!Pe?.placeText||!Le?.placeText||z!=="results")return;const s=`${N}-${F}-${ee}`;if(Xr.current===s)return;Xr.current=s,Zr(null);const a=Math.max(.1,ee/1e3);window.postMessage({type:"WHEELSEYE_PRICE_REQUEST",fromPincode:N,toPincode:F,tonnage:a},"*")},[ke,N,F,le,de,Pe,Le,ee,z]),n.useEffect(()=>{if(!ke||!G?.eligible||!N||!F||!Pe?.placeText||!Le?.placeText||z!=="results")return;const s=le?.[0]?.distanceKm??G?.distanceKm??0;window.postMessage({type:"FC_PRICE_REQUEST",from:N,to:F,weight:ee,distance:s},"*")},[ke,G?.eligible,N,F,Pe,Le,ee,le,z]);const _n=n.useRef("");n.useEffect(()=>{if(U||!G?.eligible||!N||!F||!le&&!de||z!=="results"||Ws!==void 0)return;const s=`${N}-${F}-${ee}`;_n.current!==s&&(_n.current=s,(async()=>{try{Rt({status:"fetching_bg"}),await Pa();const a=Os.current||new Map,i=fs(N,a),o=fs(F,a);if(i.lat==null||i.lng==null||o.lat==null||o.lng==null){Rt(void 0);return}const m=await Sr({fromAddress:i.placeText,fromLat:i.lat,fromLng:i.lng,toAddress:o.placeText,toLat:o.lat,toLng:o.lng}),p=m?Ta(m,Math.max(1,ee),{bikeToleranceFactor:1.1}):null,A=p?p.distanceMeters/1e3:1/0;Rt(p&&A<=60?{status:"ok",price:p.amount,vehicleName:`${p.name} · rated ${p.capacityKg} kg`}:void 0)}catch{Rt(void 0)}})())},[U,G,N,F,le,de,Ws,ee,z]),n.useEffect(()=>{if(!ke||!G?.eligible||!Pe?.placeText||!Le?.placeText||z!=="results"||!Bs)return;const s=Math.max(0,...V.flatMap(A=>[Number(A.length)||0,Number(A.width)||0,Number(A.height)||0])),a=Tr(ee,s||null);le?.[0]?.distanceKm??G?.distanceKm;const i=new Set((G?.eligiblePlatforms||[]).map(A=>A.id)),o=i.has("rapido"),m=i.has("porter_bike")||i.has("porter_3w")||i.has("porter_minitruck"),p=A=>{window.postMessage({type:"FC_OPEN_PLATFORM",platform:A,from:N,to:F,fromText:Pe.placeText,toText:Le.placeText,fromLat:Pe.lat,fromLng:Pe.lng,toLat:Le.lat,toLng:Le.lng,fromCity:Pe.city,toCity:Le.city,weight:ee,vehicleClass:a,autoFill:!0},"*")};xe.porter?.status==="fetching_bg"&&!ts.current&&(ts.current=!0,m?p("porter"):ie(A=>({...A,porter:{status:"not_applicable"}}))),xe.rapido?.status==="fetching_bg"&&!zs.current&&(zs.current=!0,o?p("rapido"):ie(A=>({...A,rapido:{status:"not_applicable"}})))},[ke,G,Pe,Le,xe,N,F,ee,le,Bs,z]);const pr=n.useRef("");n.useEffect(()=>{if(!ke||!N||!F||N===F||!le&&!de||!Pe?.placeText||!Le?.placeText||z!=="results"||!Bs||ee<=200||ee>7e3)return;const s=`${N}-${F}-${ee}`;pr.current!==s&&(pr.current=s,Ya({status:"fetching_bg"}),window.postMessage({type:"FC_OPEN_PLATFORM",platform:"porter",from:N,to:F,fromText:Pe.placeText,toText:Le.placeText,fromLat:Pe.lat,fromLng:Pe.lng,toLat:Le.lat,toLng:Le.lng,fromCity:Pe.city,toCity:Le.city,weight:ee,vehicleClass:"minitruck",autoFill:!0},"*"))},[ke,N,F,le,de,Pe,Le,ee,G,Bs,z]);const $n=Rs.useRef(!1);n.useEffect(()=>{if($n.current)return;const s=h()?.pincode;s&&(N===""||N==null)&&(Us(String(s)),$n.current=!0)},[t]),n.useEffect(()=>{Go();const s=window.requestIdleCallback?window.requestIdleCallback(()=>ti()):window.setTimeout(()=>ti(),1500);return()=>{window.cancelIdleCallback?window.cancelIdleCallback(s):window.clearTimeout(s)}},[]),n.useEffect(()=>{Yo({fromPincode:N,toPincode:F,modeOfTransport:ct,shipmentType:We,lightBoxes:ir,heavyBoxes:lr,boxes:V,dimensionUnit:it,invoiceValue:St?Number(St):null,selectedCharges:Array.from(cs),sortBy:R,minPrice:ga,maxPrice:ba,minTime:Zs,maxTime:Cs,minRating:va})},[N,F,ct,We,ir,lr,V,it,St,cs,R,ga,ba,Zs,Cs,va]),n.useEffect(()=>{const s=Zo();if(s){const a=Xo(s);if(a&&a.data&&a.hiddendata){const i=St?Number(St):1,o={modeoftransport:ct,fromPincode:N,toPincode:F,shipment_details:V.map(p=>{let A=Number(p.length||1),Y=Number(p.width||1),pe=Number(p.height||1);return it==="inch"&&(A=A*2.54,Y=Y*2.54,pe=pe*2.54),{count:p.count||1,length:A,width:Y,height:pe,weight:p.weight||0}}),optionalCharges:Array.from(cs).sort(),invoiceValue:i||0};if(qn(o)===s){console.log("[Cache] Restoring results from session storage"),Ue(a.data),rt(a.hiddendata),a.form?.smartShield&&Xa(a.form.smartShield),ne("results");const p=a.data?.[0]?.distanceKm??a.hiddendata?.[0]?.distanceKm??0;ue(zi(p,V)),(async()=>{try{const A=await si({fromPincode:N,toPincode:F,chargeableWeight:ee});if(A.length===0)return;const Y=h()?._id?String(h()._id):"";rt(pe=>{const se=Array.isArray(pe)?pe.slice():[],fe=new Set(se.map(te=>te.companyId));return A.forEach(te=>{const he=`individual-ftl-${te.id}`;if(fe.has(he))return;const O=!!Y&&!!te.createdBy&&String(te.createdBy)===Y;se.unshift({source:"individual_ftl",companyName:te.transporterName,companyId:he,totalCharges:te.charge,price:te.charge,total:te.charge,totalPrice:te.charge,currency:"INR",vehicle:te.vehicleType,isSpecialVendor:!0,isTiedUp:O,isIndividualFtl:!0,contactNumber:te.contactNumber,ratedCapacityKg:te.maxCapacityKg,chargeableWeight:ee,originPincode:te.originPincode,destinationPincode:te.destinationPincode,estimatedTime:1,estimatedDelivery:"Same day",deliveryTime:"Same day",liveFetchedAt:Date.now(),liveSourceLabel:"Individual FTL Transporter (marketplace listing)"})}),se})}catch{}})()}}}},[]),n.useEffect(()=>{if(!le&&!de)return;const s=async()=>{try{console.log("[Real-time Sync] Fetching all transporters...");const i=await Wo(void 0);console.log("[Real-time Sync] Temporary vendors:",i.length);const o={};
71i.forEach(m=>{if(m.companyName&&m.approvalStatus){const p=m.companyName.trim().toLowerCase();o[p]={approvalStatus:m.approvalStatus,isVerified:m.isVerified===!0}}}),fl(o),console.log("[Real-time Sync] Total vendor statuses updated:",Object.keys(o).length),console.log("[Real-time Sync] Status map:",o)}catch(i){console.warn("[Real-time Sync] Failed to fetch vendor statuses:",i)}};s();const a=setInterval(s,3e4);return()=>clearInterval(a)},[le,de]),n.useEffect(()=>{const s=a=>{_t!==null&&fa.current[_t]&&!fa.current[_t].contains(a.target)&&!wn.current?.contains(a.target)&&ks(null)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[_t]),n.useEffect(()=>{if(_t===null)return;let s;const a=()=>{const i=fa.current[_t],o=Nn.current;if(i&&o){const m=i.getBoundingClientRect();o.style.top=`${m.bottom+2}px`,o.style.left=`${m.left}px`,o.style.width=`${m.width}px`}s=requestAnimationFrame(a)};return s=requestAnimationFrame(a),()=>cancelAnimationFrame(s)},[_t]),n.useEffect(()=>{r||gr()},[r,t?._id,u]),n.useEffect(()=>{N.length===6&&ss&&!sr.current&&(Qs(null),sr.current=!0),(N.length!==6||!ss)&&(sr.current=!1)},[N,ss]),n.useEffect(()=>{F.length===6&&as&&!ar.current&&(Gs(null),ar.current=!0),(F.length!==6||!as)&&(ar.current=!1)},[F,as]);const hs=()=>({id:`box-${Date.now()}-${Math.random()}`,count:1,weight:void 0,description:""}),fr=()=>wt(s=>[...s,hs()]),ya=s=>!(!s.count||s.count<=0||!s.weight||s.weight<=0),wa=s=>{(!s.count||s.count<=0)&&At(s.id,"count"),(!s.weight||s.weight<=0)&&At(s.id,"weight")};n.useEffect(()=>{const s=setTimeout(()=>{const a=V.length-1,i=jn.current,o=a>=0?dr.current[a]:null;i&&o&&i.scrollHeight>i.clientHeight&&o.scrollIntoView({behavior:"smooth",block:"end"})},100);return()=>clearTimeout(s)},[V.length]),n.useEffect(()=>{if(nr){const{field:s,index:a}=nr,i=document.getElementById(`${s}-${a}`);i&&(i.focus(),i.select(),pn(null))}},[V.length,nr]);const ve=(s,a,i)=>{wt(o=>{const m=[...o];return m[s]={...m[s],[a]:i},m})},Na=s=>{V.length<=1||(wt(V.filter((a,i)=>i!==s)),El("all"))},Dl=s=>{const a=dr.current[s];a&&a.scrollIntoView({behavior:"smooth",block:"center"})},gr=async()=>{if(!t)return;const s=t?.customer?._id;let a=[];if(s)try{const A=(await Lt.get(`/api/transporter/getpackinglist?customerId=${s}`)).data?.data;Array.isArray(A)&&(a=A)}catch(p){console.error("Failed to fetch old presets:",p?.message)}let i=[];try{i=(await $o()).flatMap(A=>A.boxes.map(Y=>({_id:Y._id||`${A._id}-${Y.name}`,name:Y.name,weight:Y.weight,length:Y.length,width:Y.width,height:Y.height,quantity:Y.quantity,noofboxes:Y.quantity,originPincode:0,destinationPincode:0,modeoftransport:"Road",dimensionUnit:"cm"})))}catch(p){console.error("Failed to fetch box libraries:",p?.message)}const o=new Set,m=[];for(const p of[...a,...i])o.has(p._id)||(o.add(p._id),m.push(p));Fl(m)},Vl=async(s,a)=>{if(a.stopPropagation(),window.confirm("Delete this preset permanently?"))try{await Lt.delete(`/api/transporter/deletepackinglist/${s}`,{headers:{Authorization:`Bearer ${u}`}}),await gr()}catch(i){console.error("Failed to delete preset:",i),Z(`Could not delete preset: ${i.response?.data?.message||i.message}`)}},zl=(s,a)=>{const i=[...V];i[s]={...i[s],length:a.length,width:a.width,height:a.height,weight:a.weight,description:a.name,count:1},wt(i),gn(o=>({...o,[i[s].id]:a.name})),a.dimensionUnit&&Za(a.dimensionUnit),s===0&&((!N||N.trim()==="")&&Us(a.originPincode.toString()),qa(a.modeoftransport)),ks(null),Ys("")},gt=(s,a,i)=>{const o=s.target,m=V.length,A=(We==="Heavy"?["preset","count","weight"]:["preset","length","width","height","count","weight"]).filter(se=>document.getElementById(`${se}-${a}`)!==null),Y=(se,fe)=>{const te=document.getElementById(`${se}-${fe}`);te&&(te.focus(),te.select())},pe=(se,fe)=>{const te=V[se];te&&(ya(te)?(pn({field:fe,index:se+1}),fr()):wa(te))};if(s.key==="Enter"){s.preventDefault(),s.stopPropagation();const se=A.indexOf(i);if(se>=0&&se<A.length-1)Y(A[se+1],a);else{const fe=V[a];
71fe&&!ya(fe)?wa(fe):a<m-1?Y(A[0],a+1):pe(a,A[0])}}else if(s.key==="ArrowDown")s.preventDefault(),a<m-1?Y(i,a+1):pe(a,i);else if(s.key==="ArrowUp")a>0&&(s.preventDefault(),Y(i,a-1));else if(s.key==="ArrowLeft"){if(o.selectionStart===0&&o.selectionEnd===0){s.preventDefault();const se=A.indexOf(i);se>0?Y(A[se-1],a):a>0&&Y(A[A.length-1],a-1)}}else if(s.key==="ArrowRight"){const se=o.value.length;if(o.selectionStart===se&&o.selectionEnd===se){s.preventDefault();const fe=A.indexOf(i);fe>=0&&fe<A.length-1?Y(A[fe+1],a):a<m-1&&Y(A[0],a+1)}}else if(s.key==="Backspace"&&o.value===""){s.preventDefault();const se=A.indexOf(i);se>0?Y(A[se-1],a):a>0&&Y(A[A.length-1],a-1)}},Ol=s=>s?/^\d{6}$/.test(s)?/^[1-9]\d{5}$/.test(s)?null:"Pincode cannot start with 0.":"Enter a 6-digit pincode.":"Pincode is required.",Dn=async s=>{const a=s==="from"?N:F,i=s==="from"?Qs:Gs,o=Ol(a);return o?(i(o),!1):(i(null),!0)},ea=(s,a)=>Rl(i=>({...i,[s]:a})),Vn=async s=>{const a=V[s],i=a.id,o=(a.description||"").trim();if(!o){Z("Please enter a Box Name before saving.");return}const m=We==="Light";if(!a.weight||m&&(!a.length||!a.width||!a.height)){Z(m?"Please fill in all dimensions and weight for the box before saving.":"Please fill in weight for the box before saving."),Dl(s);return}if(!N||N.length!==6||!F||F.length!==6){Z("Please enter valid 6-digit Origin and Destination pincodes before saving a preset.");return}if(!ss||!as){Z("Selected pincodes are not serviceable.");return}if(!t){Z("You are not authenticated. Please log in again.");return}const p=h()?._id;if(!p){Z("Unable to identify user. Please log in again.");return}const A=he=>Number(he.length??0)===Number(a.length??0)&&Number(he.width??0)===Number(a.width??0)&&Number(he.height??0)===Number(a.height??0)&&Number(he.weight)===Number(a.weight),Y=pa.find(he=>he.name.toLowerCase()===o.toLowerCase()),pe=Pl[i],se=!!pe&&pe.toLowerCase()===o.toLowerCase();let fe=null;if(Y)if(se||A(Y))fe=Y._id;else{if(!window.confirm(`A box named "${o}" already exists with different details. Overwrite it?`))return;fe=Y._id}else{const he=pa.find(A);if(he&&!window.confirm(`A similar box ("${he.name}") with the same dimensions and weight already exists. Save "${o}" as a new box anyway?`))return}Z(null),ea(i,"saving");const te={name:o,description:o,customerId:p,originPincode:Number(N),destinationPincode:Number(F),length:a.length??0,width:a.width??0,height:a.height??0,weight:a.weight,modeoftransport:ct,noofboxes:a.count||1,quantity:a.count||1,dimensionUnit:it};try{if(fe)try{await Lt.delete(`/api/transporter/deletepackinglist/${fe}`,{headers:{Authorization:`Bearer ${u}`}})}catch(he){console.error("Failed to remove old preset before overwrite:",he)}await Lt.post("/api/transporter/savepackinglist",te),gn(he=>({...he,[i]:o})),ea(i,"success"),await gr(),setTimeout(()=>ea(i,"idle"),1200)}catch(he){console.error("Failed to save preset:",he),Z(`Could not save preset: ${he.response?.data?.message||he.message}`),ea(i,"error"),setTimeout(()=>ea(i,"idle"),1600)}},Bl=s=>JSON.stringify({f:N,t:s||F,m:ct,st:We,du:it,b:V.map(a=>`${a.count}|${a.weight}|${a.length}|${a.width}|${a.height}`).join(","),inv:St,ch:Array.from(cs).sort().join(",")}),Bt=async(s,a)=>{if(T)return;if(!a&&!Ls.current&&h()&&!(localStorage.getItem("pkg_spec_filled")==="true")){const p=parseInt(localStorage.getItem("pkg_spec_search_count")||"0")+1;localStorage.setItem("pkg_spec_search_count",String(p));const A=parseInt(localStorage.getItem("pkg_spec_last_shown")||"-3");p-A>=3&&(localStorage.setItem("pkg_spec_last_shown",String(p)),fn(!0))}const i=Bl(s);if(!s&&!a&&i===Me.current&&le!==null&&(le.length>0||(de?.length??0)>0)){z!=="results"&&(Se(!0),setTimeout(()=>{ne("results"),Se(!1)},210)),window.scrollTo({top:0,behavior:"instant"});return}if(!a&&(Id(),Ed()||Fd(Q.length,!!h()?.preferredVendor?.vendorId))){Ye(!0);return}if(!s){const[m,p]=await Promise.all([Dn("from"),Dn("to")]);if(rr(!0),!m||!p)return}if($l&&!s){J(!0),Ue(null),rt(null),Z(null),Oe(null),ue(null),ie({}),Rt(void 0),Ya(void 0),pr.current="",ts.current=!1,zs.current=!1,Je(!0),(async()=>{try{const m=await Lt.post("/api/quick-booking/eligibility",{fromPincode:N,toPincode:F,shipment_details:V.filter(p=>p.count&&p.weight).map(p=>({count:p.count,weight:p.weight,length:p.length||0,width:p.width||0,height:p.height||0}))});ue(m.data?.data||m.data)}catch{}finally{Je(!1)}})(),(async()=>{try{Rt({status:"fetching_bg"}),await Pa();const m=Os.current||new Map,p=fs(N,m);if(p.lat==null||p.lng==null){Rt(void 0);return}const A=await Sr({fromAddress:p.placeText,fromLat:p.lat,fromLng:p.lng,toAddress:p.placeText,toLat:p.lat,toLng:p.lng}),Y=A?Ta(A,Math.max(1,ee),{bikeToleranceFactor:1.1}):null;Rt(Y?{status:"ok",price:Y.amount,vehicleName:`${Y.name} · rated ${Y.capacityKg} kg`}:void 0)}catch{Rt(void 0)}})(),z!=="results"&&(Se(!0),setTimeout(()=>{ne("results"),Se(!1)},210)),window.scrollTo({top:0,behavior:"smooth"});return}J(!1),ue(null),ie({}),Rt(void 0),ts.current=!1,zs.current=!1,Je(!0);const o=s||F;(async()=>{try{const m=await Lt.post("/api/quick-booking/eligibility",{fromPincode:N,toPincode:o,shipment_details:V.filter(p=>p.count&&p.weight).map(p=>({count:p.count,weight:p.weight,length:p.length||0,width:p.width||0,height:p.height||0}))});ue(m.data?.data||m.data)}catch{}finally{Je(!1)}})();try{rr(!0),I(!0),Z(null),ae(!1),Oe(null),s||He(null),K(!1),z!=="results"&&(Se(!0),setTimeout(()=>{ne("results"),Se(!1)},210)),window.scrollTo({top:0,behavior:"smooth"});let m=[...V];for(;m.length>1;){const v=m[m.length-1];if(!v.description?.trim()&&(!v.count||v.count===1)&&!v.weight&&!v.length&&!v.width&&!v.height)m.pop();else break}m.length!==V.length&&wt(m);const p=yn==="all"?m:[m[yn]],A=[];for(const v of p)if(We==="Heavy"){if(!v.count||!v.weight){const be=v.description||`Box Type ${V.indexOf(v)+1}`;throw new Error(`Please fill in Qty and Weight for "${be}".`)}A.push({count:v.count,length:1,width:1,height:1,weight:v.weight})}else{if(!v.count||!v.weight){const dt=v.description||`Box Type ${V.indexOf(v)+1}`;throw new Error(`Please fill in Qty and Weight for "${dt}".`)}let be=Number(v.length)||1,we=Number(v.width)||1,Ce=Number(v.height)||1;it==="inch"&&(be=be*2.54,we=we*2.54,Ce=Ce*2.54),A.push({count:v.count,length:be,width:we,height:Ce,weight:v.weight})}let Y=oa;if(St.trim()!==""){if(Y=Number(St),!Number.isFinite(Y))throw new Error("Invoice value must be a number");if(Y<oa)throw new Error(`Minimum invoice value is ₹${oa}`);if(Y>bs)throw new Error(`Maximum invoice value is ₹${bs.toLocaleStr
71ing("en-IN")} (10 crores)`)}const pe=s||F,se={modeoftransport:ct,fromPincode:N,toPincode:pe,shipment_details:A,optionalCharges:Array.from(cs||[]).sort(),invoiceValue:Y||0},fe=qn(se),te=v=>{const be=Number(v?.estimatedTime??v?.est_time??v?.transitDays??v?.eta??0),we=Math.max(1,Math.ceil(Number.isFinite(be)?be:0));return{...v,estimatedTime:we}},he=performance.now(),O=a||qt,ge=h(),ye=await Lt.post("/api/transporter/calculate",{customerID:ge?._id,userogpincode:ge?.pincode,modeoftransport:ct,fromPincode:N,toPincode:pe,shipment_details:A,shipmentType:We,invoiceValue:Y,optionalCharges:Array.from(cs||[])},{timeout:9e4,headers:{...u?{Authorization:`Bearer ${u}`}:{},...O?{"x-captcha-token":O}:{}}}),Ze=ye.headers["x-ratelimit-remaining"];if(Ze!==void 0&&Te(parseInt(Ze,10)),ye.data.error==="NO_ROUTE_FOUND"||ye.data.error==="NO_ROAD_ROUTE")throw new Error(`No road route exists between ${N} and ${pe}.`);if(ye.data.error==="CALCULATION_FAILED")throw new Error(`Unable to calculate distance between ${N} and ${pe}.`);const ze=ye.data.distanceKm||0;console.log(`[PERF] Calculate API: ${ye.data.debug?.processingTimeMs||"N/A"}ms, distance: ${ze}km`),ue(zi(ze,V)),console.log("[VENDOR-TRACE FE] ══ RAW API RESPONSE ════════════════════════════"),console.log("[VENDOR-TRACE FE] debug:",ye.data.debug),console.log(`[VENDOR-TRACE FE] tiedUpResult count: ${(ye.data.tiedUpResult||[]).length}`),(ye.data.tiedUpResult||[]).forEach(v=>{console.log(`[VENDOR-TRACE FE]   TIED: "${v.companyName}" | isTiedUp=${v.isTiedUp} | isCustomerVendor=${v.isCustomerVendor} | customerID=${v.customerID} | totalCharges=${v.totalCharges} | source=${v.source||"mongodb"} | approvalStatus=${v.approvalStatus}`)}),console.log(`[VENDOR-TRACE FE] companyResult count: ${(ye.data.companyResult||[]).length}`),(ye.data.companyResult||[]).forEach(v=>{console.log(`[VENDOR-TRACE FE]   OTHER: "${v.companyName}" | isHidden=${v.isHidden} | isTiedUp=${v.isTiedUp} | isCustomerVendor=${v.isCustomerVendor} | source=${v.source||"mongodb"}`)}),console.log("[VENDOR-TRACE FE] ═════════════════════════════════════════════════");const et=[...(ye.data.tiedUpResult||[]).map(v=>({...v,isTiedUp:typeof v.isTiedUp=="boolean"?v.isTiedUp:!0,approvalStatus:v.transporterData?.approvalStatus||v.approvalStatus})),...(ye.data.companyResult||[]).map(v=>({...v,isTiedUp:!1,approvalStatus:v.transporterData?.approvalStatus||v.approvalStatus}))];ze>0&&et.forEach(v=>{v.distanceKm=ze,v.distance=`${Math.round(ze)} km`});const Nt=et.filter(v=>(v.companyName||"").trim().toLowerCase()!=="dp world"),jt=et.filter(v=>(v.companyName||"").trim().toLowerCase()==="dp world"),je=jt.length>0?jt.reduce((v,be)=>be.totalCharges<v.totalCharges?be:v):null;let Xe=[...Nt.filter(v=>v.isTiedUp)],Ke=[...Nt.filter(v=>!v.isTiedUp)||[],...je?[{...je,isTiedUp:!1}]:[]];console.log(`[VENDOR-TRACE FE] After isTiedUp split: tied=${Xe.length} others=${Ke.length}`),Xe.forEach(v=>console.log(`[VENDOR-TRACE FE]   tied: "${v.companyName}" | isTiedUp=${v.isTiedUp} | isCustomerVendor=${v.isCustomerVendor} | customerID=${v.customerID}`));const{ftlQuote:Qt,wheelseyeQuote:Is,numbers:$}=await lc({fromPincode:N,toPincode:pe,shipment:A,totalWeight:qs,token:u,isWheelseyeServiceArea:v=>/^\d{6}$/.test(v),distanceKmOverride:ze});if(!et.some(v=>v.source==="indiapost"||(v.companyName||"").toLowerCase()==="indiapost"))try{const v=await am({fromPincode:N,toPincode:pe,shipment:A,totalWeight:qs,token:u,distanceKmOverride:ze});v&&Ke.push({...v,isSpecialVendor:!0})}catch(v){console.warn("[IndiaPost] Fallback failed:",v)}Qt&&Ke.unshift({...Qt,isSpecialVendor:!0}),Is&&Ke.unshift({...Is,isSpecialVendor:!0});try{const v=await fetch(`/api/uber/quote?fromPincode=${encodeURIComponent(N)}&toPincode=${encodeURIComponent(pe)}`);if(v.ok){const be=await v.json();be.available&&Ke.push({source:"uber",companyName:"Uber Direct",companyId:"uber-direct",totalCharges:be.fee,currency:be.currency||"INR",etaMinutes:be.etaMinutes,distanceKm:be.distanceKm,isSpecialVendor:!0,isTiedUp:!1})}}catch{}try{await Pa();const v=Os.current||new Map,be=fs(N,v),we=fs(pe,v);if(be.lat!=null&&be.lng!=null&&we.lat!=null&&we.lng!=null){const Ce=await Sr({fromAddress:be.placeText,fromLat:be.lat,fromLng:be.lng,toAddress:we.placeText,toLat:we.lat,toLng:we.lng}),dt=Ce?Ta(Ce,Math.max(1,$.chargeableWeight),{bikeToleranceFactor:1.1}):null,us=dt?dt.distanceMeters/1e3:1/0;Rt(dt&&us<=60?{status:"ok",price:dt.amount,vehicleName:`${dt.name} · rated ${dt.capacityKg} kg`}:void 0);const bt=Ce?Ta(Ce,$.chargeableWeight):null;bt&&Ke.unshift({source:"mover",companyName:"Mover",companyId:"mover-live",totalCharges:bt.amount,price:bt.amount,total:bt.amount,totalPrice:bt.amount,currency:"INR",distanceKm:Math.round(bt.distanceMeters/1e3),estimatedTime:1,estimatedDelivery:"Same day",deliveryTime:"Same day",vehicle:bt.name,vehicleLength:bt.lengthFt,isSpecialVendor:!0,isTiedUp:!1,isMoverLive:!0,liveFetchedAt:Date.now(),liveSourceLabel:"Mover (BOXnMOVE) public API",liveOptions:Ce,livePickedId:bt.id,ratedCapacityKg:bt.capacityKg,chargeableWeight:$.chargeableWeight,originPincode:N,destinationPincode:pe})}}catch{}try{const v=await si({fromPincode:N,toPincode:pe,chargeableWeight:$.chargeableWeight}),be=h()?._id?String(h()._id):"";v.forEach(we=>{const Ce=!!be&&!!we.createdBy&&String(we.createdBy)===be;Ke.unshift({source:"individual_ftl",companyName:we.transporterName,companyId:`individual-ftl-${we.id}`,totalCharges:we.charge,price:we.charge,total:we.charge,totalPrice:we.charge,currency:"INR",vehicle:we.vehicleType,isSpecialVendor:!0,isTiedUp:Ce,isIndividualFtl:!0,contactNumber:we.contactNumber,ratedCapacityKg:we.maxCapacityKg,chargeableWeight:$.chargeableWeight,originPincode:we.originPincode,destinationPincode:we.destinationPincode,liveFetchedAt:Date.now(),liveSourceLabel:"Individual FTL Transporter (marketplace listing)"})})}catch{}
71if(Xe=Xe.map(te),Ke=Ke.map(te),ye.data.smartShield?Xa(ye.data.smartShield):Xa(null),pt.current=0,J(!1),Ue(Xe),rt(Ke),Xe.length>0&&!y){j(!0),L(!0);const v=h();v?._id&&sessionStorage.setItem(g(v._id),"true")}Me.current=i,Se(!0),setTimeout(()=>{ne("results"),Se(!1)},210),window.scrollTo({top:0,behavior:"instant"}),setTimeout(()=>{qo(fe,{params:se,data:Xe,hiddendata:Ke,form:{fromPincode:N,toPincode:pe,modeOfTransport:ct,boxes:V,smartShield:ye.data.smartShield}})},0),(async()=>{try{const be=[...[...Xe,...Ke].filter(oe=>Number.isFinite(oe.totalCharges)&&oe.totalCharges>0)].sort((oe,mt)=>oe.totalCharges-mt.totalCharges).slice(0,5);if(be.length===0)return;const we=h()?._id?String(h()._id):"",Ce=oe=>{const mt=oe.createdBy||oe.customerID||oe.customerId;return!!oe.isCustomerVendor||!!oe.isTiedUp||!!we&&!!mt&&String(mt)===we},dt=[...Xe,...Ke].filter(oe=>Ce(oe)&&Number.isFinite(oe.totalCharges)&&oe.totalCharges>0),us=dt.length>0?dt.reduce((oe,mt)=>oe.totalCharges<=mt.totalCharges?oe:mt):void 0,bt=dt.length>0?dt.reduce((oe,mt)=>oe.totalCharges>=mt.totalCharges?oe:mt):void 0,yr=us?.totalCharges,wr=bt?.totalCharges,Es=us?.companyName,ta=bt?.companyName,tt=h()?.preferredVendor,ka=tt?.companyName?dt.find(oe=>(oe.companyName||"").trim().toLowerCase()===tt.companyName.trim().toLowerCase()):null,sa=ka?ka.totalCharges:void 0,Fs=Ke.filter(oe=>!Ce(oe)&&Number.isFinite(oe.totalCharges)&&oe.totalCharges>0),xs=Fs.length>0?Math.min(...Fs.map(oe=>oe.totalCharges)):void 0,Kn=(Fs.length>0?Fs.reduce((oe,mt)=>mt.totalCharges<oe.totalCharges?mt:oe):null)?.companyName||void 0,[Ca,aa]=await Promise.all([Jn(N),Jn(pe)]);await Ko({fromPincode:N,fromCity:Ca?.city||"",fromState:Ca?.state||"",toPincode:pe,originalToPincode:s?F:void 0,toCity:aa?.city||"",toState:aa?.state||"",modeOfTransport:ct,distanceKm:ze||0,boxes:V.map(oe=>({...oe,count:oe.count||1,length:oe.length||0,width:oe.width||0,height:oe.height||0,weight:oe.weight||0,description:oe.description||""})),totalBoxes:Mn,totalWeight:qs,invoiceValue:Y,topQuotes:be,maxQuotePrice:wr,tiedCheapestPrice:yr,tiedCheapestVendorName:Es,maxQuoteVendorName:ta,preferredVendorPrice:sa,cheapestMarketPrice:xs,cheapestMarketVendorName:Kn}),ot(oe=>oe+1)}catch(v){console.error("[SearchHistory] Failed:",v)}})()}catch(m){if(console.error("[Calculate] Error:",m),m.response?.status===400&&m.response?.data?.error==="NO_ROAD_ROUTE"&&m.response?.data?.isIsland&&(m.response?.data?.nearestPorts?.length??0)>0){const p=m.response.data;Oe({islandName:p.islandName,islandZone:p.islandZone,nearestPorts:p.nearestPorts,transportNote:p.transportNote,fromPincode:N,toPincode:s||F}),Ue([]),rt([]),ne("results")}else if(m.response?.status===401){if(m.response?.data?.code==="SESSION_REPLACED")try{await Lt.post("/api/auth/refresh-token"),me("Session refreshed — retrying...",{duration:2e3}),Bt();return}catch{me.error("Your session expired. Please sign in again."),x("/signin",{replace:!0});return}Z("Authentication failed.")}else m.response?.status===403&&m.response?.data?.code==="SUBSCRIPTION_REQUIRED"?(ae(!0),Ue([]),rt([])):m.response?.status===428||m.response?.status===429?(pt.current+=1,pt.current>=3?(pt.current=0,Z("Search limit reached. Please wait.")):Ye(!0)):m.response?.status===500?(Z(m.response?.data?.message||"Internal server error."),Ue([]),rt([])):m.response?.status===400?(Z(m.response?.data?.message||"Failed to calculate rates."),Ue([]),rt([])):Z(m.message||"Failed to calculate rates.")}finally{B(""),I(!1),setTimeout(()=>{},300)}};Bd({containerRef:kn,shipmentType:We,boxCount:V.length,onAddBox:()=>{const s=V[V.length-1];s&&(ya(s)?fr():wa(s))},onCalculate:()=>{xr(),Bt()}});const[Wl,br]=n.useState(!1),[zn,On]=n.useState(!1),ja=n.useRef(!1),Ls=n.useRef(!1),vr=s=>{Ls.current=!0,Us(s.fromPincode),Qs(null),os(s.toPincode),Gs(null),wt([{id:`box-smart-${Date.now()}`,count:1,weight:s.weightKg,length:s.lengthCm,width:s.widthCm,height:s.heightCm,description:""}]),s.invoiceValue&&Hs(String(Math.round(s.invoiceValue))),On(!0)};n.useEffect(()=>{if(!zn)return;const s=setTimeout(()=>{On(!1),!Ts&&!Ps?(ja.current=!0,setTimeout(()=>{ja.current=!1},8e3),xr(),Bt()):(me("Filled in from your description — double check and hit Calculate.",{icon:"✨"}),Ls.current&&(Ls.current=!1,Cr({status:"incomplete"})))},700);return()=>clearTimeout(s)},[zn,Ts,Ps]);const Bn=n.useRef(!1);n.useEffect(()=>{const s=Bn.current;if(Bn.current=T,!Ls.current||!s||T)return;Ls.current=!1;const a=(le||[]).filter(O=>Number.isFinite(O?.totalCharges)&&O.totalCharges>0),i=(de||[]).filter(O=>Number.isFinite(O?.totalCharges)&&O.totalCharges>0),o=nt.priced[0]||null;if(H||_||X||a.length===0&&i.length===0&&!o){Cr({status:"incomplete"});return}const m=a.length?a.reduce((O,ge)=>ge.totalCharges<O.totalCharges?ge:O):null;let p,A,Y;m&&(!o||m.totalCharges<=o.price)?(p=m.companyName,A=m.totalCharges,Y=Number.isFinite(m.estimatedTime)?m.estimatedTime:void 0):o&&(p=o.name,A=o.price);const pe=i.length?Math.min(...i.map(O=>O.totalCharges)):void 0,se=[...a].sort((O,ge)=>O.totalCharges-ge.totalCharges).slice(0,2).map(O=>({kind:"tied",label:O.companyName||O.transporterName||"Vendor",price:O.totalCharges,etaDays:Number.isFinite(O.estimatedTime)?O.estimatedTime:void 0,vendorId:O.companyId||O.transporterData?._id||O.transporterID||O._id,vendorType:O.isTiedUp===!0?"temporaryTransporter":"transporter"})),fe=se.length?se[0].price:null,te=nt.priced.filter(O=>fe==null||O.price<fe).slice(0,2).map(O=>({kind:"quick_booking",label:O.name,price:O.price,vehicleName:O.vehicleName,platform:O.platform}));let he;if(te.length&&Pe?.placeText&&Le?.placeText){const O=Math.max(0,...V.flatMap(ge=>[Number(ge.length)||0,Number(ge.width)||0,Number(ge.height)||0]));he={fromPincode:N,toPincode:F,fromText:Pe.placeText,toText:Le.placeText,fromLat:Pe.lat,fromLng:Pe.lng,toLat:Le.lat,toLng:Le.lng,fromCity:Pe.city,toCity:Le.city,weight:ee,vehicleClass:Tr(ee,O||null)||"wheeler3"}}Cr({status:"ok",ourLabel:p,ourPrice:A,etaDays:Y,marketPrice:pe,hasOwnVendors:a.length>0,cards:[...se,...te],route:he})},[T]),n.useEffect(()=>{const s=Do();s&&vr(s);const a=i=>{const o=i.detail;o&&vr(o)};return window.addEventListener(Xn,a),()=>window.removeEventListener(Xn,a)},[]);const Kl=()=>{if(V.length===0)return;const s=["Box Name","Quantity","Weight (kg)","Length (cm)","Width (cm)","Height (cm)"],a=V.map(p=>[p.description||"Unnamed Box",p.count||0,p.weight||0,p.length||"-",p.width||"-",p.height||"-"]),i=[s.join(","),...a.map(p=>p.join(","))].join(`
72`),o=new Blob([i],{type:"text/csv;charset=utf-8;"}),m=document.createElement("a");m.href=URL.createObjectURL(o),m.download=`packing-list-${N}-to-${F}-${Date.now()}.csv`,m.click()},Wn=null;return e.jsxs("div",{className:"relative w-full min-h-screen text-slate-900 font-sans overflow-x-hidden bg-white",children:[e.jsx(kt,{children:z==="hero"&&e.jsx(W.div,{initial:{opacity:0}
72,animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},"hero-spacer")}),e.jsxs("div",{className:`relative w-full z-10 ${z==="results"?"":"px-4 lg:px-8 2xl:px-12 pt-8"}`,children:[e.jsx(Kc,{children:e.jsxs("div",{className:`relative w-full overflow-visible ${z==="results"?"grid grid-cols-1 xl:grid-cols-[280px_1fr_360px] 2xl:grid-cols-[300px_1fr_380px] gap-2 lg:px-2 lg:py-3 min-h-[calc(100vh-4rem)] items-start":"grid grid-cols-1 lg:grid-cols-[3fr_1fr] gap-4 lg:gap-5 max-w-[1800px] mx-auto w-full items-start"}`,style:{zIndex:2,zoom:z==="results"?.85:1,gridTemplateRows:z==="results"?"min-content 1fr":void 0},children:[e.jsxs(W.aside,{layout:!0,transition:{layout:{type:"spring",stiffness:380,damping:36,mass:.9},opacity:{duration:.2}},style:{willChange:"transform"},className:`relative z-20 group min-w-0 w-full ${z==="results"?"col-span-1 xl:col-span-3 px-5 py-3 sticky top-2 self-start bg-white rounded-2xl shadow-md border border-slate-200":"self-start"}`,onClick:s=>{z==="results"&&(s.target.closest('button, input, select, textarea, a, label, [role="option"], [role="listbox"], [role="combobox"], [role="menu"], [role="menuitem"], [tabindex]')||(ne("hero"),Se(!1),window.scrollTo({top:0,behavior:"smooth"})))},children:[z==="results"&&e.jsx(kt,{children:e.jsx(W.header,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.3},className:"w-full",children:e.jsxs("div",{className:"flex items-stretch overflow-x-auto scrollbar-hide bg-white",children:[e.jsxs("div",{className:"flex flex-col justify-center px-5 py-4 flex-1 flex-shrink-0 min-w-[110px] border-r border-slate-100",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-1",children:"Origin"}),e.jsx("span",{className:"text-lg font-black text-slate-900 truncate leading-tight",children:N||e.jsx("span",{className:"text-slate-300 font-normal text-base",children:"—"})})]}),e.jsx("div",{className:"flex items-center justify-center px-2 border-r border-slate-100 shrink-0",children:e.jsx(ci,{size:14,className:"text-slate-400"})}),e.jsxs("div",{className:"flex flex-col justify-center px-5 py-4 flex-1 flex-shrink-0 min-w-[110px] border-r border-slate-100",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-1",children:"Destination"}),e.jsx("span",{className:"text-lg font-black text-slate-900 truncate leading-tight",children:F||e.jsx("span",{className:"text-slate-300 font-normal text-base",children:"—"})})]}),e.jsxs("div",{className:"flex flex-col justify-center px-5 py-4 flex-[0.9] flex-shrink-0 min-w-[100px] border-r border-slate-100",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-1",children:"Invoice"}),e.jsx("span",{className:"text-lg font-black text-slate-900 leading-tight",children:St?`₹${Number(St).toLocaleString("en-IN")}`:e.jsx("span",{className:"text-slate-300 font-normal text-base",children:"—"})})]}),e.jsxs("div",{className:"hidden sm:flex sm:flex-col justify-center px-5 py-4 flex-[0.8] flex-shrink-0 min-w-[110px] border-r border-slate-100",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-1",children:"Service Mode"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Re,{size:14,className:"text-blue-600 shrink-0"}),e.jsx("span",{className:"text-lg font-black text-slate-900 leading-tight",children:ct})]})]}),Ht!=null&&Ht>0&&e.jsxs("div",{className:"flex flex-col justify-center px-5 py-4 flex-[0.7] flex-shrink-0 min-w-[100px] border-r border-slate-100",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-1",children:"Distance"}),e.jsxs("span",{className:"text-lg font-black text-slate-900 leading-tight",children:[Ht.toLocaleString("en-IN")," km"]})]}),e.jsxs("div",{className:"flex flex-col justify-center px-5 py-4 flex-[0.7] flex-shrink-0 min-w-[100px] border-r border-slate-100",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-1",children:We==="Heavy"?"Total Weight":"Unit Weight"}),e.jsx("span",{className:"text-lg font-black text-slate-900 leading-tight",children:`${ms.toFixed(1)} kg`})]}),e.jsx("div",{className:"flex items-center px-4 py-3 shrink-0",children:e.jsxs("button",{type:"button",onClick:()=>{ne("hero"),Se(!1),window.scrollTo({top:0,behavior:"smooth"})},className:"inline-flex items-center gap-2 text-sm font-bold text-white bg-slate-900 hover:bg-slate-700 px-5 py-3 rounded-xl transition-colors shadow-sm whitespace-nowrap",title:"Modify search",children:[e.jsx(Br,{size:13}),"Edit Search"]})})]})},"sidebar-heading")}
72),e.jsx("div",{className:`${z==="hero"&&!Da?"space-y-3":"hidden"}`,ref:kn,children:e.jsxs(W.div,{initial:b?void 0:{opacity:0,y:18},animate:b?void 0:{opacity:1,y:0},transition:{duration:.45,ease:[.16,1,.3,1]},className:"relative",children:[e.jsx(W.div,{className:"absolute -inset-6 -z-10 pointer-events-none opacity-[0.06]","aria-hidden":"true",style:{backgroundImage:"radial-gradient(circle, #1d4ed8 1px, transparent 1.4px)",backgroundSize:"22px 22px"},animate:b?void 0:{backgroundPositionX:[0,22],backgroundPositionY:[0,22]},transition:b?void 0:{duration:6,repeat:1/0,ease:"linear"}}),e.jsx(W.div,{className:"absolute -top-1.5 left-6 right-6 h-1.5 rounded-full bg-gradient-to-r from-blue-700 via-blue-500 to-blue-700 pointer-events-none","aria-hidden":"true",initial:{opacity:.9},animate:b?{opacity:.9}:{opacity:[.7,1,.7],boxShadow:["0 0 0px rgba(37,99,235,0)","0 0 14px rgba(37,99,235,0.55)","0 0 0px rgba(37,99,235,0)"]},transition:b?void 0:{duration:2.8,repeat:1/0,ease:"easeInOut"}}),e.jsxs(cm,{className:"!p-0 overflow-hidden flex flex-col bg-white border border-slate-200 shadow-[0_8px_30px_-12px_rgba(15,23,42,0.25)] rounded-[24px] lg:max-h-[calc(100vh-6rem)] relative",children:[e.jsxs("div",{className:"bg-white rounded-t-3xl shrink-0 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-16 opacity-[0.05] pointer-events-none","aria-hidden":"true",style:{backgroundImage:"repeating-linear-gradient(90deg, #0f172a 0px, #0f172a 28px, transparent 28px, transparent 44px)"}}),e.jsxs("div",{className:"hidden sm:flex items-center justify-between gap-1.5 sm:gap-2 px-2.5 sm:px-4 pt-4 pb-3 border-b border-slate-100 bg-white rounded-t-3xl overflow-x-auto scrollbar-hide relative",children:[e.jsx("div",{className:"flex items-center gap-1.5 sm:gap-2 shrink-0",children:[{name:"Road",icon:e.jsx(Re,{size:14}),isAvailable:!0},{name:"Air",icon:e.jsx(mc,{size:14}),isAvailable:!1},{name:"Rail",icon:e.jsx(hc,{size:14}),isAvailable:!1},{name:"Ship",icon:e.jsx(ri,{size:14}),isAvailable:!1}].map(s=>e.jsxs(W.button,{onClick:()=>s.isAvailable?qa(s.name):null,whileTap:s.isAvailable&&!b?{scale:.92}:void 0,transition:{type:"spring",stiffness:500,damping:25},className:`relative flex items-center gap-1.5 px-3 sm:px-4 py-1.5 text-sm sm:text-base font-semibold transition-all rounded-full border flex-shrink-0 whitespace-nowrap ${ct===s.name?"bg-slate-900 text-white border-slate-900 shadow-sm":s.isAvailable?"text-slate-600 border-slate-300 bg-white hover:border-blue-400 hover:text-blue-600":"text-slate-300 border-slate-200 bg-white cursor-not-allowed"}`,disabled:!s.isAvailable,children:[s.icon,e.jsx("span",{children:s.name}),ct===s.name&&e.jsx(W.span,{layoutId:"modeTabAccent",className:"absolute -bottom-1 left-1/2 -translate-x-1/2 w-6 h-1 rounded-full bg-yellow-400","aria-hidden":"true"})]},s.name))}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>{if(!t){ce(!0);return}br(!0)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-bold rounded-full border border-indigo-200 bg-gradient-to-br from-indigo-50 to-purple-50 text-indigo-700 hover:border-indigo-300 hover:from-indigo-100 hover:to-purple-100 transition-all flex-shrink-0 whitespace-nowrap",children:[e.jsx(Ns,{size:14}),e.jsx("span",{children:"Just tell me what you're shipping"})]}),e.jsxs($s,{to:"/recent-searches",className:"inline-flex items-center gap-1.5 text-sm font-bold text-blue-600 hover:text-blue-700 hover:underline px-2 py-1.5 transition-all cursor-pointer shrink-0 whitespace-nowrap",children:[e.jsx(Vo,{size:13,strokeWidth:2.5}),e.jsx("span",{className:"hidden sm:inline",children:"Search History & Activity"})]})]})]}),e.jsxs("div",{className:"flex sm:hidden items-center gap-1.5 px-2.5 pt-4 pb-3 border-b border-slate-100 bg-white rounded-t-3xl",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsxs("select",{value:ct,onChange:s=>qa(s.target.value),className:"appearance-none pl-2.5 pr-6 py-2 text-xs font-bold rounded-full border border-blue-600 bg-blue-600 text-white focus:outline-none focus:ring-2 focus:ring-blue-300",children:[e.jsx("option",{value:"Road",children:"🚚 Road"}),e.jsx("option",{value:"Air",disabled:!0,children:"✈️ Air — Coming soon"}),e.jsx("option",{value:"Rail",disabled:!0,children:"🚆 Rail — Coming soon"}),e.jsx("option",{value:"Ship",disabled:!0,children:"🚢 Ship — Coming soon"})]}),e.jsx(_s,{size:12,className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-white"})]}),e.jsxs("button",{type:"button",onClick:()=>
72{if(!t){ce(!0);return}br(!0)},className:"flex-1 min-w-0 flex items-center justify-center gap-1 px-2 py-2 text-xs font-bold rounded-full border border-indigo-200 bg-gradient-to-br from-indigo-50 to-purple-50 text-indigo-700 active:scale-95 transition-all whitespace-nowrap",children:[e.jsx(Ns,{size:13,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate",children:"Smart entry"})]})]}),e.jsx("div",{className:"p-3 pt-4 relative",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch border border-slate-200 rounded-2xl overflow-visible shadow-sm bg-white hover:border-blue-300 transition-colors",children:[e.jsxs("div",{className:"flex items-stretch flex-1 min-w-0",children:[e.jsx("div",{className:"flex-[1.6] min-w-0 px-3 py-2.5",children:e.jsx(ni,{label:"From",id:"fromPincode",value:N,placeholder:"Origin PIN",variant:"calculator-flat",error:Mt?mn||Wn:null,onChange:s=>{Us(s),un(!0),Qs(null)},onBlur:()=>un(!0),onSelect:()=>{},onValidationChange:wl})}),e.jsxs("div",{className:"relative flex items-center justify-center flex-shrink-0 px-1 z-10",children:[e.jsx("div",{className:"hidden sm:block absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2 w-16 h-0 border-t-2 border-dashed border-slate-200 pointer-events-none","aria-hidden":"true"}),b?e.jsx("div",{className:`hidden sm:flex items-center justify-center absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2 pointer-events-none ${N&&F?"text-blue-600":"text-slate-300"}`,"aria-hidden":"true",children:e.jsx(Re,{size:12,strokeWidth:2.5})}):e.jsx(W.div,{className:`hidden sm:flex items-center justify-center absolute top-1/2 -translate-y-1/2 pointer-events-none ${N&&F?"text-blue-600":"text-slate-300"}`,initial:{left:"30%",opacity:0}
72,animate:{left:["30%","70%"],opacity:N&&F?[0,1,1,0]:[0,.7,.7,0]},transition:{duration:N&&F?2.2:3.4,repeat:1/0,repeatDelay:.6,ease:"easeInOut"},"aria-hidden":"true",children:e.jsx(Re,{size:12,strokeWidth:2.5})},N&&F?"active-route":"idle-route"),e.jsx("button",{type:"button",title:"Swap origin and destination",onClick:()=>{const s=N;Us(F),os(s),Qs(null),Gs(null)},className:"relative w-8 h-8 rounded-full border-2 border-slate-200 bg-white flex items-center justify-center hover:border-blue-400 hover:text-blue-600 hover:bg-blue-50 transition-all shadow-sm text-slate-400 flex-shrink-0",children:e.jsx(ci,{size:14,strokeWidth:2.5})})]}),e.jsx("div",{className:"flex-[1.6] min-w-0 px-3 py-2.5 border-l border-slate-100",children:e.jsx(ni,{label:"To",id:"toPincode",value:F,placeholder:"Destination PIN",variant:"calculator-flat",error:Mt?hn||Wn:null,onChange:s=>{os(s),xn(!0),Gs(null)},onBlur:()=>xn(!0),onSelect:()=>{},onValidationChange:Nl})})]}),e.jsxs("div",{className:"flex-[1.1] min-w-0 px-3 py-2.5 border-t sm:border-t-0 sm:border-l border-slate-100 relative flex flex-col justify-center",children:[e.jsx("label",{htmlFor:"invoiceValue",className:"block text-base font-semibold text-slate-500 uppercase tracking-wider mb-1",children:"Invoice Value"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-slate-400 font-semibold pointer-events-none",children:"₹"}),e.jsx("input",{id:"invoiceValue",type:"text",inputMode:"numeric",pattern:"\\\\d*",placeholder:"Amount",value:St,onChange:s=>{const a=Ur(s.target.value);if(a===""){Hs(""),tr(null);return}const i=Number(a);i>bs?(Hs(String(bs)),tr(`Max ₹${bs.toLocaleString("en-IN")}`)):(Hs(String(i)),tr(null))},onBlur:s=>{const a=Ur(s.currentTarget.value);if(a==="")return;let i=Number(a);i<oa&&(i=oa),i>bs&&(i=bs),Hs(String(i))},className:`block w-full py-1 pl-6 pr-2 bg-transparent border-0 text-base font-semibold text-slate-800 focus:outline-none focus:ring-0 transition ${er?"text-red-600":""}`})]}),er&&e.jsxs("p",{className:"absolute -bottom-5 left-3 text-xs text-red-600 mt-1 flex items-center gap-1 w-full truncate",children:[e.jsx(Xt,{size:11,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:er})]})]})]})})]}),e.jsx("div",{className:"h-px bg-slate-100 mx-4"}),e.jsxs("div",{className:"p-0 flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 flex flex-wrap items-center justify-between gap-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsxs("div",{className:"flex bg-white rounded-lg p-0.5 border border-slate-200 shadow-sm",children:[e.jsx(W.button,{onClick:()=>rn("Light"),whileTap:b?void 0:{scale:.94},transition:{type:"spring",stiffness:500,damping:25},className:`px-2 py-1 text-base font-medium rounded-md transition-all duration-200 ${We==="Light"?"bg-blue-600 text-white shadow-sm":"text-slate-500 hover:text-slate-700 hover:bg-slate-50"}`,children:"Light (Volume)"}),e.jsx(W.button,{onClick:()=>rn("Heavy"),whileTap:b?void 0:{scale:.94},transition:{type:"spring",stiffness:500,damping:25},className:`px-2 py-1 text-base font-medium rounded-md transition-all duration-200 ${We==="Heavy"?"bg-blue-600 text-white shadow-sm":"text-slate-500 hover:text-slate-700 hover:bg-slate-50"}`,children:"Heavy (Weight)"})]})}),We==="Light"&&e.jsxs("div",{className:"flex text-base",children:[e.jsx(W.button,{onClick:()=>Za("cm"),whileTap:b?void 0:{scale:.92},transition:{type:"spring",stiffness:500,damping:25},className:`px-2 py-0.5 font-medium border ${it==="cm"?"bg-blue-600 text-white border-blue-600":"bg-white text-slate-400 border-slate-200"} rounded-l`,children:"CM"}),e.jsx(W.button,{onClick:()=>Za("inch"),whileTap:b?void 0:{scale:.92},transition:{type:"spring",stiffness:500,damping:25},className:`px-2 py-0.5 font-medium border-t border-b border-r ${it==="inch"?"bg-blue-600 text-white border-blue-600":"bg-white text-slate-400 border-slate-200"} rounded-r`,children:"IN"})]})]}),e.jsxs("div",{className:"mx-2 mb-1 bg-white overflow-hidden flex-1 min-h-0 flex flex-col",children:[e.jsx("div",{className:"shrink-0 hidden sm:flex items-center gap-2 px-1 pt-2 pb-2 border-b border-slate-200/60 mb-1 w-full text-base font-semibold text-slate-400 uppercase tracking-wider",children:We==="Heavy"?e.jsxs("div",{className:"flex w-full items-center gap-1",children:[e.jsx("div",{className:"w-8 flex-shrink-0","aria-hidden":"true"}),e.jsxs("div",{className:`grid ${z==="hero"?"grid-cols-[1.8fr_1fr_2fr_2fr]":"grid-cols-[2.8fr_1fr]"} gap-1.5 w-full text-center`,children:[e.jsx("div",{className:"text-left pl-1",children:"Packing List"}),e.jsx("div",{children:"Qty"}),z==="hero"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Unit Weight (kgs)"}),e.jsx("div",{className:"flex items-center justify-end pr-2",children:e.jsx("span",{children:"Actions"})})]})]})]}):e.jsxs("div",{className:"flex flex-nowrap w-full gap-1.5 text-center items-center text-sm",children:[e.jsx("div",{className:"w-8 flex-shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"relative flex-1 min-w-[80px] text-left pl-3 whitespace-nowrap",children:"Packing List"}),z!=="hero"&&e.jsx("div",{className:"w-14 flex-shrink-0 whitespace-nowrap",children:"Qty"}),z==="hero"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w-20 flex-shrink-0 whitespace-nowrap text-center",children:["L (",it,")"]}),e.jsxs("div",{className:"w-20 flex-shrink-0 whitespace-nowrap text-center",children:["W (",it,")"]}),e.jsxs("div",{className:"w-20 flex-shrink-0 whitespace-nowrap text-center",children:["H (",it,")"]}),e.jsx("div",{className:"w-16 flex-shrink-0 whitespace-nowrap text-center",children:"Qty"}),e.jsx("div",{className:"w-28 flex-shrink-0 whitespace-nowrap text-center",children:"Weight (kg)"}),e.jsx("div",{className:"w-[120px] flex-shrink-0 flex items-center justify-end pr-1 whitespace-nowrap",children:e.jsx("span",{children:"Actions"})})]})]})}),V.length>1&&e.jsx("div",{className:"shrink-0 flex sm:hidden justify-end px-2 pt-1.5",children:e.jsx("button",{onClick:()=>wt([hs()]),className:"flex-none flex items-center gap-1 px-2 py-1 rounded-md text-base font-semibold text-red-400 hover:text-red-600 hover:bg-red-50 border border-transparent hover:border-red-200 transition-all",title:"Delete all boxes",children:e.jsx(gs,{size:12,strokeWidth:2.5})})}),e.jsxs("div",{ref:jn,className:"flex-1 min-h-[80px] max-h-[440px] overflow-y-auto",style:{scrollbarWidth:"thin",scrollbarColor:"#e2e8f0 transparent"},children:[e.jsx(kt,{mode:"popLayout",children:V.map((s,a)=>e.jsx(W.div,{layout:!0,initial:{opacity:0,y:-10}
72,animate:{opacity:1,y:0},exit:{opacity:0,x:-20},transition:{duration:.15},className:"",ref:i=>dr.current[a]=i,children:We==="Heavy"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:flex items-center gap-1 bg-white border-b border-slate-100 last:border-0 hover:bg-blue-50/30 transition-colors px-1 py-1",children:[e.jsx("div",{className:"w-8 flex-shrink-0 flex items-center justify-center text-base font-medium text-slate-400",children:e.jsx("span",{children:a+1})}),e.jsxs("div",{className:`grid ${z==="hero"?"grid-cols-[1.8fr_1fr_2fr_2fr]":"grid-cols-[2.8fr_1fr]"} gap-1 items-center w-full`,children:[e.jsx("div",{className:"col-span-1 relative text-base",children:e.jsx(yt,{id:`preset-${a}`,placeholder:"Box name (optional)",value:s.description||"",onChange:i=>ve(a,"description",Aa(i.target.value)),onKeyDown:i=>gt(i,a,"preset"),className:"text-base py-1 bg-transparent !border-blue-400",autoComplete:"off",maxLength:30})}),e.jsx("div",{className:"col-span-1",children:e.jsx(yt,{id:`count-${a}`,type:"text",inputMode:"numeric",pattern:"\\d*",maxLength:5,value:s.count??"",onKeyDown:i=>{vs(i),gt(i,a,"count")},onChange:i=>{const o=ys(i.target.value);o===""?ve(a,"count",void 0):Number(o)<=As&&ve(a,"count",Number(o))},onBlur:()=>{At(s.id,"count"),(!s.count||s.count<1)&&ve(a,"count",1)},placeholder:"Qty",className:"py-1 px-2 text-center bg-transparent !border-blue-400 text-base",error:(Mt||Ut[s.id]?.count)&&(!s.count||s.count<=0)?"Required":null})}),z==="hero"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"col-span-1",children:e.jsx(yt,{id:`weight-${a}`,type:"text",inputMode:"decimal",placeholder:"Wt",value:rs[s.id]!==void 0?rs[s.id]:s.weight!=null?String(s.weight):"",onKeyDown:i=>{_a(i),gt(i,a,"weight")},onChange:i=>{let o=i.target.value.replace(/[^0-9.]/g,"").replace(/(\..*)\./,"$1");if(o.length>1&&o.startsWith("0")&&o[1]!=="."&&(o=o.replace(/^0+/,"")),o==="00"||o.includes(".")&&o.split(".")[1].length>3)return;if(o===""||o==="."){Et(p=>({...p,[s.id]:o})),ve(a,"weight",void 0);return}const m=parseFloat(o);!isNaN(m)&&m>5e4||(Et(p=>({...p,[s.id]:o})),!isNaN(m)&&m>0&&ve(a,"weight",m))},onBlur:()=>{const i=V[a]?.weight;Et(o=>{const m={...o};return i!=null&&i>0?m[s.id]=String(i):delete m[s.id],m}),At(s.id,"weight")},className:"py-1 text-center bg-transparent !border-blue-400 text-base",error:(Mt||Ut[s.id]?.weight)&&(!s.weight||s.weight<=0)?"Required":null})}),e.jsx("div",{className:"col-span-1 flex items-center justify-end gap-1.5 px-1",children:e.jsx("div",{className:"pl-2 ml-1 border-l border-slate-200",children:e.jsx("button",{onClick:()=>{V.length>1?Na(a):wt([hs()])},className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded-md transition-all",title:V.length>1?"Remove":"Clear",children:e.jsx(gs,{size:14})})})})]})]})]}),e.jsxs("div",{className:"sm:hidden flex flex-col gap-2 p-2.5 mb-2 bg-white border border-slate-200 rounded-xl shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 flex-shrink-0 flex items-center justify-center rounded-full bg-slate-100 text-base font-bold text-slate-500",children:a+1}),e.jsx("div",{className:"relative flex-1 text-base",children:e.jsx(yt,{id:`preset-mobile-${a}`,placeholder:"Box name (optional)",value:s.description||"",onChange:i=>ve(a,"description",Aa(i.target.value)),onKeyDown:i=>gt(i,a,"preset"),className:"text-base py-1.5 bg-white !border-slate-200",autoComplete:"off",maxLength:30})})]}),z==="hero"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-base font-bold text-slate-400 uppercase tracking-wide mb-0.5 text-center",children:"Qty"}),e.jsx(yt,{id:`count-mobile-${a}`,type:"text",inputMode:"numeric",pattern:"\\d*",maxLength:5,value:s.count??"",onKeyDown:i=>{vs(i),gt(i,a,"count")},onChange:i=>{const o=ys(i.target.value);o===""?ve(a,"count",void 0):Number(o)<=As&&ve(a,"count",Number(o))},onBlur:()=>{At(s.id,"count"),(!s.count||s.count<1)&&ve(a,"count",1)},placeholder:"1",className:"py-1.5 px-2 text-center bg-white !border-slate-200 text-base",error:(Mt||Ut[s.id]?.count)&&(!s.count||s.count<=0)?"Required":null})]}),e.jsxs("div",{className:"flex-[1.6]",children:[e.jsx("label",{className:"block text-base font-bold text-slate-400 uppercase tracking-wide mb-0.5 text-center",children:"Unit Weight (kgs)"}),e.jsx(yt,{id:`weight-mobile-${a}`,type:"text",inputMode:"decimal",placeholder:"0",value:rs[s.id]!==void 0?rs[s.id]:s.weight!=null?String(s.weight):"",onKeyDown:i=>{_a(i),gt(i,a,"weight")},onChange:i=>{let o=i.target.value.replace(/[^0-9.]/g,"").replace(/(\..*)\./,"$1");if(o.length>1&&o.startsWith("0")&&o[1]!=="."&&(o=o.replace(/^0+/,"")),o==="00"||o.includes(".")&&o.split(".")[1].length>3)return;if(o===""||o==="."){Et(p=>({...p,[s.id]:o})),ve(a,"weight",void 0);return}const m=parseFloat(o);!isNaN(m)&&m>5e4||(Et(p=>({...p,[s.id]:o})),!isNaN(m)&&m>0&&ve(a,"weight",m))},onBlur:()=>{const i=V[a]?.weight;Et(o=>{const m={...o};return i!=null&&i>0?m[s.id]=String(i):delete m[s.id],m}),At(s.id,"weight")},className:"py-1.5 text-center bg-white !border-slate-200 text-base",error:(Mt||Ut[s.id]?.weight)&&(!s.weight||s.weight<=0)?"Required":null})]})]}),e.jsx("div",{className:"flex items-center justify-end mt-2 pt-2 border-t border-slate-100",children:e.jsx("button",{onClick:()=>{V.length>1?Na(a):wt([hs()])},className:"p-2 text-red-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-all",title:V.length>1?"Remove":"Clear",children:e.jsx(gs,{size:16})})})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:flex sm:flex-nowrap sm:items-center gap-1.5 px-1 py-1.5 bg-white border-b border-slate-100 last:border-0 hover:bg-blue-50/30 transition-colors",children:[e.jsx("div",{className:"w-8 flex-shrink-0 flex items-center justify-center text-base font-medium text-slate-400",children:e.jsx("span",{children:a+1})}),e.jsx("div",{className:"relative flex-1 min-w-[80px]",ref:i=>{i&&(fa.current[a]=i)},children:e.jsx(yt,{id:`preset-${a}`,placeholder:"Box name",value:s.description||(_t===a?cr:""),onChange:i=>{const o=Aa(i.target.value);ve(a,"description",o),Ys(o)},onKeyDown:i=>gt(i,a,"preset"),onFocus:()=>{ns.current&&(clearTimeout(ns.current),ns.current=null),ks(a),Ys("")},onBlur:()=>{ns.current=setTimeout(()=>ks(null),200)},icon:e.jsx(Ea,{size:14}),className:"text-base py-1.5 bg-transparent !border-blue-400",autoComplete:"off",maxLength:30})}),z!=="hero"&&e.jsx("div",{className:"w-14 flex-shrink-0",children:e.jsx(yt,{id:`count-${a}`,type:"text",value:s.count??"",onKeyDown:i=>{vs(i),gt(i,a,"count")},onChange:i=>{const o=ys(i.target.value);o===""?ve(a,"count",void 0):Number(o)<=As&&ve(a,"count",Number(o))},onBlur:()=>{At(s.id,"count"),(!s.count||s.count<1)&&ve(a,"count",1)},placeholder:"Qty",className:"py-1.5 px-1 text-center font-semibold text-base bg-transparent !border-blue-400",error:(Mt||Ut[s.id]?.count)&&(!s.count||s.count<=0)?"!":null})}),z==="hero"&&e.jsxs(e.Fragment,{children:[["length","width","height"].map(i=>e.jsx("div",{className:"w-20 flex-shrink-0",children:e.jsx(yt,{id:`${i}-${a}
72`,placeholder:i==="length"?"L":i==="width"?"W":"H",value:s[i]??"",onKeyDown:o=>{vs(o),gt(o,a,i)},onChange:o=>{const m=ys(o.target.value);if(m==="")ve(a,i,void 0);else{const p=i==="length"?Ar:i==="width"?_r:$r;Number(m)<=p&&ve(a,i,Number(m))}},className:"py-1.5 px-1 text-center font-medium text-slate-800 text-base bg-transparent !border-blue-400",error:null})},i)),e.jsx("div",{className:"w-16 flex-shrink-0",children:e.jsx(yt,{id:`count-${a}`,type:"text",value:s.count??"",onKeyDown:i=>{vs(i),gt(i,a,"count")},onChange:i=>{const o=ys(i.target.value);o===""?ve(a,"count",void 0):Number(o)<=As&&ve(a,"count",Number(o))},onBlur:()=>{At(s.id,"count"),(!s.count||s.count<1)&&ve(a,"count",1)},placeholder:"Qty",className:"py-1.5 px-1 text-center font-semibold text-base bg-transparent !border-blue-400",error:(Mt||Ut[s.id]?.count)&&(!s.count||s.count<=0)?"!":null})}),e.jsx("div",{className:"w-28 flex-shrink-0",children:e.jsx(yt,{id:`weight-${a}`,type:"text",inputMode:"decimal",placeholder:"Wt",value:rs[s.id]!==void 0?rs[s.id]:s.weight!=null?String(s.weight):"",onKeyDown:i=>{_a(i),gt(i,a,"weight")},onChange:i=>{let o=i.target.value.replace(/[^0-9.]/g,"").replace(/(\..*)\./,"$1");if(o.length>1&&o.startsWith("0")&&o[1]!=="."&&(o=o.replace(/^0+/,"")),o==="00"||o.includes(".")&&o.split(".")[1].length>3)return;if(o===""||o==="."){Et(p=>({...p,[s.id]:o})),ve(a,"weight",void 0);return}const m=parseFloat(o);!isNaN(m)&&m>5e4||(Et(p=>({...p,[s.id]:o})),!isNaN(m)&&m>0&&ve(a,"weight",m))},onBlur:()=>{const i=V[a]?.weight;Et(o=>{const m={...o};return i!=null&&i>0?m[s.id]=String(i):delete m[s.id],m}),At(s.id,"weight")},className:"py-1.5 px-1 text-center font-medium text-base bg-transparent !border-blue-400",error:(Mt||Ut[s.id]?.weight)&&(!s.weight||s.weight<=0)?"!":null})}),e.jsxs("div",{className:"flex items-center justify-end w-[120px] gap-1.5 flex-shrink-0 pr-1",children:[(()=>{const i=Cn[s.id]||"idle";return e.jsx("button",{onClick:()=>Vn(a),className:`px-2 py-1 rounded-md text-xs font-semibold transition-all border shadow-sm whitespace-nowrap  ${i==="saving"?"bg-slate-100 text-slate-400 cursor-wait flex items-center gap-1":i==="success"?"bg-green-50 text-green-600 border-green-200 hover:bg-green-100":!s.count||s.count<=0||!s.weight||s.weight<=0?"bg-slate-50 text-slate-300 border-slate-100 cursor-not-allowed":"bg-white text-slate-600 border-slate-200 hover:bg-slate-50 hover:text-slate-800"}`,disabled:i==="saving"||!s.count||s.count<=0||!s.weight||s.weight<=0,title:"Save Preset",children:i==="saving"?e.jsxs(e.Fragment,{children:[e.jsx(ut,{size:10,className:"animate-spin"}),"Saving"]}):i==="success"?"Saved":"Save"})})(),e.jsx("div",{className:"pl-1.5 ml-0.5 border-l border-slate-200",children:e.jsx("button",{onClick:()=>{V.length>1?Na(a):wt([hs()])},className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded-md transition-all",title:V.length>1?"Remove":"Clear",children:e.jsx(gs,{size:14})})})]})]})]}),e.jsxs("div",{className:"sm:hidden flex flex-col gap-2 p-2.5 mb-2 bg-white border border-slate-200 rounded-xl shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 flex-shrink-0 flex items-center justify-center rounded-full bg-slate-100 text-base font-bold text-slate-500",children:a+1}),e.jsx("div",{className:"relative flex-1 text-base",children:e.jsx(yt,{id:`preset-mobile-${a}`,placeholder:"Box name (optional)",value:s.description||(_t===a?cr:""),onChange:i=>{const o=Aa(i.target.value);ve(a,"description",o),Ys(o)},onKeyDown:i=>gt(i,a,"preset"),onFocus:()=>{ns.current&&(clearTimeout(ns.current),ns.current=null),ks(a),Ys("")},onBlur:()=>{ns.current=setTimeout(()=>ks(null),200)},icon:e.jsx(Ea,{size:14}),className:"text-base py-1.5 bg-white !border-slate-200",autoComplete:"off",maxLength:30})})]}),z==="hero"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-2",children:["length","width","height"].map(i=>e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-base font-bold text-slate-400 uppercase tracking-wide mb-0.5 text-center",children:i==="length"?`L (${it})`:i==="width"?`W (${it})`:`H (${it})`}),e.jsx(yt,{id:`${i}-mobile-${a}`,placeholder:"0",value:s[i]??"",onKeyDown:o=>{vs(o),gt(o,a,i)},onChange:o=>{const m=ys(o.target.value);if(m==="")ve(a,i,void 0);else{const p=i==="length"?Ar:i==="width"?_r:$r;Number(m)<=p&&ve(a,i,Number(m))}},className:"py-1.5 px-1 text-center font-medium text-slate-800 text-base bg-white !border-slate-200",error:null})]},i))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-base font-bold text-slate-400 uppercase tracking-wide mb-0.5 text-center",children:"Qty"}),e.jsx(yt,{id:`count-mobile-${a}`,type:"text",value:s.count??"",onKeyDown:i=>{vs(i),gt(i,a,"count")},onChange:i=>{const o=ys(i.target.value);o===""?ve(a,"count",void 0):Number(o)<=As&&ve(a,"count",Number(o))},onBlur:()=>{At(s.id,"count"),(!s.count||s.count<1)&&ve(a,"count",1)},placeholder:"1",className:"py-1.5 px-1 text-center font-semibold text-base bg-white !border-slate-200",error:(Mt||Ut[s.id]?.count)&&(!s.count||s.count<=0)?"!":null})]}),e.jsxs("div",{className:"flex-[1.6]",children:[e.jsx("label",{className:"block text-base font-bold text-slate-400 uppercase tracking-wide mb-0.5 text-center",children:"Unit Weight (kgs)"}),e.jsx(yt,{id:`weight-mobile-${a}`,type:"text",inputMode:"decimal",placeholder:"0",value:rs[s.id]!==void 0?rs[s.id]:s.weight!=null?String(s.weight):"",onKeyDown:i=>{_a(i),gt(i,a,"weight")},onChange:i=>{let o=i.target.value.replace(/[^0-9.]/g,"").replace(/(\..*)\./,"$1");if(o.length>1&&o.startsWith("0")&&o[1]!=="."&&(o=o.replace(/^0+/,"")),o==="00"||o.includes(".")&&o.split(".")[1].length>3)return;if(o===""||o==="."){Et(p=>({...p,[s.id]:o})),ve(a,"weight",void 0);return}const m=parseFloat(o);!isNaN(m)&&m>5e4||(Et(p=>({...p,[s.id]:o})),!isNaN(m)&&m>0&&ve(a,"weight",m))},onBlur:()=>{const i=V[a]?.weight;Et(o=>{const m={...o};return i!=null&&i>0?m[s.id]=String(i):delete m[s.id],m}),At(s.id,"weight")},className:"py-1.5 px-1 text-center font-medium text-base bg-white !border-slate-200",error:(Mt||Ut[s.id]?.weight)&&(!s.weight||s.weight<=0)?"!":null})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-2 pt-2 border-t border-slate-100",children:[(()=>{const i=Cn[s.id]||"idle";return e.jsx("button",{onClick:()=>Vn(a),className:`flex-1 py-1.5 rounded-lg text-base font-semibold transition-all border shadow-sm text-center  ${i==="saving"?"bg-slate-100 text-slate-400 border-slate-200 cursor-wait flex items-center justify-center gap-1":i==="success"?"bg-green-50 text-green-600 border-green-200 hover:bg-green-100":"bg-white text-slate-600 border-slate-200 hover:bg-slate-50 hover:text-slate-800"}`,disabled:i==="saving"||!s.count||s.count<=0||!s.weight||s.weight<=0,children:i==="saving"?e.jsxs(e.Fragment,{children:[e.jsx(ut,{size:10,
72className:"animate-spin"}),"Saving"]}):i==="success"?"Saved":"Save"})})(),e.jsx("div",{className:"pl-1.5 ml-0.5 border-l border-slate-200",children:e.jsx("button",{onClick:()=>{V.length>1?Na(a):wt([hs()])},className:"p-2 text-red-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-all",title:V.length>1?"Remove":"Clear",children:e.jsx(gs,{size:16})})})]})]})]})]})},s.id))}),z==="hero"&&(()=>{const s=V[V.length-1],a=!!s&&ya(s);return e.jsxs("button",{id:"add-box-button",type:"button",onClick:()=>{a?fr():s&&wa(s)},className:`flex items-center gap-1.5 mt-1.5 ml-9 px-3 py-1.5 rounded-lg text-sm font-semibold transition-colors ${a?"text-blue-600 hover:bg-blue-50 active:bg-blue-100":"text-slate-300 cursor-not-allowed"}`,children:[e.jsx(wc,{size:15,strokeWidth:2.5}),"Add Box"]})})()]}),H&&e.jsxs(W.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"inline-flex items-center gap-3 bg-red-100 text-red-800 font-semibold px-4 py-3 rounded-xl shadow-sm w-full",children:[e.jsx(Xt,{size:20}),H]}),z==="hero"&&e.jsxs("div",{className:"shrink-0 flex flex-wrap items-center justify-between gap-y-2 mt-auto pt-3.5 pb-3.5 px-4 border-t border-slate-100",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[e.jsxs("button",{onClick:()=>js.current?.click(),disabled:bn,className:"flex items-center gap-1.5 text-blue-600 hover:text-blue-700 text-base font-bold transition-colors whitespace-nowrap",children:[bn?e.jsx(ut,{size:12,className:"animate-spin",strokeWidth:2.5}):e.jsx(Nc,{size:12,strokeWidth:2.5}),"Upload Packing List"]}),e.jsxs("button",{onClick:Ll,className:"flex items-center gap-1.5 text-blue-600 hover:text-blue-700 text-base font-bold transition-colors whitespace-nowrap",children:[e.jsx(li,{size:12,strokeWidth:2.5}),"Download Template"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx("input",{type:"file",ref:js,onChange:Il,accept:".xlsx,.xls",className:"hidden"}),e.jsxs("button",{onClick:Kl,disabled:V.length===0||!V.some(s=>s.count),className:`inline-flex items-center gap-1.5 text-base font-bold transition-colors whitespace-nowrap ${V.length===0||!V.some(s=>s.count)?"text-slate-300 cursor-not-allowed":"text-blue-600 hover:text-blue-700"}`,children:[e.jsx(li,{size:16})," Download This List"]}),V.length>1&&e.jsxs("button",{onClick:()=>wt([hs()]),className:"inline-flex items-center gap-1.5 text-base font-bold text-red-400 hover:text-red-600 transition-colors whitespace-nowrap",title:"Delete all boxes",children:[e.jsx(gs,{size:14})," Clear All"]})]})]})]})]})]})]})}),z==="hero"&&Da,e.jsx(kt,{children:C&&e.jsx(W.div,{initial:{opacity:0}
72,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/60 backdrop-blur-sm",children:e.jsxs(W.div,{initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},transition:{type:"spring",damping:25,stiffness:300},className:"bg-white rounded-2xl shadow-2xl p-8 max-w-sm w-full mx-4 text-center relative",children:[e.jsx("button",{onClick:()=>ce(!1),className:"absolute top-3 right-3 p-1.5 rounded-full text-slate-400 hover:text-slate-700 hover:bg-slate-100 transition-colors","aria-label":"Close",children:e.jsx(Vt,{size:20})}),e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-blue-100 flex items-center justify-center",children:e.jsx(Dt,{size:32,className:"text-blue-600"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-800 mb-2",children:"Sign in to Continue"}),e.jsx("p",{className:"text-base text-slate-500 mb-6",children:"Create an account or sign in to compare freight rates from multiple vendors instantly."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{onClick:()=>{ce(!1),x("/signin",{replace:!0})},className:"w-full py-3 px-6 bg-blue-600 text-white font-semibold rounded-xl hover:bg-blue-700 transition-colors shadow-md hover:shadow-lg",children:"Sign In"}),e.jsx("button",{onClick:()=>{ce(!1),x("/userselect")},className:"w-full py-3 px-6 bg-slate-100 text-slate-700 font-semibold rounded-xl hover:bg-slate-200 transition-colors border border-slate-200",children:"Get Started — Create Account"})]})]})})})]}),z==="hero"&&!Da&&e.jsxs(W.div,{initial:b?void 0:{opacity:0,y:18},animate:b?void 0:{opacity:1,y:0},transition:{duration:.45,delay:.1,ease:[.16,1,.3,1]},className:"sticky top-6 flex flex-col gap-2.5 w-full max-w-[340px] mx-auto lg:mx-0 mb-4 lg:mb-0",children:[e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("div",{className:"relative bg-white border border-slate-100 rounded-[24px] shadow-[0_8px_30px_-14px_rgba(15,23,42,0.3)] w-full overflow-hidden",children:[e.jsx(W.div,{className:"absolute -right-6 -bottom-6 text-slate-50 pointer-events-none","aria-hidden":"true",animate:b?void 0:{x:[0,6,0]},transition:b?void 0:{duration:4,repeat:1/0,ease:"easeInOut"},children:e.jsx(Re,{size:120,strokeWidth:1})}),e.jsxs("div",{className:"relative flex items-center justify-between gap-2 px-5 pt-3.5 pb-3 bg-slate-900",children:[e.jsxs("span",{className:"text-sm font-black text-blue-200/80 uppercase tracking-wide flex items-center gap-1.5 whitespace-nowrap shrink-0",children:[e.jsx(jc,{size:14,className:"text-yellow-400 shrink-0"})," Live Summary"]}),N&&F&&ee>0?e.jsxs("div",{className:"bg-yellow-400 text-slate-900 text-xs font-black px-2.5 py-1 rounded-full flex items-center gap-1 shadow-sm whitespace-nowrap shrink-0",children:[e.jsx(Va,{size:11,strokeWidth:3.5})," Ready"]}):e.jsxs("div",{className:"bg-slate-800 text-slate-400 text-xs font-bold px-2.5 py-1 rounded-full flex items-center gap-1 border border-slate-700 whitespace-nowrap shrink-0",children:[e.jsx(Xt,{size:11,strokeWidth:2.5})," Incomplete"]})]}),e.jsxs("div",{className:"relative p-4 pt-3.5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-base font-bold text-slate-400 flex items-center gap-2 uppercase tracking-widest mb-1",children:[e.jsx(kc,{size:14})," Weight"]}),e.jsxs("div",{className:"flex items-baseline gap-1.5 text-slate-900",children:[e.jsx("span",{className:"text-3xl font-black tracking-tighter",children:e.jsx(Oi,{value:ms>0?ms:0,decimals:0,reduceMotion:b})}),e.jsx("span",{className:"text-base font-bold text-slate-400 uppercase",children:"KG"})]})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-base font-bold text-slate-400 flex items-center gap-2 uppercase tracking-widest mb-1",children:[e.jsx(Ic,{size:14})," Distance"]}),e.jsxs("div",{className:"flex items-baseline gap-1.5 text-slate-900",children:[e.jsx("span",{className:"text-3xl font-black tracking-tighter",children:Ht?e.jsx(Oi,{value:Ht,decimals:0,reduceMotion:b}):"—"}),e.jsx("span",{className:"text-base font-bold text-slate-400 uppercase",children:"KM"})]})]})]}),!(N&&F&&ee>0)&&(()=>{const a=((N?1:0)+(F?1:0)+(ms>0?1:0))/3*100;return e.jsxs("div",{className:"mt-3 mb-1",children:[e.jsxs("div",{className:"relative h-1.5 rounded-full bg-slate-100 overflow-hidden",children:[e.jsx(W.div,{className:"absolute inset-y-0 left-0 rounded-full bg-gradient-to-r from-blue-600 to-blue-400",initial:!1,animate:{width:`${a}%`},transition:{duration:.5,ease:[.16,1,.3,1]}}),!b&&a>0&&a<100&&e.jsx(W.div,{className:"absolute top-1/2 -translate-y-1/2 text-blue-700",style:{left:`calc(${a}% - 5px)`}
72,animate:{opacity:[.4,1,.4]},transition:{duration:1.4,repeat:1/0,ease:"easeInOut"},children:e.jsx(Re,{size:10,strokeWidth:2.5})})]}),e.jsxs("div",{className:"flex justify-between mt-1.5 text-[10px] font-bold uppercase tracking-wide",children:[e.jsx("span",{className:N?"text-blue-600":"text-slate-300",children:"Origin"}),e.jsx("span",{className:F?"text-blue-600":"text-slate-300",children:"Destination"}),e.jsx("span",{className:ms>0?"text-blue-600":"text-slate-300",children:"Weight"})]})]})})(),e.jsx("div",{className:"w-full border-t-2 border-dashed border-slate-100 my-3","aria-hidden":"true"}),e.jsxs("div",{className:"grid grid-cols-2 gap-y-3 gap-x-6",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-base font-bold text-slate-400 flex items-center gap-1.5 uppercase tracking-wider mb-1",children:[e.jsx(Jt,{size:12})," Origin"]}),e.jsx("div",{className:"text-base font-bold text-slate-900 truncate",children:N||e.jsx("span",{className:"text-slate-300 italic font-medium",children:"Select"})})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-base font-bold text-slate-400 flex items-center gap-1.5 uppercase tracking-wider mb-1",children:[e.jsx(Sa,{size:12})," Destination"]}),e.jsx("div",{className:"text-base font-bold text-slate-900 truncate",children:F||e.jsx("span",{className:"text-slate-300 italic font-medium",children:"Select"})})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-base font-bold text-slate-400 flex items-center gap-1.5 uppercase tracking-wider mb-1",children:[e.jsx(Re,{size:12})," Mode"]}),e.jsx("div",{className:"text-base font-bold text-slate-900 capitalize",children:ct})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-base font-bold text-slate-400 flex items-center gap-1.5 uppercase tracking-wider mb-1",children:[e.jsx(Dt,{size:12})," Shipment"]}),e.jsx("div",{className:"text-base font-bold text-slate-900 capitalize",children:We})]})]})]})]})}),z==="hero"&&e.jsxs("div",{className:"w-full flex flex-col items-center",children:[e.jsxs("div",{className:"w-full mb-2",children:[e.jsxs("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-1.5 flex items-center gap-1.5",children:[e.jsx("span",{children:"Optional Charges"}),e.jsx("span",{className:"font-normal text-slate-300",children:"(Select if applicable)"})]}),e.jsx("div",{className:"flex justify-between gap-2",children:[{key:"cod",label:"COD",description:"Cash on Delivery — handling & collection fee"},{key:"topay",label:"To-Pay",description:"Freight charged to consignee at destination"},{key:"dacc",label:"DACC",description:"Delivery Against Consignee Copy surcharge"}].map(s=>{const a=cs.has(s.key);return e.jsxs("label",{className:`relative flex items-center justify-center gap-1.5 py-2 px-3 cursor-pointer transition-all select-none flex-1 min-w-0 ${a?"bg-white":"bg-white hover:bg-blue-50/40"}`,children:[e.jsx("input",{type:"checkbox",checked:a,onChange:()=>yl(s.key),className:"sr-only"}),e.jsx(W.div,{className:`flex-shrink-0 w-4 h-4 rounded border-2 flex items-center justify-center transition-colors ${a?"bg-blue-600 border-blue-600":"bg-white border-slate-300"}`,animate:!b&&a?{scale:[.7,1.15,1]}:void 0,transition:{duration:.32,ease:[.34,1.56,.64,1]},children:e.jsx(kt,{children:a&&e.jsx(W.span,{initial:b?void 0:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:b?void 0:{scale:0,opacity:0},transition:{duration:.18},children:e.jsx(Va,{size:10,className:"text-white",strokeWidth:3})})})}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("span",{className:`text-sm font-bold leading-none whitespace-nowrap ${a?"text-blue-700":"text-slate-800"}`,children:s.label}),e.jsxs("div",{className:"relative group/info flex items-center justify-center shrink-0",children:[e.jsx(Gr,{size:12,className:"text-slate-400 hover:text-slate-600 transition-colors"}),e.jsxs("div",{className:`absolute bottom-full mb-1.5 hidden group-hover/info:block w-max max-w-[220px] bg-slate-800 text-white text-sm px-2.5 py-1 rounded shadow-lg z-[200] pointer-events-none ${s.key==="cod"?"left-0":s.key==="dacc"?"right-0":"left-1/2 -translate-x-1/2"}`,children:[s.description,e.jsx("div",{className:`absolute top-full border-4 border-transparent border-t-slate-800 ${s.key==="cod"?"left-1.5":s.key==="dacc"?"right-1.5":"left-1/2 -translate-x-1/2"}`})]})]})]})]},s.key)})})]}),e.jsxs("button",{id:"calculate-button",type:"button",onClick:()=>
72{if(!t){ce(!0);return}xr(),Bt()},disabled:T||Ge||Ps||Ts,className:`group relative w-full flex items-center justify-center gap-3 px-8 py-4 rounded-2xl text-lg font-bold tracking-wide transition-all shadow-lg overflow-hidden ${T||Ge?"bg-slate-100 text-slate-400 cursor-wait":Ps||Ts?"bg-slate-100 text-slate-400 cursor-not-allowed":"bg-gradient-to-r from-blue-600 via-blue-600 to-slate-900 hover:shadow-blue-400/30 text-white active:scale-[0.98]"}`,children:[e.jsx("span",{className:"absolute inset-0 opacity-0 group-hover:opacity-20 transition-opacity duration-300 pointer-events-none","aria-hidden":"true",style:{backgroundImage:"repeating-linear-gradient(45deg, #facc15 0px, #facc15 10px, transparent 10px, transparent 20px)"}}),T?e.jsxs(e.Fragment,{children:[e.jsx(ut,{size:20,className:"animate-spin"}),e.jsx("span",{children:"Calculating…"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:19,className:"relative"}),e.jsx("span",{className:"relative",children:"Calculate Freight"}),e.jsx(Fa,{size:22,className:"relative opacity-90 group-hover:translate-x-1 transition-transform"})]})]}),E!==null&&E>0&&E<=10&&e.jsxs("p",{className:`text-base text-center mt-3 font-medium ${E<=5?"text-amber-600":"text-blue-500"}`,children:[E,"/15 searches this hour"]}),e.jsx(Kd,{isTransporter:h()?.isTransporter,isAdmin:h()?.isAdmin,refreshSignal:at})]})]}),z==="hero"&&Da,z==="results"&&e.jsxs(W.aside,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-12},transition:{type:"spring",stiffness:340,damping:32,delay:.05},className:"hidden xl:flex flex-col gap-4 sticky top-20 self-start min-w-0",children:[e.jsxs("div",{className:"rounded-2xl overflow-hidden ",children:[e.jsx("div",{className:"px-4 py-3 border-b border-slate-100 bg-slate-50 cursor-pointer hover:bg-blue-50 transition-colors group",onClick:()=>{ne("hero"),Se(!1),window.scrollTo({top:0,behavior:"smooth"})},title:"Click to edit boxes",children:e.jsxs("span",{className:"text-xs font-black text-slate-700 group-hover:text-blue-600 uppercase tracking-widest flex items-center gap-1.5 transition-colors",children:[e.jsx(Dt,{size:13})," Shipment Boxes",e.jsx("span",{className:"ml-auto text-[10px] font-semibold text-slate-400 group-hover:text-blue-500 normal-case tracking-normal",children:"Edit ›"})]})}),e.jsxs("div",{children:[e.jsxs("table",{className:"w-full text-sm",style:{tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"1.5rem"}}),e.jsx("col",{}),e.jsx("col",{style:{width:"2.75rem"}}),e.jsx("col",{style:{width:"7rem"}})]}),e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-100",children:[e.jsx("th",{className:"text-left px-2 py-2 text-[10px] font-black uppercase tracking-widest text-slate-400 whitespace-nowrap",children:"#"}),e.jsx("th",{className:"text-left px-2 py-2 text-[10px] font-black uppercase tracking-widest text-slate-400 whitespace-nowrap",children:"Box Name"}),e.jsx("th",{className:"text-center px-2 py-2 text-[10px] font-black uppercase tracking-widest text-slate-400 whitespace-nowrap",children:"QTY"}),e.jsx("th",{className:"text-right px-2 py-2 text-[10px] font-black uppercase tracking-widest text-slate-400 whitespace-nowrap",children:"Unit Wt (kg)"})]})})]}),e.jsx("div",{style:{maxHeight:"200px",overflowY:"auto"},className:"[&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-blue-500 [&::-webkit-scrollbar-thumb]:rounded-full",children:e.jsxs("table",{className:"w-full text-sm",style:{tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"1.5rem"}}),e.jsx("col",{}),e.jsx("col",{style:{width:"2.75rem"}}),e.jsx("col",{style:{width:"7rem"}})]}),e.jsxs("tbody",{children:[V.filter(s=>s.count&&s.count>0).map((s,a)=>e.jsxs("tr",{className:"border-b border-slate-50 last:border-0 hover:bg-slate-50/60 transition-colors",children:[e.jsx("td",{className:"px-3 py-2.5 text-slate-400 font-semibold text-xs",children:a+1}),e.jsx("td",{className:"px-3 py-2.5 text-slate-700 font-medium truncate",children:s.description?.trim()||e.jsx("span",{className:"text-slate-300 italic",children:"—"})}),e.jsx("td",{className:"px-3 py-2.5 text-center text-slate-800 font-bold",children:s.count}),e.jsx("td",{className:"px-3 py-2.5 text-right text-slate-800 font-bold",children:s.weight??"—"})]},s.id)),V.filter(s=>s.count&&s.count>0).length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-6 text-center text-slate-400 text-xs",children:"No boxes added"})})]})]})}),V.filter(s=>s.count&&s.count>0).length>0&&e.jsxs("table",{className:"w-full text-sm",style:{tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"1.5rem"}}),e.jsx("col",{}),e.jsx("col",{style:{width:"2.75rem"}}),e.jsx("col",{style:{width:"7rem"}})]}),e.jsx("tfoot",{children:e.jsxs("tr",{className:"bg-slate-50 border-t border-slate-200",children:[e.jsx("td",{className:"px-3 py-2 text-[10px] font-black text-slate-400 uppercase tracking-wider",colSpan:2,children:"Total Boxes"}),e.jsx("td",{className:"px-3 py-2 text-center text-slate-800 font-black text-xs",children:V.reduce((s,a)=>
72s+(a.count||0),0)}),e.jsxs("td",{className:"px-3 py-2 text-right text-slate-800 font-black text-xs",children:[V.reduce((s,a)=>s+(a.weight||0)*(a.count||0),0).toFixed(1)," kg"]})]})})]})]})]}),(()=>{const s=$=>{const _e=Ne($);return Number.isFinite(_e)&&_e>0&&$?.message!=="service not available"},a=(le||[]).filter(s),i=(de||[]).filter(s),o=["LOCAL FTL","Wheelseye FTL","wheelseye","local ftl","ftl transporter","local-ftl"],m=$=>{const _e=($.companyName||$.transporterName||"").toLowerCase();return o.some(v=>_e.includes(v.toLowerCase()))},p=a.filter($=>!m($)).map($=>Ne($)).filter($=>Number.isFinite($)&&$>0),A=p.length>0?Math.min(...p):1/0,Y=p.length>0?i.filter($=>$.isMoverLive||m($)||$.isIndividualFtl||Ne($)<A):i,pe=[...a,...Y],se=pe.map($=>$.estimatedTime??0).filter($=>$>0&&$<300),fe=se.length>0?Math.max(...se):3,te=Ht??le?.[0]?.distanceKm??0,he=Vr(te),O=pe.map($=>Ne($)).filter($=>Number.isFinite($)&&$>0),ge=O.length>0?Math.floor(Math.min(...O)):0,ye=O.length>0?Math.ceil(Math.max(...O)):1e7,Ze=Math.max(Zs,1),ze=Math.min(Cs,fe),et=zr(Math.max(Zs,Ft[0])),Nt=zr(Math.min(Cs,Ft[Ft.length-1])),jt=Math.max(ga,ge),je=Math.min(ba,ye),Xe=Math.min(Math.max(va,2),5),Ke=[{label:"Cheapest",value:"price",icon:e.jsx(oi,{size:12})},{label:"Fastest",value:"time",icon:e.jsx(It,{size:12})},{label:"Most Ratings",value:"rating",icon:e.jsx(ws,{size:12})}],Qt=Ke.find($=>$.value===R)||Ke[0],Is=Ze>1||ze<fe||Xe>2||jt>ge||je<ye||R!=="price";
72return e.jsxs("div",{className:"flex flex-col gap-4 rounded-2xl p-4 ",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5 flex-nowrap",children:[e.jsxs("span",{className:"text-xs font-black text-slate-700 uppercase tracking-widest flex items-center gap-1.5 flex-shrink-0 whitespace-nowrap",children:[e.jsx(Cc,{size:13})," Filters"]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[Is&&e.jsx("button",{onClick:()=>{Sn(0),mr(1e7),Xs(0),Js(300),hr(2),P.current=!0,k("price")},className:"text-[10px] font-bold text-slate-400 hover:text-red-500 transition-colors whitespace-nowrap flex-shrink-0",children:"Reset"}),e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsxs("button",{onClick:()=>ur($=>!$),className:"flex items-center gap-1 px-2 py-1.5 bg-blue-50 hover:bg-blue-100 border border-blue-200 rounded-lg text-blue-700 text-[10px] font-black uppercase tracking-wide transition-all whitespace-nowrap",children:[Qt.icon,e.jsx("span",{className:"whitespace-nowrap",children:Qt.label}),e.jsx(_s,{size:10,className:`transition-transform flex-shrink-0 ${Pn?"rotate-180":""}`})]}),Pn&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>ur(!1)}),e.jsxs("div",{className:"absolute top-full right-0 mt-1.5 w-44 bg-white rounded-xl border border-slate-200 shadow-xl z-20 overflow-hidden",children:[e.jsx("div",{className:"px-3 pt-2.5 pb-1",children:e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-slate-400",children:"Sort by"})}),Ke.map($=>e.jsxs("button",{onClick:()=>{P.current=!0,k($.value),ur(!1)},className:`w-full flex items-center gap-2.5 px-3 py-2.5 text-[11px] font-bold transition-all text-left border-t border-slate-50 first:border-0 ${R===$.value?"bg-blue-600 text-white":"text-slate-700 hover:bg-blue-50"}`,children:[$.icon,$.label,R===$.value&&e.jsx(Va,{size:11,strokeWidth:3,className:"ml-auto"})]},$.value))]})]})]})]})]}),e.jsx("div",{className:"h-px bg-slate-100"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5 mb-2.5 flex-nowrap",children:[e.jsxs("p",{className:"text-xs font-black uppercase tracking-widest text-slate-600 flex items-center gap-1.5 whitespace-nowrap flex-shrink-0",children:[e.jsx(ws,{size:13})," Transporter Ratings"]}),e.jsxs("span",{className:"text-xs font-black text-blue-600 flex items-center gap-0.5 whitespace-nowrap flex-shrink-0",children:[e.jsx(ws,{size:11,fill:"currentColor",className:"text-amber-400"}),Xe.toFixed(1),"+"]})]}),e.jsxs("div",{className:"px-0.5",children:[e.jsx("div",{className:"flex items-center w-full mb-1",onMouseLeave:()=>Tn(null),children:[1,2,3,4,5].map($=>{const _e=$<2,be=Math.max(0,Math.min(1,(Ml??Xe)-($-1)));return e.jsx("button",{type:"button","aria-label":`${$} stars & up`,disabled:_e,onClick:()=>hr(Math.max(2,$)),onMouseEnter:()=>Tn(_e?2:$),className:`flex-1 flex justify-center py-1 ${_e?"cursor-default":""}`,children:e.jsxs("span",{className:"relative inline-block",style:{width:30,height:30},children:[e.jsx(ws,{size:30,strokeWidth:1.5,className:"absolute inset-0 text-slate-300",fill:"white"}),e.jsx("span",{className:"absolute inset-0 overflow-hidden",style:{width:`${be*100}%`},children:e.jsx(ws,{size:30,strokeWidth:1.5,className:"text-amber-400",fill:"currentColor"})})]})},$)})}),e.jsx("p",{className:"text-[10px] font-bold text-slate-400 text-center mb-2",children:"Tap a star for that rating & up"}),e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0",style:{width:"25%"},children:e.jsx("div",{className:"drs-track-row",children:e.jsx("div",{className:"drs-track bg-blue-600",style:{left:"9px",right:"0px"}})})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"drs-track-row",children:[e.jsx("div",{className:"drs-track bg-slate-200",style:{left:"0px",right:"9px"}}),e.jsx("div",{className:"drs-track bg-blue-600",style:{left:"0px",width:`max(0px, calc(${(Xe-2)/3*100}% - 9px))`}}),e.jsx("input",{type:"range",min:2,max:5,step:.1,value:Xe,onChange:$=>hr(Math.max(2,Number($.target.value))),className:"drs-thumb"})]})})]}),e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"flex-shrink-0 text-[9px] font-bold text-blue-500 text-center mt-1.5",style:{width:"25%"},children:"1★"}),e.jsx("div",{className:"flex-1 min-w-0 flex justify-between mt-1.5",children:[2,3,4,5].map($=>e.jsxs("span",{className:`text-[9px] font-bold transition-colors ${Xe>=$?"text-blue-500":"text-slate-300"}
72`,children:[$,"★"]},$))})]})]})]}),e.jsx("div",{className:"h-px bg-slate-100"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5 mb-2.5 flex-nowrap",children:[e.jsxs("p",{className:"text-xs font-black uppercase tracking-widest text-slate-600 flex items-center gap-1.5 whitespace-nowrap flex-shrink-0",children:[e.jsx(oi,{size:13})," Price Range"]}),e.jsxs("span",{className:"text-xs font-black text-blue-600 whitespace-nowrap flex-shrink-0",children:["₹",jt.toLocaleString("en-IN")," – ₹",je.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"px-0.5",children:[e.jsx(Rr,{min:ge,max:ye,step:Math.max(1,Math.round((ye-ge)/200)),minValue:jt,maxValue:je,onMinChange:Sn,onMaxChange:mr}),e.jsxs("div",{className:"flex justify-between mt-1.5",children:[e.jsxs("span",{className:"text-[9px] font-bold text-slate-400",children:["₹",ge.toLocaleString("en-IN")]}),e.jsxs("span",{className:"text-[9px] font-bold text-slate-400",children:["₹",ye.toLocaleString("en-IN")]})]})]})]}),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-px bg-slate-100"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5 mb-2.5 flex-nowrap",children:[e.jsxs("p",{className:"text-xs font-black uppercase tracking-widest text-slate-600 flex items-center gap-1.5 whitespace-nowrap flex-shrink-0",children:[e.jsx(da,{size:13})," Delivery Time"]}),e.jsx("span",{className:"text-xs font-black text-blue-600 whitespace-nowrap flex-shrink-0",children:he?e.jsxs(e.Fragment,{children:[Dr[et-1],et===Nt?"":`–${Dr[Nt-1]}`]}):e.jsxs(e.Fragment,{children:[Ze,Ze===ze?"":`–${ze}`," ",ze===1&&Ze===1?"Day":"Days"]})})]}),e.jsx("div",{className:"px-0.5",children:he?e.jsxs(e.Fragment,{children:[e.jsx(Rr,{min:1,max:Ft.length,step:1,minValue:et,maxValue:Nt,onMinChange:$=>Xs($i($)),onMaxChange:$=>Js($i($))}),e.jsx("div",{className:"flex justify-between mt-1.5",children:Dr.map(($,_e)=>{const v=_e+1;return e.jsx("span",{className:`text-[9px] font-bold transition-colors ${v>=et&&v<=Nt?"text-blue-500":"text-slate-300"}`,children:$},$)})}),e.jsx("p",{className:"text-[9px] font-medium text-slate-400 mt-1.5 leading-relaxed",children:"Standard vendors deliver in whole days, not hours — dragging into the hour range hides them here (hourly delivery is only available via Quick Booking above)."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Rr,{min:1,max:fe,step:1,minValue:Ze,maxValue:ze,onMinChange:Xs,onMaxChange:Js}),e.jsx("div",{className:"flex justify-between mt-1.5",children:Array.from({length:fe},($,_e)=>_e+1).map($=>e.jsxs("span",{className:`text-[9px] font-bold transition-colors ${$>=Ze&&$<=ze?"text-blue-500":"text-slate-300"}`,children:[$,"d"]},$))})]})})]})]})]})})()]},"box-summary-panel"),e.jsx(kt,{children:z==="results"&&e.jsx(W.main,{id:"market-results",initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:24},transition:{type:"spring",stiffness:340,damping:32,mass:.9,delay:0},style:{willChange:"transform",transformOrigin:"top center",maxWidth:"100%"},className:"min-w-0 overflow-x-auto flex-1 px-2 pb-6 pt-0 relative z-10 scroll-smooth",children:e.jsxs("div",{className:"w-full space-y-3",children:[U&&(()=>{const s=()=>{const a=Math.max(0,...V.flatMap(i=>[Number(i.length)||0,Number(i.width)||0,Number(i.height)||0]));x(`/quick-booking?from=${N}&to=${F}&weight=${ee}&dim=${a}&distance=0`)};return e.jsxs(W.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"bg-white rounded-2xl border border-amber-200 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-br from-amber-400 to-yellow-400 p-8 text-white relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-white/10 rounded-full -mr-20 -mt-20 blur-3xl"}),e.jsxs("div",{className:"relative z-10 flex items-start gap-4",children:[e.jsx("div",{className:"w-14 h-14 bg-white/30 rounded-2xl flex items-center justify-center flex-shrink-0",children:e.jsx(It,{size:28,className:"text-white fill-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-amber-100 text-base font-bold uppercase tracking-widest mb-1",children:"Same Pincode"}),e.jsxs("h2",{className:"text-2xl font-black leading-tight text-slate-900",children:["Shipping within ",N,"?"]}),e.jsx("p",{className:"text-amber-900/80 mt-2 text-base leading-relaxed max-w-lg",children:"Within the same pincode, only Quick Booking hyperlocal delivery is available — standard freight vendors don't serve intra-pincode moves."})]})]})]}),e.jsx("div",{className:"p-6",children:qe?e.jsxs("div",{className:"relative p-5 rounded-2xl border bg-gradient-to-r from-amber-50 to-orange-50 border-amber-300 shadow-sm hover:shadow-md transition-all duration-300",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Wa,{as:"h3",className:"font-bold tracking-tight text-slate-800 font-display min-w-0",children:qe.name}),e.jsx("span",{className:"inline-flex items-center gap-1 text-base font-black px-2 py-0.5 rounded-full border shadow-sm bg-green-50 text-green-600 border-green-100 flex-shrink-0",children:"LIVE"})]}),e.jsxs("p",{className:"mt-2.5 text-base text-slate-500 font-body",children:["Cheapest Quick Booking option within ",N,qe.vehicleName?` · ${qe.vehicleName}`:""]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 sm:flex-shrink-0",children:[e.jsx("div",{className:"flex flex-col items-end",children:e.jsxs("div",{className:"flex items-baseline gap-0.5 font-black leading-none text-slate-900 font-display whitespace-nowrap",children:[e.jsx("span",{style:{fontSize:"clamp(0.9rem, 1.4vw, 1.25rem)"},className:"opacity-80",children:"₹"}),e.jsx("span",{style:{fontSize:"clamp(1.4rem, 2.4vw, 2rem)"},className:"tracking-tighter",children:Zt(qe.price)})]})}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>ha(qe.platform,qe.vehicleName,qe.price),style:{padding:"clamp(0.4rem, 0.7vw, 0.6rem) clamp(0.6rem, 1.2vw, 1.25rem)",fontSize:"clamp(0.65rem, 0.9vw, 0.75rem)"},className:"font-bold rounded-xl transition-all tracking-widest uppercase font-display inline-flex items-center justify-center gap-1.5 whitespace-nowrap flex-shrink-0 bg-slate-900 text-white hover:bg-slate-700 shadow-sm active:scale-95",children:[e.jsx(Dt,{size:12}),"Book Now"]}),e.jsx("button",{onClick:s,style:{padding:"clamp(0.4rem, 0.7vw, 0.6rem) clamp(0.6rem, 1.2vw, 1.25rem)",fontSize:"clamp(0.65rem, 0.9vw, 0.75rem)"},className:"font-bold rounded-xl transition-all tracking-widest uppercase font-display inline-flex items-center justify-center gap-1.5 whitespace-nowrap flex-shrink-0 bg-blue-600 text-white hover:bg-blue-700 shadow-sm shadow-blue-200 active:scale-95",children:"View More"})]})]})]}),(nt.priced.length>1||nt.pending.length>0)&&e.jsxs("div",{className:"mt-4 pt-3 border-t border-amber-200/60 flex items-center justify-center flex-wrap gap-2",children:[nt.priced.slice(1).map(a=>e.jsxs("button",{onClick:()=>ha(a.platform,a.vehicleName,a.price),title:a.vehicleName||void 0,className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full border border-amber-200 bg-white/70 hover:bg-white text-sm font-bold text-slate-500 transition-colors",children:[a.name," ",e.jsxs("span",{className:"text-slate-900 font-black",children:["₹",Zt(a.price)]})]},a.platform)),nt.pending.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full border border-amber-100 bg-white/40 text-sm font-semibold text-slate-400",children:[e.jsx(ut,{size:11,className:"animate-spin"})," ",a.name]},a.platform))]})]}):an||$e?e.jsxs("button",{onClick:s,className:"w-full text-left bg-gradient-to-r from-amber-50 to-orange-50 border-2 border-amber-300 rounded-2xl p-5 hover:border-amber-400 hover:shadow-md transition-all group flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-extrabold text-amber-900 flex items-center gap-1.5",children:[e.jsx(ut,{size:14,className:"animate-spin text-amber-600"}),"Fetching live prices…"]}),e.jsxs("p",{className:"text-sm text-amber-700",children:["Checking hyperlocal platforms within ",N]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-amber-700 group-hover:text-amber-900 font-semibold text-sm flex-shrink-0",children:["View ",e.jsx(Fa,{size:14})]})]}):e.jsxs("button",{onClick:s,className:"inline-flex items-center gap-2 px-6 py-3 bg-amber-400 hover:bg-amber-500 text-amber-900 font-extrabold text-base rounded-full transition-colors shadow-sm",children:[e.jsx(It,{size:16,className:"fill-amber-900"}),"Find Quick Booking platforms"]})})]})})(),f&&!y&&!(le&&le.length>0)&&!(de&&de.length>0)&&!T&&!H&&!X&&e.jsxs(W.div,{initial:{opacity:0,y:-10}
72,animate:{opacity:1,y:0},className:"flex items-center justify-between gap-4 bg-indigo-50 border border-indigo-100 rounded-xl px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-indigo-100 flex items-center justify-center flex-shrink-0",children:e.jsx(na,{size:20,className:"text-indigo-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:"Want to compare your own vendors?"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Add one to see how it stacks up against market rates."})]})]}),e.jsxs("button",{onClick:()=>{const s=h();s?._id&&sessionStorage.removeItem(g(s._id)),x("/addvendor")},className:"inline-flex items-center gap-1.5 px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-bold rounded-lg transition-colors flex-shrink-0",children:[e.jsx(na,{size:15}),"Add Your First Vendor"]})]}),G?.eligible&&!X&&!_&&e.jsxs("section",{id:"quick-booking-section",className:"mb-5",children:[Ks&&Pe&&Le&&e.jsx(zo,{isOpen:!!Ks,onClose:()=>sn(null),platform:Ks.platform,vehicleName:Ks.vehicleName,price:Ks.price,defaultPhone:h()?.phone?String(h().phone):"",route:{fromPincode:N,toPincode:F,fromText:Pe.placeText,toText:Le.placeText,fromLat:Pe.lat,fromLng:Pe.lng,toLat:Le.lat,toLng:Le.lng,fromCity:Pe.city,toCity:Le.city,weight:ee,vehicleClass:Tr(ee,Math.max(0,...V.flatMap(s=>[Number(s.length)||0,Number(s.width)||0,Number(s.height)||0]))||null)||"wheeler3"}}),e.jsxs("div",{className:"mb-4 flex items-stretch h-10 gap-3",children:[e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:"w-1 bg-amber-600 rounded-l-sm flex-shrink-0"}),e.jsxs("h2",{className:"bg-amber-400 text-amber-900 text-xl font-extrabold flex items-center pl-4 gap-2 select-none",style:{clipPath:"polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%)",paddingRight:"40px"},children:[e.jsx(It,{size:16,className:"fill-amber-900 flex-shrink-0"}),"Quick Booking"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:ll,alt:"Porter",title:"Porter",className:"w-6 h-6 rounded-md shadow-sm object-cover"}),e.jsx("img",{src:rm,alt:"Rapido",title:"Rapido",className:"w-6 h-6 rounded-md shadow-sm object-cover"}),e.jsx("img",{src:nl,alt:"Mover",title:"Mover",className:"w-6 h-6 rounded-md shadow-sm object-cover"}),e.jsx("img",{src:il,alt:"Wheelseye",title:"Wheelseye",className:"w-6 h-6 rounded-md shadow-sm object-cover"})]})]}),(()=>{const s=le?.[0]?.distanceKm??G?.distanceKm??0,a=()=>{const o=G?.maxDimCm??0;x(`/quick-booking?from=${N}&to=${F}&weight=${ee}&dim=${o}&distance=${s}`)},i=lm(s);return qe?e.jsxs("div",{className:"relative p-5 rounded-2xl border bg-gradient-to-r from-amber-50 to-orange-50 border-amber-300 shadow-sm hover:shadow-md hover:-translate-y-0.5 transition-all duration-300",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Wa,{as:"h3",className:"font-bold tracking-tight text-slate-800 font-display min-w-0",children:qe.name}),e.jsx("span",{className:"inline-flex items-center gap-1 text-base font-black px-2 py-0.5 rounded-full border shadow-sm bg-green-50 text-green-600 border-green-100 flex-shrink-0",children:"LIVE"})]}),e.jsxs("p",{className:"mt-2.5 text-base text-slate-500 font-body",children:["Cheapest Quick Booking option for this route",qe.vehicleName?` · ${qe.vehicleName}`:""]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 sm:flex-shrink-0",children:[e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsxs("div",{className:"flex items-baseline gap-0.5 font-black leading-none text-slate-900 font-display whitespace-nowrap",children:[e.jsx("span",{style:{fontSize:"clamp(0.9rem, 1.4vw, 1.25rem)"},className:"opacity-80",children:"₹"}),e.jsx("span",{style:{fontSize:"clamp(1.4rem, 2.4vw, 2rem)"},className:"tracking-tighter",children:Zt(qe.price)})]}),i&&e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[11px] font-bold text-amber-700 whitespace-nowrap",children:[e.jsx(da,{size:11}),i]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>ha(qe.platform,qe.vehicleName,qe.price),style:{padding:"clamp(0.4rem, 0.7vw, 0.6rem) clamp(0.6rem, 1.2vw, 1.25rem)",fontSize:"clamp(0.65rem, 0.9vw, 0.75rem)"},className:"font-bold rounded-xl transition-all tracking-widest uppercase font-display inline-flex items-center justify-center gap-1.5 whitespace-nowrap flex-shrink-0 bg-slate-900 text-white hover:bg-slate-700 shadow-sm active:scale-95",children:[e.jsx(Dt,{size:12}),"Book Now"]}),e.jsx("button",{onClick:a,style:{padding:"clamp(0.4rem, 0.7vw, 0.6rem) clamp(0.6rem, 1.2vw, 1.25rem)",fontSize:"clamp(0.65rem, 0.9vw, 0.75rem)"},className:"font-bold rounded-xl transition-all tracking-widest uppercase font-display inline-flex items-center justify-center gap-1.5 whitespace-nowrap flex-shrink-0 bg-blue-600 text-white hover:bg-blue-700 shadow-sm shadow-blue-200 active:scale-95",children:"View More"})]})]})]}),(nt.priced.length>1||nt.pending.length>0)&&e.jsxs("div",{className:"mt-4 pt-3 border-t border-amber-200/60 flex items-center flex-wrap gap-x-1 gap-y-2",children:[nt.priced.slice(1).map((o,m)=>e.jsxs(Rs.Fragment,{children:[m>0&&e.jsx("span",{className:"text-slate-300 font-bold text-lg",children:"|"}),e.jsxs("button",{onClick:()=>ha(o.platform,o.vehicleName,o.price),title:o.vehicleName||void 0,className:"inline-flex items-center gap-1.5 px-2 text-lg font-bold text-slate-600 hover:text-slate-900 transition-colors",children:[o.name," ",e.jsxs("span",{className:"text-slate-900 font-black",children:["₹",Zt(o.price)]})]})]},o.platform)),nt.pending.map((o,m)=>e.jsxs(Rs.Fragment,{children:[(m>0||nt.priced.length>1)&&e.jsx("span",{className:"text-slate-300 font-bold text-lg",children:"|"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 text-lg font-semibold text-slate-400",children:[e.jsx(ut,{size:14,className:"animate-spin"})," ",o.name]})]},o.platform))]})]}):an?e.jsx("button",{onClick:a,className:"w-full text-left bg-gradient-to-r from-amber-50 to-orange-50 border-2 border-amber-300 rounded-2xl p-5 hover:border-amber-400 hover:shadow-md transition-all group",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-extrabold text-amber-900 text-lg flex items-center gap-1.5",children:[e.jsx(ut,{size:16,className:"animate-spin text-amber-600"}),"Fetching live prices…"]}),e.jsx("p",{className:"text-base text-amber-700",children:"Checking live prices for this route"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-amber-700 group-hover:text-amber-900 font-semibold text-base flex-shrink-0",children:["View ",e.jsx(Fa,{size:16})]})]})}):e.jsx("button",{onClick:a,className:"w-full text-left bg-gradient-to-r from-amber-50 to-orange-50 border-2 border-amber-300 rounded-2xl p-5 hover:border-amber-400 hover:shadow-md transition-all group",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-extrabold text-amber-900 text-lg",children:"On-demand delivery via Rapido & Porter"}),e.jsx("p",{className:"text-base text-amber-700",children:"Tap to check live Quick Booking prices for this route"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-amber-700 group-hover:text-amber-900 font-semibold text-base flex-shrink-0",children:["Open ",e.jsx(Fa,{size:16})]})]})})})()]}),T?e.jsx(Vi,{}):X?e.jsxs(W.div,{initial:{opacity:0,y:20}
72,animate:{opacity:1,y:0},className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-br from-blue-600 to-cyan-600 p-8 text-white relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-white/5 rounded-full -mr-20 -mt-20 blur-3xl"}),e.jsxs("div",{className:"relative z-10 flex items-start gap-4",children:[e.jsx("div",{className:"w-14 h-14 bg-white/20 rounded-2xl flex items-center justify-center flex-shrink-0",children:e.jsx(ri,{size:28,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-blue-100 text-base font-bold uppercase tracking-widest mb-1",children:"Sea-Only Destination"}),e.jsx("h2",{className:"text-2xl font-black leading-tight",children:X.islandName}),e.jsx("p",{className:"text-blue-100 mt-2 text-base leading-relaxed max-w-lg",children:X.transportNote})]})]})]}),e.jsxs("div",{className:"p-8 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-bold text-slate-800 mb-1 flex items-center gap-2",children:[e.jsx(Sa,{size:16,className:"text-blue-500"}),"How to ship to ",X.islandName]}),e.jsx("p",{className:"text-base text-slate-500 leading-relaxed",children:"Road freight can travel to a mainland port, then continue by cargo vessel. Choose your preferred departure port below to get a freight quote for the land leg of the journey."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-base font-bold text-slate-400 uppercase tracking-widest",children:"Available Departure Ports"}),X.nearestPorts.map(s=>e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4 p-4 bg-slate-50 border border-slate-200 rounded-xl hover:border-blue-300 hover:bg-blue-50/50 transition-all group",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 bg-white border border-slate-200 rounded-xl flex items-center justify-center shadow-sm group-hover:border-blue-300 transition-colors",children:e.jsx(Jt,{size:18,className:"text-blue-500"})}),e.jsxs("div",{className:"flex-grow",children:[e.jsx("p",{className:"font-bold text-slate-800 text-base",children:s.name}),e.jsx("p",{className:"text-base text-slate-500 mt-0.5",children:s.note}),e.jsxs("p",{className:"text-base text-slate-400 mt-0.5",children:["Pincode: ",s.pincode]})]}),e.jsxs("button",{onClick:async()=>{const{getCentroidWithFallback:a,loadCentroids:i}=await Oo(async()=>{const{getCentroidWithFallback:m,loadCentroids:p}=await import("./mapProjection-BoeLmytC.js");return{getCentroidWithFallback:m,loadCentroids:p}},[]);await i();const o=a(s.pincode);o&&X&&He({portLat:o.lat,portLng:o.lng,islandZone:X.islandZone}),os(s.pincode),Oe(null),Bt(s.pincode)},className:"flex-shrink-0 px-5 py-2.5 bg-blue-600 text-white text-base font-bold rounded-xl hover:bg-blue-700 hover:shadow-lg hover:-translate-y-0.5 active:scale-95 transition-all shadow-sm flex items-center gap-2",children:[e.jsx(Re,{size:14}),"Get Road Freight to this Port"]})]},s.pincode))]}),e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-4 flex items-start gap-3",children:[e.jsx(Xt,{size:18,className:"text-amber-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold text-amber-900",children:"Sea freight not included"}),e.jsx("p",{className:"text-base text-amber-700 mt-0.5 leading-relaxed",children:"The quote you receive covers road freight to the port only. Sea cargo charges (vessel booking, port handling, island delivery) must be arranged separately through a shipping line or freight forwarder."})]})]}),e.jsx("div",{className:"flex items-center gap-3 pt-2",children:e.jsx("button",{onClick:()=>{Oe(null),He(null),os(X.toPincode)},className:"text-base text-slate-500 hover:text-slate-700 underline underline-offset-2",children:"← Change destination"})})]})]}):_?e.jsxs("div",{className:"relative min-h-[70vh]",children:[e.jsx("div",{className:"blur-md select-none pointer-events-none","aria-hidden":"true",children:e.jsx(Vi,{})}),e.jsx("div",{className:"absolute inset-0 flex items-start justify-center pt-2 px-1 overflow-y-auto",children:e.jsx("div",{className:"w-full bg-white rounded-3xl border border-slate-200 shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-300",children:e.jsx(ec,{onUnlocked:()=>{ae(!1),Bt()}})})})]}):H?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-8 bg-white rounded-2xl border border-slate-200 shadow-sm animate-in fade-in slide-in-from-bottom-4 duration-500",children:[e.jsx("div",{className:"w-16 h-16 bg-red-50 rounded-full flex items-center justify-center mb-6 text-red-500",children:e.jsx(Xt,{size:32})}),e.jsx("h2",{className:"text-xl font-bold text-slate-800 mb-2",children:"Calculation Interrupted"}),e.jsx("p",{className:"text-slate-500 max-w-md text-center mb-8 leading-relaxed",children:H}),e.jsx("button",{onClick:()=>Bt(),className:"px-8 py-3 bg-blue-600 text-white font-bold rounded-xl hover:bg-blue-700 transition-all shadow-lg shadow-blue-200 active:scale-95",children:"Try Again"})]}):le&&le.length>0||de&&de.length>0?e.jsx("div",{className:"relative",children:e.jsx("div",{children:e.jsx(Vd,{active:Qe,watermarkLabel:[h()?.name||h()?.businessName,h()?.email].filter(
72Boolean).join(" · ")||"CONFIDENTIAL",children:e.jsx("div",{id:"results",className:"space-y-4",children:e.jsx(W.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2,duration:.5},className:"space-y-3",children:(()=>{const a=[...le||[],...de||[]].filter(d=>{if(d?.message==="service not available")return!1;const w=Ne(d);return Number.isFinite(w)&&w>0}).filter(d=>!d.isHidden&&typeof d.estimatedTime=="number"),i=a.length>0?a.reduce((d,w)=>(d.estimatedTime??1/0)<(w.estimatedTime??1/0)?d:w):null,o=d=>d?d.filter(D=>{const Ie=Ne(D);if(!Number.isFinite(Ie)||Ie<=0)return!1;const ht=D?.transporterData?.rating??D?.rating??D?.transporterData?.ratingAverage??0;if(D.companyName==="LOCAL FTL"||D.companyName==="Wheelseye FTL"){const Ee=D.actualWeight??qs,Wt=D.volumetricWeight??qs,Tt=Ee>=500,Fe=Wt>=500;if(D.companyName==="LOCAL FTL"&&!(Tt||Fe)||D.companyName==="Wheelseye FTL"&&!(Tt||Fe))return!1}const ps=D.isMoverLive||D.isIndividualFtl?!0:ht>=va;return Ne(D)>=ga&&Ne(D)<=ba&&(D.estimatedTime??1/0)>=Zs&&(D.estimatedTime??1/0)<=Cs&&ps}).sort((D,Ie)=>{switch(R){case"time":return D.isHidden&&!Ie.isHidden?1:!D.isHidden&&Ie.isHidden?-1:(D.estimatedTime??1/0)-(Ie.estimatedTime??1/0);case"rating":{const ht=D?.transporterData?.rating??D?.rating??D?.transporterData?.ratingAverage??0;return(Ie?.transporterData?.rating??Ie?.rating??Ie?.transporterData?.ratingAverage??0)-ht}case"price":default:{const ht=Ne(D),ps=Ne(Ie);if(ht===ps){const Ee=(D.companyName||D.transporterName||"").toLowerCase(),Wt=(Ie.companyName||Ie.transporterName||"").toLowerCase(),Tt=Ee.split(/(\d+)/),Fe=Wt.split(/(\d+)/),ls=Math.max(Tt.length,Fe.length);for(let $t=0;$t<ls;$t++){const jr=Tt[$t]||"",kr=Fe[$t]||"",Ul=/^\d+$/.test(jr),Hl=/^\d+$/.test(kr);if(Ul&&Hl){const ra=parseInt(jr,10),Hn=parseInt(kr,10);if(ra!==Hn)return ra-Hn}else{const ra=jr.localeCompare(kr);if(ra!==0)return ra}}return 0}return ht-ps}}}):[],m=o(le),p=o(de),A=d=>(d.transporterData?._id||d.transporterID||d.companyName||d.transporterName||"").toString().toLowerCase(),Y=new Set,pe=["Safexpress","DTDC","Delhivery (Shipshopy)","TCI Freight"],se=h(),fe=se?.email?.toLowerCase(),te=se?._id?String(se._id):"",he=l||Oa({isAdmin:se?.isAdmin,isSubscribed:se?.isSubscribed}),O=fe==="[email protected]",ge=d=>{const w=(d.companyName||d.transporterName||"").trim();return pe.some(D=>D.toLowerCase()===w.toLowerCase())},ye=d=>{const w=d.createdBy||d.customerID||d.customerId,D=!!d.isCustomerVendor||!!d.isTiedUp||!!te&&!!w&&String(w)===te;return{...d,isOwn:D}};console.log(`[VENDOR-TRACE FE] tagOwnership: customerId=${te} | tiedUpVendorsRaw=${m.length} | otherVendorsRaw=${p.length}`),[...m,...p].forEach(d=>{const w=d.createdBy||d.customerID||d.customerId,D=!!d.isCustomerVendor||!!d.isTiedUp||!!te&&!!w&&String(w)===te;console.log(`[VENDOR-TRACE FE]   "${d.companyName}" | isOwn=${D} | isCustomerVendor=${d.isCustomerVendor} | isTiedUp=${d.isTiedUp} | ownerId=${w} | customerIdMatch=${!!te&&!!w&&String(w)===te}`)});const Ze=[...m,...p].map(ye);let ze=[],et=[];const Nt=(d,w)=>{switch(R){case"time":return d.isHidden&&!w.isHidden?1:!d.isHidden&&w.isHidden?-1:(d.estimatedTime??1/0)-(w.estimatedTime??1/0);case"rating":{const D=d?.transporterData?.rating??d?.rating??d?.transporterData?.ratingAverage??0;return(w?.transporterData?.rating??w?.rating??w?.transporterData?.ratingAverage??0)-D}case"price":default:return Ne(d)-Ne(w)}};if(O){const d=Ze.filter(D=>ge(D)),w=Ze.filter(D=>D.isOwn&&!ge(D));ze=[...d,...w].sort(Nt),et=Ze.filter(D=>!D.isOwn&&!ge(D)).sort(Nt)}else ze=Ze.filter(d=>d.isOwn===!0).sort(Nt),et=Ze.filter(d=>d.isOwn!==!0).sort(Nt);let jt=ze.filter(d=>{const w=A(d);return w?Y.has(w)?!1:(Y.add(w),!0):!0}),je=et.filter(d=>{const w=A(d);return w?Y.has(w)?!1:(Y.add(w),!0):!0});je=je.map(d=>{if(d.isMoverLive)return d;const w=(d.companyName||d.transporterName||"").toLowerCase();return["local ftl","wheelseye ftl","wheelseye","ftl transporter","local-ftl"].some(D=>w.includes(D))?d:d.isHidden?{...d,isRestricted:!0}:he?d:{...d,isRestricted:!0,isHidden:!0,companyName:om(d.companyName||d.transporterName||"")}});const Xe=[...jt,...je],Ke=Xe.map(d=>Ne(d)).filter(d=>Number.isFinite(d)&&d>0),Qt=Ke.length?Math.min(...Ke):1/0,Is=Xe.filter(d=>{const w=Ne(d);return Number.isFinite(w)&&Math.abs(w-Qt)<.01}),$=["LOCAL FTL","Wheelseye FTL","wheelseye","local ftl","ftl transporter","local-ftl"],_e=d=>{const w=(d.companyName||d.transporterName||"").toLowerCase();return $.some(D=>w.includes(D.toLowerCase()))},v=Ht??le?.[0]?.distanceKm??de?.[0]?.distanceKm??0,be=d=>_e(d)||!!d.isMoverLive||!!d.isIndividualFtl||!!d.isPorterLive||!!d.isWheelseyeLive,we=d=>{if(!be(d))return!0;const w=ol(d.ratedCapacityKg??d.maxCapacityKg);return!$a(Ne(d),v,w,ee)};jt=jt.filter(we),je=je.filter(we);const Ce=jt.filter(d=>!_e(d));if(Ce.length,Ce.length>0){const d=Ce.map(w=>Ne(w)).filter(w=>Number.isFinite(w)&&w>0);if(d.length>0){const w=Math.min(...d);
72je=je.filter(D=>D.isMoverLive||_e(D)||D.isIndividualFtl||Ne(D)<w)}}const dt=je.filter(d=>d.isMoverLive),us=je.filter(d=>!d.isMoverLive&&_e(d)),bt=je.filter(d=>d.isIndividualFtl&&!d.isMoverLive&&!_e(d)),yr=je.filter(d=>d.source==="community"&&!d.isMoverLive&&!_e(d)&&!d.isIndividualFtl),wr=je.filter(d=>d.source!=="community"&&!d.isMoverLive&&!_e(d)&&!d.isIndividualFtl).slice().sort((d,w)=>Ne(d)-Ne(w)).slice(0,5);je=[...yr,...us,...bt,...wr].sort(Nt);const Es=je.find(d=>d.companyName==="Wheelseye FTL")||null;je=je.filter(d=>d.companyName!=="Wheelseye FTL"),console.log(`[VENDOR-TRACE FE] Market Carriers final: ftlSlot=${us.length} | otherVendors total=${je.length} | staticWheelseyeCard=${Es?"pulled into Your Vendors":"none"}`),je.forEach(d=>console.log(`[VENDOR-TRACE FE]   MC: "${d.companyName}" | price=${Ne(d)} | isFtlOrWheel=${_e(d)}`));const ta=ee,tt=(()=>{if(ft?.status!=="ok"||!ft.vehicles?.length)return null;const d=ft.vehicles.filter(Ie=>Number.isFinite(Ie.price));if(!d.length)return null;const w=d.filter(Ie=>{const ht=Yt(Ie.name,Ie.weightLabel);return ht!=null&&ht>=ta-1});if(!w.length)return null;const D=[...w].sort((Ie,ht)=>Ie.price-ht.price)[0];return $a(D.price,v,Yt(D.name,D.weightLabel),ta)?null:D})(),ka=!!tt,sa=(()=>{if(!tt)return null;const d=jt.find(w=>w.companyName==="Wheelseye FTL")||je.find(w=>w.companyName==="Wheelseye FTL");return d?{...d,totalCharges:tt.price,price:tt.price,total:tt.price,totalPrice:tt.price,vehicle:tt.name,isWheelseyeLive:!0,isTiedUp:!0,liveFetchedAt:ft.fetchedAt,liveSourceLabel:"Wheelseye consigner API (your account)",liveOptions:ft.vehicles.map(w=>({id:w.vid,name:w.name,amount:w.price,capacityKg:Yt(w.name,w.weightLabel),lengthFt:w.lengthFt})),livePickedId:tt.vid,ratedCapacityKg:Yt(tt.name,tt.weightLabel),chargeableWeight:ta,vehicleBreakdown:[{count:1,label:tt.name,lengthFt:tt.lengthFt,slabWeightKg:tt.weightLabel,pricePerVehicle:tt.price,totalPrice:tt.price}]}:null})(),Fs=jt.filter(d=>_e(d)&&!(ka&&d.companyName==="Wheelseye FTL")),xs=(()=>{if(ee<=200)return console.log(`[FC][UI] porterLive: skipped, weight=${ee} <= 200 (QB card scale)`),null;const d=Ga;if(!d||d.status!=="ok"||!Number.isFinite(d.price))return console.log("[FC][UI] porterLive: no ok price yet — porterFtlPrice=",d),null;if(!Array.isArray(d.options)||!d.options.length)return console.log("[FC][UI] porterLive: skipped, no options[] on price (older extension or empty)",d),null;const w=d.options.find(D=>D.name===d.vehicleName);return $a(d.price,v,w?.capacityKg,ee)?(console.log(`[FC][UI] porterLive: skipped, flagged implausible — price=${d.price} distanceKm=${v} capacityKg=${w?.capacityKg} chargeableWeight=${ee}`),null):(console.log(`[FC][UI] porterLive: rendering card — price=${d.price} vehicleName=${d.vehicleName}`),{source:"porter",companyName:"Porter",companyId:"porter-live",totalCharges:d.price,price:d.price,total:d.price,totalPrice:d.price,currency:"INR",estimatedTime:1,estimatedDelivery:"Same day",deliveryTime:"Same day",vehicle:d.vehicleName,isSpecialVendor:!0,isTiedUp:!1,isPorterLive:!0,liveFetchedAt:d.fetchedAt,liveSourceLabel:"Porter fare API (via extension)",liveOptions:d.options,livePickedId:w?.name??d.vehicleName,ratedCapacityKg:w?.capacityKg,chargeableWeight:ee,originPincode:N,destinationPincode:F})})();xs&&(xs.liveOptions=xs.liveOptions.map(d=>({...d,id:d.name})));const Nr=[...Fs,...dt,...xs?[xs]:[]],Ca=[...Nr,...je].slice().sort((d,w)=>Ne(d)-Ne(w)).slice(0,5),aa=new Set(Ca),oe=Nr.filter(d=>aa.has(d)),mt=je.filter(d=>aa.has(d)),Gt=he?[...oe,...mt].sort(Nt):[...oe,...mt],Un=async()=>{on(!0);try{const d=h()?._id||h()?.id,w=await Lt.get("/api/utsf/nearest-serviceable",{params:{pincode:F,fromPincode:N,customerId:d,_t:Date.now()},headers:{Authorization:`Bearer ${u}`,"Cache-Control":"no-cache"}});if(w.data.success&&w.data.nearestPincode){const D=w.data.nearestPincode;ln(w.data),cn(!0),os(D),await Bt(D)}else me.error(w.data.message||"No serviceable pincode found nearby")}catch(d){console.error("[Nearest Pincode]",d),me.error("Failed to search for nearest pincode")}finally{on(!1)}};return e.jsxs(e.Fragment,{children:[gl&&Ot&&e.jsxs(W.div,{initial:{opacity:0,y:-10}
72,animate:{opacity:1,y:0},className:"mb-4 bg-gradient-to-r from-amber-50 to-orange-50 border border-amber-200 rounded-xl p-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 bg-amber-100 rounded-full flex items-center justify-center",children:e.jsx(Sa,{size:20,className:"text-amber-600"})}),e.jsxs("div",{className:"flex-grow",children:[e.jsx("p",{className:"text-base font-semibold text-amber-900",children:"Showing results for nearest serviceable pincode"}),e.jsxs("p",{className:"text-base text-amber-700 mt-0.5",children:[e.jsx("span",{className:"font-bold text-amber-900",children:Ot?.nearestPincode})," ","instead of"," ",e.jsx("span",{className:"line-through text-amber-500",children:Ot?.originalPincode}),e.jsx("span",{className:"ml-2 text-amber-500",children:Ot?.distanceKm?`~${Ot.distanceKm}km away`:`±${Ot?.distance} away`})]}),Ot?.servedBy&&Ot.servedBy.length>0&&e.jsxs("p",{className:"text-base text-amber-600 mt-1",children:["Served by: ",Ot.servedBy.join(", ")]})]}),e.jsx("button",{onClick:async()=>{const d=Ot?.originalPincode;d&&(cn(!1),ln(null),os(d),await Bt(d))},className:"text-base text-amber-700 hover:text-amber-900 underline flex-shrink-0",children:"Reset to original"})]}),(()=>{const d=sa?[sa,...Ce]:Es?[Es,...Ce]:Ce;return(Ce.length>0||sa||Es||f&&!y)&&e.jsxs("section",{id:"first-results",children:[e.jsxs("div",{className:"mb-5 flex items-stretch h-10",children:[e.jsx("div",{className:"w-1 bg-blue-800 rounded-l-sm flex-shrink-0"}),e.jsxs("h2",{className:"bg-blue-600 text-white text-xl font-extrabold flex items-center pl-4 select-none flex-shrink-0",style:{clipPath:"polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%)",paddingRight:"40px"},children:["Your Vendors",e.jsx(Re,{size:14,className:"ml-2 sm:hidden"})]})]}),d.length===0?e.jsxs("div",{className:"bg-white rounded-2xl border-2 border-dashed border-indigo-200 p-6 flex flex-col items-center justify-center text-center gap-3 min-h-[220px]",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-indigo-50 flex items-center justify-center border border-indigo-100",children:e.jsx(na,{size:26,className:"text-indigo-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-black text-slate-800",children:"Want to compare your own vendors?"}),e.jsx("p",{className:"text-sm text-slate-500 mt-1 max-w-sm",children:"Add one to stack it directly against the market below."})]}),e.jsxs("button",{type:"button",onClick:()=>{const w=h();w?._id&&sessionStorage.removeItem(g(w._id)),x("/addvendor")},className:"mt-1 inline-flex items-center gap-2 px-6 py-3 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-bold rounded-xl transition-colors shadow-sm active:scale-95",children:[e.jsx(na,{size:16}),"Add Your First Vendor"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:(Ja?d:d.slice(0,3)).map((w,D)=>e.jsx(Wi,{quote:w,isBestValue:Is.includes(w),isFastest:w===i,vendorStatusMap:nn,onOpenRatingModal:In,shieldFlags:dn?.quoteFlags?.[w.companyName]||null,boxes:V,isMarketCarrier:!1,calculatorContext:{fromPincode:N,toPincode:F,fromCity:Pe?.city,toCity:Le?.city,modeOfTransport:ct,shipmentType:We,dimensionUnit:it,boxes:V,totalActualWeight:ms,totalVolumetricWeight:Fn,totalBoxes:Mn,invoiceValue:St},onEditSearch:()=>{ne("hero"),Se(!1),window.scrollTo({top:0,behavior:"smooth"})}},`tied-${D}`))}),d.length>3&&e.jsxs("button",{type:"button",onClick:()=>bl(w=>!w),className:"mt-3 w-full flex items-center justify-center gap-1.5 py-3 rounded-xl border border-slate-200 bg-white text-blue-600 font-black uppercase tracking-widest text-sm font-display hover:bg-blue-50 hover:border-blue-200 transition-colors",children:[e.jsx("span",{children:Ja?"Show less":`Show ${d.length-3} more vendor${d.length-3!==1?"s":""}`}),e.jsx(_s,{size:14,className:`transition-transform duration-300 ${Ja?"rotate-180":""}`})]})]})]})})(),(()=>{const d=Gt.length>0,w=Ce.length>0,D=d&&Gt.every(ht=>ht?.isRestricted);return!w&&(D||!d)||!w?null:e.jsxs("div",{className:"my-10 flex items-center gap-4 p-5 bg-slate-50 border border-slate-200 rounded-3xl animate-in fade-in slide-in-from-top-4 duration-700 overflow-hidden",children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-white border border-slate-100 flex items-center justify-center shadow-sm flex-shrink-0",children:e.jsx(Sc,{size:20,className:"text-slate-400"})}
72),e.jsxs("p",{className:"text-sm font-medium text-slate-500 whitespace-nowrap overflow-hidden text-ellipsis",children:[e.jsx("span",{className:"font-black text-slate-400 uppercase tracking-widest font-display",children:"Smart Shield Insight:"})," ","Our AI-powered Smart Shield continuously monitors market fluctuations to ensure the rates displayed meet our quality and reliability standards."]})]})})(),Gt.length===0&&Ce.length>0&&et.length>0&&e.jsxs("section",{className:"mb-8",children:[e.jsxs("div",{className:"mb-4 flex items-stretch h-10 gap-3",children:[e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:"w-1 bg-orange-700 rounded-l-sm flex-shrink-0"}),e.jsxs("h2",{className:"bg-orange-500 text-white text-xl font-extrabold flex items-center pl-4 select-none",style:{clipPath:"polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%)",paddingRight:"40px"},children:["Market Carriers",e.jsx(Re,{size:14,className:"ml-2 sm:hidden"})]})]}),e.jsx("span",{className:"text-sm font-bold text-orange-500 self-center",children:"hidden"})]}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-green-50 border border-green-200 rounded-xl text-base text-green-800",children:[e.jsx("svg",{className:"w-5 h-5 text-green-500 mt-0.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("span",{children:[e.jsx("strong",{children:"You're already getting the best rate."})," All ",et.length," market carrier",et.length!==1?"s":""," are more expensive than your cheapest vendor (",e.jsx("strong",{children:Ce.reduce((d,w)=>Ne(w)<Ne(d)?w:d,Ce[0])?.companyName})," at ",e.jsxs("strong",{children:["₹",Math.min(...Ce.map(d=>Ne(d))).toLocaleString("en-IN")]}),"), so they've been hidden to keep results clean."]})]})]}),Gt.length>0&&(()=>{const d=ee,w=(()=>{if(ft?.status!=="ok"||!ft.vehicles?.length)return null;const Ee=ft.vehicles.filter(Fe=>Number.isFinite(Fe.price));if(!Ee.length)return null;const Wt=Ee.filter(Fe=>{const ls=Yt(Fe.name,Fe.weightLabel);return ls!=null&&ls>=d-1});if(!Wt.length)return null;const Tt=[...Wt].sort((Fe,ls)=>Fe.price-ls.price)[0];return $a(Tt.price,v,Yt(Tt.name,Tt.weightLabel),d)?null:Tt})(),D=Ee=>Ee.companyName==="Wheelseye FTL"&&w?w.price:Ne(Ee),Ie=R==="price"?[...Gt].sort((Ee,Wt)=>D(Ee)-D(Wt)):Gt,ht=Ie.map(D).filter(Ee=>Number.isFinite(Ee)&&Ee>0),ps=Math.min(Number.isFinite(Qt)?Qt:1/0,ht.length?Math.min(...ht):1/0);return e.jsxs("section",{id:"market-carriers-section",className:"mb-12 scroll-mt-24",children:[e.jsxs("div",{className:"mb-5 flex items-stretch h-10 gap-3",children:[e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:"w-1 bg-orange-700 rounded-l-sm flex-shrink-0"}),e.jsxs("h2",{className:"bg-orange-500 text-white text-xl font-extrabold flex items-center pl-4 select-none",style:{clipPath:"polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%)",paddingRight:"40px"},children:["Market Carriers",e.jsx(Re,{size:14,className:"ml-2 sm:hidden"})]})]}),e.jsx("span",{className:"text-sm font-bold text-orange-500 self-center",children:Ce.length>0?`${Gt.filter(Ee=>!_e(Ee)&&!Ee.isMoverLive&&!Ee.isPorterLive).length} transporters cheaper than your best`:`${Gt.length} partner${Gt.length!==1?"s":""} found`})]}),e.jsx("div",{className:"space-y-2",children:Ie.map((Ee,Wt)=>{const Tt=Ee.companyName==="Wheelseye FTL",Fe=Tt?w:null,ls=Fe?{...Ee,totalCharges:Fe.price,price:Fe.price,total:Fe.price,totalPrice:Fe.price,vehicle:Fe.name,isWheelseyeLive:!0,liveFetchedAt:ft.fetchedAt,liveSourceLabel:"Wheelseye consigner API (your account)",liveOptions:ft.vehicles.map($t=>({id:$t.vid,name:$t.name,amount:$t.price,capacityKg:Yt($t.name,$t.weightLabel),lengthFt:$t.lengthFt})),livePickedId:Fe.vid,ratedCapacityKg:Yt(Fe.name,Fe.weightLabel),chargeableWeight:d,vehicleBreakdown:[{count:1,label:Fe.name,lengthFt:Fe.lengthFt,slabWeightKg:Fe.weightLabel,pricePerVehicle:Fe.price,totalPrice:Fe.price}]}:Tt?{...Ee,wheelseyeNeedsConnect:ke&&ft?.needsLogin===!0,wheelseyeNeedsExtension:!ke,wheelseyeConnectUrl:`https://wheelseye.com/booking/a/dashboard?fc_from=${encodeURIComponent(N)}&fc_to=${encodeURIComponent(F)}`}:Ee;return e.jsx(Wi,{quote:ls,isBestValue:Math.abs(D(Ee)-ps)<.01,isFastest:Ee===i,vendorStatusMap:nn,onOpenRatingModal:In,shieldFlags:dn?.quoteFlags?.[Ee.companyName]||null,boxes:V,isRestricted:Ee.isRestricted,isMarketCarrier:!0,onEditSearch:()=>{ne("hero"),Se(!1),window.scrollTo({top:0,behavior:"smooth"})}},`other-${Wt}`)})})]})})(),(()=>{if([...Ce,...je].filter(w=>!_e(w)).length===0){const w=jt.length===0&&je.length===0,D=Ht??le?.[0]?.distanceKm??0,Ie=w&&Vr(D)&&zr(Math.min(Cs,Ft[Ft.length-1]))<7;return w&&!Ie&&ja.current&&!ua&&(ja.current=!1,setTimeout(()=>
72{me("No vendor covers that pincode yet — searching the nearest serviceable one instead...",{icon:"📍"}),Un()},300)),Ie?e.jsxs("div",{className:"text-center py-12 bg-white rounded-2xl border-2 border-dashed border-amber-300 mt-6",children:[e.jsx(It,{className:"mx-auto h-12 w-12 text-amber-500 fill-amber-100"}),e.jsx("h3",{className:"mt-4 text-xl font-semibold text-slate-700",children:"No standard vendor delivers that fast"}),e.jsxs("p",{className:"mt-1 text-base text-slate-500 max-w-md mx-auto",children:["Standard vendors quote delivery in whole days, not hours. For hourly hyperlocal delivery, check ",e.jsx("strong",{children:"Quick Booking"})," above",G?.eligible?"":" (checking availability for this route)","."]}),e.jsxs("div",{className:"mt-5 flex flex-col sm:flex-row items-center justify-center gap-3",children:[G?.eligible&&e.jsxs("button",{onClick:()=>document.getElementById("quick-booking-section")?.scrollIntoView({behavior:"smooth",block:"start"}),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-base font-bold transition-all shadow-sm bg-amber-500 text-white hover:bg-amber-600 hover:shadow-md active:scale-95",children:[e.jsx(It,{size:16,className:"fill-white"})," View Quick Booking"]}),e.jsxs("button",{onClick:()=>{Xs(1),Js(1)},className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-base font-semibold border border-slate-200 text-slate-600 hover:bg-slate-50 hover:border-slate-300 transition-all",children:[e.jsx(da,{size:16})," Show 1-Day vendors instead"]})]})]}):e.jsxs("div",{className:"text-center py-12 bg-white rounded-2xl border-2 border-dashed border-slate-300 mt-6",children:[e.jsx(Ea,{className:"mx-auto h-12 w-12 text-slate-400"}),e.jsx("h3",{className:"mt-4 text-xl font-semibold text-slate-700",children:w?"No Quotes Available":"No Part-Load (LTL) Coverage Found"}),e.jsx("p",{className:"mt-1 text-base text-slate-500",children:w?"We couldn't find vendors for the details provided.":"Only FTL quotes are available for this route."}),w&&e.jsxs("ul",{className:"mt-2 text-base text-slate-500 text-left max-w-md mx-auto list-disc pl-6 mb-4",children:[e.jsxs("li",{children:["No vendors have pricing configured for this route (zones: ",
72N," → ",F,")"]}),e.jsx("li",{children:"The origin or destination pincode is not in any vendor's service area"})]}),e.jsxs("div",{className:"mt-5 flex flex-col sm:flex-row items-center justify-center gap-3",children:[e.jsx("button",{onClick:Un,disabled:ua,className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-base font-semibold transition-all shadow-sm ${ua?"bg-slate-100 text-slate-400 cursor-wait":"bg-blue-600 text-white hover:bg-blue-700 hover:shadow-md active:scale-95"}`,children:ua?e.jsxs(e.Fragment,{children:[e.jsx(ut,{size:16,className:"animate-spin"})," Searching..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Sa,{size:16})," Find nearest serviceable pincode"]})}),w&&e.jsxs($s,{to:"/my-vendors",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-base font-semibold border border-slate-200 text-slate-600 hover:bg-slate-50 hover:border-slate-300 transition-all",children:[e.jsx(na,{size:16})," Add a vendor"]})]})]})}return null})()]})})()})})})})}):U?null:e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center py-24",children:[e.jsxs("div",{className:"w-24 h-24 bg-blue-50 rounded-full flex items-center justify-center mb-8 border border-blue-100 shadow-sm relative",children:[e.jsx(Ea,{size:48,className:"text-blue-600"}),e.jsx("div",{className:"absolute inset-0 bg-blue-500/5 rounded-full animate-pulse"})]}),e.jsx("h3",{className:"text-2xl font-bold text-slate-800 tracking-tight",children:"System Ready"}),e.jsx("p",{className:"text-slate-500 max-w-sm mt-3 leading-relaxed",children:"Configure your origin and destination in the left panel to begin live freight analysis and network mapping."})]})]})},"results-main")}),e.jsx(kt,{children:z==="results"&&e.jsxs(W.aside,{initial:{opacity:0,x:56},animate:{opacity:1,x:0},exit:{opacity:0,x:36},transition:{type:"spring",stiffness:340,damping:32,mass:.9,delay:.08},className:"hidden xl:flex flex-col gap-4 sticky top-20 self-start min-w-0",children:[e.jsxs("div",{className:"bg-white flex flex-col gap-3 rounded-3xl shadow-[0_20px_50px_rgba(0,0,0,0.1)] p-4 border border-slate-100 min-w-0 flex-shrink-0 max-h-[calc(100vh-11rem)] overflow-y-auto scrollbar-hide",children:[e.jsx(md,{}),e.jsx("div",{className:"relative h-[320px] w-full rounded-2xl overflow-hidden border border-slate-200 shadow-sm group",children:e.jsx("div",{className:"absolute inset-0 z-0 transition-all duration-500 group-hover:scale-105",style:{filter:"grayscale(15%) brightness(0.92)"},children:ss&&as&&e.jsx(Jo,{fromPincode:N,toPincode:F,isCalculating:T,weightKg:ee,seaLeg:st,islandPanelActive:!!X,islandZone:X?.islandZone,islandPorts:X?.nearestPorts})})})]}),is&&e.jsx(W.button,{initial:{opacity:0,y:14},animate:{opacity:1,y:0},transition:{delay:.45,type:"spring",stiffness:300,damping:24},onClick:()=>document.getElementById(is.source==="quickbooking"?"quick-booking-section":"market-carriers-section")?.scrollIntoView({behavior:"smooth",block:"start"}),className:"w-full text-left bg-gradient-to-r from-emerald-50 to-green-50 border border-emerald-300 rounded-3xl px-5 py-4 shadow-[0_12px_30px_rgba(16,185,129,0.14)] hover:border-emerald-400 hover:shadow-[0_14px_34px_rgba(16,185,129,0.2)] active:scale-[0.99] transition-all group flex-shrink-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-emerald-500 flex items-center justify-center flex-shrink-0 shadow-sm shadow-emerald-200",children:e.jsx(sc,{size:18,className:"text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[10px] font-black text-emerald-700 uppercase tracking-widest leading-none",children:is.source==="quickbooking"?"Cheaper Quick Booking option found":"Cheaper market carrier found"}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 min-w-0",children:[e.jsxs("span",{className:"text-lg font-black text-slate-900 leading-none whitespace-nowrap",children:["₹",Zt(is.price)]}),e.jsx("span",{className:`text-xs font-bold text-slate-500 truncate ${is.masked?"blur-[10px] select-none":""}`,children:is.name})]}),e.jsxs("div",{className:"text-[10px] text-emerald-700 font-semibold mt-1",children:["Save ₹",Zt(is.savings)," vs your best vendor",is.masked?" · subscribe to unlock vendor":""]})]}),e.jsx(_s,{size:16,className:"text-emerald-600 group-hover:translate-y-0.5 transition-transform flex-shrink-0"})]})}),e.jsx(wd,{quotes:le,quickBookingParams:{from:N,to:F,weight:ee,dim:G?.maxDimCm??0,distance:le?.[0]?.distanceKm??G?.distanceKm??0}})]},"map-aside")})]})}),Ge&&e.jsx(_d,{onPass:()=>{Ye(!1),Ae(!1),Te(null),setTimeout(()=>{Bt(void 0,"frontend-verified")},500)},onClose:()=>
72Ye(!1),ownVendors:Q,hasPreferredVendor:!!h()?.preferredVendor?.vendorId,onPreferredVendorPicked:async(s,a,i)=>{try{await Hi(s,a,i),me.success(`${a} set as your preferred vendor`)}catch{}}}),e.jsx(kt,{children:cl&&e.jsxs(W.div,{initial:{opacity:0,y:-16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.4,ease:"easeOut"},className:"fixed top-5 left-1/2 -translate-x-1/2 z-[9700] flex items-center gap-3 bg-white rounded-2xl border border-indigo-100 shadow-2xl px-5 py-3.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-gradient-to-br from-indigo-500 to-blue-500 flex items-center justify-center flex-shrink-0",children:e.jsx(Ns,{size:16,className:"text-white"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-bold text-slate-800",children:["Welcome aboard",h()?.firstName?`, ${h()?.firstName}`:"","! 🎉"]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Let's find you the best freight rates."})]})]})}),e.jsx(Bo,{isOpen:ml,onClose:hl,heading:zt?"Unlock live prices":void 0,description:zt?"Add the free FreightCompare extension to see real, live prices from Wheelseye, Porter, Rapido & more right here — takes a few seconds.":void 0}),e.jsx(Hd,{isOpen:Wl,onClose:()=>br(!1),onResolved:vr}),ul&&e.jsx("div",{className:"fixed bottom-5 right-5 z-[9500] w-[min(92vw,340px)] bg-white rounded-2xl border border-slate-200 shadow-2xl p-4 animate-in fade-in slide-in-from-bottom-4 duration-300",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-blue-50 flex items-center justify-center flex-shrink-0 border border-blue-100",children:e.jsx(It,{size:16,className:"text-blue-600"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-sm font-bold text-slate-800",children:"Connect your Wheelseye account"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 leading-relaxed",children:"See live FTL prices from your own Wheelseye account on Market Carriers."}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-3",children:[e.jsx("a",{href:"https://wheelseye.com/booking/a/dashboard",target:"_blank",rel:"noopener noreferrer",onClick:Qa,className:"text-xs font-bold text-blue-600 hover:text-blue-800",children:"Connect now"}),e.jsx("button",{type:"button",onClick:Qa,className:"text-xs font-semibold text-slate-400 hover:text-slate-600",children:"Skip for now"})]})]}),e.jsx("button",{type:"button",onClick:Qa,"aria-label":"Dismiss",className:"text-slate-300 hover:text-slate-500 flex-shrink-0",children:e.jsx(Vt,{size:16})})]})}),e.jsx(qd,{isOpen:ds.isOpen,onClose:Al,vendorId:ds.vendorId,vendorName:ds.vendorName,isTemporaryVendor:ds.isTemporaryVendor,vendorType:ds.vendorType,onRatingSubmitted:(s,a)=>{ds.onRatingSubmitted&&ds.onRatingSubmitted(s,a)}}),e.jsx(um,{isOpen:Cl,onClose:()=>fn(!1),onSave:Sl}),_t!==null&&Kt.createPortal(e.jsx(W.ul,{ref:s=>{wn.current=s,Nn.current=s},initial:{opacity:0,scale:.97},animate:{opacity:1,scale:1},transition:{duration:.12},style:{position:"fixed",zIndex:99999},className:"border border-slate-200 rounded-lg max-h-44 overflow-y-auto bg-white shadow-2xl",children:An.length>0?e.jsxs(e.Fragment,{children:[e.jsx("li",{className:"px-4 pt-2 pb-1 text-[10px] font-bold uppercase tracking-widest text-slate-400 border-b border-slate-100 select-none",children:"Saved Box Names"}),An.map(s=>e.jsxs("li",{onClick:()=>zl(_t,s),className:"group flex justify-between items-center px-4 py-2 hover:bg-blue-50 cursor-pointer text-slate-700 text-base transition-colors",children:[e.jsx("span",{children:s.name}),e.jsx("button",{onClick:a=>Vl(s._id,a),className:"p-1 text-slate-300 opacity-0 group-hover:opacity-100 hover:text-red-600 hover:bg-red-100 rounded-full transition-all",children:e.jsx(gs,{size:10})})]},s._id))]}):e.jsx("li",{className:"px-4 py-3 italic text-base text-slate-500",children:pa.length===0?"No saved box names yet.":"No matches found."})}),document.body)]})]})},um=({isOpen:t,onClose:l,onSave:c})=>{const[r,u]=n.useState({averageLoadInDispatch:0,monthlyOrder:0,maxLength:0,maxWidth:0,maxHeight:0}),[x,b]=n.useState(!1);if(!t)return null;const h=async()=>
72{if(r.averageLoadInDispatch>1e5){me.error("Max weight is 1,00,000 kg");return}if(r.monthlyOrder>1e4){me.error("Max monthly shipments is 10,000");return}if(r.maxLength>1e4||r.maxWidth>1e4||r.maxHeight>1e4){me.error("Max dimension is 10,000 inches each");return}b(!0),await c(r),b(!1),l()};return Kt.createPortal(e.jsx(W.div,{initial:{opacity:0},animate:{opacity:1},className:"fixed inset-0 z-[10000] bg-slate-900/40 backdrop-blur-sm flex items-center justify-center p-4",children:e.jsxs(W.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white w-full max-w-md rounded-3xl shadow-2xl overflow-hidden",children:[e.jsxs("div",{className:"bg-slate-900 p-6 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"bg-blue-500/20 p-2 rounded-lg",children:e.jsx(Dt,{className:"text-blue-400",size:24})}),e.jsx("h3",{className:"text-xl font-bold",children:"Package Specifications"})]}),e.jsx("p",{className:"text-slate-400 text-base",children:"Help us tailor better freight solutions for your business by sharing your average shipment details."})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-base font-black uppercase tracking-widest text-slate-400",children:"Avg. Weight (Kg)"}),e.jsx("input",{type:"number",min:0,max:1e5,value:r.averageLoadInDispatch||"",onChange:g=>u({...r,averageLoadInDispatch:Number(g.target.value)}),className:"w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-2.5 text-base font-bold focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all outline-none",placeholder:"e.g. 50"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-base font-black uppercase tracking-widest text-slate-400",children:"Monthly Shipments"}),e.jsx("input",{type:"number",min:0,max:1e4,value:r.monthlyOrder||"",onChange:g=>u({...r,monthlyOrder:Number(g.target.value)}),className:"w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-2.5 text-base font-bold focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all outline-none",placeholder:"e.g. 100"})]})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx("label",{className:"text-base font-black uppercase tracking-widest text-slate-400",children:"Average Dimensions (Inches)"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx("input",{type:"number",min:0,max:1e4,placeholder:"L",value:r.maxLength||"",onChange:g=>u({...r,maxLength:Number(g.target.value)}),className:"w-full bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 text-center text-base font-bold focus:ring-2 focus:ring-blue-500/20 outline-none"}),e.jsx("input",{type:"number",min:0,max:1e4,placeholder:"W",value:r.maxWidth||"",onChange:g=>u({...r,maxWidth:Number(g.target.value)}),className:"w-full bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 text-center text-base font-bold focus:ring-2 focus:ring-blue-500/20 outline-none"}),e.jsx("input",{type:"number",min:0,max:1e4,placeholder:"H",value:r.maxHeight||"",onChange:g=>u({...r,maxHeight:Number(g.target.value)}),className:"w-full bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 text-center text-base font-bold focus:ring-2 focus:ring-blue-500/20 outline-none"})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:l,className:"flex-1 px-6 py-3 rounded-xl text-base font-bold text-slate-500 hover:bg-slate-50 transition-colors",children:"Skip for now"}),e.jsx("button",{onClick:h,disabled:x,className:"flex-1 bg-blue-600 text-white px-6 py-3 rounded-xl text-base font-bold shadow-lg shadow-blue-200 hover:bg-blue-700 transition-all active:scale-95 disabled:opacity-50",children:x?"Saving...":"Save & Continue"})]})]})]})}),document.body)},xm=({quote:t})=>{const{user:l}=Ka(),c=l,r=c?.customer||c;Oa({isAdmin:r?.isAdmin,isSubscribed:r?.isSubscribed});const u=f=>new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:0,maximumFractionDigits:0}).format(Math.round(f||0)),x=[{label:"Base Freight",keys:["effectiveBaseFreight","effective_base_freight","baseFreight","base_freight","freight"]},{label:"Docket Charge",keys:["docketCharge","docket_charge","docket"]},{label:"Fuel Surcharge",keys:["fuelCharges","fuel_surcharge","fuel"]},{label:"ROV Charges",keys:["rovCharges","rov_charges","rov"]},{label:"Insurance Charges",keys:["insuaranceCharges","insuranceCharges","insurance_charges","insurance"]},{label:"ODA Charges",keys:["odaCharges","oda_charges","oda"]},{label:"Handling Charges",keys:["handlingCharges","handling_charges","handling"]},{label:"FM Charges",keys:["fmCharges","fm_charges","fm"]},{label:"Appointment Charges",keys:["appointmentCharges","appointment_charges","appointment"]},{label:"DACC Charges",keys:["daccCharges","dacc_charges","dacc","breakdown.daccCharges"]},{label:"Green Tax",keys:["greenTax","green_tax","green","breakdown.greenTax"]},{label:"Miscellaneous Charges",keys:["miscCharges","miscellaneous_charges","misc","breakdown.miscCharges"]},{label:"COD Charges",keys:["codCharges","cod_charges","breakdown.codCharges"]},{label:"To-Pay Charges",keys:["topayCharges","topay_charges","breakdown.topayCharges"]},{label:"Hamali Charges",keys:["hamaliCharges","hamali_charges","breakdown.hamaliCharges"]},{label:"OS/OW Charges",keys:["osOwCharges","os_ow_charges","breakdown.osOwCharges"]},{label:"Single Piece Charges",keys:["singlePieceCharges","single_piece_charges","breakdown.singlePieceCharges"]},{label:"DOD Charges",keys:["dodCharges","dod_charges","breakdown.dodCharges"]},{label:"Cheque Handling",keys:["chequeHandlingCharges","cheque_handling_charges","breakdown.chequeHandlingCharges"]},{label:"Invoice Value Charges",keys:["invoiceAddon","invoiceValueCharge","
72invoiceValueCharges","breakdown.invoiceValueCharges"]},{label:"Custom Surcharges",keys:["customSurcharges","breakdown.customSurcharges"]},{label:"GST (18%)",keys:["gstAmount","breakdown.gstAmount"]}],b=f=>{for(const L of f)if(L.includes(".")){const[R,k]=L.split("."),P=t[R]?.[k];if(P!==void 0&&P>0)return P}else{const R=t[L]!==void 0?t[L]:t.breakdown?.[L];if(R!==void 0&&R>0)return R}return 0},h=t.companyName==="FTL"||t.companyName==="Wheelseye FTL"||t.companyName==="LOCAL FTL"||!!t.isMoverLive||!!t.isPorterLive,y=Array.isArray(t.vehicleBreakdown)&&t.vehicleBreakdown.length>0?(console.log("✅ Found vehicleBreakdown directly on quote:",t.vehicleBreakdown),t.vehicleBreakdown):Array.isArray(t.vehicleCalculation?.vehicleBreakdown)&&t.vehicleCalculation.vehicleBreakdown.length>0?(console.log("✅ Found vehicleBreakdown in vehicleCalculation:",t.vehicleCalculation.vehicleBreakdown),t.vehicleCalculation.vehicleBreakdown):Array.isArray(t.loadSplit?.vehicles)&&t.loadSplit.vehicles.length>0?(console.log("✅ Found vehicles in loadSplit:",t.loadSplit.vehicles),t.loadSplit.vehicles):Array.isArray(t.vehiclePricing)&&t.vehiclePricing.length>0?(console.log("✅ Found vehiclePricing, converting:",t.vehiclePricing),t.vehiclePricing.map(f=>({label:f.vehicleType,count:1,slabWeightKg:f.maxWeight||f.weight,totalPrice:f.wheelseyePrice||f.ftlPrice,lengthFt:null}))):(console.log("❌ No vehicleBreakdown found in quote:",{vehicleBreakdown:t.vehicleBreakdown,vehicleCalculation:t.vehicleCalculation,loadSplit:t.loadSplit,vehiclePricing:t.vehiclePricing}),null),j=y?y.reduce((f,L)=>f+(L.count??1),0):0;return e.jsxs(W.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:"easeInOut"},className:"overflow-hidden",children:[Array.isArray(t.liveOptions)&&t.liveOptions.length>0&&(()=>{const f=t.liveOptions,L=t.livePickedId,R=Number(t.chargeableWeight)||0,k=t.liveFetchedAt,P=t.liveSourceLabel,T=f.filter(M=>M.id!=null&&M.id===L),I=T.length>0?T:f;return e.jsxs("div",{className:"border-t border-slate-100 mt-4 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2 mb-3",children:[e.jsxs("h4",{className:"font-bold text-slate-800 uppercase tracking-wider text-base flex items-center gap-2",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-500 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-green-600"})]}),"Live options returned by the platform"]}),e.jsxs("span",{className:"text-[11px] font-semibold text-slate-400",children:[P,k?` · fetched ${new Date(k).toLocaleTimeString("en-IN",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0})}`:""]})]}),R>0&&e.jsxs("p",{className:"text-[12px] text-slate-500 mb-2",children:["Your chargeable weight is ",e.jsxs("strong",{className:"text-slate-700",children:[Math.ceil(R).toLocaleString("en-IN")," kg"]})," — vehicles rated below that are shown struck out and are never selected, even when cheaper."]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-base",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wider text-slate-400 border-b border-slate-100",children:[e.jsx("th",{className:"py-1.5 pr-4 font-black",children:"Vehicle"}),e.jsx("th",{className:"py-1.5 pr-4 font-black",children:"Rated capacity"}),e.jsx("th",{className:"py-1.5 pr-4 font-black",children:"Length"}),e.jsx("th",{className:"py-1.5 text-right font-black",children:"Live fare"})]})}),e.jsx("tbody",{children:I.map(M=>{const B=M.id!=null&&M.id===L,H=R>0&&Number(M.capacityKg)>0&&Number(M.capacityKg)<R;return e.jsxs("tr",{className:`border-b border-slate-50 last:border-0 ${B?"bg-green-50/70":""} ${H?"opacity-45":""}`,children:[e.jsxs("td",{className:`py-1.5 pr-4 font-semibold text-slate-700 ${H?"line-through":""}`,children:[M.name,B&&e.jsx("span",{className:"ml-2 text-[9px] font-black uppercase tracking-wider text-green-700 bg-green-100 border border-green-200 rounded-full px-1.5 py-0.5 no-underline inline-block",children:"Selected"}),H&&e.jsx("span",{className:"ml-2 text-[9px] font-bold uppercase tracking-wider text-slate-400 no-underline inline-block",children:"too small"})]}),e.jsx("td",{className:"py-1.5 pr-4 text-slate-500",children:Number(M.capacityKg)>
720?`${Number(M.capacityKg).toLocaleString("en-IN")} kg`:"—"}),e.jsx("td",{className:"py-1.5 pr-4 text-slate-500",children:Number(M.lengthFt)>0?`${M.lengthFt} ft`:"—"}),e.jsx("td",{className:`py-1.5 text-right font-bold ${B?"text-green-700":"text-slate-700"} ${H?"line-through":""}`,children:Number.isFinite(M.amount)?`₹${Math.round(M.amount).toLocaleString("en-IN")}`:"—"})]},`${M.id}-${M.name}`)})})]})})]})})(),!h&&e.jsxs("div",{className:"border-t border-slate-100 mt-4 pt-4",children:[e.jsx("h4",{className:"font-bold text-slate-800 mb-3 uppercase tracking-wider text-base",children:"Cost Breakdown"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-x-6 gap-y-3 text-base",children:x.map(f=>{const L=b(f.keys);return L>0?e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-slate-500 font-medium",children:[f.label,":"]}),e.jsx("span",{className:`font-bold text-slate-900 ${t.isHidden?"blur-[10px] select-none":""}`,children:u(L)})]},f.label):null})}),(t.breakdown?.gstAmount??t.gstAmount??0)>0?e.jsxs("div",{className:"mt-3 pt-3 border-t border-slate-100 flex justify-between text-base font-bold text-slate-900",children:[e.jsx("span",{className:"text-slate-600",children:"Total (incl. 18% GST):"}),e.jsx("span",{className:`text-blue-600 font-black ${t.isHidden?"blur-[10px] select-none":""}`,children:u(t.totalCharges)})]}):null]}),e.jsxs("div",{className:"border-t border-slate-100 mt-4 pt-4",children:[e.jsx("h4",{className:"font-bold text-slate-800 mb-3 uppercase tracking-wider text-base",children:"Route Info"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-x-6 gap-y-3 text-base",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Chargeable Weight:"}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsxs("span",{className:"font-medium text-slate-800",children:[(()=>{const f=t.chargeableWeight??t.actualWeight??t.weight??0;return typeof f=="number"&&isFinite(f)?Math.ceil(f).toLocaleString():"0"})()," ","Kg"]}),t.minWeightApplied&&e.jsxs("span",{className:"text-base text-amber-500 font-bold",children:["Minimum Weight : ",t.minWeight," kgs"]})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Distance:"}),e.jsx("span",{className:"font-medium text-slate-800",children:t.distance?t.distance:t.distanceKm?`${Math.round(t.distanceKm)} km`:"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Origin:"}),e.jsx("span",{className:"font-medium text-slate-800",children:t.originPincode??t.origin??"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Destination:"}),e.jsx("span",{className:"font-medium text-slate-800",children:t.destinationPincode??t.destination??"-"})]}),t.source==="utsf"&&t.zone&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Zone:"}),e.jsx("span",{className:"font-medium text-blue-700 font-mono text-base bg-blue-50 px-2 py-0.5 rounded",children:t.zone})]}),t.source==="utsf"&&t.unitPrice>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Rate/Kg:"}),e.jsx("span",{className:"font-medium text-slate-800",children:new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:2,maximumFractionDigits:2}).format(t.unitPrice)})]})]}),h&&e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"bg-yellow-100 border-2 border-yellow-500 rounded-lg p-4",children:[e.jsx("h5",{className:"text-amber-950 font-bold text-lg mb-3 flex items-center gap-2",children:"🚛 Vehicle Details"}),y&&y.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-900 font-semibold",children:[e.jsx("span",{children:"Total Vehicles Required:"}),e.jsx("span",{className:"bg-yellow-200 px-3 py-1 rounded-full text-lg",children:j})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-base",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b-2 border-yellow-300",children:[e.jsx("th",{className:"text-left py-2 px-2 text-black font-semibold",children:"Qty"}),e.jsx("th",{className:"text-left py-2 px-2 text-black font-semibold",children:"Vehicle Type"}),e.jsx("th",{className:"text-left py-2 px-2 text-black font-semibold",children:"Length"}),e.jsx("th",{className:"text-left py-2 px-2 text-black font-semibold",children:"Capacity"}),e.jsx("th",{className:"text-right py-2 px-2 text-black font-semibold",children:"Price/Vehicle"}),e.jsx("th",{className:"text-right py-2 px-2 text-black font-semibold",children:"Total"})]})}),e.jsx("tbody",{children:y.map((f,L)=>{const R=f.count??1,k=f.label||f.vehicle||f.vehicleType||f.name||"Vehicle",P=f.lengthFt||f.vehicleLength||"-",T=f.slabWeightKg||f.maxWeight||f.weight||"-",I=f.pricePerVehicle||f.price||0,M=f.totalPrice||I*R||0;return e.jsxs("tr",{className:"border-b border-yellow-200 hover:bg-yellow-50",children:[e.jsxs("td",{className:"py-2 px-2 text-black font-medium",children:[R,"×"]}),e.jsx("td",{className:"py-2 px-2 text-black font-medium",children:k}),e.jsx("td",{className:"py-2 px-2 text-black",children:typeof P=="number"?`${P} ft`:P}),e.jsx("td",{className:"py-2 px-2 text-black",children:typeof T=="number"?`${T.toLocaleStr
72ing()} kg`:T}),e.jsx("td",{className:"py-2 px-2 text-black text-right",children:I>0?`₹${I.toLocaleString()}`:"-"}),e.jsx("td",{className:"py-2 px-2 text-black text-right font-medium",children:M>0?`₹${M.toLocaleString()}`:"-"})]},L)})}),e.jsxs("tfoot",{children:[e.jsxs("tr",{className:"border-t-2 border-yellow-400 bg-yellow-50",children:[e.jsx("td",{colSpan:5,className:"py-3 px-2 text-black font-bold text-right",children:"Grand Total:"}),e.jsxs("td",{className:"py-3 px-2 text-black font-bold text-right text-xl",children:["₹",(t.totalCharges||t.price||0).toLocaleString()]})]}),t.companyName==="LOCAL FTL"&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"py-1 px-2 text-right",children:e.jsx("span",{className:"text-base text-slate-500 italic",children:"* Local Charges: 20%"})})})]})]})})]}):e.jsxs("div",{className:"space-y-3 text-black",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"bg-yellow-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-base text-yellow-700 font-medium",children:"Vehicle Type"}),e.jsx("div",{className:"text-lg font-bold",children:t.vehicle||"Full Truck Load"})]}),t.vehicleLength&&e.jsxs("div",{className:"bg-yellow-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-base text-yellow-700 font-medium",children:"Vehicle Length"}),e.jsx("div",{className:"text-lg font-bold",children:t.vehicleLength})]})]}),t.chargeableWeight&&e.jsxs("div",{className:"bg-yellow-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-base text-yellow-700 font-medium",children:"Chargeable Weight"}),e.jsxs("div",{className:"text-lg font-bold",children:[Math.ceil(t.chargeableWeight).toLocaleString()," kg"]})]}),e.jsxs("div",{className:"bg-yellow-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-base text-yellow-700 font-medium",children:"Total Price"}),e.jsxs("div",{className:"text-xl font-bold text-green-700",children:["₹",(t.totalCharges||t.price||0).toLocaleString()]})]})]})]})}),!h&&t.loadSplit?.vehicles&&e.jsxs("div",{className:"mt-4 p-3 bg-yellow-50 rounded-lg",children:[e.jsx("h6",{className:"font-semibold text-black mb-3",children:"Load Split Details:"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-base",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-yellow-200",children:[e.jsx("th",{className:"text-left py-2 text-black font-semibold",children:"Vehicle"}),e.jsx("th",{className:"text-left py-2 text-black font-semibold",children:"Type"}),e.jsx("th",{className:"text-left py-2 text-black font-semibold",children:"Max Weight"}),e.jsx("th",{className:"text-left py-2 text-black font-semibold",children:"Chargeable Weight"}),e.jsx("th",{className:"text-right py-2 text-black font-semibold",children:"Price"})]})}),e.jsx("tbody",{children:t.loadSplit.vehicles.map((f,L)=>e.jsxs("tr",{className:"border-b border-yellow-100",children:[e.jsxs("td",{className:"py-2 text-black",children:["Vehicle ",L+1]}),e.jsx("td",{className:"py-2 text-black",children:f.vehicle||f.vehicleType}),e.jsxs("td",{className:"py-2 text-black",children:[(f.maxWeight||0).toLocaleString()," kg"]}),e.jsxs("td",{className:"py-2 text-black",children:[(f.weight||0).toLocaleString()," kg"]}),e.jsxs("td",{className:"py-2 text-black text-right",children:["₹",(f.price||0).toLocaleString()]})]},L))})]})})]})]})]})},Bi=(t,l={},c=!1)=>{if(c)return"verified";const r=(t.companyName||"").trim().toLowerCase(),u=["rivigo","gati","dtdc"],x=["tci","cargo planet","xpressbees","shadowfax","shadow fax"],b=["ekart","delhivery lite","dp world","indiapost","safeexpress","safexpress"];if(u.some(g=>r.includes(g)))return"unverified_critical";if(x.some(g=>r.includes(g)))return"unverified";if(b.some(g=>r.includes(g))||t.isSpecialVendor||r==="local ftl"||r==="wheelseye ftl")return"verified";const h=l[r];if(h){if(h.isVerified===!0)return"verified";if(h.approvalStatus==="approved")return"unverified"}return r==="vl cargo"?"unverified":t.isVerified===!0?"verified":(t.approvalStatus==="approved","unverified")},Wi=({quote:t,isBestValue:l,isFastest:c,vendorStatusMap:r,onOpenRatingModal:u,shieldFlags:x,boxes:b,isRestricted:h,isMarketCarrier:g,calculatorContext:y,onEditSearch:j})=>{const[f,L]=n.useState(!1),[R,k]=n.useState(t.rating??t.transporterData?.rating??4),[P,T]=n.useState(t.vendorRatings||t.transporterData?.vendorRatings),[I,M]=n.useState(t.totalRatings||0);n.useEffect(()=>{k(t.rating??t.transporterData?.rating??4),T(t.vendorRatings||t.transporterData?.vendorRatings),M(t.totalRatings||0)},[t.rating,t.transporterData?.rating,t.vendorRatings,t.transporterData?.vendorRatings,t.totalRatings]);const{user:B}=Ka();Hr();const H=()=>
72{if(!B)return null;const Q=B;return Q.customer||Q},Z=H(),_=!!(Z?.isAdmin||Z?.isSubscribed)||!g,ae=t.companyName==="LOCAL FTL"||t.companyName==="Wheelseye FTL"||t.companyName==="IndiaPost",q=!!t.isWheelseyeLive,re=t.companyName==="Wheelseye FTL",[K,C]=n.useState(!1),[ce,X]=n.useState(!1),[Oe,st]=n.useState(null),He=!!t.isMoverLive||!!t.isPorterLive,z=t.companyName==="LOCAL FTL"||t.companyName==="Wheelseye FTL"||He,ne=!!t.isIndividualFtl,Qe=!g&&_&&!h&&(!ae||q||re)&&!ne||g&&!ne&&(z||_),lt=!ne;/^(TESTER|DUMMY|testvendor|Vellore Institute)/i.test(t.companyName||""),console.log(`[VendorCard] ${t.companyName}: isTemporaryTransporter=${t.isTemporaryTransporter}, selectedZones=${t.selectedZones?.length||0}, priceChart=${JSON.stringify(t.priceChart)}`);const at=Ne(t);if(!Number.isFinite(at)||at<=0)return null;const ot=h?"Contact Now":t.isIndividualFtl?"Call Transporter":t.isMoverLive?"Book on Mover":t.isPorterLive?"Book on Porter":_?"Contact Now":"View Details",De=()=>{if(h){me("Subscribe to unlock this premium carrier and compare rates.",{duration:2500});return}if(t.isIndividualFtl){const ue=t.contactNumber;ue?window.open(`tel:${ue}`,"_self"):me.error("No contact number on file for this transporter.");return}if(t.isMoverLive||t.isPorterLive){window.open(t.isMoverLive?"https://mover.delivery":"https://porter.in","_blank","noopener");return}if(!_){me("Subscribe to contact vendors directly and negotiate better rates.",{duration:2500});return}console.log("=== QUOTE DATA DEBUG ==="),console.log("Full quote object:",t),console.log("companyName:",t.companyName),console.log("companyId:",t.companyId),console.log("isTemporaryTransporter:",t.isTemporaryTransporter),console.log("isTiedUp:",t.isTiedUp);const Q=t.companyName||t.transporterName;if(Q==="Wheelseye FTL"||Q==="LOCAL FTL"||Q==="IndiaPost"){if(console.log("Special vendor detected:",Q),Q==="IndiaPost"&&_&&Z?._id){const ue=Gi.get("authToken");me.loading("Adding India Post to your vendors..."),fetch(`${Vs}/api/transporter/add-system-vendor`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ue}`},body:JSON.stringify({customerId:Z._id,systemVendorId:"indiapost-transporter"})}).then($e=>$e.json()).then($e=>{me.dismiss(),$e.success?($e.alreadyExists?me.success("India Post is already in your vendors!",{duration:4e3}):me.success("India Post added to Your Vendors!",{duration:5e3}),st({companyName:"IndiaPost",phone:"1800 266 6868",email:"[email protected]",contactPerson:"IndiaPost Customer Care"}),C(!1),X(!0)):(me.error($e.message||"Failed to add India Post. Please try again."),st({companyName:"IndiaPost",phone:"1800 266 6868",email:"[email protected]",contactPerson:"IndiaPost Customer Care"}),C(!1),X(!0))}).catch($e=>{me.dismiss(),console.error("[SystemVendor] Add failed:",$e),me.error("Failed to add vendor. Please check your connection."),st({companyName:"IndiaPost",phone:"1800 266 6868",email:"[email protected]",contactPerson:"IndiaPost Customer Care"}),C(!1),X(!0)});return}st({companyName:Q,phone:Q==="Wheelseye FTL"?"9876543210":Q==="IndiaPost"?"1800 266 6868":"8800123456",email:Q==="Wheelseye FTL"?"[email protected]":Q==="IndiaPost"?"[email protected]":"[email protected]",contactPerson:Q==="Wheelseye FTL"?"Wheelseye Support":Q==="IndiaPost"?"IndiaPost Customer Care":"FreightCompare FTL Team"}),C(!1),X(!0);return}if(!(t.companyId||t.transporterData?._id||t.transporterID||t._id)){console.error("No transporter ID found in quote:",t),alert("Sorry, the transporter details could not be retrieved.");return}Q?(st(null),C(!1),X(!0)):(console.error("Company name missing. Quote data:",t),alert("Sorry, the transporter details could not be retrieved."))},Me=t.companyName==="Wheelseye FTL",E=t.companyName==="LOCAL FTL",Te=!!t.isMoverLive,Be=!!t.isPorterLive,Ae=!!t.isIndividualFtl,Ve=Te||Be,xt=Te?"Mover":"Porter",Ge=Me||E||Ve||Ae,Ye=Me,qt=Me,es=Ve||Ae,pt=!!(t.isWheelseyeLive||Ve||Ae),le=t.liveFetchedAt,Ue=le?new Date(le).toLocaleTimeString("en-IN",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}):null,de=t.liveSourceLabel,rt=Me?il:Te?nl:Be?ll:E?"/logo.svg":yc({logoUrl:t.logoUrl,networks:t.networks,companyName:t.companyName});return e.jsxs("div",{className:`relative p-5 rounded-2xl border transition-all duration-300 shadow-sm hover:shadow-md hover:-translate-y-0.5 overflow-hidden
73                ${Ge?"bg-amber-50/95 border-amber-200 ring-1 ring-amber-200/50":l?"bg-emerald-50/60 border-emerald-200 ring-1 ring-emerald-100":"bg-white border-slate-100"}`,children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none z-50 overflow-hidden",style:{backgroundImage:"var(--wm-svg, none)",backgroundRepeat:"repeat"},"aria-hidden":"true"}),e.jsxs("div",{className:"hidden sm:flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Wa,{as:"h3",className:"font-bold tracking-tight text-slate-800 font-display min-w-0",style:h?{filter:"blur(14px)",userSelect:"none",pointerEvents:"none"}:void 0,children:(t.companyName||"").split(" ").map(Q=>Q.charAt(0).toUpperCase()+Q.slice(1).toLowerCase()).join(" ")}),rt&&e.jsx("img",{src:rt,alt:`${t.companyName} logo`,className:"w-7 h-7 rounded-md shadow-sm border border-black/5 flex-shrink-0 bg-white object-contain p-0.5",draggable:!1}),e.jsxs("div",{className:"flex items-center flex-nowrap gap-1.5 flex-shrink-0",children:[(()=>{if(Me)return null;const G=Bi(t,r,!!(g&&!_));return e.jsx(Mi,{status:G,className:"!text-[8px] !px-2 !py-0.5"})})(),(()=>{const Q=t.dataQualityScore,G=t.dataQualityIssues;if(Q==null&&(!G||G.length===0)||Q!=null&&Q>=85&&(!G||G.length===0))return null;const ue=G&&G.length>0,$e=ue?"bg-red-50 text-red-600 border-red-200":Q!=null&&Q>=70?"bg-amber-50 text-amber-600 border-amber-200":"bg-orange-50 text-orange-600 border-orange-200",Je=ue?"⚠ Unverified Rates":`Data: ${Q}%`,U=ue?G.join(" | "):"Rate data may not be fully verified";return e.jsx("div",{className:`flex items-center gap-1 px-2 py-0.5 rounded-full border text-[8px] font-bold cursor-help ${$e}`,title:U,children:Je})})(),Ye&&e.jsxs("div",{className:"flex items-center gap-1 bg-blue-600 px-2 py-0.5 rounded-full border border-blue-700 shadow-sm shadow-blue-100",children:[e.jsx(Re,{size:10,
73className:"text-white"}),e.jsx("span",{className:"text-[8px] font-black text-white tracking-wider uppercase font-display",children:"Partner"})]}),qt&&e.jsxs("div",{className:"flex items-center gap-1 bg-amber-200 px-2 py-0.5 rounded-full border border-amber-300 shadow-sm shadow-amber-900/5",children:[e.jsx("span",{className:"text-base",children:"🏆"}),e.jsx("span",{className:"text-[8px] font-black text-amber-900 tracking-wider uppercase font-display",children:"Recommended"})]}),pt&&e.jsxs("div",{className:"flex items-center gap-1.5 bg-green-100 px-2 py-0.5 rounded-full border border-green-200 cursor-help",title:`Fetched live${Ue?` at ${Ue}`:""}${de?` from ${de}`:""} — open Breakup to see every option the platform returned`,children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-500 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-green-600"})]}),e.jsxs("span",{className:"text-[8px] font-black text-green-700 tracking-wider uppercase font-display",children:["Live",Ue?` · ${Ue}`:""]})]}),Me&&!t.isWheelseyeLive&&(()=>{const G=(Array.isArray(t.vehicleBreakdown)?t.vehicleBreakdown:[]).reduce(($e,Je)=>$e+(Number(Je?.count)||1),0),ue=Number(t.vehicleCalculation?.totalVehiclesRequired)||G;return!Number.isFinite(ue)||ue<=1?null:e.jsxs("div",{className:"flex items-center gap-1 bg-orange-50 px-2 py-0.5 rounded-full border border-orange-200 cursor-help",title:`This load exceeds a single truck — our estimate books ${ue} vehicles, so the final price is tentative and may differ. Connect Wheelseye for an exact live quote.`,children:[e.jsx(Re,{size:10,className:"text-orange-500"}),e.jsxs("span",{className:"text-[8px] font-black text-orange-600 tracking-wider uppercase font-display",children:["Tentative · needs ",ue," vehicles"]})]})})()]})]}),t.wheelseyeNeedsConnect&&e.jsx("a",{href:t.wheelseyeConnectUrl||"https://wheelseye.com/booking/a/dashboard",target:"_blank",rel:"noopener noreferrer",onClick:Q=>Q.stopPropagation(),className:"text-[11px] text-blue-600 hover:text-blue-800 font-semibold underline underline-offset-2 mt-0.5 inline-block",children:"Connect your Wheelseye account for a live price →"}),t.wheelseyeNeedsExtension&&e.jsx("a",{href:"https://chromewebstore.google.com/detail/freightcompare-quick-book/apdmijcbadkjbnncfhhgogaibndfmeel",target:"_blank",rel:"noopener noreferrer",onClick:Q=>Q.stopPropagation(),className:"text-[11px] text-blue-600 hover:text-blue-800 font-semibold underline underline-offset-2 mt-0.5 inline-block",children:"Add the free extension for a live Wheelseye price →"}),pt&&t.vehicle&&e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5 font-medium",children:[e.jsx("span",{className:"font-bold text-slate-700",children:t.vehicle}),Number(t.ratedCapacityKg)>0&&e.jsxs(e.Fragment,{children:[" · rated ",Number(t.ratedCapacityKg).toLocaleString("en-IN")," kg",Number(t.chargeableWeight)>0&&e.jsxs(e.Fragment,{children:[" — fits your ",Math.ceil(t.chargeableWeight).toLocaleString("en-IN")," kg load"]})]}),de&&e.jsxs(e.Fragment,{children:[" · via ",de]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2.5",children:[Ae&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-base font-black px-2 py-0.5 rounded-full border shadow-sm bg-yellow-50 text-yellow-700 border-yellow-200",children:[e.jsx(Re,{size:10})," INDIVIDUAL FTL"]}),c&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-base font-black px-2 py-0.5 rounded-full border shadow-sm bg-blue-50 text-blue-600 border-blue-100",children:[e.jsx(It,{size:10,className:"fill-current"})," FASTEST"]}),l&&e.jsx("span",{className:"inline-flex items-center gap-1 text-base font-black px-2 py-0.5 rounded-full border shadow-sm bg-emerald-50 text-emerald-600 border-emerald-100",children:"BEST VALUE"})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-4",children:[Ae?e.jsx("span",{className:"inline-flex items-center gap-1.5 text-base text-slate-500 font-body",children:"Individual FTL listing — contact the transporter directly to book"}):Ve?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-base text-slate-500 font-body",children:["Live app pricing — booked & fulfilled on the ",xt," app"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-base text-slate-500 font-body",children:[e.jsx("span",{className:"font-semibold text-yellow-400",children:"★"}),e.jsx("strong",{className:"font-black text-slate-900 font-display",children:R.toFixed(1)}),e.jsxs("span",{className:"opacity-60",children:["(",I,")"]}),e.jsx(Ai,{vendorRatings:P,totalRatings:I,overallRating:R,vendorId:ae?t.transporterData?._id||Ia(t.companyName):t.companyId||t.transporterData?._id||t._id,isTemporaryVendor:t.isTiedUp===!0||t.isTemporaryTransporter===!0,vendorType:ae?"special":t.isTiedUp===!0||t.isTemporaryTransporter===!0?"temporary":"regular"})]}),!h&&!es&&e.jsx("button",{onClick:Q=>{Q.stopPropagation();const G=ae?t.transporterData?._id||Ia(t.companyName):t.companyId||t.transporterData?._id||t._id,ue=ae?"special":t.isTiedUp===!0||t.isTemporaryTransporter===!0?"temporary":"regular";u({vendorId:G,vendorName:(t.companyName||"").toUpperCase(),isTemporaryVendor:t.isTiedUp===!0||t.isTemporaryTransporter===!0||ae,vendorType:ue,onRatingSubmitted:($e,Je)=>{k($e),T(Je),M(U=>U+1)}})},className:"text-base font-bold underline underline-offset-4 decoration-current transition-opacity hover:opacity-70 text-slate-400",children:"Submit Rating"})]})]}),e.jsxs("div",{className:"flex-shrink-0 flex items-center gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center gap-1 font-bold text-slate-900 font-display whitespace-nowrap",style:{fontSize:"clamp(0.7rem, 1.1vw, 0.9rem)"},children:[e.jsx(da,{size:14,className:"text-blue-600 flex-shrink-0"}),e.jsxs("span",{children:[Math.ceil(t.estimatedTime??1)," ",Math.
73ceil(t.estimatedTime??1)===1?"DAY":"DAYS"]})]}),e.jsx("div",{className:"text-base font-black uppercase tracking-widest text-slate-400 font-display",children:"Delivery"})]}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsxs("div",{className:"flex items-baseline gap-1 font-black leading-none text-slate-900 font-display whitespace-nowrap",children:[e.jsx("span",{style:{fontSize:"clamp(0.9rem, 1.4vw, 1.25rem)"},className:"opacity-80",children:"₹"}),e.jsx("span",{style:{fontSize:"clamp(1.4rem, 2.4vw, 2rem)"},className:"tracking-tighter",children:Zt(at)}),!g&&e.jsx("span",{style:{fontSize:"clamp(1.4rem, 2.4vw, 2rem)"},className:"leading-none",children:e.jsx(gi,{quote:t})})]}),e.jsx("div",{className:"flex items-center gap-1",children:_i})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("button",{onClick:De,style:{padding:"clamp(0.4rem, 0.7vw, 0.6rem) clamp(0.6rem, 1.2vw, 1.25rem)",fontSize:"clamp(0.65rem, 0.9vw, 0.75rem)"},className:"font-bold rounded-xl transition-all tracking-widest uppercase font-display inline-flex items-center justify-center gap-1.5 whitespace-nowrap flex-shrink-0 bg-blue-600 text-white hover:bg-blue-700 shadow-sm shadow-blue-200 active:scale-95",children:ot}),lt&&e.jsxs("button",{onClick:()=>{if(!Qe){me("Subscribe to book this market carrier directly.",{duration:2500});return}if(He){window.open(t.isMoverLive?"https://mover.delivery":"https://porter.in","_blank","noopener");return}X(!1),C(!0)},style:{padding:"clamp(0.4rem, 0.7vw, 0.6rem) clamp(0.6rem, 1.2vw, 1.25rem)",fontSize:"clamp(0.65rem, 0.9vw, 0.75rem)"},className:"font-bold rounded-xl transition-all tracking-widest uppercase font-display inline-flex items-center justify-center gap-1.5 whitespace-nowrap flex-shrink-0 shadow-sm active:scale-95 bg-slate-900 text-white hover:bg-slate-700",children:[e.jsx(Dt,{size:12}),"Book Now"]})]})]})]}),e.jsxs("div",{className:"sm:hidden",children:[pt&&!!t.vehicle?null:e.jsx("div",{className:"absolute text-right font-black leading-none text-slate-900 font-display whitespace-nowrap pointer-events-none",style:{top:"4.5rem",right:"1.25rem"},children:e.jsxs("span",{className:"flex items-baseline gap-1 justify-end pointer-events-auto",children:[e.jsx("span",{style:{fontSize:"clamp(1.2rem, 2.1vw, 1.6rem)"},className:"opacity-80",children:"₹"}),e.jsx("span",{style:{fontSize:"clamp(2.1rem, 3.8vw, 2.75rem)"},className:"tracking-tighter",children:Zt(at)})]})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Wa,{as:"h3",className:"font-bold tracking-tight text-slate-800 font-display min-w-0",style:h?{filter:"blur(14px)",userSelect:"none",pointerEvents:"none"}:void 0,children:(t.companyName||"").split(" ").map(Q=>Q.charAt(0).toUpperCase()+Q.slice(1).toLowerCase()).join(" ")}),rt&&e.jsx("img",{src:rt,alt:`${t.companyName} logo`,className:"w-7 h-7 rounded-md shadow-sm border border-black/5 flex-shrink-0 bg-white object-contain p-0.5",draggable:!1})]}),!g&&e.jsx("div",{className:"flex-shrink-0",style:{fontSize:"clamp(2.1rem, 3.8vw, 2.75rem)"},children:e.jsx(gi,{quote:t})})]}),pt&&!!t.vehicle&&e.jsx("div",{className:"flex justify-end -mt-1 -mb-1",children:e.jsxs("span",{className:"flex items-baseline gap-1 font-black leading-none text-slate-900 font-display whitespace-nowrap",children:[e.jsx("span",{style:{fontSize:"clamp(1.2rem, 2.1vw, 1.6rem)"},className:"opacity-80",children:"₹"}),e.jsx("span",{style:{fontSize:"clamp(2.1rem, 3.8vw, 2.75rem)"},className:"tracking-tighter",children:Zt(at)})]})}),_i,e.jsxs("div",{className:"flex items-center flex-nowrap gap-1.5 flex-wrap",children:[(()=>{if(Me)return null;const G=Bi(t,r,!!(g&&!_));return e.jsx(Mi,{status:G,className:"!text-[8px] !px-2 !py-0.5"})})(),(()=>{const Q=t.dataQualityScore,G=t.dataQualityIssues;if(Q==null&&(!G||G.length===0)||Q!=null&&Q>=85&&(!G||G.length===0))return null;const ue=G&&G.length>0,$e=ue?"bg-red-50 text-red-600 border-red-200":Q!=null&&Q>=70?"bg-amber-50 text-amber-600 border-amber-200":"bg-orange-50 text-orange-600 border-orange-200",Je=ue?"⚠ Unverified Rates":`Data: ${Q}%`,U=ue?G.join(" | "):"Rate data may not be fully verified";return e.jsx("div",{className:`flex items-center gap-1 px-2 py-0.5 rounded-full border text-[8px] font-bold cursor-help ${$e}`,title:U,children:Je})})(),Ye&&e.jsxs("div",{className:"flex items-center gap-1 bg-blue-600 px-2 py-0.5 rounded-full border border-blue-700 shadow-sm shadow-blue-100",children:[e.jsx(Re,{size:10,
73className:"text-white"}),e.jsx("span",{className:"text-[8px] font-black text-white tracking-wider uppercase font-display",children:"Partner"})]}),qt&&e.jsxs("div",{className:"flex items-center gap-1 bg-amber-200 px-2 py-0.5 rounded-full border border-amber-300 shadow-sm shadow-amber-900/5",children:[e.jsx("span",{className:"text-base",children:"🏆"}),e.jsx("span",{className:"text-[8px] font-black text-amber-900 tracking-wider uppercase font-display",children:"Recommended"})]}),pt&&e.jsxs("div",{className:"flex items-center gap-1.5 bg-green-100 px-2 py-0.5 rounded-full border border-green-200 cursor-help",title:`Fetched live${Ue?` at ${Ue}`:""}${de?` from ${de}`:""} — open Breakup to see every option the platform returned`,children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-500 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-green-600"})]}),e.jsxs("span",{className:"text-[8px] font-black text-green-700 tracking-wider uppercase font-display",children:["Live",Ue?` · ${Ue}`:""]})]}),Me&&!t.isWheelseyeLive&&(()=>{const G=(Array.isArray(t.vehicleBreakdown)?t.vehicleBreakdown:[]).reduce(($e,Je)=>$e+(Number(Je?.count)||1),0),ue=Number(t.vehicleCalculation?.totalVehiclesRequired)||G;return!Number.isFinite(ue)||ue<=1?null:e.jsxs("div",{className:"flex items-center gap-1 bg-orange-50 px-2 py-0.5 rounded-full border border-orange-200 cursor-help",title:`This load exceeds a single truck — our estimate books ${ue} vehicles, so the final price is tentative and may differ. Connect Wheelseye for an exact live quote.`,children:[e.jsx(Re,{size:10,className:"text-orange-500"}),e.jsxs("span",{className:"text-[8px] font-black text-orange-600 tracking-wider uppercase font-display",children:["Tentative · needs ",ue," vehicles"]})]})})(),Ae&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-base font-black px-2 py-0.5 rounded-full border shadow-sm bg-yellow-50 text-yellow-700 border-yellow-200",children:[e.jsx(Re,{size:10})," INDIVIDUAL FTL"]}),c&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-base font-black px-2 py-0.5 rounded-full border shadow-sm bg-blue-50 text-blue-600 border-blue-100",children:[e.jsx(It,{size:10,className:"fill-current"})," FASTEST"]}),l&&e.jsx("span",{className:"inline-flex items-center gap-1 text-base font-black px-2 py-0.5 rounded-full border shadow-sm bg-emerald-50 text-emerald-600 border-emerald-100",children:"BEST VALUE"})]}),t.wheelseyeNeedsConnect&&e.jsx("a",{href:t.wheelseyeConnectUrl||"https://wheelseye.com/booking/a/dashboard",target:"_blank",rel:"noopener noreferrer",onClick:Q=>Q.stopPropagation(),className:"text-[11px] text-blue-600 hover:text-blue-800 font-semibold underline underline-offset-2 -mt-1 inline-block",children:"Connect your Wheelseye account for a live price →"}),t.wheelseyeNeedsExtension&&e.jsx("a",{href:"https://chromewebstore.google.com/detail/freightcompare-quick-book/apdmijcbadkjbnncfhhgogaibndfmeel",target:"_blank",rel:"noopener noreferrer",onClick:Q=>Q.stopPropagation(),className:"text-[11px] text-blue-600 hover:text-blue-800 font-semibold underline underline-offset-2 -mt-1 inline-block",children:"Add the free extension for a live Wheelseye price →"}),pt&&t.vehicle&&e.jsxs("div",{className:"text-[11px] text-slate-500 -mt-1 font-medium",children:[e.jsx("span",{className:"font-bold text-slate-700",children:t.vehicle}),Number(t.ratedCapacityKg)>0&&e.jsxs(e.Fragment,{children:[" · rated ",Number(t.ratedCapacityKg).toLocaleString("en-IN")," kg",Number(t.chargeableWeight)>0&&e.jsxs(e.Fragment,{children:[" — fits your ",Math.ceil(t.chargeableWeight).toLocaleString("en-IN")," kg load"]})]}),de&&e.jsxs(e.Fragment,{children:[" · via ",de]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[Ae?e.jsx("span",{className:"inline-flex items-center gap-1.5 text-base text-slate-500 font-body",children:"Individual FTL listing — contact the transporter directly to book"}):Ve?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-base text-slate-500 font-body",children:["Live app pricing — booked & fulfilled on the ",xt," app"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-base text-slate-500 font-body",children:[e.jsx("span",{className:"font-semibold text-yellow-400",children:"★"}),e.jsx("strong",{className:"font-black text-slate-900 font-display",children:R.toFixed(1)}),e.jsxs("span",{className:"opacity-60",children:["(",I,")"]}),e.jsx(Ai,{vendorRatings:P,totalRatings:I,overallRating:R,vendorId:ae?t.transporterData?._id||Ia(t.companyName):t.companyId||t.transporterData?._id||t._id,isTemporaryVendor:t.isTiedUp===!0||t.isTemporaryTransporter===!0,vendorType:ae?"special":t.isTiedUp===!0||t.isTemporaryTransporter===!0?"temporary":"regular"})]}),!h&&!es&&e.jsx("button",{onClick:Q=>{Q.stopPropagation();const G=ae?t.transporterData?._id||Ia(t.companyName):t.companyId||t.transporterData?._id||t._id,ue=ae?"special":t.isTiedUp===!0||t.isTemporaryTransporter===!0?"temporary":"regular";u({vendorId:G,vendorName:(t.companyName||"").toUpperCase(),isTemporaryVendor:t.isTiedUp===!0||t.isTemporaryTransporter===!0||ae,vendorType:ue,onRatingSubmitted:($e,Je)=>{k($e),T(Je),M(U=>U+1)}})},className:"text-base font-bold underline underline-offset-4 decoration-current transition-opacity hover:opacity-70 text-slate-400",children:"Submit Rating"})]}),e.jsxs("div",{className:"flex items-center gap-1 font-bold text-slate-400 font-display whitespace-nowrap uppercase tracking-widest",style:{fontSize:"clamp(0.65rem, 1vw, 0.8rem)"},children:[e.jsx(da,{size:13,className:"text-blue-600 flex-shrink-0"}),e.jsxs("span",{children:[Math.ceil(t.estimatedTime??1)," ",Math.
73ceil(t.estimatedTime??1)===1?"DAY":"DAYS"," DELIVERY"]})]}),e.jsxs("div",{className:"flex items-stretch gap-1.5 w-full",children:[e.jsx("button",{onClick:De,style:{padding:"clamp(0.5rem, 1vw, 0.7rem) 0",fontSize:"clamp(0.65rem, 0.9vw, 0.75rem)"},className:"flex-1 font-bold rounded-xl transition-all tracking-widest uppercase font-display inline-flex items-center justify-center gap-1.5 whitespace-nowrap bg-blue-600 text-white hover:bg-blue-700 shadow-sm shadow-blue-200 active:scale-95",children:ot}),lt&&e.jsxs("button",{onClick:()=>{if(!Qe){me("Subscribe to book this market carrier directly.",{duration:2500});return}if(He){window.open(t.isMoverLive?"https://mover.delivery":"https://porter.in","_blank","noopener");return}X(!1),C(!0)},style:{padding:"clamp(0.5rem, 1vw, 0.7rem) 0",fontSize:"clamp(0.65rem, 0.9vw, 0.75rem)"},className:"flex-1 font-bold rounded-xl transition-all tracking-widest uppercase font-display inline-flex items-center justify-center gap-1.5 whitespace-nowrap shadow-sm active:scale-95 bg-slate-900 text-white hover:bg-slate-700",children:[e.jsx(Dt,{size:12}),"Book Now"]})]})]})]}),e.jsx(kt,{children:f&&e.jsx(xm,{quote:t})}),Qe&&y&&(re?e.jsx(Td,{isOpen:K,onClose:()=>C(!1),onEditSearch:()=>{C(!1),j()},vehicleName:t.vehicle,price:at,defaultPhone:H()?.phone?String(H().phone):"",defaultName:H()?.name||"",route:{fromPincode:y.fromPincode,toPincode:y.toPincode,fromCity:y.fromCity,toCity:y.toCity,weight:t.chargeableWeight??y.totalActualWeight,tonnage:t.ratedCapacityKg?t.ratedCapacityKg/1e3:Math.max(.1,(t.chargeableWeight??y.totalActualWeight)/1e3)}}):e.jsx(Uo,{isOpen:K,onClose:()=>C(!1),quote:t,vendorType:t.isTiedUp===!0?"temporaryTransporter":"transporter",vend
73orId:t.companyId||t.transporterData?._id||t.transporterID||t._id,calculatorContext:y})),e.jsx(hd,{isOpen:ce,onClose:()=>X(!1),vendorType:t.isTiedUp===!0?"temporaryTransporter":"transporter",vendorId:t.companyId||t.transporterData?._id||t.transporterID||t._id,companyName:t.companyName||t.transporterName||"Vendor",canBookNow:Qe&&!!y,staticContact:Oe,onBookNow:()=>{X(!1),C(!0)}})]})};export{rh 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.