{"version":3,"file":"CreateSeance.tGt5aDOe.mjs","names":["state","useState","collection","addDoc","doc","setDoc","getDocs","query","where","orderBy","limit","writeBatch","updateDoc","getDoc","deleteDoc","onSnapshot","getFirestore","sessionStore","electionDefault","electionStore","resolutionDefault","resolutionStore","participantsStore","proxyStore","sessionStore","electionDefault","electionStore","resolutionDefault","resolutionStore","participantsStore","proxyStore","sessionStore","electionDefault","electionStore","resolutionDefault","resolutionStore","participantsStore","PARTICIPANTS_STORE_ID","proxyStore","sessionStore","electionDefault","electionStore","resolutionDefault","resolutionStore","participantsStore","PARTICIPANTS_STORE_ID","proxyStore","sessionStore","electionDefault","electionStore","resolutionDefault","resolutionStore","participantsStore","PARTICIPANTS_STORE_ID","proxyStore","sessionStore","electionDefault","electionStore","resolutionDefault","resolutionStore","useState","p"],"sources":["https:/framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js","https:/framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js","https:/framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js","https:/framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/R4s8N5FHglD5oU98v8Il/CreateSeance.js","https:/framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/LBHLgsg8D7krWL1uiHLr/ParticipantSeance.js","https:/framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/jt70H8T03vxbf6Z9xejQ/CreateSeance.js","https:/framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/Jzb8T924Cfz7iw8UCfCe/ParticipantSeance.js","https:/framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/gE5Hgh8tdRIGMPiuVcm8/CreateSeance.js","https:/framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/eUVraZycpfEYGFXK6Q4T/ParticipantSeance.js","https:/framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/35YaN4IIcGHsodnEwLpn/CreateSeance.js","https:/framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/q8Wm02tTr4j0xzkjGsvg/ParticipantSeance.js","https:/framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/be381nkNUE4HePOwNcPO/CreateSeance.js","https:/framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/11ChxFnuPG9eoCvnRowH/ParticipantSeance.js","https:/framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/V8mfhTKZHQIcl6T9FFl4/CreateSeance.js","https:/framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/HdbdkjjAQBekRtZImCHb/ParticipantSeance.js","https:/framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/vJlsm97W7BpTvjRGiB8z/CreateSeance.js"],"sourcesContent":["import create from\"zustand\";import{combine,persist}from\"zustand/middleware\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";export const userDefault={id:\"\",name:\"\",firstName:\"\",code:\"\",sessionId:\"\",docId:\"\",proxyFrom:{},proxyTo:{},isLogged:false,admin:false};export const globalStore=create(persist(combine({allUsersList:{},variant:\"\",url:\"\",//  isLogged: false,\nuser:{...userDefault},session:{},edit:{},docIdVoteSelf:\"\",docIdVoteProxy:\"\"},set=>({setUrl:url=>set({url:url}),setUser:value=>set(state=>({user:value})),setUserSessionId:value=>set(state=>{state.user.sessionId=value;return state;}),setUserProxy:value=>set(state=>{state.user.proxyFrom=value.proxyFrom;state.user.proxyTo=value.proxyTo;return state;}),setLoggedIn:()=>set(state=>({isLogged:true})),setLoggedOut:()=>set(state=>({isLogged:false})),resetUser:()=>set(state=>({user:{...userDefault,admin:state.user.admin}})),setSession:value=>set(state=>({session:value})),setAllUsersList:value=>set(state=>({allUsersList:value})),setVariant:value=>set(state=>({variant:value})),setEdit:value=>set(state=>({edit:value})),setDocIdVoteSelf:value=>set(state=>({docIdVoteSelf:value})),setDocIdVoteProxy:value=>set(state=>({docIdVoteProxy:value}))})),{name:\"storage\",getStorage:()=>sessionStorage,onRehydrateStorage:state=>{console.log(\"hydration starts\");// optional\nreturn(state,error)=>{if(error){console.log(\"an error happened during hydration\",error);}else{console.log(\"hydration finished \",state);// resets if you want\nstate.session.currentItemId=\"\";// state.setUser({})\n}};}}));export const userStore=createStore({...userDefault});export const sessionsStore=createStore({sessions:[],filter:\"current\"});export const editStore=createStore({onEditSession:false,idSession:null,onEditItem:false,indexItem:null,onEditParticipants:false});export const currentSessionStore=createStore({session:{},indexCurrentItem:null,currentItem:{}});export const errorStore=createStore({error:false,errorMessage:\"\"});\nexport const __FramerMetadata__ = {\"exports\":{\"Session\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"currentSessionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"Participant\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionsStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"userStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"editStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"userDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"errorStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"globalStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Globals.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{globalStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{useState,useEffect}from\"react\";// Learn more: https://www.framer.com/docs/guides/overrides/\nexport function sleep(ms){return new Promise(resolve=>setTimeout(resolve,ms));}export function capitalizeFirstLetter(string){return string.charAt(0).toUpperCase()+string.slice(1);}export function textUsername(Component){return props=>{const userName=globalStore(state=>state.user.name);const userFirstName=globalStore(state=>state.user.firstName);const[fullName,setFullName]=useState(\"\");useEffect(()=>{setFullName(`${userFirstName} ${userName}`);},[userName,userFirstName]);return /*#__PURE__*/_jsx(Component,{...props,text:fullName});};}export function generateUniqueId(){return`id_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;}// Fonction de comparaison pour trier par nom\nexport function compareNames(a,b){const nomA=a.name.toUpperCase()// Ignorer la casse\n;const nomB=b.name.toUpperCase()// Ignorer la casse\n;if(nomA<nomB){return-1;}if(nomA>nomB){return 1;}return 0// Les noms sont égaux\n;}\nexport const __FramerMetadata__ = {\"exports\":{\"compareNames\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"generateUniqueId\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sleep\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"textUsername\":{\"type\":\"reactHoc\",\"name\":\"textUsername\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"capitalizeFirstLetter\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Miscellaneous.map","import{initializeApp}from\"firebase/app\";import{getFirestore,doc,setDoc,collection,addDoc,updateDoc,query,where,getDocs,getDoc,orderBy,limit,deleteDoc,writeBatch,onSnapshot}from\"firebase/firestore\";const firebaseConfig={apiKey:\"AIzaSyCjjf0ZsoSOVoEaWovB4RNXG_pRhvnsv1E\",authDomain:\"voting-system-d96da.firebaseapp.com\",projectId:\"voting-system-d96da\",storageBucket:\"voting-system-d96da.appspot.com\",messagingSenderId:\"870034363718\",appId:\"1:870034363718:web:d107a6afba1cdbdc548147\"};// Initialize Firebase\nconst app=initializeApp(firebaseConfig);// Initialize Cloud Firestore and get a reference to the service\nconst db=getFirestore(app);/*exemple d'envoie = \nconst chemin = [\"session\", \"votre_document_session\", \"items\", \"votre_document_item1\", \"subCollection\", \"votre_document_subItem1\"];\n\nlet tab = { Time: false, CurrentQuestion: \"\" };\n\nconst response = await setFirestore(chemin, tab);\nif (response.success) {\n    console.log(response.message);\n} else {\n    console.error(\"Erreur lors de la mise à jour :\", response.error);\n}\n*/export async function createDocument(nameCollection,data,nameDocument=\"\"){try{const collectionRef=collection(db,nameCollection);let newDocRef;if(nameDocument===\"\"){newDocRef=await addDoc(collectionRef,data);}else{newDocRef=doc(collectionRef,nameDocument);await setDoc(newDocRef,data);}return{id:newDocRef.id,success:true,message:\"Document cr\\xe9\\xe9 avec succ\\xe8s.\"};}catch(error){console.error(\"Erreur lors de la cr\\xe9ation du document :\",error);return{success:false,error};}}export async function valueOfChampInCollection(collectionName,code){const collectionRef=collection(db,collectionName);const queryRef=query(collectionRef,where(\"code\",\"==\",code));const querySnapshot=await getDocs(queryRef);return querySnapshot.empty// Retourne true si aucun document n'a ce code\n;}export async function setSeveralDocumentsWithChamps(nameCollection,csvData){try{// const rows = csvData.split(\"\\r\\n\").slice(1) // Supposer que la première ligne est l'en-tête\nconst rows=csvData.split(/\\r?\\n/).filter(line=>line.trim()!==\"\").slice(1);const collectionRef=collection(db,nameCollection);const lastDocQuery=query(collectionRef,orderBy(\"id\",\"desc\"),limit(1));const lastDocSnapshot=await getDocs(lastDocQuery);let lastId=lastDocSnapshot.empty?1:Number(lastDocSnapshot.docs[0].data().id);const batch=writeBatch(db);rows.forEach(row=>{const[firstName,name,code,firstNameSubstitute,nameSubstitute,codeSubstitute,lists]=row.split(\";\").map(value=>value.replace(/^\"|\"$/g,\"\").trim());const listsArray=lists?lists.split(\",\").map(item=>item.trim()):[];// Vérifier si les informations du suppléant sont présentes\nif(firstNameSubstitute&&nameSubstitute&&codeSubstitute){// Créer le suppléant\nlastId++;const substituteDocRef=doc(collectionRef,lastId.toString());batch.set(substituteDocRef,{firstName:firstNameSubstitute,name:nameSubstitute,code:codeSubstitute,id:lastId,isLogged:false});// Créer le titulaire avec référence au suppléant\nlastId++;const titulaireDocRef=doc(collectionRef,lastId.toString());batch.set(titulaireDocRef,{firstName:firstName,name:name,code:code,id:lastId,isLogged:false,lists:listsArray,substitute:{firstName:firstNameSubstitute,name:nameSubstitute,code:codeSubstitute,id:lastId-1},isSubstituted:false});}else{// Créer le titulaire sans suppléant\nlastId++;const titulaireDocRef=doc(collectionRef,lastId.toString());batch.set(titulaireDocRef,{firstName:firstName,name:name,code:code,id:lastId,isLogged:false,lists:listsArray});}});await batch.commit();return{success:true,message:\"Documents mis \\xe0 jour avec succ\\xe8s.\"};}catch(error){console.error(\"Erreur lors de la mise \\xe0 jour des documents :\",error);return{success:false,error:error.message};}}export async function updateChampInDocument(nameCollection,fields,nameDocument){try{const refCollection=doc(db,nameCollection,nameDocument);await updateDoc(refCollection,fields);return{success:true,message:\"Document mis \\xe0 jour avec succ\\xe8s.\"};}catch(error){console.error(\"Erreur lors de la mise \\xe0 jour du document :\",error);return{success:false,error};}}export async function updateFieldInAllDocuments(collectionName,fieldName,newValue){try{const collectionRef=collection(db,collectionName);const snapshot=await getDocs(collectionRef);const updatePromises=[];snapshot.forEach(documentSnapshot=>{const docRef=doc(db,collectionName,documentSnapshot.id);updatePromises.push(updateDoc(docRef,{[fieldName]:newValue}));});await Promise.all(updatePromises);console.log(`All documents in '${collectionName}' have been updated.`);}catch(error){console.error(\"Error updating documents: \",error);}}export async function getValueFromCollection(valueInFirestore,nameCollection,symbole,valueSend){try{const usersRef=collection(db,nameCollection);const snapshot=query(usersRef,where(valueSend,symbole,valueInFirestore));const querySnapshot=await getDocs(snapshot);if(querySnapshot.empty){console.info(`Pas de r\\xe9sultat avec la requ\\xeate ${valueSend} ${symbole} ${valueInFirestore}`);return null;}let data=null;querySnapshot.forEach(doc=>{data={docId:doc.id,...doc.data()};});return data;}catch(error){console.error(`Erreur lors de la requ\\xeate ${valueSend} ${symbole} ${valueInFirestore}:`,error);throw error;}}export async function getOneDocument(nameCollection,docId){try{const docRef=doc(db,nameCollection,docId);const docSnap=await getDoc(docRef);if(docSnap.exists()){return docSnap.data();}else{console.log(\"Aucun document trouv\\xe9!\");return null;}}catch(error){console.error(\"Erreur lors de la r\\xe9cup\\xe9ration du document:\",error);throw error;}}export async function getAllDocument(nameCollection){const sessionsCollectionRef=collection(db,nameCollection);const querySnapshot=await getDocs(sessionsCollectionRef);return querySnapshot.docs.map(doc=>({docId:doc.id,...doc.data()}));}export async function getLastIdDocument(nameCollection){const collectionRef=collection(db,nameCollection);const querySnapshot=await getDocs(collectionRef);const ids=querySnapshot.docs.map(doc=>doc.id).filter(id=>!isNaN(id))// S'assurer que les IDs sont numériques\n.map(Number)// Convertir les IDs en nombres\n.sort((a,b)=>b-a);// Renvoyer le plus grand ID (le dernier document)\nreturn ids.length>0?ids[0]:null;}export async function getValueInChamp(collection,documentId,expectedSessionId){const docRef=doc(db,collection,documentId);const docSnapshot=await getDoc(docRef);if(docSnapshot.exists()&&docSnapshot.data().idSession===expectedSessionId){return true// Le sessionId correspond\n;}return false// Le document n'existe pas, ou sessionId ne correspond pas\n;}export async function deleteDocument(nameCollection,docId){try{const docRef=doc(db,nameCollection,docId);await deleteDoc(docRef);console.info(`Document with ID ${docId} successfully deleted`);return`Document with ID ${docId} successfully deleted`;}catch(error){console.error(\"Erreur lors de la suppression du document\",error);throw error;}}export async function deleteAllDocuments(collectionName){const collectionRef=collection(db,collectionName);const snapshot=await getDocs(collectionRef);// Vérifiez si la collection est vide\nif(snapshot.empty){console.log(\"Aucun document \\xe0 supprimer dans la collection\",collectionName);return;}const batch=writeBatch(db);snapshot.docs.forEach(doc=>{batch.delete(doc.ref);});await batch.commit();console.log(\"Tous les documents ont \\xe9t\\xe9 supprim\\xe9s de la collection\",collectionName);}export async function deleteAllDocumentsInSubCollection(nameCollection,docId,subcollection){try{//const newDocRef = doc(collection(db, nameCollection), nameDocument)\n//const subCollectionRef = collection(newDocRef, nameSousCollection)\nconst subCollectionRef=collection(db,nameCollection,docId,subcollection);// Récupérer tous les documents de la sous-collection\nconst snapshot=await getDocs(subCollectionRef);// Créer un lot pour la suppression\nconst batch=writeBatch(db);// Ajouter chaque document à supprimer dans le lot\nsnapshot.docs.forEach(doc=>{batch.delete(doc.ref);});// Exécuter le lot pour supprimer tous les documents\nawait batch.commit();console.log(`All documents in subcollection '${subcollection}' successfully deleted`);return`All documents in subcollection '${subcollection}' successfully deleted`;}catch(error){console.error(\"Erreur lors de la suppression des documents de la sous-collection \"+subcollection,error);throw new Error(\"Erreur lors de la suppression des documents de la sous-collection \"+subcollection);}}export async function editSession(nameCollection,docIdSession,data){try{const{participants,items,...dataSession}=data;console.log(\"data dans edit \",data);const batch=writeBatch(db);const sessionDocRef=doc(db,nameCollection,docIdSession);// Mettre à jour la sous-collection \"participants\"\nconst participantsCollectionRef=collection(sessionDocRef,\"participants\");const existingParticipants=await getDocs(participantsCollectionRef);existingParticipants.forEach(existingParticipant=>{const existingParticipantData=existingParticipant.data();const participantId=existingParticipant.id;// Si l'ID du participant existant n'est pas dans la nouvelle liste, le supprimer\nif(!participants.some(participant=>participant.docId===participantId)){const participantDocRef=doc(participantsCollectionRef,participantId);batch.delete(participantDocRef);}});for(const participant of participants){if(participant.docId){// Si l'item a un docId, il existe déjà, on le met à jour\nconst participantDocRef=doc(participantsCollectionRef,participant.docId);batch.update(participantDocRef,participant);}else{// Si l'item n'a pas de docId, il est nouveau, on l'ajoute\nawait addDoc(participantsCollectionRef,participant);}}// Mettre à jour la sous-collection \"items\"\nconst itemsCollectionRef=collection(sessionDocRef,\"items\");const existingItems=await getDocs(itemsCollectionRef);for(const existingItem of existingItems.docs){const existingItemData=existingItem.data();const itemId=existingItem.id;// Si l'ID de l'item existant n'est pas dans la nouvelle liste, le supprimer\nif(!items.some(item=>item.docId===itemId)){const itemDocRef=doc(itemsCollectionRef,itemId);// Gérer la suppression des votes pour les élections\nif(existingItemData.type===\"election\"&&existingItemData.round){for(let i=1;i<=existingItemData.round;i++){await deleteAllDocumentsInSubCollection(`sessions/${docIdSession}/items`,itemId,`votes${i}`);}}else{// Gérer la suppression de la collection standard \"votes\"\nconst voteCollectionRef=collection(itemDocRef,\"votes\");const voteSnapshot=await getDocs(voteCollectionRef);if(!voteSnapshot.empty){voteSnapshot.forEach(docSnapshot=>{const voteDocRef=doc(voteCollectionRef,docSnapshot.id);batch.delete(voteDocRef);});}}// Supprimer l'item lui-même\nbatch.delete(itemDocRef);}}/*for (const existingItem of existingItems.docs) {\n            const existingItemData = existingItem.data()\n            const itemId = existingItem.id\n\n            // Si l'ID de l'item existant n'est pas dans la nouvelle liste, le supprimer\n            if (!items.some((item) => item.docId === itemId)) {\n                const itemDocRef = doc(itemsCollectionRef, itemId)\n\n                const voteCollectionRef = collection(itemDocRef, \"votes\")\n                const voteSnapshot = await getDocs(voteCollectionRef)\n\n                if (!voteSnapshot.empty) {\n                    voteSnapshot.forEach((docSnapshot) => {\n                        const voteDocRef = doc(\n                            voteCollectionRef,\n                            docSnapshot.id\n                        )\n                        batch.delete(voteDocRef)\n                    })\n                }\n\n                batch.delete(itemDocRef)\n            }\n        }*/const orderItemIds=[];for(const item of items){if(item.docId){// Si l'item a un docId, il existe déjà, on le met à jour\nconst itemDocRef=doc(itemsCollectionRef,item.docId);batch.update(itemDocRef,item);orderItemIds.push(item.docId);}else{// Si l'item n'a pas de docId, il est nouveau, on l'ajoute\nconst newItemDocRef=await addDoc(itemsCollectionRef,item);orderItemIds.push(newItemDocRef.id);}}// Mettre à jour le document principal\nconst dataWithOrderedItems={...dataSession,orderItems:orderItemIds};batch.update(sessionDocRef,dataWithOrderedItems);// Exécuter la transaction\nawait batch.commit();// Récupérer les données de la session mise à jour\nconst updatedSessionDoc=await getDoc(sessionDocRef);const updatedSessionData=updatedSessionDoc.data();updatedSessionData.items=await getAllDocument(itemsCollectionRef.path);updatedSessionData.participants=await getAllDocument(participantsCollectionRef.path);return{success:true,message:\"Edition de la session avec succ\\xe8s\",updatedSession:updatedSessionData};}catch(error){console.error(\"Erreur lors de l'\\xe9dition de la session :\",error);return{success:false,error:error};}}export async function deleteSession(nameCollection,docIdSession){try{const subcollections=[\"items\",\"participants\"];for(const subcollection of subcollections){const subCollectionRef=collection(db,nameCollection,docIdSession,subcollection);const subCollectionSnapshot=await getDocs(subCollectionRef);if(!subCollectionSnapshot.empty){await deleteAllDocumentsInSubCollection(nameCollection,docIdSession,subcollection);if(subcollection===\"items\"){for(const itemDoc of subCollectionSnapshot.docs){const voteCollecNames=[\"votes\",\"votes1\",\"votes2\",\"votes3\"];for(const collecName of voteCollecNames){const votesSubCollectionRef=collection(db,nameCollection,docIdSession,`${subcollection}/${itemDoc.id}/${collecName}`);const votesSubCollectionSnapshot=await getDocs(votesSubCollectionRef);if(!votesSubCollectionSnapshot.empty){await deleteAllDocumentsInSubCollection(nameCollection,docIdSession,`${subcollection}/${itemDoc.id}/${collecName}`);}}}}}}await deleteDoc(doc(db,nameCollection,docIdSession));console.log(`Session ${docIdSession} and its subcollections successfully deleted.`);return{success:true,message:`Session with ID ${docIdSession} successfully deleted.`};}catch(error){console.error(\"Erreur lors de la suppression de la session :\",error);return{success:false,error:error};}}/*  const test = await setCollectionAndDocumentToDocument(\n                \"sessions\",\n                \"test0\",\n                \"essaie1\",\n                \"sousdoc1\"\n            )*///   let chemin = [\"session\", \"test0\", \"essaie1\"]\n// const TEST1 = await setChampsToDocument(chemin, fields, \"sousdoc1\")\nexport async function setCollectionAndDocumentToDocument(nameCollection,nameDocument,nameSousCollection,items){try{const newDocRef=doc(collection(db,nameCollection),nameDocument);const subCollectionRef=collection(newDocRef,nameSousCollection);const ids=await Promise.all(items.map(async item=>{const docRef=await addDoc(subCollectionRef,item);return docRef.id;}));return ids;}catch(error){console.error(\"Erreur lors de la mise \\xe0 jour du document :\",error);return{success:false,error};}}export async function getSubCollectionData(parentCollection,parentId,subCollection){try{const parentDocRef=doc(db,parentCollection,parentId);const subCollectionRef=collection(parentDocRef,subCollection);const querySnapshot=await getDocs(subCollectionRef);let documents=[];querySnapshot.forEach(doc=>{// Ajoutez l'id du document uniquement pour la sous-collection \"items\"\n// const documentData =\n//     subCollection === \"items\"\n//         ? { ...doc.data(), id: doc.id }\n//         : { ...doc.data() }\n// documents.push(documentData)\ndocuments.push({...doc.data(),docId:doc.id});});return documents;}catch(error){console.error(\"Erreur lors de l'obtention des documents de la sous-collection :\",error);throw error;}}export async function checkPathAndFindDocument(path,userDocId,type,round){try{const itemDocRef=doc(db,path);const itemDocSnap=await getDoc(itemDocRef);if(itemDocSnap.exists()){// Déterminer la collection en fonction du type\nlet votesCollectionRef;if(type===\"resolution\"){votesCollectionRef=collection(itemDocRef,\"votes\");}else if(type===\"election\"){votesCollectionRef=collection(itemDocRef,`votes${round}`);}else{// Gérer les autres cas ou retourner une erreur\nconsole.log(\"Type non reconnu.\");return null;}const q=query(votesCollectionRef,where(\"participantId\",\"==\",userDocId));const querySnapshot=await getDocs(q);let foundDocId=null;querySnapshot.forEach(doc=>{foundDocId=doc.id;});return foundDocId// Retourne l'ID du document trouvé, ou null si aucun document correspondant n'a été trouvé\n;}else{console.log(\"Le chemin sp\\xe9cifi\\xe9 n'existe pas.\");return null;}}catch(error){console.error(\"Erreur lors de la v\\xe9rification du chemin et de la recherche du document :\",error);throw error;}}export function subscribeToCollection(collectionName,callback){const q=query(collection(db,collectionName));const unsub=onSnapshot(q,querySnapshot=>{const data=[];querySnapshot.forEach(doc=>{data.push({...doc.data(),docId:doc.id});});callback(data);});return unsub;}export function subscribeToDocument(collectionName,docId,callback){return onSnapshot(doc(db,collectionName,docId),doc=>{callback(doc.data());});}export const fetchLoggedUsers=(participantIds,callback)=>{const unsubscribeFunctions=participantIds.map(id=>{return onSnapshot(doc(db,\"users\",id.toString()),docSnapshot=>{if(docSnapshot.exists()){callback(docSnapshot.data())// Appeler le callback à chaque changement de l'état du document\n;}});});// Retourner une fonction pour désinscrire tous les écouteurs à la fois\nreturn()=>{unsubscribeFunctions.forEach(unsubscribe=>unsubscribe());};}/*export async function getAllSubcollections(parentPath) {\n    const documentRef = collection(db, parentPath)\n\n    // Obtenez le document\n    const documentSnapshot = await getCollecion(documentRef)\n\n    if (!documentSnapshot.exists) {\n        throw new Error(\"Le document n'existe pas\")\n    }\n\n    // Obtenez les sous-collections du document\n    const subcollections = await documentSnapshot.ref.listCollections()\n\n    const subcollectionNames = subcollections.map((collection) => collection.id)\n\n    return subcollectionNames\n}*//*export async function getAllSubcollections(nameCollection) {\n    const sessionsCollectionRef = doc(db, nameCollection)\n    const querySnapshot = await getCollections(sessionsCollectionRef)\n\n    return querySnapshot.docs.map((doc) => ({\n        docId: doc.id,\n        ...doc.data(),\n    }))\n}\n*/;\nexport const __FramerMetadata__ = {\"exports\":{\"setSeveralDocumentsWithChamps\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"createDocument\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"subscribeToCollection\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"deleteDocument\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"deleteSession\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"subscribeToDocument\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"deleteAllDocuments\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getSubCollectionData\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"editSession\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updateChampInDocument\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getValueInChamp\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"valueOfChampInCollection\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getOneDocument\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getValueFromCollection\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getAllDocument\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updateFieldInAllDocuments\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getLastIdDocument\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"setCollectionAndDocumentToDocument\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"fetchLoggedUsers\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"checkPathAndFindDocument\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"deleteAllDocumentsInSubCollection\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Firebase.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{generateUniqueId}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{globalStore,editStore,errorStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createDocument,setCollectionAndDocumentToDocument,editSession,getLastIdDocument,updateChampInDocument,getValueInChamp}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{participantsStore}from\"https://framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/LBHLgsg8D7krWL1uiHLr/ParticipantSeance.js\";export const sessionStore=createStore({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,chorum:false,orderItems:[],items:[],selectedList:\"\",participants:[]});export const electionDefault={title:\"\",list:\"\",candidats:[],anonymous:true,round:1};export const electionStore=createStore(electionDefault);export const resolutionDefault={title:\"\",anonymous:false,responses:[],scrutin:\"\",answerTypeResponses:\"\"};export const resolutionStore=createStore(resolutionDefault);export function secretarySeance(Component){return props=>{const[state,setState]=sessionStore();const[participants,setParticipants]=participantsStore();const onChangeInput=value=>{setState(prev=>({...prev,secretary:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.secretary||\"\",onChange:value=>onChangeInput(value)});};}export function titleSeance(Component){return props=>{const[state,setState]=sessionStore();const onChangeInput=value=>{setState(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.title||\"\",onChange:value=>onChangeInput(value)});};}export function sessionDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,sessionDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.sessionDate,onDateChange:handleDateChange,onEditCalendar:state.sessionDate});};}export function convocationDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,convocationDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.convocationDate,onDateChange:handleDateChange,onEditCalendar:state.convocationDate});};}export function validateButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[participantsStoreState,setParticipantsStoreState]=participantsStore()// ✅ Accès direct au store des participants\n;const[messageState,setMessageState]=errorStore();const setSessionGlobal=globalStore(state=>state.setSession);const sessionGlobal=globalStore(state=>state.session);const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);const[isSubmitted,setIsSubmitted]=useState(false);const[edit,setEdit]=editStore();const handleTap=async()=>{// ✅ session contient les bonnes données (vérifié via les logs)\nconsole.log(\"🔎 handleTap - \\xe9tat au clic Valider :\",{\"participantsStore.participants.length\":participantsStoreState.participants.length,\"session.participants.length\":session.participants?.length??0,\"session.selectedList\":session.selectedList});const areRequiredFieldsFilled=session.title&&session.sessionDate&&session.convocationDate;const hasItems=session.items.length>0;const hasParticipants=session.participants.length>0// ✅ session\n;if(!areRequiredFieldsFilled){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Tous les champs obligatoires doivent \\xeatre remplis.\"}));return;}if(!hasItems){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Au moins un item doit \\xeatre ajout\\xe9.\"}));return;}if(!hasParticipants){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Une liste de participants doit \\xeatre s\\xe9lectionn\\xe9e.\"}));return;}const sessionDate=new Date(session.sessionDate);const convocationDate=new Date(session.convocationDate);if(sessionDate<=convocationDate){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"La date de la s\\xe9ance doit \\xeatre post\\xe9rieure \\xe0 la date de convocation.\"}));return;}const{items,participants,...stateWithoutCollections}=session;if(!edit.onEditSession&&!isSubmitted){// ... (tout le code de création inchangé, tel qu'il était à l'origine)\nsetIsSubmitted(true);const id=await getLastIdDocument(\"sessions\");if(id){setSessionGlobal(session);const subCollectionItems=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"items\",session.items);const subCollectionParticipants=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"participants\",session.participants);if(Array.isArray(subCollectionItems)){const orderItems=subCollectionItems;const dataToSend={...stateWithoutCollections,orderItems,chorum:false,docId:(id+1).toString(),id:(id+1).toString()};const response=await createDocument(\"sessions\",dataToSend,(id+1).toString());if(response.success){console.info(response.message);window.location.href=\"/admin/sessions/\";}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",response.error);setIsSubmitted(false);}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\");}}}else{/**\n                 * EDIT EXISTING SESSION\n                 */if(!isSubmitted){setIsSubmitted(true);const{currentItemId,...sessionWithoutCurrentItemId}=session;// ✅ LOG DEBUG - vérification que les pouvoirs sont bien présents\nconsole.log(\"📤 Envoi \\xe0 editSession :\",{idSession:edit.idSession,participantsAvecPouvoirs:sessionWithoutCurrentItemId.participants?.map(p=>({id:p.id,name:p.name,proxyFrom:p.proxyFrom,proxyTo:p.proxyTo}))});const editResponse=await editSession(`sessions`,edit.idSession,sessionWithoutCurrentItemId);setSessionGlobal(editResponse.updatedSession);if(editResponse.success){console.info(editResponse.message);setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(session.startedSession){// ... (reste du code identique à l'original)\nconst newParticipantIds=session.participants.reduce((acc,participant)=>{if(participant.missing===false){if(participant.isSubstituted&&participant.substitute){acc.push(participant.substitute.id);}else if(Object.keys(participant.proxyTo||{}).length===0){acc.push(participant.id);}}return acc;},[]);const participantsWithSubstitute=session.participants.reduce((acc,participant)=>{if(participant.substitute){acc.push(participant.substitute.id);acc.push(participant.id);}else{acc.push(participant.id);}return acc;},[]);const updatedSession={...session,participantIds:newParticipantIds};const deletedParticipantIds=participantsStoreState.deletedParticipants.map(participant=>participant.id);let allParticipantIdsToUpdate=[...participantsWithSubstitute,...deletedParticipantIds];let filteredParticipantIds=[];for(const participantId of allParticipantIdsToUpdate){const matches=await getValueInChamp(\"users\",participantId.toString(),session.docId);if(matches){filteredParticipantIds.push(participantId);}}allParticipantIdsToUpdate=filteredParticipantIds;for(const participantId of allParticipantIdsToUpdate){await updateChampInDocument(\"users\",{idSession:\"\"},participantId.toString());}for(const participantId of newParticipantIds){await updateChampInDocument(\"users\",{idSession:updatedSession.id},participantId.toString());}setSessionGlobal(updatedSession);}if(url==\"/admin/sessions/current/\"){setIsSubmitted(false);window.location.href=\"/admin/sessions/current/\";}else{setIsSubmitted(false);window.location.href=\"/admin/sessions/\";}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",editResponse.error);}}}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);// const tapOrigin = props.tap\nconst handleTap=()=>{setSession(prev=>({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,items:[]}));if(edit.onEditSession){setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(url==\"/admin/sessions/current/\"){//    setUrl(\"\")\nwindow.location.href=\"/admin/sessions/current/\";return;}else{window.location.href=\"/admin/sessions/\";}}window.location.href=\"/admin/sessions/\";// tapOrigin()\n};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------------------ELECTION-------------------------------------------------------\nexport function titleElectionSeance(Component){return props=>{const[election,setElection]=electionStore();const handleTitleChange=value=>{setElection(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:election.title,onChange:value=>handleTitleChange(value)});};}export function listSelectElection(Component){return props=>{const[options,setOptions]=useState([]);const[election,setElection]=electionStore();const[participants,setParticipants]=participantsStore();useEffect(()=>{setOptions(participants.lists);},[participants.lists]);useEffect(()=>{if(!election.list){setElection(state=>({...state,list:participants.selectedList}));}},[participants.selectedList]);const handleOnChange=(index,label)=>{if(index!=0){setElection(state=>({...state,list:label}));}};return /*#__PURE__*/_jsx(Component,{...props,options:options,onChange:(index,label)=>handleOnChange(index,label),value:options.findIndex(option=>option===election.list)+1});};}export function candidatElectionSeance(Component){return props=>{const[election,setElection]=electionStore();const[participants,setParticipant]=participantsStore();const[extractedNames,setExtractedNames]=useState([]);const[filteredElectionCandidates,setFilteredElectionCandidates]=useState([]);const handleInputChangeCallback=newInputs=>{const newCandidats=newInputs.filter(input=>input.trim()!==\"\");setElection(prev=>({...prev,candidats:newCandidats}));};// const extractedNames = participant.participants.map(\n//     (p) => `${p.firstName} ${p.name}`\n// )\nuseEffect(()=>{if(participants.users.length>0&&election.list!==\"\"){setExtractedNames(participants.users.filter(user=>user.lists?.includes(election.list)).map(p=>`${p.firstName} ${p.name}`));}},[election.list]);return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:inputs=>handleInputChangeCallback(inputs),onEditValues:extractedNames,initialSelectedCandidates:election.candidats});};}/*export function scrutintElectionSeance(Component): ComponentType {\n    return (props) => {\n        const [election, setElection] = electionStore()\n\n        useEffect(() => {\n            if (election.scrutin == \"\") {\n                setElection((prev) => ({\n                    ...prev,\n                    scrutin: props.options[0],\n                }))\n            }\n        }, [])\n\n        const handleOnChange = (index, label) => {\n            setElection((prev) => ({\n                ...prev,\n                scrutin: label,\n            }))\n        }\n        console.log(\"props.opt[0]\", props.options[0])\n        const initialValue = props.options.findIndex(\n            (option) => option === election.scrutin\n        )\n        return (\n            <Component\n                {...props}\n                value={initialValue + 1}\n                onChange={(index, label) => handleOnChange(index, label)}\n            />\n        )\n    }\n}*/export function validateButtonElectionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[election,setElection]=electionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=election.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez bien remplir le titre de l'\\xe9lection\"}));}else if(election.list===\"\"){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez choisir une liste\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newElectionItem={type:\"election\",id:uniqueId,...election};setSession(prev=>({...prev,items:[...prev.items,newElectionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"election\",...election};return state;});}setElection(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonElectionSeance(Component){return props=>{const[electionState,setElectionState]=electionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setElectionState(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------RESOLUTION----------------------------------------\nexport function titleResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleTitleChange=value=>{setResolution(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:resolution.title,onChange:value=>handleTitleChange(value)});};}export function responsesResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleInputChangeCallback=(newInputs,answerTypeCallback)=>{const newResponses=newInputs;setResolution(prev=>({...prev,responses:newResponses,answerTypeResponses:answerTypeCallback}));};return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:(inputs,answerTypeCallback)=>handleInputChangeCallback(inputs,answerTypeCallback),answerResponses:resolution.answerTypeResponses,onEditValues:resolution.responses});};}export function scrutintResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();useEffect(()=>{if(resolution.scrutin==\"\"){setResolution(prev=>({...prev,scrutin:props.options[0]}));}},[]);const handleOnChange=(index,label)=>{setResolution(prev=>({...prev,scrutin:label}));};const initialValue=props.options.findIndex(option=>option===resolution.scrutin);return /*#__PURE__*/_jsx(Component,{...props,value:initialValue+1,onChange:(index,label)=>handleOnChange(index,label)});};}export function anonymousResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleToggle=()=>{setResolution(prev=>({...prev,anonymous:!prev.anonymous}));};const checkboxProps={isChecked:resolution.anonymous,onToggle:()=>{handleToggle();}};return /*#__PURE__*/_jsx(Component,{...props,...checkboxProps});};}export function validateButtonResolutionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[resolution,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=resolution.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez remplir le titre!\"}));}else if(resolution.responses.length===1&&resolution.responses[0]===\"\"||resolution.responses.length===0){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez ajouter une r\\xe9ponse valide!\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newResolutionItem={type:\"resolution\",id:uniqueId,...resolution};setSession(prev=>({...prev,items:[...prev.items,newResolutionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"resolution\",...resolution};return state;});}setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonResotutioSeance(Component){return props=>{const[resolutionState,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-------------------------------------------UTILS-----------------\nexport function snakbarre(Component){return props=>{const[state,setState]=errorStore();if(state.error){setTimeout(()=>{setState(prevState=>({...prevState,error:false}));},3e3);return /*#__PURE__*/_jsx(Component,{...props,message:state.errorMessage});}return;};}\nexport const __FramerMetadata__ = {\"exports\":{\"validateButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"anonymousResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"anonymousResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"candidatElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"candidatElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"listSelectElection\":{\"type\":\"reactHoc\",\"name\":\"listSelectElection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleSeance\":{\"type\":\"reactHoc\",\"name\":\"titleSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonResotutioSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonResotutioSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"secretarySeance\":{\"type\":\"reactHoc\",\"name\":\"secretarySeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"responsesResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"responsesResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"convocationDateSeance\":{\"type\":\"reactHoc\",\"name\":\"convocationDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionDateSeance\":{\"type\":\"reactHoc\",\"name\":\"sessionDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"snakbarre\":{\"type\":\"reactHoc\",\"name\":\"snakbarre\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrutintResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"scrutintResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{jsx as _jsx}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{useState,useEffect}from\"react\";import{sessionStore}from\"https://framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/R4s8N5FHglD5oU98v8Il/CreateSeance.js\";import{editStore,globalStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{getAllDocument}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{compareNames}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";export const participantsStore=createStore({participants:[],deletedParticipants:[],lists:[],users:[],selectedList:\"\",selectListIndex:1,search:\"\",president:null});const proxyStore=createStore({userGivingProxy:{},userReceivingProxy:{}});export function withDifferentLists(Component){return props=>{const[participants,setParticipants]=participantsStore();const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const[users,setUsers]=useState([]);useEffect(()=>{getAllDocument(\"users\").then(async users=>{const lists=[];const usersParticipants=[];users.forEach(user=>{// Assuming \"lists\" is the property containing the array in each user\nconst userLists=user.lists||[];lists.push(...userLists);const{docId,code,idSession,...userWithoutId}=user;usersParticipants.push({...userWithoutId,userId:docId,missing:true,proxyFrom:{},proxyTo:{}});});// Use Set to ensure unique elements\nconst uniqueLists=[\"Choisir une liste...\",...new Set(lists)];setUsers(usersParticipants);setParticipants(prev=>({...prev,lists:uniqueLists,users:usersParticipants}));});},[edit.onEditParticipants]);const handleOnChange=(index,label)=>{if(index!=0){setParticipants(state=>({...state,selectedList:label,selectListIndex:index+1,participants:users.reduce((acc,user,index)=>{if(user.lists?.includes(label)){acc.push(user);}return acc;},[]).sort(compareNames)}));setEdit(state=>({...state,onEditParticipants:true}));}};if(edit.onEditSession&&edit.onEditParticipants&&session.selectedList!=\"\"){return /*#__PURE__*/_jsx(\"span\",{style:{color:\"black\",fontSize:16,fontWeight:\"bold\"},children:participants.selectedList});}else{return /*#__PURE__*/_jsx(Component,{...props,options:participants.lists,onChange:(index,label)=>handleOnChange(index,label),value:participants.selectListIndex,disabled:edit.onEditParticipants&&edit.onEditSession});}};}export function withReinitList(Component){return props=>{const[participants,setParticipants]=participantsStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";const handleOnClick=()=>{if(isCurrentAdminSession){return;}const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer cette liste de participant ?\");if(isConfirmed){setEdit(state=>({...state,onEditParticipants:false}));setParticipants(state=>({...state,participants:[],deletedParticipants:[],selectListIndex:1,president:null}));}};return /*#__PURE__*/_jsx(Component,{...props,onClick:()=>handleOnClick(),color:isCurrentAdminSession?\"grey\":\"\",disabled:!edit.onEditParticipants});};}export function withFormParticipants(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[session,setSession]=sessionStore();const[participantList,setParticipantList]=useState([]);const[isDeleted,setIsDeleted]=useState(false);const[isDisabled,setIsDisabled]=useState(false);const[substituteDisabled,setSubstituteDisabled]=useState(false);const[selectedSubstituteId,setSelectedSubstituteId]=useState(null);const giveVoteOrigin=props.giveVote;const url=globalStore(state=>state.url);const[substituteIds,setSubstituteIds]=useState([]);const isCurrentAdminSession=url===\"/admin/sessions/current/\";useEffect(()=>{if(session.participants.length>0){setParticipants(state=>{const newState={...state};newState.participants=session.participants;newState.selectedList=session.selectedList;newState.president=session.president;if(session.selectedList&&state.users.length>0){newState.deletedParticipants=state.users.reduce((acc,user,index)=>{if(user.lists?.includes(participants.selectedList)&&session.participants.find(participant=>participant.userId==user.userId)===undefined){acc.push(user);}return acc;},[]);}return{...newState};});}},[participants.users]);useEffect(()=>{const substitutes=participants.participants.filter(p=>p.isSubstituted).map(p=>p.id);setSubstituteIds(substitutes);},[participants.participants]);useEffect(()=>{const sortedParticipants=participants.participants.sort(compareNames);setParticipantList(sortedParticipants);setSession(state=>({...state,participants:sortedParticipants,president:participants.president}));if(isDeleted){setIsDeleted(false);}},[participants.participants,participants.president]);useEffect(()=>{if(participants.selectedList!==\"\"){setSession(state=>({...state,selectedList:participants.selectedList}));}},[participants.selectedList]);const handleGiveVote=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;setProxy(state=>({...state,userReceivingProxy:participantWithoutProxy}));giveVoteOrigin();};const handleChangeMissing=participantId=>{setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);// Inverser le statut missing du participant sélectionné\nnewState.participants[indexParticipant].missing=!newState.participants[indexParticipant].missing;// Vérifier si le participant est le représentant de quelqu'un d'autre\nnewState.participants.forEach((participant,index)=>{if(participant.proxyTo?.id===participantId){// Si le représentant est absent, mettre à jour le statut missing du représenté\nnewState.participants[index].missing=newState.participants[indexParticipant].missing;}});return newState;});};const handleDeleteUser=async participantId=>{/*  if (isCurrentAdminSession) {\n                return\n            }*/const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer ce participant de la s\\xe9ance ?\");if(isConfirmed){setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);const proxyToId=newState.participants[indexParticipant].proxyTo?.id;const indexProxyTo=newState.participants.findIndex(participant=>participant.id===proxyToId);const proxyFromId=newState.participants[indexParticipant].proxyFrom?.id;const indexProxyFrom=newState.participants.findIndex(participant=>participant.id===proxyFromId);// si proxyTo enelver le proxyFrom de l'autre\nif(indexProxyTo!==-1){newState.participants[indexProxyTo].proxyFrom={};}// si proxyFrom enlever le proxYTo de l'autre\nif(indexProxyFrom!==-1){newState.participants[indexProxyFrom].proxyTo={};}const deletedParticipant=newState.participants.splice(indexParticipant,1);newState.deletedParticipants=[...newState.deletedParticipants,deletedParticipant[0]];setIsDeleted(true);return newState;});}};const handlePresidentSeance=participantId=>{setParticipants(state=>{const isAlreadyPresident=state.president===participantId;return{...state,president:isAlreadyPresident?null:participantId};});};// Assurez-vous que cela s'exécute lorsque 'participants' change\n/* useEffect(() => {\n            const participant = participants.participants.find(\n                (p) => p.id === participantId\n            )\n            if (participant.isSubstituted === true) {\n                setSelectedSubstituteId(participantId)\n            }\n        }, [participants.participants])*/const handleSubstitute=participantId=>{setParticipants(prevParticipants=>{const updatedParticipants=prevParticipants.participants.map(p=>{if(p.id===participantId){// Mettre à jour isSubstituted pour le participant ciblé\nreturn{...p,proxyTo:{},proxyFrom:{},isSubstituted:!p.isSubstituted};}else if(p.proxyTo?.id===participantId||p.proxyFrom?.id===participantId){// Retirer le pouvoir donné ou reçu par le participant\nreturn{...p,proxyTo:{},proxyFrom:{}};}return p;});// Mettre à jour l'état global des participants\nreturn{...prevParticipants,participants:updatedParticipants};});// Mettre à jour l'ensemble des substituts\nsetSubstituteIds(prevIds=>{const isCurrentlySubstituted=prevIds.includes(participantId);if(isCurrentlySubstituted){// Retirer l'ID du participant de la liste s'il est déjà un substitut\nreturn prevIds.filter(id=>id!==participantId);}else{// Ajouter l'ID du participant à la liste s'il n'est pas encore un substitut\nreturn[...prevIds,participantId];}});// Mettre à jour l'état de la session si nécessaire\nsetSession(state=>({...state,participants:participants.participants}));};return /*#__PURE__*/_jsx(Component,{...props,participants:participantList,//selectedParticipant={participants.selectedParticipant}\ngiveVote:participant=>handleGiveVote(participant),changeMissing:participantId=>handleChangeMissing(participantId),deleteUser:participantId=>handleDeleteUser(participantId),presidentSeance:participantId=>handlePresidentSeance(participantId),president:participants.president,participantSubstitute:participantId=>handleSubstitute(participantId),substituteId:substituteIds,deleteDisabled:isDisabled});};}export function inputSearch(Component){return props=>{const[participants,setParticipants]=participantsStore();const handleOnChange=value=>{setParticipants(state=>({...state,search:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:participants.search,onChange:value=>handleOnChange(value)});};}export function searchWithFilter(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[participantsDisplayed,setParticipantsDisplayed]=useState([]);useEffect(()=>{setParticipants(prevState=>({...prevState,search:\"\"}));},[]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Si le receveur a déjà un pouvoir reçu, on pré-sélectionne le donneur\nif(participantReceivingProxy?.proxyFrom?.id){setProxy(state=>({...state,userGivingProxy:participantReceivingProxy.proxyFrom}));}},[proxy.userReceivingProxy?.id]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Calcul des participants déjà impliqués dans un pouvoir\nconst participantsThatAlreadyGaveVote=participants.participants.reduce((acc,participant)=>{if(participant.proxyFrom?.id){const giver=participants.participants.find(p=>p.id===participant.proxyFrom.id);if(giver)acc.push(giver);}return acc;},[]);const participantsThatAlreadyReceivedVote=participants.participants.filter(p=>p.proxyFrom?.id);const uniqueGivers=[...new Set(participantsThatAlreadyGaveVote)];const uniqueReceivers=[...new Set(participantsThatAlreadyReceivedVote)];// Filtrage principal\nconst participantsFirstFilter=participants.participants.filter(participant=>{// Cas 1 : pas de receveur sélectionné → on affiche tous les non-substitués\nif(!participantReceivingProxy){return!participant.isSubstituted;}// Cas 2 : le participant est l'actuel donneur du receveur → on le garde\nif(participant.id===participantReceivingProxy.proxyFrom?.id){return true;}// Cas 3 : filtre standard\nreturn participant.id!==receiverId&&!uniqueGivers.includes(participant)&&!uniqueReceivers.includes(participant)&&!participant.isSubstituted;});// Application du filtre de recherche\nif(participants.search){const searchTerm=participants.search.toLowerCase();const filtered=participantsFirstFilter.filter(participant=>{const nameMatch=participant.name?.toLowerCase().includes(searchTerm);const firstNameMatch=participant.firstName?.toLowerCase().includes(searchTerm);return nameMatch||firstNameMatch;});setParticipantsDisplayed(filtered);}else{setParticipantsDisplayed(participantsFirstFilter);}},[participants.search,participants.participants,proxy.userReceivingProxy?.id]);const handleClick=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;if(proxy.userGivingProxy?.id===participant.id){setProxy(state=>({...state,userGivingProxy:{}}));}else{setProxy(state=>({...state,userGivingProxy:participantWithoutProxy}));}};return /*#__PURE__*/_jsx(Component,{...props,participants:participantsDisplayed,click:participant=>handleClick(participant),selectedId:proxy.userGivingProxy?.id});};}export function withGiveVote(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const validateOrigin=props.valider;const cancelOrigin=props.annuler;const handleValidate=()=>{if(proxy.userReceivingProxy.id){const indexOfReceiver=participants.participants.findIndex(participant=>participant.id===proxy.userReceivingProxy.id);const previousGiverId=participants.participants[indexOfReceiver].proxyFrom?.id;if(previousGiverId){const indexPreviousGiver=participants.participants.findIndex(participant=>participant.id===previousGiverId);if(indexPreviousGiver!==-1){setParticipants(state=>{const newState={...state};newState.participants[indexPreviousGiver].proxyTo=null;return newState;});}}if(proxy.userGivingProxy.id){const indexOfGiver=participants.participants.findIndex(participant=>participant.id===proxy.userGivingProxy.id);setParticipants(state=>{const newState={...state};newState.participants[indexOfReceiver].proxyFrom=proxy.userGivingProxy;newState.participants[indexOfGiver].proxyTo=proxy.userReceivingProxy;newState.participants[indexOfGiver].missing=false;return newState;});}else{setParticipants(state=>{const newState={...state};const previousGiver=newState.participants[indexOfReceiver].proxyFrom;const indexPreviousGiver=newState.participants.findIndex(participant=>participant.id===previousGiver.id);if(indexPreviousGiver!==-1){newState.participants[indexPreviousGiver].proxyTo={};newState.participants[indexPreviousGiver].missing=true;}newState.participants[indexOfReceiver].proxyFrom={};return newState;});}}setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));console.log(\"valideeee\",participants);validateOrigin();};const handleCancel=()=>{setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));cancelOrigin();};return /*#__PURE__*/_jsx(Component,{...props,valider:()=>handleValidate(),annuler:()=>handleCancel()});};}export function withAddParticipant(Component){return props=>{const[participants,setParticipants]=participantsStore();const session=globalStore(state=>state.session);const[list,setList]=useState([\"Choisir un participant...\"]);const[value,setValue]=useState(1);const[updateKey,setUpdateKey]=useState(0);const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";useEffect(()=>{setList(()=>{const participantsList=[\"Choisir un participant...\"];participantsList.push(...participants.deletedParticipants.reduce((acc,participant)=>{acc.push(`${participant.name} ${participant.firstName}`);return acc;},[]));return participantsList;});},[participants.deletedParticipants]);const handleOnChange=(index,label)=>{setValue(1);if(index!==0){setParticipants(state=>{const newState={...state};const deletedParticipants=[...newState.deletedParticipants];const newParticipant=deletedParticipants.splice(index-1,1);newState.deletedParticipants=deletedParticipants;newState.participants=[...newState.participants,newParticipant[0]];return newState;});}};// Effect to reset the value when needed\nuseEffect(()=>{setValue(1);setUpdateKey(prevKey=>prevKey+1)// Incrémente le key pour forcer la mise à jour\n;},[list]);return /*#__PURE__*/_createElement(Component,{...props,key:updateKey,value:value,options:list,onChange:(index,label)=>handleOnChange(index,label)});};}\nexport const __FramerMetadata__ = {\"exports\":{\"inputSearch\":{\"type\":\"reactHoc\",\"name\":\"inputSearch\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"participantsStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"searchWithFilter\":{\"type\":\"reactHoc\",\"name\":\"searchWithFilter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFormParticipants\":{\"type\":\"reactHoc\",\"name\":\"withFormParticipants\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAddParticipant\":{\"type\":\"reactHoc\",\"name\":\"withAddParticipant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDifferentLists\":{\"type\":\"reactHoc\",\"name\":\"withDifferentLists\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGiveVote\":{\"type\":\"reactHoc\",\"name\":\"withGiveVote\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withReinitList\":{\"type\":\"reactHoc\",\"name\":\"withReinitList\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{generateUniqueId}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{globalStore,editStore,errorStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createDocument,setCollectionAndDocumentToDocument,editSession,getLastIdDocument,updateChampInDocument,getValueInChamp}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{participantsStore}from\"https://framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/LBHLgsg8D7krWL1uiHLr/ParticipantSeance.js\";export const sessionStore=createStore({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,chorum:false,orderItems:[],items:[],selectedList:\"\",participants:[]});export const electionDefault={title:\"\",list:\"\",candidats:[],anonymous:true,round:1};export const electionStore=createStore(electionDefault);export const resolutionDefault={title:\"\",anonymous:false,responses:[],scrutin:\"\",answerTypeResponses:\"\"};export const resolutionStore=createStore(resolutionDefault);export function secretarySeance(Component){return props=>{const[state,setState]=sessionStore();const[participants,setParticipants]=participantsStore();const onChangeInput=value=>{setState(prev=>({...prev,secretary:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.secretary||\"\",onChange:value=>onChangeInput(value)});};}export function titleSeance(Component){return props=>{const[state,setState]=sessionStore();const onChangeInput=value=>{setState(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.title||\"\",onChange:value=>onChangeInput(value)});};}export function sessionDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,sessionDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.sessionDate,onDateChange:handleDateChange,onEditCalendar:state.sessionDate});};}export function convocationDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,convocationDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.convocationDate,onDateChange:handleDateChange,onEditCalendar:state.convocationDate});};}export function validateButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[participantsStoreState,setParticipantsStoreState]=participantsStore()// ✅ Accès direct au store des participants\n;const[messageState,setMessageState]=errorStore();const setSessionGlobal=globalStore(state=>state.setSession);const sessionGlobal=globalStore(state=>state.session);const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);const[isSubmitted,setIsSubmitted]=useState(false);const[edit,setEdit]=editStore();const handleTap=async()=>{// ✅ session contient les bonnes données (vérifié via les logs)\nconsole.log(\"🔎 handleTap - \\xe9tat au clic Valider :\",{\"participantsStore.participants.length\":participantsStoreState.participants.length,\"session.participants.length\":session.participants?.length??0,\"session.selectedList\":session.selectedList});const areRequiredFieldsFilled=session.title&&session.sessionDate&&session.convocationDate;const hasItems=session.items.length>0;const hasParticipants=session.participants.length>0// ✅ session\n;if(!areRequiredFieldsFilled){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Tous les champs obligatoires doivent \\xeatre remplis.\"}));return;}if(!hasItems){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Au moins un item doit \\xeatre ajout\\xe9.\"}));return;}if(!hasParticipants){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Une liste de participants doit \\xeatre s\\xe9lectionn\\xe9e.\"}));return;}const sessionDate=new Date(session.sessionDate);const convocationDate=new Date(session.convocationDate);if(sessionDate<=convocationDate){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"La date de la s\\xe9ance doit \\xeatre post\\xe9rieure \\xe0 la date de convocation.\"}));return;}const{items,participants,...stateWithoutCollections}=session;if(!edit.onEditSession&&!isSubmitted){// ... (tout le code de création inchangé, tel qu'il était à l'origine)\nsetIsSubmitted(true);const id=await getLastIdDocument(\"sessions\");if(id){setSessionGlobal(session);const subCollectionItems=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"items\",session.items);const subCollectionParticipants=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"participants\",session.participants);if(Array.isArray(subCollectionItems)){const orderItems=subCollectionItems;const dataToSend={...stateWithoutCollections,orderItems,chorum:false,docId:(id+1).toString(),id:(id+1).toString()};const response=await createDocument(\"sessions\",dataToSend,(id+1).toString());if(response.success){console.info(response.message);window.location.href=\"/admin/sessions/\";}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",response.error);setIsSubmitted(false);}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\");}}}else{/**\n                 * EDIT EXISTING SESSION\n                 */if(!isSubmitted){setIsSubmitted(true);const{currentItemId,...sessionWithoutCurrentItemId}=session;// ✅ LOG DEBUG - vérification que les pouvoirs sont bien présents\nconsole.log(\"📤 Envoi \\xe0 editSession :\",{idSession:edit.idSession,participantsAvecPouvoirs:sessionWithoutCurrentItemId.participants?.map(p=>({id:p.id,name:p.name,proxyFrom:p.proxyFrom,proxyTo:p.proxyTo}))});const editResponse=await editSession(`sessions`,edit.idSession,sessionWithoutCurrentItemId);setSessionGlobal(editResponse.updatedSession);if(editResponse.success){console.info(editResponse.message);setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(session.startedSession){// ... (reste du code identique à l'original)\nconst newParticipantIds=session.participants.reduce((acc,participant)=>{if(participant.missing===false){if(participant.isSubstituted&&participant.substitute){acc.push(participant.substitute.id);}else if(Object.keys(participant.proxyTo||{}).length===0){acc.push(participant.id);}}return acc;},[]);const participantsWithSubstitute=session.participants.reduce((acc,participant)=>{if(participant.substitute){acc.push(participant.substitute.id);acc.push(participant.id);}else{acc.push(participant.id);}return acc;},[]);const updatedSession={...session,participantIds:newParticipantIds};const deletedParticipantIds=participantsStoreState.deletedParticipants.map(participant=>participant.id);let allParticipantIdsToUpdate=[...participantsWithSubstitute,...deletedParticipantIds];let filteredParticipantIds=[];for(const participantId of allParticipantIdsToUpdate){const matches=await getValueInChamp(\"users\",participantId.toString(),session.docId);if(matches){filteredParticipantIds.push(participantId);}}allParticipantIdsToUpdate=filteredParticipantIds;for(const participantId of allParticipantIdsToUpdate){await updateChampInDocument(\"users\",{idSession:\"\"},participantId.toString());}for(const participantId of newParticipantIds){await updateChampInDocument(\"users\",{idSession:updatedSession.id},participantId.toString());}setSessionGlobal(updatedSession);}if(url==\"/admin/sessions/current/\"){setIsSubmitted(false);window.location.href=\"/admin/sessions/current/\";}else{setIsSubmitted(false);window.location.href=\"/admin/sessions/\";}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",editResponse.error);}}}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);// const tapOrigin = props.tap\nconst handleTap=()=>{setSession(prev=>({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,items:[]}));if(edit.onEditSession){setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(url==\"/admin/sessions/current/\"){//    setUrl(\"\")\nwindow.location.href=\"/admin/sessions/current/\";return;}else{window.location.href=\"/admin/sessions/\";}}window.location.href=\"/admin/sessions/\";// tapOrigin()\n};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------------------ELECTION-------------------------------------------------------\nexport function titleElectionSeance(Component){return props=>{const[election,setElection]=electionStore();// ✅ LOG DEBUG\nconsole.log(\"📝 titleElectionSeance render, election.title =\",election.title,\"full election =\",election);const handleTitleChange=value=>{setElection(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:election.title,onChange:value=>handleTitleChange(value)});};}export function listSelectElection(Component){return props=>{const[options,setOptions]=useState([]);const[election,setElection]=electionStore();const[participants,setParticipants]=participantsStore();useEffect(()=>{setOptions(participants.lists);},[participants.lists]);useEffect(()=>{if(!election.list){setElection(state=>({...state,list:participants.selectedList}));}},[participants.selectedList]);const handleOnChange=(index,label)=>{if(index!=0){setElection(state=>({...state,list:label}));}};return /*#__PURE__*/_jsx(Component,{...props,options:options,onChange:(index,label)=>handleOnChange(index,label),value:options.findIndex(option=>option===election.list)+1});};}export function candidatElectionSeance(Component){return props=>{const[election,setElection]=electionStore();const[participants,setParticipant]=participantsStore();const[extractedNames,setExtractedNames]=useState([]);const[filteredElectionCandidates,setFilteredElectionCandidates]=useState([]);const handleInputChangeCallback=newInputs=>{const newCandidats=newInputs.filter(input=>input.trim()!==\"\");setElection(prev=>({...prev,candidats:newCandidats}));};// const extractedNames = participant.participants.map(\n//     (p) => `${p.firstName} ${p.name}`\n// )\nuseEffect(()=>{if(participants.users.length>0&&election.list!==\"\"){setExtractedNames(participants.users.filter(user=>user.lists?.includes(election.list)).map(p=>`${p.firstName} ${p.name}`));}},[election.list]);return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:inputs=>handleInputChangeCallback(inputs),onEditValues:extractedNames,initialSelectedCandidates:election.candidats});};}/*export function scrutintElectionSeance(Component): ComponentType {\n    return (props) => {\n        const [election, setElection] = electionStore()\n\n        useEffect(() => {\n            if (election.scrutin == \"\") {\n                setElection((prev) => ({\n                    ...prev,\n                    scrutin: props.options[0],\n                }))\n            }\n        }, [])\n\n        const handleOnChange = (index, label) => {\n            setElection((prev) => ({\n                ...prev,\n                scrutin: label,\n            }))\n        }\n        console.log(\"props.opt[0]\", props.options[0])\n        const initialValue = props.options.findIndex(\n            (option) => option === election.scrutin\n        )\n        return (\n            <Component\n                {...props}\n                value={initialValue + 1}\n                onChange={(index, label) => handleOnChange(index, label)}\n            />\n        )\n    }\n}*/export function validateButtonElectionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[election,setElection]=electionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=election.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez bien remplir le titre de l'\\xe9lection\"}));}else if(election.list===\"\"){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez choisir une liste\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newElectionItem={type:\"election\",id:uniqueId,...election};setSession(prev=>({...prev,items:[...prev.items,newElectionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"election\",...election};return state;});}setElection(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonElectionSeance(Component){return props=>{const[electionState,setElectionState]=electionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setElectionState(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------RESOLUTION----------------------------------------\nexport function titleResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleTitleChange=value=>{setResolution(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:resolution.title,onChange:value=>handleTitleChange(value)});};}export function responsesResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleInputChangeCallback=(newInputs,answerTypeCallback)=>{const newResponses=newInputs;setResolution(prev=>({...prev,responses:newResponses,answerTypeResponses:answerTypeCallback}));};return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:(inputs,answerTypeCallback)=>handleInputChangeCallback(inputs,answerTypeCallback),answerResponses:resolution.answerTypeResponses,onEditValues:resolution.responses});};}export function scrutintResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();useEffect(()=>{if(resolution.scrutin==\"\"){setResolution(prev=>({...prev,scrutin:props.options[0]}));}},[]);const handleOnChange=(index,label)=>{setResolution(prev=>({...prev,scrutin:label}));};const initialValue=props.options.findIndex(option=>option===resolution.scrutin);return /*#__PURE__*/_jsx(Component,{...props,value:initialValue+1,onChange:(index,label)=>handleOnChange(index,label)});};}export function anonymousResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleToggle=()=>{setResolution(prev=>({...prev,anonymous:!prev.anonymous}));};const checkboxProps={isChecked:resolution.anonymous,onToggle:()=>{handleToggle();}};return /*#__PURE__*/_jsx(Component,{...props,...checkboxProps});};}export function validateButtonResolutionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[resolution,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=resolution.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez remplir le titre!\"}));}else if(resolution.responses.length===1&&resolution.responses[0]===\"\"||resolution.responses.length===0){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez ajouter une r\\xe9ponse valide!\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newResolutionItem={type:\"resolution\",id:uniqueId,...resolution};setSession(prev=>({...prev,items:[...prev.items,newResolutionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"resolution\",...resolution};return state;});}setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonResotutioSeance(Component){return props=>{const[resolutionState,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-------------------------------------------UTILS-----------------\nexport function snakbarre(Component){return props=>{const[state,setState]=errorStore();if(state.error){setTimeout(()=>{setState(prevState=>({...prevState,error:false}));},3e3);return /*#__PURE__*/_jsx(Component,{...props,message:state.errorMessage});}return;};}\nexport const __FramerMetadata__ = {\"exports\":{\"snakbarre\":{\"type\":\"reactHoc\",\"name\":\"snakbarre\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"secretarySeance\":{\"type\":\"reactHoc\",\"name\":\"secretarySeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonResotutioSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonResotutioSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionDateSeance\":{\"type\":\"reactHoc\",\"name\":\"sessionDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"convocationDateSeance\":{\"type\":\"reactHoc\",\"name\":\"convocationDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleSeance\":{\"type\":\"reactHoc\",\"name\":\"titleSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"candidatElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"candidatElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"responsesResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"responsesResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrutintResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"scrutintResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"anonymousResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"anonymousResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"listSelectElection\":{\"type\":\"reactHoc\",\"name\":\"listSelectElection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CreateSeance.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{useState,useEffect}from\"react\";import{sessionStore}from\"https://framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/jt70H8T03vxbf6Z9xejQ/CreateSeance.js\";import{editStore,globalStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{getAllDocument}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{compareNames}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";export const participantsStore=createStore({participants:[],deletedParticipants:[],lists:[],users:[],selectedList:\"\",selectListIndex:1,search:\"\",president:null});const proxyStore=createStore({userGivingProxy:{},userReceivingProxy:{}});export function withDifferentLists(Component){return props=>{const[participants,setParticipants]=participantsStore();const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const[users,setUsers]=useState([]);useEffect(()=>{getAllDocument(\"users\").then(async users=>{const lists=[];const usersParticipants=[];users.forEach(user=>{// Assuming \"lists\" is the property containing the array in each user\nconst userLists=user.lists||[];lists.push(...userLists);const{docId,code,idSession,...userWithoutId}=user;usersParticipants.push({...userWithoutId,userId:docId,missing:true,proxyFrom:{},proxyTo:{}});});// Use Set to ensure unique elements\nconst uniqueLists=[\"Choisir une liste...\",...new Set(lists)];setUsers(usersParticipants);setParticipants(prev=>({...prev,lists:uniqueLists,users:usersParticipants}));});},[edit.onEditParticipants]);const handleOnChange=(index,label)=>{if(index!=0){setParticipants(state=>({...state,selectedList:label,selectListIndex:index+1,participants:users.reduce((acc,user,index)=>{if(user.lists?.includes(label)){acc.push(user);}return acc;},[]).sort(compareNames)}));setEdit(state=>({...state,onEditParticipants:true}));}};if(edit.onEditSession&&edit.onEditParticipants&&session.selectedList!=\"\"){return /*#__PURE__*/_jsx(\"span\",{style:{color:\"black\",fontSize:16,fontWeight:\"bold\"},children:participants.selectedList});}else{return /*#__PURE__*/_jsx(Component,{...props,options:participants.lists,onChange:(index,label)=>handleOnChange(index,label),value:participants.selectListIndex,disabled:edit.onEditParticipants&&edit.onEditSession});}};}export function withReinitList(Component){return props=>{const[participants,setParticipants]=participantsStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";const handleOnClick=()=>{if(isCurrentAdminSession){return;}const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer cette liste de participant ?\");if(isConfirmed){setEdit(state=>({...state,onEditParticipants:false}));setParticipants(state=>({...state,participants:[],deletedParticipants:[],selectListIndex:1,president:null}));}};return /*#__PURE__*/_jsx(Component,{...props,onClick:()=>handleOnClick(),color:isCurrentAdminSession?\"grey\":\"\",disabled:!edit.onEditParticipants});};}export function withFormParticipants(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[session,setSession]=sessionStore();const[participantList,setParticipantList]=useState([]);const[isDeleted,setIsDeleted]=useState(false);const[isDisabled,setIsDisabled]=useState(false);const[substituteDisabled,setSubstituteDisabled]=useState(false);const[selectedSubstituteId,setSelectedSubstituteId]=useState(null);const giveVoteOrigin=props.giveVote;const url=globalStore(state=>state.url);const[substituteIds,setSubstituteIds]=useState([]);const isCurrentAdminSession=url===\"/admin/sessions/current/\";useEffect(()=>{if(session.participants.length>0){setParticipants(state=>{const newState={...state};newState.participants=session.participants;newState.selectedList=session.selectedList;newState.president=session.president;if(session.selectedList&&state.users.length>0){newState.deletedParticipants=state.users.reduce((acc,user,index)=>{if(user.lists?.includes(participants.selectedList)&&session.participants.find(participant=>participant.userId==user.userId)===undefined){acc.push(user);}return acc;},[]);}return{...newState};});}},[participants.users]);useEffect(()=>{const substitutes=participants.participants.filter(p=>p.isSubstituted).map(p=>p.id);setSubstituteIds(substitutes);},[participants.participants]);useEffect(()=>{const sortedParticipants=participants.participants.sort(compareNames);setParticipantList(sortedParticipants);setSession(state=>({...state,participants:sortedParticipants,president:participants.president}));if(isDeleted){setIsDeleted(false);}},[participants.participants,participants.president]);useEffect(()=>{if(participants.selectedList!==\"\"){setSession(state=>({...state,selectedList:participants.selectedList}));}},[participants.selectedList]);const handleGiveVote=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;setProxy(state=>({...state,userReceivingProxy:participantWithoutProxy}));giveVoteOrigin();};const handleChangeMissing=participantId=>{setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);// Inverser le statut missing du participant sélectionné\nnewState.participants[indexParticipant].missing=!newState.participants[indexParticipant].missing;// Vérifier si le participant est le représentant de quelqu'un d'autre\nnewState.participants.forEach((participant,index)=>{if(participant.proxyTo?.id===participantId){// Si le représentant est absent, mettre à jour le statut missing du représenté\nnewState.participants[index].missing=newState.participants[indexParticipant].missing;}});return newState;});};const handleDeleteUser=async participantId=>{/*  if (isCurrentAdminSession) {\n                return\n            }*/const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer ce participant de la s\\xe9ance ?\");if(isConfirmed){setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);const proxyToId=newState.participants[indexParticipant].proxyTo?.id;const indexProxyTo=newState.participants.findIndex(participant=>participant.id===proxyToId);const proxyFromId=newState.participants[indexParticipant].proxyFrom?.id;const indexProxyFrom=newState.participants.findIndex(participant=>participant.id===proxyFromId);// si proxyTo enelver le proxyFrom de l'autre\nif(indexProxyTo!==-1){newState.participants[indexProxyTo].proxyFrom={};}// si proxyFrom enlever le proxYTo de l'autre\nif(indexProxyFrom!==-1){newState.participants[indexProxyFrom].proxyTo={};}const deletedParticipant=newState.participants.splice(indexParticipant,1);newState.deletedParticipants=[...newState.deletedParticipants,deletedParticipant[0]];setIsDeleted(true);return newState;});}};const handlePresidentSeance=participantId=>{setParticipants(state=>{const isAlreadyPresident=state.president===participantId;return{...state,president:isAlreadyPresident?null:participantId};});};// Assurez-vous que cela s'exécute lorsque 'participants' change\n/* useEffect(() => {\n            const participant = participants.participants.find(\n                (p) => p.id === participantId\n            )\n            if (participant.isSubstituted === true) {\n                setSelectedSubstituteId(participantId)\n            }\n        }, [participants.participants])*/const handleSubstitute=participantId=>{setParticipants(prevParticipants=>{const updatedParticipants=prevParticipants.participants.map(p=>{if(p.id===participantId){// Mettre à jour isSubstituted pour le participant ciblé\nreturn{...p,proxyTo:{},proxyFrom:{},isSubstituted:!p.isSubstituted};}else if(p.proxyTo?.id===participantId||p.proxyFrom?.id===participantId){// Retirer le pouvoir donné ou reçu par le participant\nreturn{...p,proxyTo:{},proxyFrom:{}};}return p;});// Mettre à jour l'état global des participants\nreturn{...prevParticipants,participants:updatedParticipants};});// Mettre à jour l'ensemble des substituts\nsetSubstituteIds(prevIds=>{const isCurrentlySubstituted=prevIds.includes(participantId);if(isCurrentlySubstituted){// Retirer l'ID du participant de la liste s'il est déjà un substitut\nreturn prevIds.filter(id=>id!==participantId);}else{// Ajouter l'ID du participant à la liste s'il n'est pas encore un substitut\nreturn[...prevIds,participantId];}});// Mettre à jour l'état de la session si nécessaire\nsetSession(state=>({...state,participants:participants.participants}));};return /*#__PURE__*/_jsx(Component,{...props,participants:participantList,//selectedParticipant={participants.selectedParticipant}\ngiveVote:participant=>handleGiveVote(participant),changeMissing:participantId=>handleChangeMissing(participantId),deleteUser:participantId=>handleDeleteUser(participantId),presidentSeance:participantId=>handlePresidentSeance(participantId),president:participants.president,participantSubstitute:participantId=>handleSubstitute(participantId),substituteId:substituteIds,deleteDisabled:isDisabled});};}export function inputSearch(Component){return props=>{const[participants,setParticipants]=participantsStore();const handleOnChange=value=>{setParticipants(state=>({...state,search:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:participants.search,onChange:value=>handleOnChange(value)});};}export function searchWithFilter(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[participantsDisplayed,setParticipantsDisplayed]=useState([]);useEffect(()=>{setParticipants(prevState=>({...prevState,search:\"\"}));},[]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Si le receveur a déjà un pouvoir reçu, on pré-sélectionne le donneur\nif(participantReceivingProxy?.proxyFrom?.id){setProxy(state=>({...state,userGivingProxy:participantReceivingProxy.proxyFrom}));}},[proxy.userReceivingProxy?.id]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Calcul des participants déjà impliqués dans un pouvoir\nconst participantsThatAlreadyGaveVote=participants.participants.reduce((acc,participant)=>{if(participant.proxyFrom?.id){const giver=participants.participants.find(p=>p.id===participant.proxyFrom.id);if(giver)acc.push(giver);}return acc;},[]);const participantsThatAlreadyReceivedVote=participants.participants.filter(p=>p.proxyFrom?.id);const uniqueGivers=[...new Set(participantsThatAlreadyGaveVote)];const uniqueReceivers=[...new Set(participantsThatAlreadyReceivedVote)];// Filtrage principal\nconst participantsFirstFilter=participants.participants.filter(participant=>{// Cas 1 : pas de receveur sélectionné → on affiche tous les non-substitués\nif(!participantReceivingProxy){return!participant.isSubstituted;}// Cas 2 : le participant est l'actuel donneur du receveur → on le garde\nif(participant.id===participantReceivingProxy.proxyFrom?.id){return true;}// Cas 3 : filtre standard\nreturn participant.id!==receiverId&&!uniqueGivers.includes(participant)&&!uniqueReceivers.includes(participant)&&!participant.isSubstituted;});// Application du filtre de recherche\nif(participants.search){const searchTerm=participants.search.toLowerCase();const filtered=participantsFirstFilter.filter(participant=>{const nameMatch=participant.name?.toLowerCase().includes(searchTerm);const firstNameMatch=participant.firstName?.toLowerCase().includes(searchTerm);return nameMatch||firstNameMatch;});setParticipantsDisplayed(filtered);}else{setParticipantsDisplayed(participantsFirstFilter);}},[participants.search,participants.participants,proxy.userReceivingProxy?.id]);const handleClick=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;if(proxy.userGivingProxy?.id===participant.id){setProxy(state=>({...state,userGivingProxy:{}}));}else{setProxy(state=>({...state,userGivingProxy:participantWithoutProxy}));}};return /*#__PURE__*/_jsx(Component,{...props,participants:participantsDisplayed,click:participant=>handleClick(participant),selectedId:proxy.userGivingProxy?.id});};}export function withGiveVote(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const validateOrigin=props.valider;const cancelOrigin=props.annuler;const handleValidate=()=>{if(proxy.userReceivingProxy.id){const indexOfReceiver=participants.participants.findIndex(participant=>participant.id===proxy.userReceivingProxy.id);const previousGiverId=participants.participants[indexOfReceiver].proxyFrom?.id;if(previousGiverId){const indexPreviousGiver=participants.participants.findIndex(participant=>participant.id===previousGiverId);if(indexPreviousGiver!==-1){setParticipants(state=>{const newState={...state};newState.participants[indexPreviousGiver].proxyTo=null;return newState;});}}if(proxy.userGivingProxy.id){const indexOfGiver=participants.participants.findIndex(participant=>participant.id===proxy.userGivingProxy.id);setParticipants(state=>{const newState={...state};newState.participants[indexOfReceiver].proxyFrom=proxy.userGivingProxy;newState.participants[indexOfGiver].proxyTo=proxy.userReceivingProxy;newState.participants[indexOfGiver].missing=false;return newState;});}else{setParticipants(state=>{const newState={...state};const previousGiver=newState.participants[indexOfReceiver].proxyFrom;const indexPreviousGiver=newState.participants.findIndex(participant=>participant.id===previousGiver.id);if(indexPreviousGiver!==-1){newState.participants[indexPreviousGiver].proxyTo={};newState.participants[indexPreviousGiver].missing=true;}newState.participants[indexOfReceiver].proxyFrom={};return newState;});}}setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));console.log(\"valideeee\",participants);validateOrigin();};const handleCancel=()=>{setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));cancelOrigin();};return /*#__PURE__*/_jsx(Component,{...props,valider:()=>handleValidate(),annuler:()=>handleCancel()});};}export function withAddParticipant(Component){return props=>{const[participants,setParticipants]=participantsStore();const session=globalStore(state=>state.session);const[list,setList]=useState([\"Choisir un participant...\"]);const[value,setValue]=useState(1);const[updateKey,setUpdateKey]=useState(0);const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";useEffect(()=>{setList(()=>{const participantsList=[\"Choisir un participant...\"];participantsList.push(...participants.deletedParticipants.reduce((acc,participant)=>{acc.push(`${participant.name} ${participant.firstName}`);return acc;},[]));return participantsList;});},[participants.deletedParticipants]);const handleOnChange=(index,label)=>{setValue(1);if(index!==0){setParticipants(state=>{const newState={...state};const deletedParticipants=[...newState.deletedParticipants];const newParticipant=deletedParticipants.splice(index-1,1);newState.deletedParticipants=deletedParticipants;newState.participants=[...newState.participants,newParticipant[0]];return newState;});}};// Effect to reset the value when needed\nuseEffect(()=>{setValue(1);setUpdateKey(prevKey=>prevKey+1)// Incrémente le key pour forcer la mise à jour\n;},[list]);return /*#__PURE__*/_createElement(Component,{...props,key:updateKey,value:value,options:list,onChange:(index,label)=>handleOnChange(index,label)});};}\nexport const __FramerMetadata__ = {\"exports\":{\"inputSearch\":{\"type\":\"reactHoc\",\"name\":\"inputSearch\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"participantsStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"searchWithFilter\":{\"type\":\"reactHoc\",\"name\":\"searchWithFilter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFormParticipants\":{\"type\":\"reactHoc\",\"name\":\"withFormParticipants\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAddParticipant\":{\"type\":\"reactHoc\",\"name\":\"withAddParticipant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDifferentLists\":{\"type\":\"reactHoc\",\"name\":\"withDifferentLists\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGiveVote\":{\"type\":\"reactHoc\",\"name\":\"withGiveVote\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withReinitList\":{\"type\":\"reactHoc\",\"name\":\"withReinitList\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{generateUniqueId}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{globalStore,editStore,errorStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createDocument,setCollectionAndDocumentToDocument,editSession,getLastIdDocument,updateChampInDocument,getValueInChamp}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{participantsStore}from\"https://framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/Jzb8T924Cfz7iw8UCfCe/ParticipantSeance.js\";export const sessionStore=createStore({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,chorum:false,orderItems:[],items:[],selectedList:\"\",participants:[]});export const electionDefault={title:\"\",list:\"\",candidats:[],anonymous:true,round:1};export const electionStore=createStore(electionDefault);export const resolutionDefault={title:\"\",anonymous:false,responses:[],scrutin:\"\",answerTypeResponses:\"\"};export const resolutionStore=createStore(resolutionDefault);export function secretarySeance(Component){return props=>{const[state,setState]=sessionStore();const[participants,setParticipants]=participantsStore();const onChangeInput=value=>{setState(prev=>({...prev,secretary:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.secretary||\"\",onChange:value=>onChangeInput(value)});};}export function titleSeance(Component){return props=>{const[state,setState]=sessionStore();const onChangeInput=value=>{setState(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.title||\"\",onChange:value=>onChangeInput(value)});};}export function sessionDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,sessionDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.sessionDate,onDateChange:handleDateChange,onEditCalendar:state.sessionDate});};}export function convocationDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,convocationDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.convocationDate,onDateChange:handleDateChange,onEditCalendar:state.convocationDate});};}export function validateButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[participantsStoreState,setParticipantsStoreState]=participantsStore()// ✅ Accès direct au store des participants\n;const[messageState,setMessageState]=errorStore();const setSessionGlobal=globalStore(state=>state.setSession);const sessionGlobal=globalStore(state=>state.session);const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);const[isSubmitted,setIsSubmitted]=useState(false);const[edit,setEdit]=editStore();const handleTap=async()=>{// ✅ session contient les bonnes données (vérifié via les logs)\nconsole.log(\"🔎 handleTap - \\xe9tat au clic Valider :\",{\"participantsStore.participants.length\":participantsStoreState.participants.length,\"session.participants.length\":session.participants?.length??0,\"session.selectedList\":session.selectedList});const areRequiredFieldsFilled=session.title&&session.sessionDate&&session.convocationDate;const hasItems=session.items.length>0;const hasParticipants=session.participants.length>0// ✅ session\n;if(!areRequiredFieldsFilled){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Tous les champs obligatoires doivent \\xeatre remplis.\"}));return;}if(!hasItems){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Au moins un item doit \\xeatre ajout\\xe9.\"}));return;}if(!hasParticipants){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Une liste de participants doit \\xeatre s\\xe9lectionn\\xe9e.\"}));return;}const sessionDate=new Date(session.sessionDate);const convocationDate=new Date(session.convocationDate);if(sessionDate<=convocationDate){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"La date de la s\\xe9ance doit \\xeatre post\\xe9rieure \\xe0 la date de convocation.\"}));return;}const{items,participants,...stateWithoutCollections}=session;if(!edit.onEditSession&&!isSubmitted){// ... (tout le code de création inchangé, tel qu'il était à l'origine)\nsetIsSubmitted(true);const id=await getLastIdDocument(\"sessions\");if(id){setSessionGlobal(session);const subCollectionItems=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"items\",session.items);const subCollectionParticipants=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"participants\",session.participants);if(Array.isArray(subCollectionItems)){const orderItems=subCollectionItems;const dataToSend={...stateWithoutCollections,orderItems,chorum:false,docId:(id+1).toString(),id:(id+1).toString()};const response=await createDocument(\"sessions\",dataToSend,(id+1).toString());if(response.success){console.info(response.message);window.location.href=\"/admin/sessions/\";}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",response.error);setIsSubmitted(false);}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\");}}}else{/**\n                 * EDIT EXISTING SESSION\n                 */if(!isSubmitted){setIsSubmitted(true);const{currentItemId,...sessionWithoutCurrentItemId}=session;// ✅ LOG DEBUG - vérification que les pouvoirs sont bien présents\nconsole.log(\"📤 Envoi \\xe0 editSession :\",{idSession:edit.idSession,participantsAvecPouvoirs:sessionWithoutCurrentItemId.participants?.map(p=>({id:p.id,name:p.name,proxyFrom:p.proxyFrom,proxyTo:p.proxyTo}))});const editResponse=await editSession(`sessions`,edit.idSession,sessionWithoutCurrentItemId);setSessionGlobal(editResponse.updatedSession);if(editResponse.success){console.info(editResponse.message);setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(session.startedSession){// ... (reste du code identique à l'original)\nconst newParticipantIds=session.participants.reduce((acc,participant)=>{if(participant.missing===false){if(participant.isSubstituted&&participant.substitute){acc.push(participant.substitute.id);}else if(Object.keys(participant.proxyTo||{}).length===0){acc.push(participant.id);}}return acc;},[]);const participantsWithSubstitute=session.participants.reduce((acc,participant)=>{if(participant.substitute){acc.push(participant.substitute.id);acc.push(participant.id);}else{acc.push(participant.id);}return acc;},[]);const updatedSession={...session,participantIds:newParticipantIds};const deletedParticipantIds=participantsStoreState.deletedParticipants.map(participant=>participant.id);let allParticipantIdsToUpdate=[...participantsWithSubstitute,...deletedParticipantIds];let filteredParticipantIds=[];for(const participantId of allParticipantIdsToUpdate){const matches=await getValueInChamp(\"users\",participantId.toString(),session.docId);if(matches){filteredParticipantIds.push(participantId);}}allParticipantIdsToUpdate=filteredParticipantIds;for(const participantId of allParticipantIdsToUpdate){await updateChampInDocument(\"users\",{idSession:\"\"},participantId.toString());}for(const participantId of newParticipantIds){await updateChampInDocument(\"users\",{idSession:updatedSession.id},participantId.toString());}setSessionGlobal(updatedSession);}if(url==\"/admin/sessions/current/\"){setIsSubmitted(false);window.location.href=\"/admin/sessions/current/\";}else{setIsSubmitted(false);window.location.href=\"/admin/sessions/\";}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",editResponse.error);}}}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);// const tapOrigin = props.tap\nconst handleTap=()=>{setSession(prev=>({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,items:[]}));if(edit.onEditSession){setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(url==\"/admin/sessions/current/\"){//    setUrl(\"\")\nwindow.location.href=\"/admin/sessions/current/\";return;}else{window.location.href=\"/admin/sessions/\";}}window.location.href=\"/admin/sessions/\";// tapOrigin()\n};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------------------ELECTION-------------------------------------------------------\nexport function titleElectionSeance(Component){return props=>{const[election,setElection]=electionStore();// ✅ LOG DEBUG\nconsole.log(\"📝 titleElectionSeance render, election.title =\",election.title,\"full election =\",election);const handleTitleChange=value=>{setElection(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:election.title,onChange:value=>handleTitleChange(value)});};}export function listSelectElection(Component){return props=>{const[options,setOptions]=useState([]);const[election,setElection]=electionStore();const[participants,setParticipants]=participantsStore();// ✅ LOG DEBUG\nconsole.log(\"📋 listSelectElection render\",{\"options.length\":options.length,options:options,\"participants.lists\":participants.lists,\"election.list\":election.list,\"computed value\":options.findIndex(o=>o===election.list)+1});useEffect(()=>{setOptions(participants.lists);},[participants.lists]);useEffect(()=>{if(!election.list){setElection(state=>({...state,list:participants.selectedList}));}},[participants.selectedList]);const handleOnChange=(index,label)=>{if(index!=0){setElection(state=>({...state,list:label}));}};return /*#__PURE__*/_jsx(Component,{...props,options:options,onChange:(index,label)=>handleOnChange(index,label),value:options.findIndex(option=>option===election.list)+1});};}export function candidatElectionSeance(Component){return props=>{const[election,setElection]=electionStore();const[participants,setParticipant]=participantsStore();const[extractedNames,setExtractedNames]=useState([]);const[filteredElectionCandidates,setFilteredElectionCandidates]=useState([]);const handleInputChangeCallback=newInputs=>{const newCandidats=newInputs.filter(input=>input.trim()!==\"\");setElection(prev=>({...prev,candidats:newCandidats}));};// const extractedNames = participant.participants.map(\n//     (p) => `${p.firstName} ${p.name}`\n// )\nuseEffect(()=>{if(participants.users.length>0&&election.list!==\"\"){setExtractedNames(participants.users.filter(user=>user.lists?.includes(election.list)).map(p=>`${p.firstName} ${p.name}`));}},[election.list]);return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:inputs=>handleInputChangeCallback(inputs),onEditValues:extractedNames,initialSelectedCandidates:election.candidats});};}/*export function scrutintElectionSeance(Component): ComponentType {\n    return (props) => {\n        const [election, setElection] = electionStore()\n\n        useEffect(() => {\n            if (election.scrutin == \"\") {\n                setElection((prev) => ({\n                    ...prev,\n                    scrutin: props.options[0],\n                }))\n            }\n        }, [])\n\n        const handleOnChange = (index, label) => {\n            setElection((prev) => ({\n                ...prev,\n                scrutin: label,\n            }))\n        }\n        console.log(\"props.opt[0]\", props.options[0])\n        const initialValue = props.options.findIndex(\n            (option) => option === election.scrutin\n        )\n        return (\n            <Component\n                {...props}\n                value={initialValue + 1}\n                onChange={(index, label) => handleOnChange(index, label)}\n            />\n        )\n    }\n}*/export function validateButtonElectionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[election,setElection]=electionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=election.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez bien remplir le titre de l'\\xe9lection\"}));}else if(election.list===\"\"){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez choisir une liste\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newElectionItem={type:\"election\",id:uniqueId,...election};setSession(prev=>({...prev,items:[...prev.items,newElectionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"election\",...election};return state;});}setElection(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonElectionSeance(Component){return props=>{const[electionState,setElectionState]=electionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setElectionState(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------RESOLUTION----------------------------------------\nexport function titleResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleTitleChange=value=>{setResolution(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:resolution.title,onChange:value=>handleTitleChange(value)});};}export function responsesResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleInputChangeCallback=(newInputs,answerTypeCallback)=>{const newResponses=newInputs;setResolution(prev=>({...prev,responses:newResponses,answerTypeResponses:answerTypeCallback}));};return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:(inputs,answerTypeCallback)=>handleInputChangeCallback(inputs,answerTypeCallback),answerResponses:resolution.answerTypeResponses,onEditValues:resolution.responses});};}export function scrutintResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();useEffect(()=>{if(resolution.scrutin==\"\"){setResolution(prev=>({...prev,scrutin:props.options[0]}));}},[]);const handleOnChange=(index,label)=>{setResolution(prev=>({...prev,scrutin:label}));};const initialValue=props.options.findIndex(option=>option===resolution.scrutin);return /*#__PURE__*/_jsx(Component,{...props,value:initialValue+1,onChange:(index,label)=>handleOnChange(index,label)});};}export function anonymousResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleToggle=()=>{setResolution(prev=>({...prev,anonymous:!prev.anonymous}));};const checkboxProps={isChecked:resolution.anonymous,onToggle:()=>{handleToggle();}};return /*#__PURE__*/_jsx(Component,{...props,...checkboxProps});};}export function validateButtonResolutionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[resolution,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=resolution.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez remplir le titre!\"}));}else if(resolution.responses.length===1&&resolution.responses[0]===\"\"||resolution.responses.length===0){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez ajouter une r\\xe9ponse valide!\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newResolutionItem={type:\"resolution\",id:uniqueId,...resolution};setSession(prev=>({...prev,items:[...prev.items,newResolutionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"resolution\",...resolution};return state;});}setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonResotutioSeance(Component){return props=>{const[resolutionState,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-------------------------------------------UTILS-----------------\nexport function snakbarre(Component){return props=>{const[state,setState]=errorStore();if(state.error){setTimeout(()=>{setState(prevState=>({...prevState,error:false}));},3e3);return /*#__PURE__*/_jsx(Component,{...props,message:state.errorMessage});}return;};}\nexport const __FramerMetadata__ = {\"exports\":{\"convocationDateSeance\":{\"type\":\"reactHoc\",\"name\":\"convocationDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"secretarySeance\":{\"type\":\"reactHoc\",\"name\":\"secretarySeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonResotutioSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonResotutioSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"snakbarre\":{\"type\":\"reactHoc\",\"name\":\"snakbarre\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrutintResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"scrutintResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"anonymousResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"anonymousResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"listSelectElection\":{\"type\":\"reactHoc\",\"name\":\"listSelectElection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"candidatElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"candidatElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleSeance\":{\"type\":\"reactHoc\",\"name\":\"titleSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"responsesResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"responsesResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionDateSeance\":{\"type\":\"reactHoc\",\"name\":\"sessionDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CreateSeance.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{useState,useEffect}from\"react\";import{sessionStore}from\"https://framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/gE5Hgh8tdRIGMPiuVcm8/CreateSeance.js\";import{editStore,globalStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{getAllDocument}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{compareNames}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";export const participantsStore=createStore({participants:[],deletedParticipants:[],lists:[],users:[],selectedList:\"\",selectListIndex:1,search:\"\",president:null});// ✅ Identifiant unique pour vérifier qu'on a bien une seule instance\nexport const PARTICIPANTS_STORE_ID=\"STORE_\"+Math.random().toString(36).substring(2,8);console.log(\"📦 participantsStore cr\\xe9\\xe9 avec ID:\",PARTICIPANTS_STORE_ID);const proxyStore=createStore({userGivingProxy:{},userReceivingProxy:{}});export function withDifferentLists(Component){return props=>{const[participants,setParticipants]=participantsStore();const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const[users,setUsers]=useState([]);useEffect(()=>{getAllDocument(\"users\").then(async users=>{const lists=[];const usersParticipants=[];users.forEach(user=>{// Assuming \"lists\" is the property containing the array in each user\nconst userLists=user.lists||[];lists.push(...userLists);const{docId,code,idSession,...userWithoutId}=user;usersParticipants.push({...userWithoutId,userId:docId,missing:true,proxyFrom:{},proxyTo:{}});});// Use Set to ensure unique elements\nconst uniqueLists=[\"Choisir une liste...\",...new Set(lists)];setUsers(usersParticipants);setParticipants(prev=>({...prev,lists:uniqueLists,users:usersParticipants}));});},[edit.onEditParticipants]);const handleOnChange=(index,label)=>{if(index!=0){setParticipants(state=>({...state,selectedList:label,selectListIndex:index+1,participants:users.reduce((acc,user,index)=>{if(user.lists?.includes(label)){acc.push(user);}return acc;},[]).sort(compareNames)}));setEdit(state=>({...state,onEditParticipants:true}));}};if(edit.onEditSession&&edit.onEditParticipants&&session.selectedList!=\"\"){return /*#__PURE__*/_jsx(\"span\",{style:{color:\"black\",fontSize:16,fontWeight:\"bold\"},children:participants.selectedList});}else{return /*#__PURE__*/_jsx(Component,{...props,options:participants.lists,onChange:(index,label)=>handleOnChange(index,label),value:participants.selectListIndex,disabled:edit.onEditParticipants&&edit.onEditSession});}};}export function withReinitList(Component){return props=>{const[participants,setParticipants]=participantsStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";const handleOnClick=()=>{if(isCurrentAdminSession){return;}const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer cette liste de participant ?\");if(isConfirmed){setEdit(state=>({...state,onEditParticipants:false}));setParticipants(state=>({...state,participants:[],deletedParticipants:[],selectListIndex:1,president:null}));}};return /*#__PURE__*/_jsx(Component,{...props,onClick:()=>handleOnClick(),color:isCurrentAdminSession?\"grey\":\"\",disabled:!edit.onEditParticipants});};}export function withFormParticipants(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[session,setSession]=sessionStore();const[participantList,setParticipantList]=useState([]);const[isDeleted,setIsDeleted]=useState(false);const[isDisabled,setIsDisabled]=useState(false);const[substituteDisabled,setSubstituteDisabled]=useState(false);const[selectedSubstituteId,setSelectedSubstituteId]=useState(null);const giveVoteOrigin=props.giveVote;const url=globalStore(state=>state.url);const[substituteIds,setSubstituteIds]=useState([]);const isCurrentAdminSession=url===\"/admin/sessions/current/\";// ✅ LOG IDENTITÉ DU STORE\nconsole.log(\"🔄 withFormParticipants - STORE_ID:\",PARTICIPANTS_STORE_ID,\"lists.length:\",participants.lists.length);useEffect(()=>{if(session.participants.length>0){setParticipants(state=>{const newState={...state};newState.participants=session.participants;newState.selectedList=session.selectedList;newState.president=session.president;if(session.selectedList&&state.users.length>0){newState.deletedParticipants=state.users.reduce((acc,user,index)=>{if(user.lists?.includes(participants.selectedList)&&session.participants.find(participant=>participant.userId==user.userId)===undefined){acc.push(user);}return acc;},[]);}return{...newState};});}},[participants.users]);useEffect(()=>{const substitutes=participants.participants.filter(p=>p.isSubstituted).map(p=>p.id);setSubstituteIds(substitutes);},[participants.participants]);useEffect(()=>{const sortedParticipants=participants.participants.sort(compareNames);setParticipantList(sortedParticipants);setSession(state=>({...state,participants:sortedParticipants,president:participants.president}));if(isDeleted){setIsDeleted(false);}},[participants.participants,participants.president]);useEffect(()=>{if(participants.selectedList!==\"\"){setSession(state=>({...state,selectedList:participants.selectedList}));}},[participants.selectedList]);const handleGiveVote=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;setProxy(state=>({...state,userReceivingProxy:participantWithoutProxy}));giveVoteOrigin();};const handleChangeMissing=participantId=>{setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);// Inverser le statut missing du participant sélectionné\nnewState.participants[indexParticipant].missing=!newState.participants[indexParticipant].missing;// Vérifier si le participant est le représentant de quelqu'un d'autre\nnewState.participants.forEach((participant,index)=>{if(participant.proxyTo?.id===participantId){// Si le représentant est absent, mettre à jour le statut missing du représenté\nnewState.participants[index].missing=newState.participants[indexParticipant].missing;}});return newState;});};const handleDeleteUser=async participantId=>{/*  if (isCurrentAdminSession) {\n                return\n            }*/const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer ce participant de la s\\xe9ance ?\");if(isConfirmed){setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);const proxyToId=newState.participants[indexParticipant].proxyTo?.id;const indexProxyTo=newState.participants.findIndex(participant=>participant.id===proxyToId);const proxyFromId=newState.participants[indexParticipant].proxyFrom?.id;const indexProxyFrom=newState.participants.findIndex(participant=>participant.id===proxyFromId);// si proxyTo enelver le proxyFrom de l'autre\nif(indexProxyTo!==-1){newState.participants[indexProxyTo].proxyFrom={};}// si proxyFrom enlever le proxYTo de l'autre\nif(indexProxyFrom!==-1){newState.participants[indexProxyFrom].proxyTo={};}const deletedParticipant=newState.participants.splice(indexParticipant,1);newState.deletedParticipants=[...newState.deletedParticipants,deletedParticipant[0]];setIsDeleted(true);return newState;});}};const handlePresidentSeance=participantId=>{setParticipants(state=>{const isAlreadyPresident=state.president===participantId;return{...state,president:isAlreadyPresident?null:participantId};});};// Assurez-vous que cela s'exécute lorsque 'participants' change\n/* useEffect(() => {\n            const participant = participants.participants.find(\n                (p) => p.id === participantId\n            )\n            if (participant.isSubstituted === true) {\n                setSelectedSubstituteId(participantId)\n            }\n        }, [participants.participants])*/const handleSubstitute=participantId=>{setParticipants(prevParticipants=>{const updatedParticipants=prevParticipants.participants.map(p=>{if(p.id===participantId){// Mettre à jour isSubstituted pour le participant ciblé\nreturn{...p,proxyTo:{},proxyFrom:{},isSubstituted:!p.isSubstituted};}else if(p.proxyTo?.id===participantId||p.proxyFrom?.id===participantId){// Retirer le pouvoir donné ou reçu par le participant\nreturn{...p,proxyTo:{},proxyFrom:{}};}return p;});// Mettre à jour l'état global des participants\nreturn{...prevParticipants,participants:updatedParticipants};});// Mettre à jour l'ensemble des substituts\nsetSubstituteIds(prevIds=>{const isCurrentlySubstituted=prevIds.includes(participantId);if(isCurrentlySubstituted){// Retirer l'ID du participant de la liste s'il est déjà un substitut\nreturn prevIds.filter(id=>id!==participantId);}else{// Ajouter l'ID du participant à la liste s'il n'est pas encore un substitut\nreturn[...prevIds,participantId];}});// Mettre à jour l'état de la session si nécessaire\nsetSession(state=>({...state,participants:participants.participants}));};return /*#__PURE__*/_jsx(Component,{...props,participants:participantList,//selectedParticipant={participants.selectedParticipant}\ngiveVote:participant=>handleGiveVote(participant),changeMissing:participantId=>handleChangeMissing(participantId),deleteUser:participantId=>handleDeleteUser(participantId),presidentSeance:participantId=>handlePresidentSeance(participantId),president:participants.president,participantSubstitute:participantId=>handleSubstitute(participantId),substituteId:substituteIds,deleteDisabled:isDisabled});};}export function inputSearch(Component){return props=>{const[participants,setParticipants]=participantsStore();const handleOnChange=value=>{setParticipants(state=>({...state,search:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:participants.search,onChange:value=>handleOnChange(value)});};}export function searchWithFilter(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[participantsDisplayed,setParticipantsDisplayed]=useState([]);useEffect(()=>{setParticipants(prevState=>({...prevState,search:\"\"}));},[]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Si le receveur a déjà un pouvoir reçu, on pré-sélectionne le donneur\nif(participantReceivingProxy?.proxyFrom?.id){setProxy(state=>({...state,userGivingProxy:participantReceivingProxy.proxyFrom}));}},[proxy.userReceivingProxy?.id]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Calcul des participants déjà impliqués dans un pouvoir\nconst participantsThatAlreadyGaveVote=participants.participants.reduce((acc,participant)=>{if(participant.proxyFrom?.id){const giver=participants.participants.find(p=>p.id===participant.proxyFrom.id);if(giver)acc.push(giver);}return acc;},[]);const participantsThatAlreadyReceivedVote=participants.participants.filter(p=>p.proxyFrom?.id);const uniqueGivers=[...new Set(participantsThatAlreadyGaveVote)];const uniqueReceivers=[...new Set(participantsThatAlreadyReceivedVote)];// Filtrage principal\nconst participantsFirstFilter=participants.participants.filter(participant=>{// Cas 1 : pas de receveur sélectionné → on affiche tous les non-substitués\nif(!participantReceivingProxy){return!participant.isSubstituted;}// Cas 2 : le participant est l'actuel donneur du receveur → on le garde\nif(participant.id===participantReceivingProxy.proxyFrom?.id){return true;}// Cas 3 : filtre standard\nreturn participant.id!==receiverId&&!uniqueGivers.includes(participant)&&!uniqueReceivers.includes(participant)&&!participant.isSubstituted;});// Application du filtre de recherche\nif(participants.search){const searchTerm=participants.search.toLowerCase();const filtered=participantsFirstFilter.filter(participant=>{const nameMatch=participant.name?.toLowerCase().includes(searchTerm);const firstNameMatch=participant.firstName?.toLowerCase().includes(searchTerm);return nameMatch||firstNameMatch;});setParticipantsDisplayed(filtered);}else{setParticipantsDisplayed(participantsFirstFilter);}},[participants.search,participants.participants,proxy.userReceivingProxy?.id]);const handleClick=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;if(proxy.userGivingProxy?.id===participant.id){setProxy(state=>({...state,userGivingProxy:{}}));}else{setProxy(state=>({...state,userGivingProxy:participantWithoutProxy}));}};return /*#__PURE__*/_jsx(Component,{...props,participants:participantsDisplayed,click:participant=>handleClick(participant),selectedId:proxy.userGivingProxy?.id});};}export function withGiveVote(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const validateOrigin=props.valider;const cancelOrigin=props.annuler;const handleValidate=()=>{if(proxy.userReceivingProxy.id){const indexOfReceiver=participants.participants.findIndex(participant=>participant.id===proxy.userReceivingProxy.id);const previousGiverId=participants.participants[indexOfReceiver].proxyFrom?.id;if(previousGiverId){const indexPreviousGiver=participants.participants.findIndex(participant=>participant.id===previousGiverId);if(indexPreviousGiver!==-1){setParticipants(state=>{const newState={...state};newState.participants[indexPreviousGiver].proxyTo=null;return newState;});}}if(proxy.userGivingProxy.id){const indexOfGiver=participants.participants.findIndex(participant=>participant.id===proxy.userGivingProxy.id);setParticipants(state=>{const newState={...state};newState.participants[indexOfReceiver].proxyFrom=proxy.userGivingProxy;newState.participants[indexOfGiver].proxyTo=proxy.userReceivingProxy;newState.participants[indexOfGiver].missing=false;return newState;});}else{setParticipants(state=>{const newState={...state};const previousGiver=newState.participants[indexOfReceiver].proxyFrom;const indexPreviousGiver=newState.participants.findIndex(participant=>participant.id===previousGiver.id);if(indexPreviousGiver!==-1){newState.participants[indexPreviousGiver].proxyTo={};newState.participants[indexPreviousGiver].missing=true;}newState.participants[indexOfReceiver].proxyFrom={};return newState;});}}setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));console.log(\"valideeee\",participants);validateOrigin();};const handleCancel=()=>{setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));cancelOrigin();};return /*#__PURE__*/_jsx(Component,{...props,valider:()=>handleValidate(),annuler:()=>handleCancel()});};}export function withAddParticipant(Component){return props=>{const[participants,setParticipants]=participantsStore();const session=globalStore(state=>state.session);const[list,setList]=useState([\"Choisir un participant...\"]);const[value,setValue]=useState(1);const[updateKey,setUpdateKey]=useState(0);const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";useEffect(()=>{setList(()=>{const participantsList=[\"Choisir un participant...\"];participantsList.push(...participants.deletedParticipants.reduce((acc,participant)=>{acc.push(`${participant.name} ${participant.firstName}`);return acc;},[]));return participantsList;});},[participants.deletedParticipants]);const handleOnChange=(index,label)=>{setValue(1);if(index!==0){setParticipants(state=>{const newState={...state};const deletedParticipants=[...newState.deletedParticipants];const newParticipant=deletedParticipants.splice(index-1,1);newState.deletedParticipants=deletedParticipants;newState.participants=[...newState.participants,newParticipant[0]];return newState;});}};// Effect to reset the value when needed\nuseEffect(()=>{setValue(1);setUpdateKey(prevKey=>prevKey+1)// Incrémente le key pour forcer la mise à jour\n;},[list]);return /*#__PURE__*/_createElement(Component,{...props,key:updateKey,value:value,options:list,onChange:(index,label)=>handleOnChange(index,label)});};}\nexport const __FramerMetadata__ = {\"exports\":{\"participantsStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAddParticipant\":{\"type\":\"reactHoc\",\"name\":\"withAddParticipant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withReinitList\":{\"type\":\"reactHoc\",\"name\":\"withReinitList\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFormParticipants\":{\"type\":\"reactHoc\",\"name\":\"withFormParticipants\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDifferentLists\":{\"type\":\"reactHoc\",\"name\":\"withDifferentLists\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGiveVote\":{\"type\":\"reactHoc\",\"name\":\"withGiveVote\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"PARTICIPANTS_STORE_ID\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"searchWithFilter\":{\"type\":\"reactHoc\",\"name\":\"searchWithFilter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"inputSearch\":{\"type\":\"reactHoc\",\"name\":\"inputSearch\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ParticipantSeance.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{generateUniqueId}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{globalStore,editStore,errorStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createDocument,setCollectionAndDocumentToDocument,editSession,getLastIdDocument,updateChampInDocument,getValueInChamp}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{participantsStore}from\"https://framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/eUVraZycpfEYGFXK6Q4T/ParticipantSeance.js\";export const sessionStore=createStore({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,chorum:false,orderItems:[],items:[],selectedList:\"\",participants:[]});export const electionDefault={title:\"\",list:\"\",candidats:[],anonymous:true,round:1};export const electionStore=createStore(electionDefault);export const resolutionDefault={title:\"\",anonymous:false,responses:[],scrutin:\"\",answerTypeResponses:\"\"};export const resolutionStore=createStore(resolutionDefault);export function secretarySeance(Component){return props=>{const[state,setState]=sessionStore();const[participants,setParticipants]=participantsStore();const onChangeInput=value=>{setState(prev=>({...prev,secretary:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.secretary||\"\",onChange:value=>onChangeInput(value)});};}export function titleSeance(Component){return props=>{const[state,setState]=sessionStore();const onChangeInput=value=>{setState(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.title||\"\",onChange:value=>onChangeInput(value)});};}export function sessionDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,sessionDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.sessionDate,onDateChange:handleDateChange,onEditCalendar:state.sessionDate});};}export function convocationDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,convocationDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.convocationDate,onDateChange:handleDateChange,onEditCalendar:state.convocationDate});};}export function validateButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[participantsStoreState,setParticipantsStoreState]=participantsStore()// ✅ Accès direct au store des participants\n;const[messageState,setMessageState]=errorStore();const setSessionGlobal=globalStore(state=>state.setSession);const sessionGlobal=globalStore(state=>state.session);const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);const[isSubmitted,setIsSubmitted]=useState(false);const[edit,setEdit]=editStore();const handleTap=async()=>{// ✅ session contient les bonnes données (vérifié via les logs)\nconsole.log(\"🔎 handleTap - \\xe9tat au clic Valider :\",{\"participantsStore.participants.length\":participantsStoreState.participants.length,\"session.participants.length\":session.participants?.length??0,\"session.selectedList\":session.selectedList});const areRequiredFieldsFilled=session.title&&session.sessionDate&&session.convocationDate;const hasItems=session.items.length>0;const hasParticipants=session.participants.length>0// ✅ session\n;if(!areRequiredFieldsFilled){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Tous les champs obligatoires doivent \\xeatre remplis.\"}));return;}if(!hasItems){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Au moins un item doit \\xeatre ajout\\xe9.\"}));return;}if(!hasParticipants){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Une liste de participants doit \\xeatre s\\xe9lectionn\\xe9e.\"}));return;}const sessionDate=new Date(session.sessionDate);const convocationDate=new Date(session.convocationDate);if(sessionDate<=convocationDate){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"La date de la s\\xe9ance doit \\xeatre post\\xe9rieure \\xe0 la date de convocation.\"}));return;}const{items,participants,...stateWithoutCollections}=session;if(!edit.onEditSession&&!isSubmitted){// ... (tout le code de création inchangé, tel qu'il était à l'origine)\nsetIsSubmitted(true);const id=await getLastIdDocument(\"sessions\");if(id){setSessionGlobal(session);const subCollectionItems=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"items\",session.items);const subCollectionParticipants=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"participants\",session.participants);if(Array.isArray(subCollectionItems)){const orderItems=subCollectionItems;const dataToSend={...stateWithoutCollections,orderItems,chorum:false,docId:(id+1).toString(),id:(id+1).toString()};const response=await createDocument(\"sessions\",dataToSend,(id+1).toString());if(response.success){console.info(response.message);window.location.href=\"/admin/sessions/\";}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",response.error);setIsSubmitted(false);}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\");}}}else{/**\n                 * EDIT EXISTING SESSION\n                 */if(!isSubmitted){setIsSubmitted(true);const{currentItemId,...sessionWithoutCurrentItemId}=session;// ✅ LOG DEBUG - vérification que les pouvoirs sont bien présents\nconsole.log(\"📤 Envoi \\xe0 editSession :\",{idSession:edit.idSession,participantsAvecPouvoirs:sessionWithoutCurrentItemId.participants?.map(p=>({id:p.id,name:p.name,proxyFrom:p.proxyFrom,proxyTo:p.proxyTo}))});const editResponse=await editSession(`sessions`,edit.idSession,sessionWithoutCurrentItemId);setSessionGlobal(editResponse.updatedSession);if(editResponse.success){console.info(editResponse.message);setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(session.startedSession){// ... (reste du code identique à l'original)\nconst newParticipantIds=session.participants.reduce((acc,participant)=>{if(participant.missing===false){if(participant.isSubstituted&&participant.substitute){acc.push(participant.substitute.id);}else if(Object.keys(participant.proxyTo||{}).length===0){acc.push(participant.id);}}return acc;},[]);const participantsWithSubstitute=session.participants.reduce((acc,participant)=>{if(participant.substitute){acc.push(participant.substitute.id);acc.push(participant.id);}else{acc.push(participant.id);}return acc;},[]);const updatedSession={...session,participantIds:newParticipantIds};const deletedParticipantIds=participantsStoreState.deletedParticipants.map(participant=>participant.id);let allParticipantIdsToUpdate=[...participantsWithSubstitute,...deletedParticipantIds];let filteredParticipantIds=[];for(const participantId of allParticipantIdsToUpdate){const matches=await getValueInChamp(\"users\",participantId.toString(),session.docId);if(matches){filteredParticipantIds.push(participantId);}}allParticipantIdsToUpdate=filteredParticipantIds;for(const participantId of allParticipantIdsToUpdate){await updateChampInDocument(\"users\",{idSession:\"\"},participantId.toString());}for(const participantId of newParticipantIds){await updateChampInDocument(\"users\",{idSession:updatedSession.id},participantId.toString());}setSessionGlobal(updatedSession);}if(url==\"/admin/sessions/current/\"){setIsSubmitted(false);window.location.href=\"/admin/sessions/current/\";}else{setIsSubmitted(false);window.location.href=\"/admin/sessions/\";}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",editResponse.error);}}}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);// const tapOrigin = props.tap\nconst handleTap=()=>{setSession(prev=>({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,items:[]}));if(edit.onEditSession){setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(url==\"/admin/sessions/current/\"){//    setUrl(\"\")\nwindow.location.href=\"/admin/sessions/current/\";return;}else{window.location.href=\"/admin/sessions/\";}}window.location.href=\"/admin/sessions/\";// tapOrigin()\n};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------------------ELECTION-------------------------------------------------------\nexport function titleElectionSeance(Component){return props=>{const[election,setElection]=electionStore();// ✅ LOG DEBUG\nconsole.log(\"📝 titleElectionSeance render, election.title =\",election.title,\"full election =\",election);const handleTitleChange=value=>{setElection(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:election.title,onChange:value=>handleTitleChange(value)});};}export function listSelectElection(Component){return props=>{const[options,setOptions]=useState([]);const[election,setElection]=electionStore();const[participants,setParticipants]=participantsStore();// ✅ LOG DEBUG\nconsole.log(\"📋 listSelectElection render\",{\"options.length\":options.length,options:options,\"participants.lists\":participants.lists,\"election.list\":election.list,\"computed value\":options.findIndex(o=>o===election.list)+1});useEffect(()=>{setOptions(participants.lists);},[participants.lists]);useEffect(()=>{if(!election.list){setElection(state=>({...state,list:participants.selectedList}));}},[participants.selectedList]);const handleOnChange=(index,label)=>{if(index!=0){setElection(state=>({...state,list:label}));}};return /*#__PURE__*/_jsx(Component,{...props,options:options,onChange:(index,label)=>handleOnChange(index,label),value:options.findIndex(option=>option===election.list)+1});};}export function candidatElectionSeance(Component){return props=>{const[election,setElection]=electionStore();const[participants,setParticipant]=participantsStore();const[extractedNames,setExtractedNames]=useState([]);const[filteredElectionCandidates,setFilteredElectionCandidates]=useState([]);const handleInputChangeCallback=newInputs=>{const newCandidats=newInputs.filter(input=>input.trim()!==\"\");setElection(prev=>({...prev,candidats:newCandidats}));};// const extractedNames = participant.participants.map(\n//     (p) => `${p.firstName} ${p.name}`\n// )\nuseEffect(()=>{if(participants.users.length>0&&election.list!==\"\"){setExtractedNames(participants.users.filter(user=>user.lists?.includes(election.list)).map(p=>`${p.firstName} ${p.name}`));}},[election.list]);return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:inputs=>handleInputChangeCallback(inputs),onEditValues:extractedNames,initialSelectedCandidates:election.candidats});};}/*export function scrutintElectionSeance(Component): ComponentType {\n    return (props) => {\n        const [election, setElection] = electionStore()\n\n        useEffect(() => {\n            if (election.scrutin == \"\") {\n                setElection((prev) => ({\n                    ...prev,\n                    scrutin: props.options[0],\n                }))\n            }\n        }, [])\n\n        const handleOnChange = (index, label) => {\n            setElection((prev) => ({\n                ...prev,\n                scrutin: label,\n            }))\n        }\n        console.log(\"props.opt[0]\", props.options[0])\n        const initialValue = props.options.findIndex(\n            (option) => option === election.scrutin\n        )\n        return (\n            <Component\n                {...props}\n                value={initialValue + 1}\n                onChange={(index, label) => handleOnChange(index, label)}\n            />\n        )\n    }\n}*/export function validateButtonElectionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[election,setElection]=electionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=election.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez bien remplir le titre de l'\\xe9lection\"}));}else if(election.list===\"\"){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez choisir une liste\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newElectionItem={type:\"election\",id:uniqueId,...election};setSession(prev=>({...prev,items:[...prev.items,newElectionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"election\",...election};return state;});}setElection(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonElectionSeance(Component){return props=>{const[electionState,setElectionState]=electionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setElectionState(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------RESOLUTION----------------------------------------\nexport function titleResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleTitleChange=value=>{setResolution(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:resolution.title,onChange:value=>handleTitleChange(value)});};}export function responsesResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleInputChangeCallback=(newInputs,answerTypeCallback)=>{const newResponses=newInputs;setResolution(prev=>({...prev,responses:newResponses,answerTypeResponses:answerTypeCallback}));};return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:(inputs,answerTypeCallback)=>handleInputChangeCallback(inputs,answerTypeCallback),answerResponses:resolution.answerTypeResponses,onEditValues:resolution.responses});};}export function scrutintResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();useEffect(()=>{if(resolution.scrutin==\"\"){setResolution(prev=>({...prev,scrutin:props.options[0]}));}},[]);const handleOnChange=(index,label)=>{setResolution(prev=>({...prev,scrutin:label}));};const initialValue=props.options.findIndex(option=>option===resolution.scrutin);return /*#__PURE__*/_jsx(Component,{...props,value:initialValue+1,onChange:(index,label)=>handleOnChange(index,label)});};}export function anonymousResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleToggle=()=>{setResolution(prev=>({...prev,anonymous:!prev.anonymous}));};const checkboxProps={isChecked:resolution.anonymous,onToggle:()=>{handleToggle();}};return /*#__PURE__*/_jsx(Component,{...props,...checkboxProps});};}export function validateButtonResolutionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[resolution,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=resolution.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez remplir le titre!\"}));}else if(resolution.responses.length===1&&resolution.responses[0]===\"\"||resolution.responses.length===0){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez ajouter une r\\xe9ponse valide!\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newResolutionItem={type:\"resolution\",id:uniqueId,...resolution};setSession(prev=>({...prev,items:[...prev.items,newResolutionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"resolution\",...resolution};return state;});}setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonResotutioSeance(Component){return props=>{const[resolutionState,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-------------------------------------------UTILS-----------------\nexport function snakbarre(Component){return props=>{const[state,setState]=errorStore();if(state.error){setTimeout(()=>{setState(prevState=>({...prevState,error:false}));},3e3);return /*#__PURE__*/_jsx(Component,{...props,message:state.errorMessage});}return;};}\nexport const __FramerMetadata__ = {\"exports\":{\"validateButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionDateSeance\":{\"type\":\"reactHoc\",\"name\":\"sessionDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"anonymousResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"anonymousResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"convocationDateSeance\":{\"type\":\"reactHoc\",\"name\":\"convocationDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"listSelectElection\":{\"type\":\"reactHoc\",\"name\":\"listSelectElection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrutintResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"scrutintResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonResotutioSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonResotutioSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"candidatElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"candidatElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleSeance\":{\"type\":\"reactHoc\",\"name\":\"titleSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"snakbarre\":{\"type\":\"reactHoc\",\"name\":\"snakbarre\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"responsesResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"responsesResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"secretarySeance\":{\"type\":\"reactHoc\",\"name\":\"secretarySeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CreateSeance.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{useState,useEffect}from\"react\";import{sessionStore}from\"https://framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/35YaN4IIcGHsodnEwLpn/CreateSeance.js\";import{editStore,globalStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{getAllDocument}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{compareNames}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";export const participantsStore=createStore({participants:[],deletedParticipants:[],lists:[],users:[],selectedList:\"\",selectListIndex:1,search:\"\",president:null});// ✅ Identifiant unique pour vérifier qu'on a bien une seule instance\nexport const PARTICIPANTS_STORE_ID=\"STORE_\"+Math.random().toString(36).substring(2,8);console.log(\"📦 participantsStore cr\\xe9\\xe9 avec ID:\",PARTICIPANTS_STORE_ID);const proxyStore=createStore({userGivingProxy:{},userReceivingProxy:{}});export function withDifferentLists(Component){return props=>{const[participants,setParticipants]=participantsStore();const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const[users,setUsers]=useState([]);useEffect(()=>{getAllDocument(\"users\").then(async users=>{const lists=[];const usersParticipants=[];users.forEach(user=>{// Assuming \"lists\" is the property containing the array in each user\nconst userLists=user.lists||[];lists.push(...userLists);const{docId,code,idSession,...userWithoutId}=user;usersParticipants.push({...userWithoutId,userId:docId,missing:true,proxyFrom:{},proxyTo:{}});});// Use Set to ensure unique elements\nconst uniqueLists=[\"Choisir une liste...\",...new Set(lists)];setUsers(usersParticipants);setParticipants(prev=>({...prev,lists:uniqueLists,users:usersParticipants}));});},[edit.onEditParticipants]);const handleOnChange=(index,label)=>{if(index!=0){setParticipants(state=>({...state,selectedList:label,selectListIndex:index+1,participants:users.reduce((acc,user,index)=>{if(user.lists?.includes(label)){acc.push(user);}return acc;},[]).sort(compareNames)}));setEdit(state=>({...state,onEditParticipants:true}));}};if(edit.onEditSession&&edit.onEditParticipants&&session.selectedList!=\"\"){return /*#__PURE__*/_jsx(\"span\",{style:{color:\"black\",fontSize:16,fontWeight:\"bold\"},children:participants.selectedList});}else{return /*#__PURE__*/_jsx(Component,{...props,options:participants.lists,onChange:(index,label)=>handleOnChange(index,label),value:participants.selectListIndex,disabled:edit.onEditParticipants&&edit.onEditSession});}};}export function withReinitList(Component){return props=>{const[participants,setParticipants]=participantsStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";const handleOnClick=()=>{if(isCurrentAdminSession){return;}const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer cette liste de participant ?\");if(isConfirmed){setEdit(state=>({...state,onEditParticipants:false}));setParticipants(state=>({...state,participants:[],deletedParticipants:[],selectListIndex:1,president:null}));}};return /*#__PURE__*/_jsx(Component,{...props,onClick:()=>handleOnClick(),color:isCurrentAdminSession?\"grey\":\"\",disabled:!edit.onEditParticipants});};}export function withFormParticipants(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[session,setSession]=sessionStore();const[participantList,setParticipantList]=useState([]);const[isDeleted,setIsDeleted]=useState(false);const[isDisabled,setIsDisabled]=useState(false);const[substituteDisabled,setSubstituteDisabled]=useState(false);const[selectedSubstituteId,setSelectedSubstituteId]=useState(null);const giveVoteOrigin=props.giveVote;const url=globalStore(state=>state.url);const[substituteIds,setSubstituteIds]=useState([]);const isCurrentAdminSession=url===\"/admin/sessions/current/\";// ✅ LOG IDENTITÉ DU STORE\nconsole.log(\"🔄 withFormParticipants - STORE_ID:\",PARTICIPANTS_STORE_ID,\"lists.length:\",participants.lists.length);useEffect(()=>{if(session.participants.length>0){setParticipants(state=>{const newState={...state};newState.participants=session.participants;newState.selectedList=session.selectedList;newState.president=session.president;if(session.selectedList&&state.users.length>0){newState.deletedParticipants=state.users.reduce((acc,user,index)=>{if(user.lists?.includes(participants.selectedList)&&session.participants.find(participant=>participant.userId==user.userId)===undefined){acc.push(user);}return acc;},[]);}return{...newState};});}},[participants.users]);useEffect(()=>{const substitutes=participants.participants.filter(p=>p.isSubstituted).map(p=>p.id);setSubstituteIds(substitutes);},[participants.participants]);useEffect(()=>{const sortedParticipants=participants.participants.sort(compareNames);setParticipantList(sortedParticipants);setSession(state=>({...state,participants:sortedParticipants,president:participants.president}));if(isDeleted){setIsDeleted(false);}},[participants.participants,participants.president]);useEffect(()=>{if(participants.selectedList!==\"\"){setSession(state=>({...state,selectedList:participants.selectedList}));}},[participants.selectedList]);const handleGiveVote=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;setProxy(state=>({...state,userReceivingProxy:participantWithoutProxy}));giveVoteOrigin();};const handleChangeMissing=participantId=>{setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);// Inverser le statut missing du participant sélectionné\nnewState.participants[indexParticipant].missing=!newState.participants[indexParticipant].missing;// Vérifier si le participant est le représentant de quelqu'un d'autre\nnewState.participants.forEach((participant,index)=>{if(participant.proxyTo?.id===participantId){// Si le représentant est absent, mettre à jour le statut missing du représenté\nnewState.participants[index].missing=newState.participants[indexParticipant].missing;}});return newState;});};const handleDeleteUser=async participantId=>{/*  if (isCurrentAdminSession) {\n                return\n            }*/const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer ce participant de la s\\xe9ance ?\");if(isConfirmed){setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);const proxyToId=newState.participants[indexParticipant].proxyTo?.id;const indexProxyTo=newState.participants.findIndex(participant=>participant.id===proxyToId);const proxyFromId=newState.participants[indexParticipant].proxyFrom?.id;const indexProxyFrom=newState.participants.findIndex(participant=>participant.id===proxyFromId);// si proxyTo enelver le proxyFrom de l'autre\nif(indexProxyTo!==-1){newState.participants[indexProxyTo].proxyFrom={};}// si proxyFrom enlever le proxYTo de l'autre\nif(indexProxyFrom!==-1){newState.participants[indexProxyFrom].proxyTo={};}const deletedParticipant=newState.participants.splice(indexParticipant,1);newState.deletedParticipants=[...newState.deletedParticipants,deletedParticipant[0]];setIsDeleted(true);return newState;});}};const handlePresidentSeance=participantId=>{setParticipants(state=>{const isAlreadyPresident=state.president===participantId;return{...state,president:isAlreadyPresident?null:participantId};});};// Assurez-vous que cela s'exécute lorsque 'participants' change\n/* useEffect(() => {\n            const participant = participants.participants.find(\n                (p) => p.id === participantId\n            )\n            if (participant.isSubstituted === true) {\n                setSelectedSubstituteId(participantId)\n            }\n        }, [participants.participants])*/const handleSubstitute=participantId=>{setParticipants(prevParticipants=>{const updatedParticipants=prevParticipants.participants.map(p=>{if(p.id===participantId){// Mettre à jour isSubstituted pour le participant ciblé\nreturn{...p,proxyTo:{},proxyFrom:{},isSubstituted:!p.isSubstituted};}else if(p.proxyTo?.id===participantId||p.proxyFrom?.id===participantId){// Retirer le pouvoir donné ou reçu par le participant\nreturn{...p,proxyTo:{},proxyFrom:{}};}return p;});// Mettre à jour l'état global des participants\nreturn{...prevParticipants,participants:updatedParticipants};});// Mettre à jour l'ensemble des substituts\nsetSubstituteIds(prevIds=>{const isCurrentlySubstituted=prevIds.includes(participantId);if(isCurrentlySubstituted){// Retirer l'ID du participant de la liste s'il est déjà un substitut\nreturn prevIds.filter(id=>id!==participantId);}else{// Ajouter l'ID du participant à la liste s'il n'est pas encore un substitut\nreturn[...prevIds,participantId];}});// Mettre à jour l'état de la session si nécessaire\nsetSession(state=>({...state,participants:participants.participants}));};return /*#__PURE__*/_jsx(Component,{...props,participants:participantList,//selectedParticipant={participants.selectedParticipant}\ngiveVote:participant=>handleGiveVote(participant),changeMissing:participantId=>handleChangeMissing(participantId),deleteUser:participantId=>handleDeleteUser(participantId),presidentSeance:participantId=>handlePresidentSeance(participantId),president:participants.president,participantSubstitute:participantId=>handleSubstitute(participantId),substituteId:substituteIds,deleteDisabled:isDisabled});};}export function inputSearch(Component){return props=>{const[participants,setParticipants]=participantsStore();const handleOnChange=value=>{setParticipants(state=>({...state,search:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:participants.search,onChange:value=>handleOnChange(value)});};}export function searchWithFilter(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[participantsDisplayed,setParticipantsDisplayed]=useState([]);useEffect(()=>{setParticipants(prevState=>({...prevState,search:\"\"}));},[]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Si le receveur a déjà un pouvoir reçu, on pré-sélectionne le donneur\nif(participantReceivingProxy?.proxyFrom?.id){setProxy(state=>({...state,userGivingProxy:participantReceivingProxy.proxyFrom}));}},[proxy.userReceivingProxy?.id]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Calcul des participants déjà impliqués dans un pouvoir\nconst participantsThatAlreadyGaveVote=participants.participants.reduce((acc,participant)=>{if(participant.proxyFrom?.id){const giver=participants.participants.find(p=>p.id===participant.proxyFrom.id);if(giver)acc.push(giver);}return acc;},[]);const participantsThatAlreadyReceivedVote=participants.participants.filter(p=>p.proxyFrom?.id);const uniqueGivers=[...new Set(participantsThatAlreadyGaveVote)];const uniqueReceivers=[...new Set(participantsThatAlreadyReceivedVote)];// Filtrage principal\nconst participantsFirstFilter=participants.participants.filter(participant=>{// Cas 1 : pas de receveur sélectionné → on affiche tous les non-substitués\nif(!participantReceivingProxy){return!participant.isSubstituted;}// Cas 2 : le participant est l'actuel donneur du receveur → on le garde\nif(participant.id===participantReceivingProxy.proxyFrom?.id){return true;}// Cas 3 : filtre standard\nreturn participant.id!==receiverId&&!uniqueGivers.includes(participant)&&!uniqueReceivers.includes(participant)&&!participant.isSubstituted;});// Application du filtre de recherche\nif(participants.search){const searchTerm=participants.search.toLowerCase();const filtered=participantsFirstFilter.filter(participant=>{const nameMatch=participant.name?.toLowerCase().includes(searchTerm);const firstNameMatch=participant.firstName?.toLowerCase().includes(searchTerm);return nameMatch||firstNameMatch;});setParticipantsDisplayed(filtered);}else{setParticipantsDisplayed(participantsFirstFilter);}},[participants.search,participants.participants,proxy.userReceivingProxy?.id]);const handleClick=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;if(proxy.userGivingProxy?.id===participant.id){setProxy(state=>({...state,userGivingProxy:{}}));}else{setProxy(state=>({...state,userGivingProxy:participantWithoutProxy}));}};return /*#__PURE__*/_jsx(Component,{...props,participants:participantsDisplayed,click:participant=>handleClick(participant),selectedId:proxy.userGivingProxy?.id});};}export function withGiveVote(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const validateOrigin=props.valider;const cancelOrigin=props.annuler;const handleValidate=()=>{if(proxy.userReceivingProxy.id){const indexOfReceiver=participants.participants.findIndex(participant=>participant.id===proxy.userReceivingProxy.id);const previousGiverId=participants.participants[indexOfReceiver].proxyFrom?.id;if(previousGiverId){const indexPreviousGiver=participants.participants.findIndex(participant=>participant.id===previousGiverId);if(indexPreviousGiver!==-1){setParticipants(state=>{const newState={...state};newState.participants[indexPreviousGiver].proxyTo=null;return newState;});}}if(proxy.userGivingProxy.id){const indexOfGiver=participants.participants.findIndex(participant=>participant.id===proxy.userGivingProxy.id);setParticipants(state=>{const newState={...state};newState.participants[indexOfReceiver].proxyFrom=proxy.userGivingProxy;newState.participants[indexOfGiver].proxyTo=proxy.userReceivingProxy;newState.participants[indexOfGiver].missing=false;return newState;});}else{setParticipants(state=>{const newState={...state};const previousGiver=newState.participants[indexOfReceiver].proxyFrom;const indexPreviousGiver=newState.participants.findIndex(participant=>participant.id===previousGiver.id);if(indexPreviousGiver!==-1){newState.participants[indexPreviousGiver].proxyTo={};newState.participants[indexPreviousGiver].missing=true;}newState.participants[indexOfReceiver].proxyFrom={};return newState;});}}setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));console.log(\"valideeee\",participants);validateOrigin();};const handleCancel=()=>{setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));cancelOrigin();};return /*#__PURE__*/_jsx(Component,{...props,valider:()=>handleValidate(),annuler:()=>handleCancel()});};}export function withAddParticipant(Component){return props=>{const[participants,setParticipants]=participantsStore();const session=globalStore(state=>state.session);const[list,setList]=useState([\"Choisir un participant...\"]);const[value,setValue]=useState(1);const[updateKey,setUpdateKey]=useState(0);const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";useEffect(()=>{setList(()=>{const participantsList=[\"Choisir un participant...\"];participantsList.push(...participants.deletedParticipants.reduce((acc,participant)=>{acc.push(`${participant.name} ${participant.firstName}`);return acc;},[]));return participantsList;});},[participants.deletedParticipants]);const handleOnChange=(index,label)=>{setValue(1);if(index!==0){setParticipants(state=>{const newState={...state};const deletedParticipants=[...newState.deletedParticipants];const newParticipant=deletedParticipants.splice(index-1,1);newState.deletedParticipants=deletedParticipants;newState.participants=[...newState.participants,newParticipant[0]];return newState;});}};// Effect to reset the value when needed\nuseEffect(()=>{setValue(1);setUpdateKey(prevKey=>prevKey+1)// Incrémente le key pour forcer la mise à jour\n;},[list]);return /*#__PURE__*/_createElement(Component,{...props,key:updateKey,value:value,options:list,onChange:(index,label)=>handleOnChange(index,label)});};}\nexport const __FramerMetadata__ = {\"exports\":{\"participantsStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAddParticipant\":{\"type\":\"reactHoc\",\"name\":\"withAddParticipant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withReinitList\":{\"type\":\"reactHoc\",\"name\":\"withReinitList\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFormParticipants\":{\"type\":\"reactHoc\",\"name\":\"withFormParticipants\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDifferentLists\":{\"type\":\"reactHoc\",\"name\":\"withDifferentLists\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGiveVote\":{\"type\":\"reactHoc\",\"name\":\"withGiveVote\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"PARTICIPANTS_STORE_ID\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"searchWithFilter\":{\"type\":\"reactHoc\",\"name\":\"searchWithFilter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"inputSearch\":{\"type\":\"reactHoc\",\"name\":\"inputSearch\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{generateUniqueId}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{globalStore,editStore,errorStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createDocument,setCollectionAndDocumentToDocument,editSession,getLastIdDocument,updateChampInDocument,getValueInChamp}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{participantsStore,PARTICIPANTS_STORE_ID}from\"https://framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/q8Wm02tTr4j0xzkjGsvg/ParticipantSeance.js\";export const sessionStore=createStore({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,chorum:false,orderItems:[],items:[],selectedList:\"\",participants:[]});export const electionDefault={title:\"\",list:\"\",candidats:[],anonymous:true,round:1};export const electionStore=createStore(electionDefault);export const resolutionDefault={title:\"\",anonymous:false,responses:[],scrutin:\"\",answerTypeResponses:\"\"};export const resolutionStore=createStore(resolutionDefault);export function secretarySeance(Component){return props=>{const[state,setState]=sessionStore();const[participants,setParticipants]=participantsStore();const onChangeInput=value=>{setState(prev=>({...prev,secretary:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.secretary||\"\",onChange:value=>onChangeInput(value)});};}export function titleSeance(Component){return props=>{const[state,setState]=sessionStore();const onChangeInput=value=>{setState(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.title||\"\",onChange:value=>onChangeInput(value)});};}export function sessionDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,sessionDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.sessionDate,onDateChange:handleDateChange,onEditCalendar:state.sessionDate});};}export function convocationDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,convocationDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.convocationDate,onDateChange:handleDateChange,onEditCalendar:state.convocationDate});};}export function validateButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[participantsStoreState,setParticipantsStoreState]=participantsStore()// ✅ Accès direct au store des participants\n;const[messageState,setMessageState]=errorStore();const setSessionGlobal=globalStore(state=>state.setSession);const sessionGlobal=globalStore(state=>state.session);const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);const[isSubmitted,setIsSubmitted]=useState(false);const[edit,setEdit]=editStore();const handleTap=async()=>{// ✅ session contient les bonnes données (vérifié via les logs)\nconsole.log(\"🔎 handleTap - \\xe9tat au clic Valider :\",{\"participantsStore.participants.length\":participantsStoreState.participants.length,\"session.participants.length\":session.participants?.length??0,\"session.selectedList\":session.selectedList});const areRequiredFieldsFilled=session.title&&session.sessionDate&&session.convocationDate;const hasItems=session.items.length>0;const hasParticipants=session.participants.length>0// ✅ session\n;if(!areRequiredFieldsFilled){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Tous les champs obligatoires doivent \\xeatre remplis.\"}));return;}if(!hasItems){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Au moins un item doit \\xeatre ajout\\xe9.\"}));return;}if(!hasParticipants){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Une liste de participants doit \\xeatre s\\xe9lectionn\\xe9e.\"}));return;}const sessionDate=new Date(session.sessionDate);const convocationDate=new Date(session.convocationDate);if(sessionDate<=convocationDate){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"La date de la s\\xe9ance doit \\xeatre post\\xe9rieure \\xe0 la date de convocation.\"}));return;}const{items,participants,...stateWithoutCollections}=session;if(!edit.onEditSession&&!isSubmitted){// ... (tout le code de création inchangé, tel qu'il était à l'origine)\nsetIsSubmitted(true);const id=await getLastIdDocument(\"sessions\");if(id){setSessionGlobal(session);const subCollectionItems=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"items\",session.items);const subCollectionParticipants=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"participants\",session.participants);if(Array.isArray(subCollectionItems)){const orderItems=subCollectionItems;const dataToSend={...stateWithoutCollections,orderItems,chorum:false,docId:(id+1).toString(),id:(id+1).toString()};const response=await createDocument(\"sessions\",dataToSend,(id+1).toString());if(response.success){console.info(response.message);window.location.href=\"/admin/sessions/\";}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",response.error);setIsSubmitted(false);}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\");}}}else{/**\n                 * EDIT EXISTING SESSION\n                 */if(!isSubmitted){setIsSubmitted(true);const{currentItemId,...sessionWithoutCurrentItemId}=session;// ✅ LOG DEBUG - vérification que les pouvoirs sont bien présents\nconsole.log(\"📤 Envoi \\xe0 editSession :\",{idSession:edit.idSession,participantsAvecPouvoirs:sessionWithoutCurrentItemId.participants?.map(p=>({id:p.id,name:p.name,proxyFrom:p.proxyFrom,proxyTo:p.proxyTo}))});const editResponse=await editSession(`sessions`,edit.idSession,sessionWithoutCurrentItemId);setSessionGlobal(editResponse.updatedSession);if(editResponse.success){console.info(editResponse.message);setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(session.startedSession){// ... (reste du code identique à l'original)\nconst newParticipantIds=session.participants.reduce((acc,participant)=>{if(participant.missing===false){if(participant.isSubstituted&&participant.substitute){acc.push(participant.substitute.id);}else if(Object.keys(participant.proxyTo||{}).length===0){acc.push(participant.id);}}return acc;},[]);const participantsWithSubstitute=session.participants.reduce((acc,participant)=>{if(participant.substitute){acc.push(participant.substitute.id);acc.push(participant.id);}else{acc.push(participant.id);}return acc;},[]);const updatedSession={...session,participantIds:newParticipantIds};const deletedParticipantIds=participantsStoreState.deletedParticipants.map(participant=>participant.id);let allParticipantIdsToUpdate=[...participantsWithSubstitute,...deletedParticipantIds];let filteredParticipantIds=[];for(const participantId of allParticipantIdsToUpdate){const matches=await getValueInChamp(\"users\",participantId.toString(),session.docId);if(matches){filteredParticipantIds.push(participantId);}}allParticipantIdsToUpdate=filteredParticipantIds;for(const participantId of allParticipantIdsToUpdate){await updateChampInDocument(\"users\",{idSession:\"\"},participantId.toString());}for(const participantId of newParticipantIds){await updateChampInDocument(\"users\",{idSession:updatedSession.id},participantId.toString());}setSessionGlobal(updatedSession);}if(url==\"/admin/sessions/current/\"){setIsSubmitted(false);window.location.href=\"/admin/sessions/current/\";}else{setIsSubmitted(false);window.location.href=\"/admin/sessions/\";}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",editResponse.error);}}}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);// const tapOrigin = props.tap\nconst handleTap=()=>{setSession(prev=>({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,items:[]}));if(edit.onEditSession){setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(url==\"/admin/sessions/current/\"){//    setUrl(\"\")\nwindow.location.href=\"/admin/sessions/current/\";return;}else{window.location.href=\"/admin/sessions/\";}}window.location.href=\"/admin/sessions/\";// tapOrigin()\n};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------------------ELECTION-------------------------------------------------------\nexport function titleElectionSeance(Component){return props=>{const[election,setElection]=electionStore();// ✅ LOG DEBUG\nconsole.log(\"📝 titleElectionSeance render, election.title =\",election.title,\"full election =\",election);const handleTitleChange=value=>{setElection(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:election.title,onChange:value=>handleTitleChange(value)});};}export function listSelectElection(Component){return props=>{const[options,setOptions]=useState([]);const[election,setElection]=electionStore();const[participants,setParticipants]=participantsStore();// ✅ LOG IDENTITÉ DU STORE\nconsole.log(\"📋 listSelectElection - STORE_ID:\",PARTICIPANTS_STORE_ID,\"lists.length:\",participants.lists.length);// ✅ LOG DEBUG\nconsole.log(\"📋 listSelectElection render\",{\"options.length\":options.length,options:options,\"participants.lists\":participants.lists,\"election.list\":election.list,\"computed value\":options.findIndex(o=>o===election.list)+1});useEffect(()=>{setOptions(participants.lists);},[participants.lists]);useEffect(()=>{if(!election.list){setElection(state=>({...state,list:participants.selectedList}));}},[participants.selectedList]);const handleOnChange=(index,label)=>{if(index!=0){setElection(state=>({...state,list:label}));}};return /*#__PURE__*/_jsx(Component,{...props,options:options,onChange:(index,label)=>handleOnChange(index,label),value:options.findIndex(option=>option===election.list)+1});};}export function candidatElectionSeance(Component){return props=>{const[election,setElection]=electionStore();const[participants,setParticipant]=participantsStore();const[extractedNames,setExtractedNames]=useState([]);const[filteredElectionCandidates,setFilteredElectionCandidates]=useState([]);const handleInputChangeCallback=newInputs=>{const newCandidats=newInputs.filter(input=>input.trim()!==\"\");setElection(prev=>({...prev,candidats:newCandidats}));};// const extractedNames = participant.participants.map(\n//     (p) => `${p.firstName} ${p.name}`\n// )\nuseEffect(()=>{if(participants.users.length>0&&election.list!==\"\"){setExtractedNames(participants.users.filter(user=>user.lists?.includes(election.list)).map(p=>`${p.firstName} ${p.name}`));}},[election.list]);return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:inputs=>handleInputChangeCallback(inputs),onEditValues:extractedNames,initialSelectedCandidates:election.candidats});};}/*export function scrutintElectionSeance(Component): ComponentType {\n    return (props) => {\n        const [election, setElection] = electionStore()\n\n        useEffect(() => {\n            if (election.scrutin == \"\") {\n                setElection((prev) => ({\n                    ...prev,\n                    scrutin: props.options[0],\n                }))\n            }\n        }, [])\n\n        const handleOnChange = (index, label) => {\n            setElection((prev) => ({\n                ...prev,\n                scrutin: label,\n            }))\n        }\n        console.log(\"props.opt[0]\", props.options[0])\n        const initialValue = props.options.findIndex(\n            (option) => option === election.scrutin\n        )\n        return (\n            <Component\n                {...props}\n                value={initialValue + 1}\n                onChange={(index, label) => handleOnChange(index, label)}\n            />\n        )\n    }\n}*/export function validateButtonElectionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[election,setElection]=electionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=election.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez bien remplir le titre de l'\\xe9lection\"}));}else if(election.list===\"\"){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez choisir une liste\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newElectionItem={type:\"election\",id:uniqueId,...election};setSession(prev=>({...prev,items:[...prev.items,newElectionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"election\",...election};return state;});}setElection(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonElectionSeance(Component){return props=>{const[electionState,setElectionState]=electionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setElectionState(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------RESOLUTION----------------------------------------\nexport function titleResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleTitleChange=value=>{setResolution(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:resolution.title,onChange:value=>handleTitleChange(value)});};}export function responsesResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleInputChangeCallback=(newInputs,answerTypeCallback)=>{const newResponses=newInputs;setResolution(prev=>({...prev,responses:newResponses,answerTypeResponses:answerTypeCallback}));};return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:(inputs,answerTypeCallback)=>handleInputChangeCallback(inputs,answerTypeCallback),answerResponses:resolution.answerTypeResponses,onEditValues:resolution.responses});};}export function scrutintResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();useEffect(()=>{if(resolution.scrutin==\"\"){setResolution(prev=>({...prev,scrutin:props.options[0]}));}},[]);const handleOnChange=(index,label)=>{setResolution(prev=>({...prev,scrutin:label}));};const initialValue=props.options.findIndex(option=>option===resolution.scrutin);return /*#__PURE__*/_jsx(Component,{...props,value:initialValue+1,onChange:(index,label)=>handleOnChange(index,label)});};}export function anonymousResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleToggle=()=>{setResolution(prev=>({...prev,anonymous:!prev.anonymous}));};const checkboxProps={isChecked:resolution.anonymous,onToggle:()=>{handleToggle();}};return /*#__PURE__*/_jsx(Component,{...props,...checkboxProps});};}export function validateButtonResolutionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[resolution,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=resolution.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez remplir le titre!\"}));}else if(resolution.responses.length===1&&resolution.responses[0]===\"\"||resolution.responses.length===0){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez ajouter une r\\xe9ponse valide!\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newResolutionItem={type:\"resolution\",id:uniqueId,...resolution};setSession(prev=>({...prev,items:[...prev.items,newResolutionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"resolution\",...resolution};return state;});}setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonResotutioSeance(Component){return props=>{const[resolutionState,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-------------------------------------------UTILS-----------------\nexport function snakbarre(Component){return props=>{const[state,setState]=errorStore();if(state.error){setTimeout(()=>{setState(prevState=>({...prevState,error:false}));},3e3);return /*#__PURE__*/_jsx(Component,{...props,message:state.errorMessage});}return;};}\nexport const __FramerMetadata__ = {\"exports\":{\"secretarySeance\":{\"type\":\"reactHoc\",\"name\":\"secretarySeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionDateSeance\":{\"type\":\"reactHoc\",\"name\":\"sessionDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"candidatElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"candidatElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"responsesResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"responsesResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"listSelectElection\":{\"type\":\"reactHoc\",\"name\":\"listSelectElection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"convocationDateSeance\":{\"type\":\"reactHoc\",\"name\":\"convocationDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonResotutioSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonResotutioSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"snakbarre\":{\"type\":\"reactHoc\",\"name\":\"snakbarre\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrutintResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"scrutintResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"anonymousResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"anonymousResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleSeance\":{\"type\":\"reactHoc\",\"name\":\"titleSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CreateSeance.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{useState,useEffect}from\"react\";import{sessionStore}from\"https://framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/be381nkNUE4HePOwNcPO/CreateSeance.js\";import{editStore,globalStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{getAllDocument}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{compareNames}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";export const participantsStore=createStore({participants:[],deletedParticipants:[],lists:[],users:[],selectedList:\"\",selectListIndex:1,search:\"\",president:null});// ✅ Identifiant unique pour vérifier qu'on a bien une seule instance\nexport const PARTICIPANTS_STORE_ID=\"STORE_\"+Math.random().toString(36).substring(2,8);console.log(\"📦 participantsStore cr\\xe9\\xe9 avec ID:\",PARTICIPANTS_STORE_ID);const proxyStore=createStore({userGivingProxy:{},userReceivingProxy:{}});export function withDifferentLists(Component){return props=>{const[participants,setParticipants]=participantsStore();const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const[users,setUsers]=useState([]);useEffect(()=>{getAllDocument(\"users\").then(async users=>{const lists=[];const usersParticipants=[];users.forEach(user=>{// Assuming \"lists\" is the property containing the array in each user\nconst userLists=user.lists||[];lists.push(...userLists);const{docId,code,idSession,...userWithoutId}=user;usersParticipants.push({...userWithoutId,userId:docId,missing:true,proxyFrom:{},proxyTo:{}});});// Use Set to ensure unique elements\nconst uniqueLists=[\"Choisir une liste...\",...new Set(lists)];setUsers(usersParticipants);setParticipants(prev=>({...prev,lists:uniqueLists,users:usersParticipants}));});},[edit.onEditParticipants]);const handleOnChange=(index,label)=>{if(index!=0){setParticipants(state=>({...state,selectedList:label,selectListIndex:index+1,participants:users.reduce((acc,user,index)=>{if(user.lists?.includes(label)){acc.push(user);}return acc;},[]).sort(compareNames)}));setEdit(state=>({...state,onEditParticipants:true}));}};if(edit.onEditSession&&edit.onEditParticipants&&session.selectedList!=\"\"){return /*#__PURE__*/_jsx(\"span\",{style:{color:\"black\",fontSize:16,fontWeight:\"bold\"},children:participants.selectedList});}else{return /*#__PURE__*/_jsx(Component,{...props,options:participants.lists,onChange:(index,label)=>handleOnChange(index,label),value:participants.selectListIndex,disabled:edit.onEditParticipants&&edit.onEditSession});}};}export function withReinitList(Component){return props=>{const[participants,setParticipants]=participantsStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";const handleOnClick=()=>{if(isCurrentAdminSession){return;}const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer cette liste de participant ?\");if(isConfirmed){setEdit(state=>({...state,onEditParticipants:false}));setParticipants(state=>({...state,participants:[],deletedParticipants:[],selectListIndex:1,president:null}));}};return /*#__PURE__*/_jsx(Component,{...props,onClick:()=>handleOnClick(),color:isCurrentAdminSession?\"grey\":\"\",disabled:!edit.onEditParticipants});};}export function withFormParticipants(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[session,setSession]=sessionStore();const[participantList,setParticipantList]=useState([]);const[isDeleted,setIsDeleted]=useState(false);const[isDisabled,setIsDisabled]=useState(false);const[substituteDisabled,setSubstituteDisabled]=useState(false);const[selectedSubstituteId,setSelectedSubstituteId]=useState(null);const giveVoteOrigin=props.giveVote;const url=globalStore(state=>state.url);const[substituteIds,setSubstituteIds]=useState([]);const isCurrentAdminSession=url===\"/admin/sessions/current/\";// ✅ LOG IDENTITÉ DU STORE\nconsole.log(\"🔄 withFormParticipants - STORE_ID:\",PARTICIPANTS_STORE_ID,\"lists.length:\",participants.lists.length);useEffect(()=>{if(session.participants.length>0){setParticipants(state=>{const newState={...state};newState.participants=session.participants;newState.selectedList=session.selectedList;newState.president=session.president;if(session.selectedList&&state.users.length>0){newState.deletedParticipants=state.users.reduce((acc,user,index)=>{if(user.lists?.includes(participants.selectedList)&&session.participants.find(participant=>participant.userId==user.userId)===undefined){acc.push(user);}return acc;},[]);}return{...newState};});}},[participants.users]);useEffect(()=>{const substitutes=participants.participants.filter(p=>p.isSubstituted).map(p=>p.id);setSubstituteIds(substitutes);},[participants.participants]);useEffect(()=>{const sortedParticipants=participants.participants.sort(compareNames);setParticipantList(sortedParticipants);setSession(state=>({...state,participants:sortedParticipants,president:participants.president}));if(isDeleted){setIsDeleted(false);}},[participants.participants,participants.president]);useEffect(()=>{if(participants.selectedList!==\"\"){setSession(state=>({...state,selectedList:participants.selectedList}));}},[participants.selectedList]);const handleGiveVote=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;setProxy(state=>({...state,userReceivingProxy:participantWithoutProxy}));giveVoteOrigin();};const handleChangeMissing=participantId=>{setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);// Inverser le statut missing du participant sélectionné\nnewState.participants[indexParticipant].missing=!newState.participants[indexParticipant].missing;// Vérifier si le participant est le représentant de quelqu'un d'autre\nnewState.participants.forEach((participant,index)=>{if(participant.proxyTo?.id===participantId){// Si le représentant est absent, mettre à jour le statut missing du représenté\nnewState.participants[index].missing=newState.participants[indexParticipant].missing;}});return newState;});};const handleDeleteUser=async participantId=>{/*  if (isCurrentAdminSession) {\n                return\n            }*/const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer ce participant de la s\\xe9ance ?\");if(isConfirmed){setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);const proxyToId=newState.participants[indexParticipant].proxyTo?.id;const indexProxyTo=newState.participants.findIndex(participant=>participant.id===proxyToId);const proxyFromId=newState.participants[indexParticipant].proxyFrom?.id;const indexProxyFrom=newState.participants.findIndex(participant=>participant.id===proxyFromId);// si proxyTo enelver le proxyFrom de l'autre\nif(indexProxyTo!==-1){newState.participants[indexProxyTo].proxyFrom={};}// si proxyFrom enlever le proxYTo de l'autre\nif(indexProxyFrom!==-1){newState.participants[indexProxyFrom].proxyTo={};}const deletedParticipant=newState.participants.splice(indexParticipant,1);newState.deletedParticipants=[...newState.deletedParticipants,deletedParticipant[0]];setIsDeleted(true);return newState;});}};const handlePresidentSeance=participantId=>{setParticipants(state=>{const isAlreadyPresident=state.president===participantId;return{...state,president:isAlreadyPresident?null:participantId};});};// Assurez-vous que cela s'exécute lorsque 'participants' change\n/* useEffect(() => {\n            const participant = participants.participants.find(\n                (p) => p.id === participantId\n            )\n            if (participant.isSubstituted === true) {\n                setSelectedSubstituteId(participantId)\n            }\n        }, [participants.participants])*/const handleSubstitute=participantId=>{setParticipants(prevParticipants=>{const updatedParticipants=prevParticipants.participants.map(p=>{if(p.id===participantId){// Mettre à jour isSubstituted pour le participant ciblé\nreturn{...p,proxyTo:{},proxyFrom:{},isSubstituted:!p.isSubstituted};}else if(p.proxyTo?.id===participantId||p.proxyFrom?.id===participantId){// Retirer le pouvoir donné ou reçu par le participant\nreturn{...p,proxyTo:{},proxyFrom:{}};}return p;});// Mettre à jour l'état global des participants\nreturn{...prevParticipants,participants:updatedParticipants};});// Mettre à jour l'ensemble des substituts\nsetSubstituteIds(prevIds=>{const isCurrentlySubstituted=prevIds.includes(participantId);if(isCurrentlySubstituted){// Retirer l'ID du participant de la liste s'il est déjà un substitut\nreturn prevIds.filter(id=>id!==participantId);}else{// Ajouter l'ID du participant à la liste s'il n'est pas encore un substitut\nreturn[...prevIds,participantId];}});// Mettre à jour l'état de la session si nécessaire\nsetSession(state=>({...state,participants:participants.participants}));};return /*#__PURE__*/_jsx(Component,{...props,participants:participantList,//selectedParticipant={participants.selectedParticipant}\ngiveVote:participant=>handleGiveVote(participant),changeMissing:participantId=>handleChangeMissing(participantId),deleteUser:participantId=>handleDeleteUser(participantId),presidentSeance:participantId=>handlePresidentSeance(participantId),president:participants.president,participantSubstitute:participantId=>handleSubstitute(participantId),substituteId:substituteIds,deleteDisabled:isDisabled});};}export function inputSearch(Component){return props=>{const[participants,setParticipants]=participantsStore();const handleOnChange=value=>{setParticipants(state=>({...state,search:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:participants.search,onChange:value=>handleOnChange(value)});};}export function searchWithFilter(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[participantsDisplayed,setParticipantsDisplayed]=useState([]);useEffect(()=>{setParticipants(prevState=>({...prevState,search:\"\"}));},[]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Si le receveur a déjà un pouvoir reçu, on pré-sélectionne le donneur\nif(participantReceivingProxy?.proxyFrom?.id){setProxy(state=>({...state,userGivingProxy:participantReceivingProxy.proxyFrom}));}},[proxy.userReceivingProxy?.id]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Calcul des participants déjà impliqués dans un pouvoir\nconst participantsThatAlreadyGaveVote=participants.participants.reduce((acc,participant)=>{if(participant.proxyFrom?.id){const giver=participants.participants.find(p=>p.id===participant.proxyFrom.id);if(giver)acc.push(giver);}return acc;},[]);const participantsThatAlreadyReceivedVote=participants.participants.filter(p=>p.proxyFrom?.id);const uniqueGivers=[...new Set(participantsThatAlreadyGaveVote)];const uniqueReceivers=[...new Set(participantsThatAlreadyReceivedVote)];// Filtrage principal\nconst participantsFirstFilter=participants.participants.filter(participant=>{// Cas 1 : pas de receveur sélectionné → on affiche tous les non-substitués\nif(!participantReceivingProxy){return!participant.isSubstituted;}// Cas 2 : le participant est l'actuel donneur du receveur → on le garde\nif(participant.id===participantReceivingProxy.proxyFrom?.id){return true;}// Cas 3 : filtre standard\nreturn participant.id!==receiverId&&!uniqueGivers.includes(participant)&&!uniqueReceivers.includes(participant)&&!participant.isSubstituted;});// Application du filtre de recherche\nif(participants.search){const searchTerm=participants.search.toLowerCase();const filtered=participantsFirstFilter.filter(participant=>{const nameMatch=participant.name?.toLowerCase().includes(searchTerm);const firstNameMatch=participant.firstName?.toLowerCase().includes(searchTerm);return nameMatch||firstNameMatch;});setParticipantsDisplayed(filtered);}else{setParticipantsDisplayed(participantsFirstFilter);}},[participants.search,participants.participants,proxy.userReceivingProxy?.id]);const handleClick=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;if(proxy.userGivingProxy?.id===participant.id){setProxy(state=>({...state,userGivingProxy:{}}));}else{setProxy(state=>({...state,userGivingProxy:participantWithoutProxy}));}};return /*#__PURE__*/_jsx(Component,{...props,participants:participantsDisplayed,click:participant=>handleClick(participant),selectedId:proxy.userGivingProxy?.id});};}export function withGiveVote(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const validateOrigin=props.valider;const cancelOrigin=props.annuler;const handleValidate=()=>{if(proxy.userReceivingProxy.id){const indexOfReceiver=participants.participants.findIndex(participant=>participant.id===proxy.userReceivingProxy.id);const previousGiverId=participants.participants[indexOfReceiver].proxyFrom?.id;if(previousGiverId){const indexPreviousGiver=participants.participants.findIndex(participant=>participant.id===previousGiverId);if(indexPreviousGiver!==-1){setParticipants(state=>{const newState={...state};newState.participants[indexPreviousGiver].proxyTo=null;return newState;});}}if(proxy.userGivingProxy.id){const indexOfGiver=participants.participants.findIndex(participant=>participant.id===proxy.userGivingProxy.id);setParticipants(state=>{const newState={...state};newState.participants[indexOfReceiver].proxyFrom=proxy.userGivingProxy;newState.participants[indexOfGiver].proxyTo=proxy.userReceivingProxy;newState.participants[indexOfGiver].missing=false;return newState;});}else{setParticipants(state=>{const newState={...state};const previousGiver=newState.participants[indexOfReceiver].proxyFrom;const indexPreviousGiver=newState.participants.findIndex(participant=>participant.id===previousGiver.id);if(indexPreviousGiver!==-1){newState.participants[indexPreviousGiver].proxyTo={};newState.participants[indexPreviousGiver].missing=true;}newState.participants[indexOfReceiver].proxyFrom={};return newState;});}}setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));console.log(\"valideeee\",participants);validateOrigin();};const handleCancel=()=>{setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));cancelOrigin();};return /*#__PURE__*/_jsx(Component,{...props,valider:()=>handleValidate(),annuler:()=>handleCancel()});};}export function withAddParticipant(Component){return props=>{const[participants,setParticipants]=participantsStore();const session=globalStore(state=>state.session);const[list,setList]=useState([\"Choisir un participant...\"]);const[value,setValue]=useState(1);const[updateKey,setUpdateKey]=useState(0);const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";useEffect(()=>{setList(()=>{const participantsList=[\"Choisir un participant...\"];participantsList.push(...participants.deletedParticipants.reduce((acc,participant)=>{acc.push(`${participant.name} ${participant.firstName}`);return acc;},[]));return participantsList;});},[participants.deletedParticipants]);const handleOnChange=(index,label)=>{setValue(1);if(index!==0){setParticipants(state=>{const newState={...state};const deletedParticipants=[...newState.deletedParticipants];const newParticipant=deletedParticipants.splice(index-1,1);newState.deletedParticipants=deletedParticipants;newState.participants=[...newState.participants,newParticipant[0]];return newState;});}};// Effect to reset the value when needed\nuseEffect(()=>{setValue(1);setUpdateKey(prevKey=>prevKey+1)// Incrémente le key pour forcer la mise à jour\n;},[list]);return /*#__PURE__*/_createElement(Component,{...props,key:updateKey,value:value,options:list,onChange:(index,label)=>handleOnChange(index,label)});};}\nexport const __FramerMetadata__ = {\"exports\":{\"participantsStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAddParticipant\":{\"type\":\"reactHoc\",\"name\":\"withAddParticipant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withReinitList\":{\"type\":\"reactHoc\",\"name\":\"withReinitList\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFormParticipants\":{\"type\":\"reactHoc\",\"name\":\"withFormParticipants\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDifferentLists\":{\"type\":\"reactHoc\",\"name\":\"withDifferentLists\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGiveVote\":{\"type\":\"reactHoc\",\"name\":\"withGiveVote\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"PARTICIPANTS_STORE_ID\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"searchWithFilter\":{\"type\":\"reactHoc\",\"name\":\"searchWithFilter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"inputSearch\":{\"type\":\"reactHoc\",\"name\":\"inputSearch\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{generateUniqueId}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{globalStore,editStore,errorStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createDocument,getAllDocument,setCollectionAndDocumentToDocument,editSession,getLastIdDocument,updateChampInDocument,getValueInChamp}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{participantsStore}from\"https://framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/11ChxFnuPG9eoCvnRowH/ParticipantSeance.js\";export const sessionStore=createStore({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,chorum:false,orderItems:[],items:[],selectedList:\"\",participants:[]});export const electionDefault={title:\"\",list:\"\",candidats:[],anonymous:true,round:1};export const electionStore=createStore(electionDefault);export const resolutionDefault={title:\"\",anonymous:false,responses:[],scrutin:\"\",answerTypeResponses:\"\"};export const resolutionStore=createStore(resolutionDefault);export function secretarySeance(Component){return props=>{const[state,setState]=sessionStore();const[participants,setParticipants]=participantsStore();const onChangeInput=value=>{setState(prev=>({...prev,secretary:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.secretary||\"\",onChange:value=>onChangeInput(value)});};}export function titleSeance(Component){return props=>{const[state,setState]=sessionStore();const onChangeInput=value=>{setState(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.title||\"\",onChange:value=>onChangeInput(value)});};}export function sessionDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,sessionDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.sessionDate,onDateChange:handleDateChange,onEditCalendar:state.sessionDate});};}export function convocationDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,convocationDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.convocationDate,onDateChange:handleDateChange,onEditCalendar:state.convocationDate});};}export function validateButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[participantsStoreState,setParticipantsStoreState]=participantsStore()// ✅ Accès direct au store des participants\n;const[messageState,setMessageState]=errorStore();const setSessionGlobal=globalStore(state=>state.setSession);const sessionGlobal=globalStore(state=>state.session);const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);const[isSubmitted,setIsSubmitted]=useState(false);const[edit,setEdit]=editStore();const handleTap=async()=>{// ✅ session contient les bonnes données (vérifié via les logs)\nconsole.log(\"🔎 handleTap - \\xe9tat au clic Valider :\",{\"participantsStore.participants.length\":participantsStoreState.participants.length,\"session.participants.length\":session.participants?.length??0,\"session.selectedList\":session.selectedList});const areRequiredFieldsFilled=session.title&&session.sessionDate&&session.convocationDate;const hasItems=session.items.length>0;const hasParticipants=session.participants.length>0// ✅ session\n;if(!areRequiredFieldsFilled){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Tous les champs obligatoires doivent \\xeatre remplis.\"}));return;}if(!hasItems){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Au moins un item doit \\xeatre ajout\\xe9.\"}));return;}if(!hasParticipants){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Une liste de participants doit \\xeatre s\\xe9lectionn\\xe9e.\"}));return;}const sessionDate=new Date(session.sessionDate);const convocationDate=new Date(session.convocationDate);if(sessionDate<=convocationDate){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"La date de la s\\xe9ance doit \\xeatre post\\xe9rieure \\xe0 la date de convocation.\"}));return;}const{items,participants,...stateWithoutCollections}=session;if(!edit.onEditSession&&!isSubmitted){// ... (tout le code de création inchangé, tel qu'il était à l'origine)\nsetIsSubmitted(true);const id=await getLastIdDocument(\"sessions\");if(id){setSessionGlobal(session);const subCollectionItems=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"items\",session.items);const subCollectionParticipants=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"participants\",session.participants);if(Array.isArray(subCollectionItems)){const orderItems=subCollectionItems;const dataToSend={...stateWithoutCollections,orderItems,chorum:false,docId:(id+1).toString(),id:(id+1).toString()};const response=await createDocument(\"sessions\",dataToSend,(id+1).toString());if(response.success){console.info(response.message);window.location.href=\"/admin/sessions/\";}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",response.error);setIsSubmitted(false);}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\");}}}else{/**\n                 * EDIT EXISTING SESSION\n                 */if(!isSubmitted){setIsSubmitted(true);const{currentItemId,...sessionWithoutCurrentItemId}=session;// ✅ LOG DEBUG - vérification que les pouvoirs sont bien présents\nconsole.log(\"📤 Envoi \\xe0 editSession :\",{idSession:edit.idSession,participantsAvecPouvoirs:sessionWithoutCurrentItemId.participants?.map(p=>({id:p.id,name:p.name,proxyFrom:p.proxyFrom,proxyTo:p.proxyTo}))});const editResponse=await editSession(`sessions`,edit.idSession,sessionWithoutCurrentItemId);setSessionGlobal(editResponse.updatedSession);if(editResponse.success){console.info(editResponse.message);setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(session.startedSession){// ... (reste du code identique à l'original)\nconst newParticipantIds=session.participants.reduce((acc,participant)=>{if(participant.missing===false){if(participant.isSubstituted&&participant.substitute){acc.push(participant.substitute.id);}else if(Object.keys(participant.proxyTo||{}).length===0){acc.push(participant.id);}}return acc;},[]);const participantsWithSubstitute=session.participants.reduce((acc,participant)=>{if(participant.substitute){acc.push(participant.substitute.id);acc.push(participant.id);}else{acc.push(participant.id);}return acc;},[]);const updatedSession={...session,participantIds:newParticipantIds};const deletedParticipantIds=participantsStoreState.deletedParticipants.map(participant=>participant.id);let allParticipantIdsToUpdate=[...participantsWithSubstitute,...deletedParticipantIds];let filteredParticipantIds=[];for(const participantId of allParticipantIdsToUpdate){const matches=await getValueInChamp(\"users\",participantId.toString(),session.docId);if(matches){filteredParticipantIds.push(participantId);}}allParticipantIdsToUpdate=filteredParticipantIds;for(const participantId of allParticipantIdsToUpdate){await updateChampInDocument(\"users\",{idSession:\"\"},participantId.toString());}for(const participantId of newParticipantIds){await updateChampInDocument(\"users\",{idSession:updatedSession.id},participantId.toString());}setSessionGlobal(updatedSession);}if(url==\"/admin/sessions/current/\"){setIsSubmitted(false);window.location.href=\"/admin/sessions/current/\";}else{setIsSubmitted(false);window.location.href=\"/admin/sessions/\";}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",editResponse.error);}}}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);// const tapOrigin = props.tap\nconst handleTap=()=>{setSession(prev=>({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,items:[]}));if(edit.onEditSession){setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(url==\"/admin/sessions/current/\"){//    setUrl(\"\")\nwindow.location.href=\"/admin/sessions/current/\";return;}else{window.location.href=\"/admin/sessions/\";}}window.location.href=\"/admin/sessions/\";// tapOrigin()\n};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------------------ELECTION-------------------------------------------------------\nexport function titleElectionSeance(Component){return props=>{const[election,setElection]=electionStore();// ✅ LOG DEBUG\nconsole.log(\"📝 titleElectionSeance render, election.title =\",election.title,\"full election =\",election);const handleTitleChange=value=>{setElection(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:election.title,onChange:value=>handleTitleChange(value)});};}export function listSelectElection(Component){return props=>{const[options,setOptions]=useState([]);const[election,setElection]=electionStore();const[participants,setParticipants]=participantsStore();useEffect(()=>{// ✅ Si le store local a les listes, on les utilise\nif(participants.lists&&participants.lists.length>0){setOptions(participants.lists);return;}// ✅ Sinon on les charge directement depuis Firestore\nconsole.log(\"📋 listSelectElection - chargement des listes depuis Firestore\");getAllDocument(\"users\").then(users=>{const lists=[];users.forEach(user=>{const userLists=user.lists||[];lists.push(...userLists);});const uniqueLists=[\"Choisir une liste...\",...new Set(lists)];setOptions(uniqueLists);// On met aussi à jour notre instance locale du store\nsetParticipants(prev=>({...prev,lists:uniqueLists}));});},[participants.lists]);useEffect(()=>{if(!election.list&&participants.selectedList){setElection(state=>({...state,list:participants.selectedList}));}},[participants.selectedList]);const handleOnChange=(index,label)=>{if(index!=0){setElection(state=>({...state,list:label}));}};return /*#__PURE__*/_jsx(Component,{...props,options:options,onChange:(index,label)=>handleOnChange(index,label),value:options.findIndex(option=>option===election.list)+1});};}export function candidatElectionSeance(Component){return props=>{const[election,setElection]=electionStore();const[participants,setParticipant]=participantsStore();const[extractedNames,setExtractedNames]=useState([]);const[filteredElectionCandidates,setFilteredElectionCandidates]=useState([]);const handleInputChangeCallback=newInputs=>{const newCandidats=newInputs.filter(input=>input.trim()!==\"\");setElection(prev=>({...prev,candidats:newCandidats}));};// const extractedNames = participant.participants.map(\n//     (p) => `${p.firstName} ${p.name}`\n// )\nuseEffect(()=>{if(participants.users.length>0&&election.list!==\"\"){setExtractedNames(participants.users.filter(user=>user.lists?.includes(election.list)).map(p=>`${p.firstName} ${p.name}`));}},[election.list]);return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:inputs=>handleInputChangeCallback(inputs),onEditValues:extractedNames,initialSelectedCandidates:election.candidats});};}/*export function scrutintElectionSeance(Component): ComponentType {\n    return (props) => {\n        const [election, setElection] = electionStore()\n\n        useEffect(() => {\n            if (election.scrutin == \"\") {\n                setElection((prev) => ({\n                    ...prev,\n                    scrutin: props.options[0],\n                }))\n            }\n        }, [])\n\n        const handleOnChange = (index, label) => {\n            setElection((prev) => ({\n                ...prev,\n                scrutin: label,\n            }))\n        }\n        console.log(\"props.opt[0]\", props.options[0])\n        const initialValue = props.options.findIndex(\n            (option) => option === election.scrutin\n        )\n        return (\n            <Component\n                {...props}\n                value={initialValue + 1}\n                onChange={(index, label) => handleOnChange(index, label)}\n            />\n        )\n    }\n}*/export function validateButtonElectionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[election,setElection]=electionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=election.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez bien remplir le titre de l'\\xe9lection\"}));}else if(election.list===\"\"){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez choisir une liste\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newElectionItem={type:\"election\",id:uniqueId,...election};setSession(prev=>({...prev,items:[...prev.items,newElectionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"election\",...election};return state;});}setElection(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonElectionSeance(Component){return props=>{const[electionState,setElectionState]=electionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setElectionState(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------RESOLUTION----------------------------------------\nexport function titleResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleTitleChange=value=>{setResolution(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:resolution.title,onChange:value=>handleTitleChange(value)});};}export function responsesResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleInputChangeCallback=(newInputs,answerTypeCallback)=>{const newResponses=newInputs;setResolution(prev=>({...prev,responses:newResponses,answerTypeResponses:answerTypeCallback}));};return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:(inputs,answerTypeCallback)=>handleInputChangeCallback(inputs,answerTypeCallback),answerResponses:resolution.answerTypeResponses,onEditValues:resolution.responses});};}export function scrutintResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();useEffect(()=>{if(resolution.scrutin==\"\"){setResolution(prev=>({...prev,scrutin:props.options[0]}));}},[]);const handleOnChange=(index,label)=>{setResolution(prev=>({...prev,scrutin:label}));};const initialValue=props.options.findIndex(option=>option===resolution.scrutin);return /*#__PURE__*/_jsx(Component,{...props,value:initialValue+1,onChange:(index,label)=>handleOnChange(index,label)});};}export function anonymousResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleToggle=()=>{setResolution(prev=>({...prev,anonymous:!prev.anonymous}));};const checkboxProps={isChecked:resolution.anonymous,onToggle:()=>{handleToggle();}};return /*#__PURE__*/_jsx(Component,{...props,...checkboxProps});};}export function validateButtonResolutionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[resolution,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=resolution.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez remplir le titre!\"}));}else if(resolution.responses.length===1&&resolution.responses[0]===\"\"||resolution.responses.length===0){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez ajouter une r\\xe9ponse valide!\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newResolutionItem={type:\"resolution\",id:uniqueId,...resolution};setSession(prev=>({...prev,items:[...prev.items,newResolutionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"resolution\",...resolution};return state;});}setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonResotutioSeance(Component){return props=>{const[resolutionState,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-------------------------------------------UTILS-----------------\nexport function snakbarre(Component){return props=>{const[state,setState]=errorStore();if(state.error){setTimeout(()=>{setState(prevState=>({...prevState,error:false}));},3e3);return /*#__PURE__*/_jsx(Component,{...props,message:state.errorMessage});}return;};}\nexport const __FramerMetadata__ = {\"exports\":{\"cancelButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"snakbarre\":{\"type\":\"reactHoc\",\"name\":\"snakbarre\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"anonymousResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"anonymousResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleSeance\":{\"type\":\"reactHoc\",\"name\":\"titleSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrutintResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"scrutintResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"convocationDateSeance\":{\"type\":\"reactHoc\",\"name\":\"convocationDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"candidatElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"candidatElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"secretarySeance\":{\"type\":\"reactHoc\",\"name\":\"secretarySeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonResotutioSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonResotutioSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionDateSeance\":{\"type\":\"reactHoc\",\"name\":\"sessionDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"responsesResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"responsesResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"listSelectElection\":{\"type\":\"reactHoc\",\"name\":\"listSelectElection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CreateSeance.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{useState,useEffect}from\"react\";import{sessionStore}from\"https://framerusercontent.com/modules/fPmX8pt73d02W1MZkbha/V8mfhTKZHQIcl6T9FFl4/CreateSeance.js\";import{editStore,globalStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{getAllDocument}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{compareNames}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";export const participantsStore=createStore({participants:[],deletedParticipants:[],lists:[],users:[],selectedList:\"\",selectListIndex:1,search:\"\",president:null});// ✅ Identifiant unique pour vérifier qu'on a bien une seule instance\nexport const PARTICIPANTS_STORE_ID=\"STORE_\"+Math.random().toString(36).substring(2,8);console.log(\"📦 participantsStore cr\\xe9\\xe9 avec ID:\",PARTICIPANTS_STORE_ID);const proxyStore=createStore({userGivingProxy:{},userReceivingProxy:{}});export function withDifferentLists(Component){return props=>{const[participants,setParticipants]=participantsStore();const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const[users,setUsers]=useState([]);useEffect(()=>{getAllDocument(\"users\").then(async users=>{const lists=[];const usersParticipants=[];users.forEach(user=>{// Assuming \"lists\" is the property containing the array in each user\nconst userLists=user.lists||[];lists.push(...userLists);const{docId,code,idSession,...userWithoutId}=user;usersParticipants.push({...userWithoutId,userId:docId,missing:true,proxyFrom:{},proxyTo:{}});});// Use Set to ensure unique elements\nconst uniqueLists=[\"Choisir une liste...\",...new Set(lists)];setUsers(usersParticipants);setParticipants(prev=>({...prev,lists:uniqueLists,users:usersParticipants}));});},[edit.onEditParticipants]);const handleOnChange=(index,label)=>{if(index!=0){setParticipants(state=>({...state,selectedList:label,selectListIndex:index+1,participants:users.reduce((acc,user,index)=>{if(user.lists?.includes(label)){acc.push(user);}return acc;},[]).sort(compareNames)}));setEdit(state=>({...state,onEditParticipants:true}));}};if(edit.onEditSession&&edit.onEditParticipants&&session.selectedList!=\"\"){return /*#__PURE__*/_jsx(\"span\",{style:{color:\"black\",fontSize:16,fontWeight:\"bold\"},children:participants.selectedList});}else{return /*#__PURE__*/_jsx(Component,{...props,options:participants.lists,onChange:(index,label)=>handleOnChange(index,label),value:participants.selectListIndex,disabled:edit.onEditParticipants&&edit.onEditSession});}};}export function withReinitList(Component){return props=>{const[participants,setParticipants]=participantsStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";const handleOnClick=()=>{if(isCurrentAdminSession){return;}const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer cette liste de participant ?\");if(isConfirmed){setEdit(state=>({...state,onEditParticipants:false}));setParticipants(state=>({...state,participants:[],deletedParticipants:[],selectListIndex:1,president:null}));}};return /*#__PURE__*/_jsx(Component,{...props,onClick:()=>handleOnClick(),color:isCurrentAdminSession?\"grey\":\"\",disabled:!edit.onEditParticipants});};}export function withFormParticipants(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[session,setSession]=sessionStore();const[participantList,setParticipantList]=useState([]);const[isDeleted,setIsDeleted]=useState(false);const[isDisabled,setIsDisabled]=useState(false);const[substituteDisabled,setSubstituteDisabled]=useState(false);const[selectedSubstituteId,setSelectedSubstituteId]=useState(null);const giveVoteOrigin=props.giveVote;const url=globalStore(state=>state.url);const[substituteIds,setSubstituteIds]=useState([]);const isCurrentAdminSession=url===\"/admin/sessions/current/\";// ✅ LOG IDENTITÉ DU STORE\nconsole.log(\"🔄 withFormParticipants - STORE_ID:\",PARTICIPANTS_STORE_ID,\"lists.length:\",participants.lists.length);useEffect(()=>{if(session.participants.length>0){setParticipants(state=>{const newState={...state};newState.participants=session.participants;newState.selectedList=session.selectedList;newState.president=session.president;if(session.selectedList&&state.users.length>0){newState.deletedParticipants=state.users.reduce((acc,user,index)=>{if(user.lists?.includes(participants.selectedList)&&session.participants.find(participant=>participant.userId==user.userId)===undefined){acc.push(user);}return acc;},[]);}return{...newState};});}},[participants.users]);useEffect(()=>{const substitutes=participants.participants.filter(p=>p.isSubstituted).map(p=>p.id);setSubstituteIds(substitutes);},[participants.participants]);useEffect(()=>{const sortedParticipants=participants.participants.sort(compareNames);setParticipantList(sortedParticipants);setSession(state=>({...state,participants:sortedParticipants,president:participants.president}));if(isDeleted){setIsDeleted(false);}},[participants.participants,participants.president]);useEffect(()=>{if(participants.selectedList!==\"\"){setSession(state=>({...state,selectedList:participants.selectedList}));}},[participants.selectedList]);const handleGiveVote=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;setProxy(state=>({...state,userReceivingProxy:participantWithoutProxy}));giveVoteOrigin();};const handleChangeMissing=participantId=>{setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);// Inverser le statut missing du participant sélectionné\nnewState.participants[indexParticipant].missing=!newState.participants[indexParticipant].missing;// Vérifier si le participant est le représentant de quelqu'un d'autre\nnewState.participants.forEach((participant,index)=>{if(participant.proxyTo?.id===participantId){// Si le représentant est absent, mettre à jour le statut missing du représenté\nnewState.participants[index].missing=newState.participants[indexParticipant].missing;}});return newState;});};const handleDeleteUser=async participantId=>{/*  if (isCurrentAdminSession) {\n                return\n            }*/const isConfirmed=window.confirm(\"\\xcates-vous s\\xfbr de vouloir supprimer ce participant de la s\\xe9ance ?\");if(isConfirmed){setParticipants(state=>{const newState={...state};const indexParticipant=newState.participants.findIndex(participant=>participant.id===participantId);const proxyToId=newState.participants[indexParticipant].proxyTo?.id;const indexProxyTo=newState.participants.findIndex(participant=>participant.id===proxyToId);const proxyFromId=newState.participants[indexParticipant].proxyFrom?.id;const indexProxyFrom=newState.participants.findIndex(participant=>participant.id===proxyFromId);// si proxyTo enelver le proxyFrom de l'autre\nif(indexProxyTo!==-1){newState.participants[indexProxyTo].proxyFrom={};}// si proxyFrom enlever le proxYTo de l'autre\nif(indexProxyFrom!==-1){newState.participants[indexProxyFrom].proxyTo={};}const deletedParticipant=newState.participants.splice(indexParticipant,1);newState.deletedParticipants=[...newState.deletedParticipants,deletedParticipant[0]];setIsDeleted(true);return newState;});}};const handlePresidentSeance=participantId=>{setParticipants(state=>{const isAlreadyPresident=state.president===participantId;return{...state,president:isAlreadyPresident?null:participantId};});};// Assurez-vous que cela s'exécute lorsque 'participants' change\n/* useEffect(() => {\n            const participant = participants.participants.find(\n                (p) => p.id === participantId\n            )\n            if (participant.isSubstituted === true) {\n                setSelectedSubstituteId(participantId)\n            }\n        }, [participants.participants])*/const handleSubstitute=participantId=>{setParticipants(prevParticipants=>{const updatedParticipants=prevParticipants.participants.map(p=>{if(p.id===participantId){// Mettre à jour isSubstituted pour le participant ciblé\nreturn{...p,proxyTo:{},proxyFrom:{},isSubstituted:!p.isSubstituted};}else if(p.proxyTo?.id===participantId||p.proxyFrom?.id===participantId){// Retirer le pouvoir donné ou reçu par le participant\nreturn{...p,proxyTo:{},proxyFrom:{}};}return p;});// Mettre à jour l'état global des participants\nreturn{...prevParticipants,participants:updatedParticipants};});// Mettre à jour l'ensemble des substituts\nsetSubstituteIds(prevIds=>{const isCurrentlySubstituted=prevIds.includes(participantId);if(isCurrentlySubstituted){// Retirer l'ID du participant de la liste s'il est déjà un substitut\nreturn prevIds.filter(id=>id!==participantId);}else{// Ajouter l'ID du participant à la liste s'il n'est pas encore un substitut\nreturn[...prevIds,participantId];}});// Mettre à jour l'état de la session si nécessaire\nsetSession(state=>({...state,participants:participants.participants}));};return /*#__PURE__*/_jsx(Component,{...props,participants:participantList,//selectedParticipant={participants.selectedParticipant}\ngiveVote:participant=>handleGiveVote(participant),changeMissing:participantId=>handleChangeMissing(participantId),deleteUser:participantId=>handleDeleteUser(participantId),presidentSeance:participantId=>handlePresidentSeance(participantId),president:participants.president,participantSubstitute:participantId=>handleSubstitute(participantId),substituteId:substituteIds,deleteDisabled:isDisabled});};}export function inputSearch(Component){return props=>{const[participants,setParticipants]=participantsStore();const handleOnChange=value=>{setParticipants(state=>({...state,search:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:participants.search,onChange:value=>handleOnChange(value)});};}export function searchWithFilter(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const[participantsDisplayed,setParticipantsDisplayed]=useState([]);useEffect(()=>{setParticipants(prevState=>({...prevState,search:\"\"}));},[]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Si le receveur a déjà un pouvoir reçu, on pré-sélectionne le donneur\nif(participantReceivingProxy?.proxyFrom?.id){setProxy(state=>({...state,userGivingProxy:participantReceivingProxy.proxyFrom}));}},[proxy.userReceivingProxy?.id]);useEffect(()=>{const receiverId=proxy.userReceivingProxy?.id;const participantReceivingProxy=receiverId?participants.participants.find(p=>p.id===receiverId):null;// Calcul des participants déjà impliqués dans un pouvoir\nconst participantsThatAlreadyGaveVote=participants.participants.reduce((acc,participant)=>{if(participant.proxyFrom?.id){const giver=participants.participants.find(p=>p.id===participant.proxyFrom.id);if(giver)acc.push(giver);}return acc;},[]);const participantsThatAlreadyReceivedVote=participants.participants.filter(p=>p.proxyFrom?.id);const uniqueGivers=[...new Set(participantsThatAlreadyGaveVote)];const uniqueReceivers=[...new Set(participantsThatAlreadyReceivedVote)];// Filtrage principal\nconst participantsFirstFilter=participants.participants.filter(participant=>{// Cas 1 : pas de receveur sélectionné → on affiche tous les non-substitués\nif(!participantReceivingProxy){return!participant.isSubstituted;}// Cas 2 : le participant est l'actuel donneur du receveur → on le garde\nif(participant.id===participantReceivingProxy.proxyFrom?.id){return true;}// Cas 3 : filtre standard\nreturn participant.id!==receiverId&&!uniqueGivers.includes(participant)&&!uniqueReceivers.includes(participant)&&!participant.isSubstituted;});// Application du filtre de recherche\nif(participants.search){const searchTerm=participants.search.toLowerCase();const filtered=participantsFirstFilter.filter(participant=>{const nameMatch=participant.name?.toLowerCase().includes(searchTerm);const firstNameMatch=participant.firstName?.toLowerCase().includes(searchTerm);return nameMatch||firstNameMatch;});setParticipantsDisplayed(filtered);}else{setParticipantsDisplayed(participantsFirstFilter);}},[participants.search,participants.participants,proxy.userReceivingProxy?.id]);const handleClick=participant=>{const{proxyFrom,proxyTo,...participantWithoutProxy}=participant;if(proxy.userGivingProxy?.id===participant.id){setProxy(state=>({...state,userGivingProxy:{}}));}else{setProxy(state=>({...state,userGivingProxy:participantWithoutProxy}));}};return /*#__PURE__*/_jsx(Component,{...props,participants:participantsDisplayed,click:participant=>handleClick(participant),selectedId:proxy.userGivingProxy?.id});};}export function withGiveVote(Component){return props=>{const[participants,setParticipants]=participantsStore();const[proxy,setProxy]=proxyStore();const validateOrigin=props.valider;const cancelOrigin=props.annuler;const handleValidate=()=>{if(proxy.userReceivingProxy.id){const indexOfReceiver=participants.participants.findIndex(participant=>participant.id===proxy.userReceivingProxy.id);const previousGiverId=participants.participants[indexOfReceiver].proxyFrom?.id;if(previousGiverId){const indexPreviousGiver=participants.participants.findIndex(participant=>participant.id===previousGiverId);if(indexPreviousGiver!==-1){setParticipants(state=>{const newState={...state};newState.participants[indexPreviousGiver].proxyTo=null;return newState;});}}if(proxy.userGivingProxy.id){const indexOfGiver=participants.participants.findIndex(participant=>participant.id===proxy.userGivingProxy.id);setParticipants(state=>{const newState={...state};newState.participants[indexOfReceiver].proxyFrom=proxy.userGivingProxy;newState.participants[indexOfGiver].proxyTo=proxy.userReceivingProxy;newState.participants[indexOfGiver].missing=false;return newState;});}else{setParticipants(state=>{const newState={...state};const previousGiver=newState.participants[indexOfReceiver].proxyFrom;const indexPreviousGiver=newState.participants.findIndex(participant=>participant.id===previousGiver.id);if(indexPreviousGiver!==-1){newState.participants[indexPreviousGiver].proxyTo={};newState.participants[indexPreviousGiver].missing=true;}newState.participants[indexOfReceiver].proxyFrom={};return newState;});}}setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));console.log(\"valideeee\",participants);validateOrigin();};const handleCancel=()=>{setProxy(state=>({userGivingProxy:{},userReceivingProxy:{}}));cancelOrigin();};return /*#__PURE__*/_jsx(Component,{...props,valider:()=>handleValidate(),annuler:()=>handleCancel()});};}export function withAddParticipant(Component){return props=>{const[participants,setParticipants]=participantsStore();const session=globalStore(state=>state.session);const[list,setList]=useState([\"Choisir un participant...\"]);const[value,setValue]=useState(1);const[updateKey,setUpdateKey]=useState(0);const url=globalStore(state=>state.url);const isCurrentAdminSession=url===\"/admin/sessions/current/\";useEffect(()=>{setList(()=>{const participantsList=[\"Choisir un participant...\"];participantsList.push(...participants.deletedParticipants.reduce((acc,participant)=>{acc.push(`${participant.name} ${participant.firstName}`);return acc;},[]));return participantsList;});},[participants.deletedParticipants]);const handleOnChange=(index,label)=>{setValue(1);if(index!==0){setParticipants(state=>{const newState={...state};const deletedParticipants=[...newState.deletedParticipants];const newParticipant=deletedParticipants.splice(index-1,1);newState.deletedParticipants=deletedParticipants;newState.participants=[...newState.participants,newParticipant[0]];return newState;});}};// Effect to reset the value when needed\nuseEffect(()=>{setValue(1);setUpdateKey(prevKey=>prevKey+1)// Incrémente le key pour forcer la mise à jour\n;},[list]);return /*#__PURE__*/_createElement(Component,{...props,key:updateKey,value:value,options:list,onChange:(index,label)=>handleOnChange(index,label)});};}\nexport const __FramerMetadata__ = {\"exports\":{\"participantsStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAddParticipant\":{\"type\":\"reactHoc\",\"name\":\"withAddParticipant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withReinitList\":{\"type\":\"reactHoc\",\"name\":\"withReinitList\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFormParticipants\":{\"type\":\"reactHoc\",\"name\":\"withFormParticipants\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDifferentLists\":{\"type\":\"reactHoc\",\"name\":\"withDifferentLists\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGiveVote\":{\"type\":\"reactHoc\",\"name\":\"withGiveVote\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"PARTICIPANTS_STORE_ID\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"searchWithFilter\":{\"type\":\"reactHoc\",\"name\":\"searchWithFilter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"inputSearch\":{\"type\":\"reactHoc\",\"name\":\"inputSearch\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{generateUniqueId}from\"https://framerusercontent.com/modules/x3DKjgflibXKty5OWFXp/rnwtbIjzVNxDLCRTdxCl/Miscellaneous.js\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{globalStore,editStore,errorStore}from\"https://framerusercontent.com/modules/yCVW0sl8skOTnaEg6ZHn/EjkxzQ4u1A7wJxXbP3hs/Globals.js\";import{createDocument,getAllDocument,setCollectionAndDocumentToDocument,editSession,getLastIdDocument,updateChampInDocument,getValueInChamp}from\"https://framerusercontent.com/modules/9eN7tRwB8O4la4Be656T/xGlXLzNbSIqryyPcmzJQ/Firebase.js\";import{participantsStore}from\"https://framerusercontent.com/modules/uG0FllQBWYDjBDEnJPhH/HdbdkjjAQBekRtZImCHb/ParticipantSeance.js\";export const sessionStore=createStore({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,chorum:false,orderItems:[],items:[],selectedList:\"\",participants:[]});export const electionDefault={title:\"\",list:\"\",candidats:[],anonymous:true,round:1};export const electionStore=createStore(electionDefault);export const resolutionDefault={title:\"\",anonymous:false,responses:[],scrutin:\"\",answerTypeResponses:\"\"};export const resolutionStore=createStore(resolutionDefault);export function secretarySeance(Component){return props=>{const[state,setState]=sessionStore();const[participants,setParticipants]=participantsStore();const onChangeInput=value=>{setState(prev=>({...prev,secretary:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.secretary||\"\",onChange:value=>onChangeInput(value)});};}export function titleSeance(Component){return props=>{const[state,setState]=sessionStore();const onChangeInput=value=>{setState(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:state.title||\"\",onChange:value=>onChangeInput(value)});};}export function sessionDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,sessionDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.sessionDate,onDateChange:handleDateChange,onEditCalendar:state.sessionDate});};}export function convocationDateSeance(Component){return props=>{const[state,setState]=sessionStore();const handleDateChange=newDate=>{setState(oldState=>({...oldState,convocationDate:newDate}));};return /*#__PURE__*/_jsx(Component,{...props,selectedDate:state.convocationDate,onDateChange:handleDateChange,onEditCalendar:state.convocationDate});};}export function validateButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[participantsStoreState,setParticipantsStoreState]=participantsStore()// ✅ Accès direct au store des participants\n;const[messageState,setMessageState]=errorStore();const setSessionGlobal=globalStore(state=>state.setSession);const sessionGlobal=globalStore(state=>state.session);const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);const[isSubmitted,setIsSubmitted]=useState(false);const[edit,setEdit]=editStore();const handleTap=async()=>{// ✅ session contient les bonnes données (vérifié via les logs)\nconsole.log(\"🔎 handleTap - \\xe9tat au clic Valider :\",{\"participantsStore.participants.length\":participantsStoreState.participants.length,\"session.participants.length\":session.participants?.length??0,\"session.selectedList\":session.selectedList});const areRequiredFieldsFilled=session.title&&session.sessionDate&&session.convocationDate;const hasItems=session.items.length>0;const hasParticipants=session.participants.length>0// ✅ session\n;if(!areRequiredFieldsFilled){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Tous les champs obligatoires doivent \\xeatre remplis.\"}));return;}if(!hasItems){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Au moins un item doit \\xeatre ajout\\xe9.\"}));return;}if(!hasParticipants){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"Une liste de participants doit \\xeatre s\\xe9lectionn\\xe9e.\"}));return;}const sessionDate=new Date(session.sessionDate);const convocationDate=new Date(session.convocationDate);if(sessionDate<=convocationDate){setMessageState(prevState=>({...prevState,error:true,errorMessage:\"La date de la s\\xe9ance doit \\xeatre post\\xe9rieure \\xe0 la date de convocation.\"}));return;}const{items,participants,...stateWithoutCollections}=session;if(!edit.onEditSession&&!isSubmitted){// ... (tout le code de création inchangé, tel qu'il était à l'origine)\nsetIsSubmitted(true);const id=await getLastIdDocument(\"sessions\");if(id){setSessionGlobal(session);const subCollectionItems=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"items\",session.items);const subCollectionParticipants=await setCollectionAndDocumentToDocument(\"sessions\",(id+1).toString(),\"participants\",session.participants);if(Array.isArray(subCollectionItems)){const orderItems=subCollectionItems;const dataToSend={...stateWithoutCollections,orderItems,chorum:false,docId:(id+1).toString(),id:(id+1).toString()};const response=await createDocument(\"sessions\",dataToSend,(id+1).toString());if(response.success){console.info(response.message);window.location.href=\"/admin/sessions/\";}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",response.error);setIsSubmitted(false);}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\");}}}else{/**\n                 * EDIT EXISTING SESSION\n                 */if(!isSubmitted){setIsSubmitted(true);const{currentItemId,...sessionWithoutCurrentItemId}=session;// ✅ LOG DEBUG - vérification que les pouvoirs sont bien présents\nconsole.log(\"📤 Envoi \\xe0 editSession :\",{idSession:edit.idSession,participantsAvecPouvoirs:sessionWithoutCurrentItemId.participants?.map(p=>({id:p.id,name:p.name,proxyFrom:p.proxyFrom,proxyTo:p.proxyTo}))});const editResponse=await editSession(`sessions`,edit.idSession,sessionWithoutCurrentItemId);setSessionGlobal(editResponse.updatedSession);if(editResponse.success){console.info(editResponse.message);setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(session.startedSession){// ... (reste du code identique à l'original)\nconst newParticipantIds=session.participants.reduce((acc,participant)=>{if(participant.missing===false){if(participant.isSubstituted&&participant.substitute){acc.push(participant.substitute.id);}else if(Object.keys(participant.proxyTo||{}).length===0){acc.push(participant.id);}}return acc;},[]);const participantsWithSubstitute=session.participants.reduce((acc,participant)=>{if(participant.substitute){acc.push(participant.substitute.id);acc.push(participant.id);}else{acc.push(participant.id);}return acc;},[]);const updatedSession={...session,participantIds:newParticipantIds};const deletedParticipantIds=participantsStoreState.deletedParticipants.map(participant=>participant.id);let allParticipantIdsToUpdate=[...participantsWithSubstitute,...deletedParticipantIds];let filteredParticipantIds=[];for(const participantId of allParticipantIdsToUpdate){const matches=await getValueInChamp(\"users\",participantId.toString(),session.docId);if(matches){filteredParticipantIds.push(participantId);}}allParticipantIdsToUpdate=filteredParticipantIds;for(const participantId of allParticipantIdsToUpdate){await updateChampInDocument(\"users\",{idSession:\"\"},participantId.toString());}for(const participantId of newParticipantIds){await updateChampInDocument(\"users\",{idSession:updatedSession.id},participantId.toString());}setSessionGlobal(updatedSession);}if(url==\"/admin/sessions/current/\"){setIsSubmitted(false);window.location.href=\"/admin/sessions/current/\";}else{setIsSubmitted(false);window.location.href=\"/admin/sessions/\";}}else{console.error(\"Erreur lors de la mise \\xe0 jour :\",editResponse.error);}}}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonSeance(Component){return props=>{const[session,setSession]=sessionStore();const[edit,setEdit]=editStore();const url=globalStore(state=>state.url);const setUrl=globalStore(state=>state.setUrl);// const tapOrigin = props.tap\nconst handleTap=()=>{setSession(prev=>({secretary:\"\",title:\"\",agenda:\"\",sessionDate:null,convocationDate:null,items:[]}));if(edit.onEditSession){setEdit(prev=>({...prev,onEditSession:false,onEditParticipants:false,idSession:null}));if(url==\"/admin/sessions/current/\"){//    setUrl(\"\")\nwindow.location.href=\"/admin/sessions/current/\";return;}else{window.location.href=\"/admin/sessions/\";}}window.location.href=\"/admin/sessions/\";// tapOrigin()\n};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------------------ELECTION-------------------------------------------------------\nexport function titleElectionSeance(Component){return props=>{const[election,setElection]=electionStore();// ✅ LOG DEBUG\nconsole.log(\"📝 titleElectionSeance render, election.title =\",election.title,\"full election =\",election);const handleTitleChange=value=>{setElection(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:election.title,onChange:value=>handleTitleChange(value)});};}export function listSelectElection(Component){return props=>{const[options,setOptions]=useState([]);const[election,setElection]=electionStore();const[participants,setParticipants]=participantsStore();useEffect(()=>{// ✅ Si le store local a les listes, on les utilise\nif(participants.lists&&participants.lists.length>0){setOptions(participants.lists);return;}// ✅ Sinon on les charge directement depuis Firestore\nconsole.log(\"📋 listSelectElection - chargement des listes depuis Firestore\");getAllDocument(\"users\").then(users=>{const lists=[];users.forEach(user=>{const userLists=user.lists||[];lists.push(...userLists);});const uniqueLists=[\"Choisir une liste...\",...new Set(lists)];setOptions(uniqueLists);// On met aussi à jour notre instance locale du store\nsetParticipants(prev=>({...prev,lists:uniqueLists}));});},[participants.lists]);useEffect(()=>{if(!election.list&&participants.selectedList){setElection(state=>({...state,list:participants.selectedList}));}},[participants.selectedList]);const handleOnChange=(index,label)=>{if(index!=0){setElection(state=>({...state,list:label}));}};return /*#__PURE__*/_jsx(Component,{...props,options:options,onChange:(index,label)=>handleOnChange(index,label),value:options.findIndex(option=>option===election.list)+1});};}export function candidatElectionSeance(Component){return props=>{const[election,setElection]=electionStore();const[participants,setParticipants]=participantsStore();const[extractedNames,setExtractedNames]=useState([]);const handleInputChangeCallback=newInputs=>{const newCandidats=newInputs.filter(input=>input.trim()!==\"\");setElection(prev=>({...prev,candidats:newCandidats}));};useEffect(()=>{if(!election.list)return;// ✅ Si les users sont dans le store local, on les utilise\nif(participants.users&&participants.users.length>0){setExtractedNames(participants.users.filter(user=>user.lists?.includes(election.list)).map(p=>`${p.firstName} ${p.name}`));return;}// ✅ Sinon on charge depuis Firestore\nconsole.log(\"📋 candidatElectionSeance - chargement des users depuis Firestore\");getAllDocument(\"users\").then(users=>{const filtered=users.filter(user=>user.lists?.includes(election.list)).map(p=>`${p.firstName} ${p.name}`);setExtractedNames(filtered);});},[election.list,participants.users]);return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:inputs=>handleInputChangeCallback(inputs),onEditValues:extractedNames,initialSelectedCandidates:election.candidats});};}/*export function scrutintElectionSeance(Component): ComponentType {\n    return (props) => {\n        const [election, setElection] = electionStore()\n\n        useEffect(() => {\n            if (election.scrutin == \"\") {\n                setElection((prev) => ({\n                    ...prev,\n                    scrutin: props.options[0],\n                }))\n            }\n        }, [])\n\n        const handleOnChange = (index, label) => {\n            setElection((prev) => ({\n                ...prev,\n                scrutin: label,\n            }))\n        }\n        console.log(\"props.opt[0]\", props.options[0])\n        const initialValue = props.options.findIndex(\n            (option) => option === election.scrutin\n        )\n        return (\n            <Component\n                {...props}\n                value={initialValue + 1}\n                onChange={(index, label) => handleOnChange(index, label)}\n            />\n        )\n    }\n}*/export function validateButtonElectionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[election,setElection]=electionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=election.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez bien remplir le titre de l'\\xe9lection\"}));}else if(election.list===\"\"){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez choisir une liste\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newElectionItem={type:\"election\",id:uniqueId,...election};setSession(prev=>({...prev,items:[...prev.items,newElectionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"election\",...election};return state;});}setElection(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonElectionSeance(Component){return props=>{const[electionState,setElectionState]=electionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setElectionState(electionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-----------------------RESOLUTION----------------------------------------\nexport function titleResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleTitleChange=value=>{setResolution(prev=>({...prev,title:value}));};return /*#__PURE__*/_jsx(Component,{...props,value:resolution.title,onChange:value=>handleTitleChange(value)});};}export function responsesResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleInputChangeCallback=(newInputs,answerTypeCallback)=>{const newResponses=newInputs;setResolution(prev=>({...prev,responses:newResponses,answerTypeResponses:answerTypeCallback}));};return /*#__PURE__*/_jsx(Component,{...props,onInputChangeCallback:(inputs,answerTypeCallback)=>handleInputChangeCallback(inputs,answerTypeCallback),answerResponses:resolution.answerTypeResponses,onEditValues:resolution.responses});};}export function scrutintResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();useEffect(()=>{if(resolution.scrutin==\"\"){setResolution(prev=>({...prev,scrutin:props.options[0]}));}},[]);const handleOnChange=(index,label)=>{setResolution(prev=>({...prev,scrutin:label}));};const initialValue=props.options.findIndex(option=>option===resolution.scrutin);return /*#__PURE__*/_jsx(Component,{...props,value:initialValue+1,onChange:(index,label)=>handleOnChange(index,label)});};}export function anonymousResolutionSeance(Component){return props=>{const[resolution,setResolution]=resolutionStore();const handleToggle=()=>{setResolution(prev=>({...prev,anonymous:!prev.anonymous}));};const checkboxProps={isChecked:resolution.anonymous,onToggle:()=>{handleToggle();}};return /*#__PURE__*/_jsx(Component,{...props,...checkboxProps});};}export function validateButtonResolutionSeance(Component){return props=>{const[session,setSession]=sessionStore();const[resolution,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const[error,setError]=errorStore();const tapOrigin=props.tap;const handleTap=()=>{const isTitleFilled=resolution.title!==\"\";if(!isTitleFilled){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez remplir le titre!\"}));}else if(resolution.responses.length===1&&resolution.responses[0]===\"\"||resolution.responses.length===0){setError(prevState=>({...prevState,error:true,errorMessage:\"Veuillez ajouter une r\\xe9ponse valide!\"}));}else{if(!edit.onEditItem){const uniqueId=generateUniqueId();const newResolutionItem={type:\"resolution\",id:uniqueId,...resolution};setSession(prev=>({...prev,items:[...prev.items,newResolutionItem]}));}else{setSession(state=>{state.items[edit.indexItem]={type:\"resolution\",...resolution};return state;});}setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();}};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}export function cancelButtonResotutioSeance(Component){return props=>{const[resolutionState,setResolution]=resolutionStore();const[edit,setEdit]=editStore();const tapOrigin=props.tap;const handleTap=()=>{setResolution(resolutionDefault);setEdit(prev=>({...prev,onEditItem:false,indexItem:null}));tapOrigin();};return /*#__PURE__*/_jsx(Component,{...props,tap:()=>handleTap()});};}//-------------------------------------------UTILS-----------------\nexport function snakbarre(Component){return props=>{const[state,setState]=errorStore();if(state.error){setTimeout(()=>{setState(prevState=>({...prevState,error:false}));},3e3);return /*#__PURE__*/_jsx(Component,{...props,message:state.errorMessage});}return;};}\nexport const __FramerMetadata__ = {\"exports\":{\"sessionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"snakbarre\":{\"type\":\"reactHoc\",\"name\":\"snakbarre\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"listSelectElection\":{\"type\":\"reactHoc\",\"name\":\"listSelectElection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonResotutioSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonResotutioSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleSeance\":{\"type\":\"reactHoc\",\"name\":\"titleSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrutintResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"scrutintResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"responsesResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"responsesResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"secretarySeance\":{\"type\":\"reactHoc\",\"name\":\"secretarySeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"candidatElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"candidatElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"convocationDateSeance\":{\"type\":\"reactHoc\",\"name\":\"convocationDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionDateSeance\":{\"type\":\"reactHoc\",\"name\":\"sessionDateSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"anonymousResolutionSeance\":{\"type\":\"reactHoc\",\"name\":\"anonymousResolutionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"titleElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"titleElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"validateButtonElectionSeance\":{\"type\":\"reactHoc\",\"name\":\"validateButtonElectionSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"electionDefault\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cancelButtonSeance\":{\"type\":\"reactHoc\",\"name\":\"cancelButtonSeance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resolutionStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CreateSeance.map"],"mappings":"yYAA4B,IAAgD,IAAqE,CAAa,EAAY,CAAC,GAAG,GAAG,KAAK,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,GAAM,MAAM,GAAM,CAAc,EAAY,GAAO,GAAQ,GAAQ,CAAC,aAAa,EAAE,CAAC,QAAQ,GAAG,IAAI,GACxW,KAAK,CAAC,GAAG,EAAY,CAAC,QAAQ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