import{r as j,j as e,p as L,o as h,n as A}from"./index-D4ZMoJFe.js";function V({open:t,loading:r,checksLoading:N,checksError:d,draft:l,controlChecks:a,confirmationText:i,onConfirmationTextChange:f,onClose:n,onRefreshChecks:v,onConfirm:y}){var p,b,u,g;const[o,m]=j.useState(!1);j.useEffect(()=>{t||m(!1)},[t]);const x=!!((p=a==null?void 0:a.zero_lines)!=null&&p.length),c=!!(a!=null&&a.can_validate),z=c&&i.trim().toUpperCase()==="VALIDER"&&(!x||o)&&!r;return e.jsx(L,{open:t,title:"Validation de la G50",subtitle:"Contrôle final",onClose:n,maxWidthClassName:"max-w-3xl",children:e.jsxs("div",{className:"space-y-6 px-6 py-6",children:[N?e.jsx("div",{className:"space-y-3",children:Array.from({length:4}).map((s,_)=>e.jsx("div",{className:"h-16 animate-pulse rounded-2xl border border-border bg-surface2"},`g50-validation-skeleton-${_}`))}):d?e.jsxs("div",{className:"rounded-2xl border border-danger/20 bg-danger/10 px-4 py-4 text-sm text-danger",children:[e.jsx("p",{className:"font-semibold",children:"Contrôle impossible"}),e.jsx("p",{className:"mt-2 leading-6",children:d}),e.jsx("button",{type:"button",className:"btn-secondary mt-4",onClick:v,children:"Relancer les contrôles"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-2xl border border-border bg-surface2 px-4 py-4",children:[e.jsx("p",{className:"text-sm font-semibold text-text",children:((u=(b=l==null?void 0:l.header)==null?void 0:b.descriptor)==null?void 0:u.period_label)||"Période G50"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-textMuted",children:"Une fois validée, la G50 ne pourra plus être modifiée sans autorisation spéciale."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-4 text-sm text-emerald-700",children:e.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[e.jsx(h,{size:16}),"Brouillon chargé et contrôles de validation disponibles"]})}),e.jsx("div",{className:"rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-4 text-sm text-emerald-700",children:e.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[e.jsx(h,{size:16}),((g=l==null?void 0:l.lines)==null?void 0:g.filter(s=>s.is_manually_adjusted).length)||0," ajustement(s) manuel(s) documenté(s)"]})}),x?e.jsxs("div",{className:"rounded-2xl border border-gold/20 bg-gold/10 px-4 py-4 text-sm text-gold",children:[e.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[e.jsx(A,{size:16}),"Rubriques à zéro à confirmer"]}),e.jsx("p",{className:"mt-2 leading-6",children:a.zero_lines.map(s=>`${s.code} ${s.label}`).join(", ")}),e.jsxs("label",{className:"mt-4 flex items-start gap-3 text-sm text-text",children:[e.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-border text-accent focus:ring-accent",checked:o,onChange:s=>m(s.target.checked)}),e.jsx("span",{children:"Je confirme que ces rubriques à zéro sont normales pour cette période."})]})]}):null,((a==null?void 0:a.checks)||[]).map(s=>e.jsxs("div",{className:`rounded-2xl border px-4 py-4 text-sm ${s.ok?"border-emerald-200 bg-emerald-50 text-emerald-700":s.is_critical?"border-danger/20 bg-danger/10 text-danger":"border-gold/20 bg-gold/10 text-gold"}`,children:[e.jsx("p",{className:"font-semibold",children:s.label}),e.jsx("p",{className:"mt-1",children:s.result_label})]},s.key))]}),e.jsxs("label",{className:"space-y-2",children:[e.jsxs("span",{className:"text-sm font-medium text-text",children:["Saisissez ",e.jsx("span",{className:"font-semibold text-danger",children:"VALIDER"})," pour confirmer"]}),e.jsx("input",{type:"text",className:"input-base",value:i,onChange:s=>f(s.target.value),placeholder:"VALIDER"})]}),c?null:e.jsx("p",{className:"text-sm text-danger",children:"Les contrôles critiques doivent être conformes avant validation."})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",className:"btn-secondary",onClick:n,children:"Annuler"}),e.jsx("button",{type:"button",className:"rounded-lg bg-danger px-4 py-2 text-sm font-medium text-white transition hover:bg-danger/90 disabled:cursor-not-allowed disabled:opacity-60",onClick:y,disabled:!z,children:r?"Validation...":"Confirmer la validation"})]})]})})}export{V as G};
