1import{j as e}from"./vendor-radix-BMN_-y0O.js";import{r as l,e as pe}from"./vendor-react-LwREbmHq.js";import{u as ge,B as M,s as G,Y as Ne,c as ve,bD as je}from"./index-vfr963b2.js";import{d as we,a as re,b as be,c as ye,u as ke,K as Ce,h as Se}from"./KioskTaskOverlay-BC8R8And.js";import{l as Te,c as Ee}from"./deviceSession-DaQyCCLr.js";import{a as Ie,r as _e,b as Pe,u as ne,o as me,s as U,l as J}from"./vendor-forms-BxJQRD3T.js";import{f as Fe}from"./useDuplicateOpportunityCheck-w3WUWuuq.js";import{I as K}from"./input-CeRIysyv.js";import{L as B}from"./label-BDqyVCAL.js";import{C as W,a as Z,b as ee,d as X}from"./card-D4x0WM4V.js";import{C as Le}from"./checkbox-D6lsrQY5.js";import{aE as De,d as ie,w as Ke,M as Be,L as te,$ as Ue,a4 as oe,F as Ae,c8 as He,cw as Re,J as ue,U as Me,u as ze,I as Ve,X as Oe}from"./vendor-icons-B40_8yDG.js";import{u as $e}from"./useTipCelebration-pbXQrCdc.js";import"./vendor-data-DUXRAtvF.js";import"./vendor-date-DYQ7tMgT.js";import"./useTipCelebrationSound-BJmwh1gN.js";import"./index-Dv1z28RV.js";import"./index-CaDXAaVT.js";import"./TerminalPaymentCollector-B1kCDMjF.js";import"./useTipsEnabled-Bk1mlhyG.js";import"./requestPaymentPlan-hqSu0DOk.js";import"./confetti.module-ONDKWxYZ.js";const qe=4e3;function Ye(a){const[n,r]=l.useState(null),[c,f]=l.useState(!0),u=l.useRef(null),i=l.useCallback(async()=>{if(a)try{const{task:o}=await we(a);o?(u.current=o.id,r(o)):u.current||r(null)}catch(o){console.warn("[useKioskDeviceTasks] poll failed",o)}finally{f(!1)}},[a]);l.useEffect(()=>{if(!a){f(!1);return}i();const o=setInterval(()=>{u.current||i()},qe);return()=>clearInterval(o)},[a,i]);const x=l.useCallback(async o=>{if(a)try{await re(a,o,"in_progress"),r(v=>v&&v.id===o?{...v,status:"in_progress"}:v)}catch(v){console.warn("[useKioskDeviceTasks] start failed",v)}},[a]),m=l.useCallback(async(o,v)=>{if(a){try{await re(a,o,v)}catch(p){console.warn("[useKioskDeviceTasks] finish failed",p)}u.current=null,r(null),i()}},[a,i]);return{pendingTask:n,loading:c,startTask:x,completeTask:o=>m(o,"completed"),cancelTask:o=>m(o,"cancelled"),refetch:i}}var Ge=function(a,n){for(var r={};a.length;){var c=a[0],f=c.code,u=c.message,i=c.path.join(".");if(!r[i])if("unionErrors"in c){var x=c.unionErrors[0].errors[0];r[i]={message:x.message,type:x.code}}else r[i]={message:u,type:f};if("unionErrors"in c&&c.unionErrors.forEach(function(v){return v.errors.forEach(function(p){return a.push(p)})}),n){var m=r[i].types,o=m&&m[c.code];r[i]=Pe(i,n,r,f,o?[].concat(o,c.message):c.message)}a.shift()}return r},le=function(a,n,r){return r===void 0&&(r={}),function(c,f,u){try{return Promise.resolve(function(i,x){try{var m=Promise.resolve(a[r.mode==="sync"?"parse":"parseAsync"](c,n)).then(function(o){return u.shouldUseNativeValidation&&Ie({},u),{errors:{},values:r.raw?c:o}})}catch(o){return x(o)}return m&&m.then?m.then(void 0,x):m}(0,function(i){if(function(x){return Array.isArray(x?.errors)}(i))return{values:{},errors:_e(Ge(i.errors,!u.shouldUseNativeValidation&&u.criteriaMode==="all"),u)};throw i}))}catch(i){return Promise.reject(i)}}};function Je(){const a=globalThis.crypto;if(a?.randomUUID)return a.randomUUID();if(a?.getRandomValues){const n=new Uint8Array(16);a.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=Array.from(n,c=>c.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}throw new Error("Secure random source unavailable on this device")}const ce=me({firstName:U().min(1,"Please enter your first name").max(50),lastName:U().min(1,"Please enter your last name").max(50),phone:U().min(10,"Please enter a valid phone number").max(20),email:U().email("Please enter a valid email").min(1,"Email is required").max(255)}),We=me({insuranceCompany:U().max(100).optional().or(J("")),claimNumber:U().max(50).optional().or(J("")),adjusterName:U().max(100).optional().or(J("")),adjusterPhone:U().max(20).optional().or(J(""))});function Xe(a){const n=window.visualViewport,r=n?.offsetTop??0,c=n?.height??window.innerHeight,f=a.getBoundingClientRect(),i=r+c-24,x=f.bottom-i;if(x<=0)return;let m=a.parentElement;for(;m&&m!==document.body;){const o=getComputedStyle(m).overflowY;if((o==="auto"||o==="scroll")&&m.scrollHeight>m.clientHeight){m.scrollBy({top:x,behavior:"auto"});return}m=m.parentElement}window.scrollBy({top:x,behavior:"auto"})}function Qe({businessId:a,onSuccess:n,deviceSession:r=null}){const[c,f]=l.useState(!1),[u,i]=l.useState("contact"),[x,m]=l.useState(null),[o,v]=l.useState(null),[p,V]=l.useState(!0),{toast:y}=ge(),_=l.useRef(null),T=t=>{_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{const s=document.getElementById(t);s&&Xe(s),_.current=null},350)};l.useEffect(()=>()=>{_.current!==null&&window.clearTimeout(_.current)},[]),l.useEffect(()=>{let t=window.scrollY,s=!1;const j=()=>
1{if(s)return;const C=window.scrollY;if(C>=t){t=C;return}if(w){t=C;return}s=!0,window.scrollTo({top:t,behavior:"auto"}),requestAnimationFrame(()=>{s=!1})};let w=!1;const L=()=>{w=!0},D=()=>{window.setTimeout(()=>{w=!1},400)};return window.addEventListener("scroll",j,{passive:!0}),window.addEventListener("touchmove",L,{passive:!0}),window.addEventListener("touchend",D,{passive:!0}),()=>{window.removeEventListener("scroll",j),window.removeEventListener("touchmove",L),window.removeEventListener("touchend",D)}},[u]);const g=ne({resolver:le(ce),defaultValues:{firstName:"",lastName:"",phone:"",email:""}}),P=ne({resolver:le(We),defaultValues:{insuranceCompany:"",claimNumber:"",adjusterName:"",adjusterPhone:""}}),E=g.watch(),N=P.watch(),k=t=>t.trim()?"h-14 text-lg px-4 border-success/40 bg-success-light focus-visible:border-success/60 focus-visible:ring-success/30":"h-14 text-lg px-4 kiosk-glow",O=t=>{const s=t.replace(/\D/g,"");return s.length<=3?s:s.length<=6?`(${s.slice(0,3)}) ${s.slice(3)}`:`(${s.slice(0,3)}) ${s.slice(3,6)}-${s.slice(6,10)}`},Q=async t=>{if(r)try{const{intake_link_id:s}=await be(r,{firstName:t.firstName.trim(),lastName:t.lastName.trim(),phone:t.phone,email:t.email.trim(),smsConsent:p});return s}catch(s){return console.error("[KioskCheckInForm] Device check-in failed",s),y({title:"Something went wrong",description:"Please try again or ask a team member for help.",variant:"destructive"}),null}try{const s=t.phone.replace(/\D/g,""),j=`${t.firstName.trim()} ${t.lastName.trim()}`,w=h=>h.toLowerCase().replace(/[^a-z\s]/g,"").replace(/\s+/g," ").trim(),L=(await Fe(a,s,t.email||null)).filter(h=>w(h.customer_name||"")===w(j));if(L.length>0){const h=L[0];console.log("[KioskCheckInForm] Found existing opportunity, linking:",h.id,h.customer_name);const I=h.metadata||{};return await G.from("business_intake_links").update({metadata:{...I,kiosk_checkin_at:new Date().toISOString(),kiosk_checkin_name:j},...!h.customer_email&&t.email?{customer_email:t.email.trim()}:{}}).eq("id",h.id),h.id}const D=Je(),C={source:"ipad_kiosk",is_new_opportunity:!0,needs_vehicle_info:!0,needs_photos:!0,created_via:"customer_kiosk",sms_consent:{granted:p,granted_at:new Date().toISOString(),source:"kiosk_checkin"}},{data:d,error:b}=await G.from("business_intake_links").insert({business_id:a,token:D,customer_name:j,customer_phone:s,customer_email:t.email?.trim()||null,status:"active",is_active:!0,metadata:C}).select("id").single();if(b)throw b;return d?.id||null}catch(s){return console.error("[KioskCheckInForm] Error creating check-in",{error:s,businessId:a,hasCrypto:!!globalThis.crypto,hasRandomUUID:!!globalThis.crypto?.randomUUID}),y({title:"Something went wrong",description:"Please try again or ask a team member for help.",variant:"destructive"}),null}},A=async(t,s)=>{if(r){try{await ye(r,{intakeLinkId:t,insuranceCompany:s.insuranceCompany?.trim(),claimNumber:s.claimNumber?.trim(),adjusterName:s.adjusterName?.trim(),adjusterPhone:s.adjusterPhone?.trim()})}catch(j){console.error("[KioskCheckInForm] Device insurance update failed",j)}return}try{const j=s.adjusterPhone?.replace(/\D/g,"")||null,w={};if(s.adjusterName?.trim()&&(w.adjuster_name=s.adjusterName.trim()),j&&(w.adjuster_phone=j),!(s.insuranceCompany?.trim()||s.claimNumber?.trim()||Object.keys(w).length>0))return;const{data:D}=await G.from("business_intake_links").select("metadata").eq("id",t).single(),C={...D?.metadata||{},...w},d={metadata:C};s.claimNumber?.trim()&&(d.claim_number=s.claimNumber.trim()),s.insuranceCompany?.trim()&&(C.insurance_company=s.insuranceCompany.trim(),d.metadata=C),await G.from("business_intake_links").update(d).eq("id",t)}catch(j){console.error("Error updating insurance info:",j)}},F=async t=>{f(!0);try{const s=await Q(t);s&&(m(t),v(s),i("insurance"))}catch(s){console.error("Error in contact submission:",s),y({title:"Something went wrong",description:"Please try again or ask a team member for help.",variant:"destructive"})}finally{f(!1)}},$=async t=>{f(!0),o&&await A(o,t),f(!1),q()},z=()=>{q()},q=()=>{const t=x?.firstName?.trim()||"Guest";g.reset(),P.reset(),i("contact"),m(null),v(null),V(!0),n(t)};return u==="contact"?e.jsxs(W,{className:"w-full max-w-lg shadow-xl border-2",children:[e.jsxs(Z,{className:"text-center pb-4",children:[e.jsx(ee,{className:"text-3xl font-bold text-foreground",children:"Welcome! Check In Here"}),e.jsx("p",{className:"text-lg text-muted-foreground mt-2",children:"A team member will be with you shortly"})]}),e.jsx(X,{children:e.jsxs("form",{onSubmit:g.handleSubmit(F),className:"space-y-6",children:[e.jsx("p",{className:"text-center text-sm font-medium text-primary",children:"Fill in each highlighted box"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",onBlur:t=>{t.currentTarget.contains(t.relatedTarget)||E.firstName.trim()&&E.lastName.trim()&&T("phone")},children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{htmlFor:"firstName",className:"text-lg font-medium flex items-center gap-2",children:[e.jsx(De,{className:"h-5 w-5 text-primary"}),"First Name"]}),e.jsx(K,{id:"firstName",type:"text",placeholder:"Enter first name",autoComplete:"given-name",autoCapitalize:"words",className:k(E.firstName),...g.register("firstName"),enterKeyHint:"next"}),g.formState.errors.firstName&&e.jsx("p",{className:"text-sm text-destructive",children:g.formState.errors.firstName.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"lastName",className:"text-lg font-medium",children:"Last Name"}),e.jsx(K,{id:"lastName",type:"text",placeholder:"Enter last name",autoComplete:"family-name",autoCapitalize:"words",className:k(E.lastName),...g.register("lastName"),enterKeyHint:"next"}),g.formState.errors.lastName&&e.jsx("p",{className:"text-sm text-destructive",children:g.formState.errors.lastName.message})]})]}),e.jsxs("div",{className:"space-y-2",onBlur:()=>{E.phone.replace(/\D/g,"").length>=10&&T("email")},children:[e.jsxs(B,{htmlFor:"phone",className:"text-lg font-medium flex items-center gap-2",children:[e.jsx(ie,{className:"h-5 w-5 text-primary"}),"Phone Number"]}),e.jsx(K,{id:"phone",type:"tel",placeholder:"(555) 123-4567",autoComplete:"tel",inputMode:"tel",className:k(E.phone),...g.register("phone",{onChange:t=>{t.target.value=O(t.target.value)}}),enterKeyHint:"next"}),g.formState.errors.phone&&e.jsx("p",{className:"text-sm text-destructive",children:g.formState.errors.phone.message})]}),e.jsxs("div",{className:"space-y-2",onBlur:()=>{ce.shape.email.safeParse(E.email).success&&T("kiosk-continue-btn")},children:[e.jsxs(B,{htmlFor:"email",className:"text-lg font-medium flex items-center gap-2",children:[e.jsx(Ke,{className:"h-5 w-5 text-primary"}),"Email"]}),e.jsx(K,{id:"email",type:"email",placeholder:"Enter email address",autoComplete:"email",inputMode:"email",className:k(E.email),...g.register("email"),enterKeyHint:"next"}),g.formState.errors.email&&e.jsx("p",{className:"text-sm text-destructive",children:g.formState.errors.email.message})]}),e.jsx("div",{className:"space-y-1 pt-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Le,{id:"kiosk-sms-consent",checked:p,onCheckedChange:t=>V(!!t),className:"mt-1 h-6 w-6"}),e.jsxs("label",{htmlFor:"kiosk-sms-consent",className:"text-base text-muted-foreground cursor-pointer leading-relaxed",children:[e.jsxs("span",{className:"flex items-center gap-2 font-medium text-foreground",children:[e.jsx(Be,{className:"h-4 w-4 text-primary"}),"Text me repair updates"]}),e.jsx("span",{className:"text-sm",children:"Receive notifications about your vehicle's repair status"})]})]})}),e.jsx(M,{id:"kiosk-continue-btn",type:"submit",size:"lg",disabled:c,
1className:"w-full h-16 text-xl font-semibold mt-4",children:c?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"h-6 w-6 animate-spin mr-2"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"h-6 w-6 mr-2"}),"Continue"]})})]})})]}):e.jsxs(W,{className:"w-full max-w-lg shadow-xl border-2 mb-24",children:[e.jsxs(Z,{className:"text-center pb-3 pt-4",children:[e.jsx("div",{className:"mx-auto w-11 h-11 bg-primary/10 rounded-full flex items-center justify-center mb-1",children:e.jsx(oe,{className:"h-7 w-7 text-primary"})}),e.jsx(ee,{className:"text-2xl font-bold text-foreground",children:"Insurance Information"}),e.jsx("p",{className:"text-base text-muted-foreground mt-2",children:"Optional â helps speed up your estimate"})]}),e.jsx(X,{children:e.jsxs("form",{onSubmit:P.handleSubmit($),className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",onBlur:()=>{N.insuranceCompany?.trim()&&T("claimNumber")},children:[e.jsxs(B,{htmlFor:"insuranceCompany",className:"text-lg font-medium flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-primary"}),"Insurance Company"]}),e.jsx(K,{id:"insuranceCompany",type:"text",placeholder:"State Farm, Geico, etc.",autoCapitalize:"words",className:k(N.insuranceCompany||""),...P.register("insuranceCompany"),enterKeyHint:"next"})]}),e.jsxs("div",{className:"space-y-2",onBlur:()=>{N.claimNumber?.trim()&&T("adjusterName")},children:[e.jsxs(B,{htmlFor:"claimNumber",className:"text-lg font-medium flex items-center gap-2",children:[e.jsx(Ae,{className:"h-5 w-5 text-primary"}),"Claim Number"]}),e.jsx(K,{id:"claimNumber",type:"text",placeholder:"CLM-123456",className:k(N.claimNumber||""),...P.register("claimNumber"),enterKeyHint:"next"})]}),e.jsxs("div",{className:"space-y-2",onBlur:()=>{N.adjusterName?.trim()&&T("adjusterPhone")},children:[e.jsxs(B,{htmlFor:"adjusterName",className:"text-lg font-medium flex items-center gap-2",children:[e.jsx(He,{className:"h-5 w-5 text-primary"}),"Adjuster Name"]}),e.jsx(K,{id:"adjusterName",type:"text",placeholder:"John Doe",autoCapitalize:"words",className:k(N.adjusterName||""),...P.register("adjusterName"),enterKeyHint:"next"})]}),e.jsxs("div",{className:"space-y-2",onBlur:()=>{N.adjusterPhone?.trim()&&T("kiosk-continue-btn")},children:[e.jsxs(B,{htmlFor:"adjusterPhone",className:"text-lg font-medium flex items-center gap-2",children:[e.jsx(ie,{className:"h-5 w-5 text-primary"}),"Adjuster Phone"]}),e.jsx(K,{id:"adjusterPhone",type:"tel",placeholder:"(555) 123-4567",inputMode:"tel",className:k(N.adjusterPhone||""),...P.register("adjusterPhone",{onChange:t=>{t.target.value=O(t.target.value)}}),enterKeyHint:"done"})]}),e.jsxs("div",{className:"sticky bottom-3 z-10 flex gap-3 rounded-md border bg-card p-2 shadow-lg",children:[e.jsxs(M,{type:"button",variant:"outline",size:"lg",onClick:z,disabled:c,className:"flex-1 h-14 text-lg font-medium kiosk-glow",children:[e.jsx(Re,{className:"h-5 w-5 mr-2"}),"Skip"]}),e.jsx(M,{id:"kiosk-continue-btn",type:"submit",size:"lg",disabled:c,className:"flex-1 h-14 text-lg font-semibold",children:c?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"h-5 w-5 animate-spin mr-2"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-5 w-5 mr-2"}),"Done"]})})]})]})})]})}function Ze({customerName:a,onReset:n,autoResetSeconds:r=5}){const[c,f]=l.useState(r);return l.useEffect(()=>{Ne("complete").catch(()=>{});const u=setInterval(()=>{f(i=>i<=1?(clearInterval(u),n(),0):i-1)},1e3);return()=>clearInterval(u)},[n]),e.jsx(W,{className:"w-full max-w-lg shadow-xl border-2 bg-primary/5",children:e.jsxs(X,{className:"pt-12 pb-10 text-center",children:[e.jsx("div",{className:"mb-6 flex justify-center",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-primary/20 rounded-full animate-ping"}),e.jsx("div",{className:"relative w-24 h-24 bg-primary rounded-full flex items-center justify-center",children:e.jsx(ue,{className:"h-14 w-14 text-primary-foreground"})})]})}),e.jsx("h1",{className:"text-4xl font-bold text-foreground mb-4",children:"Success!"}),e.jsxs("p",{className:"text-xl text-muted-foreground mb-8 leading-relaxed",children:["Thank you, ",e.jsx("span",{className:"font-semibold text-foreground",children:a}),"!",e.jsx("br",{}),"A team member will be with you shortly."]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Resetting in ",c," second",c!==1?"s":"","..."]}
1),e.jsxs(M,{variant:"outline",size:"lg",onClick:n,className:"h-14 px-8 text-lg font-medium",children:[e.jsx(Me,{className:"h-5 w-5 mr-2"}),"Add Another Customer"]})]})})}function et({onExit:a,onCancel:n}){return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center p-6",children:e.jsxs(W,{className:"w-full max-w-sm shadow-2xl border-2",children:[e.jsxs(Z,{className:"text-center pb-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-primary/10 rounded-full flex items-center justify-center mb-4",children:e.jsx(ze,{className:"h-8 w-8 text-primary"})}),e.jsx(ee,{className:"text-2xl font-bold",children:"Staff Mode"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Exit kiosk to access the dashboard?"})]}),e.jsxs(X,{className:"space-y-3",children:[e.jsxs(M,{variant:"default",size:"lg",onClick:a,className:"w-full h-12 text-base font-medium",children:[e.jsx(Ve,{className:"h-5 w-5 mr-2"}),"Exit to Dashboard"]}),e.jsxs(M,{variant:"outline",size:"lg",onClick:n,className:"w-full h-12 text-base font-medium",children:[e.jsx(Oe,{className:"h-5 w-5 mr-2"}),"Cancel"]})]})]})})}function yt(){const a=pe(),{currentBusiness:n,loading:r}=ve(),[c,f]=l.useState(!1),[u,i]=l.useState(0);l.useEffect(()=>{const d=S=>!!S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.tagName==="SELECT"),b=()=>{const S=document.activeElement;if(!d(S))return;const Y=window.visualViewport,de=Y?Y.offsetTop:0,he=Y?Y.height:window.innerHeight,fe=S.getBoundingClientRect(),xe=
1de+Math.min(140,he*.25),ae=fe.top-xe;Math.abs(ae)>8&&window.scrollBy({top:ae,behavior:"smooth"})};let h=[];const I=()=>{h.forEach(clearTimeout),h=[60,250,500].map(S=>window.setTimeout(b,S))},H=S=>{d(S.target)&&(i(Math.round(window.innerHeight*.6)),I())},R=()=>{window.setTimeout(()=>{d(document.activeElement)||i(0)},150)},se=window.visualViewport;return document.addEventListener("focusin",H),document.addEventListener("focusout",R),se?.addEventListener("resize",I),()=>{h.forEach(clearTimeout),document.removeEventListener("focusin",H),document.removeEventListener("focusout",R),se?.removeEventListener("resize",I)}},[]),l.useEffect(()=>{const d=b=>{const h=b.target;if(b.key!=="Enter"||!h||h.tagName!=="INPUT")return;const I=h.form;if(!I)return;const H=Array.from(I.querySelectorAll("input:not([type=hidden]):not([disabled]), textarea")),R=H.indexOf(h);R>=0&&R<H.length-1&&(b.preventDefault(),H[R+1].focus())};return document.addEventListener("keydown",d,!0),()=>document.removeEventListener("keydown",d,!0)},[]);const[x,m]=l.useState(""),[o,v]=l.useState(!1),[p,V]=l.useState(()=>Te()),y=!n&&!!p,_=n?.id||(y?p.business_id:""),T=n?.name||p?.business_name||"",g=n?.logo_url||null;l.useEffect(()=>{if(!y||!p)return;let d=!1;const b=async()=>{try{await Se(p)}catch(I){!d&&I?.message==="device_revoked"&&(Ee(),V(null))}};b();const h=setInterval(b,5*60*1e3);return()=>{d=!0,clearInterval(h)}},[y,p]),$e(n?.id);const P=ke({businessId:n?.id||"",enabled:!!n?.id}),E=Ye(y?p:null),{pendingTask:N,startTask:k,completeTask:O,cancelTask:Q}=y?E:P,A=l.useRef(null);l.useEffect(()=>{N&&(A.current=N)},[N]);const F=N||A.current,[$,z]=l.useState(0),[q,t]=l.useState(0);l.useEffect(()=>{N&&N.status==="pending"&&k(N.id)},[N?.id,N?.status,k]);const s=()=>{F&&O(F.id),A.current=null},j=()=>{F&&Q(F.id),A.current=null},w=()=>{const d=Date.now();d-q>500?z(1):z(b=>b+1),t(d)};l.useEffect(()=>{$>=3&&(v(!0),z(0))},[$]);const L=d=>{m(d),f(!0)},D=()=>{f(!1),m("")},C=()=>{try{localStorage.setItem("fw:kiosk_unlocked_until",String(Date.now()+72e5))}catch{}a("/business-dashboard")};return r&&!n&&!p?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(te,{className:"h-8 w-8 animate-spin text-primary"})}):_?e.jsxs("div",{className:"min-h-[100dvh] bg-gradient-to-b from-background to-muted/30 relative overflow-x-clip",children:[e.jsx("div",{className:"absolute top-0 right-0 w-20 h-20 z-50",onClick:w,"aria-hidden":"true"}),o&&e.jsx(et,{onExit:C,onCancel:()=>v(!1)}),F&&e.jsx(Ce,{task:F,onComplete:s,onCancel:j,autoResetSeconds:30,deviceSession:y?p:null}),e.jsxs("div",{className:`min-h-[100dvh] flex flex-col items-center p-6 ${u>0?"justify-start":"justify-start sm:justify-center pb-40 sm:pb-6"}`,style:u>0?{paddingBottom:u}:void 0,children:[e.jsx("div",{className:"mb-8 text-center",children:g?e.jsx("img",{src:g,alt:T,className:"h-16 mx-auto mb-4 object-contain"}):e.jsx("h2",{className:"text-xl font-medium text-muted-foreground mb-4",children:T})}),c?e.jsx(Ze,{customerName:x,onReset:D}):e.jsx(Qe,{businessId:_,onSuccess:L,deviceSession:y?p:null}),e.jsxs("p",{className:"mt-6 text-center text-[10px] text-muted-foreground/60 select-none",children:["v",je().slice(-6)||"dev"]})]})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-6",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"This tablet isn't set up yet"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Ask the shop for a pairing code, then enter it to turn this tablet into the front-desk check-in screen."}),e.jsx("button",{className:"text-primary underline text-lg",onClick:()=>a("/kiosk/pair"),children:"Enter pairing code"})]})})}export{yt 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.