1import{c as i,j as e}from"./vendor-1kUQ7zn2.js";import{a0 as v,u as S,ay as k,C,l as T,o as A,am as N,m as _,B as c,an as E,s as D,az as I}from"./index--kdl1ae9.js";import{T as F}from"./textarea-eVnMW_FJ.js";import{d as H}from"./vendor-supabase-Dh2gyaRa.js";import{A as O,a as f}from"./vendor-motion-BX-jsy7E.js";import"./vendor-date-en1IyhsK.js";const L=()=>{const[a,y]=i.useState(null),[u,b]=i.useState(""),[o,d]=v("nps_submitted",!1),[g,n]=i.useState(!1),{toast:m}=S(),{session:r}=H.useSessionContext(),l=r?.user?.id,h=r?.user?.created_at;i.useEffect(()=>{if(o||!l||k(h)<3)return;let t;const s=()=>{let x=!1;try{x=sessionStorage.getItem("onb:coach-shown")==="1"}catch{}return x||I(l)||!!document.querySelector('[role="dialog"], .cm-coach, .cm-starter')},p=()=>{if(s()){t=window.setTimeout(p,3e4);return}n(!0)};return t=window.setTimeout(p,12e4),()=>window.clearTimeout(t)},[o,l,h]);const w=async()=>{if(a!==null)try{r?.user?.id&&await D.from("nps_responses").insert({user_id:r.user.id,rating:a,feedback:u,session_data:{url:window.location.pathname,userAgent:navigator.userAgent,timestamp:new Date().toISOString()}}),d(!0),n(!1),m({title:"Thank you for your feedback!",description:"Your response helps us improve our service."})}catch{m({title:"Error",description:"Failed to save your feedback. Please try again later.",variant:"destructive"})}},j=()=>{n(!1),d(!0)};return!g||o?null:e.jsx(O,{children:e.jsx(f.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},className:"fixed bottom-4 right-4 z-50 max-w-md w-full mx-auto max-sm:right-2 max-sm:left-2 max-sm:w-auto max-sm:bottom-[calc(env(safe-area-inset-bottom,0px)+84px)]",children:e.jsxs(C,{className:"shadow-lg border-2",children:[e.jsxs(T,{children:[e.jsx(A,{className:"text-lg",children:"How likely are you to recommend us?"}),e.jsx(N,{children:"On a scale of 0-10, where 0 is not at all likely and 10 is extremely likely"})]}),e.jsxs(_,{children:[e.jsx("div",{className:"flex gap-1 mb-4",children:Array.from({length:11},(t,s)=>e.jsx(c,{variant:a===s?"default":"outline",className:"w-8 h-8 p-0",onClick:()=>y(s),children:s},s))}),a!==null&&e.jsx(f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:e.jsx(F,{placeholder:"Would you like to tell us why? (optional)",value:u,onChange:t=>b(t.target.value),className:"min-h-[80px]"})})]}),e.jsxs(E,{className:"flex justify-between",children:[e.jsx(c,{variant:"ghost",onClick:j,children:"Maybe later"}),e.jsx(c,{onClick:w,disabled:a===null,children:"Submit feedback"})]})]})})})};export{L as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.