PageSourceSearch

https://campwee.com/assets/LotOperationnelDetailPage-DLqUFJHT.js

js campwee.com collected 2026-10-07 14:43:25 UTC 46,146 bytes, 1 lines download raw bytes

1import{u as W,r as b,b as R,c as N,aU as o,j as e,a6 as ve,at as Ne,bm as te,a0 as ee,H as ke,c6 as fe,b2 as we,G as _e,Z as S,aj as Se,b7 as Ce,m as Fe,cr as Ee,D as Le,br as qe,cs as Me}from"./vendor-CP7SK-71.js";import{l as p}from"./lotsOperationnelsApi-BlmItx_7.js";import{u as se,E as Re,Q as me}from"./index-X7X_BvP-.js";import{uploadFile as Ae}from"./storageApi-D-9hFth7.js";import{S as z}from"./SejoursHubBackNav-pocDU93s.js";import{u as De}from"./useBudgetPosteLignes-hiNSNnSR.js";import{f as V,b as Te}from"./vendor-utils-Cx3EO531.js";const Ke=({lotId:n})=>{const r=W(),{user:v}=se(),u=b.useMemo(()=>new Set(v?.permissions??[]),[v?.permissions]),m=u.has("*")||u.has("ops.tickets.create")||u.has("ops.tickets.reply")||u.has("ops.tickets.status.update"),[j,k]=b.useState({statut:"",categorie:"",q:""}),[g,C]=b.useState(null),[d,F]=b.useState({categorie:"LOGISTIQUE",titre:"",description:""}),[x,h]=b.useState(""),[q,A]=b.useState(!1),{data:$,isLoading:B,refetch:O}=R({queryKey:["lots-operationnels",n,"ops-tickets",j],queryFn:async()=>p.listOpsTickets(n,{statut:j.statut||void 0,categorie:j.categorie||void 0,q:j.q||void 0,page:1,limit:50}),enabled:n>0}),M=$?.data||[],{data:f}=R({queryKey:["lots-operationnels",n,"ops-ticket",g],queryFn:async()=>p.getOpsTicket(n,g),enabled:n>0&&g!=null}),E=f,T=N({mutationFn:async()=>p.createOpsTicket(n,{categorie:d.categorie,titre:d.titre.trim(),description:d.description.trim()||void 0}),onSuccess:a=>{r.invalidateQueries({queryKey:["lots-operationnels",n,"ops-tickets"]}),C(a.id),F({categorie:"LOGISTIQUE",titre:"",description:""}),o.success("Ticket créé")},onError:a=>o.error(a?.response?.data?.error??"Erreur création")}),w=N({mutationFn:async a=>p.addOpsTicketMessage(n,g,a),onSuccess:()=>{r.invalidateQueries({queryKey:["lots-operationnels",n,"ops-ticket",g]}),h(""),o.success("Message envoyé")},onError:a=>o.error(a?.response?.data?.error??"Erreur envoi")}),K=N({mutationFn:async a=>p.updateOpsTicketStatus(n,g,a),onSuccess:()=>{r.invalidateQueries({queryKey:["lots-operationnels",n,"ops-tickets"]}),r.invalidateQueries({queryKey:["lots-operationnels",n,"ops-ticket",g]}),o.success("Statut mis à jour")},onError:a=>o.error(a?.response?.data?.error??"Erreur statut")}),c=async a=>{if(!(!m||!g))try{A(!0);const i=Date.now(),P=a.name.replace(/[^a-zA-Z0-9.-]/g,"_"),Z="campeurs-documents",Q=`ops/lot/${n}/tickets/${g}/${i}-${P}`,D=await Ae(a,Z,Q,!1);await p.addOpsTicketAttachment(n,g,{bucket:D.bucket,path:D.path,original_name:D.originalName,size:D.size,content_type:D.contentType}),r.invalidateQueries({queryKey:["lots-operationnels",n,"ops-ticket",g]}),o.success("Pièce jointe ajoutée")}catch(i){const P=i;o.error(P?.response?.data?.error??P?.message??"Erreur upload")}finally{A(!1)}};return e.jsxs("div",{className:"mt-10 space-y-4",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(ve,{className:"h-5 w-5 text-indigo-600"}),"Ops / Tickets (lot)"]}),e.jsx("p",{className:"text-sm text-gray-600",children:"Tickets logistique ou restauration pour l’ensemble du lot. Les tickets liés à un séjour précis restent sur la fiche du séjour."}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"border border-gray-200 rounded-lg bg-white p-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"Liste"}),e.jsxs("button",{type:"button",onClick:()=>void O(),className:"inline-flex items-center gap-1 text-sm text-gray-600 hover:text-gray-900",children:[e.jsx(Ne,{className:`h-4 w-4 ${B?"animate-spin":""}`}),"Actualiser"]})]}),e.jsx("input",{value:j.q,onChange:a=>k(i=>({...i,q:a.target.value})),placeholder:"Rechercher…",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("select",{value:j.categorie,onChange:a=>k(i=>({...i,categorie:a.target.value})),className:"px-2 py-1.5 border border-gray-300 rounded-md text-sm",children:[e.jsx("option",{value:"",children:"Catégorie"}),e.jsx("option",{value:"LOGISTIQUE",children:"Logistique"}),e.jsx("option",{value:"RESTAURATION",children:"Restauration"}),e.jsx("option",{value:"AUTRE",children:"Autre"})]}),e.jsxs("select",{value:j.statut,onChange:a=>k(i=>({...i,statut:a.target.value})),className:"px-2 py-1.5 border border-gray-300 rounded-md text-sm",children:[e.jsx("option",{value:"",children:"Statut"}),e.jsx("option",{value:"NOUVEAU",children:"Nouveau"}),e.jsx("option",{value:"EN_COURS",children:"En cours"}),e.jsx("option",{value:"EN_ATTENTE",children:"En attente"}),e.jsx("option",{value:"TERMINE",children:"Terminé"}),e.jsx("option",{value:"ANNULE",children:"Annulé"})]})]}),m&&e.jsxs("div",{className:"border-t border-gray-100 pt-3 space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-gray-700",children:"Nouveau ticket"}
1),e.jsxs("select",{value:d.categorie,onChange:a=>F(i=>({...i,categorie:a.target.value})),className:"w-full px-2 py-1.5 border border-gray-300 rounded-md text-sm",children:[e.jsx("option",{value:"LOGISTIQUE",children:"Logistique"}),e.jsx("option",{value:"RESTAURATION",children:"Restauration"}),e.jsx("option",{value:"AUTRE",children:"Autre"})]}),e.jsx("input",{value:d.titre,onChange:a=>F(i=>({...i,titre:a.target.value})),placeholder:"Titre",className:"w-full px-2 py-1.5 border border-gray-300 rounded-md text-sm"}),e.jsx("textarea",{value:d.description,onChange:a=>F(i=>({...i,description:a.target.value})),placeholder:"Description (optionnel)",rows:2,className:"w-full px-2 py-1.5 border border-gray-300 rounded-md text-sm"}),e.jsxs("button",{type:"button",disabled:T.isPending||!d.titre.trim(),onClick:()=>T.mutate(),className:"inline-flex items-center gap-1 px-3 py-1.5 bg-indigo-600 text-white rounded-md text-sm disabled:opacity-50",children:[e.jsx(te,{className:"h-4 w-4"}),"Créer"]})]}),e.jsxs("ul",{className:"divide-y divide-gray-100 max-h-80 overflow-y-auto",children:[M.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>C(a.id),className:`w-full text-left px-2 py-2 text-sm hover:bg-gray-50 ${g===a.id?"bg-indigo-50":""}`,children:[e.jsx("div",{className:"font-medium text-gray-900",children:a.titre}),e.jsxs("div",{className:"text-xs text-gray-500",children:[a.statut," · ",a.categorie,a._count?` · ${a._count.messages} msg`:""]})]})},a.id)),M.length===0&&!B&&e.jsx("li",{className:"text-sm text-gray-500 py-4 text-center",children:"Aucun ticket"})]})]}),e.jsx("div",{className:"border border-gray-200 rounded-lg bg-white p-4 min-h-[200px]",children:!g||!E?e.jsx("p",{className:"text-sm text-gray-500",children:"Sélectionnez un ticket pour voir le fil."}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900",children:E.titre}),e.jsxs("p",{className:"text-xs text-gray-500",children:[E.statut," · ",E.categorie]}),E.description?e.jsx("p",{className:"text-sm text-gray-700 mt-2",children:E.description}):null]}),m&&e.jsx("div",{className:"flex flex-wrap gap-2",children:["NOUVEAU","EN_COURS","EN_ATTENTE","TERMINE","ANNULE"].map(a=>e.jsx("button",{type:"button",disabled:K.isPending,onClick:()=>K.mutate(a),className:"px-2 py-1 text-xs border border-gray-200 rounded hover:bg-gray-50",children:a},a))}),e.jsx("div",{className:"border-t border-gray-100 pt-2 space-y-2 max-h-48 overflow-y-auto",children:(E.messages||[]).map(a=>e.jsxs("div",{className:"text-sm bg-gray-50 rounded p-2",children:[a.message,e.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:new Date(a.created_at).toLocaleString("fr-FR")})]},a.id))}),m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:x,onChange:a=>h(a.target.value),placeholder:"Répondre…",className:"flex-1 px-2 py-1.5 border border-gray-300 rounded-md text-sm",onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),x.trim()&&w.mutate(x.trim()))}}),e.jsx("button",{type:"button",disabled:w.isPending||!x.trim(),onClick:()=>w.mutate(x.trim()),className:"px-3 py-1.5 bg-indigo-600 text-white rounded-md text-sm disabled:opacity-50",children:"Envoyer"})]}),e.jsxs("label",{className:"block text-xs text-gray-600",children:["Pièce jointe",e.jsx("input",{type:"file",disabled:q,className:"block mt-1 text-sm",onChange:a=>{const i=a.target.files?.[0];i&&c(i),a.target.value=""}})]})]})]})})]})]})},Pe=({lotId:n})=>{const r=W(),[v,u]=b.useState(""),{data:m,isLoading:j}=R({queryKey:["lots-operationnels",n,"groupes"],queryFn:async()=>p.listLotGroupes(n),enabled:Number.isFinite(n)&&n>0}),k=N({mutationFn:async()=>p.createLotGroupe(n,{nom:v.trim()}),onSuccess:()=>{u(""),r.invalidateQueries({queryKey:["lots-operationnels",n,"groupes"]}),o.success("Groupe créé")},onError:d=>o.error(d.message||"Échec de la création")}),g=N({mutationFn:async d=>p.deleteLotGroupe(n,d),onSuccess:()=>{r.invalidateQueries({queryKey:["lots-operationnels",n,"groupes"]}),o.success("Groupe supprimé")},onError:d=>o.error(d.message||"Échec de la suppression")}
1),C=m??[];return e.jsxs("div",{className:"mt-10 p-4 bg-violet-50/80 border border-violet-200 rounded-lg",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 mb-2",children:"Groupes transverses (lot)"}),e.jsx("p",{className:"text-sm text-gray-600 mb-3",children:"Groupes partagés au niveau du lot (ex. équipe cuisine), distincts des groupes pédagogiques par séjour."}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx("input",{type:"text",value:v,onChange:d=>u(d.target.value),placeholder:"Nom du groupe",className:"flex-1 min-w-[160px] px-3 py-2 border border-violet-200 rounded-md text-sm"}),e.jsxs("button",{type:"button",onClick:()=>v.trim()&&k.mutate(),disabled:!v.trim()||k.isPending,className:"inline-flex items-center gap-1 px-3 py-2 bg-violet-600 text-white rounded-md text-sm disabled:opacity-50",children:[e.jsx(te,{className:"h-4 w-4"}),"Ajouter"]})]}),j?e.jsx("p",{className:"text-sm text-gray-500",children:"Chargement…"}):C.length===0?e.jsx("p",{className:"text-sm text-gray-500",children:"Aucun groupe de lot pour l’instant."}):e.jsx("ul",{className:"space-y-2",children:C.map(d=>e.jsxs("li",{className:"flex items-center justify-between gap-2 text-sm bg-white/80 border border-violet-100 rounded-md px-3 py-2",children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-medium text-violet-900",children:d.nom}),d._count!=null?e.jsxs("span",{className:"text-gray-500 ml-2",children:["(",d._count.group_memberships," membre(s))"]}):null]}),e.jsx("button",{type:"button",onClick:()=>{confirm(`Supprimer le groupe « ${d.nom} » ?`)&&g.mutate(d.id)},className:"p-1 text-red-600 hover:bg-red-50 rounded","aria-label":"Supprimer",children:e.jsx(ee,{className:"h-4 w-4"})})]},d.id))})]})},Ue=({lotId:n})=>{const r=W(),{hasPermission:v}=se(),u=v("hebergement.update")||v("sejour.update"),{data:m,isLoading:j,error:k}=R({queryKey:["lots-operationnels",n,"chambres-attributions"],queryFn:async()=>p.getChambresAttributions(n),enabled:Number.isFinite(n)&&n>0}),[g,C]=b.useState({});b.useEffect(()=>{if(!m?.chambres)return;const x={};for(const h of m.chambres)x[h.chambre_id]=h.attribue_sejour_id;C(x)},[m]);const d=b.useMemo(()=>m?.sejours??[],[m?.sejours]),F=N({mutationFn:async()=>{const x=Object.entries(g).map(([h,q])=>({chambre_id:Number(h),sejour_id:q}));return p.putChambresAttributions(n,{attributions:x})},onSuccess:()=>{r.invalidateQueries({queryKey:["lots-operationnels",n,"chambres-attributions"]}),r.invalidateQueries({queryKey:["chambres-affectations"]}),o.success("Attributions enregistrées")},onError:x=>{const h=x;o.error(h?.response?.data?.error??"Erreur lors de l’enregistrement")}});return j?e.jsx("p",{className:"text-sm text-gray-500",children:"Chargement des chambres…"}):k?e.jsx("p",{className:"text-sm text-red-600",children:"Impossible de charger les attributions."}):m?.chambres.length?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-gray-600",children:["Chaque chambre ne peut être attribuée qu’à ",e.jsx("strong",{children:"un seul séjour"})," du lot. Les affectations participants / personnel sur la page hébergement du séjour respectent cette attribution."]}),e.jsx("div",{className:"overflow-x-auto border border-amber-200 rounded-lg bg-white",children:e.jsxs("table",{className:"min-w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-amber-100/60 text-left text-gray-800",children:[e.jsx("th",{className:"px-3 py-2 font-medium",children:"Lieu"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Bâtiment"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Chambre"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Cap."}),e.jsx("th",{className:"px-3 py-2 font-medium min-w-[12rem]",children:"Attribuée au séjour"})]})}),e.jsx("tbody",{className:"divide-y divide-amber-100",children:m.chambres.map(x=>e.jsxs("tr",{className:"hover:bg-amber-50/40",children:[e.jsx("td",{className:"px-3 py-2 text-gray-800",children:x.hebergement_nom}),e.jsx("td",{className:"px-3 py-2 text-gray-600",children:x.batiment_nom??"—"}),e.jsx("td",{className:"px-3 py-2 font-medium text-gray-900",children:x.chambre_nom}),e.jsx("td",{className:"px-3 py-2 text-gray-600",children:x.capacite}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("select",{className:"w-full max-w-xs border border-gray-300 rounded-md px-2 py-1.5 text-sm bg-white disabled:opacity-60",disabled:!u,value:g[x.chambre_id]??"",onChange:h=>{const q=h.target.value;C(A=>({...A,[x.chambre_id]:q===""?null:Number(q)}))},children:[e.jsx("option",{value:"",children:"Non attribuée"}),d.map(h=>e.jsx("option",{value:h.id,children:h.nom},h.id))]})})]},x.chambre_id))})]})}),u?e.jsxs("button",{type:"button",onClick:()=>F.mutate(),disabled:F.isPending,className:"inline-flex items-center gap-2 px-4 py-2 bg-amber-700 text-white text-sm font-medium rounded-lg hover:bg-amber-800 disabled:opacity-50",children:[e.jsx(fe,{className:"h-4 w-4"}),F.isPending?"Enregistrement…":"Enregistrer les attributions"]}):e.jsx("p",{className:"text-xs text-gray-500",children:"Lecture seule — droits « Modifier hébergements » ou « Modifier séjours » requis pour éditer."})]}):e.jsx("p",{className:"text-sm text-gray-600",children:"Aucune chambre dans les lieux liés aux séjours de ce lot. Liez d’abord des hébergements aux séjours du lot."})},Oe=()=>e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ke,{className:"h-5 w-5 text-amber-800"}),e.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"Attribution des chambres (lot)"})]});function Qe(n){return n?"Modifier la dépense":"Nouvelle dépense"}function H(n,r,v,u){return n?v:r==null?null:u(r)}function I(n){try{return V(new Date(n),"d MMM yyyy",{locale:Te})}catch{return n}}function Je(){const{id:n}=we(),r=parseInt(n??"0",10),v=_e(),u=W(),{hasPermission:m}=se(),{posteLabelsMap:j,orderedCodes:k}=De(),g=b.useMemo(()=>[{value:"",label:"— Poste —"},...k.map(t=>({value:t,label:j[t]??t}))],[k,j]),C=t=>t?j[t]??t:"—",d=m("finances.view")||m("budget.view")||m("depenses.view"),F=m("budget.create")&&m("budget.update"),x=m("sejour.edit"),[h,q]=b.useState(""),[A,$]=b.useState(""),[B,O]=b.useState(!1),[M,f]=b.useState({montant_total_previsionnel:"",commentaire:"",postes:[]}),[E,T]=b.useState(!1),[w,K]=b.useState(null),[c,a]=b.useState({date:V(new Date,"yyyy-MM-dd"),montant:"",poste:"",libelle:"",description:"",payee:"",mode_paiement:""}),{data:i,isLoading:P,error:Z}=R({queryKey:["lots-operationnels",r],queryFn:async()=>p.getById(r),enabled:Number.isFinite(r)&&r>0}),{data:Q,isLoading:D}=R({queryKey:["lots-operationnels",r,"hebergement-summary"],queryFn:async()=>p.getHebergementSummary(r),enabled:Number.isFinite(r)&&r>0}),ue=b.useMemo(()=>{const t=new Map;for(const s of Q?.sejours??[])t.set(s.id,s.nom);return t},[Q?.sejours]),{data:xe,isLoading:pe}=R({queryKey:["lots-operationnels",r,"finances","depenses"],queryFn:async()=>p.listFinancesDepenses(r,{limit:100}),enabled:Number.isFinite(r)&&r>0}),{data:ae,isLoading:ge}=R({queryKey:["lots-operationnels",r,"finances","summary"],queryFn:async()=>p.getFinancesSummary(r),enabled:Number.isFinite(r)&&r>0&&d}),{data:re,isLoading:be}=R({queryKey:["lots-operationnels",r,"finances","budget"],queryFn:async()=>p.getFinancesBudget(r),enabled:Number.isFinite(r)&&r>0&&d}),J=()=>{a({date:V(new Date,"yyyy-MM-dd"),montant:"",poste:"",libelle:"",description:"",payee:"",mode_paiement:""}),K(null),T(!1)},ne=N({mutationFn:async()=>{const t=parseFloat(c.montant.replace(",","."));if(!Number.isFinite(t)||t<=0)throw new Error("Montant invalide");return p.createFinancesDepense(r,{date:c.date,montant:t,libelle:c.libelle.trim(),...c.poste?{poste:c.poste}:{},description:c.description.trim()||null,payee:c.payee.trim()||null,...c.mode_paiement?{mode_paiement:c.mode_paiement}:{}})},onSuccess:()=>
1{u.invalidateQueries({queryKey:["lots-operationnels",r,"finances"]}),J(),o.success("Dépense enregistrée")},onError:t=>o.error(t.message||"Échec de la création")}),ie=N({mutationFn:async()=>{if(!w)throw new Error("Aucune dépense à modifier");const t=parseFloat(c.montant.replace(",","."));if(!Number.isFinite(t)||t<=0)throw new Error("Montant invalide");return p.updateFinancesDepense(r,w.id,{date:c.date,montant:t,libelle:c.libelle.trim(),...c.poste?{poste:c.poste}:{},description:c.description.trim()||null,payee:c.payee.trim()||null,...c.mode_paiement?{mode_paiement:c.mode_paiement}:{}})},onSuccess:()=>{u.invalidateQueries({queryKey:["lots-operationnels",r,"finances"]}),J(),o.success("Dépense mise à jour")},onError:t=>o.error(t.message||"Échec de la mise à jour")}),he=N({mutationFn:async t=>p.deleteFinancesDepense(r,t),onSuccess:()=>{u.invalidateQueries({queryKey:["lots-operationnels",r,"finances"]}),o.success("Dépense supprimée")},onError:()=>o.error("Suppression impossible")}),le=N({mutationFn:async()=>{const t=parseFloat(M.montant_total_previsionnel.replace(",","."));if(!Number.isFinite(t)||t<0)throw new Error("Montant prévisionnel invalide");const s=M.postes.filter(l=>l.poste&&l.montant_previsionnel.trim()!=="").map(l=>{const y=parseFloat(l.montant_previsionnel.replace(",","."));if(!Number.isFinite(y)||y<0)throw new Error("Montant poste invalide");return{poste:l.poste,montant_previsionnel:y,commentaire:l.commentaire.trim()||null}});return p.putFinancesBudget(r,{montant_total_previsionnel:t,commentaire:M.commentaire.trim()||null,postes:s})},onSuccess:()=>{u.invalidateQueries({queryKey:["lots-operationnels",r,"finances"]}),O(!1),o.success("Budget lot enregistré")},onError:t=>o.error(t.message||"Échec enregistrement budget")}),ye=()=>{const t=re?.budget;f(t?{montant_total_previsionnel:String(t.montant_total_previsionnel),commentaire:t.commentaire??"",postes:t.postes?.map(s=>({poste:s.poste,montant_previsionnel:String(s.montant_previsionnel),commentaire:s.commentaire??""}))??[]}:{montant_total_previsionnel:"",commentaire:"",postes:[]}),O(!0)};b.useEffect(()=>{i&&(q(i.nom),$(i.description??""))},[i]);const X=N({mutationFn:async()=>p.update(r,{nom:h.trim(),description:A.trim()?A.trim():null}),onSuccess:()=>{u.invalidateQueries({queryKey:["lots-operationnels"]}),o.success("Lot mis à jour")},onError:()=>o.error("Échec de la mise à jour")}),oe=N({mutationFn:async t=>Re.updateSejour(t,{lot_operationnel_id:null}),onSuccess:()=>{u.invalidateQueries({queryKey:["lots-operationnels",r]}
1),u.invalidateQueries({queryKey:["lots-operationnels"]}),u.invalidateQueries({queryKey:["sejours"]}),o.success("Séjour retiré du lot")},onError:()=>o.error("Impossible de retirer ce séjour du lot")}),de=N({mutationFn:async()=>p.delete(r),onSuccess:()=>{u.invalidateQueries({queryKey:["lots-operationnels"]}),u.invalidateQueries({queryKey:["sejours"]}),o.success("Lot supprimé"),v("/lots-operationnels")},onError:t=>{const s=t?.response?.data;s?.message?o.error(s.message):o.error("Suppression impossible (des séjours sont peut-être encore rattachés)")}});if(!Number.isFinite(r)||r<=0)return e.jsxs("div",{className:"p-8 max-w-3xl mx-auto",children:[e.jsx(z,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-slate-300",children:"Identifiant invalide."})]});if(P)return e.jsxs("div",{className:"p-8 max-w-3xl mx-auto",children:[e.jsx(z,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-slate-300",children:"Chargement…"})]});if(Z||!i)return e.jsxs("div",{className:"p-8 max-w-3xl mx-auto",children:[e.jsx(z,{className:"mb-4"}),e.jsx("p",{className:"text-red-600",children:"Lot introuvable."}),e.jsx(S,{to:"/lots-operationnels",className:"text-indigo-600 text-sm mt-2 inline-block",children:"Retour à la liste des lots"})]});const G=i.sejours_archives??[],Y=(i.sejours_rattaches_count??i.sejours.length+G.length)===0,je=t=>{window.confirm(`Retirer « ${t.nom} » du lot « ${i.nom} » ? Le séjour restera accessible depuis la liste des séjours.`)&&oe.mutate(t.id)},ce=(t,s)=>e.jsxs("li",{className:"flex items-stretch gap-2",children:[e.jsx(S,{to:`/sejours/${t.id}`,className:"flex-1 min-w-0 p-4 hover:bg-gray-50 dark:hover:bg-slate-800/50 block",children:e.jsxs("div",{className:"flex justify-between gap-4 items-start",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-slate-100 block truncate",children:t.nom}),s?.archived?e.jsxs("span",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5 inline-block",children:["Archivé · ",me(t.statut)]}):e.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400 mt-0.5 inline-block",children:me(t.statut)})]}),e.jsxs("span",{className:"text-xs text-gray-500 dark:text-slate-400 shrink-0 text-right",children:[I(t.date_debut),e.jsx("br",{}),"→ ",I(t.date_fin)]})]})}),x&&e.jsxs("button",{type:"button",onClick:()=>je(t),disabled:oe.isPending,title:"Retirer du lot",className:"shrink-0 px-3 my-2 mr-2 inline-flex items-center gap-1.5 text-xs font-medium text-gray-600 dark:text-slate-300 border border-gray-200 dark:border-slate-700 rounded-md hover:bg-gray-50 dark:hover:bg-slate-800/50 hover:text-indigo-700 disabled:opacity-50",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Retirer"})]})]},t.id);return e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-8",children:[e.jsx(z,{className:"mb-4"}),e.jsxs(S,{to:"/lots-operationnels",className:"inline-flex items-center gap-2 text-sm text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:text-indigo-200 dark:hover:text-indigo-300 mb-6",children:[e.jsx(Se,{className:"h-4 w-4"}),"Tous les lots"]}),e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-8 w-8 text-indigo-600 shrink-0"}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-slate-100",children:"Lot opérationnel"})]}),e.jsx(S,{to:`/sejours?lot_operationnel_id=${r}`,className:"text-sm text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:text-indigo-200 dark:hover:text-indigo-300 whitespace-nowrap",children:"Voir les séjours filtrés"})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-slate-700 rounded-lg p-6 shadow-sm space-y-4 mb-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"edit-lot-nom",className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-1",children:"Nom"}),e.jsx("input",{id:"edit-lot-nom",value:h,onChange:t=>q(t.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-md bg-white dark:bg-slate-800 dark:text-slate-100"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"edit-lot-desc",className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-1",children:"Description"}),e.jsx("textarea",{id:"edit-lot-desc",value:A,onChange:t=>$(t.target.value),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-md bg-white dark:bg-slate-800 dark:text-slate-100"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsx("button",{type:"button",onClick:()=>X.mutate(),disabled:X.isPending||!h.trim(),className:"px-4 py-2 bg-indigo-600 text-white rounded-md text-sm font-medium hover:bg-indigo-700 disabled:opacity-50",children:X.isPending?"Enregistrement…":"Enregistrer"}),e.jsxs("button",{type:"button",onClick:()=>{Y&&window.confirm("Supprimer définitivement ce lot ?")&&de.mutate()},disabled:!Y||de.isPending,title:Y?"Supprimer le lot":"Retirez d’abord tous les séjours de ce lot",className:"inline-flex items-center gap-2 px-4 py-2 border border-red-200 dark:border-red-800/50 text-red-700 dark:text-red-300 rounded-md text-sm hover:bg-red-50 dark:hover:bg-red-950/30 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(ee,{className:"h-4 w-4"}),"Supprimer"]})]})]}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-slate-100 mb-3",children:"Séjours rattachés"}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-slate-300 mb-3",children:["Retirez un séjour du lot sans le supprimer, ou rattachez-en depuis la fiche séjour /"," ",e.jsx(S,{to:"/sejours/new",className:"text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:text-indigo-200 dark:hover:text-indigo-300",children:"Nouveau séjour"}),"."]}),i.sejours.length===0&&G.length===0?e.jsx("p",{className:"text-gray-600 dark:text-slate-300 text-sm",children:"Aucun séjour rattaché pour l’instant."}):e.jsxs(e.Fragment,{children:[i.sejours.length>0&&e.jsx("ul",{className:"border border-gray-200 dark:border-slate-700 rounded-lg divide-y divide-gray-100 dark:divide-slate-800 bg-white dark:bg-slate-900 mb-4",children:i.sejours.map(t=>ce(t))}),G.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-900 dark:text-amber-100",children:"Séjours archivés encore liés au lot"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Ces séjours n’apparaissent plus dans les listes actives. Retirez-les du lot pour les détacher définitivement."}),e.jsx("ul",{className:"border border-amber-200 dark:border-amber-800/50 rounded-lg divide-y divide-amber-100 dar
1k:divide-amber-900/40 bg-amber-50 dark:bg-amber-950/35/40",children:G.map(t=>ce(t,{archived:!0}))})]})]}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-slate-100 mt-10 mb-3 flex items-center gap-2",children:[e.jsx(Fe,{className:"h-5 w-5 text-slate-600"}),"Synthèse financière (vue lot)"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mb-3",children:ae?.note_agregee}),H(ge,ae,e.jsx("p",{className:"text-gray-500 dark:text-slate-400 text-sm",children:"Chargement de la synthèse…"}),t=>e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 mb-2",children:[e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-4",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Dépenses réalisées (lot)"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-slate-100",children:t.depenses.total_lot.toLocaleString("fr-FR",{style:"currency",currency:"EUR"})})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-4",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Dépenses séjours du lot"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-slate-100",children:t.depenses.total_sejours_du_lot.toLocaleString("fr-FR",{style:"currency",currency:"EUR"})})]}),e.jsxs("div",{className:"rounded-lg border border-emerald-100 dark:border-emerald-800/50 bg-emerald-50 dark:bg-emerald-950/35/80 p-4 sm:col-span-2 lg:col-span-1",children:[e.jsx("p",{className:"text-xs text-emerald-800 dark:text-emerald-200",children:"Total réalisé consolidé"}),e.jsx("p",{className:"text-lg font-semibold text-emerald-900 dark:text-emerald-100",children:t.depenses.total_realise_consolide.toLocaleString("fr-FR",{style:"currency",currency:"EUR"})})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-4",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Somme budgets séjours"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-slate-100",children:t.budgets_previsionnels.somme_totaux_budgets_sejours.toLocaleString("fr-FR",{style:"currency",currency:"EUR"})})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-4",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Budget prévisionnel (lot)"}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-slate-100",children:(t.budgets_previsionnels.lot?.montant_total_previsionnel??0).toLocaleString("fr-FR",{style:"currency",currency:"EUR"})})]}),e.jsxs("div",{className:"rounded-lg border border-indigo-100 dark:border-indigo-800/50 bg-indigo-50 dark:bg-indigo-950/35/80 p-4",children:[e.jsx("p",{className:"text-xs text-indigo-800 dark:text-indigo-200",children:"Enveloppe affichée (lot + séjours)"}),e.jsx("p",{className:"text-lg font-semibold text-indigo-900 dark:text-indigo-100",children:t.budgets_previsionnels.somme_affichee_budgets_lot_et_sejours.toLocaleString("fr-FR",{style:"currency",currency:"EUR"})})]})]})),e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-slate-100 mt-10 mb-3 flex items-center gap-2",children:[e.jsx(Ee,{className:"h-5 w-5 text-amber-600"}),"Budget prévisionnel (lot)"]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-300 mb-3",children:"Enveloppe prévisionnelle commune au lot (distincte des budgets de chaque séjour). Les postes sont optionnels."}),H(be,re,e.jsx("p",{className:"text-gray-500 dark:text-slate-400 text-sm",children:"Chargement du budget…"}),t=>e.jsx("div",{className:"space-y-3",children:B?e.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-slate-700 rounded-lg p-4 space-y-3",children:[e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 block",children:["Montant total prévisionnel (€)",e.jsx("input",{type:"text",inputMode:"decimal",value:M.montant_total_previsionnel,onChange:s=>
1f(l=>({...l,montant_total_previsionnel:s.target.value})),className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100"})]}),e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 block",children:["Commentaire",e.jsx("textarea",{value:M.commentaire,onChange:s=>f(l=>({...l,commentaire:s.target.value})),rows:2,className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-slate-300",children:"Ventilation par poste"}),e.jsx("button",{type:"button",onClick:()=>f(s=>({...s,postes:[...s.postes,{poste:"",montant_previsionnel:"",commentaire:""}]})),className:"text-xs text-amber-700 dark:text-amber-300 hover:underline",children:"+ Ligne poste"})]}),M.postes.map((s,l)=>e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-12 gap-2 items-end border-t border-gray-100 dark:border-slate-800 pt-2",children:[e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 sm:col-span-4 block",children:["Poste",e.jsxs("select",{value:s.poste,onChange:y=>{const U=y.target.value;f(L=>{const _=[...L.postes];return _[l]={..._[l],poste:U},{...L,postes:_}})},className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100",children:[e.jsx("option",{value:"",children:"—"}),g.filter(y=>y.value).map(y=>e.jsx("option",{value:y.value,children:y.label},y.value))]})]}),e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 sm:col-span-3 block",children:["Montant (€)",e.jsx("input",{type:"text",inputMode:"decimal",value:s.montant_previsionnel,onChange:y=>{const U=y.target.value;f(L=>{const _=[...L.postes];return _[l]={..._[l],montant_previsionnel:U},{...L,postes:_}})},className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100"})]}),e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 sm:col-span-4 block",children:["Note",e.jsx("input",{type:"text",value:s.commentaire,onChange:y=>{const U=y.target.value;f(L=>{const _=[...L.postes];return _[l]={..._[l],commentaire:U},{...L,postes:_}})},className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100"})]}),e.jsx("button",{type:"button",onClick:()=>f(y=>({...y,postes:y.postes.filter((U,L)=>L!==l)})),className:"sm:col-span-1 text-red-600 text-xs py-2","aria-label":"Retirer la ligne",children:"Retirer"})]},`poste-${s.poste||"empty"}-${l}`))]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[e.jsx("button",{type:"button",disabled:le.isPending,onClick:()=>le.mutate(),className:"px-3 py-1.5 text-sm bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50",children:"Enregistrer"}),e.jsx("button",{type:"button",onClick:()=>O(!1),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-slate-600 rounded-md bg-white dark:bg-slate-800 dark:text-slate-100",children:"Annuler"})]})]}):e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-4 flex flex-wrap justify-between gap-3 items-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Montant total prévisionnel"}),e.jsx("p",{className:"text-xl font-semibold text-gray-900 dark:text-slate-100",children:t.budget?t.budget.montant_total_previsionnel.toLocaleString("fr-FR",{style:"currency",currency:"EUR"}):"— Non défini —"}),t.budget?.commentaire?e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-300 mt-1",children:t.budget.commentaire}):null]}),F&&e.jsx("button",{type:"button",onClick:ye,className:"px-3 py-2 text-sm bg-amber-600 text-white rounded-md hover:bg-amber-700",children:t.budget?"Modifier":"Définir le budget"})]})}))]}),e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-slate-100 mt-10 mb-3 flex items-center gap-2",children:[e.jsx(Le,{className:"h-5 w-5 text-emerald-600"}),"Dépenses communes (lot)"]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-300 mb-4",children:"Coûts partagés entre les séjours du lot (bus, cuisine centrale, etc.). Les dépenses par séjour restent sur la fiche finance de chaque séjour."}),H(pe,xe,e.jsx("p",{className:"text-gray-500 dark:text-slate-400 text-sm",children:"Chargement des dépenses…"}),t=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-emerald-50 dark:bg-emerald-950/35 border border-emerald-100 dark:border-emerald-800/50 rounded-lg px-4 py-3 flex flex-wrap justify-between gap-2 items-center",children:[e.jsx("span",{className:"text-sm font-medium text-emerald-900 dark:text-emerald-100",children:"Total dépenses lot"}),e.jsx("span",{className:"text-lg font-semibold text-emerald-800 dark:text-emerald-200",children:t.synthese.total_montant.toLocaleStr
1ing("fr-FR",{style:"currency",currency:"EUR"})})]}),m("depenses.create")&&e.jsxs("div",{children:[!E&&!w&&e.jsxs("button",{type:"button",onClick:()=>{K(null),a({date:V(new Date,"yyyy-MM-dd"),montant:"",poste:"",libelle:"",description:"",payee:"",mode_paiement:""}),T(!0)},className:"inline-flex items-center gap-2 px-3 py-2 text-sm bg-emerald-600 text-white rounded-md hover:bg-emerald-700",children:[e.jsx(te,{className:"h-4 w-4"}),"Nouvelle dépense lot"]}),(E||w)&&e.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-slate-700 rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-gray-800 dark:text-slate-200",children:Qe(!!w)}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 block",children:["Date",e.jsx("input",{type:"date",value:c.date,onChange:s=>a(l=>({...l,date:s.target.value})),className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100"})]}),e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 block",children:["Montant (€)",e.jsx("input",{type:"text",inputMode:"decimal",value:c.montant,onChange:s=>a(l=>({...l,montant:s.target.value})),className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100",placeholder:"0,00"})]}),e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 block",children:["Poste",e.jsx("select",{value:c.poste,onChange:s=>a(l=>({...l,poste:s.target.value})),className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100",children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value||"empty"))})]}),e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 block",children:["Libellé",e.jsx("input",{value:c.libelle,onChange:s=>a(l=>({...l,libelle:s.target.value})),className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100"})]}),e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 block sm:col-span-2",children:["Fournisseur / bénéficiaire",e.jsx("input",{value:c.payee,onChange:s=>a(l=>({...l,payee:s.target.value})),className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100"})]}),e.jsxs("label",{className:"text-xs text-gray-600 dark:text-slate-300 block sm:col-span-2",children:["Description",e.jsx("textarea",{value:c.description,onChange:s=>a(l=>({...l,description:s.target.value})),rows:2,className:"mt-1 w-full px-2 py-1.5 border border-gray-300 dark:border-slate-600 rounded text-sm bg-white dark:bg-slate-800 dark:text-slate-100"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",disabled:ne.isPending||ie.isPending||!c.libelle.trim(),onClick:()=>w?ie.mutate():ne.mutate(),className:"px-3 py-1.5 text-sm bg-emerald-600 text-white rounded-md hover:bg-emerald-700 disabled:opacity-50",children:w?"Enregistrer":"Créer"}),e.jsx("button",{type:"button",onClick:J,className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-slate-600 rounded-md bg-white dark:bg-slate-800 dark:text-slate-100",children:"Annuler"})]})]})]}),t.depenses.length===0?e.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Aucune dépense au niveau lot pour l’instant."}):e.jsx("ul",{className:"border border-gray-200 dark:border-slate-700 rounded-lg divide-y divide-gray-100 dark:divide-slate-800 bg-white dark:bg-slate-900 text-sm",children:t.depenses.map(s=>e.jsxs("li",{className:"p-4 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-slate-100",children:s.libelle??"Sans libellé"}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-slate-400 mt-0.5",children:[I(s.date)," · ",C(s.poste),s.payee?` · ${s.payee}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("span",{className:"font-semibold text-gray-900 dark:text-slate-100",children:s.montant.toLocaleStr
1ing("fr-FR",{style:"currency",currency:"EUR"})}),m("depenses.create")&&e.jsx("button",{type:"button","aria-label":"Modifier",onClick:()=>{K(s),T(!1),a({date:s.date.slice(0,10),montant:String(s.montant),poste:s.poste??"",libelle:s.libelle??"",description:s.description??"",payee:s.payee??"",mode_paiement:s.mode_paiement??""})},className:"p-1.5 text-gray-600 dark:text-slate-300 hover:text-indigo-600 dark:hover:text-indigo-400",children:e.jsx(Me,{className:"h-4 w-4"})}),m("depenses.delete")&&e.jsx("button",{type:"button","aria-label":"Supprimer",onClick:()=>{window.confirm("Supprimer cette dépense ?")&&he.mutate(s.id)},className:"p-1.5 text-red-600 hover:text-red-800",children:e.jsx(ee,{className:"h-4 w-4"})})]})]},s.id))})]})),e.jsxs("div",{className:"mt-10 p-4 bg-amber-50 dark:bg-amber-950/35/80 border border-amber-200 dark:border-amber-800/50 rounded-lg",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-slate-100 mb-2",children:"Hébergements (vue lot)"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-300 mb-3",children:"Lecture seule : chaque lieu physique n’est compté qu’une fois dans le total (capacité unitaire par lieu distinct), même s’il est lié à plusieurs séjours du lot. Les affectations de chambres se font séjour par séjour, après attribution explicite au niveau du lot (voir ci-dessous)."}),H(D,Q,e.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Chargement…"}),t=>e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-amber-900 dark:text-amber-100",children:"Capacité totale (lieux distincts)"})," :"," ",t.capacite_totale_estimee]}),t.par_lieu.length>0&&e.jsx("ul",{className:"list-disc list-inside text-gray-700 dark:text-slate-300 space-y-3",children:t.par_lieu.map(s=>e.jsxs("li",{className:"space-y-1",children:[e.jsxs("div",{children:[s.nom," — ",s.capacite_unitaire," pl. / lieu · ",s.nb_liaisons," liaison(s) · séjours"," ",s.sejour_ids.join(", ")]}),e.jsx("ul",{className:"list-none pl-0 space-y-0.5 text-amber-800 dark:text-amber-200",children:s.sejour_ids.map(l=>e.jsx("li",{children:e.jsxs(S,{to:`/sejours/${l}/hebergement`,className:"text-sm font-medium hover:text-amber-950 dark:hover:text-amber-100 underline underline-offset-2",children:["Affectations chambres — ",ue.get(l)??`Séjour ${l}`]})},`${s.hebergement_id}-${l}`))})]},s.hebergement_id))}),t.liaisons.length===0&&e.jsx("p",{className:"text-gray-500 dark:text-slate-400",children:"Aucun lieu d’hébergement lié aux séjours de ce lot."})]}))]}),e.jsxs("div",{className:"mt-6 p-4 bg-amber-50 dark:bg-amber-950/35/90 border border-amber-200 dark:border-amber-800/50 rounded-lg",children:[e.jsx(Oe,{}),e.jsx(Ue,{lotId:r})]}),e.jsxs("div",{className:"mt-10 p-4 bg-emerald-50 dark:bg-emerald-950/35/80 border border-emerald-200 dark:border-emerald-800/50 rounded-lg",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-slate-100 mb-2",children:"Activités taguées (lot)"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-300 mb-3",children:"Les activités restent sur un séjour ; le tag lot permet de les lister ensemble pour la vision consolidée."}),e.jsx(S,{to:`/activites?lot_operationnel_id=${r}`,className:"text-sm text-emerald-700 dark:text-emerald-300 hover:text-emerald-900 dark:hover:text-emerald-200 dark:text-emerald-100 font-medium block mb-2",children:"Ouvrir les activités filtrées par ce lot →"}),i?.sejours&&i.sejours.length>0&&e.jsxs("div",{className:"text-sm text-gray-700 dark:text-slate-300",children:[e.jsx("p",{className:"font-medium text-gray-800 dark:text-slate-200 mb-1",children:"Par séjour"}),e.jsx("ul",{className:"space-y-0.5",children:i.sejours.map(t=>e.jsx("li",{children:e.jsxs(S,{to:`/sejours/${t.id}/activites`,className:"text-emerald-700 dark:text-emerald-300 hover:text-emerald-900 dark:hover:text-emerald-200 dark:text-emerald-100 underline underline-offset-2",children:["Activités — ",t.nom]})},t.id))})]})]}),e.jsxs("div",{className:"mt-10 p-4 bg-orange-50 dark:bg-orange-950/35/80 border border-orange-200 dark:border-orange-800/50 rounded-lg",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-slate-100 mb-2",children:"Menus du lot (restauration)"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-300 mb-3",children:"Menus partagés au niveau lot (un repas par date et type sur le lot). Édition depuis la page Restauration."}),e.jsx(S,{to:`/restauration?lot_operationnel_id=${r}`,className:"text-sm text-orange-700 dark:text-orange-300 hover:text-orange-900 dark:hover:text-orange-200 font-medium",children:"Ouvrir la restauration pour ce lot →"})]}),e.jsx(Pe,{lotId:r}),e.jsxs("div",{className:"mt-10 p-4 bg-slate-50 dark:bg-slate-900/60 border border-slate-200 dark:border-slate-700 rounded-lg",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-slate-100 mb-2",children:"Transports tagués (lot)"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-300 mb-3",children:"Les trajets restent rattachés à un séjour ; le tag lot permet de les filtrer ensemble (bus partagé, etc.)."}),e.jsx(S,{to:`/transports?lot_operationnel_id=${r}`,className:"text-sm text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:text-indigo-200 dark:hover:text-indigo-300 font-medium block mb-2",children:"Ouvrir la liste des transports pour ce lot →"}),i?.sejours&&i.sejours.length>0&&e.jsxs("div",{className:"text-sm text-gray-700 dark:text-slate-300",children:[e.jsx("p",{className:"font-medium text-gray-800 dark:text-slate-200 mb-1",children:"Par séjour"}),e.jsx("ul",{className:"space-y-0.5",children:i.sejours.map(t=>e.jsx("li",{children:e.jsxs(S,{to:`/sejours/${t.id}/transports`,className:"text-indigo-600 hover:text-indigo-900 dark:text-indigo-100 dark:hover:text-indigo-300 underline underline-offset-2",children:["Transports — ",t.nom]})},t.id))})]})]}),e.jsx(Ke,{lotId:r})]})}
1export{Je 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.