1import{v as S,u as C,a as E,d as L,r as f,w as p,i as j,f as T,j as e,P as x,B as o,C as i,g as c,A as d,n as g}from"./index-BXLW5ieO.js";import A from"./purify.es-DBIK8olT.js";import{A as k,a as _}from"./sanitize-config-ColsXBJR.js";import{S as h}from"./SubscriptionGate-C5r1JKU-.js";import{J as N}from"./JourneyProgressBar-C_xWYPCS.js";import{E as q}from"./educationalContent-DumgMAbe.js";import{g as R}from"./supabaseDemandLetterStore-CyIEmXuW.js";import{c as D,a as P}from"./useCanonicalEmployment-Dm3ADmqM.js";import{T as F}from"./triangle-alert-BUDdiHIG.js";const B={"pre-letter":{dbSlot:"pre_letter",stepId:"education-pre",title:"Understanding Your Rights",subtitle:"Before generating your demand letter, take a moment to understand what you're entitled to and how the process works.",nextRoute:"/journey/demand-letter",nextLabel:"Generate Your Demand Letter",pageTitle:"Your Rights | DemandPay"},"post-letter":{dbSlot:"post_letter",stepId:"education-post",title:"What Happens Next",subtitle:"Your demand letter is ready. Here's what to expect after you send it.",nextRoute:"/journey/next-steps",nextLabel:"Review & Send Options",pageTitle:"Next Steps | DemandPay"}};function I(n){if(!n)return null;try{const t=new URL(n);if(t.hostname.includes("youtube.com")&&t.searchParams.get("v"))return`https://www.youtube.com/embed/${t.searchParams.get("v")}`;if(t.hostname==="youtu.be")return`https://www.youtube.com/embed${t.pathname}`;if(t.hostname.includes("vimeo.com")){const s=t.pathname.split("/").filter(Boolean).pop();if(s&&/^\d+$/.test(s))return`https://player.vimeo.com/video/${s}`}return t.pathname.includes("/embed/")||t.hostname==="player.vimeo.com"?n:null}catch{return null}}function H(){const{slot:n}=S(),t=B[n],{user:s}=C(),r=E(s?.id),y=L();f.useEffect(()=>{document.title=t?.pageTitle||"Education | DemandPay"},[t]),f.useEffect(()=>{!s?.id||n!=="pre-letter"||(p.prefetchQuery({queryKey:["demand-letter-draft",s.id],queryFn:()=>R({userId:s.id}),staleTime:3e4}),p.prefetchQuery({queryKey:D(s.id),queryFn:async()=>{const a=await j(),{data:l,error:m}=await a.from("case_facts").select("*").eq("user_id",s.id).maybeSingle();return m?null:l??null},staleTime:6e4}),p.prefetchQuery({queryKey:P(s.id),queryFn:async()=>{const a=await j(),{data:l,error:m}=await a.from("employments").select("*, employer:employers(*)").eq("owner_id",s.id).order("updated_at",{ascending:!1}).limit(1).maybeSingle();return m?null:l??null},staleTime:6e4}))},[s?.id,n]);const{data:b=[],isLoading:w,isError:v}=T({queryKey:["journey-education",t?.dbSlot],queryFn:async()=>{if(!t)return[];try{return await q.listByJourneySlot(t.dbSlot)}catch(a){return console.error("[JourneyEducation] Fetch error:",a),[]}},enabled:!!t,staleTime:5*6e4,retry:1,refetchOnWindowFocus:!1});if(!t)return e.jsx(x,{children:e.jsx(h,{children:e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-8 text-center",children:e.jsxs("p",{className:"text-slate-600",children:["Unknown education slot. ",e.jsx(o,{variant:"link",onClick:()=>y("/Dashboard"),children:"Back to Dashboard"})]})})})});if(!r.isLoading&&!r.canAccess(t.stepId))return e.jsx(x,{children:e.jsx(h,{children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-8",children:[e.jsx(N,{currentStep:r.currentStep,completedSteps:r.completedSteps,canAccess:r.canAccess,className:"mb-8"}),e.jsx(i,{children:e.jsxs(c,{className:"py-8 text-center",children:[e.jsx(F,{className:"w-10 h-10 text-amber-500 mx-auto mb-4","aria-hidden":"true"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-900 mb-2",children:"Complete the previous step first"}),e.jsxs(o,{onClick:()=>r.navigateToCurrentStep(),className:"bg-brand-navy hover:bg-brand-navy/90 rounded-full mt-4",children:["Go to Current Step ",e.jsx(d,{className:"w-4 h-4 ml-2","aria-hidden":"true"})]})]})})]})})});const u=()=>{r.markEducationSeen(n),y(t.nextRoute)};return e.jsx(x,{children:e.jsx(h,{children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-8",children:[e.jsx(N,{currentStep:r.currentStep,completedSteps:r.completedSteps,canAccess:r.canAccess,className:"mb-8"}),e.jsx("h1",{className:"sr-only",children:t.title}),e.jsxs("div",{className:"space-y-1 mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:"w-6 h-6 text-brand-navy","aria-hidden":"true"}),e.jsx("h2",{className:"text-2xl font-serif font-bold text-brand-navy",children:t.title})]}),e.jsx("p",{className:"text-slate-600",children:t.subtitle})]}),w||r.isLoading&&r.completedSteps.length===0?e.jsx("div",{className:"space-y-6","aria-busy":"true","aria-label":"Loading educational content",children:[1,2].map(a=>e.jsx("div",{className:"h-40 bg-slate-100 rounded-xl animate-pulse"},a))}):v?e.jsx(i,{className:"border-amber-200",children:e.jsxs(c,{className:"py-8 text-center",children:[e.jsx("p",{className:"text-slate-600 mb-4",children:"We could not load this
1section. You can continue to the next step."}),e.jsxs(o,{onClick:u,className:"bg-brand-navy hover:bg-brand-navy/90 rounded-full",children:["Continue ",e.jsx(d,{className:"w-4 h-4 ml-2","aria-hidden":"true"})]})]})}):b.length===0?e.jsx(i,{className:"border-slate-200",children:e.jsxs(c,{className:"py-12 text-center",children:[e.jsx(g,{className:"w-10 h-10 text-slate-300 mx-auto mb-4","aria-hidden":"true"}),e.jsx("h3",{className:"text-lg font-semibold text-slate-700 mb-2",children:"Content Coming Soon"}),e.jsx("p",{className:"text-slate-500 mb-6",children:"Educational content for this step is being prepared."}),e.jsxs(o,{onClick:u,className:"bg-brand-navy hover:bg-brand-navy/90 rounded-full",children:["Skip for Now ",e.jsx(d,{className:"w-4 h-4 ml-2","aria-hidden":"true"})]})]})}):e.jsxs("div",{className:"space-y-8",children:[b.map(a=>{const l=I(a.video_url);return e.jsx(i,{className:"border-slate-200",children:e.jsxs(c,{className:"p-6 sm:p-8",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-3",children:a.title}),a.summary&&e.jsx("p",{className:"text-slate-600 mb-4 leading-relaxed",children:a.summary}),l&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-slate-100 mb-4",children:e.jsx("iframe",{src:l,title:`Video: ${a.title}`,className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy",sandbox:"allow-scripts allow-same-origin allow-popups"})}),a.content&&e.jsx("div",{className:"prose prose-slate prose-sm max-w-none",dangerouslySetInnerHTML:{__html:A.sanitize(a.content,{ALLOWED_TAGS:_,ALLOWED_ATTR:k})}})]})},a.id)}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsxs(o,{onClick:u,className:"bg-brand-navy hover:bg-brand-navy/90 rounded-full",children:[t.nextLabel,e.jsx(d,{className:"w-4 h-4 ml-2","aria-hidden":"true"})]})})]})]})})})}export{H 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.