PageSourceSearch

https://distribuidoraeficaz.com.br/assets/TrainingPublic-BqmNApEc.js

js distribuidoraeficaz.com.br collected 2026-09-30 06:37:58 UTC 7,512 bytes, 1 lines download raw bytes

1import{a0 as I,$ as M,r as c,j as e,H as R,B as w,a1 as D}from"./index-DD08oKkH.js";import{P as z}from"./progress-nwLCo5Sa.js";import{B as P}from"./badge-TzaVLEqa.js";import V from"./purify.es-sOfw8HaZ.js";import{L as H}from"./loader-circle-bWaExBdR.js";import{G as U}from"./graduation-cap-96y0_fdT.js";import{C as q}from"./check-Vq6YUZzP.js";import{C as G}from"./circle-CbJ5QwxK.js";import{V as J}from"./video-BfYRNLs0.js";import{F as Y}from"./file-text-BGF_vpkj.js";const F="https://msbrdgrpznlyekahuyhc.supabase.co/functions/v1";function Z(l){const g=l.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([A-Za-z0-9_-]+)/);if(g)return`https://www.youtube.com/embed/${g[1]}`;const p=l.match(/vimeo\.com\/(\d+)/);return p?`https://player.vimeo.com/video/${p[1]}`:null}function oe(){var T;const{token:l}=I(),p=M().pathname.includes("/treinamento/publico/"),[i,_]=c.useState(null),[x,k]=c.useState(null),[L,S]=c.useState(!0),[j,h]=c.useState(null),[O,C]=c.useState(!1),B=async()=>{var s;if(l){S(!0);try{const n=p?`public_token=${encodeURIComponent(l)}`:`token=${encodeURIComponent(l)}`,r=await fetch(`${F}/training-public-view?${n}`),a=await r.json();r.ok?(_(a),(s=a.lessons)!=null&&s.length&&!j&&h(a.lessons[0].id)):k(a.error||"erro")}catch(n){k(String((n==null?void 0:n.message)||n))}finally{S(!1)}}};c.useEffect(()=>{B()},[l]);const m=c.useMemo(()=>new Set(((i==null?void 0:i.progress)||[]).map(s=>s.lesson_id)),[i]),o=c.useMemo(()=>{if(!i)return[];const s=Object.fromEntries(i.modules.map(n=>[n.id,n.position]));return[...i.lessons].sort((n,r)=>s[n.module_id]-s[r.module_id]||n.position-r.position)},[i]),u=o.findIndex(s=>s.id===j),t=u>=0?o[u]:null,b=o.filter(s=>s.required).length||o.length,$=o.filter(s=>(s.required||!o.some(n=>n.required))&&m.has(s.id)).length,E=b?Math.round($/b*100):0,A=async(s,n)=>{C(!0);try{const r=await fetch(`${F}/training-mark-lesson`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:l,lesson_id:s,done:n})}),a=await r.json();if(!r.ok)throw new Error(a.error||"erro");_(d=>d&&{...d,progress:n?[...d.progress.filter(N=>N.lesson_id!==s),{lesson_id:s,completed_at:new Date().toISOString()}]:d.progress.filter(N=>N.lesson_id!==s)})}catch{D.error("Não foi possível salvar. Tente novamente.")}finally{C(!1)}};if(L)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(H,{className:"h-8 w-8 animate-spin text-primary"})});if(x||!i)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center max-w-md p-6",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Treinamento indisponível"}),e.jsx("p",{className:"text-muted-foreground",children:x==="not_found"?"Link inválido ou removido.":x==="expired"?"Este link expirou.":x==="inactive"?"Este treinamento está inativo no momento.":"Não foi possível carregar o treinamento."})]})});const v=(t==null?void 0:t.lesson_type)==="kb_article"&&t.content_slug?i.articles[t.content_slug]:null,y=(t==null?void 0:t.lesson_type)==="video"&&t.video_url?Z(t.video_url):null,f=i.mode==="public"||!i.enrollment;return e.jsxs(e.Fragment,{children:[e.jsx(R,{children:e.jsx("title",{children:i.track.name})}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(U,{className:"h-5 w-5 text-primary shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold truncate",children:i.track.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:f?"Acesso público":`Olá, ${(T=i.enrollment)==null?void 0:T.name}`})]})]}),!f&&e.jsxs("div",{className:"flex items-center gap-3 min-w-[200px]",children:[e.jsx(z,{value:E,className:"w-40"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[$,"/",b," · ",E,"%"]})]})]})}),e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-6 grid grid-cols-1 lg:grid-cols-[320px_1fr] gap-6",children:[e.jsx("aside",{className:"space-y-4",children:i.modules.map(s=>{const n=o.filter(r=>r.module_id===s.id);return e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/40 px-3 py-2 border-b",children:e.jsx("p",{className:"text-sm font-semibold",children:s.title})}),e.jsx("ul",{children:n.map(r=>{const a=m.has(r.id),d=r.id===j;return e.jsx("li",{children:e.jsxs("button",{onClick:()=>h(r.id),className:`w-full text-left px-3 py-2 flex items-start gap-2 text-sm hover:bg-muted/50 transition-colors ${d?"bg-primary/10":""}`,children:[a?e.jsx(q,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}):e.jsx(G,{className:"h-4 w-4 text-muted-foreground shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`truncate ${a?"text-muted-foreground line-through":""}`,children:r.title}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r.lesson_type==="video"?e.jsx(J,{className:"h-3 w-3"}):e.jsx(Y,{className:"h-3 w-3"}),r.duration_minutes?`${r.duration_minutes} min`:r.lesson_type==="video"?"Vídeo":"Artigo"]})]})]})},r.id)})})]},s.id)})}),e.jsx("main",{className:"min-w-0",children:t?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(P,{variant:"outline",children:t.lesson_type==="video"?"Vídeo":"Artigo"}),t.required&&e.jsx(P,{variant:"secondary",children:"Obrigatória"})]}),e.jsx("h1",{className:"text-2xl font-bold",children:t.title}),t.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:t.description})]}),t.lesson_type==="video"&&y&&e.jsx("div",{className:"relative w-full pt-[56.25%] rounded-lg overflow-hidden bg-black",children:e.jsx("iframe",{className:"absolute inset-0 w-full h-full",src:y,title:t.title,frameBorder:0,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.lesson_type==="video"&&!y&&e.jsx("a",{href:t.video_url,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"Abrir vídeo"}
1),t.lesson_type==="kb_article"&&v&&e.jsx("article",{className:"prose prose-lg max-w-none dark:prose-invert prose-headings:font-bold prose-a:text-primary prose-img:rounded-lg",dangerouslySetInnerHTML:{__html:V.sanitize(v.content||"",{ADD_ATTR:["class","colwidth","colspan","rowspan"]})}}),t.lesson_type==="kb_article"&&!v&&e.jsx("p",{className:"text-muted-foreground",children:"Artigo não disponível."}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-4 gap-2 flex-wrap",children:[e.jsx(w,{variant:"outline",disabled:u<=0,onClick:()=>{var s;return h(((s=o[u-1])==null?void 0:s.id)||null)},children:"Anterior"}),!f&&e.jsx(w,{disabled:O,onClick:()=>A(t.id,!m.has(t.id)),variant:m.has(t.id)?"secondary":"default",children:m.has(t.id)?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"h-4 w-4 mr-2"})," Concluída — desmarcar"]}):e.jsx(e.Fragment,{children:"Marcar como concluída"})}),e.jsx(w,{disabled:u>=o.length-1,onClick:()=>{var s;!f&&!m.has(t.id)&&A(t.id,!0),h(((s=o[u+1])==null?void 0:s.id)||null)},children:"Próxima aula"})]})]}):e.jsx("p",{className:"text-muted-foreground",children:"Selecione uma aula."})})]})]})]})}export{oe 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.