public/assets/index-M3mvPwS8.js: `,zn=new Blob([Be],{type:"application/javascript"}),Bn=URL.createObjectURL(zn);try{await _e.audioWorklet.addModule(Bn),URL.revokeObjectURL(Bn);const Qe=_e.createMediaStreamSource(le),Ke=new AudioWorkletNode(_e,"pcm-processor");Ke.port.onmessage=Kt=>{if(ye.readyState!==WebSocket.OPEN)return;const{buffer:Ys,chunkCount:Fs,db:Ic,first8:ci,hasNonZero:ui}=Kt.data;(Fs<=5||Fs%50===0)&&console.log(`[LiveCopilot] AudioWorklet chunk #${Fs}:`,{size:Ys.byteLength,level:`${Ic.toFixed(1)} dB`,first8samples:ci,hasNonZero:ui}),ye.send(Ys)},Qe.connect(Ke),console.log("[LiveCopilot] AudioWorklet started (linear16 at",et,"Hz)"),ft.current={stop:()=>{Ke.disconnect(),Qe.disconnect(),_e.close()}}}catch(Qe){console.error("[LiveCopilot] AudioWorklet failed:",Qe),D("Audio processing failed"),_e.close()}}else{if(console.log("[LiveCopilot] Falling back to Web Speech API"),je("webspeech"),"webkitSpeechRecognition"in window||"SpeechRecognition"in window){const ye=window.SpeechRecognition||window.webkitSpeechRecognition,Ae=new ye;Ae.continuous=!0,Ae.interimResults=!0,Ae.lang="en-AU",Ae.onstart=()=>{console.log("[LiveCopilot] Web Speech API started")},Ae.onend=()=>{if(console.log("[LiveCopilot] Web Speech API ended"),f){console.log("[LiveCopilot] Restarting Web Speech API...");try{Ae.start()}catch(_e){console.log("[LiveCopilot] Could not restart:",_e.message)}}},Ae.onresult=_e=>{let et="",Be="";for(let zn=_e.resultIndex;zn<_e.results.length;zn++){const Bn=_e.results[zn];if(Bn.isFinal){Be+=Bn[0].transcript,mt(Be),Xe(Be);const Qe=Dt(Be);Qe?kt(Qe):Jn(Be)&&ys(Be),qt&&oi(Be)}else et+=Bn[0].transcript}Be&&y(zn=>zn+" "+Be),g(et)},Ae.onerror=_e=>{console.error("[LiveCopilot] Speech recognition error:",_e.error),D({network:"Network error - check your internet connection","not-allowed":"Microphone access denied - please allow in browser settings","no-speech":"No speech detected - try speaking louder","audio-capture":"No microphone found",aborted:"Transcription stopped"}[_e.error]||`Speech error: ${_e.error}`)},Ae.start(),Ft.current=Ae,m(!0),D(null)}else D("Speech recognition not supported in this browser. Use Chrome for best results."),je(null);le.getTracks().forEach(ye=>ye.stop())}}catch(le){console.error("Failed to start listening:",le),D("Microphone access denied")}},xs=()=>{Xt.current&&(clearTimeout(Xt.current),Xt.current=null),be.current&&(be.current.getTracks().forEach(le=>le.stop()),be.current=null),ft.current&&(ft.current.stop(),ft.current=null),Ft.current&&(Ft.current instanceof WebSocket?Ft.current.close():Ft.current.stop(),Ft.current=null),m(!1)},ul=async()=>{xs(),Qn.current=!0;try{await It.saveCopilotSession({leadId:t?.id,transcript:p,suggestions:w,duration:A})}catch(le){console.error("Failed to save copilot session:",le)}i?.(),s()},Hc=async()=>{if(t?.id)try{console.log("Marked lead as hot:",t.id)}catch(le){console.error("Failed to mark as hot:",le)}},qc=()=>{ri(le=>!le)},kr=()=>{$s(null)};return B?c.jsxs("button",{onClick:()=>_(!1),className:"fixed top-4 right-4 z-50 bg-gradient-to-r from-violet-600 to-purple-600 text-white px-4 py-3 rounded-2xl shadow-lg shadow-violet-500/30 flex items-center gap-3 animate-pulse",children:[c.jsx("div",{className:"w-3 h-3 bg-red-500 rounded-full animate-ping"}),c.jsx("span",{className:"font-semibold",children:Ht(A)}),c.jsx(mh,{className:"w-5 h-5"})]}):c.jsxs(c.Fragment,{children:[c.jsx(jE,{lead:t,duration:A,isListening:f,isMuted:Ln,script:ps,scriptStage:Yn,intel:Xn,latestSuggestion:St,openingLine:X,error:R,onMinimize:()=>_(!0),onMute:qc,onMarkHot:Hc,onEndCall:ul,onDismissSuggestion:kr}),Ne&&c.jsx(hE,{candidate:Ne,sourceLeadId:t?.id,onAdd:Wn,onDismiss:()=>se(null)})]})}const vw=b.createContext(null);function kE({children:t}){const s=Bj(),[i,l]=b.useState(null),[o,d]=b.useState(null),[f,m]=b.useState(null),[p,y]=b.useState(!1),[x,g]=b.useState(!1),[w,S]=b.useState(""),[T,N]=b.useState(!1),[R,D]=b.useState(null),[A,C]=b.useState(!1),[B,_]=b.useState(null),[F,$]=b.useState(null),[I,z]=b.useState(0),X=b.useRef(null),te=b.useRef(null),H=b.useRef(null),P=b.useRef(null),K=async()=>{if(P.current)return P.current;try{const ne=await It.getDeepgramCredentials();return P.current=ne,ne}catch{return console.log("Deepgram not configured, using Web Speech API fallback"),null}};b.useCallback(async()=>{try{const ne=await navigator.mediaDevices.getUserMedia({audio:!0});H.current=ne;const de=await K();if(de?.url&&de?.apiKey){const oe=new WebSocket(de.url,["token",de.apiKey]);oe.onopen=()=>{console.log("[AutoTranscribe] Deepgram connected"),N(!0)},oe.onmessage=ge=>{const Ee=JSON.parse(ge.data);if(Ee.channel?.alternatives?.[0]?.transcript){const wt=Ee.channel.alternatives[0].transcript;Ee.is_final&&wt.trim()&&S(me=>(me+" "+wt).trim())}},oe.onerror=ge=>{console.error("[AutoTranscribe] Deepgram error:",ge)},oe.onclose=()=>{console.log("[AutoTranscribe] Deepgram disconnected"),N(!1)},X.current=oe;const ee=new MediaRecorder(ne,{mimeType:"audio/webm"});ee.ondataavailable=ge=>{ge.data.size>0&&oe.readyState===WebSocket.OPEN&&oe.send(ge.data)},ee.start(250),te.current=ee}else{if("webkitSpeechRecognition"in window||"SpeechRecognition"in window){const oe=window.SpeechRecognition||window.webkitSpeechRecognition,ee=new oe;ee.continuous=!0,ee.interimResults=!1,ee.lang="en-AU",ee.onresult=ge=>{for(let Ee=ge.resultIndex;Ee(me+" "+wt).trim())}},ee.onerror=ge=>{console.error("[AutoTranscribe] Speech recognition error:",ge)},ee.start(),X.current=ee,N(!0)}ne.getTracks().forEach(oe=>oe.stop()),H.current=null}}catch(ne){console.error("[AutoTranscribe] Failed to start:",ne)}},[]);const ae=b.useCallback(()=>{te.current&&(te.current.stop(),te.current=null),X.current&&(X.current instanceof WebSocket?X.current.close():X.current.stop(),X.current=null),H.current&&(H.current.getTracks().forEach(ne=>ne.stop()),H.current=null),N(!1)},[]),O=b.useCallback(async(ne,de,oe)=>{if(!oe||oe.trim().length<10)return console.log("[AutoSummary] Transcript too short, skipping"),null;C(!0);try{console.log("[AutoSummary] Generating summary for",oe.length,"chars");const ee=await It.postCallSummary({leadId:ne.id,transcript:oe,callDuration:de||0});if(ee.summary)return D(ee.summary),ee.summary}catch(ee){console.error("[AutoSummary] Failed:",ee)}finally{C(!1)}return null},[]),[G,Z]=b.useState(null),re=(ne,de,oe=null)=>{S(""),D(null),$(null),g(!0),y(!1),m(null),l(ne),d(de||null),Z(oe)},ue=b.useCallback(async(ne,de)=>{if(!ne){console.error("[CallContext] makeCall: No phone number provided");return}let oe={id:de,phone:ne};if(de)try{const ee=await Tr.get(de);ee&&(oe=ee)}catch(ee){console.log("[CallContext] Could not fetch lead, using minimal data:",ee)}re(oe)},[]),je=b.useCallback((ne,de,oe)=>{console.log("[CallContext] Accepting inbound call for lead:",de?.id),S(""),D(null),g(!0),y(!0),m(ne);const ee=ne?.parameters?.CallSid||null;console.log("[CallContext] Inbound call CallSid:",ee),$(ee),l(de||{id:null,first_name:"Unknown",last_name:"Caller",phone:ne?.parameters?.From||"Unknown"}),d(oe||null),ne&&ne.on("disconnect",()=>{console.log("[CallContext] Inbound call disconnected")})},[]),Ne=b.useCallback(ne=>{console.log("[CallContext] Call connected, CallSid:",ne),ne&&$(ne)},[]),se=async ne=>{z(ne||0),ae();const de=w,oe=i;de&&de.trim().length>10&&oe&&await O(oe,ne,de),s.invalidateQueries({queryKey:["dashboard-all"]}),s.invalidateQueries({queryKey:["priority-action"]}),oe?.id&&(s.invalidateQueries({queryKey:["leads",oe.id]}),s.invalidateQueries({queryKey:["lead",oe.id]})),console.log("[CallContext] Cache invalidated after call end"),l(null),o&&(o(ne),d(null))},ce=b.useCallback(()=>{S(""),D(null),_(null),$(null),z(0),m(null),y(!1)},[]);return c.jsxs(vw.Provider,{value:{startCall:re,makeCall:ue,acceptInboundCall:je,activeLead:i,isInboundCall:p,inboundCall:f,transcript:w,isTranscribing:T,autoSummary:R,generatingSummary:A,clearCallData:ce,scriptSessionId:B,setScriptSessionId:_,callSid:F,callDuration:I,showCopilot:x,setShowCopilot:g,preloadedIntel:G},children:[t,i&&x&&c.jsx(DE,{lead:i,onClose:()=>g(!1),onEnd:se}),i&&c.jsx(fE,{lead:i,inboundCall:f,isInbound:p,onClose:()=>{ae(),l(null),m(null),y(!1)},onCallEnd:se,onCallConnected:Ne})]})}function kc(){const t=b.useContext(vw);if(!t)throw new Error("useCall must be used within CallProvider");return t}const ww=b.createContext(null),Yo=()=>{try{const t=new(window.AudioContext||window.webkitAudioContext),s=t.createOscillator(),i=t.createGain();s.connect(i),i.connect(t.destination),s.frequency.value=800,s.type="sine",i.gain.setValueAtTime(.3,t.currentTime),i.gain.exponentialRampToValueAtTime(.01,t.currentTime+.3),s.start(t.currentTime),s.stop(t.currentTime+.3)}catch{console.log("Could not play notification sound")}},Sw=(t,s,i)=>{if(!("Notification"in window)){console.log("[Realtime] Browser notifications not supported");return}if(Notification.permission==="granted"){const l=new Notification(t,{body:s,icon:"/icon-192.png",badge:"/icon-192.png",tag:"high-intent-sms",requireInteraction:!0});i&&(l.onclick=i)}else Notification.permission!=="denied"&&Notification.requestPermission().then(l=>{l==="granted"&&Sw(t,s,i)})},zx=()=>{try{const t=new(window.AudioContext||window.webkitAudioContext);for(let s=0;s<2;s++){const i=t.createOscillator(),l=t.createGain();i.connect(l),l.connect(t.destination),i.frequency.value=1e3,i.type="square";const o=t.currentTime+s*.25;l.gain.setValueAtTime(.4,o),l.gain.exponentialRampToValueAtTime(.01,o+.15),i.start(o),i.stop(o+.15)}}catch{console.log("Could not play urgent alert sound")}};function RE({children:t}){const[s,i]=b.useState(0),[l,o]=b.useState(0),[d,f]=b.useState(0),[m,p]=b.useState(null),[y,x]=b.useState(null),[g,w]=b.useState(!1),[S,T]=b.useState(null),N=b.useCallback(()=>T(null),[]),R=b.useRef({sms_inbound:[],sms_outbound:[],call_inbound:[],call_logged:[],voicemail:[],lead_updated:[],lead_converted:[],website_signup:[],high_intent_sms:[]}),D=b.useCallback((I,z)=>(R.current[I]||(R.current[I]=[]),R.current[I].push(z),()=>{R.current[I]=R.current[I].filter(X=>X!==z)}),[]),A=b.useCallback((I,z)=>{(R.current[I]||[]).forEach(te=>{try{te(z)}catch(H){console.error("Realtime listener error:",H)}})},[]),C=b.useCallback(()=>i(0),[]),B=b.useCallback(()=>o(0),[]),_=b.useCallback(()=>f(0),[]),F=b.useCallback(()=>p(null),[]),$=b.useCallback(I=>{i(I)},[]);return b.useEffect(()=>{(async()=>{try{const z=await fetch("/api/sms/conversations/prioritized?limit=1");if(z.ok){const X=await z.json();X.totalUnread!==void 0&&(i(X.totalUnread),console.log("[Realtime] Initialized SMS count:",X.totalUnread))}}catch(z){console.warn("[Realtime] Failed to init SMS count:",z.message)}})()},[]),b.useEffect(()=>{console.log("[Realtime] Setting up subscriptions...");const I=Nt.channel("communications-changes").on("postgres_changes",{event:"INSERT",schema:"public",table:"communications"},te=>{console.log("[Realtime] New communication:",te.new?.type);const H=te.new;if(H.type==="sms_inbound"){i(K=>K+1),x({type:"sms_inbound",data:H,timestamp:Date.now()}),A("sms_inbound",H);const P=H.metadata?.buyingSignal;if(P?.level==="high"||P?.level==="medium"){console.log("[Realtime] 🔥 HIGH INTENT SMS received!",P),zx(),A("high_intent_sms",H);const K=P.level==="high";Sw(K?"🔥 HIGH BUYING INTENT!":"⚡ Buying Signal Detected",`"${(H.content||"").substring(0,80)}..."`,()=>{window.focus()}),console.log("[Realtime] Setting highIntentSms state:",{leadId:H.lead_id,phone:H.phone,message:H.content?.substring(0,50)}),T({leadId:H.lead_id,phone:H.phone,message:H.content,buyingSignal:P,timestamp:Date.now()})}else Yo()}else H.type==="sms_outbound"?(x({type:"sms_outbound",data:H,timestamp:Date.now()}),A("sms_outbound",H)):H.type==="call_inbound"?(o(P=>P+1),x({type:"call_inbound",data:H,timestamp:Date.now()}),A("call_inbound",H),Yo()):H.type==="voicemail"?(f(P=>P+1),x({type:"voicemail",data:H,timestamp:Date.now()}),A("voicemail",H),Yo()):H.type==="call_outbound"&&(o(P=>P+1),x({type:"call_logged",data:H,timestamp:Date.now()}),A("call_logged",H))}).subscribe(te=>{console.log("[Realtime] Communications channel:",te),w(te==="SUBSCRIBED")}),z=Nt.channel("leads-changes").on("postgres_changes",{event:"UPDATE",schema:"public",table:"leads"},te=>{console.log("[Realtime] Lead updated:",te.new?.id);const H=te.old,P=te.new;A("lead_updated",P),H.status!=="converted"&&P.status==="converted"&&(x({type:"lead_converted",data:P,timestamp:Date.now()}),A("lead_converted",P),Yo())}).subscribe(te=>{console.log("[Realtime] Leads channel:",te)}),X=Nt.channel("notifications-changes").on("postgres_changes",{event:"INSERT",schema:"public",table:"notifications"},te=>{const H=te.new;console.log("[Realtime] New notification:",H?.type),H.type==="website_signup"&&(p({title:H.title,message:H.message,leadId:H.metadata?.lead_id,isReEngaged:H.metadata?.is_re_engaged,signupAt:H.metadata?.signup_at,aiInsight:H.metadata?.ai_insight,timestamp:Date.now()}),x({type:"website_signup",data:H,timestamp:Date.now()}),A("website_signup",H),zx())}).subscribe(te=>{console.log("[Realtime] Notifications channel:",te)});return()=>{console.log("[Realtime] Cleaning up subscriptions..."),Nt.removeChannel(I),Nt.removeChannel(z),Nt.removeChannel(X)}},[A]),c.jsx(ww.Provider,{value:{newSmsCount:s,newCallCount:l,newVoicemailCount:d,websiteSignup:m,highIntentSms:S,lastEvent:y,isConnected:g,subscribe:D,clearNewSmsCount:C,syncSmsCount:$,clearNewCallCount:B,clearNewVoicemailCount:_,clearWebsiteSignup:F,clearHighIntentSms:N},children:t})}function Rc(){const t=b.useContext(ww);if(!t)throw new Error("useRealtime must be used within RealtimeProvider");return t}function hR(t,s){const{subscribe:i}=Rc();b.useEffect(()=>i(t,s),[t,s,i])}const ME={duel_win:"https://assets.mixkit.co/active_storage/sfx/2019/2019-preview.mp3",duel_lose:"https://assets.mixkit.co/active_storage/sfx/2020/2020-preview.mp3",challenge_received:"https://assets.mixkit.co/active_storage/sfx/2869/2869-preview.mp3",conversion:"https://assets.mixkit.co/active_storage/sfx/1435/1435-preview.mp3",streak_milestone:"https://assets.mixkit.co/active_storage/sfx/2000/2000-preview.mp3",challenge_win:"https://assets.mixkit.co/active_storage/sfx/2013/2013-preview.mp3"},Bx={};function OE(t,s=.5){if(!(localStorage.getItem("battleground_sounds")!=="false"))return;const l=ME[t];if(!l){console.warn(`Unknown sound: ${t}`);return}try{let o=Bx[t];o?o.currentTime=0:(o=new Audio(l),Bx[t]=o),o.volume=s,o.play().catch(d=>{console.debug("Sound playback blocked:",d.message)})}catch(o){console.error("Error playing sound:",o)}}const Vx=["#FFD700","#FF6B6B","#4ECDC4","#A855F7","#F97316"];function jw({celebration:t,onDismiss:s}){const[i,l]=b.useState([]);if(b.useEffect(()=>{if(!t)return;const m={conversion:"conversion",duel_win:"duel_win",challenge_win:"challenge_win",streak_milestone:"streak_milestone"}[t.event_type]||"conversion";OE(m,.6);const p=Array.from({length:50},(x,g)=>({id:g,x:Math.random()*100,delay:Math.random()*.5,color:Vx[Math.floor(Math.random()*Vx.length)],rotation:Math.random()*360}));l(p);const y=setTimeout(()=>{s?.()},4e3);return()=>clearTimeout(y)},[t]),!t)return null;const o=()=>{switch(t.event_type){case"duel_win":return c.jsx(ph,{className:"w-12 h-12 text-purple-400"});case"streak_milestone":return c.jsx(nl,{className:"w-12 h-12 text-orange-400"});case"challenge_win":return c.jsx(Zj,{className:"w-12 h-12 text-amber-400"});default:return c.jsx(ny,{className:"w-12 h-12 text-green-400"})}},d=()=>{switch(t.event_type){case"duel_win":return"from-purple-500/90 to-pink-500/90";case"streak_milestone":return"from-orange-500/90 to-red-500/90";case"challenge_win":return"from-amber-500/90 to-yellow-500/90";default:return"from-green-500/90 to-emerald-500/90"}};return c.jsx(si,{children:c.jsxs(Le.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center",onClick:s,children:[c.jsx("div",{className:"absolute inset-0 bg-black/70"}),i.map(f=>c.jsx(Le.div,{initial:{y:-20,x:`${f.x}vw`,opacity:1,rotate:f.rotation},animate:{y:"100vh",rotate:f.rotation+720,opacity:[1,1,0]},transition:{duration:3,delay:f.delay,ease:"easeIn"},className:"absolute top-0 w-3 h-3 rounded-sm",style:{backgroundColor:f.color}},f.id)),c.jsxs(Le.div,{initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.5,opacity:0},transition:{type:"spring",damping:15},className:`relative bg-gradient-to-br ${d()} rounded-3xl p-8 text-center max-w-sm mx-4 shadow-2xl`,children:[c.jsx("button",{onClick:s,className:"absolute top-4 right-4 p-1 text-white/50 hover:text-white",children:c.jsx(Gt,{className:"w-5 h-5"})}),c.jsx(Le.div,{initial:{scale:0},animate:{scale:[0,1.2,1]},transition:{delay:.2,duration:.5},className:"w-20 h-20 bg-white/20 rounded-full flex items-center justify-center mx-auto mb-4",children:o()}),c.jsx(Le.h2,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.3},className:"text-3xl font-black text-white mb-2",children:t.title}),t.subtitle&&c.jsx(Le.p,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.4},className:"text-white/80 text-lg mb-4",children:t.subtitle}),t.xp_amount>0&&c.jsxs(Le.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.5,type:"spring"},className:"inline-flex items-center gap-2 px-4 py-2 bg-black/20 rounded-full",children:[c.jsx(ny,{className:"w-5 h-5 text-yellow-300"}),c.jsxs("span",{className:"text-xl font-black text-white",children:["+",t.xp_amount," XP"]})]})]})]})})}function mR(){const[t,s]=b.useState(null),i=f=>{s({event_type:"achievement",title:f.title||"Achievement Unlocked!",subtitle:f.description,xp_amount:f.xp_reward||0})},l=f=>{s(f)},o=()=>{s(null)};return{celebration:t,showAchievement:i,showCelebration:l,closeCelebration:o,CelebrationComponent:()=>c.jsx(jw,{celebration:t,onDismiss:o})}}const Tw=b.createContext(null);function _E({children:t}){const[s,i]=b.useState(null),l=b.useCallback(y=>{y&&(y.levelUp?i({type:"level_up",level:y.level,levelName:y.levelName}):y.awarded>=20&&i({type:"xp",xp:y.awarded}))},[]),o=b.useCallback(y=>{i({type:"achievement",achievement:y})},[]),d=b.useCallback((y,x)=>{i({type:"level_up",level:y,levelName:x})},[]),f=b.useCallback(y=>{i({type:"xp",xp:y})},[]),m=b.useCallback(y=>{i({type:"streak",streak:y})},[]),p=b.useCallback(()=>{i(null)},[]);return c.jsxs(Tw.Provider,{value:{handleXPResponse:l,showAchievement:o,showLevelUp:d,showXP:f,showStreak:m},children:[t,s&&c.jsx(jw,{...s,onClose:p,autoCloseDelay:4e3})]})}function LE(){const t=b.useContext(Tw);if(!t)throw new Error("useXP must be used within an XPProvider");return t}const Nw=b.createContext(null),pR=[{value:30,label:"30s"},{value:60,label:"1 min"},{value:120,label:"2 min"},{value:180,label:"3 min"},{value:300,label:"5 min"}];function zE({children:t}){const[s,i]=b.useState(!1),[l,o]=b.useState(!1),[d,f]=b.useState([]),[m,p]=b.useState(0),[y,x]=b.useState(120),[g,w]=b.useState(0),[S,T]=b.useState({callsMade:0,totalDuration:0,conversions:0,startedAt:null}),N=b.useRef(null),R=b.useRef(null),D=b.useCallback(H=>{R.current=H},[]),A=b.useCallback((H,P=0)=>{if(!H||H.length===0)return;f(H),p(P),i(!0),o(!1),T({callsMade:0,totalDuration:0,conversions:0,startedAt:new Date().toISOString()});const K=H[P];K&&R.current&&R.current(`/call-prep/${K.id}`)},[]),C=b.useCallback(()=>{!s||l||(w(y),N.current&&clearInterval(N.current),N.current=setInterval(()=>{w(H=>H<=1?(clearInterval(N.current),N.current=null,0):H-1)},1e3))},[s,l,y]),B=b.useCallback(()=>{o(H=>(H?g>0&&N.current===null&&(N.current=setInterval(()=>{w(P=>P<=1?(clearInterval(N.current),N.current=null,0):P-1)},1e3)):N.current&&(clearInterval(N.current),N.current=null),!H))},[g]),_=b.useCallback(()=>{N.current&&(clearInterval(N.current),N.current=null),w(0)},[]),F=b.useCallback((H,P=0)=>{T(ae=>({...ae,callsMade:ae.callsMade+1,totalDuration:ae.totalDuration+P,conversions:ae.conversions+(H==="converted"?1:0)}));const K=m+1;if(K{R.current(`/call-prep/${ae.id}`)},500)}else $()},[m,d]),$=b.useCallback(()=>{N.current&&(clearInterval(N.current),N.current=null),i(!1),o(!1),w(0)},[]),I=b.useCallback(()=>{$(),f([]),p(0),T({callsMade:0,totalDuration:0,conversions:0,startedAt:null})},[$]),z=d[m]||null,X=d.length-m,te=d.length>0?m/d.length*100:0;return b.useEffect(()=>()=>{N.current&&clearInterval(N.current)},[]),c.jsx(Nw.Provider,{value:{isActive:s,isPaused:l,queue:d,currentIndex:m,currentLead:z,studyTime:y,timeRemaining:g,remainingLeads:X,progress:te,sessionStats:S,setNavigate:D,startSession:A,startStudyTimer:C,togglePause:B,skipTimer:_,recordCallAndAdvance:F,endSession:$,resetSession:I,setStudyTime:x},children:t})}function gR(){const t=b.useContext(Nw);if(!t)throw new Error("usePowerDialer must be used within a PowerDialerProvider");return t}const Cw=b.createContext();function BE({children:t}){const[s,i]=b.useState(()=>{const f=localStorage.getItem("trainingWheelsEnabled");return f===null?!0:f==="true"}),[l]=b.useState(()=>{const f=localStorage.getItem("firstUseDate");if(!f){const m=new Date().toISOString();return localStorage.setItem("firstUseDate",m),m}return f});b.useEffect(()=>{localStorage.setItem("trainingWheelsEnabled",String(s))},[s]);const o=Math.floor((Date.now()-new Date(l).getTime())/(1e3*60*60*24)),d=s&&o>=7;return c.jsx(Cw.Provider,{value:{enabled:s,setEnabled:i,shouldPromptToDisable:d,daysSinceFirstUse:o},children:t})}const Aw=()=>{const t=b.useContext(Cw);return t||{enabled:!0,setEnabled:()=>{},shouldPromptToDisable:!1,daysSinceFirstUse:0}},Ew=b.createContext(null);function Dw(){const t=b.useContext(Ew);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function VE({children:t}){const[s,i]=b.useState(()=>typeof window<"u"&&localStorage.getItem("theme")||"system"),l=s==="dark"||s==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches;b.useEffect(()=>{const f=document.documentElement;l?f.classList.add("dark"):f.classList.remove("dark"),localStorage.setItem("theme",s)},[s,l]),b.useEffect(()=>{if(s!=="system")return;const f=window.matchMedia("(prefers-color-scheme: dark)"),m=()=>{const p=document.documentElement;f.matches?p.classList.add("dark"):p.classList.remove("dark")};return f.addEventListener("change",m),()=>f.removeEventListener("change",m)},[s]);const o=()=>{i(f=>f==="light"?"dark":f==="dark"?"system":"light")},d=f=>{["light","dark","system"].includes(f)&&i(f)};return c.jsx(Ew.Provider,{value:{theme:s,isDark:l,toggleTheme:o,setTheme:d},children:t})}function Vs(t,s,{checkForDefaultPrevented:i=!0}={}){return function(o){if(t?.(o),i===!1||!o.defaultPrevented)return s?.(o)}}function Ux(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function kw(...t){return s=>{let i=!1;const l=t.map(o=>{const d=Ux(o,s);return!i&&typeof d=="function"&&(i=!0),d});if(i)return()=>{for(let o=0;o{const{scope:w,children:S,...T}=g,N=w?.[t]?.[p]||m,R=b.useMemo(()=>T,Object.values(T));return c.jsx(N.Provider,{value:R,children:S})};y.displayName=d+"Provider";function x(g,w){const S=w?.[t]?.[p]||m,T=b.useContext(S);if(T)return T;if(f!==void 0)return f;throw new Error(`\`${g}\` must be used within \`${d}\``)}return[y,x]}const o=()=>{const d=i.map(f=>b.createContext(f));return function(m){const p=m?.[t]||d;return b.useMemo(()=>({[`__scope${t}`]:{...m,[t]:p}}),[m,p])}};return o.scopeName=t,[l,UE(o,...s)]}function UE(...t){const s=t[0];if(t.length===1)return s;const i=()=>{const l=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(d){const f=l.reduce((m,{useScope:p,scopeName:y})=>{const g=p(d)[`__scope${y}`];return{...m,...g}},{});return b.useMemo(()=>({[`__scope${s.scopeName}`]:f}),[f])}};return i.scopeName=s.scopeName,i}function PE(t){const s=HE(t),i=b.forwardRef((l,o)=>{const{children:d,...f}=l,m=b.Children.toArray(d),p=m.find(IE);if(p){const y=p.props.children,x=m.map(g=>g===p?b.Children.count(y)>1?b.Children.only(null):b.isValidElement(y)?y.props.children:null:g);return c.jsx(s,{...f,ref:o,children:b.isValidElement(y)?b.cloneElement(y,void 0,x):null})}return c.jsx(s,{...f,ref:o,children:d})});return i.displayName=`${t}.Slot`,i}function HE(t){const s=b.forwardRef((i,l)=>{const{children:o,...d}=i;if(b.isValidElement(o)){const f=GE(o),m=$E(d,o.props);return o.type!==b.Fragment&&(m.ref=l?kw(l,f):f),b.cloneElement(o,m)}return b.Children.count(o)>1?b.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Mw=Symbol("radix.slottable");function qE(t){const s=({children:i})=>c.jsx(c.Fragment,{children:i});return s.displayName=`${t}.Slottable`,s.__radixId=Mw,s}function IE(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Mw}function $E(t,s){const i={...s};for(const l in s){const o=t[l],d=s[l];/^on[A-Z]/.test(l)?o&&d?i[l]=(...m)=>{const p=d(...m);return o(...m),p}:o&&(i[l]=o):l==="style"?i[l]={...o,...d}:l==="className"&&(i[l]=[o,d].filter(Boolean).join(" "))}return{...t,...i}}function GE(t){let s=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,i=s&&"isReactWarning"in s&&s.isReactWarning;return i?t.ref:(s=Object.getOwnPropertyDescriptor(t,"ref")?.get,i=s&&"isReactWarning"in s&&s.isReactWarning,i?t.props.ref:t.props.ref||t.ref)}var YE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ca=YE.reduce((t,s)=>{const i=PE(`Primitive.${s}`),l=b.forwardRef((o,d)=>{const{asChild:f,...m}=o,p=f?i:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(p,{...m,ref:d})});return l.displayName=`Primitive.${s}`,{...t,[s]:l}},{});function FE(t,s){t&&wc.flushSync(()=>t.dispatchEvent(s))}function Mc(t){const s=b.useRef(t);return b.useEffect(()=>{s.current=t}),b.useMemo(()=>(...i)=>s.current?.(...i),[])}function XE(t,s=globalThis?.document){const i=Mc(t);b.useEffect(()=>{const l=o=>{o.key==="Escape"&&i(o)};return s.addEventListener("keydown",l,{capture:!0}),()=>s.removeEventListener("keydown",l,{capture:!0})},[i,s])}var KE="DismissableLayer",Qf="dismissableLayer.update",QE="dismissableLayer.pointerDownOutside",ZE="dismissableLayer.focusOutside",Px,Ow=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_w=b.forwardRef((t,s)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:l,onPointerDownOutside:o,onFocusOutside:d,onInteractOutside:f,onDismiss:m,...p}=t,y=b.useContext(Ow),[x,g]=b.useState(null),w=x?.ownerDocument??globalThis?.document,[,S]=b.useState({}),T=ii(s,$=>g($)),N=Array.from(y.layers),[R]=[...y.layersWithOutsidePointerEventsDisabled].slice(-1),D=N.indexOf(R),A=x?N.indexOf(x):-1,C=y.layersWithOutsidePointerEventsDisabled.size>0,B=A>=D,_=e5($=>{const I=$.target,z=[...y.branches].some(X=>X.contains(I));!B||z||(o?.($),f?.($),$.defaultPrevented||m?.())},w),F=t5($=>{const I=$.target;[...y.branches].some(X=>X.contains(I))||(d?.($),f?.($),$.defaultPrevented||m?.())},w);return XE($=>{A===y.layers.size-1&&(l?.($),!$.defaultPrevented&&m&&($.preventDefault(),m()))},w),b.useEffect(()=>{if(x)return i&&(y.layersWithOutsidePointerEventsDisabled.size===0&&(Px=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),y.layersWithOutsidePointerEventsDisabled.add(x)),y.layers.add(x),Hx(),()=>{i&&y.layersWithOutsidePointerEventsDisabled.size===1&&(w.body.style.pointerEvents=Px)}},[x,w,i,y]),b.useEffect(()=>()=>{x&&(y.layers.delete(x),y.layersWithOutsidePointerEventsDisabled.delete(x),Hx())},[x,y]),b.useEffect(()=>{const $=()=>S({});return document.addEventListener(Qf,$),()=>document.removeEventListener(Qf,$)},[]),c.jsx(Ca.div,{...p,ref:T,style:{pointerEvents:C?B?"auto":"none":void 0,...t.style},onFocusCapture:Vs(t.onFocusCapture,F.onFocusCapture),onBlurCapture:Vs(t.onBlurCapture,F.onBlurCapture),onPointerDownCapture:Vs(t.onPointerDownCapture,_.onPointerDownCapture)})});_w.displayName=KE;var JE="DismissableLayerBranch",WE=b.forwardRef((t,s)=>{const i=b.useContext(Ow),l=b.useRef(null),o=ii(s,l);return b.useEffect(()=>{const d=l.current;if(d)return i.branches.add(d),()=>{i.branches.delete(d)}},[i.branches]),c.jsx(Ca.div,{...t,ref:o})});WE.displayName=JE;function e5(t,s=globalThis?.document){const i=Mc(t),l=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const d=m=>{if(m.target&&!l.current){let p=function(){Lw(QE,i,y,{discrete:!0})};const y={originalEvent:m};m.pointerType==="touch"?(s.removeEventListener("click",o.current),o.current=p,s.addEventListener("click",o.current,{once:!0})):p()}else s.removeEventListener("click",o.current);l.current=!1},f=window.setTimeout(()=>{s.addEventListener("pointerdown",d)},0);return()=>{window.clearTimeout(f),s.removeEventListener("pointerdown",d),s.removeEventListener("click",o.current)}},[s,i]),{onPointerDownCapture:()=>l.current=!0}}function t5(t,s=globalThis?.document){const i=Mc(t),l=b.useRef(!1);return b.useEffect(()=>{const o=d=>{d.target&&!l.current&&Lw(ZE,i,{originalEvent:d},{discrete:!1})};return s.addEventListener("focusin",o),()=>s.removeEventListener("focusin",o)},[s,i]),{onFocusCapture:()=>l.current=!0,onBlurCapture:()=>l.current=!1}}function Hx(){const t=new CustomEvent(Qf);document.dispatchEvent(t)}function Lw(t,s,i,{discrete:l}){const o=i.originalEvent.target,d=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:i});s&&o.addEventListener(t,s,{once:!0}),l?FE(o,d):o.dispatchEvent(d)}var Sa=globalThis?.document?b.useLayoutEffect:()=>{},n5=jb[" useId ".trim().toString()]||(()=>{}),s5=0;function a5(t){const[s,i]=b.useState(n5());return Sa(()=>{i(l=>l??String(s5++))},[t]),s?`radix-${s}`:""}const i5=["top","right","bottom","left"],ja=Math.min,xn=Math.max,mc=Math.round,Fo=Math.floor,os=t=>({x:t,y:t}),l5={left:"right",right:"left",bottom:"top",top:"bottom"},r5={start:"end",end:"start"};function Zf(t,s,i){return xn(t,ja(s,i))}function Hs(t,s){return typeof t=="function"?t(s):t}function qs(t){return t.split("-")[0]}function ll(t){return t.split("-")[1]}function Jh(t){return t==="x"?"y":"x"}function Wh(t){return t==="y"?"height":"width"}const o5=new Set(["top","bottom"]);function is(t){return o5.has(qs(t))?"y":"x"}function em(t){return Jh(is(t))}function c5(t,s,i){i===void 0&&(i=!1);const l=ll(t),o=em(t),d=Wh(o);let f=o==="x"?l===(i?"end":"start")?"right":"left":l==="start"?"bottom":"top";return s.reference[d]>s.floating[d]&&(f=pc(f)),[f,pc(f)]}function u5(t){const s=pc(t);return[Jf(t),s,Jf(s)]}function Jf(t){return t.replace(/start|end/g,s=>r5[s])}const qx=["left","right"],Ix=["right","left"],d5=["top","bottom"],f5=["bottom","top"];function h5(t,s,i){switch(t){case"top":case"bottom":return i?s?Ix:qx:s?qx:Ix;case"left":case"right":return s?d5:f5;default:return[]}}function m5(t,s,i,l){const o=ll(t);let d=h5(qs(t),i==="start",l);return o&&(d=d.map(f=>f+"-"+o),s&&(d=d.concat(d.map(Jf)))),d}function pc(t){return t.replace(/left|right|bottom|top/g,s=>l5[s])}function p5(t){return{top:0,right:0,bottom:0,left:0,...t}}function zw(t){return typeof t!="number"?p5(t):{top:t,right:t,bottom:t,left:t}}function gc(t){const{x:s,y:i,width:l,height:o}=t;return{width:l,height:o,top:i,left:s,right:s+l,bottom:i+o,x:s,y:i}}function $x(t,s,i){let{reference:l,floating:o}=t;const d=is(s),f=em(s),m=Wh(f),p=qs(s),y=d==="y",x=l.x+l.width/2-o.width/2,g=l.y+l.height/2-o.height/2,w=l[m]/2-o[m]/2;let S;switch(p){case"top":S={x,y:l.y-o.height};break;case"bottom":S={x,y:l.y+l.height};break;case"right":S={x:l.x+l.width,y:g};break;case"left":S={x:l.x-o.width,y:g};break;default:S={x:l.x,y:l.y}}switch(ll(s)){case"start":S[f]-=w*(i&&y?-1:1);break;case"end":S[f]+=w*(i&&y?-1:1);break}return S}const g5=async(t,s,i)=>{const{placement:l="bottom",strategy:o="absolute",middleware:d=[],platform:f}=i,m=d.filter(Boolean),p=await(f.isRTL==null?void 0:f.isRTL(s));let y=await f.getElementRects({reference:t,floating:s,strategy:o}),{x,y:g}=$x(y,l,p),w=l,S={},T=0;for(let N=0;N({name:"arrow",options:t,async fn(s){const{x:i,y:l,placement:o,rects:d,platform:f,elements:m,middlewareData:p}=s,{element:y,padding:x=0}=Hs(t,s)||{};if(y==null)return{};const g=zw(x),w={x:i,y:l},S=em(o),T=Wh(S),N=await f.getDimensions(y),R=S==="y",D=R?"top":"left",A=R?"bottom":"right",C=R?"clientHeight":"clientWidth",B=d.reference[T]+d.reference[S]-w[S]-d.floating[T],_=w[S]-d.reference[S],F=await(f.getOffsetParent==null?void 0:f.getOffsetParent(y));let $=F?F[C]:0;(!$||!await(f.isElement==null?void 0:f.isElement(F)))&&($=m.floating[C]||d.floating[T]);const I=B/2-_/2,z=$/2-N[T]/2-1,X=ja(g[D],z),te=ja(g[A],z),H=X,P=$-N[T]-te,K=$/2-N[T]/2+I,ae=Zf(H,K,P),O=!p.arrow&&ll(o)!=null&&K!==ae&&d.reference[T]/2-(KK<=0)){var te,H;const K=(((te=d.flip)==null?void 0:te.index)||0)+1,ae=$[K];if(ae&&(!(g==="alignment"?A!==is(ae):!1)||X.every(Z=>is(Z.placement)===A?Z.overflows[0]>0:!0)))return{data:{index:K,overflows:X},reset:{placement:ae}};let O=(H=X.filter(G=>G.overflows[0]<=0).sort((G,Z)=>G.overflows[1]-Z.overflows[1])[0])==null?void 0:H.placement;if(!O)switch(S){case"bestFit":{var P;const G=(P=X.filter(Z=>{if(F){const re=is(Z.placement);return re===A||re==="y"}return!0}).map(Z=>[Z.placement,Z.overflows.filter(re=>re>0).reduce((re,ue)=>re+ue,0)]).sort((Z,re)=>Z[1]-re[1])[0])==null?void 0:P[0];G&&(O=G);break}case"initialPlacement":O=m;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function Gx(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function Yx(t){return i5.some(s=>t[s]>=0)}const b5=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:i}=s,{strategy:l="referenceHidden",...o}=Hs(t,s);switch(l){case"referenceHidden":{const d=await gr(s,{...o,elementContext:"reference"}),f=Gx(d,i.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:Yx(f)}}}case"escaped":{const d=await gr(s,{...o,altBoundary:!0}),f=Gx(d,i.floating);return{data:{escapedOffsets:f,escaped:Yx(f)}}}default:return{}}}}},Bw=new Set(["left","top"]);async function v5(t,s){const{placement:i,platform:l,elements:o}=t,d=await(l.isRTL==null?void 0:l.isRTL(o.floating)),f=qs(i),m=ll(i),p=is(i)==="y",y=Bw.has(f)?-1:1,x=d&&p?-1:1,g=Hs(s,t);let{mainAxis:w,crossAxis:S,alignmentAxis:T}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return m&&typeof T=="number"&&(S=m==="end"?T*-1:T),p?{x:S*x,y:w*y}:{x:w*y,y:S*x}}const w5=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var i,l;const{x:o,y:d,placement:f,middlewareData:m}=s,p=await v5(s,t);return f===((i=m.offset)==null?void 0:i.placement)&&(l=m.arrow)!=null&&l.alignmentOffset?{}:{x:o+p.x,y:d+p.y,data:{...p,placement:f}}}}},S5=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:i,y:l,placement:o}=s,{mainAxis:d=!0,crossAxis:f=!1,limiter:m={fn:R=>{let{x:D,y:A}=R;return{x:D,y:A}}},...p}=Hs(t,s),y={x:i,y:l},x=await gr(s,p),g=is(qs(o)),w=Jh(g);let S=y[w],T=y[g];if(d){const R=w==="y"?"top":"left",D=w==="y"?"bottom":"right",A=S+x[R],C=S-x[D];S=Zf(A,S,C)}if(f){const R=g==="y"?"top":"left",D=g==="y"?"bottom":"right",A=T+x[R],C=T-x[D];T=Zf(A,T,C)}const N=m.fn({...s,[w]:S,[g]:T});return{...N,data:{x:N.x-i,y:N.y-l,enabled:{[w]:d,[g]:f}}}}}},j5=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:i,y:l,placement:o,rects:d,middlewareData:f}=s,{offset:m=0,mainAxis:p=!0,crossAxis:y=!0}=Hs(t,s),x={x:i,y:l},g=is(o),w=Jh(g);let S=x[w],T=x[g];const N=Hs(m,s),R=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:0,crossAxis:0,...N};if(p){const C=w==="y"?"height":"width",B=d.reference[w]-d.floating[C]+R.mainAxis,_=d.reference[w]+d.reference[C]-R.mainAxis;S_&&(S=_)}if(y){var D,A;const C=w==="y"?"width":"height",B=Bw.has(qs(o)),_=d.reference[g]-d.floating[C]+(B&&((D=f.offset)==null?void 0:D[g])||0)+(B?0:R.crossAxis),F=d.reference[g]+d.reference[C]+(B?0:((A=f.offset)==null?void 0:A[g])||0)-(B?R.crossAxis:0);T<_?T=_:T>F&&(T=F)}return{[w]:S,[g]:T}}}},T5=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var i,l;const{placement:o,rects:d,platform:f,elements:m}=s,{apply:p=()=>{},...y}=Hs(t,s),x=await gr(s,y),g=qs(o),w=ll(o),S=is(o)==="y",{width:T,height:N}=d.floating;let R,D;g==="top"||g==="bottom"?(R=g,D=w===(await(f.isRTL==null?void 0:f.isRTL(m.floating))?"start":"end")?"left":"right"):(D=g,R=w==="end"?"top":"bottom");const A=N-x.top-x.bottom,C=T-x.left-x.right,B=ja(N-x[R],A),_=ja(T-x[D],C),F=!s.middlewareData.shift;let $=B,I=_;if((i=s.middlewareData.shift)!=null&&i.enabled.x&&(I=C),(l=s.middlewareData.shift)!=null&&l.enabled.y&&($=A),F&&!w){const X=xn(x.left,0),te=xn(x.right,0),H=xn(x.top,0),P=xn(x.bottom,0);S?I=T-2*(X!==0||te!==0?X+te:xn(x.left,x.right)):$=N-2*(H!==0||P!==0?H+P:xn(x.top,x.bottom))}await p({...s,availableWidth:I,availableHeight:$});const z=await f.getDimensions(m.floating);return T!==z.width||N!==z.height?{reset:{rects:!0}}:{}}}};function Oc(){return typeof window<"u"}function rl(t){return Vw(t)?(t.nodeName||"").toLowerCase():"#document"}function vn(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function hs(t){var s;return(s=(Vw(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function Vw(t){return Oc()?t instanceof Node||t instanceof vn(t).Node:!1}function $n(t){return Oc()?t instanceof Element||t instanceof vn(t).Element:!1}function us(t){return Oc()?t instanceof HTMLElement||t instanceof vn(t).HTMLElement:!1}function Fx(t){return!Oc()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof vn(t).ShadowRoot}const N5=new Set(["inline","contents"]);function Nr(t){const{overflow:s,overflowX:i,overflowY:l,display:o}=Gn(t);return/auto|scroll|overlay|hidden|clip/.test(s+l+i)&&!N5.has(o)}const C5=new Set(["table","td","th"]);function A5(t){return C5.has(rl(t))}const E5=[":popover-open",":modal"];function _c(t){return E5.some(s=>{try{return t.matches(s)}catch{return!1}})}const D5=["transform","translate","scale","rotate","perspective"],k5=["transform","translate","scale","rotate","perspective","filter"],R5=["paint","layout","strict","content"];function tm(t){const s=nm(),i=$n(t)?Gn(t):t;return D5.some(l=>i[l]?i[l]!=="none":!1)||(i.containerType?i.containerType!=="normal":!1)||!s&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!s&&(i.filter?i.filter!=="none":!1)||k5.some(l=>(i.willChange||"").includes(l))||R5.some(l=>(i.contain||"").includes(l))}function M5(t){let s=Ta(t);for(;us(s)&&!el(s);){if(tm(s))return s;if(_c(s))return null;s=Ta(s)}return null}function nm(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const O5=new Set(["html","body","#document"]);function el(t){return O5.has(rl(t))}function Gn(t){return vn(t).getComputedStyle(t)}function Lc(t){return $n(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Ta(t){if(rl(t)==="html")return t;const s=t.assignedSlot||t.parentNode||Fx(t)&&t.host||hs(t);return Fx(s)?s.host:s}function Uw(t){const s=Ta(t);return el(s)?t.ownerDocument?t.ownerDocument.body:t.body:us(s)&&Nr(s)?s:Uw(s)}function yr(t,s,i){var l;s===void 0&&(s=[]),i===void 0&&(i=!0);const o=Uw(t),d=o===((l=t.ownerDocument)==null?void 0:l.body),f=vn(o);if(d){const m=Wf(f);return s.concat(f,f.visualViewport||[],Nr(o)?o:[],m&&i?yr(m):[])}return s.concat(o,yr(o,[],i))}function Wf(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Pw(t){const s=Gn(t);let i=parseFloat(s.width)||0,l=parseFloat(s.height)||0;const o=us(t),d=o?t.offsetWidth:i,f=o?t.offsetHeight:l,m=mc(i)!==d||mc(l)!==f;return m&&(i=d,l=f),{width:i,height:l,$:m}}function sm(t){return $n(t)?t:t.contextElement}function Zi(t){const s=sm(t);if(!us(s))return os(1);const i=s.getBoundingClientRect(),{width:l,height:o,$:d}=Pw(s);let f=(d?mc(i.width):i.width)/l,m=(d?mc(i.height):i.height)/o;return(!f||!Number.isFinite(f))&&(f=1),(!m||!Number.isFinite(m))&&(m=1),{x:f,y:m}}const _5=os(0);function Hw(t){const s=vn(t);return!nm()||!s.visualViewport?_5:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function L5(t,s,i){return s===void 0&&(s=!1),!i||s&&i!==vn(t)?!1:s}function ai(t,s,i,l){s===void 0&&(s=!1),i===void 0&&(i=!1);const o=t.getBoundingClientRect(),d=sm(t);let f=os(1);s&&(l?$n(l)&&(f=Zi(l)):f=Zi(t));const m=L5(d,i,l)?Hw(d):os(0);let p=(o.left+m.x)/f.x,y=(o.top+m.y)/f.y,x=o.width/f.x,g=o.height/f.y;if(d){const w=vn(d),S=l&&$n(l)?vn(l):l;let T=w,N=Wf(T);for(;N&&l&&S!==T;){const R=Zi(N),D=N.getBoundingClientRect(),A=Gn(N),C=D.left+(N.clientLeft+parseFloat(A.paddingLeft))*R.x,B=D.top+(N.clientTop+parseFloat(A.paddingTop))*R.y;p*=R.x,y*=R.y,x*=R.x,g*=R.y,p+=C,y+=B,T=vn(N),N=Wf(T)}}return gc({width:x,height:g,x:p,y})}function zc(t,s){const i=Lc(t).scrollLeft;return s?s.left+i:ai(hs(t)).left+i}function qw(t,s){const i=t.getBoundingClientRect(),l=i.left+s.scrollLeft-zc(t,i),o=i.top+s.scrollTop;return{x:l,y:o}}function z5(t){let{elements:s,rect:i,offsetParent:l,strategy:o}=t;const d=o==="fixed",f=hs(l),m=s?_c(s.floating):!1;if(l===f||m&&d)return i;let p={scrollLeft:0,scrollTop:0},y=os(1);const x=os(0),g=us(l);if((g||!g&&!d)&&((rl(l)!=="body"||Nr(f))&&(p=Lc(l)),us(l))){const S=ai(l);y=Zi(l),x.x=S.x+l.clientLeft,x.y=S.y+l.clientTop}const w=f&&!g&&!d?qw(f,p):os(0);return{width:i.width*y.x,height:i.height*y.y,x:i.x*y.x-p.scrollLeft*y.x+x.x+w.x,y:i.y*y.y-p.scrollTop*y.y+x.y+w.y}}function B5(t){return Array.from(t.getClientRects())}function V5(t){const s=hs(t),i=Lc(t),l=t.ownerDocument.body,o=xn(s.scrollWidth,s.clientWidth,l.scrollWidth,l.clientWidth),d=xn(s.scrollHeight,s.clientHeight,l.scrollHeight,l.clientHeight);let f=-i.scrollLeft+zc(t);const m=-i.scrollTop;return Gn(l).direction==="rtl"&&(f+=xn(s.clientWidth,l.clientWidth)-o),{width:o,height:d,x:f,y:m}}const Xx=25;function U5(t,s){const i=vn(t),l=hs(t),o=i.visualViewport;let d=l.clientWidth,f=l.clientHeight,m=0,p=0;if(o){d=o.width,f=o.height;const x=nm();(!x||x&&s==="fixed")&&(m=o.offsetLeft,p=o.offsetTop)}const y=zc(l);if(y<=0){const x=l.ownerDocument,g=x.body,w=getComputedStyle(g),S=x.compatMode==="CSS1Compat"&&parseFloat(w.marginLeft)+parseFloat(w.marginRight)||0,T=Math.abs(l.clientWidth-g.clientWidth-S);T<=Xx&&(d-=T)}else y<=Xx&&(d+=y);return{width:d,height:f,x:m,y:p}}const P5=new Set(["absolute","fixed"]);function H5(t,s){const i=ai(t,!0,s==="fixed"),l=i.top+t.clientTop,o=i.left+t.clientLeft,d=us(t)?Zi(t):os(1),f=t.clientWidth*d.x,m=t.clientHeight*d.y,p=o*d.x,y=l*d.y;return{width:f,height:m,x:p,y}}function Kx(t,s,i){let l;if(s==="viewport")l=U5(t,i);else if(s==="document")l=V5(hs(t));else if($n(s))l=H5(s,i);else{const o=Hw(t);l={x:s.x-o.x,y:s.y-o.y,width:s.width,height:s.height}}return gc(l)}function Iw(t,s){const i=Ta(t);return i===s||!$n(i)||el(i)?!1:Gn(i).position==="fixed"||Iw(i,s)}function q5(t,s){const i=s.get(t);if(i)return i;let l=yr(t,[],!1).filter(m=>$n(m)&&rl(m)!=="body"),o=null;const d=Gn(t).position==="fixed";let f=d?Ta(t):t;for(;$n(f)&&!el(f);){const m=Gn(f),p=tm(f);!p&&m.position==="fixed"&&(o=null),(d?!p&&!o:!p&&m.position==="static"&&!!o&&P5.has(o.position)||Nr(f)&&!p&&Iw(t,f))?l=l.filter(x=>x!==f):o=m,f=Ta(f)}return s.set(t,l),l}function I5(t){let{element:s,boundary:i,rootBoundary:l,strategy:o}=t;const f=[...i==="clippingAncestors"?_c(s)?[]:q5(s,this._c):[].concat(i),l],m=f[0],p=f.reduce((y,x)=>{const g=Kx(s,x,o);return y.top=xn(g.top,y.top),y.right=ja(g.right,y.right),y.bottom=ja(g.bottom,y.bottom),y.left=xn(g.left,y.left),y},Kx(s,m,o));return{width:p.right-p.left,height:p.bottom-p.top,x:p.left,y:p.top}}function $5(t){const{width:s,height:i}=Pw(t);return{width:s,height:i}}function G5(t,s,i){const l=us(s),o=hs(s),d=i==="fixed",f=ai(t,!0,d,s);let m={scrollLeft:0,scrollTop:0};const p=os(0);function y(){p.x=zc(o)}if(l||!l&&!d)if((rl(s)!=="body"||Nr(o))&&(m=Lc(s)),l){const S=ai(s,!0,d,s);p.x=S.x+s.clientLeft,p.y=S.y+s.clientTop}else o&&y();d&&!l&&o&&y();const x=o&&!l&&!d?qw(o,m):os(0),g=f.left+m.scrollLeft-p.x-x.x,w=f.top+m.scrollTop-p.y-x.y;return{x:g,y:w,width:f.width,height:f.height}}function yf(t){return Gn(t).position==="static"}function Qx(t,s){if(!us(t)||Gn(t).position==="fixed")return null;if(s)return s(t);let i=t.offsetParent;return hs(t)===i&&(i=i.ownerDocument.body),i}function $w(t,s){const i=vn(t);if(_c(t))return i;if(!us(t)){let o=Ta(t);for(;o&&!el(o);){if($n(o)&&!yf(o))return o;o=Ta(o)}return i}let l=Qx(t,s);for(;l&&A5(l)&&yf(l);)l=Qx(l,s);return l&&el(l)&&yf(l)&&!tm(l)?i:l||M5(t)||i}const Y5=async function(t){const s=this.getOffsetParent||$w,i=this.getDimensions,l=await i(t.floating);return{reference:G5(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:l.width,height:l.height}}};function F5(t){return Gn(t).direction==="rtl"}const X5={convertOffsetParentRelativeRectToViewportRelativeRect:z5,getDocumentElement:hs,getClippingRect:I5,getOffsetParent:$w,getElementRects:Y5,getClientRects:B5,getDimensions:$5,getScale:Zi,isElement:$n,isRTL:F5};function Gw(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function K5(t,s){let i=null,l;const o=hs(t);function d(){var m;clearTimeout(l),(m=i)==null||m.disconnect(),i=null}function f(m,p){m===void 0&&(m=!1),p===void 0&&(p=1),d();const y=t.getBoundingClientRect(),{left:x,top:g,width:w,height:S}=y;if(m||s(),!w||!S)return;const T=Fo(g),N=Fo(o.clientWidth-(x+w)),R=Fo(o.clientHeight-(g+S)),D=Fo(x),C={rootMargin:-T+"px "+-N+"px "+-R+"px "+-D+"px",threshold:xn(0,ja(1,p))||1};let B=!0;function _(F){const $=F[0].intersectionRatio;if($!==p){if(!B)return f();$?f(!1,$):l=setTimeout(()=>{f(!1,1e-7)},1e3)}$===1&&!Gw(y,t.getBoundingClientRect())&&f(),B=!1}try{i=new IntersectionObserver(_,{...C,root:o.ownerDocument})}catch{i=new IntersectionObserver(_,C)}i.observe(t)}return f(!0),d}function Q5(t,s,i,l){l===void 0&&(l={});const{ancestorScroll:o=!0,ancestorResize:d=!0,elementResize:f=typeof ResizeObserver=="function",layoutShift:m=typeof IntersectionObserver=="function",animationFrame:p=!1}=l,y=sm(t),x=o||d?[...y?yr(y):[],...yr(s)]:[];x.forEach(D=>{o&&D.addEventListener("scroll",i,{passive:!0}),d&&D.addEventListener("resize",i)});const g=y&&m?K5(y,i):null;let w=-1,S=null;f&&(S=new ResizeObserver(D=>{let[A]=D;A&&A.target===y&&S&&(S.unobserve(s),cancelAnimationFrame(w),w=requestAnimationFrame(()=>{var C;(C=S)==null||C.observe(s)})),i()}),y&&!p&&S.observe(y),S.observe(s));let T,N=p?ai(t):null;p&&R();function R(){const D=ai(t);N&&!Gw(N,D)&&i(),N=D,T=requestAnimationFrame(R)}return i(),()=>{var D;x.forEach(A=>{o&&A.removeEventListener("scroll",i),d&&A.removeEventListener("resize",i)}),g?.(),(D=S)==null||D.disconnect(),S=null,p&&cancelAnimationFrame(T)}}const Z5=w5,J5=S5,W5=x5,e4=T5,t4=b5,Zx=y5,n4=j5,s4=(t,s,i)=>{const l=new Map,o={platform:X5,...i},d={...o.platform,_c:l};return g5(t,s,{...o,platform:d})};var a4=typeof document<"u",i4=function(){},sc=a4?b.useLayoutEffect:i4;function yc(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let i,l,o;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(i=t.length,i!==s.length)return!1;for(l=i;l--!==0;)if(!yc(t[l],s[l]))return!1;return!0}if(o=Object.keys(t),i=o.length,i!==Object.keys(s).length)return!1;for(l=i;l--!==0;)if(!{}.hasOwnProperty.call(s,o[l]))return!1;for(l=i;l--!==0;){const d=o[l];if(!(d==="_owner"&&t.$$typeof)&&!yc(t[d],s[d]))return!1}return!0}return t!==t&&s!==s}function Yw(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Jx(t,s){const i=Yw(t);return Math.round(s*i)/i}function xf(t){const s=b.useRef(t);return sc(()=>{s.current=t}),s}function l4(t){t===void 0&&(t={});const{placement:s="bottom",strategy:i="absolute",middleware:l=[],platform:o,elements:{reference:d,floating:f}={},transform:m=!0,whileElementsMounted:p,open:y}=t,[x,g]=b.useState({x:0,y:0,strategy:i,placement:s,middlewareData:{},isPositioned:!1}),[w,S]=b.useState(l);yc(w,l)||S(l);const[T,N]=b.useState(null),[R,D]=b.useState(null),A=b.useCallback(Z=>{Z!==F.current&&(F.current=Z,N(Z))},[]),C=b.useCallback(Z=>{Z!==$.current&&($.current=Z,D(Z))},[]),B=d||T,_=f||R,F=b.useRef(null),$=b.useRef(null),I=b.useRef(x),z=p!=null,X=xf(p),te=xf(o),H=xf(y),P=b.useCallback(()=>{if(!F.current||!$.current)return;const Z={placement:s,strategy:i,middleware:w};te.current&&(Z.platform=te.current),s4(F.current,$.current,Z).then(re=>{const ue={...re,isPositioned:H.current!==!1};K.current&&!yc(I.current,ue)&&(I.current=ue,wc.flushSync(()=>{g(ue)}))})},[w,s,i,te,H]);sc(()=>{y===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,g(Z=>({...Z,isPositioned:!1})))},[y]);const K=b.useRef(!1);sc(()=>(K.current=!0,()=>{K.current=!1}),[]),sc(()=>{if(B&&(F.current=B),_&&($.current=_),B&&_){if(X.current)return X.current(B,_,P);P()}},[B,_,P,X,z]);const ae=b.useMemo(()=>({reference:F,floating:$,setReference:A,setFloating:C}),[A,C]),O=b.useMemo(()=>({reference:B,floating:_}),[B,_]),G=b.useMemo(()=>{const Z={position:i,left:0,top:0};if(!O.floating)return Z;const re=Jx(O.floating,x.x),ue=Jx(O.floating,x.y);return m?{...Z,transform:"translate("+re+"px, "+ue+"px)",...Yw(O.floating)>=1.5&&{willChange:"transform"}}:{position:i,left:re,top:ue}},[i,m,O.floating,x.x,x.y]);return b.useMemo(()=>({...x,update:P,refs:ae,elements:O,floatingStyles:G}),[x,P,ae,O,G])}const r4=t=>{function s(i){return{}.hasOwnProperty.call(i,"current")}return{name:"arrow",options:t,fn(i){const{element:l,padding:o}=typeof t=="function"?t(i):t;return l&&s(l)?l.current!=null?Zx({element:l.current,padding:o}).fn(i):{}:l?Zx({element:l,padding:o}).fn(i):{}}}},o4=(t,s)=>({...Z5(t),options:[t,s]}),c4=(t,s)=>({...J5(t),options:[t,s]}),u4=(t,s)=>({...n4(t),options:[t,s]}),d4=(t,s)=>({...W5(t),options:[t,s]}),f4=(t,s)=>({...e4(t),options:[t,s]}),h4=(t,s)=>({...t4(t),options:[t,s]}),m4=(t,s)=>({...r4(t),options:[t,s]});var p4="Arrow",Fw=b.forwardRef((t,s)=>{const{children:i,width:l=10,height:o=5,...d}=t;return c.jsx(Ca.svg,{...d,ref:s,width:l,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?i:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Fw.displayName=p4;var g4=Fw;function y4(t){const[s,i]=b.useState(void 0);return Sa(()=>{if(t){i({width:t.offsetWidth,height:t.offsetHeight});const l=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const d=o[0];let f,m;if("borderBoxSize"in d){const p=d.borderBoxSize,y=Array.isArray(p)?p[0]:p;f=y.inlineSize,m=y.blockSize}else f=t.offsetWidth,m=t.offsetHeight;i({width:f,height:m})});return l.observe(t,{box:"border-box"}),()=>l.unobserve(t)}else i(void 0)},[t]),s}var am="Popper",[Xw,Kw]=Rw(am),[x4,Qw]=Xw(am),Zw=t=>{const{__scopePopper:s,children:i}=t,[l,o]=b.useState(null);return c.jsx(x4,{scope:s,anchor:l,onAnchorChange:o,children:i})};Zw.displayName=am;var Jw="PopperAnchor",Ww=b.forwardRef((t,s)=>{const{__scopePopper:i,virtualRef:l,...o}=t,d=Qw(Jw,i),f=b.useRef(null),m=ii(s,f),p=b.useRef(null);return b.useEffect(()=>{const y=p.current;p.current=l?.current||f.current,y!==p.current&&d.onAnchorChange(p.current)}),l?null:c.jsx(Ca.div,{...o,ref:m})});Ww.displayName=Jw;var im="PopperContent",[b4,v4]=Xw(im),eS=b.forwardRef((t,s)=>{const{__scopePopper:i,side:l="bottom",sideOffset:o=0,align:d="center",alignOffset:f=0,arrowPadding:m=0,avoidCollisions:p=!0,collisionBoundary:y=[],collisionPadding:x=0,sticky:g="partial",hideWhenDetached:w=!1,updatePositionStrategy:S="optimized",onPlaced:T,...N}=t,R=Qw(im,i),[D,A]=b.useState(null),C=ii(s,oe=>A(oe)),[B,_]=b.useState(null),F=y4(B),$=F?.width??0,I=F?.height??0,z=l+(d!=="center"?"-"+d:""),X=typeof x=="number"?x:{top:0,right:0,bottom:0,left:0,...x},te=Array.isArray(y)?y:[y],H=te.length>0,P={padding:X,boundary:te.filter(S4),altBoundary:H},{refs:K,floatingStyles:ae,placement:O,isPositioned:G,middlewareData:Z}=l4({strategy:"fixed",placement:z,whileElementsMounted:(...oe)=>Q5(...oe,{animationFrame:S==="always"}),elements:{reference:R.anchor},middleware:[o4({mainAxis:o+I,alignmentAxis:f}),p&&c4({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?u4():void 0,...P}),p&&d4({...P}),f4({...P,apply:({elements:oe,rects:ee,availableWidth:ge,availableHeight:Ee})=>{const{width:wt,height:me}=ee.reference,ze=oe.floating.style;ze.setProperty("--radix-popper-available-width",`${ge}px`),ze.setProperty("--radix-popper-available-height",`${Ee}px`),ze.setProperty("--radix-popper-anchor-width",`${wt}px`),ze.setProperty("--radix-popper-anchor-height",`${me}px`)}}),B&&m4({element:B,padding:m}),j4({arrowWidth:$,arrowHeight:I}),w&&h4({strategy:"referenceHidden",...P})]}),[re,ue]=sS(O),je=Mc(T);Sa(()=>{G&&je?.()},[G,je]);const Ne=Z.arrow?.x,se=Z.arrow?.y,ce=Z.arrow?.centerOffset!==0,[ne,de]=b.useState();return Sa(()=>{D&&de(window.getComputedStyle(D).zIndex)},[D]),c.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{...ae,transform:G?ae.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ne,"--radix-popper-transform-origin":[Z.transformOrigin?.x,Z.transformOrigin?.y].join(" "),...Z.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:c.jsx(b4,{scope:i,placedSide:re,onArrowChange:_,arrowX:Ne,arrowY:se,shouldHideArrow:ce,children:c.jsx(Ca.div,{"data-side":re,"data-align":ue,...N,ref:C,style:{...N.style,animation:G?void 0:"none"}})})})});eS.displayName=im;var tS="PopperArrow",w4={top:"bottom",right:"left",bottom:"top",left:"right"},nS=b.forwardRef(function(s,i){const{__scopePopper:l,...o}=s,d=v4(tS,l),f=w4[d.placedSide];return c.jsx("span",{ref:d.onArrowChange,style:{position:"absolute",left:d.arrowX,top:d.arrowY,[f]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[d.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[d.placedSide],visibility:d.shouldHideArrow?"hidden":void 0},children:c.jsx(g4,{...o,ref:i,style:{...o.style,display:"block"}})})});nS.displayName=tS;function S4(t){return t!==null}var j4=t=>({name:"transformOrigin",options:t,fn(s){const{placement:i,rects:l,middlewareData:o}=s,f=o.arrow?.centerOffset!==0,m=f?0:t.arrowWidth,p=f?0:t.arrowHeight,[y,x]=sS(i),g={start:"0%",center:"50%",end:"100%"}[x],w=(o.arrow?.x??0)+m/2,S=(o.arrow?.y??0)+p/2;let T="",N="";return y==="bottom"?(T=f?g:`${w}px`,N=`${-p}px`):y==="top"?(T=f?g:`${w}px`,N=`${l.floating.height+p}px`):y==="right"?(T=`${-p}px`,N=f?g:`${S}px`):y==="left"&&(T=`${l.floating.width+p}px`,N=f?g:`${S}px`),{data:{x:T,y:N}}}});function sS(t){const[s,i="center"]=t.split("-");return[s,i]}var T4=Zw,N4=Ww,C4=eS,A4=nS,E4="Portal",aS=b.forwardRef((t,s)=>{const{container:i,...l}=t,[o,d]=b.useState(!1);Sa(()=>d(!0),[]);const f=i||o&&globalThis?.document?.body;return f?Tb.createPortal(c.jsx(Ca.div,{...l,ref:s}),f):null});aS.displayName=E4;function D4(t,s){return b.useReducer((i,l)=>s[i][l]??i,t)}var lm=t=>{const{present:s,children:i}=t,l=k4(s),o=typeof i=="function"?i({present:l.isPresent}):b.Children.only(i),d=ii(l.ref,R4(o));return typeof i=="function"||l.isPresent?b.cloneElement(o,{ref:d}):null};lm.displayName="Presence";function k4(t){const[s,i]=b.useState(),l=b.useRef(null),o=b.useRef(t),d=b.useRef("none"),f=t?"mounted":"unmounted",[m,p]=D4(f,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const y=Xo(l.current);d.current=m==="mounted"?y:"none"},[m]),Sa(()=>{const y=l.current,x=o.current;if(x!==t){const w=d.current,S=Xo(y);t?p("MOUNT"):S==="none"||y?.display==="none"?p("UNMOUNT"):p(x&&w!==S?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,p]),Sa(()=>{if(s){let y;const x=s.ownerDocument.defaultView??window,g=S=>{const N=Xo(l.current).includes(CSS.escape(S.animationName));if(S.target===s&&N&&(p("ANIMATION_END"),!o.current)){const R=s.style.animationFillMode;s.style.animationFillMode="forwards",y=x.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=R)})}},w=S=>{S.target===s&&(d.current=Xo(l.current))};return s.addEventListener("animationstart",w),s.addEventListener("animationcancel",g),s.addEventListener("animationend",g),()=>{x.clearTimeout(y),s.removeEventListener("animationstart",w),s.removeEventListener("animationcancel",g),s.removeEventListener("animationend",g)}}else p("ANIMATION_END")},[s,p]),{isPresent:["mounted","unmountSuspended"].includes(m),ref:b.useCallback(y=>{l.current=y?getComputedStyle(y):null,i(y)},[])}}function Xo(t){return t?.animationName||"none"}function R4(t){let s=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,i=s&&"isReactWarning"in s&&s.isReactWarning;return i?t.ref:(s=Object.getOwnPropertyDescriptor(t,"ref")?.get,i=s&&"isReactWarning"in s&&s.isReactWarning,i?t.props.ref:t.props.ref||t.ref)}var M4=jb[" useInsertionEffect ".trim().toString()]||Sa;function O4({prop:t,defaultProp:s,onChange:i=()=>{},caller:l}){const[o,d,f]=_4({defaultProp:s,onChange:i}),m=t!==void 0,p=m?t:o;{const x=b.useRef(t!==void 0);b.useEffect(()=>{const g=x.current;g!==m&&console.warn(`${l} is changing from ${g?"controlled":"uncontrolled"} to ${m?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),x.current=m},[m,l])}const y=b.useCallback(x=>{if(m){const g=L4(x)?x(t):x;g!==t&&f.current?.(g)}else d(x)},[m,t,d,f]);return[p,y]}function _4({defaultProp:t,onChange:s}){const[i,l]=b.useState(t),o=b.useRef(i),d=b.useRef(s);return M4(()=>{d.current=s},[s]),b.useEffect(()=>{o.current!==i&&(d.current?.(i),o.current=i)},[i,o]),[i,l,d]}function L4(t){return typeof t=="function"}var z4=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),B4="VisuallyHidden",iS=b.forwardRef((t,s)=>c.jsx(Ca.span,{...t,ref:s,style:{...z4,...t.style}}));iS.displayName=B4;var V4=iS,[Bc]=Rw("Tooltip",[Kw]),Vc=Kw(),lS="TooltipProvider",U4=700,eh="tooltip.open",[P4,rm]=Bc(lS),rS=t=>{const{__scopeTooltip:s,delayDuration:i=U4,skipDelayDuration:l=300,disableHoverableContent:o=!1,children:d}=t,f=b.useRef(!0),m=b.useRef(!1),p=b.useRef(0);return b.useEffect(()=>{const y=p.current;return()=>window.clearTimeout(y)},[]),c.jsx(P4,{scope:s,isOpenDelayedRef:f,delayDuration:i,onOpen:b.useCallback(()=>{window.clearTimeout(p.current),f.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>f.current=!0,l)},[l]),isPointerInTransitRef:m,onPointerInTransitChange:b.useCallback(y=>{m.current=y},[]),disableHoverableContent:o,children:d})};rS.displayName=lS;var xr="Tooltip",[H4,Cr]=Bc(xr),oS=t=>{const{__scopeTooltip:s,children:i,open:l,defaultOpen:o,onOpenChange:d,disableHoverableContent:f,delayDuration:m}=t,p=rm(xr,t.__scopeTooltip),y=Vc(s),[x,g]=b.useState(null),w=a5(),S=b.useRef(0),T=f??p.disableHoverableContent,N=m??p.delayDuration,R=b.useRef(!1),[D,A]=O4({prop:l,defaultProp:o??!1,onChange:$=>{$?(p.onOpen(),document.dispatchEvent(new CustomEvent(eh))):p.onClose(),d?.($)},caller:xr}),C=b.useMemo(()=>D?R.current?"delayed-open":"instant-open":"closed",[D]),B=b.useCallback(()=>{window.clearTimeout(S.current),S.current=0,R.current=!1,A(!0)},[A]),_=b.useCallback(()=>{window.clearTimeout(S.current),S.current=0,A(!1)},[A]),F=b.useCallback(()=>{window.clearTimeout(S.current),S.current=window.setTimeout(()=>{R.current=!0,A(!0),S.current=0},N)},[N,A]);return b.useEffect(()=>()=>{S.current&&(window.clearTimeout(S.current),S.current=0)},[]),c.jsx(T4,{...y,children:c.jsx(H4,{scope:s,contentId:w,open:D,stateAttribute:C,trigger:x,onTriggerChange:g,onTriggerEnter:b.useCallback(()=>{p.isOpenDelayedRef.current?F():B()},[p.isOpenDelayedRef,F,B]),onTriggerLeave:b.useCallback(()=>{T?_():(window.clearTimeout(S.current),S.current=0)},[_,T]),onOpen:B,onClose:_,disableHoverableContent:T,children:i})})};oS.displayName=xr;var th="TooltipTrigger",cS=b.forwardRef((t,s)=>{const{__scopeTooltip:i,...l}=t,o=Cr(th,i),d=rm(th,i),f=Vc(i),m=b.useRef(null),p=ii(s,m,o.onTriggerChange),y=b.useRef(!1),x=b.useRef(!1),g=b.useCallback(()=>y.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),c.jsx(N4,{asChild:!0,...f,children:c.jsx(Ca.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...l,ref:p,onPointerMove:Vs(t.onPointerMove,w=>{w.pointerType!=="touch"&&!x.current&&!d.isPointerInTransitRef.current&&(o.onTriggerEnter(),x.current=!0)}),onPointerLeave:Vs(t.onPointerLeave,()=>{o.onTriggerLeave(),x.current=!1}),onPointerDown:Vs(t.onPointerDown,()=>{o.open&&o.onClose(),y.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Vs(t.onFocus,()=>{y.current||o.onOpen()}),onBlur:Vs(t.onBlur,o.onClose),onClick:Vs(t.onClick,o.onClose)})})});cS.displayName=th;var om="TooltipPortal",[q4,I4]=Bc(om,{forceMount:void 0}),uS=t=>{const{__scopeTooltip:s,forceMount:i,children:l,container:o}=t,d=Cr(om,s);return c.jsx(q4,{scope:s,forceMount:i,children:c.jsx(lm,{present:i||d.open,children:c.jsx(aS,{asChild:!0,container:o,children:l})})})};uS.displayName=om;var tl="TooltipContent",dS=b.forwardRef((t,s)=>{const i=I4(tl,t.__scopeTooltip),{forceMount:l=i.forceMount,side:o="top",...d}=t,f=Cr(tl,t.__scopeTooltip);return c.jsx(lm,{present:l||f.open,children:f.disableHoverableContent?c.jsx(fS,{side:o,...d,ref:s}):c.jsx($4,{side:o,...d,ref:s})})}),$4=b.forwardRef((t,s)=>{const i=Cr(tl,t.__scopeTooltip),l=rm(tl,t.__scopeTooltip),o=b.useRef(null),d=ii(s,o),[f,m]=b.useState(null),{trigger:p,onClose:y}=i,x=o.current,{onPointerInTransitChange:g}=l,w=b.useCallback(()=>{m(null),g(!1)},[g]),S=b.useCallback((T,N)=>{const R=T.currentTarget,D={x:T.clientX,y:T.clientY},A=X4(D,R.getBoundingClientRect()),C=K4(D,A),B=Q4(N.getBoundingClientRect()),_=J4([...C,...B]);m(_),g(!0)},[g]);return b.useEffect(()=>()=>w(),[w]),b.useEffect(()=>{if(p&&x){const T=R=>S(R,x),N=R=>S(R,p);return p.addEventListener("pointerleave",T),x.addEventListener("pointerleave",N),()=>{p.removeEventListener("pointerleave",T),x.removeEventListener("pointerleave",N)}}},[p,x,S,w]),b.useEffect(()=>{if(f){const T=N=>{const R=N.target,D={x:N.clientX,y:N.clientY},A=p?.contains(R)||x?.contains(R),C=!Z4(D,f);A?w():C&&(w(),y())};return document.addEventListener("pointermove",T),()=>document.removeEventListener("pointermove",T)}},[p,x,f,y,w]),c.jsx(fS,{...t,ref:d})}),[G4,Y4]=Bc(xr,{isInside:!1}),F4=qE("TooltipContent"),fS=b.forwardRef((t,s)=>{const{__scopeTooltip:i,children:l,"aria-label":o,onEscapeKeyDown:d,onPointerDownOutside:f,...m}=t,p=Cr(tl,i),y=Vc(i),{onClose:x}=p;return b.useEffect(()=>(document.addEventListener(eh,x),()=>document.removeEventListener(eh,x)),[x]),b.useEffect(()=>{if(p.trigger){const g=w=>{w.target?.contains(p.trigger)&&x()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[p.trigger,x]),c.jsx(_w,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:g=>g.preventDefault(),onDismiss:x,children:c.jsxs(C4,{"data-state":p.stateAttribute,...y,...m,ref:s,style:{...m.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[c.jsx(F4,{children:l}),c.jsx(G4,{scope:i,isInside:!0,children:c.jsx(V4,{id:p.contentId,role:"tooltip",children:o||l})})]})})});dS.displayName=tl;var hS="TooltipArrow",mS=b.forwardRef((t,s)=>{const{__scopeTooltip:i,...l}=t,o=Vc(i);return Y4(hS,i).isInside?null:c.jsx(A4,{...o,...l,ref:s})});mS.displayName=hS;function X4(t,s){const i=Math.abs(s.top-t.y),l=Math.abs(s.bottom-t.y),o=Math.abs(s.right-t.x),d=Math.abs(s.left-t.x);switch(Math.min(i,l,o,d)){case d:return"left";case o:return"right";case i:return"top";case l:return"bottom";default:throw new Error("unreachable")}}function K4(t,s,i=5){const l=[];switch(s){case"top":l.push({x:t.x-i,y:t.y+i},{x:t.x+i,y:t.y+i});break;case"bottom":l.push({x:t.x-i,y:t.y-i},{x:t.x+i,y:t.y-i});break;case"left":l.push({x:t.x+i,y:t.y-i},{x:t.x+i,y:t.y+i});break;case"right":l.push({x:t.x-i,y:t.y-i},{x:t.x-i,y:t.y+i});break}return l}function Q4(t){const{top:s,right:i,bottom:l,left:o}=t;return[{x:o,y:s},{x:i,y:s},{x:i,y:l},{x:o,y:l}]}function Z4(t,s){const{x:i,y:l}=t;let o=!1;for(let d=0,f=s.length-1;dl!=w>l&&i<(g-y)*(l-x)/(w-x)+y&&(o=!o)}return o}function J4(t){const s=t.slice();return s.sort((i,l)=>i.xl.x?1:i.yl.y?1:0),W4(s)}function W4(t){if(t.length<=1)return t.slice();const s=[];for(let l=0;l=2;){const d=s[s.length-1],f=s[s.length-2];if((d.x-f.x)*(o.y-f.y)>=(d.y-f.y)*(o.x-f.x))s.pop();else break}s.push(o)}s.pop();const i=[];for(let l=t.length-1;l>=0;l--){const o=t[l];for(;i.length>=2;){const d=i[i.length-1],f=i[i.length-2];if((d.x-f.x)*(o.y-f.y)>=(d.y-f.y)*(o.x-f.x))i.pop();else break}i.push(o)}return i.pop(),s.length===1&&i.length===1&&s[0].x===i[0].x&&s[0].y===i[0].y?s:s.concat(i)}var eD=rS,tD=oS,nD=cS,sD=uS,aD=dS,iD=mS;function lD({children:t}){return c.jsx(eD,{delayDuration:300,children:t})}function Qa({children:t,content:s,side:i="top",delayDuration:l=300}){const{enabled:o}=Aw();return o?c.jsxs(tD,{delayDuration:l,children:[c.jsx(nD,{asChild:!0,children:t}),c.jsx(sD,{children:c.jsxs(aD,{side:i,sideOffset:5,className:"z-[100] max-w-xs px-3 py-2 text-sm text-white bg-slate-900 rounded-lg shadow-lg",style:{animation:"fadeIn 0.15s ease-out"},children:[s,c.jsx(iD,{className:"fill-slate-900"})]})})]}):t}function rD(t){if(typeof document>"u")return;let s=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",s.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}const oD=t=>{switch(t){case"success":return dD;case"info":return hD;case"warning":return fD;case"error":return mD;default:return null}},cD=Array(12).fill(0),uD=({visible:t,className:s})=>ie.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ie.createElement("div",{className:"sonner-spinner"},cD.map((i,l)=>ie.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${l}`})))),dD=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),fD=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),hD=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),mD=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),pD=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ie.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ie.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),gD=()=>{const[t,s]=ie.useState(document.hidden);return ie.useEffect(()=>{const i=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",i),()=>window.removeEventListener("visibilitychange",i)},[]),t};let nh=1;class yD{constructor(){this.subscribe=s=>(this.subscribers.push(s),()=>{const i=this.subscribers.indexOf(s);this.subscribers.splice(i,1)}),this.publish=s=>{this.subscribers.forEach(i=>i(s))},this.addToast=s=>{this.publish(s),this.toasts=[...this.toasts,s]},this.create=s=>{var i;const{message:l,...o}=s,d=typeof s?.id=="number"||((i=s.id)==null?void 0:i.length)>0?s.id:nh++,f=this.toasts.find(p=>p.id===d),m=s.dismissible===void 0?!0:s.dismissible;return this.dismissedToasts.has(d)&&this.dismissedToasts.delete(d),f?this.toasts=this.toasts.map(p=>p.id===d?(this.publish({...p,...s,id:d,title:l}),{...p,...s,id:d,dismissible:m,title:l}):p):this.addToast({title:l,...o,dismissible:m,id:d}),d},this.dismiss=s=>(s?(this.dismissedToasts.add(s),requestAnimationFrame(()=>this.subscribers.forEach(i=>i({id:s,dismiss:!0})))):this.toasts.forEach(i=>{this.subscribers.forEach(l=>l({id:i.id,dismiss:!0}))}),s),this.message=(s,i)=>this.create({...i,message:s}),this.error=(s,i)=>this.create({...i,message:s,type:"error"}),this.success=(s,i)=>this.create({...i,type:"success",message:s}),this.info=(s,i)=>this.create({...i,type:"info",message:s}),this.warning=(s,i)=>this.create({...i,type:"warning",message:s}),this.loading=(s,i)=>this.create({...i,type:"loading",message:s}),this.promise=(s,i)=>{if(!i)return;let l;i.loading!==void 0&&(l=this.create({...i,promise:s,type:"loading",message:i.loading,description:typeof i.description!="function"?i.description:void 0}));const o=Promise.resolve(s instanceof Function?s():s);let d=l!==void 0,f;const m=o.then(async y=>{if(f=["resolve",y],ie.isValidElement(y))d=!1,this.create({id:l,type:"default",message:y});else if(bD(y)&&!y.ok){d=!1;const g=typeof i.error=="function"?await i.error(`HTTP error! status: ${y.status}`):i.error,w=typeof i.description=="function"?await i.description(`HTTP error! status: ${y.status}`):i.description,T=typeof g=="object"&&!ie.isValidElement(g)?g:{message:g};this.create({id:l,type:"error",description:w,...T})}else if(y instanceof Error){d=!1;const g=typeof i.error=="function"?await i.error(y):i.error,w=typeof i.description=="function"?await i.description(y):i.description,T=typeof g=="object"&&!ie.isValidElement(g)?g:{message:g};this.create({id:l,type:"error",description:w,...T})}else if(i.success!==void 0){d=!1;const g=typeof i.success=="function"?await i.success(y):i.success,w=typeof i.description=="function"?await i.description(y):i.description,T=typeof g=="object"&&!ie.isValidElement(g)?g:{message:g};this.create({id:l,type:"success",description:w,...T})}}).catch(async y=>{if(f=["reject",y],i.error!==void 0){d=!1;const x=typeof i.error=="function"?await i.error(y):i.error,g=typeof i.description=="function"?await i.description(y):i.description,S=typeof x=="object"&&!ie.isValidElement(x)?x:{message:x};this.create({id:l,type:"error",description:g,...S})}}).finally(()=>{d&&(this.dismiss(l),l=void 0),i.finally==null||i.finally.call(i)}),p=()=>new Promise((y,x)=>m.then(()=>f[0]==="reject"?x(f[1]):y(f[1])).catch(x));return typeof l!="string"&&typeof l!="number"?{unwrap:p}:Object.assign(l,{unwrap:p})},this.custom=(s,i)=>{const l=i?.id||nh++;return this.create({jsx:s(l),id:l,...i}),l},this.getActiveToasts=()=>this.toasts.filter(s=>!this.dismissedToasts.has(s.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const rn=new yD,xD=(t,s)=>{const i=s?.id||nh++;return rn.addToast({title:t,...s,id:i}),i},bD=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",vD=xD,wD=()=>rn.toasts,SD=()=>rn.getActiveToasts(),Ji=Object.assign(vD,{success:rn.success,info:rn.info,warning:rn.warning,error:rn.error,custom:rn.custom,message:rn.message,promise:rn.promise,dismiss:rn.dismiss,loading:rn.loading},{getHistory:wD,getToasts:SD});rD("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Ko(t){return t.label!==void 0}const jD=3,TD="24px",ND="16px",Wx=4e3,CD=356,AD=14,ED=45,DD=200;function as(...t){return t.filter(Boolean).join(" ")}function kD(t){const[s,i]=t.split("-"),l=[];return s&&l.push(s),i&&l.push(i),l}const RD=t=>{var s,i,l,o,d,f,m,p,y;const{invert:x,toast:g,unstyled:w,interacting:S,setHeights:T,visibleToasts:N,heights:R,index:D,toasts:A,expanded:C,removeToast:B,defaultRichColors:_,closeButton:F,style:$,cancelButtonStyle:I,actionButtonStyle:z,className:X="",descriptionClassName:te="",duration:H,position:P,gap:K,expandByDefault:ae,classNames:O,icons:G,closeButtonAriaLabel:Z="Close toast"}=t,[re,ue]=ie.useState(null),[je,Ne]=ie.useState(null),[se,ce]=ie.useState(!1),[ne,de]=ie.useState(!1),[oe,ee]=ie.useState(!1),[ge,Ee]=ie.useState(!1),[wt,me]=ie.useState(!1),[ze,st]=ie.useState(0),[on,Wt]=ie.useState(0),ms=ie.useRef(g.duration||H||Wx),Yn=ie.useRef(null),Yt=ie.useRef(null),li=D===0,Ea=D+1<=N,Vt=g.type,Fn=g.dismissible!==!1,St=g.className||"",$s=g.descriptionClassName||"",Xn=ie.useMemo(()=>R.findIndex(be=>be.toastId===g.id)||0,[R,g.id]),Da=ie.useMemo(()=>{var be;return(be=g.closeButton)!=null?be:F},[g.closeButton,F]),ps=ie.useMemo(()=>g.duration||H||Wx,[g.duration,H]),ka=ie.useRef(0),Ln=ie.useRef(0),ri=ie.useRef(0),cn=ie.useRef(null),[Ft,ft]=P.split("-"),Ut=ie.useMemo(()=>R.reduce((be,Fe,ht)=>ht>=Xn?be:be+Fe.height,0),[R,Xn]),Ct=gD(),Gs=g.invert||x,Kn=Vt==="loading";Ln.current=ie.useMemo(()=>Xn*K+Ut,[Xn,Ut]),ie.useEffect(()=>{ms.current=ps},[ps]),ie.useEffect(()=>{ce(!0)},[]),ie.useEffect(()=>{const be=Yt.current;if(be){const Fe=be.getBoundingClientRect().height;return Wt(Fe),T(ht=>[{toastId:g.id,height:Fe,position:g.position},...ht]),()=>T(ht=>ht.filter(At=>At.toastId!==g.id))}},[T,g.id]),ie.useLayoutEffect(()=>{if(!se)return;const be=Yt.current,Fe=be.style.height;be.style.height="auto";const ht=be.getBoundingClientRect().height;be.style.height=Fe,Wt(ht),T(At=>At.find(Xe=>Xe.toastId===g.id)?At.map(Xe=>Xe.toastId===g.id?{...Xe,height:ht}:Xe):[{toastId:g.id,height:ht,position:g.position},...At])},[se,g.title,g.description,T,g.id,g.jsx,g.action,g.cancel]);const un=ie.useCallback(()=>{de(!0),st(Ln.current),T(be=>be.filter(Fe=>Fe.toastId!==g.id)),setTimeout(()=>{B(g)},DD)},[g,B,T,Ln]);ie.useEffect(()=>{if(g.promise&&Vt==="loading"||g.duration===1/0||g.type==="loading")return;let be;return C||S||Ct?(()=>{if(ri.current{g.onAutoClose==null||g.onAutoClose.call(g,g),un()},ms.current)),()=>clearTimeout(be)},[C,S,g,Vt,Ct,un]),ie.useEffect(()=>{g.delete&&(un(),g.onDismiss==null||g.onDismiss.call(g,g))},[un,g.delete]);function gs(){var be;if(G?.loading){var Fe;return ie.createElement("div",{className:as(O?.loader,g==null||(Fe=g.classNames)==null?void 0:Fe.loader,"sonner-loader"),"data-visible":Vt==="loading"},G.loading)}return ie.createElement(uD,{className:as(O?.loader,g==null||(be=g.classNames)==null?void 0:be.loader),visible:Vt==="loading"})}const Qn=g.icon||G?.[Vt]||oD(Vt);var Pt,Xt;return ie.createElement("li",{tabIndex:0,ref:Yt,className:as(X,St,O?.toast,g==null||(s=g.classNames)==null?void 0:s.toast,O?.default,O?.[Vt],g==null||(i=g.classNames)==null?void 0:i[Vt]),"data-sonner-toast":"","data-rich-colors":(Pt=g.richColors)!=null?Pt:_,"data-styled":!(g.jsx||g.unstyled||w),"data-mounted":se,"data-promise":!!g.promise,"data-swiped":wt,"data-removed":ne,"data-visible":Ea,"data-y-position":Ft,"data-x-position":ft,"data-index":D,"data-front":li,"data-swiping":oe,"data-dismissible":Fn,"data-type":Vt,"data-invert":Gs,"data-swipe-out":ge,"data-swipe-direction":je,"data-expanded":!!(C||ae&&se),"data-testid":g.testId,style:{"--index":D,"--toasts-before":D,"--z-index":A.length-D,"--offset":`${ne?ze:Ln.current}px`,"--initial-height":ae?"auto":`${on}px`,...$,...g.style},onDragEnd:()=>{ee(!1),ue(null),cn.current=null},onPointerDown:be=>{be.button!==2&&(Kn||!Fn||(Yn.current=new Date,st(Ln.current),be.target.setPointerCapture(be.pointerId),be.target.tagName!=="BUTTON"&&(ee(!0),cn.current={x:be.clientX,y:be.clientY})))},onPointerUp:()=>{var be,Fe,ht;if(ge||!Fn)return;cn.current=null;const At=Number(((be=Yt.current)==null?void 0:be.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Zn=Number(((Fe=Yt.current)==null?void 0:Fe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Xe=new Date().getTime()-((ht=Yn.current)==null?void 0:ht.getTime()),Ht=re==="x"?At:Zn,Jn=Math.abs(Ht)/Xe;if(Math.abs(Ht)>=ED||Jn>.11){st(Ln.current),g.onDismiss==null||g.onDismiss.call(g,g),Ne(re==="x"?At>0?"right":"left":Zn>0?"down":"up"),un(),Ee(!0);return}else{var Dt,kt;(Dt=Yt.current)==null||Dt.style.setProperty("--swipe-amount-x","0px"),(kt=Yt.current)==null||kt.style.setProperty("--swipe-amount-y","0px")}me(!1),ee(!1),ue(null)},onPointerMove:be=>{var Fe,ht,At;if(!cn.current||!Fn||((Fe=window.getSelection())==null?void 0:Fe.toString().length)>0)return;const Xe=be.clientY-cn.current.y,Ht=be.clientX-cn.current.x;var Jn;const Dt=(Jn=t.swipeDirections)!=null?Jn:kD(P);!re&&(Math.abs(Ht)>1||Math.abs(Xe)>1)&&ue(Math.abs(Ht)>Math.abs(Xe)?"x":"y");let kt={x:0,y:0};const ys=qt=>1/(1.5+Math.abs(qt)/20);if(re==="y"){if(Dt.includes("top")||Dt.includes("bottom"))if(Dt.includes("top")&&Xe<0||Dt.includes("bottom")&&Xe>0)kt.y=Xe;else{const qt=Xe*ys(Xe);kt.y=Math.abs(qt)0)kt.x=Ht;else{const qt=Ht*ys(Ht);kt.x=Math.abs(qt)0||Math.abs(kt.y)>0)&&me(!0),(ht=Yt.current)==null||ht.style.setProperty("--swipe-amount-x",`${kt.x}px`),(At=Yt.current)==null||At.style.setProperty("--swipe-amount-y",`${kt.y}px`)}},Da&&!g.jsx&&Vt!=="loading"?ie.createElement("button",{"aria-label":Z,"data-disabled":Kn,"data-close-button":!0,onClick:Kn||!Fn?()=>{}:()=>{un(),g.onDismiss==null||g.onDismiss.call(g,g)},className:as(O?.closeButton,g==null||(l=g.classNames)==null?void 0:l.closeButton)},(Xt=G?.close)!=null?Xt:pD):null,(Vt||g.icon||g.promise)&&g.icon!==null&&(G?.[Vt]!==null||g.icon)?ie.createElement("div",{"data-icon":"",className:as(O?.icon,g==null||(o=g.classNames)==null?void 0:o.icon)},g.promise||g.type==="loading"&&!g.icon?g.icon||gs():null,g.type!=="loading"?Qn:null):null,ie.createElement("div",{"data-content":"",className:as(O?.content,g==null||(d=g.classNames)==null?void 0:d.content)},ie.createElement("div",{"data-title":"",className:as(O?.title,g==null||(f=g.classNames)==null?void 0:f.title)},g.jsx?g.jsx:typeof g.title=="function"?g.title():g.title),g.description?ie.createElement("div",{"data-description":"",className:as(te,$s,O?.description,g==null||(m=g.classNames)==null?void 0:m.description)},typeof g.description=="function"?g.description():g.description):null),ie.isValidElement(g.cancel)?g.cancel:g.cancel&&Ko(g.cancel)?ie.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||I,onClick:be=>{Ko(g.cancel)&&Fn&&(g.cancel.onClick==null||g.cancel.onClick.call(g.cancel,be),un())},className:as(O?.cancelButton,g==null||(p=g.classNames)==null?void 0:p.cancelButton)},g.cancel.label):null,ie.isValidElement(g.action)?g.action:g.action&&Ko(g.action)?ie.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||z,onClick:be=>{Ko(g.action)&&(g.action.onClick==null||g.action.onClick.call(g.action,be),!be.defaultPrevented&&un())},className:as(O?.actionButton,g==null||(y=g.classNames)==null?void 0:y.actionButton)},g.action.label):null)};function eb(){if(typeof window>"u"||typeof document>"u")return"ltr";const t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function MD(t,s){const i={};return[t,s].forEach((l,o)=>{const d=o===1,f=d?"--mobile-offset":"--offset",m=d?ND:TD;function p(y){["top","right","bottom","left"].forEach(x=>{i[`${f}-${x}`]=typeof y=="number"?`${y}px`:y})}typeof l=="number"||typeof l=="string"?p(l):typeof l=="object"?["top","right","bottom","left"].forEach(y=>{l[y]===void 0?i[`${f}-${y}`]=m:i[`${f}-${y}`]=typeof l[y]=="number"?`${l[y]}px`:l[y]}):p(m)}),i}const OD=ie.forwardRef(function(s,i){const{id:l,invert:o,position:d="bottom-right",hotkey:f=["altKey","KeyT"],expand:m,closeButton:p,className:y,offset:x,mobileOffset:g,theme:w="light",richColors:S,duration:T,style:N,visibleToasts:R=jD,toastOptions:D,dir:A=eb(),gap:C=AD,icons:B,containerAriaLabel:_="Notifications"}=s,[F,$]=ie.useState([]),I=ie.useMemo(()=>l?F.filter(se=>se.toasterId===l):F.filter(se=>!se.toasterId),[F,l]),z=ie.useMemo(()=>Array.from(new Set([d].concat(I.filter(se=>se.position).map(se=>se.position)))),[I,d]),[X,te]=ie.useState([]),[H,P]=ie.useState(!1),[K,ae]=ie.useState(!1),[O,G]=ie.useState(w!=="system"?w:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Z=ie.useRef(null),re=f.join("+").replace(/Key/g,"").replace(/Digit/g,""),ue=ie.useRef(null),je=ie.useRef(!1),Ne=ie.useCallback(se=>{$(ce=>{var ne;return(ne=ce.find(de=>de.id===se.id))!=null&&ne.delete||rn.dismiss(se.id),ce.filter(({id:de})=>de!==se.id)})},[]);return ie.useEffect(()=>rn.subscribe(se=>{if(se.dismiss){requestAnimationFrame(()=>{$(ce=>ce.map(ne=>ne.id===se.id?{...ne,delete:!0}:ne))});return}setTimeout(()=>{Tb.flushSync(()=>{$(ce=>{const ne=ce.findIndex(de=>de.id===se.id);return ne!==-1?[...ce.slice(0,ne),{...ce[ne],...se},...ce.slice(ne+1)]:[se,...ce]})})})}),[F]),ie.useEffect(()=>{if(w!=="system"){G(w);return}if(w==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?G("dark"):G("light")),typeof window>"u")return;const se=window.matchMedia("(prefers-color-scheme: dark)");try{se.addEventListener("change",({matches:ce})=>{G(ce?"dark":"light")})}catch{se.addListener(({matches:ne})=>{try{G(ne?"dark":"light")}catch(de){console.error(de)}})}},[w]),ie.useEffect(()=>{F.length<=1&&P(!1)},[F]),ie.useEffect(()=>{const se=ce=>{var ne;if(f.every(ee=>ce[ee]||ce.code===ee)){var oe;P(!0),(oe=Z.current)==null||oe.focus()}ce.code==="Escape"&&(document.activeElement===Z.current||(ne=Z.current)!=null&&ne.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",se),()=>document.removeEventListener("keydown",se)},[f]),ie.useEffect(()=>{if(Z.current)return()=>{ue.current&&(ue.current.focus({preventScroll:!0}),ue.current=null,je.current=!1)}},[Z.current]),ie.createElement("section",{ref:i,"aria-label":`${_} ${re}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},z.map((se,ce)=>{var ne;const[de,oe]=se.split("-");return I.length?ie.createElement("ol",{key:se,dir:A==="auto"?eb():A,tabIndex:-1,ref:Z,className:y,"data-sonner-toaster":!0,"data-sonner-theme":O,"data-y-position":de,"data-x-position":oe,style:{"--front-toast-height":`${((ne=X[0])==null?void 0:ne.height)||0}px`,"--width":`${CD}px`,"--gap":`${C}px`,...N,...MD(x,g)},onBlur:ee=>{je.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(je.current=!1,ue.current&&(ue.current.focus({preventScroll:!0}),ue.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||je.current||(je.current=!0,ue.current=ee.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{K||P(!1)},onDragEnd:()=>P(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||ae(!0)},onPointerUp:()=>ae(!1)},I.filter(ee=>!ee.position&&ce===0||ee.position===se).map((ee,ge)=>{var Ee,wt;return ie.createElement(RD,{key:ee.id,icons:B,index:ge,toast:ee,defaultRichColors:S,duration:(Ee=D?.duration)!=null?Ee:T,className:D?.className,descriptionClassName:D?.descriptionClassName,invert:o,visibleToasts:R,closeButton:(wt=D?.closeButton)!=null?wt:p,interacting:K,position:se,style:D?.style,unstyled:D?.unstyled,classNames:D?.classNames,cancelButtonStyle:D?.cancelButtonStyle,actionButtonStyle:D?.actionButtonStyle,closeButtonAriaLabel:D?.closeButtonAriaLabel,removeToast:Ne,toasts:I.filter(me=>me.position==ee.position),heights:X.filter(me=>me.position==ee.position),setHeights:te,expandByDefault:m,gap:C,expanded:H,swipeDirections:s.swipeDirections})})):null}))});function _D(){let t=!1;try{t=Dw()?.isDark??!1}catch{}return c.jsx(OD,{position:"bottom-right",offset:100,toastOptions:{className:"font-sans text-sm",duration:4e3,style:t?{background:"#1e293b",border:"1px solid #334155",boxShadow:"0 4px 20px rgba(0,0,0,0.4)",color:"#f1f5f9"}:{background:"white",border:"1px solid #e2e8f0",boxShadow:"0 4px 20px rgba(0,0,0,0.12)"}},theme:t?"dark":"light",richColors:!0,closeButton:!0})}const pS=b.createContext(null);function LD({children:t}){const[s,i]=b.useState(!1),[l,o]=b.useState(()=>{try{const x=localStorage.getItem("command_palette_recent");return x?JSON.parse(x):[]}catch{return[]}}),d=b.useCallback(()=>i(!0),[]),f=b.useCallback(()=>i(!1),[]),m=b.useCallback(()=>i(x=>!x),[]),p=b.useCallback(x=>{o(g=>{const w=g.filter(T=>T.id!==x.id),S=[x,...w].slice(0,5);try{localStorage.setItem("command_palette_recent",JSON.stringify(S))}catch{}return S})},[]);b.useEffect(()=>{const x=g=>{(g.metaKey||g.ctrlKey)&&g.key.toLowerCase()==="k"&&(g.preventDefault(),m()),g.key==="Escape"&&s&&(g.preventDefault(),f())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[s,m,f]);const y={isOpen:s,open:d,close:f,toggle:m,recentItems:l,addRecentItem:p};return c.jsx(pS.Provider,{value:y,children:t})}function cm(){const t=b.useContext(pS);if(!t)throw new Error("useCommand must be used within a CommandProvider");return t}function Is(t){return Array.isArray?Array.isArray(t):xS(t)==="[object Array]"}function zD(t){if(typeof t=="string")return t;let s=t+"";return s=="0"&&1/t==-1/0?"-0":s}function BD(t){return t==null?"":zD(t)}function ls(t){return typeof t=="string"}function gS(t){return typeof t=="number"}function VD(t){return t===!0||t===!1||UD(t)&&xS(t)=="[object Boolean]"}function yS(t){return typeof t=="object"}function UD(t){return yS(t)&&t!==null}function bn(t){return t!=null}function bf(t){return!t.trim().length}function xS(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const PD="Incorrect 'index' type",HD=t=>`Invalid value for key ${t}`,qD=t=>`Pattern length exceeds max of ${t}.`,ID=t=>`Missing ${t} property in key`,$D=t=>`Property 'weight' in key '${t}' must be a positive integer`,tb=Object.prototype.hasOwnProperty;class GD{constructor(s){this._keys=[],this._keyMap={};let i=0;s.forEach(l=>{let o=bS(l);this._keys.push(o),this._keyMap[o.id]=o,i+=o.weight}),this._keys.forEach(l=>{l.weight/=i})}get(s){return this._keyMap[s]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function bS(t){let s=null,i=null,l=null,o=1,d=null;if(ls(t)||Is(t))l=t,s=nb(t),i=sh(t);else{if(!tb.call(t,"name"))throw new Error(ID("name"));const f=t.name;if(l=f,tb.call(t,"weight")&&(o=t.weight,o<=0))throw new Error($D(f));s=nb(f),i=sh(f),d=t.getFn}return{path:s,id:i,weight:o,src:l,getFn:d}}function nb(t){return Is(t)?t:t.split(".")}function sh(t){return Is(t)?t.join("."):t}function YD(t,s){let i=[],l=!1;const o=(d,f,m)=>{if(bn(d))if(!f[m])i.push(d);else{let p=f[m];const y=d[p];if(!bn(y))return;if(m===f.length-1&&(ls(y)||gS(y)||VD(y)))i.push(BD(y));else if(Is(y)){l=!0;for(let x=0,g=y.length;xt.score===s.score?t.idx{this._keysMap[i.id]=l})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,ls(this.docs[0])?this.docs.forEach((s,i)=>{this._addString(s,i)}):this.docs.forEach((s,i)=>{this._addObject(s,i)}),this.norm.clear())}add(s){const i=this.size();ls(s)?this._addString(s,i):this._addObject(s,i)}removeAt(s){this.records.splice(s,1);for(let i=s,l=this.size();i{let f=o.getFn?o.getFn(s):this.getFn(s,o.path);if(bn(f)){if(Is(f)){let m=[];const p=[{nestedArrIndex:-1,value:f}];for(;p.length;){const{nestedArrIndex:y,value:x}=p.pop();if(bn(x))if(ls(x)&&!bf(x)){let g={v:x,i:y,n:this.norm.get(x)};m.push(g)}else Is(x)&&x.forEach((g,w)=>{p.push({nestedArrIndex:w,value:g})})}l.$[d]=m}else if(ls(f)&&!bf(f)){let m={v:f,n:this.norm.get(f)};l.$[d]=m}}}),this.records.push(l)}toJSON(){return{keys:this.keys,records:this.records}}}function vS(t,s,{getFn:i=we.getFn,fieldNormWeight:l=we.fieldNormWeight}={}){const o=new um({getFn:i,fieldNormWeight:l});return o.setKeys(t.map(bS)),o.setSources(s),o.create(),o}function WD(t,{getFn:s=we.getFn,fieldNormWeight:i=we.fieldNormWeight}={}){const{keys:l,records:o}=t,d=new um({getFn:s,fieldNormWeight:i});return d.setKeys(l),d.setIndexRecords(o),d}function Qo(t,{errors:s=0,currentLocation:i=0,expectedLocation:l=0,distance:o=we.distance,ignoreLocation:d=we.ignoreLocation}={}){const f=s/t.length;if(d)return f;const m=Math.abs(l-i);return o?f+m/o:m?1:f}function e3(t=[],s=we.minMatchCharLength){let i=[],l=-1,o=-1,d=0;for(let f=t.length;d=s&&i.push([l,o]),l=-1)}return t[d-1]&&d-l>=s&&i.push([l,d-1]),i}const Za=32;function t3(t,s,i,{location:l=we.location,distance:o=we.distance,threshold:d=we.threshold,findAllMatches:f=we.findAllMatches,minMatchCharLength:m=we.minMatchCharLength,includeMatches:p=we.includeMatches,ignoreLocation:y=we.ignoreLocation}={}){if(s.length>Za)throw new Error(qD(Za));const x=s.length,g=t.length,w=Math.max(0,Math.min(l,g));let S=d,T=w;const N=m>1||p,R=N?Array(g):[];let D;for(;(D=t.indexOf(s,T))>-1;){let $=Qo(s,{currentLocation:D,expectedLocation:w,distance:o,ignoreLocation:y});if(S=Math.min($,S),T=D+x,N){let I=0;for(;I=X;K-=1){let ae=K-1,O=i[t.charAt(ae)];if(N&&(R[ae]=+!!O),H[K]=(H[K+1]<<1|1)&O,$&&(H[K]|=(A[K+1]|A[K])<<1|1|A[K+1]),H[K]&_&&(C=Qo(s,{errors:$,currentLocation:ae,expectedLocation:w,distance:o,ignoreLocation:y}),C<=S)){if(S=C,T=ae,T<=w)break;X=Math.max(1,2*w-T)}}if(Qo(s,{errors:$+1,currentLocation:w,expectedLocation:w,distance:o,ignoreLocation:y})>S)break;A=H}const F={isMatch:T>=0,score:Math.max(.001,C)};if(N){const $=e3(R,m);$.length?p&&(F.indices=$):F.isMatch=!1}return F}function n3(t){let s={};for(let i=0,l=t.length;it.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class wS{constructor(s,{location:i=we.location,threshold:l=we.threshold,distance:o=we.distance,includeMatches:d=we.includeMatches,findAllMatches:f=we.findAllMatches,minMatchCharLength:m=we.minMatchCharLength,isCaseSensitive:p=we.isCaseSensitive,ignoreDiacritics:y=we.ignoreDiacritics,ignoreLocation:x=we.ignoreLocation}={}){if(this.options={location:i,threshold:l,distance:o,includeMatches:d,findAllMatches:f,minMatchCharLength:m,isCaseSensitive:p,ignoreDiacritics:y,ignoreLocation:x},s=p?s:s.toLowerCase(),s=y?xc(s):s,this.pattern=s,this.chunks=[],!this.pattern.length)return;const g=(S,T)=>{this.chunks.push({pattern:S,alphabet:n3(S),startIndex:T})},w=this.pattern.length;if(w>Za){let S=0;const T=w%Za,N=w-T;for(;S{const{isMatch:A,score:C,indices:B}=t3(s,N,R,{location:d+D,distance:f,threshold:m,findAllMatches:p,minMatchCharLength:y,includeMatches:o,ignoreLocation:x});A&&(S=!0),w+=C,A&&B&&(g=[...g,...B])});let T={isMatch:S,score:S?w/this.chunks.length:1};return S&&o&&(T.indices=g),T}}class Aa{constructor(s){this.pattern=s}static isMultiMatch(s){return sb(s,this.multiRegex)}static isSingleMatch(s){return sb(s,this.singleRegex)}search(){}}function sb(t,s){const i=t.match(s);return i?i[1]:null}class s3 extends Aa{constructor(s){super(s)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(s){const i=s===this.pattern;return{isMatch:i,score:i?0:1,indices:[0,this.pattern.length-1]}}}class a3 extends Aa{constructor(s){super(s)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(s){const l=s.indexOf(this.pattern)===-1;return{isMatch:l,score:l?0:1,indices:[0,s.length-1]}}}class i3 extends Aa{constructor(s){super(s)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(s){const i=s.startsWith(this.pattern);return{isMatch:i,score:i?0:1,indices:[0,this.pattern.length-1]}}}class l3 extends Aa{constructor(s){super(s)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(s){const i=!s.startsWith(this.pattern);return{isMatch:i,score:i?0:1,indices:[0,s.length-1]}}}class r3 extends Aa{constructor(s){super(s)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(s){const i=s.endsWith(this.pattern);return{isMatch:i,score:i?0:1,indices:[s.length-this.pattern.length,s.length-1]}}}class o3 extends Aa{constructor(s){super(s)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(s){const i=!s.endsWith(this.pattern);return{isMatch:i,score:i?0:1,indices:[0,s.length-1]}}}class SS extends Aa{constructor(s,{location:i=we.location,threshold:l=we.threshold,distance:o=we.distance,includeMatches:d=we.includeMatches,findAllMatches:f=we.findAllMatches,minMatchCharLength:m=we.minMatchCharLength,isCaseSensitive:p=we.isCaseSensitive,ignoreDiacritics:y=we.ignoreDiacritics,ignoreLocation:x=we.ignoreLocation}={}){super(s),this._bitapSearch=new wS(s,{location:i,threshold:l,distance:o,includeMatches:d,findAllMatches:f,minMatchCharLength:m,isCaseSensitive:p,ignoreDiacritics:y,ignoreLocation:x})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(s){return this._bitapSearch.searchIn(s)}}class jS extends Aa{constructor(s){super(s)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(s){let i=0,l;const o=[],d=this.pattern.length;for(;(l=s.indexOf(this.pattern,i))>-1;)i=l+d,o.push([l,i-1]);const f=!!o.length;return{isMatch:f,score:f?0:1,indices:o}}}const ah=[s3,jS,i3,l3,o3,r3,a3,SS],ab=ah.length,c3=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,u3="|";function d3(t,s={}){return t.split(u3).map(i=>{let l=i.trim().split(c3).filter(d=>d&&!!d.trim()),o=[];for(let d=0,f=l.length;d!!(t[bc.AND]||t[bc.OR]),p3=t=>!!t[rh.PATH],g3=t=>!Is(t)&&yS(t)&&!oh(t),ib=t=>({[bc.AND]:Object.keys(t).map(s=>({[s]:t[s]}))});function TS(t,s,{auto:i=!0}={}){const l=o=>{let d=Object.keys(o);const f=p3(o);if(!f&&d.length>1&&!oh(o))return l(ib(o));if(g3(o)){const p=f?o[rh.PATH]:d[0],y=f?o[rh.PATTERN]:o[p];if(!ls(y))throw new Error(HD(p));const x={keyId:sh(p),pattern:y};return i&&(x.searcher=lh(y,s)),x}let m={children:[],operator:d[0]};return d.forEach(p=>{const y=o[p];Is(y)&&y.forEach(x=>{m.children.push(l(x))})}),m};return oh(t)||(t=ib(t)),l(t)}function y3(t,{ignoreFieldNorm:s=we.ignoreFieldNorm}){t.forEach(i=>{let l=1;i.matches.forEach(({key:o,norm:d,score:f})=>{const m=o?o.weight:null;l*=Math.pow(f===0&&m?Number.EPSILON:f,(m||1)*(s?1:d))}),i.score=l})}function x3(t,s){const i=t.matches;s.matches=[],bn(i)&&i.forEach(l=>{if(!bn(l.indices)||!l.indices.length)return;const{indices:o,value:d}=l;let f={indices:o,value:d};l.key&&(f.key=l.key.src),l.idx>-1&&(f.refIndex=l.idx),s.matches.push(f)})}function b3(t,s){s.score=t.score}function v3(t,s,{includeMatches:i=we.includeMatches,includeScore:l=we.includeScore}={}){const o=[];return i&&o.push(x3),l&&o.push(b3),t.map(d=>{const{idx:f}=d,m={item:s[f],refIndex:f};return o.length&&o.forEach(p=>{p(d,m)}),m})}class ol{constructor(s,i={},l){this.options={...we,...i},this.options.useExtendedSearch,this._keyStore=new GD(this.options.keys),this.setCollection(s,l)}setCollection(s,i){if(this._docs=s,i&&!(i instanceof um))throw new Error(PD);this._myIndex=i||vS(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(s){bn(s)&&(this._docs.push(s),this._myIndex.add(s))}remove(s=()=>!1){const i=[];for(let l=0,o=this._docs.length;l-1&&(p=p.slice(0,i)),v3(p,this._docs,{includeMatches:l,includeScore:o})}_searchStringList(s){const i=lh(s,this.options),{records:l}=this._myIndex,o=[];return l.forEach(({v:d,i:f,n:m})=>{if(!bn(d))return;const{isMatch:p,score:y,indices:x}=i.searchIn(d);p&&o.push({item:d,idx:f,matches:[{score:y,value:d,norm:m,indices:x}]})}),o}_searchLogical(s){const i=TS(s,this.options),l=(m,p,y)=>{if(!m.children){const{keyId:g,searcher:w}=m,S=this._findMatches({key:this._keyStore.get(g),value:this._myIndex.getValueForItemAtKeyId(p,g),searcher:w});return S&&S.length?[{idx:y,item:p,matches:S}]:[]}const x=[];for(let g=0,w=m.children.length;g{if(bn(m)){let y=l(i,m,p);y.length&&(d[p]||(d[p]={idx:p,item:m,matches:[]},f.push(d[p])),y.forEach(({matches:x})=>{d[p].matches.push(...x)}))}}),f}_searchObjectList(s){const i=lh(s,this.options),{keys:l,records:o}=this._myIndex,d=[];return o.forEach(({$:f,i:m})=>{if(!bn(f))return;let p=[];l.forEach((y,x)=>{p.push(...this._findMatches({key:y,value:f[x],searcher:i}))}),p.length&&d.push({idx:m,item:f,matches:p})}),d}_findMatches({key:s,value:i,searcher:l}){if(!bn(i))return[];let o=[];if(Is(i))i.forEach(({v:d,i:f,n:m})=>{if(!bn(d))return;const{isMatch:p,score:y,indices:x}=l.searchIn(d);p&&o.push({score:y,key:s,value:d,idx:f,norm:m,indices:x})});else{const{v:d,n:f}=i,{isMatch:m,score:p,indices:y}=l.searchIn(d);m&&o.push({score:p,key:s,value:d,norm:f,indices:y})}return o}}ol.version="7.1.0";ol.createIndex=vS;ol.parseIndex=WD;ol.config=we;ol.parseQuery=TS;m3(h3);const lb=[{id:"nav-home",type:"navigation",label:"Dashboard",icon:kb,path:"/",shortcut:"1"},{id:"nav-calls",type:"navigation",label:"Call List",icon:ni,path:"/calls",shortcut:"2"},{id:"nav-inbox",type:"navigation",label:"Messages",icon:Nc,path:"/inbox",shortcut:"3"},{id:"nav-leads",type:"navigation",label:"Leads",icon:ic,path:"/leads",shortcut:"4"},{id:"nav-battleground",type:"navigation",label:"Battleground",icon:ph,path:"/battleground",shortcut:"5"},{id:"nav-playbook",type:"navigation",label:"Sales Playbook",icon:Jj,path:"/playbook"},{id:"nav-stats",type:"navigation",label:"My Stats",icon:Wj,path:"/my-stats"},{id:"nav-insights",type:"navigation",label:"Weekly Insights",icon:$i,path:"/weekly-insights"},{id:"nav-more",type:"navigation",label:"More",icon:eT,path:"/more"}],rb=[{id:"action-new-lead",type:"action",label:"New Lead",icon:tT,action:"new-lead",shortcut:"N"},{id:"action-start-calls",type:"action",label:"Start Calling",icon:ni,action:"start-calls"}];function w3(){const t=Sc(),{isOpen:s,close:i,addRecentItem:l,recentItems:o}=cm(),[d,f]=b.useState(""),[m,p]=b.useState(0),[y,x]=b.useState([]),[g,w]=b.useState(!1),S=b.useRef(null),T=b.useRef(null);b.useEffect(()=>{s&&y.length===0&&(w(!0),Tr.list({limit:100,sort:"score",order:"desc"}).then(z=>{x(z.leads||[])}).catch(console.error).finally(()=>w(!1)))},[s]),b.useEffect(()=>{s&&(f(""),p(0),setTimeout(()=>S.current?.focus(),50))},[s]);const N=b.useMemo(()=>y.map(z=>({id:`lead-${z.id}`,type:"lead",label:`${z.first_name||""} ${z.last_name||""}`.trim()||"Unknown",subtitle:z.company||z.trade||"",icon:cr,path:`/leads/${z.id}`,score:z.score,leadId:z.id})),[y]),R=b.useMemo(()=>[...lb,...rb,...N],[N]),D=b.useMemo(()=>new ol(R,{keys:["label","subtitle"],threshold:.4,includeScore:!0}),[R]),A=b.useMemo(()=>{if(!d.trim()){const te=new Set(o.map(K=>K.id)),H=o.filter(K=>R.some(ae=>ae.id===K.id)),P=lb.filter(K=>!te.has(K.id));return{recent:H.length>0?H:null,navigation:P,actions:rb,leads:null}}const X=D.search(d).slice(0,10).map(te=>te.item);return{recent:null,navigation:X.filter(te=>te.type==="navigation"),actions:X.filter(te=>te.type==="action"),leads:X.filter(te=>te.type==="lead")}},[d,D,o,R]),C=b.useMemo(()=>{const z=[];return A.recent&&z.push(...A.recent),A.navigation?.length&&z.push(...A.navigation),A.actions?.length&&z.push(...A.actions),A.leads?.length&&z.push(...A.leads),z},[A]),B=b.useCallback(z=>{switch(z.key){case"ArrowDown":z.preventDefault(),p(X=>Math.min(X+1,C.length-1));break;case"ArrowUp":z.preventDefault(),p(X=>Math.max(X-1,0));break;case"Enter":z.preventDefault(),C[m]&&_(C[m]);break;case"Escape":z.preventDefault(),i();break}},[C,m,i]);b.useEffect(()=>{const z=T.current;if(!z)return;const X=z.querySelector(`[data-index="${m}"]`);X&&X.scrollIntoView({block:"nearest"})},[m]);const _=b.useCallback(z=>{l({id:z.id,type:z.type,label:z.label,icon:z.icon?.name||"User",path:z.path}),z.type==="navigation"||z.type==="lead"?t(z.path):z.type==="action"&&(z.action==="new-lead"?t("/leads?new=1"):z.action==="start-calls"&&t("/calls")),i()},[t,i,l]),F=(z,X)=>{const te=z.icon||cr,H=X===m;return c.jsxs("button",{"data-index":X,onClick:()=>_(z),onMouseEnter:()=>p(X),className:`w-full flex items-center gap-3 px-4 py-3 text-left transition-colors ${H?"bg-blue-50 text-blue-900 dark:bg-blue-900/30 dark:text-blue-100":"text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-700"}`,children:[c.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${H?"bg-blue-100 dark:bg-blue-800":"bg-slate-100 dark:bg-slate-700"}`,children:c.jsx(te,{className:`w-4 h-4 ${H?"text-blue-600 dark:text-blue-400":"text-slate-500 dark:text-slate-400"}`})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"font-medium truncate",children:z.label}),z.subtitle&&c.jsx("div",{className:"text-sm text-slate-500 dark:text-slate-400 truncate",children:z.subtitle})]}),z.shortcut&&c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("kbd",{className:"px-1.5 py-0.5 text-xs font-medium bg-slate-100 dark:bg-slate-700 text-slate-500 dark:text-slate-400 rounded border border-slate-200 dark:border-slate-600",children:navigator.platform.includes("Mac")?"⌘":"Ctrl"}),c.jsx("kbd",{className:"px-1.5 py-0.5 text-xs font-medium bg-slate-100 dark:bg-slate-700 text-slate-500 dark:text-slate-400 rounded border border-slate-200 dark:border-slate-600",children:z.shortcut})]}),z.type==="lead"&&z.score!==void 0&&c.jsx("div",{className:`px-2 py-0.5 text-xs font-bold rounded ${z.score>=70?"bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300":z.score>=50?"bg-orange-100 dark:bg-orange-900/40 text-orange-700 dark:text-orange-300":z.score>=20?"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300":"bg-slate-100 dark:bg-slate-700 text-slate-600 dark:text-slate-400"}`,children:z.score}),c.jsx(nT,{className:`w-4 h-4 ${H?"text-blue-400":"text-slate-300 dark:text-slate-500"}`})]},z.id)},$=({title:z})=>c.jsx("div",{className:"px-4 py-2 text-xs font-semibold text-slate-400 dark:text-slate-500 uppercase tracking-wider bg-slate-50 dark:bg-slate-900",children:z});if(!s)return null;let I=0;return wc.createPortal(c.jsxs("div",{className:"fixed inset-0 z-[100] flex items-start justify-center pt-[15vh]",children:[c.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),c.jsxs("div",{className:"relative w-full max-w-xl mx-4 bg-white dark:bg-slate-800 rounded-2xl shadow-2xl overflow-hidden animate-fade-in",children:[c.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-slate-200 dark:border-slate-700",children:[c.jsx(gh,{className:"w-5 h-5 text-slate-400 dark:text-slate-500"}),c.jsx("input",{ref:S,type:"text",value:d,onChange:z=>{f(z.target.value),p(0)},onKeyDown:B,placeholder:"Search leads, navigate, or take action...",className:"flex-1 text-lg outline-none placeholder:text-slate-400 dark:placeholder:text-slate-500 bg-transparent text-slate-900 dark:text-slate-100"}),c.jsxs("div",{className:"flex items-center gap-1 text-slate-400 dark:text-slate-500",children:[c.jsx("kbd",{className:"px-1.5 py-0.5 text-xs font-medium bg-slate-100 dark:bg-slate-700 rounded border border-slate-200 dark:border-slate-600",children:"esc"}),c.jsx("span",{className:"text-xs",children:"to close"})]})]}),c.jsxs("div",{ref:T,className:"max-h-[60vh] overflow-y-auto",children:[g&&!d&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-slate-500 dark:text-slate-400",children:[c.jsx(_n,{className:"w-5 h-5 animate-spin"}),c.jsx("span",{children:"Loading leads..."})]}),C.length===0&&d&&c.jsxs("div",{className:"py-12 text-center",children:[c.jsxs("div",{className:"text-slate-400 dark:text-slate-500 mb-2",children:['No results for "',d,'"']}),c.jsx("div",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Try a different search term"})]}),A.recent&&A.recent.length>0&&c.jsxs(c.Fragment,{children:[c.jsx($,{title:"Recent"}),A.recent.map(z=>{const X=F(z,I);return I++,X})]}),A.navigation&&A.navigation.length>0&&c.jsxs(c.Fragment,{children:[c.jsx($,{title:"Navigation"}),A.navigation.map(z=>{const X=F(z,I);return I++,X})]}),A.actions&&A.actions.length>0&&c.jsxs(c.Fragment,{children:[c.jsx($,{title:"Actions"}),A.actions.map(z=>{const X=F(z,I);return I++,X})]}),A.leads&&A.leads.length>0&&c.jsxs(c.Fragment,{children:[c.jsx($,{title:"Leads"}),A.leads.map(z=>{const X=F(z,I);return I++,X})]})]}),c.jsxs("div",{className:"px-4 py-3 bg-slate-50 dark:bg-slate-900 border-t border-slate-200 dark:border-slate-700 flex items-center justify-between text-xs text-slate-500 dark:text-slate-400",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx("kbd",{className:"px-1 py-0.5 bg-white dark:bg-slate-700 rounded border border-slate-200 dark:border-slate-600",children:"↑"}),c.jsx("kbd",{className:"px-1 py-0.5 bg-white dark:bg-slate-700 rounded border border-slate-200 dark:border-slate-600",children:"↓"}),"navigate"]}),c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx("kbd",{className:"px-1.5 py-0.5 bg-white dark:bg-slate-700 rounded border border-slate-200 dark:border-slate-600",children:"↵"}),"select"]})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(yh,{className:"w-3 h-3"}),c.jsx("span",{children:"K to open anytime"})]})]})]})]}),document.body)}function S3({isOpen:t,onClose:s}){if(!t)return null;const l=navigator.platform.toUpperCase().indexOf("MAC")>=0?"⌘":"Ctrl",o=[{category:"Navigation",items:[{keys:[`${l}`,"K"],description:"Open command palette"},{keys:[`${l}`,"1"],description:"Go to Dashboard"},{keys:[`${l}`,"2"],description:"Go to Call List"},{keys:[`${l}`,"3"],description:"Go to Messages"},{keys:[`${l}`,"4"],description:"Go to Leads"},{keys:[`${l}`,"5"],description:"Go to Battleground"}]},{category:"Vim-Style Navigation",items:[{keys:["G","H"],description:"Go to Home (Dashboard)"},{keys:["G","C"],description:"Go to Calls"},{keys:["G","M"],description:"Go to Messages"},{keys:["G","L"],description:"Go to Leads"},{keys:["G","B"],description:"Go to Battleground"}]},{category:"Lists",items:[{keys:["J","↓"],description:"Move down"},{keys:["K","↑"],description:"Move up"},{keys:["Enter"],description:"Open selected"},{keys:["C"],description:"Call selected lead"},{keys:["M"],description:"Message selected lead"}]},{category:"General",items:[{keys:["?"],description:"Show this help"},{keys:["Esc"],description:"Close modal / Cancel"}]}];return wc.createPortal(c.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:s}),c.jsxs("div",{className:"relative w-full max-w-lg bg-white dark:bg-slate-800 rounded-2xl shadow-2xl overflow-hidden animate-fade-in",children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(yh,{className:"w-5 h-5 text-slate-600 dark:text-slate-400"}),c.jsx("h2",{className:"text-lg font-bold text-slate-900 dark:text-slate-100",children:"Keyboard Shortcuts"})]}),c.jsx("button",{onClick:s,className:"w-8 h-8 flex items-center justify-center rounded-lg hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-slate-500 dark:text-slate-400"})})]}),c.jsx("div",{className:"p-6 max-h-[70vh] overflow-y-auto",children:c.jsx("div",{className:"space-y-6",children:o.map(d=>c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-semibold text-slate-400 dark:text-slate-500 uppercase tracking-wider mb-3",children:d.category}),c.jsx("div",{className:"space-y-2",children:d.items.map((f,m)=>c.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[c.jsx("span",{className:"text-sm text-slate-700 dark:text-slate-300",children:f.description}),c.jsx("div",{className:"flex items-center gap-1",children:f.keys.map((p,y)=>c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx("kbd",{className:"px-2 py-1 text-xs font-medium bg-slate-100 dark:bg-slate-700 text-slate-600 dark:text-slate-300 rounded border border-slate-200 dark:border-slate-600 min-w-[24px] text-center",children:p}),yl("light"),className:`flex items-center gap-2 px-3 py-2 rounded-md transition-colors ${s==="light"?"bg-white dark:bg-slate-600 shadow-sm text-amber-600":"text-slate-500 dark:text-slate-400 hover:bg-white/50 dark:hover:bg-slate-600/50"}`,children:[c.jsx(sy,{className:"w-4 h-4"}),c.jsx("span",{className:"text-sm font-medium",children:"Light"})]}),c.jsxs("button",{onClick:()=>l("dark"),className:`flex items-center gap-2 px-3 py-2 rounded-md transition-colors ${s==="dark"?"bg-white dark:bg-slate-600 shadow-sm text-blue-500":"text-slate-500 dark:text-slate-400 hover:bg-white/50 dark:hover:bg-slate-600/50"}`,children:[c.jsx(ay,{className:"w-4 h-4"}),c.jsx("span",{className:"text-sm font-medium",children:"Dark"})]}),c.jsxs("button",{onClick:()=>l("system"),className:`flex items-center gap-2 px-3 py-2 rounded-md transition-colors ${s==="system"?"bg-white dark:bg-slate-600 shadow-sm text-slate-700 dark:text-slate-200":"text-slate-500 dark:text-slate-400 hover:bg-white/50 dark:hover:bg-slate-600/50"}`,children:[c.jsx(iy,{className:"w-4 h-4"}),c.jsx("span",{className:"text-sm font-medium",children:"Auto"})]})]}):c.jsxs("button",{onClick:i,className:"p-2 rounded-lg transition-colors bg-slate-100 hover:bg-slate-200 dark:bg-slate-700 dark:hover:bg-slate-600",title:`Theme: ${s}`,children:[s==="light"&&c.jsx(sy,{className:"w-5 h-5 text-amber-500"}),s==="dark"&&c.jsx(ay,{className:"w-5 h-5 text-blue-400"}),s==="system"&&c.jsx(iy,{className:"w-5 h-5 text-slate-500 dark:text-slate-400"})]})}function T3(){const t=Sc(),[s,i]=b.useState(!1),[l,o]=b.useState(!1),d=b.useCallback(()=>i(!0),[]),f=b.useCallback(()=>i(!1),[]);return b.useEffect(()=>{let m=null;const p=y=>{const x=y.target;if(!(x.tagName==="INPUT"||x.tagName==="TEXTAREA"||x.isContentEditable)){if(y.key==="?"||y.shiftKey&&y.key==="/"){y.preventDefault(),i(w=>!w);return}if(y.key==="Escape"&&s){y.preventDefault(),i(!1);return}if((y.metaKey||y.ctrlKey)&&!y.shiftKey){const w={1:"/",2:"/calls",3:"/inbox",4:"/leads",5:"/battleground"};if(w[y.key]){y.preventDefault(),t(w[y.key]);return}}if(l){const S={h:"/",c:"/calls",m:"/inbox",l:"/leads",b:"/battleground",p:"/playbook",s:"/my-stats"}[y.key.toLowerCase()];S&&(y.preventDefault(),t(S)),o(!1),clearTimeout(m);return}if(y.key.toLowerCase()==="g"&&!y.metaKey&&!y.ctrlKey){o(!0),m=setTimeout(()=>o(!1),1e3);return}}};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p),m&&clearTimeout(m)}},[t,s,l]),{showHelp:s,openHelp:d,closeHelp:f,pendingG:l}}function at({children:t}){const{isAuthenticated:s,loading:i}=br();return i?c.jsx("div",{className:"min-h-screen flex items-center justify-center bg-slate-50",children:c.jsxs("div",{className:"flex flex-col items-center gap-4",children:[c.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-blue-600 border-t-transparent rounded-full"}),c.jsx("p",{className:"text-slate-500 font-medium",children:"Loading..."})]})}):s?t:c.jsx(qj,{to:"/login",replace:!0})}const N3="https://rateright-growth-production.up.railway.app",ob=new Set,C3=50;let cb=0;async function ch(t){if(cb>=C3){console.debug("Error rate limit reached");return}const s=`${t.message}:${t.page_path}`;if(!ob.has(s)){ob.add(s),cb++;try{await fetch(`${N3}/api/frontend/error`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch(i){console.debug("Error tracking send failed:",i.message)}}}function uh(t,s={}){return{message:t.message||String(t),stack:t.stack||null,page_path:window.location.pathname,url:window.location.href,user_agent:navigator.userAgent,timestamp:new Date().toISOString(),...s}}function A3(t,s){const i=uh(t,{type:"boundary",component_stack:s?.componentStack||null});ch(i)}function E3(){window.addEventListener("error",t=>{const s=uh(t.error||new Error(t.message),{type:"uncaught",filename:t.filename,lineno:t.lineno,colno:t.colno});ch(s)}),window.addEventListener("unhandledrejection",t=>{const s=t.reason instanceof Error?t.reason:new Error(String(t.reason)),i=uh(s,{type:"unhandled_rejection"});ch(i)}),console.debug("Error tracking initialized")}class D3 extends b.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,i){console.error("React Error Boundary caught:",s,i),A3(s,i)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?c.jsx("div",{className:"min-h-screen bg-slate-100 flex items-center justify-center p-4",children:c.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-8 max-w-md w-full text-center",children:[c.jsx("div",{className:"w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4",children:c.jsx(Db,{className:"w-8 h-8 text-red-500"})}),c.jsx("h1",{className:"text-xl font-bold text-slate-900 mb-2",children:"Something went wrong"}),c.jsx("p",{className:"text-slate-600 mb-6",children:"An unexpected error occurred. Please try refreshing the page."}),this.state.error&&c.jsx("pre",{className:"bg-slate-100 p-3 rounded-lg text-left text-xs text-red-600 mb-4 overflow-auto max-h-32",children:this.state.error.toString()}),c.jsxs("div",{className:"flex gap-3 justify-center",children:[c.jsx("button",{onClick:this.handleReset,className:"px-4 py-2 bg-slate-200 text-slate-700 rounded-lg font-medium hover:bg-slate-300",children:"Try Again"}),c.jsxs("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-blue-500 text-white rounded-lg font-medium hover:bg-blue-600 flex items-center gap-2",children:[c.jsx(Rb,{className:"w-4 h-4"}),"Refresh Page"]})]})]})}):this.props.children}}function k3(){const t=Nb(),{newSmsCount:s}=Rc(),i=[{to:"/",icon:kb,label:"Home",tooltip:`Dashboard – Tap "Today's Mission" for AI action plan + ready-to-send messages`},{to:"/calls",icon:ni,label:"Calls",tooltip:"Call List – AI-ranked leads. Try Power Dialer (lightning bolt) to auto-advance calls"},{to:"/inbox",icon:Nc,label:"Messages",badge:s,tooltip:"Messages – Use AI sparkle button to generate personalized replies in one tap"},{to:"/battleground",icon:ph,label:"Battle",tooltip:"Battleground – See live leaderboard, daily challenges, team pulse"},{to:"/more",icon:sT,label:"More",tooltip:"More – Power Features Guide, voicemail drops, settings"}];return c.jsx("nav",{className:"bottom-nav fixed bottom-0 left-0 right-0 z-30 flex items-stretch justify-around md:hidden",children:i.map(({to:l,icon:o,label:d,badge:f,tooltip:m})=>{const p=t.pathname===l||l!=="/"&&t.pathname.startsWith(l);return c.jsx(Qa,{content:m,side:"top",children:c.jsxs(Ka,{to:l,className:`nav-item flex-1 flex flex-col items-center justify-center gap-1 py-2 relative ${p?"active text-blue-600 dark:text-blue-400":"text-slate-400 dark:text-slate-500"}`,children:[c.jsxs("div",{className:"relative",children:[c.jsx(o,{className:"nav-icon",strokeWidth:p?2.5:2}),f>0&&c.jsx("span",{className:"absolute -top-1 -right-2 min-w-[18px] h-[18px] bg-red-500 text-white text-[10px] font-bold rounded-full flex items-center justify-center px-1",children:f})]}),c.jsx("span",{className:p?"font-bold":"font-semibold",children:d})]})},l)})})}const R3=[{text:"Mark hot",icon:"🔥"},{text:"Callback tomorrow",icon:"📅"},{text:"Skip",icon:"⏭️"},{text:"Note: interested in residential",icon:"📝"},{text:"Send follow-up",icon:"💬"},{text:"Idea: try morning calls",icon:"💡"}];function M3({onAction:t,currentLead:s,onSkip:i,onCall:l,onOpenSms:o,onRefresh:d}){const{user:f}=br(),[m,p]=b.useState(!1),[y,x]=b.useState(!1),[g,w]=b.useState(""),[S,T]=b.useState(!1),[N,R]=b.useState(null),[D,A]=b.useState(null),C=b.useRef(null),B=b.useRef([]),_=b.useRef(null),F=b.useRef(null),$=15e3,I=async()=>{try{const H=await navigator.mediaDevices.getUserMedia({audio:!0});if(F.current=H,"webkitSpeechRecognition"in window||"SpeechRecognition"in window){const P=window.SpeechRecognition||window.webkitSpeechRecognition,K=new P;K.continuous=!0,K.interimResults=!0,K.lang="en-AU";const ae=()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{console.log("[VoiceAssistant] Silence timeout - stopping"),K.stop()},$)};K.onresult=O=>{ae();let G="",Z="";for(let re=0;re{console.error("Speech recognition error:",O),O.error!=="no-speech"&&A("Failed to recognize speech"),x(!1),_.current&&clearTimeout(_.current)},K.onend=()=>{x(!1),H.getTracks().forEach(O=>O.stop()),_.current&&clearTimeout(_.current)},K.start(),ae(),x(!0),A(null),R(null),w(""),C.current=K}else{const P=new MediaRecorder(H);B.current=[],P.ondataavailable=K=>B.current.push(K.data),P.onstop=async()=>{H.getTracks().forEach(ae=>ae.stop());const K=new Blob(B.current,{type:"audio/webm"});try{T(!0);const ae=await It.transcribe(K);w(ae.transcript),await X(ae.transcript)}catch{A("Failed to process audio")}finally{T(!1)}},P.start(),x(!0),A(null),R(null),w("Listening..."),C.current=P}}catch(H){console.error("Microphone error:",H),A("Microphone access denied")}},z=()=>{_.current&&(clearTimeout(_.current),_.current=null),C.current&&(C.current instanceof MediaRecorder,C.current.stop(),C.current=null),F.current&&(F.current.getTracks().forEach(H=>H.stop()),F.current=null),x(!1)},X=async H=>{T(!0),A(null);try{const P=await It.voiceCommand({transcript:H,userEmail:f?.email,leadId:s?.id});if(P.success){R({intent:P.parsed.intent,confirmation:P.parsed.confirmation,confidence:P.parsed.confidence,actionResult:P.actionResult});const{frontendAction:K}=P;if(K)switch(K){case"skip":i?.();break;case"call":l?.();break;case"open_sms":o?.();break;case"refresh":d?.();break}P.actionResult&&t?.(P.actionResult),setTimeout(()=>{p(!1),R(null),w("")},2500)}else A("Could not understand command")}catch(P){A(P.message||"Failed to process command")}finally{T(!1)}},te=H=>{w(H),X(H)};return m?c.jsxs("div",{className:"fixed inset-0 z-50 flex items-end justify-center",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>p(!1)}),c.jsxs("div",{className:"relative w-full max-w-lg bg-gradient-to-b from-slate-900 to-slate-800 rounded-t-3xl overflow-hidden animate-slide-up",children:[c.jsxs("div",{className:"px-5 py-4 flex items-center justify-between border-b border-white/10",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 bg-violet-500/20 rounded-xl flex items-center justify-center",children:c.jsx(yh,{className:"w-5 h-5 text-violet-400"})}),c.jsxs("div",{children:[c.jsx("h2",{className:"text-white font-bold",children:"Voice Assistant"}),s?c.jsxs("p",{className:"text-cyan-400 text-sm",children:["Commands for: ",c.jsx("span",{className:"font-semibold",children:s.first_name||"Lead"})]}):c.jsx("p",{className:"text-slate-400 text-sm",children:"Say a command"})]})]}),c.jsx("button",{onClick:()=>p(!1),className:"p-2 text-slate-400 hover:text-white",children:c.jsx(Gt,{className:"w-6 h-6"})})]}),c.jsxs("div",{className:"p-5 space-y-4",children:[c.jsx("div",{className:"min-h-[60px] bg-white/5 rounded-2xl p-4 border border-white/10",children:g?c.jsx("p",{className:"text-white text-lg",children:g}):c.jsx("p",{className:"text-slate-500",children:"Tap the mic and speak..."})}),S&&c.jsxs("div",{className:"flex items-center gap-2 text-violet-400",children:[c.jsx(_n,{className:"w-5 h-5 animate-spin"}),c.jsx("span",{children:"Processing command..."})]}),D&&c.jsxs("div",{className:"flex items-center gap-2 bg-red-500/10 border border-red-500/30 rounded-xl p-3 text-red-400",children:[c.jsx(Mb,{className:"w-5 h-5"}),c.jsx("span",{children:D})]}),N&&c.jsxs("div",{className:`rounded-xl p-4 animate-fade-in ${N.intent==="capture_idea"?"bg-violet-500/10 border border-violet-500/30":N.intent==="mark_tier"?"bg-orange-500/10 border border-orange-500/30":N.intent==="skip_lead"?"bg-blue-500/10 border border-blue-500/30":N.intent==="schedule_callback"?"bg-cyan-500/10 border border-cyan-500/30":"bg-emerald-500/10 border border-emerald-500/30"}`,children:[c.jsxs("div",{className:`flex items-center gap-2 mb-2 ${N.intent==="capture_idea"?"text-violet-400":N.intent==="mark_tier"?"text-orange-400":N.intent==="skip_lead"?"text-blue-400":N.intent==="schedule_callback"?"text-cyan-400":"text-emerald-400"}`,children:[c.jsx(Ob,{className:"w-5 h-5"}),c.jsx("span",{className:"font-semibold",children:N.intent==="capture_idea"?"Captured!":N.intent==="skip_lead"?"Skipping...":N.intent==="call_lead"?"Calling...":N.intent==="schedule_callback"?"Scheduled!":"Done!"}),N.actionResult?.category&&c.jsx("span",{className:"text-xs px-2 py-0.5 bg-white/10 rounded-full capitalize",children:N.actionResult.category}),N.actionResult?.tier&&c.jsx("span",{className:"text-xs px-2 py-0.5 bg-white/10 rounded-full capitalize",children:N.actionResult.tier})]}),c.jsx("p",{className:"text-white",children:N.confirmation})]}),!y&&!S&&!N&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wide",children:"Try saying:"}),c.jsx("div",{className:"grid grid-cols-2 gap-2",children:R3.map((H,P)=>c.jsxs("button",{onClick:()=>te(H.text),className:"p-3 bg-white/5 hover:bg-white/10 rounded-xl text-left transition-colors",children:[c.jsx("span",{className:"text-xl mr-2",children:H.icon}),c.jsx("span",{className:"text-sm text-slate-300",children:H.text})]},P))})]})]}),c.jsx("div",{className:"p-5 pt-0",children:c.jsx("button",{onClick:y?z:I,disabled:S,className:`w-full h-16 rounded-2xl font-bold text-lg flex items-center justify-center gap-3 transition-all disabled:opacity-50 ${y?"bg-red-500 text-white animate-pulse":"bg-gradient-to-r from-violet-600 to-purple-600 text-white"}`,children:y?c.jsxs(c.Fragment,{children:[c.jsx(Tc,{className:"w-6 h-6"}),"Tap to Stop"]}):c.jsxs(c.Fragment,{children:[c.jsx(ti,{className:"w-6 h-6"}),"Tap to Talk"]})})})]})]}):c.jsx("button",{onClick:()=>p(!0),className:"fixed bottom-28 right-4 md:bottom-6 md:right-6 z-40 w-14 h-14 bg-gradient-to-br from-violet-600 to-purple-600 rounded-full shadow-lg shadow-violet-500/30 flex items-center justify-center text-white hover:scale-110 transition-transform",children:c.jsx(ti,{className:"w-6 h-6"})})}function O3(){const{user:t}=br(),[s,i]=b.useState(!1),[l,o]=b.useState(""),[d,f]=b.useState(null),[m,p]=b.useState(!1),[y,x]=b.useState(!1),[g,w]=b.useState(!1),[S,T]=b.useState(!1),N=async()=>{p(!0),T(!1);try{const C=(await ct(async()=>{const{default:$}=await import("./html2canvas.esm-DXEQVQnt.js");return{default:$}},[])).default,B=document.getElementById("bug-report-modal");B&&(B.style.display="none");const _=await C(document.body,{useCORS:!0,allowTaint:!0,scale:.5,logging:!1});B&&(B.style.display="flex");const F=_.toDataURL("image/jpeg",.7);f(F)}catch(C){console.error("Screenshot capture failed:",C),T(!0),Ji.error("Screenshot capture failed. Try uploading instead.")}finally{p(!1)}},R=C=>{const B=C.target.files?.[0];if(!B)return;if(!B.type.startsWith("image/")){Ji.error("Please upload an image file");return}const _=new FileReader;_.onload=F=>{f(F.target?.result),T(!1)},_.readAsDataURL(B)},D=async()=>{if(l.trim()){x(!0);try{const C={userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,screenSize:`${window.innerWidth}x${window.innerHeight}`},B=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),_=navigator.userAgent.match(/(Chrome|Safari|Firefox|Edge|Opera)/i)?.[1]||"Unknown",F=B?navigator.userAgent.match(/iPhone|iPad|Android/i)?.[0]||"Mobile":"Desktop";await cE.submit({description:l.trim(),pageUrl:window.location.pathname,userEmail:t?.email||"unknown",deviceInfo:`${F} / ${_}`,fullDeviceInfo:C,screenshot:d||null}),w(!0),setTimeout(()=>{i(!1),o(""),f(null),w(!1)},2e3)}catch(C){console.error("Bug report failed:",C),Ji.error("Failed to submit bug report. Please try again.")}finally{x(!1)}}},A=()=>{i(!1),o(""),f(null),w(!1)};return c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:()=>i(!0),className:"fixed bottom-32 left-4 md:bottom-6 md:left-6 z-40 w-10 h-10 bg-slate-700 hover:bg-slate-600 text-white rounded-full shadow-lg flex items-center justify-center transition-all hover:scale-110",title:"Report a bug",children:c.jsx(ly,{className:"w-5 h-5"})}),s&&c.jsxs("div",{id:"bug-report-modal",className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:A}),c.jsxs("div",{className:"relative w-full max-w-md bg-white dark:bg-slate-900 rounded-2xl shadow-2xl overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-5 py-4 bg-slate-800",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-9 h-9 bg-red-500/20 rounded-xl flex items-center justify-center",children:c.jsx(ly,{className:"w-5 h-5 text-red-400"})}),c.jsx("h2",{className:"text-white font-bold",children:"Report a Bug"})]}),c.jsx("button",{onClick:A,className:"w-8 h-8 bg-white/10 hover:bg-white/20 rounded-full flex items-center justify-center transition-colors",children:c.jsx(Gt,{className:"w-4 h-4 text-white"})})]}),c.jsx("div",{className:"p-5 space-y-4",children:g?c.jsxs("div",{className:"py-8 text-center",children:[c.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4",children:c.jsx(ba,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),c.jsx("h3",{className:"text-lg font-bold text-slate-900 dark:text-slate-100 mb-1",children:"Bug reported!"}),c.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:"We'll fix it."})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-semibold text-slate-700 dark:text-slate-300 mb-2",children:"What went wrong?"}),c.jsx("textarea",{value:l,onChange:C=>o(C.target.value),placeholder:"Describe the bug...",rows:4,className:"w-full px-4 py-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 outline-none resize-none text-slate-900 dark:text-slate-100 placeholder-slate-400",autoFocus:!0})]}),c.jsx("div",{children:d?c.jsxs("div",{className:"relative",children:[c.jsx("img",{src:d,alt:"Screenshot",className:"w-full rounded-xl border border-slate-200 dark:border-slate-700"}),c.jsx("button",{onClick:()=>f(null),className:"absolute top-2 right-2 w-8 h-8 bg-black/50 hover:bg-black/70 rounded-full flex items-center justify-center transition-colors",children:c.jsx(Gt,{className:"w-4 h-4 text-white"})})]}):c.jsxs("div",{className:"space-y-2",children:[c.jsx("button",{onClick:N,disabled:m,className:"w-full py-3 border-2 border-dashed border-slate-200 dark:border-slate-700 rounded-xl text-slate-500 dark:text-slate-400 hover:border-slate-300 dark:hover:border-slate-600 hover:text-slate-600 dark:hover:text-slate-300 transition-colors flex items-center justify-center gap-2",children:m?c.jsxs(c.Fragment,{children:[c.jsx(_n,{className:"w-5 h-5 animate-spin"}),"Capturing..."]}):c.jsxs(c.Fragment,{children:[c.jsx(aT,{className:"w-5 h-5"}),"Capture Screenshot"]})}),c.jsxs("label",{className:"w-full py-2 border border-slate-200 dark:border-slate-700 rounded-xl text-slate-500 dark:text-slate-400 hover:border-slate-300 dark:hover:border-slate-600 hover:text-slate-600 dark:hover:text-slate-300 transition-colors flex items-center justify-center gap-2 cursor-pointer text-sm",children:[c.jsx(iT,{className:"w-4 h-4"}),"Or upload image",c.jsx("input",{type:"file",accept:"image/*",onChange:R,className:"hidden"})]}),S&&c.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 text-center",children:"Auto-capture failed. Please upload a screenshot instead."})]})}),c.jsxs("div",{className:"text-xs text-slate-400 dark:text-slate-500 bg-slate-50 dark:bg-slate-800 rounded-lg px-3 py-2",children:["Page: ",window.location.pathname]}),c.jsx("button",{onClick:D,disabled:!l.trim()||y,className:"w-full py-4 bg-slate-800 hover:bg-slate-700 disabled:bg-slate-300 dark:disabled:bg-slate-700 text-white font-bold rounded-xl transition-colors flex items-center justify-center gap-2",children:y?c.jsxs(c.Fragment,{children:[c.jsx(_n,{className:"w-5 h-5 animate-spin"}),"Submitting..."]}):"Submit Bug Report"})]})})]})]})]})}const _3="https://rateright-growth-production.up.railway.app";function L3(){const{user:t}=br(),[s,i]=b.useState(!1),[l,o]=b.useState(""),[d,f]=b.useState(""),[m,p]=b.useState(!1),[y,x]=b.useState(!1),g=async()=>{if(l.trim()){p(!0);try{const{data:{session:S}}=await Nt.auth.getSession(),T=S?.access_token;if(!T){Ji.error("Please log in to submit a feature request"),p(!1);return}const N=await fetch(`${_3}/api/dev/feature`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({title:l.trim(),description:d.trim()||null,reportedBy:t?.email||"Unknown"})});if(!N.ok)throw new Error("Failed to submit");const R=await N.json();x(!0),setTimeout(()=>{i(!1),o(""),f(""),x(!1)},2e3)}catch(S){console.error("Feature request failed:",S),Ji.error("Failed to submit feature request. Please try again.")}finally{p(!1)}}},w=()=>{i(!1),o(""),f(""),x(!1)};return c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:()=>i(!0),className:"fixed bottom-44 left-4 md:bottom-16 md:left-6 z-40 w-10 h-10 bg-purple-600 hover:bg-purple-500 text-white rounded-full shadow-lg flex items-center justify-center transition-all hover:scale-110",title:"Request a feature",children:c.jsx(ac,{className:"w-5 h-5"})}),s&&c.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:w}),c.jsxs("div",{className:"relative w-full max-w-md bg-white dark:bg-slate-900 rounded-2xl shadow-2xl overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-5 py-4 bg-purple-600",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-9 h-9 bg-white/20 rounded-xl flex items-center justify-center",children:c.jsx(ac,{className:"w-5 h-5 text-white"})}),c.jsx("h2",{className:"text-white font-bold",children:"Request a Feature"})]}),c.jsx("button",{onClick:w,className:"w-8 h-8 bg-white/10 hover:bg-white/20 rounded-full flex items-center justify-center transition-colors",children:c.jsx(Gt,{className:"w-4 h-4 text-white"})})]}),c.jsx("div",{className:"p-5 space-y-4",children:y?c.jsxs("div",{className:"py-8 text-center",children:[c.jsx("div",{className:"w-16 h-16 bg-purple-100 dark:bg-purple-900 rounded-full flex items-center justify-center mx-auto mb-4",children:c.jsx(ba,{className:"w-8 h-8 text-purple-600 dark:text-purple-400"})}),c.jsx("h3",{className:"text-lg font-bold text-slate-900 dark:text-slate-100 mb-1",children:"Feature requested!"}),c.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:"Added to the queue."})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-semibold text-slate-700 dark:text-slate-300 mb-2",children:"What feature do you want?"}),c.jsx("input",{type:"text",value:l,onChange:S=>o(S.target.value),placeholder:"e.g., Add dark mode",className:"w-full px-4 py-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 outline-none text-slate-900 dark:text-slate-100 placeholder-slate-400",autoFocus:!0})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm font-semibold text-slate-700 dark:text-slate-300 mb-2",children:["Why do you need it? ",c.jsx("span",{className:"text-slate-400 dark:text-slate-500 font-normal",children:"(optional)"})]}),c.jsx("textarea",{value:d,onChange:S=>f(S.target.value),placeholder:"Describe the problem it solves...",rows:3,className:"w-full px-4 py-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 outline-none resize-none text-slate-900 dark:text-slate-100 placeholder-slate-400"})]}),c.jsx("button",{onClick:g,disabled:!l.trim()||m,className:"w-full py-4 bg-purple-600 hover:bg-purple-500 disabled:bg-slate-300 dark:disabled:bg-slate-700 text-white font-bold rounded-xl transition-colors flex items-center justify-center gap-2",children:m?c.jsxs(c.Fragment,{children:[c.jsx(_n,{className:"w-5 h-5 animate-spin"}),"Submitting..."]}):"Submit Feature Request"})]})})]})]})]})}const zt=[];for(let t=0;t<256;++t)zt.push((t+256).toString(16).slice(1));function z3(t,s=0){return(zt[t[s+0]]+zt[t[s+1]]+zt[t[s+2]]+zt[t[s+3]]+"-"+zt[t[s+4]]+zt[t[s+5]]+"-"+zt[t[s+6]]+zt[t[s+7]]+"-"+zt[t[s+8]]+zt[t[s+9]]+"-"+zt[t[s+10]]+zt[t[s+11]]+zt[t[s+12]]+zt[t[s+13]]+zt[t[s+14]]+zt[t[s+15]]).toLowerCase()}let vf;const B3=new Uint8Array(16);function V3(){if(!vf){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");vf=crypto.getRandomValues.bind(crypto)}return vf(B3)}const U3=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ub={randomUUID:U3};function P3(t,s,i){t=t||{};const l=t.random??t.rng?.()??V3();if(l.length<16)throw new Error("Random bytes length must be >= 16");return l[6]=l[6]&15|64,l[8]=l[8]&63|128,z3(l)}function H3(t,s,i){return ub.randomUUID&&!t?ub.randomUUID():P3(t)}const q3=()=>{let t=sessionStorage.getItem("intelligence_session_id");return t||(t=H3(),sessionStorage.setItem("intelligence_session_id",t)),t},I3=()=>{const t=window.innerWidth;return t<768?"mobile":t<1024?"tablet":"desktop"};let or=[],wf=null;const vc=async()=>{if(or.length===0)return;const t=[...or];or=[];try{await fetch("/api/intelligence/track-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({events:t})})}catch(s){console.debug("Failed to track events:",s)}},Bs=t=>{or.push({...t,session_id:q3(),device_type:I3(),created_at:new Date().toISOString()}),wf&&clearTimeout(wf),or.length>=10?vc():wf=setTimeout(vc,2e3)};typeof window<"u"&&(window.addEventListener("beforeunload",vc),window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&vc()}));function $3(t){const s=b.useRef(Date.now()),i=b.useRef(!1),l=b.useRef({});b.useEffect(()=>(t&&!i.current&&(i.current=!0,s.current=Date.now(),Bs({event_type:"page_view",event_name:`${t}_view`,page:t})),()=>{if(t&&i.current){const x=Date.now()-s.current;Bs({event_type:"page_leave",event_name:`${t}_leave`,page:t,duration_ms:x})}}),[t]);const o=b.useCallback((x,g={})=>{Bs({event_type:"button_click",event_name:`${x}_click`,page:t,element:x,context:g});const w=Date.now(),S=`${t}_${x}`;l.current[S]||(l.current[S]=[]),l.current[S].push(w),l.current[S]=l.current[S].filter(T=>w-T<1e3),l.current[S].length>=3&&(Bs({event_type:"rage_click",event_name:`${x}_rage_click`,page:t,element:x,context:{click_count:l.current[S].length}}),l.current[S]=[])},[t]),d=b.useCallback((x,g={})=>{const w=Date.now()-s.current;Bs({event_type:"flow_complete",event_name:`${x}_complete`,page:t,duration_ms:w,context:g})},[t]),f=b.useCallback((x,g,w={})=>{const S=Date.now()-s.current;Bs({event_type:"flow_abandon",event_name:`${x}_abandon`,page:t,duration_ms:S,context:{...w,abandoned_at_step:g}})},[t]),m=b.useCallback((x,g,w={})=>{Bs({event_type:"error",event_name:`${x}_error`,page:t,context:{error_message:g,...w}})},[t]),p=b.useCallback((x,g,w={})=>{Bs({event_type:x,event_name:g,page:t,context:w})},[t]),y=b.useCallback((x,g,w,S={})=>{Bs({event_type:"api_call",event_name:`api_${x.replace(/\//g,"_")}`,page:t,duration_ms:g,context:{endpoint:x,success:w,...S}})},[t]);return{trackClick:o,trackFlowComplete:d,trackFlowAbandon:f,trackError:m,trackEvent:p,trackApiCall:y}}function G3({onRecordingComplete:t}){const[s,i]=b.useState(!1),[l,o]=b.useState(0),d=b.useRef(null),f=b.useRef([]),m=b.useRef(null),p=async()=>{try{const g=await navigator.mediaDevices.getUserMedia({audio:!0}),w=new MediaRecorder(g);d.current=w,f.current=[],w.ondataavailable=S=>{S.data.size>0&&f.current.push(S.data)},w.onstop=()=>{const S=new Blob(f.current,{type:"audio/webm"});g.getTracks().forEach(T=>T.stop()),t&&t(S,l)},w.start(),i(!0),o(0),m.current=setInterval(()=>{o(S=>S+1)},1e3)}catch(g){console.error("Failed to start recording:",g),alert("Could not access microphone. Please allow microphone access.")}},y=()=>{d.current&&s&&(d.current.stop(),clearInterval(m.current),i(!1))},x=g=>{const w=Math.floor(g/60),S=g%60;return`${w}:${S.toString().padStart(2,"0")}`};return c.jsx("button",{onClick:s?y:p,className:`voice-recorder w-full p-4 flex items-center justify-center gap-3 ${s?"recording":""}`,children:s?c.jsxs(c.Fragment,{children:[c.jsx(lT,{className:"w-6 h-6 text-red-600 dark:text-red-500 fill-red-600 dark:fill-red-500"}),c.jsxs("span",{className:"text-base font-semibold text-red-700 dark:text-red-300",children:["Recording... ",x(l)]})]}):c.jsxs(c.Fragment,{children:[c.jsx(ti,{className:"w-6 h-6 text-slate-500 dark:text-slate-400"}),c.jsx("span",{className:"text-base font-semibold text-slate-600 dark:text-slate-300",children:"Tap to record voice note"})]})})}function Y3({selected:t,onChange:s}){const i=[{label:"Today",value:"today"},{label:"Tomorrow",value:"tomorrow"},{label:"Next Week",value:"next_week"},{label:"Pick...",value:"custom"}],l=d=>{const f=new Date;switch(d){case"today":return f;case"tomorrow":const m=new Date(f);return m.setDate(m.getDate()+1),m;case"next_week":const p=new Date(f);return p.setDate(p.getDate()+7),p;default:return null}},o=d=>{if(d==="custom"){const f=prompt("Enter date (YYYY-MM-DD):");f&&s({value:"custom",date:new Date(f)})}else s({value:d,date:l(d)})};return c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-300",children:"When to follow up?"}),c.jsx("div",{className:"flex gap-2",children:i.map(d=>c.jsx("button",{onClick:()=>o(d.value),className:`date-btn flex-1 py-3 px-2 text-sm ${t===d.value?"selected":"text-slate-700 dark:text-slate-300"}`,children:d.value==="custom"?c.jsx(rT,{className:"w-4 h-4 mx-auto"}):d.label},d.value))})]})}const F3=["Carpenter","Electrician","Plumber","Labourer","Concretor","Scaffolder","Steel Fixer","Formworker","Painter","Other"];let X3=1;const db=()=>X3++;function K3({referringLead:t,onClose:s,onSuccess:i}){const[l,o]=b.useState([{id:db(),name:"",phone:"",trade:""}]),[d,f]=b.useState(!1),[m,p]=b.useState(!1),[y,x]=b.useState([]),g=()=>{l.length<5&&o([...l,{id:db(),name:"",phone:"",trade:""}])},w=A=>{l.length>1&&o(l.filter(C=>C.id!==A))},S=(A,C,B)=>{const _=[...l];_[A][C]=B,o(_)},T=A=>{const C=A.replace(/\D/g,"");return C.length<=4?C:C.length<=7?`${C.slice(0,4)} ${C.slice(4)}`:`${C.slice(0,4)} ${C.slice(4,7)} ${C.slice(7,10)}`},N=A=>{const C=A.replace(/\D/g,"");return C.startsWith("61")&&C.length===11?{valid:!0,phone:`+${C}`}:C.startsWith("0")&&C.length===10?{valid:!0,phone:`+61${C.slice(1)}`}:C.length===9&&!C.startsWith("0")?{valid:!0,phone:`+61${C}`}:{valid:!1,phone:A,error:"Invalid phone number. Use format: 04XX XXX XXX"}},R=async()=>{const A=l.filter(_=>_.name.trim()&&_.phone.trim());if(A.length===0){alert("Please enter at least one referral with name and phone");return}const C=[],B=A.map(_=>{const F=N(_.phone);return F.valid||C.push(`${_.name}: ${F.error}`),{..._,normalizedPhone:F.phone,phoneValid:F.valid}});if(C.length>0){x(C);return}x([]),f(!0);try{const _=t&&`${t.first_name||""} ${t.last_name||""}`.trim()||"Unknown",F=await Promise.allSettled(B.map(async z=>{const X=z.name.trim().split(" "),te=X[0],H=X.slice(1).join(" ")||"";return Tr.create({first_name:te,last_name:H,phone:z.normalizedPhone,type:"worker",source:"worker_referral",status:"new",score:70,referred_by_lead_id:t?.id||null,referral_context:`Referred by ${_} during call`,is_hot_referral:!0,metadata:{trade:z.trade||"Unknown",referred_by_name:_,created_via:"call_outcome_referral"}})})),$=F.filter(z=>z.status==="fulfilled"),I=F.filter(z=>z.status==="rejected");if(I.length>0&&$.length===0){const z=I.map((X,te)=>`${B[te].name}: ${X.reason?.message||"Failed"}`);x(z);return}I.length>0&&console.warn("Some referrals failed:",I),p(!0),setTimeout(()=>{i?.($.length),s()},1e3)}catch(_){console.error("Failed to create referrals:",_),x([_.message||"An unexpected error occurred"])}finally{f(!1)}},D=l.some(A=>A.name.trim()&&A.phone.trim());return m?c.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),c.jsxs("div",{className:"relative bg-gradient-to-br from-green-500 to-emerald-600 rounded-2xl p-8 text-center animate-scale-in",children:[c.jsx("div",{className:"w-16 h-16 bg-white/20 rounded-full flex items-center justify-center mx-auto mb-4",children:c.jsx(ba,{className:"w-8 h-8 text-white"})}),c.jsx("h3",{className:"text-xl font-bold text-white mb-2",children:"Referrals Saved!"}),c.jsx("p",{className:"text-white/80",children:"Added to call list as hot leads"})]})]}):c.jsxs("div",{className:"fixed inset-0 z-50 flex items-end sm:items-center justify-center p-0 sm:p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:s}),c.jsxs("div",{className:"relative w-full sm:max-w-md bg-white rounded-t-3xl sm:rounded-2xl overflow-hidden max-h-[90vh] flex flex-col",children:[c.jsx("div",{className:"bg-gradient-to-r from-purple-600 to-pink-600 px-5 py-4",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center",children:c.jsx(ic,{className:"w-5 h-5 text-white"})}),c.jsxs("div",{children:[c.jsx("h2",{className:"text-white font-bold text-lg",children:"Capture Referrals"}),c.jsxs("p",{className:"text-white/70 text-sm",children:["From ",t?.first_name||"this lead"]})]})]}),c.jsx("button",{onClick:s,className:"w-10 h-10 bg-white/20 hover:bg-white/30 rounded-full flex items-center justify-center transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-white"})})]})}),c.jsx("div",{className:"px-5 py-3 bg-purple-50 border-b border-purple-100",children:c.jsxs("p",{className:"text-sm text-purple-700 font-medium flex items-center gap-2",children:[c.jsx(_b,{className:"w-4 h-4"}),'"Know any other tradies looking for work?"']})}),y.length>0&&c.jsx("div",{className:"px-5 py-3 bg-red-50 border-b border-red-100",children:c.jsxs("div",{className:"flex items-start gap-2 text-red-700",children:[c.jsx(Mb,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),c.jsx("div",{className:"text-sm",children:y.map((A,C)=>c.jsx("p",{children:A},C))})]})}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[l.map((A,C)=>c.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 relative",children:[l.length>1&&c.jsx("button",{onClick:()=>w(A.id),className:"absolute top-2 right-2 w-6 h-6 bg-slate-200 hover:bg-red-100 rounded-full flex items-center justify-center text-slate-400 hover:text-red-500 transition-colors",children:c.jsx(Gt,{className:"w-3 h-3"})}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{children:[c.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-semibold text-slate-500 mb-1.5",children:[c.jsx(Af,{className:"w-3.5 h-3.5"}),"Name"]}),c.jsx("input",{type:"text",value:A.name,onChange:B=>S(C,"name",B.target.value),placeholder:"John Smith",className:"w-full px-4 py-2.5 rounded-xl border border-slate-200 focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 outline-none text-sm"})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-semibold text-slate-500 mb-1.5",children:[c.jsx(ni,{className:"w-3.5 h-3.5"}),"Phone"]}),c.jsx("input",{type:"tel",value:A.phone,onChange:B=>S(C,"phone",T(B.target.value)),placeholder:"0412 345 678",maxLength:12,className:"w-full px-4 py-2.5 rounded-xl border border-slate-200 focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 outline-none text-sm"})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-semibold text-slate-500 mb-1.5",children:[c.jsx(Eb,{className:"w-3.5 h-3.5"}),"Trade (optional)"]}),c.jsxs("select",{value:A.trade,onChange:B=>S(C,"trade",B.target.value),className:"w-full px-4 py-2.5 rounded-xl border border-slate-200 focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 outline-none text-sm bg-white",children:[c.jsx("option",{value:"",children:"Select trade..."}),F3.map(B=>c.jsx("option",{value:B,children:B},B))]})]})]})]},A.id)),l.length<5&&c.jsxs("button",{onClick:g,className:"w-full py-3 border-2 border-dashed border-slate-200 rounded-xl text-slate-500 font-medium hover:border-purple-300 hover:text-purple-600 transition-colors flex items-center justify-center gap-2",children:[c.jsx(Af,{className:"w-4 h-4"}),"Add Another Referral"]})]}),c.jsx("div",{className:"p-4 border-t border-slate-100 bg-slate-50",children:c.jsxs("div",{className:"flex gap-3",children:[c.jsx("button",{onClick:s,className:"flex-1 py-3.5 bg-slate-100 text-slate-700 font-semibold rounded-xl hover:bg-slate-200 transition-colors",children:"Skip"}),c.jsxs("button",{onClick:R,disabled:d||!D,className:"flex-1 py-3.5 bg-gradient-to-r from-purple-600 to-pink-600 text-white font-bold rounded-xl transition-all disabled:opacity-50 flex items-center justify-center gap-2",children:[d?c.jsx(_n,{className:"w-5 h-5 animate-spin"}):c.jsx(ba,{className:"w-5 h-5"}),d?"Saving...":"Save Referrals"]})]})})]})]})}const Q3={converted:"success",interested:"interested",callback_scheduled:"callback_scheduled",no_answer:"no_answer",not_interested:"not_interested"},Sf=[{id:"interested",emoji:"1F60A",label:"Interested",color:"bg-green-50 dark:bg-green-900/30 border-green-200 dark:border-green-700 text-green-700 dark:text-green-300"},{id:"callback_scheduled",emoji:"1F610",label:"Callback",color:"bg-amber-50 dark:bg-amber-900/30 border-amber-200 dark:border-amber-700 text-amber-700 dark:text-amber-300"},{id:"no_answer",emoji:"1F61E",label:"No Answer",color:"bg-slate-50 dark:bg-slate-700 border-slate-200 dark:border-slate-600 text-slate-700 dark:text-slate-300"},{id:"converted",emoji:"1F389",label:"CONVERTED",color:"bg-emerald-50 dark:bg-emerald-900/30 border-emerald-200 dark:border-emerald-700 text-emerald-700 dark:text-emerald-300"},{id:"not_interested",emoji:"274C",label:"Not Interested",color:"bg-red-50 dark:bg-red-900/30 border-red-200 dark:border-red-700 text-red-700 dark:text-red-300"}];function Z3({lead:t,onClose:s,onComplete:i}){const{transcript:l,autoSummary:o,generatingSummary:d,clearCallData:f,scriptSessionId:m,callSid:p,callDuration:y}=kc(),{handleXPResponse:x}=LE(),{trackClick:g,trackFlowComplete:w,trackFlowAbandon:S,trackError:T}=$3("call_outcome"),[N,R]=b.useState(null),[D,A]=b.useState(null),[C,B]=b.useState(null),[_,F]=b.useState(""),[$,I]=b.useState(!1),[z,X]=b.useState(!1),[te,H]=b.useState(!1),[P,K]=b.useState(null),[ae,O]=b.useState(!1),[G,Z]=b.useState(!1),[re,ue]=b.useState(0),[je,Ne]=b.useState([]),[se,ce]=b.useState(!0),[ne,de]=b.useState(null);b.useEffect(()=>{(async()=>{try{const ze=await Rx.list("sms");if(ze.sequences?.length>0){Ne(ze.sequences);const st=t?.type||t?.metadata?.lead_type;let on;st==="contractor"?on=ze.sequences.find(Wt=>Wt.name?.toLowerCase().includes("contractor")):on=ze.sequences.find(Wt=>Wt.name?.toLowerCase().includes("worker")),de(on?.id||ze.sequences[0]?.id)}}catch(ze){console.error("Failed to fetch sequences:",ze)}})()},[t?.type,t?.metadata?.lead_type]);const oe=b.useCallback(()=>{if(!N&&!_&&!l){s();return}O(!0)},[N,_,l,s]);b.useEffect(()=>{o?.summary&&!_?(F(o.summary),o.status_recommendation&&Sf.find(ze=>ze.id===o.status_recommendation)&&R(o.status_recommendation)):l&&!_&&!o&&F(l)},[o,l]);const ee=b.useCallback(async()=>{if(N){g("save_call_outcome",{outcome:N,lead_id:t?.id}),I(!0);try{const me=await oE.log({leadId:t.id,outcome:N,durationSeconds:y||0,notes:_||C?.transcript||"",followUpAt:D?.date?.toISOString(),aiSummary:o,transcript:l,callSid:p});if(me.xp&&(K(me.xp),x(me.xp)),m)try{const st=Q3[N]||N;await hc.endSession(m,{outcome:st,notes:l?`Auto-transcript: ${l.slice(0,500)}...`:null})}catch(st){console.error("Failed to end script session:",st)}if(N==="no_answer"&&se&&ne&&t?.id)try{await Rx.enroll(ne,t.id),console.log(`Enrolled lead ${t.id} in sequence ${ne}`)}catch(st){console.error("Failed to enroll in sequence:",st)}f?.();const ze=me.durationSeconds||y||0;w("call_logged",{outcome:N,lead_id:t?.id,duration:ze}),me.xp?setTimeout(()=>i(N,ze),1500):i(N,ze)}catch(me){console.error("Failed to log call:",me),console.error("Lead ID:",t?.id,"Outcome:",N),T("call_log_failed",me.message,{lead_id:t?.id,outcome:N}),Ji.error(`Failed to save: ${me.message||"Unknown error"}`)}finally{I(!1)}}},[N,t,y,_,C,D,o,l,p,m,se,ne,g,w,T,x,f,i]),ge=b.useCallback(async(me,ze)=>{B({blob:me,duration:ze,transcript:""}),X(!0);try{const on=(await It.transcribe(me)).transcript||"Voice note recorded";B({blob:me,duration:ze,transcript:on}),F(Wt=>(Wt?Wt+` public/assets/index-M3mvPwS8.js- public/assets/index-M3mvPwS8.js-`:"")+on)}catch(st){console.error("Transcription failed:",st),B({blob:me,duration:ze,transcript:"Voice note (transcription failed)"})}finally{X(!1)}},[]),Ee=me=>String.fromCodePoint(parseInt(me,16)),wt=N==="callback_scheduled"||N==="interested";return c.jsxs(c.Fragment,{children:[c.jsx(Le.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/40 z-40",onClick:oe}),c.jsxs(Le.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:25,stiffness:300},className:"fixed bottom-0 left-0 right-0 z-50 bg-white dark:bg-slate-800 bottom-sheet max-h-[85vh] overflow-y-auto",children:[c.jsx("div",{className:"flex justify-center pt-3 pb-2",children:c.jsx("div",{className:"w-10 h-1 bg-slate-300 dark:bg-slate-600 rounded-full"})}),c.jsx("button",{onClick:oe,className:"absolute top-4 right-4 p-2 text-slate-400 hover:text-slate-600 dark:hover:text-slate-300",children:c.jsx(Gt,{className:"w-6 h-6"})}),c.jsxs("div",{className:"px-5 pb-8",children:[c.jsxs("h2",{className:"text-xl font-bold text-slate-900 dark:text-slate-100 text-center mb-4",children:["How did it go with ",t.first_name||"them","?"]}),d&&c.jsxs("div",{className:"mb-4 p-3 bg-violet-50 dark:bg-violet-900/30 border border-violet-200 dark:border-violet-700 rounded-xl flex items-center gap-3",children:[c.jsx(_n,{className:"w-5 h-5 text-violet-600 dark:text-violet-400 animate-spin"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-semibold text-violet-700 dark:text-violet-300",children:"AI analyzing your call..."}),c.jsx("p",{className:"text-xs text-violet-600 dark:text-violet-400",children:"Generating summary from transcript"})]})]}),o&&!d&&c.jsxs("div",{className:"mb-4 p-3 bg-emerald-50 dark:bg-emerald-900/30 border border-emerald-200 dark:border-emerald-700 rounded-xl",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx(_b,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400"}),c.jsx("span",{className:"text-sm font-bold text-emerald-700 dark:text-emerald-300",children:"AI Summary Ready"}),o.score_adjustment!==0&&c.jsxs("span",{className:`ml-auto text-xs font-bold px-2 py-0.5 rounded-full ${o.score_adjustment>0?"bg-emerald-100 dark:bg-emerald-800 text-emerald-700 dark:text-emerald-300":"bg-red-100 dark:bg-red-800 text-red-700 dark:text-red-300"}`,children:[o.score_adjustment>0?"+":"",o.score_adjustment," pts"]})]}),o.next_step&&c.jsxs("p",{className:"text-xs text-emerald-600 dark:text-emerald-400 mb-1",children:[c.jsx("span",{className:"font-semibold",children:"Next:"})," ",o.next_step]}),o.coaching_note&&c.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400 italic",children:["💡 ",o.coaching_note]})]}),l&&l.length>10&&c.jsxs("div",{className:"mb-4",children:[c.jsxs("button",{onClick:()=>H(!te),className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-1",children:[c.jsx(ti,{className:"w-3 h-3"}),te?"Hide":"Show"," call transcript (",l.split(" ").length," words)"]}),te&&c.jsx("div",{className:"mt-2 p-3 bg-slate-50 dark:bg-slate-700 rounded-lg max-h-32 overflow-y-auto",children:c.jsx("p",{className:"text-xs text-slate-600 dark:text-slate-300 leading-relaxed",children:l})})]}),c.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:Sf.slice(0,3).map(me=>c.jsxs("button",{onClick:()=>R(me.id),className:`outcome-btn flex flex-col items-center gap-2 p-4 rounded-2xl border-2 transition-all ${N===me.id?"selected "+me.color:"bg-white dark:bg-slate-700 border-slate-100 dark:border-slate-600"}`,children:[c.jsx("span",{className:"text-3xl",children:Ee(me.emoji)}),c.jsx("span",{className:"text-sm font-semibold",children:me.label})]},me.id))}),c.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:Sf.slice(3).map(me=>c.jsxs("button",{onClick:()=>R(me.id),className:`outcome-btn flex flex-col items-center gap-2 p-4 rounded-2xl border-2 transition-all ${N===me.id?"selected "+me.color:"bg-white dark:bg-slate-700 border-slate-100 dark:border-slate-600"}`,children:[c.jsx("span",{className:"text-3xl",children:Ee(me.emoji)}),c.jsx("span",{className:"text-sm font-semibold",children:me.label})]},me.id))}),N==="no_answer"&&je.length>0&&c.jsxs("div",{className:"mb-4 p-3 bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-900/30 dark:to-indigo-900/30 border border-blue-200 dark:border-blue-700 rounded-xl",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(oT,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),c.jsx("span",{className:"text-sm font-semibold text-blue-900 dark:text-blue-200",children:"Start follow-up sequence?"})]}),c.jsx("button",{onClick:()=>ce(!se),className:`relative w-12 h-6 rounded-full transition-colors ${se?"bg-blue-600":"bg-slate-300 dark:bg-slate-600"}`,children:c.jsx("span",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-transform ${se?"left-7":"left-1"}`})})]}),se&&c.jsxs("div",{className:"mt-2",children:[c.jsxs("div",{className:"relative",children:[c.jsx("select",{value:ne||"",onChange:me=>de(me.target.value),className:"w-full p-2 pr-8 text-sm bg-white dark:bg-slate-700 border border-blue-200 dark:border-blue-600 rounded-lg appearance-none focus:outline-none focus:border-blue-400 dark:text-slate-200",children:je.map(me=>c.jsxs("option",{value:me.id,children:[me.name," (",me.steps?.length||0," steps)"]},me.id))}),c.jsx(mh,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"})]}),c.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-1",children:"Auto-sends SMS follow-ups over 7 days. Pauses if they reply."})]})]}),c.jsxs("div",{className:"mb-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("label",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:"Notes"}),(o||l)&&c.jsxs("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 flex items-center gap-1",children:[c.jsx(Ob,{className:"w-3 h-3"}),"Auto-filled from call"]})]}),c.jsx("textarea",{value:_,onChange:me=>F(me.target.value),placeholder:"Notes will be auto-filled from your call transcript...",className:"w-full p-4 border-2 border-slate-200 dark:border-slate-600 bg-white dark:bg-slate-700 rounded-xl resize-none text-sm text-slate-900 dark:text-slate-100 focus:border-blue-500 focus:outline-none placeholder:text-slate-400",rows:3})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mb-2",children:"Add voice note (optional)"}),c.jsx(G3,{onRecordingComplete:ge}),z&&c.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-blue-600 dark:text-blue-400",children:[c.jsx(_n,{className:"w-4 h-4 animate-spin"}),c.jsx("span",{className:"text-sm font-medium",children:"Transcribing..."})]}),C&&!z&&c.jsxs("div",{className:"mt-2 p-3 bg-green-50 dark:bg-green-900/30 rounded-xl",children:[c.jsxs("p",{className:"text-xs text-green-600 dark:text-green-400 font-medium mb-1",children:["Voice note (",C.duration,"s)"]}),C.transcript&&c.jsx("p",{className:"text-sm text-slate-700 dark:text-slate-300",children:C.transcript})]})]}),(t.type==="worker"||N==="interested"||N==="converted")&&c.jsx("div",{className:"mb-4",children:re>0?c.jsxs("div",{className:"p-3 bg-purple-50 dark:bg-purple-900/30 border border-purple-200 dark:border-purple-700 rounded-xl flex items-center gap-3",children:[c.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-800 rounded-full flex items-center justify-center",children:c.jsx(ic,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),c.jsxs("div",{className:"flex-1",children:[c.jsxs("p",{className:"text-sm font-semibold text-purple-700 dark:text-purple-300",children:[re," referral",re>1?"s":""," captured!"]}),c.jsx("p",{className:"text-xs text-purple-500 dark:text-purple-400",children:"Added to call list as hot leads"})]}),c.jsx("button",{onClick:()=>Z(!0),className:"text-xs text-purple-600 dark:text-purple-400 font-semibold hover:underline",children:"Add More"})]}):c.jsxs("button",{onClick:()=>Z(!0),className:"w-full p-3 bg-gradient-to-r from-purple-50 to-pink-50 dark:from-purple-900/30 dark:to-pink-900/30 border-2 border-dashed border-purple-200 dark:border-purple-700 rounded-xl text-purple-700 dark:text-purple-300 font-medium hover:border-purple-400 dark:hover:border-purple-500 transition-colors flex items-center justify-center gap-2",children:[c.jsx(ic,{className:"w-5 h-5"}),c.jsx("span",{children:"Know other tradies? Capture referrals"})]})}),wt&&c.jsx("div",{className:"mb-6",children:c.jsx(Y3,{selected:D?.value,onChange:A})}),P&&c.jsxs(Le.div,{initial:{opacity:0,y:20,scale:.8},animate:{opacity:1,y:0,scale:1},className:"mb-4 p-4 bg-gradient-to-r from-amber-400 to-yellow-400 rounded-xl text-center",children:[c.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[c.jsx($i,{className:"w-6 h-6 text-amber-900"}),c.jsxs("span",{className:"text-2xl font-black text-amber-900",children:["+",P.awarded," XP"]})]}),P.streakBonus>0&&c.jsxs("p",{className:"text-xs font-semibold text-amber-800",children:["🔥 +",P.streakBonus," streak bonus!"]}),P.levelUp&&c.jsxs("p",{className:"text-sm font-bold text-amber-900 mt-1",children:["🎉 Level Up! You're now ",P.levelName,"!"]})]}),c.jsx("button",{onClick:ee,disabled:!N||$||d||P,className:`w-full py-4 rounded-xl font-bold text-lg transition-all ${P?"bg-green-600 text-white":N&&!d?"bg-blue-600 text-white active:scale-[0.98]":"bg-slate-100 dark:bg-slate-700 text-slate-400"} ${$?"opacity-50":""}`,children:P?"✓ SAVED!":$?"Saving...":d?"Waiting for AI...":"SAVE & NEXT LEAD"})]})]}),ae&&c.jsxs(Le.div,{initial:{opacity:0},animate:{opacity:1},className:"fixed inset-0 z-[60] flex items-center justify-center p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>O(!1)}),c.jsxs(Le.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"relative bg-white dark:bg-slate-800 rounded-2xl p-6 max-w-sm w-full shadow-xl",children:[c.jsx("h3",{className:"text-lg font-bold text-slate-900 dark:text-slate-100 mb-2",children:"Discard call data?"}),c.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400 mb-4",children:"This call won't be saved. The transcript and notes will be lost."}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx("button",{onClick:()=>O(!1),className:"flex-1 py-3 bg-slate-100 dark:bg-slate-700 text-slate-700 dark:text-slate-300 font-semibold rounded-xl hover:bg-slate-200 dark:hover:bg-slate-600",children:"Go Back"}),c.jsx("button",{onClick:()=>{S("call_outcome","discard",{lead_id:t?.id,had_transcript:!!l}),O(!1),f?.(),s()},className:"flex-1 py-3 bg-red-500 text-white font-semibold rounded-xl hover:bg-red-600",children:"Discard"})]})]})]}),G&&c.jsx(K3,{referringLead:t,onClose:()=>Z(!1),onSuccess:me=>{ue(ze=>ze+me),Z(!1)}})]})}const J3=(t,s)=>{try{const i=new(window.AudioContext||window.webkitAudioContext);t.current=i;const l=()=>{if(!t.current||t.current.state==="closed")return;const d=i.createOscillator(),f=i.createGain();d.connect(f),f.connect(i.destination),d.frequency.value=440,d.type="sine",f.gain.setValueAtTime(.3,i.currentTime),f.gain.exponentialRampToValueAtTime(.01,i.currentTime+.4),d.start(i.currentTime),d.stop(i.currentTime+.4),setTimeout(()=>{if(!t.current||t.current.state==="closed")return;const m=i.createOscillator(),p=i.createGain();m.connect(p),p.connect(i.destination),m.frequency.value=480,m.type="sine",p.gain.setValueAtTime(.3,i.currentTime),p.gain.exponentialRampToValueAtTime(.01,i.currentTime+.4),m.start(i.currentTime),m.stop(i.currentTime+.4)},100)};l();const o=setInterval(l,2e3);return s.current=o,()=>{clearInterval(o),i.close()}}catch(i){console.log("Could not play ringtone:",i)}},fb=(t,s)=>{s.current&&(clearInterval(s.current),s.current=null),t.current&&t.current.state!=="closed"&&(t.current.close(),t.current=null)};function W3({onCallAccepted:t}){const{acceptInboundCall:s,activeLead:i}=kc(),[l,o]=b.useState(null),[d,f]=b.useState(!1),[m,p]=b.useState(null),[y,x]=b.useState(null),[g,w]=b.useState(null),[S,T]=b.useState(null),[N,R]=b.useState("idle"),[D,A]=b.useState(0),[C,B]=b.useState(!1),[_,F]=b.useState(!1),[$,I]=b.useState(null),z=b.useRef(null),X=b.useRef(null),te=b.useRef(null),H=b.useRef(null),P=b.useRef(null),K=b.useRef(null),ae=b.useRef(!1);b.useEffect(()=>(O(),()=>{z.current&&(console.log("[IncomingCall] Destroying device on unmount"),z.current.destroy()),fb(te,H)}),[]),b.useEffect(()=>{C&&!i&&!_&&console.log("[IncomingCallHandler] CallContext cleared activeLead, checking for outcome sheet")},[i,C,_]),b.useEffect(()=>{N==="ringing"?J3(te,H):fb(te,H)},[N]),b.useEffect(()=>(N==="in-progress"?(K.current=Date.now(),P.current=setInterval(()=>{A(Math.floor((Date.now()-K.current)/1e3))},1e3)):P.current&&(clearInterval(P.current),P.current=null),()=>{P.current&&clearInterval(P.current)}),[N]);const O=async()=>{try{console.log("[IncomingCall] Getting voice token...");const{token:ce,identity:ne}=await nc.getToken();console.log("[IncomingCall] Got token for identity:",ne);const de=new Cb(ce,{logLevel:"debug",codecPreferences:["opus","pcmu"],edge:"ashburn"});de.on("registered",()=>{console.log("[IncomingCall] ✅ Device registered successfully!"),f(!0),p(null)}),de.on("unregistered",()=>{console.log("[IncomingCall] Device unregistered"),f(!1),setTimeout(()=>{de.state==="unregistered"?(console.log("[IncomingCall] Attempting to re-register..."),de.register().catch(oe=>{console.error("[IncomingCall] Re-registration failed:",oe)})):console.log("[IncomingCall] Device in state:",de.state,"- skipping re-register")},1e3)}),de.on("error",oe=>{console.error("[IncomingCall] Device error:",oe),p(oe.message||"Device error")}),de.on("tokenWillExpire",()=>{console.log("[IncomingCall] Token expiring, refreshing..."),Z(de)}),de.on("incoming",async oe=>{console.log("[IncomingCall] 📞 INCOMING CALL from:",oe.parameters.From),B(!1),ae.current=!1,R("ringing"),x(oe),X.current=oe;const ee=oe.parameters.From;if(w({phone:ee,name:null}),ee)try{const ge=await nc.lookupCaller(ee);ge.lead&&(T(ge.lead),w({phone:ee,name:`${ge.lead.first_name||""} ${ge.lead.last_name||""}`.trim()}))}catch(ge){console.log("[IncomingCall] Could not look up caller:",ge)}oe.on("accept",()=>{console.log("[IncomingCall] Call accepted"),R("in-progress")}),oe.on("disconnect",()=>{console.log("[IncomingCall] Call disconnected, callAcceptedRef:",ae.current),R("ended"),ae.current||(console.log("[IncomingCall] Call ended without being accepted by context, resetting"),G())}),oe.on("cancel",()=>{console.log("[IncomingCall] Call cancelled by caller"),G()}),oe.on("reject",()=>{console.log("[IncomingCall] Call rejected"),G()})}),await de.register(),z.current=de,o(de)}catch(ce){console.error("[IncomingCall] Failed to initialize:",ce),p(ce.message||"Failed to initialize")}},G=()=>{x(null),w(null),T(null),R("idle"),A(0),B(!1),ae.current=!1,F(!1),I(null)},Z=async ce=>{try{const{token:ne}=await nc.getToken();ce.updateToken(ne),console.log("[IncomingCall] Token refreshed")}catch(ne){console.error("[IncomingCall] Failed to refresh token:",ne)}},re=()=>{X.current&&(X.current.accept(),s(X.current,S,ce=>{console.log("[IncomingCallHandler] Call ended via context, duration:",ce);const ne=S||{id:null,first_name:"Unknown",last_name:"Caller",phone:g?.phone||"Unknown",isUnknownCaller:!0};I(ne),F(!0)}),B(!0),ae.current=!0,t?.(X.current,g,S))},ue=()=>{X.current&&(X.current.reject(),G())},je=()=>{X.current&&X.current.disconnect()},Ne=ce=>{const ne=Math.floor(ce/60),de=ce%60;return`${ne}:${de.toString().padStart(2,"0")}`},se=ce=>{if(!ce)return null;const ne=new Date(ce),oe=Math.floor((new Date-ne)/(1e3*60*60*24));return oe===0?"Today":oe===1?"Yesterday":oe<7?`${oe} days ago`:ne.toLocaleDateString()};return _&&$?c.jsx(Z3,{lead:$,onClose:()=>G(),onComplete:()=>G()}):C||!y||N==="idle"?null:c.jsx(si,{children:c.jsxs(Le.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[100] bg-gradient-to-b from-slate-900 via-slate-800 to-slate-900",children:[N==="ringing"&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center overflow-hidden",children:[1,2,3].map(ce=>c.jsx(Le.div,{className:"absolute w-64 h-64 rounded-full border-2 border-green-500/30",initial:{scale:.8,opacity:.5},animate:{scale:2.5,opacity:0},transition:{duration:2,repeat:1/0,delay:ce*.6,ease:"easeOut"}},ce))}),c.jsxs("div",{className:"relative h-full flex flex-col items-center justify-center px-6",children:[c.jsx(Le.div,{initial:{y:-20,opacity:0},animate:{y:0,opacity:1},className:"mb-8",children:c.jsxs("div",{className:`flex items-center gap-2 px-4 py-2 rounded-full ${S?.is_high_intent&&N==="ringing"?"bg-red-500/30 text-red-300":N==="ringing"?"bg-green-500/20 text-green-400":"bg-blue-500/20 text-blue-400"}`,children:[S?.is_high_intent&&N==="ringing"?c.jsx($i,{className:"w-5 h-5 animate-pulse"}):c.jsx(ni,{className:`w-5 h-5 ${N==="ringing"?"animate-bounce":""}`}),c.jsx("span",{className:"font-semibold text-lg",children:S?.is_high_intent&&N==="ringing"?`HIGH INTENT - Call #${S.inbound_call_count}`:N==="ringing"?"Incoming Call":Ne(D)})]})}),c.jsxs(Le.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},className:`relative w-32 h-32 rounded-full flex items-center justify-center mb-6 ${S?.is_high_intent?"bg-gradient-to-br from-red-600 to-pink-600":S?.score>=80?"bg-gradient-to-br from-orange-500 to-red-500":"bg-gradient-to-br from-blue-500 to-indigo-600"}`,children:[S?.is_high_intent&&c.jsx(Le.div,{className:"absolute -top-2 -right-2",animate:{scale:[1,1.3,1],rotate:[0,10,-10,0]},transition:{duration:.5,repeat:1/0},children:c.jsx($i,{className:"w-10 h-10 text-yellow-400 drop-shadow-lg"})}),S?.score>=80&&!S?.is_high_intent&&c.jsx(Le.div,{className:"absolute -top-2 -right-2",animate:{scale:[1,1.2,1]},transition:{duration:.5,repeat:1/0},children:c.jsx(nl,{className:"w-10 h-10 text-orange-400"})}),c.jsx(cr,{className:"w-16 h-16 text-white"})]}),c.jsx(Le.h1,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},className:"text-4xl font-bold text-white mb-2 text-center",children:g?.name||"Unknown Caller"}),c.jsx(Le.p,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.1},className:"text-xl text-slate-400 mb-6",children:g?.phone||"Unknown Number"}),S&&c.jsxs(Le.div,{initial:{y:30,opacity:0},animate:{y:0,opacity:1},transition:{delay:.2},className:"bg-white/10 backdrop-blur-sm rounded-2xl p-4 mb-8 w-full max-w-sm",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${S.score>=80?"bg-orange-500/20":"bg-blue-500/20"}`,children:c.jsx(cT,{className:`w-5 h-5 ${S.score>=80?"text-orange-400":"text-blue-400"}`})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-slate-400",children:"Score"}),c.jsxs("p",{className:`font-bold ${S.score>=80?"text-orange-400":"text-white"}`,children:[S.score>=80?"🔥 ":"",S.score||0]})]})]}),S.company&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-500/20 flex items-center justify-center",children:c.jsx(jc,{className:"w-5 h-5 text-slate-400"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-slate-400",children:"Company"}),c.jsx("p",{className:"font-semibold text-white truncate",children:S.company})]})]}),S.last_contact_at&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-500/20 flex items-center justify-center",children:c.jsx(uT,{className:"w-5 h-5 text-slate-400"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-slate-400",children:"Last Contact"}),c.jsx("p",{className:"font-semibold text-white",children:se(S.last_contact_at)})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-500/20 flex items-center justify-center",children:c.jsx(Nc,{className:"w-5 h-5 text-slate-400"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-slate-400",children:"Status"}),c.jsx("p",{className:"font-semibold text-white capitalize",children:S.status||"Unknown"})]})]})]}),S.is_high_intent&&c.jsxs("div",{className:"mt-4 bg-gradient-to-r from-red-600/30 to-pink-600/30 rounded-lg p-3 border border-red-500/50",children:[c.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[c.jsx($i,{className:"w-5 h-5 text-red-400"}),c.jsxs("p",{className:"text-red-300 font-bold text-center",children:["HIGH INTENT - Call #",S.inbound_call_count]}),c.jsx($i,{className:"w-5 h-5 text-red-400"})]}),c.jsx("p",{className:"text-red-200/80 text-sm text-center",children:"They're chasing YOU. Close this deal!"})]}),S.score>=80&&!S.is_high_intent&&c.jsx("div",{className:"mt-4 bg-gradient-to-r from-orange-500/20 to-red-500/20 rounded-lg p-3 border border-orange-500/30",children:c.jsx("p",{className:"text-orange-300 font-semibold text-center",children:"🔥 HOT LEAD CALLING BACK - Don't miss this!"})}),S.inbound_call_count>0&&S.inbound_call_count<3&&!S.is_high_intent&&c.jsx("div",{className:"mt-4 bg-gradient-to-r from-blue-500/20 to-indigo-500/20 rounded-lg p-3 border border-blue-500/30",children:c.jsxs("p",{className:"text-blue-300 font-semibold text-center flex items-center justify-center gap-2",children:[c.jsx(dT,{className:"w-4 h-4"}),"Call #",S.inbound_call_count," - Lead is calling YOU (+20 pts)"]})})]}),c.jsx(Le.div,{initial:{y:40,opacity:0},animate:{y:0,opacity:1},transition:{delay:.3},className:"flex gap-8",children:N==="ringing"?c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:ue,className:"w-20 h-20 bg-red-500 hover:bg-red-600 rounded-full flex items-center justify-center shadow-lg shadow-red-500/30 transition-all active:scale-95",children:c.jsx(ur,{className:"w-10 h-10 text-white"})}),c.jsx(Le.button,{onClick:re,animate:{scale:[1,1.1,1]},transition:{duration:1,repeat:1/0},className:"w-20 h-20 bg-green-500 hover:bg-green-400 rounded-full flex items-center justify-center shadow-lg shadow-green-500/30 transition-all",children:c.jsx(ni,{className:"w-10 h-10 text-white"})})]}):c.jsx("button",{onClick:je,className:"w-20 h-20 bg-red-500 hover:bg-red-600 rounded-full flex items-center justify-center shadow-lg shadow-red-500/30 transition-all active:scale-95",children:c.jsx(ur,{className:"w-10 h-10 text-white"})})}),N==="ringing"&&c.jsx(Le.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1},className:"mt-8 text-slate-500 text-sm",children:"Tap green to answer • Tap red to decline"})]})]})})}function ek(){const t=Sc(),{websiteSignup:s,clearWebsiteSignup:i}=Rc(),[l,o]=b.useState(0),[d,f]=b.useState(null),[m,p]=b.useState(!1);b.useEffect(()=>{s?.leadId&&(p(!0),Tr.get(s.leadId).then(A=>{f(A),p(!1)}).catch(A=>{console.error("Failed to fetch lead:",A),p(!1)}))},[s?.leadId]),b.useEffect(()=>{if(!s)return;const A=s.signupAt?new Date(s.signupAt).getTime():s.timestamp,C=()=>{const _=Math.floor((Date.now()-A)/1e3);o(_)};C();const B=setInterval(C,1e3);return()=>clearInterval(B)},[s]);const y=A=>{const C=Math.floor(A/60),B=A%60;return C>0?`${C}m ${B}s`:`${B}s`},x=A=>A<60?"critical":A<180?"high":A<300?"medium":"low",g=()=>{s?.leadId&&(i(),t(`/leads/${s.leadId}?action=call`))},w=()=>{i()},S=()=>{s?.leadId&&(i(),t(`/leads/${s.leadId}`))};if(!s)return null;const T=x(l),N=s.isReEngaged,D={critical:{bg:"bg-green-600",border:"border-green-400",text:"text-green-100",pulse:"animate-pulse",message:"PERFECT TIMING - Call NOW!"},high:{bg:"bg-yellow-600",border:"border-yellow-400",text:"text-yellow-100",pulse:"",message:"Good window - call within 5 mins"},medium:{bg:"bg-orange-600",border:"border-orange-400",text:"text-orange-100",pulse:"",message:"Getting late - call ASAP"},low:{bg:"bg-red-600",border:"border-red-400",text:"text-red-100",pulse:"",message:"5min window passed - still call!"}}[T];return c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:c.jsxs("div",{className:`relative max-w-lg w-full mx-4 rounded-2xl ${D.bg} ${D.border} border-2 shadow-2xl overflow-hidden`,children:[T==="critical"&&c.jsx("div",{className:"absolute inset-0 bg-green-500/30 animate-pulse"}),c.jsxs("div",{className:"relative p-6 text-center",children:[c.jsx("div",{className:`text-5xl mb-2 ${D.pulse}`,children:N?"🔴":"🟠"}),c.jsx("h2",{className:"text-2xl font-bold text-white mb-1",children:N?"THEY'RE BACK!":"NEW WEBSITE SIGNUP"}),c.jsx("p",{className:"text-white/80 text-sm",children:s.message})]}),c.jsxs("div",{className:"bg-black/30 py-4 px-6 text-center",children:[c.jsxs("div",{className:"text-4xl font-mono font-bold text-white mb-1",children:[y(l)," ago"]}),c.jsx("p",{className:`text-sm ${D.text} font-medium`,children:D.message})]}),c.jsxs("div",{className:"p-6 space-y-4",children:[c.jsxs("div",{className:"bg-white/10 rounded-lg p-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-white/60 text-sm",children:"Lead"}),c.jsxs("span",{className:"text-white font-semibold",children:[d?.first_name," ",d?.last_name||""]})]}),c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-white/60 text-sm",children:"Company"}),c.jsx("span",{className:"text-white",children:d?.company||"Unknown"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-white/60 text-sm",children:"Phone"}),c.jsx("span",{className:"text-white font-mono",children:d?.phone||"Loading..."})]})]}),N&&s.aiInsight&&c.jsxs("div",{className:"bg-purple-500/30 rounded-lg p-4 border border-purple-400/50",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx("span",{className:"text-lg",children:"🤖"}),c.jsx("span",{className:"text-purple-200 font-medium text-sm",children:"AI Insight"})]}),c.jsxs("p",{className:"text-white text-sm italic",children:['"',s.aiInsight,'"']})]}),c.jsx("div",{className:"text-center py-2",children:c.jsxs("p",{className:"text-white/80 text-sm",children:[c.jsx("span",{className:"text-green-300 font-bold",children:"10x"})," higher conversion if called within 5 mins"]})})]}),c.jsxs("div",{className:"p-6 pt-0 space-y-3",children:[c.jsxs("button",{onClick:g,disabled:m||!d?.phone,className:"w-full py-4 px-6 bg-white text-green-700 font-bold text-xl rounded-xl hover:bg-green-50 transition-all shadow-lg hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-3",children:[c.jsx("span",{className:"text-2xl",children:"📞"}),"CALL NOW"]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx("button",{onClick:S,className:"flex-1 py-3 px-4 bg-white/20 text-white font-medium rounded-xl hover:bg-white/30 transition-all",children:"View Lead"}),c.jsx("button",{onClick:w,className:"flex-1 py-3 px-4 bg-white/10 text-white/80 font-medium rounded-xl hover:bg-white/20 transition-all",children:"Dismiss"})]})]}),c.jsx("button",{onClick:w,className:"absolute top-4 right-4 text-white/60 hover:text-white",children:c.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function tk(){const t=Sc(),{highIntentSms:s,clearHighIntentSms:i}=Rc(),[l,o]=b.useState(null),[d,f]=b.useState(!1);b.useEffect(()=>{s?.leadId?(f(!0),Tr.get(s.leadId).then(S=>{o(S),f(!1)}).catch(S=>{console.error("Failed to fetch lead:",S),f(!1)})):o(null)},[s?.leadId]);const m=()=>{const S=s?.phone||l?.phone;console.log("[HighIntentAlert] Call clicked, leadId:",s?.leadId,"phone:",S),i(),s?.leadId?t(`/leads/${s.leadId}?action=call`):t(S?`/inbox?phone=${encodeURIComponent(S)}`:"/calls")},p=()=>{console.log("[HighIntentAlert] Reply clicked, leadId:",s?.leadId),i(),s?.leadId?t(`/messages?lead=${s.leadId}`):t("/inbox")},y=()=>{console.log("[HighIntentAlert] Dismiss clicked"),i()};if(console.log("[HighIntentAlert] Render check, highIntentSms:",s?"exists":"null"),!s)return null;console.log("[HighIntentAlert] Rendering popup for:",s.leadId||s.phone);const x=s.buyingSignal?.level==="high",g=s.buyingSignal?.matchedPattern,w=l?`${l.first_name||""} ${l.last_name||""}`.trim():"Unknown";return c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm pb-24 md:pb-0",children:c.jsxs("div",{className:`relative max-w-lg w-full mx-4 rounded-2xl ${x?"bg-red-600":"bg-amber-600"} border-2 ${x?"border-red-400":"border-amber-400"} shadow-2xl overflow-hidden max-h-[calc(100vh-120px)] overflow-y-auto`,children:[x&&c.jsx("div",{className:"absolute inset-0 bg-red-500/30 animate-pulse pointer-events-none"}),c.jsxs("div",{className:"relative p-6 text-center",children:[c.jsx("div",{className:"flex items-center justify-center gap-2 mb-2",children:c.jsx(nl,{className:`w-10 h-10 text-white ${x?"animate-pulse":""}`})}),c.jsx("h2",{className:"text-2xl font-bold text-white mb-1",children:x?"HIGH BUYING INTENT!":"BUYING SIGNAL DETECTED"}),c.jsx("p",{className:"text-white/80 text-sm",children:x?"This lead is ready to buy - respond NOW!":"Interested lead - respond quickly!"})]}),c.jsxs("div",{className:"bg-black/30 py-4 px-6",children:[c.jsx("p",{className:"text-white/60 text-xs uppercase mb-2",children:"They said:"}),c.jsxs("p",{className:"text-white text-lg font-medium italic",children:['"',s.message?.substring(0,100),s.message?.length>100?"...":"",'"']}),g&&c.jsxs("p",{className:"text-yellow-300 text-sm mt-2",children:['Signal: "',g,'"']})]}),c.jsxs("div",{className:"p-6 space-y-4",children:[c.jsxs("div",{className:"bg-white/10 rounded-lg p-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-white/60 text-sm",children:"Lead"}),c.jsx("span",{className:"text-white font-semibold",children:d?"Loading...":w})]}),l?.company&&c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-white/60 text-sm",children:"Company"}),c.jsx("span",{className:"text-white",children:l.company})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-white/60 text-sm",children:"Phone"}),c.jsx("span",{className:"text-white font-mono",children:s.phone||l?.phone||"Unknown"})]})]}),c.jsx("div",{className:"text-center py-2",children:c.jsxs("p",{className:"text-white/80 text-sm",children:[c.jsx("span",{className:`${x?"text-yellow-300":"text-white"} font-bold`,children:"No auto-reply sent"})," - personal response required!"]})})]}),c.jsxs("div",{className:"p-6 pt-0 space-y-3",children:[c.jsxs("button",{onClick:m,disabled:d&&!s.phone,className:"w-full py-4 px-6 bg-white text-red-700 font-bold text-xl rounded-xl hover:bg-red-50 transition-all shadow-lg hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-3",children:[c.jsx(ni,{className:"w-6 h-6"}),"CALL NOW"]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsxs("button",{onClick:p,className:"flex-1 py-3 px-4 bg-white/20 text-white font-medium rounded-xl hover:bg-white/30 transition-all flex items-center justify-center gap-2",children:[c.jsx(Nc,{className:"w-5 h-5"}),"Reply"]}),c.jsx("button",{onClick:y,className:"flex-1 py-3 px-4 bg-white/10 text-white/80 font-medium rounded-xl hover:bg-white/20 transition-all",children:"Dismiss"})]})]}),c.jsx("button",{onClick:y,className:"absolute top-4 right-4 text-white/60 hover:text-white",children:c.jsx(Gt,{className:"w-6 h-6"})})]})})}function nk(t,s){b.useEffect(()=>{function i(l){t.current&&!t.current.contains(l.target)&&s()}return document.addEventListener("mousedown",i),document.addEventListener("touchstart",i),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("touchstart",i)}},[t,s])}const hb=[{to:"/manager",icon:"👔",label:"Manager Dashboard",tooltip:"Manager Dashboard – See who needs coaching, who's crushing it, filter by period"},{to:"/activation",icon:"🚀",label:"Activation",tooltip:"Activation – Stuck leads, bulk actions, re-engage campaigns"},{to:"/playbook",icon:"📋",label:"Sales Playbook",tooltip:"Playbook – Scripts with reply rates, objection handlers, brand guidelines"},{to:"/my-stats",icon:"📊",label:"My Stats",tooltip:"My Stats – Your XP, level progress, badges earned, call performance"},{to:"/weekly-insights",icon:"📈",label:"Weekly Insights",tooltip:"Weekly Insights – AI detects your best times, trades, approaches"},{to:"/more",icon:"⚙️",label:"Settings",tooltip:"Settings – Power Features Guide, Voicemail Drops, Training Wheels toggle"}],sk=({isActive:t})=>`flex items-center gap-3 px-4 py-2.5 text-sm font-medium transition-colors ${t?"bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-700"}`;function ak(){const[t,s]=b.useState(!1),i=b.useRef(null),l=Nb();nk(i,()=>s(!1));const o=hb.some(d=>l.pathname.startsWith(d.to));return c.jsxs("div",{ref:i,className:"relative",children:[c.jsx(Qa,{content:"More – manager tools, playbook, stats, settings",side:"right",children:c.jsxs("button",{onClick:()=>s(!t),className:`w-full flex items-center justify-between gap-3 px-4 py-3 rounded-xl font-semibold transition-colors ${o?"bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-700"}`,children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("span",{className:"text-lg",children:"⚙️"})," More"]}),c.jsx(mh,{className:`w-4 h-4 transition-transform ${t?"rotate-180":""}`})]})}),t&&c.jsx("div",{className:"absolute left-0 mt-1 w-56 bg-white dark:bg-slate-800 rounded-xl shadow-lg border border-slate-200 dark:border-slate-700 py-2 z-50",children:hb.map(d=>c.jsxs(Ka,{to:d.to,className:sk,onClick:()=>s(!1),children:[c.jsx("span",{className:"text-base",children:d.icon}),c.jsx("span",{className:"whitespace-nowrap",children:d.label})]},d.to))})]})}function ik(){const{shouldPromptToDisable:t,setEnabled:s}=Aw(),[i,l]=b.useState(()=>localStorage.getItem("trainingWheelsPromptDismissed")==="true");if(!t||i)return null;const o=()=>{l(!0),localStorage.setItem("trainingWheelsPromptDismissed","true")},d=()=>{s(!1),o()};return c.jsxs("div",{className:"fixed bottom-20 left-4 right-4 md:left-auto md:right-4 md:w-80 bg-white rounded-xl shadow-lg border border-slate-200 p-4 z-50",children:[c.jsx("button",{onClick:o,className:"absolute top-2 right-2 p-1 text-slate-400 hover:text-slate-600",children:c.jsx(Gt,{className:"w-4 h-4"})}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 bg-green-50 rounded-lg shrink-0",children:c.jsx(fT,{className:"w-5 h-5 text-green-600"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-slate-900",children:"Ready to go solo?"}),c.jsx("p",{className:"text-sm text-slate-500 mt-1",children:"You've been using the app for a week. Want to turn off the training tooltips?"}),c.jsxs("div",{className:"flex gap-2 mt-3",children:[c.jsx("button",{onClick:d,className:"px-3 py-1.5 bg-slate-900 text-white text-sm font-medium rounded-lg",children:"Turn off hints"}),c.jsx("button",{onClick:o,className:"px-3 py-1.5 text-slate-600 text-sm font-medium",children:"Keep them"})]})]})]})]})}function lk(){const[t,s]=b.useState(null),[i,l]=b.useState(!1),[o,d]=b.useState(!1);b.useEffect(()=>{if(window.matchMedia("(display-mode: standalone)").matches){d(!0);return}if(sessionStorage.getItem("pwaPromptDismissed"))return;const p=x=>{x.preventDefault(),s(x),setTimeout(()=>l(!0),3e3)},y=()=>{d(!0),l(!1),s(null)};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",y),()=>{window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",y)}},[]);const f=async()=>{if(!t)return;t.prompt();const{outcome:p}=await t.userChoice;p==="accepted"&&d(!0),l(!1),s(null)},m=()=>{l(!1),sessionStorage.setItem("pwaPromptDismissed","true")};return o||!i?null:c.jsx(si,{children:c.jsx(Le.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"fixed bottom-20 left-3 right-3 z-50 md:left-auto md:right-4 md:bottom-4 md:w-96",children:c.jsxs("div",{className:"bg-gradient-to-r from-blue-600 to-blue-500 rounded-2xl p-4 shadow-2xl border border-blue-400/30",children:[c.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-full bg-white/10 hover:bg-white/20 transition-colors",children:c.jsx(Gt,{className:"w-4 h-4 text-white"})}),c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("div",{className:"flex-shrink-0 w-14 h-14 bg-white rounded-xl flex items-center justify-center shadow-lg",children:c.jsx("span",{className:"text-blue-600 font-bold text-xl",children:"RR"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-white font-semibold text-base",children:"Install RateRight"}),c.jsx("p",{className:"text-blue-100 text-sm mt-0.5",children:"Add to home screen for quick access"})]}),c.jsxs("button",{onClick:f,className:"flex-shrink-0 flex items-center gap-2 px-4 py-2.5 bg-white text-blue-600 rounded-xl font-semibold text-sm hover:bg-blue-50 transition-colors shadow-lg",children:[c.jsx(hT,{className:"w-4 h-4"}),"Install"]})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-3 pt-3 border-t border-white/20",children:[c.jsx(mT,{className:"w-4 h-4 text-blue-200"}),c.jsx("p",{className:"text-blue-100 text-xs",children:"Works offline • Auto-updates • No app store needed"})]})]})})})}function rk(){const[t,s]=b.useState(!navigator.onLine),[i,l]=b.useState(!1);return b.useEffect(()=>{const o=()=>{s(!1),i&&setTimeout(()=>l(!1),3e3)},d=()=>{s(!0),l(!0)};return window.addEventListener("online",o),window.addEventListener("offline",d),()=>{window.removeEventListener("online",o),window.removeEventListener("offline",d)}},[i]),c.jsxs(si,{children:[t&&c.jsx(Le.div,{initial:{y:-60,opacity:0},animate:{y:0,opacity:1},exit:{y:-60,opacity:0},transition:{type:"spring",damping:25},className:"fixed top-0 left-0 right-0 z-[100] bg-amber-500 text-amber-950 py-2 px-4 shadow-lg",children:c.jsxs("div",{className:"flex items-center justify-center gap-2 max-w-lg mx-auto",children:[c.jsx(pT,{className:"w-4 h-4 flex-shrink-0"}),c.jsx("span",{className:"text-sm font-medium",children:"You're offline. Changes will sync when reconnected."}),c.jsx("button",{onClick:()=>window.location.reload(),className:"ml-2 p-1 rounded hover:bg-amber-400 transition-colors",title:"Retry connection",children:c.jsx(Rb,{className:"w-4 h-4"})})]})}),!t&&i&&c.jsx(Le.div,{initial:{y:-60,opacity:0},animate:{y:0,opacity:1},exit:{y:-60,opacity:0},transition:{type:"spring",damping:25},className:"fixed top-0 left-0 right-0 z-[100] bg-green-500 text-white py-2 px-4 shadow-lg",children:c.jsx("div",{className:"flex items-center justify-center gap-2 max-w-lg mx-auto",children:c.jsx("span",{className:"text-sm font-medium",children:"Back online! Syncing your data..."})})})]})}function ok(t){const s="=".repeat((4-t.length%4)%4),i=(t+s).replace(/-/g,"+").replace(/_/g,"/"),l=window.atob(i),o=new Uint8Array(l.length);for(let d=0;d{o()},[]);const o=()=>{if(!("Notification"in window)||!("serviceWorker"in navigator)||Notification.permission==="granted"||Notification.permission==="denied")return;const m=localStorage.getItem("push-prompt-dismissed");if(m){const p=parseInt(m,10),y=Date.now()-1440*60*1e3;if(p>y)return}setTimeout(()=>s(!0),5e3)},d=async()=>{l(!0);try{if(await Notification.requestPermission()==="granted"){const{publicKey:p}=await Ox.getVapidKey();if(!p){console.error("No VAPID public key configured"),s(!1);return}const x=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:ok(p)});await Ox.subscribe(x.toJSON()),console.log("[Push] Successfully subscribed to push notifications"),s(!1)}else s(!1)}catch(m){console.error("Failed to enable notifications:",m)}finally{l(!1)}},f=()=>{localStorage.setItem("push-prompt-dismissed",Date.now().toString()),s(!1)};return t?c.jsx("div",{className:"fixed bottom-24 left-4 right-4 md:left-auto md:right-6 md:max-w-sm z-50 animate-in slide-in-from-bottom-4",children:c.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-xl border border-slate-200 dark:border-slate-700 p-4 relative",children:[c.jsx("button",{onClick:f,className:"absolute top-3 right-3 p-1 text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 rounded-full hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors",children:c.jsx(Gt,{className:"w-4 h-4"})}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900 rounded-full flex items-center justify-center flex-shrink-0",children:c.jsx(gT,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),c.jsxs("div",{className:"flex-1 pr-4",children:[c.jsx("h3",{className:"font-bold text-slate-900 dark:text-white",children:"Never miss a hot lead"}),c.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mt-1",children:"Get instant alerts for high-intent messages, callbacks, and new signups."}),c.jsxs("div",{className:"flex gap-2 mt-3",children:[c.jsx("button",{onClick:d,disabled:i,className:"px-4 py-2 bg-blue-600 text-white text-sm font-semibold rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:i?"Enabling...":"Enable Notifications"}),c.jsx("button",{onClick:f,className:"px-4 py-2 text-slate-500 dark:text-slate-400 text-sm font-medium hover:text-slate-700 dark:hover:text-slate-200 transition-colors",children:"Maybe later"})]})]})]})]})}):null}const er=({isActive:t})=>`flex items-center gap-3 px-4 py-4 rounded-xl font-semibold transition-colors ${t?"bg-blue-50 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400":"text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-700"}`,uk=b.lazy(()=>ct(()=>import("./Login-C1ze7G30.js"),__vite__mapDeps([0,1,2,3,4,5]))),dk=b.lazy(()=>ct(()=>import("./Dashboard-CXKhbb5v.js"),__vite__mapDeps([6,1,2,7,3,8,9,10,4,5]))),fk=b.lazy(()=>ct(()=>import("./CallList-CQqWG8Rk.js"),__vite__mapDeps([11,1,2,12,13,3,8,7,4,5]))),hk=b.lazy(()=>ct(()=>import("./Activity-xAw9ln5x.js"),__vite__mapDeps([14,1,2,7,3,4,5]))),mk=b.lazy(()=>ct(()=>import("./Leads-D5ZwJ7Hn.js"),__vite__mapDeps([15,1,2,13,3,7,4,5]))),pk=b.lazy(()=>ct(()=>import("./LeadProfile-B5IE1Dpk.js"),__vite__mapDeps([16,1,2,3,12,8,7,4,5]))),gk=b.lazy(()=>ct(()=>import("./Messages-pbih9WAa.js"),__vite__mapDeps([17,1,2,3,8,7,4,5]))),yk=b.lazy(()=>ct(()=>import("./More-qIIIwV8J.js"),__vite__mapDeps([18,1,2,3,4,5]))),xk=b.lazy(()=>ct(()=>import("./ActivationCenter-C4ZTd7-V.js"),__vite__mapDeps([19,1,2,7,4,5,3]))),bk=b.lazy(()=>ct(()=>import("./ScriptDetail-AJYh3FCt.js"),__vite__mapDeps([20,1,2,3,4,5]))),mb=b.lazy(()=>ct(()=>import("./ScriptBuilder-DLiD7tLK.js"),__vite__mapDeps([21,1,2,3,4,5]))),vk=b.lazy(()=>ct(()=>import("./ScriptStats-CeWB9E05.js"),__vite__mapDeps([22,1,2,7,3,4,5]))),wk=b.lazy(()=>ct(()=>import("./SmsStats-pvp0JMEe.js"),__vite__mapDeps([23,1,2,7,3,4,5]))),Sk=b.lazy(()=>ct(()=>import("./Objections-BmjPbkTW.js"),__vite__mapDeps([24,1,2,3,4,5]))),jk=b.lazy(()=>ct(()=>import("./MyStats-BWgxklJL.js"),__vite__mapDeps([25,1,2,7,9,3,4,5]))),Tk=b.lazy(()=>ct(()=>import("./WeeklyInsights-BU31N-1-.js"),__vite__mapDeps([26,1,2,10,3,4,5]))),Nk=b.lazy(()=>ct(()=>import("./Battleground-BaeIf8GY.js"),__vite__mapDeps([27,1,2,3,4,5]))),jf=b.lazy(()=>ct(()=>import("./SalesPlaybook-BqLVvrYT.js"),__vite__mapDeps([28,1,2,3,7,4,5]))),Ck=b.lazy(()=>ct(()=>import("./CallPrepPage-CaE3KT5G.js"),__vite__mapDeps([29,1,2,7,3,4,5]))),Ak=b.lazy(()=>ct(()=>import("./ManagerDashboard-Df6HEbHU.js"),__vite__mapDeps([30,1,2,7,3,4,5]))),Ek=b.lazy(()=>ct(()=>import("./IntelligenceDashboard-BSNgviri.js"),__vite__mapDeps([31,1,2,7,3,4,5])));function Dk(){return c.jsx("div",{className:"min-h-screen flex items-center justify-center bg-slate-50 dark:bg-slate-900",children:c.jsxs("div",{className:"text-center",children:[c.jsx(_n,{className:"w-8 h-8 animate-spin text-blue-600 dark:text-blue-400 mx-auto mb-3"}),c.jsx("p",{className:"text-slate-500 dark:text-slate-400 text-sm",children:"Loading..."})]})})}function kk(){const{open:t}=cm(),s=navigator.platform.toUpperCase().indexOf("MAC")>=0;return c.jsxs("button",{onClick:t,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left text-slate-500 dark:text-slate-400 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 rounded-xl transition-colors",children:[c.jsx(gh,{className:"w-4 h-4"}),c.jsx("span",{className:"flex-1 text-sm",children:"Search..."}),c.jsx("kbd",{className:"px-1.5 py-0.5 text-xs font-medium bg-white dark:bg-slate-700 text-slate-400 dark:text-slate-500 rounded border border-slate-200 dark:border-slate-600",children:s?"⌘K":"Ctrl+K"})]})}function Rk(){const{open:t}=cm();return c.jsx("button",{onClick:t,className:"md:hidden fixed top-4 right-4 z-40 w-10 h-10 bg-white dark:bg-slate-800 shadow-lg rounded-full flex items-center justify-center border border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-700 transition-colors",title:"Search",children:c.jsx(gh,{className:"w-5 h-5 text-slate-600 dark:text-slate-300"})})}function Mk(){const{showHelp:t,closeHelp:s}=T3();return c.jsx(S3,{isOpen:t,onClose:s})}function bt({children:t}){return c.jsxs("div",{className:"min-h-screen bg-slate-50 dark:bg-slate-900",children:[c.jsx(rk,{}),c.jsx("aside",{className:"hidden md:flex md:w-64 md:flex-col md:fixed md:inset-y-0 bg-white dark:bg-slate-900 border-r border-slate-200 dark:border-slate-700",children:c.jsxs("div",{className:"flex-1 flex flex-col pt-6 pb-4 overflow-y-auto",children:[c.jsx("div",{className:"flex items-center flex-shrink-0 px-5 mb-8",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-blue-600 to-blue-700 rounded-xl flex items-center justify-center",children:c.jsx("span",{className:"text-white font-black text-lg",children:"R"})}),c.jsxs("div",{children:[c.jsx("h1",{className:"text-lg font-bold text-slate-900 dark:text-slate-100",children:"RateRight"}),c.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Growth Engine"})]})]})}),c.jsx("div",{className:"px-3 mb-4",children:c.jsx(kk,{})}),c.jsxs("nav",{className:"flex-1 flex flex-col gap-4 px-3",children:[c.jsx(Qa,{content:"Dashboard – Tap 'Today's Mission' for AI action plan + ready-to-send messages",side:"right",children:c.jsxs(Ka,{to:"/",end:!0,className:er,children:[c.jsx("span",{className:"text-lg",children:"🏠"})," Dashboard"]})}),c.jsx(Qa,{content:"Call List – Use Power Dialer (lightning) to auto-advance through calls with study timer",side:"right",children:c.jsxs(Ka,{to:"/calls",className:er,children:[c.jsx("span",{className:"text-lg",children:"📞"})," Call List"]})}),c.jsx(Qa,{content:"Messages – Tap AI sparkle to generate personalized replies. Filter by Buying Signals!",side:"right",children:c.jsxs(Ka,{to:"/inbox",className:er,children:[c.jsx("span",{className:"text-lg",children:"💬"})," Messages"]})}),c.jsx(Qa,{content:"Leads – Each profile has AI Intel Brief with company research + similar wins",side:"right",children:c.jsxs(Ka,{to:"/leads",className:er,children:[c.jsx("span",{className:"text-lg",children:"👥"})," Leads"]})}),c.jsx(Qa,{content:"Battleground – Live leaderboard, daily challenges, team pulse feed",side:"right",children:c.jsxs(Ka,{to:"/battleground",className:er,children:[c.jsx("span",{className:"text-lg",children:"⚔️"})," Battleground"]})}),c.jsx(ak,{})]}),c.jsx("div",{className:"px-4 py-3 border-t border-slate-200 dark:border-slate-700",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm font-medium text-slate-600 dark:text-slate-400",children:"Theme"}),c.jsx(j3,{})]})})]})}),c.jsx("main",{className:"md:pl-64",children:t}),c.jsx(Rk,{}),c.jsx(Mk,{}),c.jsx(k3,{}),c.jsx(M3,{}),c.jsx(W3,{}),c.jsx(ek,{}),c.jsx(tk,{}),c.jsx(O3,{}),c.jsx(L3,{}),c.jsx(ik,{}),c.jsx(lk,{}),c.jsx(ck,{})]})}function Ok(){return c.jsx(D3,{children:c.jsxs(VE,{children:[c.jsx(_D,{}),c.jsx(CT,{children:c.jsx(RE,{children:c.jsx(_E,{children:c.jsx(kE,{children:c.jsx(zE,{children:c.jsx(BE,{children:c.jsx(lD,{children:c.jsx(Ij,{children:c.jsxs(LD,{children:[c.jsx(w3,{}),c.jsx(b.Suspense,{fallback:c.jsx(Dk,{}),children:c.jsxs($j,{children:[c.jsx(nt,{path:"/login",element:c.jsx(uk,{})}),c.jsx(nt,{path:"/",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(dk,{})})})}),c.jsx(nt,{path:"/calls",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(fk,{})})})}),c.jsx(nt,{path:"/activity",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(hk,{})})})}),c.jsx(nt,{path:"/inbox",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(gk,{})})})}),c.jsx(nt,{path:"/sms/stats",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(wk,{})})})}),c.jsx(nt,{path:"/leads",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(mk,{})})})}),c.jsx(nt,{path:"/leads/:id",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(pk,{})})})}),c.jsx(nt,{path:"/more",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(yk,{})})})}),c.jsx(nt,{path:"/activation",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(xk,{})})})}),c.jsx(nt,{path:"/playbook",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(jf,{})})})}),c.jsx(nt,{path:"/scripts",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(jf,{})})})}),c.jsx(nt,{path:"/scripts/command-center",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(jf,{})})})}),c.jsx(nt,{path:"/scripts/new",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(mb,{})})})}),c.jsx(nt,{path:"/scripts/stats",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(vk,{})})})}),c.jsx(nt,{path:"/scripts/:id",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(bk,{})})})}),c.jsx(nt,{path:"/scripts/:id/edit",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(mb,{})})})}),c.jsx(nt,{path:"/scripts/objections",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(Sk,{})})})}),c.jsx(nt,{path:"/my-stats",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(jk,{})})})}),c.jsx(nt,{path:"/weekly-insights",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(Tk,{})})})}),c.jsx(nt,{path:"/battleground",element:c.jsx(at,{children:c.jsx(bt,{children:c.jsx(Nk,{})})})}),c.jsx(nt,{path:"/manager",element:c.jsx(at,{children:c.jsx(Ak,{})})}),c.jsx(nt,{path:"/call-prep/:leadId",element:c.jsx(at,{children:c.jsx(Ck,{})})}),c.jsx(nt,{path:"/intelligence",element:c.jsx(at,{children:c.jsx(Ek,{})})})]})})]})})})})})})})})})]})})}let NS=-1;const cl=t=>{addEventListener("pageshow",(s=>{s.persisted&&(NS=s.timeStamp,t(s))}),!0)},ds=(t,s,i,l)=>{let o,d;return f=>{s.value>=0&&(f||l)&&(d=s.value-(o??0),(d||o===void 0)&&(o=s.value,s.delta=d,s.rating=((m,p)=>m>p[1]?"poor":m>p[0]?"needs-improvement":"good")(s.value,i),t(s)))}},dm=t=>{requestAnimationFrame((()=>requestAnimationFrame((()=>t()))))},fm=()=>{const t=performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStartfm()?.activationStart??0,fs=(t,s=-1)=>{const i=fm();let l="navigate";return NS>=0?l="back-forward-cache":i&&(document.prerendering||Ar()>0?l="prerender":document.wasDiscarded?l="restore":i.type&&(l=i.type.replace(/_/g,"-"))),{name:t,value:s,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:l}},Tf=new WeakMap;function hm(t,s){return Tf.get(t)||Tf.set(t,new s),Tf.get(t)}class _k{t;i=0;o=[];h(s){if(s.hadRecentInput)return;const i=this.o[0],l=this.o.at(-1);this.i&&i&&l&&s.startTime-l.startTime<1e3&&s.startTime-i.startTime<5e3?(this.i+=s.value,this.o.push(s)):(this.i=s.value,this.o=[s]),this.t?.(s)}}const Er=(t,s,i={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(t)){const l=new PerformanceObserver((o=>{Promise.resolve().then((()=>{s(o.getEntries())}))}));return l.observe({type:t,buffered:!0,...i}),l}}catch{}},mm=t=>{let s=!1;return()=>{s||(t(),s=!0)}};let Ki=-1;const CS=new Set,pb=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,dh=t=>{if(document.visibilityState==="hidden"){if(t.type==="visibilitychange")for(const s of CS)s();isFinite(Ki)||(Ki=t.type==="visibilitychange"?t.timeStamp:0,removeEventListener("prerenderingchange",dh,!0))}},Uc=()=>{if(Ki<0){const t=Ar();Ki=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((i=>i.name==="hidden"&&i.startTime>t))[0]?.startTime)??pb(),addEventListener("visibilitychange",dh,!0),addEventListener("prerenderingchange",dh,!0),cl((()=>{setTimeout((()=>{Ki=pb()}))}))}return{get firstHiddenTime(){return Ki},onHidden(t){CS.add(t)}}},Pc=t=>{document.prerendering?addEventListener("prerenderingchange",(()=>t()),!0):t()},gb=[1800,3e3],AS=(t,s={})=>{Pc((()=>{const i=Uc();let l,o=fs("FCP");const d=Er("paint",(f=>{for(const m of f)m.name==="first-contentful-paint"&&(d.disconnect(),m.startTime{o=fs("FCP"),l=ds(t,o,gb,s.reportAllChanges),dm((()=>{o.value=performance.now()-f.timeStamp,l(!0)}))})))}))},yb=[.1,.25],Lk=(t,s={})=>{const i=Uc();AS(mm((()=>{let l,o=fs("CLS",0);const d=hm(s,_k),f=p=>{for(const y of p)d.h(y);d.i>o.value&&(o.value=d.i,o.entries=d.o,l())},m=Er("layout-shift",f);m&&(l=ds(t,o,yb,s.reportAllChanges),i.onHidden((()=>{f(m.takeRecords()),l(!0)})),cl((()=>{d.i=0,o=fs("CLS",0),l=ds(t,o,yb,s.reportAllChanges),dm((()=>l()))})),setTimeout(l))})))};let ES=0,Nf=1/0,Zo=0;const zk=t=>{for(const s of t)s.interactionId&&(Nf=Math.min(Nf,s.interactionId),Zo=Math.max(Zo,s.interactionId),ES=Zo?(Zo-Nf)/7+1:0)};let fh;const xb=()=>fh?ES:performance.interactionCount??0,Bk=()=>{"interactionCount"in performance||fh||(fh=Er("event",zk,{type:"event",buffered:!0,durationThreshold:0}))};let bb=0;class Vk{u=[];l=new Map;m;p;v(){bb=xb(),this.u.length=0,this.l.clear()}L(){const s=Math.min(this.u.length-1,Math.floor((xb()-bb)/50));return this.u[s]}h(s){if(this.m?.(s),!s.interactionId&&s.entryType!=="first-input")return;const i=this.u.at(-1);let l=this.l.get(s.interactionId);if(l||this.u.length<10||s.duration>i.P){if(l?s.duration>l.P?(l.entries=[s],l.P=s.duration):s.duration===l.P&&s.startTime===l.entries[0].startTime&&l.entries.push(s):(l={id:s.interactionId,entries:[s],P:s.duration},this.l.set(l.id,l),this.u.push(l)),this.u.sort(((o,d)=>d.P-o.P)),this.u.length>10){const o=this.u.splice(10);for(const d of o)this.l.delete(d.id)}this.p?.(l)}}}const DS=t=>{const s=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?t():(t=mm(t),addEventListener("visibilitychange",t,{once:!0,capture:!0}),s((()=>{t(),removeEventListener("visibilitychange",t,{capture:!0})})))},vb=[200,500],Uk=(t,s={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const i=Uc();Pc((()=>{Bk();let l,o=fs("INP");const d=hm(s,Vk),f=p=>{DS((()=>{for(const x of p)d.h(x);const y=d.L();y&&y.P!==o.value&&(o.value=y.P,o.entries=y.entries,l())}))},m=Er("event",f,{durationThreshold:s.durationThreshold??40});l=ds(t,o,vb,s.reportAllChanges),m&&(m.observe({type:"first-input",buffered:!0}),i.onHidden((()=>{f(m.takeRecords()),l(!0)})),cl((()=>{d.v(),o=fs("INP"),l=ds(t,o,vb,s.reportAllChanges)})))}))};class Pk{m;h(s){this.m?.(s)}}const wb=[2500,4e3],Hk=(t,s={})=>{Pc((()=>{const i=Uc();let l,o=fs("LCP");const d=hm(s,Pk),f=p=>{s.reportAllChanges||(p=p.slice(-1));for(const y of p)d.h(y),y.startTime{f(m.takeRecords()),m.disconnect(),l(!0)})),y=x=>{x.isTrusted&&(DS(p),removeEventListener(x.type,y,{capture:!0}))};for(const x of["keydown","click","visibilitychange"])addEventListener(x,y,{capture:!0});cl((x=>{o=fs("LCP"),l=ds(t,o,wb,s.reportAllChanges),dm((()=>{o.value=performance.now()-x.timeStamp,l(!0)}))}))}}))},Sb=[800,1800],hh=t=>{document.prerendering?Pc((()=>hh(t))):document.readyState!=="complete"?addEventListener("load",(()=>hh(t)),!0):setTimeout(t)},qk=(t,s={})=>{let i=fs("TTFB"),l=ds(t,i,Sb,s.reportAllChanges);hh((()=>{const o=fm();o&&(i.value=Math.max(o.responseStart-Ar(),0),i.entries=[o],l(!0),cl((()=>{i=fs("TTFB",0),l=ds(t,i,Sb,s.reportAllChanges),l(!0)})))}))},Ik="https://rateright-growth-production.up.railway.app";async function tr(t){try{await fetch(`${Ik}/api/frontend/vitals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metric_name:t.name,metric_value:t.value,rating:t.rating,page_path:window.location.pathname,delta:t.delta,id:t.id,navigationType:t.navigationType})})}catch(s){console.debug("Web vitals send failed:",s.message)}}function $k(){Hk(tr),Uk(tr),Lk(tr),AS(tr),qk(tr),console.debug("Web vitals collection initialized")}$k();E3();const Gk=new Vj({defaultOptions:{queries:{staleTime:30*1e3,gcTime:300*1e3,retry:1,refetchOnWindowFocus:!1}}});wT.createRoot(document.getElementById("root")).render(c.jsx(b.StrictMode,{children:c.jsx(Uj,{client:Gk,children:c.jsx(Ok,{})})}));export{si as A,iR as B,Z3 as C,aR as D,rR as E,oR as F,cR as G,Nt as H,dR as I,fR as J,pR as S,Qa as T,ct as _,kc as a,hR as b,lR as c,tR as d,Rc as e,$3 as f,hc as g,gR as h,Jk as i,Rx as j,sR as k,Tr as l,Le as m,It as n,eR as o,uR as p,oE as q,nR as r,Wk as s,Ox as t,br as u,Mx as v,Ji as w,Aw as x,Dw as y,mR as z};