UNPKG

pawnote

Version:

A purrfect API wrapper for PRONOTE.

1 lines 54.6 kB
"use strict";var e=require("@literate.ink/utilities"),s=require("node-forge"),t=require("pako");function n(e){return e&&e.__esModule?e:{default:e}}var i=n(s),a=n(t),r=e=>{let s=new URL(e);s=new URL(`${s.protocol}//${s.host}${s.pathname}`);const t=s.pathname.split("/");return t[t.length-1].includes(".html")&&t.pop(),s.pathname=t.join("/"),s.href.endsWith("/")?s.href.slice(0,-1):s.href},o=class extends Error{constructor(){super("Unable to resolve the challenge, make sure the credentials or token are corrects"),this.name="BadCredentialsError"}},c=class extends Error{constructor(e){super(e),this.name="AuthenticateError"}},u=class extends Error{constructor(){super("You do not have access to this area or your authorizations are insufficient"),this.name="AccessDeniedError"}},l=class extends Error{constructor(){super("Your account has been deactivated"),this.name="AccountDisabledError"}},d=class extends Error{constructor(){super("You can't send a message or a draft in this discussion"),this.name="DiscussionActionError"}},p=class extends Error{constructor(){super("You should request messages before sending anything"),this.name="DiscussionMessagesMissingError"}},m=e=>{if("["!==(e=e.trim())[0]||"]"!==e[e.length-1])return[];if(0===(e=e.slice(1,-1)).length)return[];const s=[];for(const t of e.split(","))if(t.includes("..")){const[e,n]=t.split("..").map((e=>parseInt(e)));for(let t=e;t<=n;t++)s.push(t)}else s.push(parseInt(t));return s},f=class extends Error{handle;constructor(e,s,t){super("You're asked to custom your security methods"),this.name="SecurityError",this.handle=((e,s,t)=>{const n=m(e.actionsDoubleAuth.V);return{availableSecurityModes:m(e.modesPossibles.V),defaultSecurityMode:e.modeSecurisationParDefaut,passwordRules:(i=e.reglesSaisieMDP,{maxLength:i.max,minLength:i.min,rules:m(i.regles.V)}),shouldCustomPassword:n.includes(L.AIHMSC_PersonnalisationMotDePasse),shouldCustomDoubleAuth:n.includes(L.AIHMSC_ChoixStrategie),shouldEnterPIN:n.includes(L.AIHMSC_SaisieCodePINetSource),shouldEnterSource:n.includes(L.AIHMSC_SaisieSourcePourNotifSeulement),context:{authentication:e,identity:s,initialUsername:t}};var i})(e,s,t)}},h=class extends Error{constructor(e){super(`The source name is too long, limited to ${e} characters`),this.name="SecuritySourceTooLongError"}},g=class extends Error{constructor(){super("Your IP address has been suspended"),this.name="SuspendedIPError"}},D=class extends Error{constructor(){super("The session has expired"),this.name="SessionExpiredError"}},b=class extends Error{constructor(){super("The requested page does not exist"),this.name="PageUnavailableError"}},w=class extends Error{constructor(){super("The site is temporarily unavailable"),this.name="BusyPageError"}},C=class extends Error{constructor(){super("You've been rate-limited"),this.name="RateLimitedError"}},A=class extends Error{constructor(e="An error occurred, server-side"){super(e),this.name="ServerSideError"}},E=class extends Error{constructor(e){super(`Unreachable code reached in '${e}' function, please open an issue on GitHub (LiterateInk/Pawnote)`),this.name="UnreachableError"}},v=class extends Error{constructor(e){super(`The file you are trying to upload is too large, maximum allowed is ${e} bytes`),this.name="UploadSizeError"}},y=class extends Error{constructor(){super("The file upload failed"),this.name="UploadFailedError"}},M={STUDENT:6,PARENT:7,TEACHER:8},x={None:0,Paper:1,FileUpload:2,Kiosk:3,AudioRecording:4},V={Link:0,File:1},P={lu:"lu",nonLu:"nonLu",archiver:"archiver",desarchiver:"desarchiver",transferer:"transferer",signaler:"signaler",modifierCategories:"modifierCategories",fermerDiscussion:"fermerDiscussion",ouvrirDiscussion:"ouvrirDiscussion",signalerSuppression:"signalerSuppression",Trash:"corbeille",Restore:"restauration",Delete:"suppression",brouillon:"brouillon",plus:"plus",purger:"purger",discussionEnFenetre:"discussionEnFenetre",entrerSortirDiscussion:"entrerSortirDiscussion",modificationObjetDiscussion:"modificationObjetDiscussion",afficherDestinataires:"afficherDestinataires",copierContenuVisu:"copierContenuVisu",repondreMessage:"repondreMessage",afficherDiscussion:"afficherDiscussion"},S={Send:0,SendEveryone:1,SendEveryoneExceptParentsAndStudents:3,ReplyEveryone:2,ReplyEveryoneExceptParentsAndStudents:4,Close:5},N={Entry:0,Main:1,Side:2,Drink:3,Dessert:4,Fromage:5},I={URL:0,FILE:1,CLOUD:2,KIOSK_LINK:3,CONFERENCE_LINK:4},L={AIHMSC_PersonnalisationMotDePasse:0,AIHMSC_ChoixStrategie:1,AIHMSC_ChoixCodePINetSource:2,AIHMSC_SaisieCodePINetSource:3,AIHMSC_ReinitCodePINetSource:4,AIHMSC_SaisieSourcePourNotifSeulement:5},R={csch_VerifierPIN:0,csch_VerifierMotDePassePersonnalise:1,csch_LibellesSourceConnexionDejaConnus:2,csch_EnregistrerChoixUtilisateur:3,csch_AffecterModeDoubleAuthentification:4,csch_AffecterCodePIN:5,csch_RenommerSourceConnexionConnue:6,csch_SupprimerSourceConnexionConnue:7,csch_AffecterMotDePassePersonnalise:8,csch_ModifierLogin:9,csch_DemandeReinitialisationPIN:10,csch_VerifierCodeReinitialisationPIN:11},T={Aucune:0,Classe:1,Group:2,Teacher:3,Student:4,Responsable:5,Niveau:6,Orientation:7,Specialite:8,OptionSpecialite:9,Etablissement:10,Period:11,Service:12,Absence:13,Delay:14,Exclusion:15,Subject:16,Room:17,CoEnseignant:18,Suivis:19,Cours:20,Infirmerie:21,AbsenceRepas:22,Pilier:23,ElementPilier:24,Competence:25,_DisciplineBrevet:26,Palier:27,SousItem:28,Evaluation:29,Stage:30,SousMatiere:31,MaitreDeStage:32,InspecteurPedagogique:33,Personal:34,EvaluationHistorique:35,DossierProgression:36,ContenuDeCours:37,TravailAFaire:38,Progression:39,Dispense:40,Punishment:41,Sanction:42,Communication:43,AbsenceInternat:44,Observation:45,ObservationProfesseurEleve:46,ConvocationVS:47,DocumentJoint:48,InternetCategorie:49,DocJointEtablissement:50,Option:51,ProgrammationPunition:52,ReportPunition:53,DisciplineLivretScolaire:54,QCM:55,ExecutionQCM:56,QCMEditeur:57,PartieDeClasse:58,DocJointEleve:59,Devoir:60,InternetEnumere:61,AppreciationBulletinCompetence:62,Entreprise:63,DomaineProfessionnel:64,OffreDeStage:65,SujetDeStage:66,DocumentCasier:67,Message:68,PossessionMessage:69,RelationMessageDocJointEtablissement:70,Engagement:71,PrecautionaryMeasure:72,SousCategorieObjetDossier:73,Incident:74,ProtagonisteIncident:75,RelationIncidentFichierExterne:76,RegimeEleve:77,RepasAPreparer:78,SessionDeStage:79,Materiel:80,Bourse:81,RelationTravailAFaireEleve:82,LieuDossier:83,ElementProgramme:84,ChapitreEltPgm:85,EltPgmTravailleCDT:86,Appreciation:87,ExecutionDevoirKiosque:88,PanierRessourceKiosque:89,RessourceNumeriqueKiosque:90,MetaMatiere:91,EvaluationSujet:92,EvaluationCorrige:93,LibelleCours:94,Site:95,QuestionQCM:96,RelationElevePilierDeCompetence:97,QuestionCopieQCM:98,Coordonnees:99,ResponsablePostulant:100,ExecutionQCMEleve:101,DocJointInscription:102,CategorieDossier:103,MEFGEP:104,AutreOrientation:105,Commission:106,ReponseEducative:107,SuiviReponseEducative:108,NatureDocumentEleve:109},k={NONE:0,CREATION:1,MODIFICATION:2,DELETION:3,CHILDREN_MODIFICATION:4},O={Error:-1,Grade:0,Absent:1,Exempted:2,NotGraded:3,Unfit:4,Unreturned:5,AbsentZero:6,UnreturnedZero:7,Congratulations:8},F={Lunch:0,Dinner:1},_={InformationText:0,SurveyText:5,TextInput:1,UniqueChoice:2,MultipleChoice:3},U={ACCOUNT:0,ACCOUNT_CONNECTION:1,DIRECT_CONNECTION:2,TOKEN_ACCOUNT_CONNECTION:3,TOKEN_DIRECT_CONNECTION:4,COOKIE_CONNECTION:5},G={Grades:198,Resources:89,Assignments:88,Timetable:16,Evaluations:201,Account:49,Presence:7,News:8,Notebook:19,Discussions:131,Gradebook:13,Menus:10},B=async(s,t=e.defaultFetcher)=>{const n=new URL(s.base+"/"+(e=>{let s;switch(e){case M.STUDENT:s="eleve";break;case M.PARENT:s="parent";break;case M.TEACHER:s="professeur"}return`mobile.${s}.html`})(s.kind));for(const[e,t]of Object.entries(s.params))n.searchParams.set(e,t);const a={url:n,redirect:"manual"};e.setCookiesArrayToRequest(a,s.cookies);const{content:r}=await t(a);try{const e=r.replace(/ /gu,"").replace(/\n/gu,""),t="Start(",n=")}catch",a=e.substring(e.indexOf(t)+t.length,e.indexOf(n)).replace(/(['"])?([a-z0-9A-Z_]+)(['"])?:/gu,'"$2": ').replace(/'/gu,'"');return((e,s)=>{const t=!e.MR&&!e.ER;return{url:s,id:parseInt(e.h),accountKind:e.a,demo:e.d??!1,accessKind:e.g??U.ACCOUNT,rsaModulus:t?"B99B77A3D72D3A29B4271FC7B7300E2F791EB8948174BE7B8024667E915446D4EEA0C2424B8D1EBF7E2DDFF94691C6E994E839225C627D140A8F1146D1B0B5F18A09BBD3D8F421CA1E3E4796B301EEBCCF80D81A32A1580121B8294433C38377083C5517D5921E8A078CDC019B15775292EFDA2C30251B1CCABE812386C893E5":e.MR,rsaExponent:t?"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010001":e.ER,rsaFromConstants:t,aesIV:i.default.random.getBytesSync(16),aesKey:"",skipEncryption:e.sCrA??!1,skipCompression:e.sCoA??!1,http:e.http??!1,poll:e.poll??!1,order:0}})(JSON.parse(a),s.base)}catch(e){if(r.includes("Votre adresse IP est provisoirement suspendue"))throw new g;if(r.includes("Le site n'est pas disponible"))throw new b;if(r.includes("Le site est momentanément indisponible"))throw new w;throw new b}},j=class{static decrypt(e,s,t){s=i.default.md.md5.create().update(s.bytes()).digest(),t=t.length()?i.default.md.md5.create().update(t.bytes()).digest():i.default.util.createBuffer().fillWithByte(0,16);const n=i.default.util.createBuffer(i.default.util.binary.hex.decode(e)),a=i.default.cipher.createDecipher("AES-CBC",s);return a.start({iv:t}),a.update(n),a.finish(),a.output.bytes()}static encrypt(e,s,t){s=i.default.md.md5.create().update(s.bytes()).digest(),t=t.length()?i.default.md.md5.create().update(t.bytes()).digest():i.default.util.createBuffer().fillWithByte(0,16),e=i.default.util.createBuffer(e);const n=i.default.cipher.createCipher("AES-CBC",s);return n.start({iv:t}),n.update(e),n.finish(),n.output.toHex()}},q=(e,s=!1)=>({iv:i.default.util.createBuffer(s?"":e.information.aesIV),key:i.default.util.createBuffer(e.information.aesKey)}),$=class{constructor(e,s){this.session=e,this.data=s,this.session.information.order++;const t=s;try{const e=JSON.parse(t);if(e.Erreur){const s=e.Erreur.Titre||"Server Error";throw new A(s)}if(this.data=e.donneesSec,this.session.information.skipEncryption||this.decrypt(),this.session.information.skipCompression||this.decompress(),"string"==typeof this.data&&(this.data=JSON.parse(this.data)),void 0!==this.data?._Signature_?.Erreur)throw new A(this.data._Signature_.MessageErreur);if(void 0!==this.data?.Signature?.Erreur)throw new A(this.data.Signature.MessageErreur)}catch(e){if(t.includes("La page a expir"))throw new D;if(t.includes("Votre adresse IP "))throw new g;if(t.includes("La page dem")||t.includes("Impossible d'a"))throw new b;if(t.includes("Vous avez d"))throw new C;if(t.includes("s refus"))throw new u;throw e}}decrypt(){const{iv:e,key:s}=q(this.session);this.data=j.decrypt(this.data,s,e),this.session.information.skipCompression||(this.data=i.default.util.bytesToHex(this.data))}decompress(){const e=i.default.util.hexToBytes(this.data),s=new Uint8Array(Array.from(e).map((e=>e.charCodeAt(0))));this.data=a.default.inflateRaw(s,{to:"string"})}},H=class{constructor(e,s,t){this.session=e,this.name=s,this.data=t}process(){this.session.information.order++;const e=this.generateOrder(),s=new URL(`${this.session.information.url}/appelfonction/${this.session.information.accountKind}/${this.session.information.id}/${e}`);return this.session.information.skipCompression||this.compress(),this.session.information.skipEncryption||this.encrypt(),{order:e,url:s}}keys(){return q(this.session,1===this.session.information.order)}generateOrder(){const{key:e,iv:s}=this.keys();return j.encrypt(this.session.information.order.toString(),e,s)}stringify(){return i.default.util.encodeUtf8(JSON.stringify(this.data)||"")}compress(){const e=i.default.util.createBuffer(this.stringify()).toHex(),s=a.default.deflateRaw(e,{level:6}),t=Array.from(s).map((e=>String.fromCharCode(e))).join("");this.data=i.default.util.bytesToHex(t)}encrypt(){const{key:e,iv:s}=this.keys(),t=this.session.information.skipCompression?this.stringify():i.default.util.hexToBytes(this.data);this.data=j.encrypt(t,e,s)}async send(){return this.session.queue.push((async()=>{const e=this.process(),s=await this.session.fetcher({url:e.url,method:"POST",headers:{"Content-Type":"application/json"},content:JSON.stringify({session:this.session.information.id,numeroOrdre:e.order,nom:this.name,donneesSec:this.data})});return new $(this.session,s.content)}))}},K=/^\d{2}\/\d{2}\/\d{4}$/,J=/^\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2}$/,Q=/^\d{2}\/\d{2}\/\d{2} \d{2}h\d{2}$/,W=(new Date).getFullYear().toString().slice(0,2),z=e=>{if(K.test(e)){const[s,t,n]=e.split("/").map(Number);return new Date(n,t-1,s)}if(J.test(e)){const[s,t]=e.split(" "),[n,i,a]=s.split("/").map(Number),[r,o,c]=t.split(":").map(Number),u=new Date(a,i-1,n);return u.setHours(r,o,c),u}if(Q.test(e)){const[s,t]=e.split(" "),[n,i,a]=s.split("/").map(Number),[r,o]=t.split("h").map(Number),c=new Date(parseInt(`${W}${a}`),i-1,n);return c.setHours(r,o),c}throw new E("decodePronoteDate")},Y=e=>({id:e.N,name:e.L,startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V)}),Z=e=>({id:e.N,kind:e.G,name:e.L,startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V)}),X=async(e,s=null)=>{const t=i.default.pki.rsa.setPublicKey(new i.default.jsbn.BigInteger(e.information.rsaModulus,16),new i.default.jsbn.BigInteger(e.information.rsaExponent,16)),n=e.information.aesIV;let a;a=e.information.rsaFromConstants?i.default.util.encode64(e.information.http?t.encrypt(n):n,64):i.default.util.encode64(t.encrypt(n));const r={identifiantNav:s,Uuid:a},o=new H(e,"FonctionParametres",{data:r,donnees:r}),c=await o.send();return(e=>{const s=new Map;for(const t of[1,2]){const n=m(e.General.DomainesFrequences[t].V);for(const i of n)s.set(i,{label:e.General.LibellesFrequences[t],fortnight:t})}return{version:e.General.versionPN.split(".").map(Number),nextBusinessDay:z(e.General.JourOuvre.V),firstMonday:z(e.General.PremierLundi.V),firstDate:z(e.General.PremiereDate.V),lastDate:z(e.General.DerniereDate.V),navigatorIdentifier:e.identifiantNav,endings:e.General.ListeHeuresFin.V.map((e=>e.L)),periods:e.General.ListePeriodes.map(Z),holidays:e.General.listeJoursFeries.V.map(Y),weekFrequencies:s,blocksPerDay:e.General.PlacesParJour}})(c.data.data||c.data.donnees)},ee=([e,s,t])=>e>2024||!(e<2024)&&(s>3||!(s<3)&&t>=9),se=e=>ee(e.instance.version)?{data:"data",signature:"Signature"}:{data:"donnees",signature:"_Signature_"},te=async(e,s)=>{const t=se(e),n=new H(e,"Identification",{[t.data]:{genreConnexion:0,genreEspace:e.information.accountKind,identifiant:s.username,pourENT:s.useCAS,enConnexionAuto:!1,enConnexionAppliMobile:s.reuseMobileAuthentication,demandeConnexionAuto:!1,demandeConnexionAppliMobile:s.requestFirstMobileAuthentication,demandeConnexionAppliMobileJeton:s.requestFromQRCode,uuidAppliMobile:s.deviceUUID,loginTokenSAV:""}});return(await n.send()).data[t.data]},ne=async(e,s)=>{const t=se(e),n=new H(e,"Authentification",{[t.data]:{connexion:0,challenge:s,espace:e.information.accountKind}}),i=(await n.send()).data[t.data];if("number"==typeof i.Acces&&0!==i.Acces)switch(i.Acces){case 1:throw new o;case 2:case 3:case 4:case 5:case 7:case 8:throw new u;case 6:case 10:throw new l;case 9:if(void 0!==i.AccesMessage){let e=i.AccesMessage.message??"(none)";throw i.AccesMessage.titre&&(e+=`${i.AccesMessage.titre} ${e}`),new c(e)}}return i},ie=(e,s)=>{const t=e.AvecDiscussion??!1,n=t&&!e.discussionInterdit,i=n&&(e.AvecDiscussionPersonnels??!1),a=n&&(e.AvecDiscussionParents??!1),r=n&&(e.AvecDiscussionEleves??!1),o=n&&(e.AvecDiscussionProfesseurs??!1),c=[];if(s.length>0){const e=s=>{"G"in s&&c.push(s.G),"Onglet"in s&&s.Onglet.forEach(e)};s.forEach(e)}return{canReadDiscussions:t,canDiscuss:n,canDiscussWithStaff:i,canDiscussWithParents:a,canDiscussWithStudents:r,canDiscussWithTeachers:o,hasAdvancedDiscussionEditor:e.AvecDiscussionAvancee??!1,maxAssignmentFileUploadSize:e.tailleMaxRenduTafEleve,tabs:c}},ae=(e,s,t={})=>{const n=e.L??"",i=e.G,a=e.N;let r;if(i===V.Link)r=e.url??n;else{const{iv:e,key:i}=q(s),o=JSON.stringify({N:a,Actif:!0,...t}),c=j.encrypt(o,i,e);r=`${s.information.url}/FichiersExternes/${c}/${encodeURIComponent(n)}?Session=${s.information.id}`}return{kind:i,name:n,url:r,id:a}},re=(e,s)=>{const t=e=>s.find((s=>s.id===e)),n=e.periodeParDefaut&&t(e.periodeParDefaut.V.N),i=e.listePeriodes.V.map((e=>t(e.N))).filter(Boolean);return{defaultPeriod:n,location:e.G,periods:i}},oe=(e,s)=>{let t;switch(s.information.accountKind){case M.STUDENT:case M.TEACHER:t=[e.ressource];break;case M.PARENT:t=e.ressource.listeRessources}return{id:e.ressource.N,kind:e.ressource.G,name:e.ressource.L,resources:t.map((e=>((e,s)=>{let t=null;e.avecPhoto&&(t=ae({G:1,N:e.N,L:"photo.jpg"},s));const n=new Map;for(const t of e.listeOngletsPourPeriodes?.V??[])n.set(t.G,re(t,s.instance.periods));return{id:e.N,kind:e.G,name:e.L,establishmentName:e.Etablissement.V.L,className:e.classeDEleve?.L,profilePicture:t,tabs:n,isDirector:e.estDirecteur??!1,isDelegate:e.estDelegue??!1,isMemberCA:e.estMembreCA??!1}})(e,s))),authorizations:ie(e.autorisations,e.listeOnglets)}},ce=e=>{const s=e.split(".");switch(s.pop(),s.pop()){case"eleve":return M.STUDENT;case"parent":return M.PARENT;case"professeur":return M.TEACHER;default:throw new E("decodeAccountKindFromPath")}};function ue(e,s){e.userResource="number"==typeof s?e.user.resources[s]:s}var le={fd:1,login:!0},de=async(e,s)=>{const t=r(s.url);e.information=await B({base:t,kind:s.kind,cookies:["appliMobile=1"],params:le},e.fetcher),e.instance=await X(e,s.navigatorIdentifier);const n=await te(e,{username:s.username,deviceUUID:s.deviceUUID,requestFirstMobileAuthentication:!1,reuseMobileAuthentication:!0,requestFromQRCode:!1,useCAS:!1});fe(s,"token",n);const i=me(n,s.username,s.token),a=he(e,n,i),o=await ne(e,a);if(ge(e,o,i),De(o))throw new f(o,n,s.username);return be(e,o,n,s.username)},pe=(e,s)=>de(e,{url:e.information.url,kind:e.information.accountKind,username:s.username,token:s.token,deviceUUID:s.deviceUUID,navigatorIdentifier:e.instance.navigatorIdentifier}),me=(e,s,t)=>{const n=i.default.md.sha256.create().update(e.alea??"").update(i.default.util.encodeUtf8(t)).digest().toHex().toUpperCase();return i.default.util.createBuffer(s+n)},fe=(e,s,t)=>{1===t.modeCompLog&&(e.username=e.username.toLowerCase()),1===t.modeCompMdp&&(e[s]=e[s].toLowerCase())},he=(e,s,t)=>{const n=i.default.util.createBuffer(e.information.aesIV);try{const e=i.default.util.decodeUtf8(j.decrypt(s.challenge,t,n)),a=new Array(e.length);for(let s=0;s<e.length;s+=1)s%2==0&&a.push(e.charAt(s));const r=i.default.util.encodeUtf8(a.join(""));return j.encrypt(r,t,n)}catch{throw new o}},ge=(e,s,t)=>{const n=i.default.util.createBuffer(e.information.aesIV),a=j.decrypt(s.cle,t,n).split(",").map((e=>String.fromCharCode(parseInt(e)))).join("");e.information.aesKey=a},De=e=>Boolean(e.actionsDoubleAuth),be=async(e,s,t,n)=>(e.user=await(async e=>{const s=new H(e,"ParametresUtilisateur",{}),t=await s.send();return oe(t.data[se(e).data],e)})(e),ue(e,0),{token:s.jetonConnexionAppliMobile,username:t.login??n,kind:e.information.accountKind,url:e.information.url,navigatorIdentifier:e.instance.navigatorIdentifier}),we=(e,s,t)=>{e.kind===_.TextInput||e.kind===_.InformationText?e.textInputAnswer=s:(e.selectedAnswers=s,e.textInputAnswer=t),e.answered=void 0!==s,e.answerDate=e.answered?new Date:void 0},Ce=(e,s)=>{const t=e.instance.blocksPerDay,n=Math.floor(s.blockPosition/t);let i=s.blockPosition+s.blockLength-1;return Math.floor(i/t)!==n&&(i=n*t+t-1),i},Ae=(e,s,t,n)=>{const i=[t],a=s.blockPosition,r=Ce(e,s);for(let e=a;e<=r;e++){const s=n[e];void 0!==s&&(s===t||i.includes(s)||i.push(s))}return i},Ee=(e,s)=>{const t={};for(let n=0;n<s.length;n++){const i=s[n];i.weekNumber in t||(t[i.weekNumber]=[]);const a=t[i.weekNumber],r=i.blockPosition,o=Ce(e,i);if(!1!==i._visible)for(let t=r;t<=o;t++){if(void 0!==a[t]){const t=Ae(e,i,n,a);let r=!1,o=!1;for(let e=0;e<t.length;e++){const n=s[t[e]];o||(o=!("lesson"===n.is&&n.canceled)),r||(r="lesson"===n.is&&n.canceled)}if(o&&r)for(let e=0;e<t.length;e++){const n=s[t[e]];if(n&&"lesson"===n.is&&n.canceled)return n._visible=!1,!0}break}a[t]=n}}return!1},ve=async e=>{let s;s=ee(e.instance.version)?new H(e,"Navigation",{Signature:{onglet:G.Presence},data:{onglet:G.Presence,ongletPrec:G.Presence}}):new H(e,"Presence",{_Signature_:{onglet:G.Presence}}),await s.send()},ye=e=>{e.presence&&(clearInterval(e.presence),e.presence=null)},Me=class{queue=[];pendingPromise=!1;push(e){return new Promise(((s,t)=>{this.queue.push({promise:e,resolve:s,reject:t}),this.pendingPromise||this.dequeue()}))}dequeue(){if(this.pendingPromise)return!1;const e=this.queue.shift();return!!e&&(this.pendingPromise=!0,e.promise().then((s=>{e.resolve(s),this.pendingPromise=!1,this.dequeue()})).catch((s=>{e.reject(s),this.pendingPromise=!1,this.dequeue()})),!0)}},xe=e=>e.getTime()+60*e.getTimezoneOffset()*1e3,Ve=e=>new Date(xe(e)),Pe=(e,s)=>{const t=Math.floor((xe(e)-xe(s))/864e5);return 1+Math.floor(t/7)},Se=-1e3,Ne=()=>Se-=1,Ie=class{constructor(e,s,t,n){this.session=e,this.functionName=s,this.fileName=n,e.information.order++;const{iv:i,key:a}=q(e);this.order=j.encrypt(e.information.order.toString(),a,i);const r=new FormData;r.append("numeroOrdre",this.order),r.append("numeroSession",e.information.id.toString()),r.append("nomRequete",s),r.append("idFichier",this.id),r.append("md5",""),r.append("files[]",t,n),this.form=r,this.url=e.information.url+`/uploadfilesession/${e.information.accountKind}/${e.information.id}`,this.headers["Content-Disposition"]=`attachment; filename="${encodeURI(n)}"`}order;id=`selecfile_1_${Date.now()}`;url;form;headers={};async send(){const e=await new Response(this.form).text();this.headers["Content-Type"]=`multipart/form-data; boundary=${e.split("\n")[0].slice(2)}`;let s=3;for(;3===s;){const t=await this.session.fetcher({url:new URL(this.url),method:"POST",content:e,headers:this.headers});s=JSON.parse(t.content).etat}if(this.session.information.order++,0===s||2===s)throw new y}},Le=e=>({id:e.N,name:e.L,inGroups:e.estServiceGroupe??!1}),Re=e=>({id:e.N,name:e.L,subject:Le(e.Matiere.V)}),Te=(e,s)=>({id:e.N,subject:Le(e.Matiere.V),description:e.descriptif.V,backgroundColor:e.CouleurFond,done:e.TAFFait,deadline:z(e.PourLe.V),attachments:e.ListePieceJointe.V.map((e=>ae(e,s))),difficulty:e.niveauDifficulte,length:e.duree,themes:e.ListeThemes.V.map((e=>Re(e))),return:{kind:e.genreRendu??x.None,canUpload:e.peuRendre??!1,uploaded:e.documentRendu&&ae(e.documentRendu.V,s)},resourceID:e.cahierDeTextes?.V.N}),ke=async(e,s,t,n)=>{const i=se(e),a=new H(e,"PageCahierDeTexte",{[i.signature]:{onglet:s},[i.data]:{domaine:{_T:8,V:"number"==typeof n?`[${t}..${n}]`:`[${t}]`}}});return(await a.send()).data[i.data]},Oe=async(e,s,t,n)=>{t=Ve(t),n=Ve(n);const i=Pe(t,e.instance.firstMonday),a=Pe(n,e.instance.firstMonday);return ke(e,s,i,a)},Fe=(e,s)=>s.ListeTravauxAFaire.V.map((s=>Te(s,e))),_e=async(e,s,t)=>{let n;switch(s){case P.brouillon:n={commande:s,brouillon:"number"==typeof t.id?{E:k.CREATION,N:t.id}:{E:k.MODIFICATION,N:t.id},contenu:t.content,messagePourReponse:{G:0,N:t.replyMessageID},listeDestinataires:[],listeFichiers:[],objet:""};break;case"":n={commande:s,bouton:{N:0,G:t.button},brouillon:{N:t.id},contenu:t.content,listeDestinataires:[],listeFichiers:[],messagePourReponse:{G:0,N:t.replyMessageID}};break;default:n={commande:s,listePossessionsMessages:t.possessions}}const i=se(e),a=new H(e,"SaisieMessage",{[i.signature]:{onglet:G.Discussions},[i.data]:n});await a.send()},Ue=e=>({id:e.N,name:e.L,kind:e.G}),Ge=async(e,s={_:[]})=>{const t=se(e),n=new H(e,"ListeMessagerie",{[t.signature]:{onglet:G.Discussions},[t.data]:{avecLu:!0,avecMessage:!0,possessionMessageDiscussionUnique:null}}),i=(await n.send()).data[t.data],a=i.listeEtiquettes.V.map(Ue),r=i.listeMessagerie.V.filter((e=>{const s=0===(e.profondeur||0),t=e.messagePourParticipants?.V.N;return e.estUneDiscussion&&t&&s})).map((e=>((e,s,t)=>({cache:t,creator:e.initiateur,dateAsFrenchText:e.libelleDate,recipientName:e.public,participantsMessageID:e.messagePourParticipants.V.N,possessions:e.listePossessionsMessages.V,numberOfDrafts:e.nbBrouillons??0,subject:e.objet??"",numberOfMessages:e.nombreMessages??0,numberOfMessagesUnread:e.nbNonLus??0,closed:e.ferme??!1,folders:e.listeEtiquettes?.V.map((e=>s.find((s=>s.id===e.N)))).filter(Boolean)??[]}))(e,a,s)));s._.length=0,s._.push(...r);for(const e of s._)e.participantsMessageID in s?Object.assign(s[e.participantsMessageID],e):s[e.participantsMessageID]=e;for(const e in s)"_"!==e&&(s._.find((s=>s.participantsMessageID===e))||delete s[e]);return{folders:a,items:s._}},Be=e=>{const s=e.estHTML??!1;return{possessionID:e.possessionMessage.V.N,replyMessageID:e.messageSource.V.N,content:s?e.contenu.V:e.contenu,isHTML:s}},je=e=>{let s;switch(e){case"Professeur":s=T.Teacher;break;case"Personnel":s=T.Personal;break;default:s=T.Student}return s},qe=(e,s)=>{let t,n;return"Moi"!==e.public_gauche&&(t={name:e.public_gauche,kind:je(e.hint_gauche)}),"Moi"===e.public_droite?n=void 0:"string"==typeof e.public_droite&&(n={name:e.public_droite,kind:je(e.hint_droite)}),{id:e.N,content:e.estHTML?e.contenu.V:e.contenu,creationDate:z(e.date.V),author:t,receiver:n,partialVisibility:e.estUnAparte,amountOfRecipients:(e.nbPublic??1)+1,files:e.listeDocumentsJoints?.V.map((e=>ae(e,s)))??[]}},$e=(e,s,t)=>{const n=[],i=e.messageSource.V.N;if(e.listeMessagesPourContexte)for(const t of e.listeMessagesPourContexte.V){const e=qe(t,s);n.push(e)}let a=t.find((e=>e.id===i));return{...qe(e,s),transferredMessages:n,replyMessageID:i,replyingTo:a}},He=async(e,s,t=!1)=>{const n=se(e),i=new H(e,"ListeMessages",{[n.signature]:{onglet:G.Discussions},[n.data]:{listePossessionsMessages:s.possessions,marquerCommeLu:t,nbMessagesVus:0}}),a=((e,s)=>{const t=e.brouillon,n=[],i=[],a=e.messagePourReponse.V.N;for(const t of e.listeMessages.V)t.brouillon?i.push(Be(t)):n.push($e(t,s,n));if(n.sort(((e,s)=>s.creationDate.getTime()-e.creationDate.getTime())),t){const e=t.V.estHTML??!1;i.push({isHTML:e,content:e?t.V.contenu:t.V.contenu.V,possessionID:t.V.N,replyMessageID:a})}const r=e.listeBoutons.V.find((e=>e.L.startsWith("Envoyer")))?.G;return{sents:n,drafts:i,defaultReplyMessageID:a,sendAction:r,canIncludeStudentsAndParents:r===S.ReplyEveryoneExceptParentsAndStudents||r===S.SendEveryoneExceptParentsAndStudents}})((await i.send()).data[n.data],e);return s.messages?Object.assign(s.messages,a):s.messages=a,a},Ke=e=>({id:e.N,name:e.L,kind:e.G,disallowMessages:e.refusMess??!1}),Je=(e,s)=>(e===S.SendEveryoneExceptParentsAndStudents&&s&&(e=S.SendEveryone),e===S.ReplyEveryoneExceptParentsAndStudents&&s&&(e=S.ReplyEveryone),e),Qe=e=>({id:e.N,level:e.L,abbreviation:e.abbreviation,coefficient:e.coefficient,domainID:e.domaine.V.N,domainName:e.domaine.V.L,itemID:e.item?.V.N,itemName:e.item?.V.L,order:e.ordre,pillarID:e.pilier.V.N,pillarName:e.pilier.V.L,pillarPrefixes:e.pilier.V.strPrefixes.split(",").map((e=>e.trim()))}),We=e=>{const s=e.listeNiveauxDAcquisitions.V.map(Qe);return s.sort(((e,s)=>e.order-s.order)),{skills:s,name:e.L,id:e.N,teacher:e.individu.V.L,coefficient:e.coefficient,description:e.descriptif,subject:Le(e.matiere.V),levels:e.listePaliers.V.map((e=>e.L)),date:z(e.date.V)}},ze=e=>({N:e.id,G:e.kind,L:e.name}),Ye=e=>e*Math.PI/180,Ze=e=>(e=>e*e)(Math.sin(e/2)),Xe=(e,s)=>{const t=Ye(e[0]),n=Ye(s[0]),i=Ye(e[1]),a=Ye(s[1]),r=Ze(n-t)+Math.cos(t)*Math.cos(n)*Ze(a-i);return 12756274*Math.asin(Math.sqrt(r))},es=async(e,s)=>{const t=se(e),n=new H(e,"GenerationPDF",{[t.data]:{avecCodeCompetences:!1,genreGenerationPDF:2,options:{adapterHauteurService:!1,desEleves:!1,gererRectoVerso:!1,hauteurServiceMax:15,hauteurServiceMin:10,piedMonobloc:!0,portrait:!0,taillePolice:6.5,taillePoliceMin:5,taillePolicePied:6.5,taillePolicePiedMin:5},periode:ze(s)},[t.signature]:{onglet:G.Gradebook}}),i=await n.send();return e.information.url+"/"+encodeURI(i.data[t.data].url.V)},ss=e=>{let s,t=O.Grade;if("string"==typeof e)e.split("|").length>=2&&(t=parseInt(e.split("|")[1])),s=parseFloat(e.replace(",",".")),t!==O.AbsentZero&&t!==O.UnreturnedZero||(s=0);else{if("number"!=typeof e)throw new E("decodeGradeValue");s=e}return{kind:t,points:s}},ts=e=>({student:e.moyEleve&&ss(e.moyEleve.V),outOf:e.baremeMoyEleve&&ss(e.baremeMoyEleve.V),defaultOutOf:e.baremeMoyEleveParDefaut&&ss(e.baremeMoyEleveParDefaut.V),class_average:e.moyClasse&&ss(e.moyClasse.V),min:e.moyMin&&ss(e.moyMin.V),max:e.moyMax&&ss(e.moyMax.V),subject:Le(e),backgroundColor:e.couleur}),ns=(e,s)=>({grades:e.listeDevoirs.V.map((e=>((e,s)=>{const t=e.N,n=e.estBonus,i=(n,i)=>e[n]&&ae({G:V.File,L:e[n],N:t},s,{G:i});return{id:t,value:ss(e.note.V),outOf:ss(e.bareme.V),defaultOutOf:ss(e.baremeParDefaut.V),date:z(e.date.V),subject:Le(e.service.V),average:e.moyenne&&ss(e.moyenne.V),max:e.noteMax&&ss(e.noteMax.V),min:e.noteMin&&ss(e.noteMin.V),coefficient:e.coefficient,comment:e.commentaire,commentaireSurNote:e.commentaireSurNote,isBonus:n,isOptional:e.estFacultatif&&!n,isOutOf20:e.estRamenerSur20,subjectFile:i("libelleSujet","DevoirSujet"),correctionFile:i("libelleCorrige","DevoirCorrige")}})(e,s))),subjectsAverages:e.listeServices.V.map(ts),classAverage:e.moyGeneraleClasse&&ss(e.moyGeneraleClasse.V),overallAverage:e.moyGenerale&&ss(e.moyGenerale.V)}),is=e=>`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()} ${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}`,as=e=>({description:e.commentaire,name:e.L,url:e.url}),rs=e=>({name:e.libellePorteMonnaie,description:e.hintPorteMonnaie,warning:e.avecWarning,balance:parseInt(e.valeurSolde.replace(",",".")),balanceDescription:e.hintSolde}),os=e=>({sso:e.SSO}),cs=e=>{const s=[];let t,n;var i;"partenaireARD"in e&&(i=e.partenaireARD,n={...os(i),canRefreshData:i.avecActualisation,wallets:i.porteMonnaie.V.map(rs)});for(const n of e.lienUtile.listeLiens.V)"SSO"in n?"TURBOSELF"===n.SSO.codePartenaire&&(t=os(n)):s.push(as(n));return{partnerARD:n,partnerTurboself:t,links:s}},us=e=>({name:e.L,color:e.couleur}),ls=e=>({name:e.L,color:e.couleur}),ds=e=>({name:e.L,allergens:e.listeAllergenesAlimentaire.V.map(us),labels:e.listeLabelsAlimentaires.V.map(ls)}),ps=e=>{let s=e.ListeRepas.V.reduce(((e,s)=>{let t;switch(s.G){case F.Lunch:t="lunch";break;case F.Dinner:t="dinner";break;default:throw new E("decodeMenu")}return e[t]=(e=>{const s=e.ListePlats.V.reduce(((e,s)=>{let t;switch(s.G){case N.Entry:t="entry";break;case N.Main:t="main";break;case N.Side:t="side";break;case N.Drink:t="drink";break;case N.Fromage:t="fromage";break;case N.Dessert:t="dessert";break;default:throw new E("decodeMeal")}return e[t]=s.ListeAliments.V.map(ds),e}),{});return{name:e.L,...s}})(s),e}),{});return{date:z(e.Date.V),...s}},ms=e=>({id:e.N,name:e.L,from:e.libelleMatiere}),fs=(e,s)=>({id:e.N,name:e.L,sub:s}),hs=e=>{const s=[];if(e.listeRessources){const t=e.listeRessources.V.filter((e=>e.estUneSousMatiere)).map(ms);for(const n of e.listeRessources.V)n.estUneSousMatiere||s.push(fs(n,t.filter((e=>e.from===n.L))))}return{id:e.N,name:e.L,kind:e.G,subjects:s,function:e.fonction&&(t=e.fonction.V,{id:t.N,name:t.L}),isPrincipal:e.estPrincipal??!1};var t},gs=e=>{if(0===e.length)return"[]";const s=[...e].sort(((e,s)=>e-s)),t=[];let n=s[0],i=n;for(let e=1;e<s.length;e++)s[e]-n!=1&&(i===n?t.push(i.toString()):t.push(`${i}..${n}`),i=s[e]),n=s[e];return i===n?t.push(i.toString()):t.push(`${i}..${n}`),`[${t.join(",")}]`},Ds=async(e,s,t={delete:!1,markAsRead:!0,onlyMarkAsRead:!1})=>{const n=se(e),i=t.onlyMarkAsRead||t.delete?[]:"information"===s.is?[s.question]:s.questions,a=new H(e,"SaisieActualites",{[n.signature]:{onglet:G.News},[n.data]:{listeActualites:[{N:s.id,L:s.title??"",genrePublic:s.public.G,public:s.public,validationDirecte:!0,listeQuestions:i.map((e=>({N:e.id,L:e.fullTitle,genreReponse:e.kind,reponse:{N:parseInt(e.answerID),Actif:!0,valeurReponse:e.kind===_.InformationText||e.kind===_.TextInput?e.textInputAnswer??"":{_T:8,V:gs(e.selectedAnswers??[])},valeurReponseLibre:e.choices.filter((e=>e.isTextInput)).length>0?e.textInputAnswer:void 0,avecReponse:e.answered,estReponseAttendue:e.shouldAnswer,_validationSaisie:!0}}))),marqueLueSeulement:!t.delete&&t.onlyMarkAsRead,lue:!t.delete&&t.markAsRead,supprimee:!t.onlyMarkAsRead&&t.delete,saisieActualite:!1}],saisieActualite:!1}});await a.send()},bs=async(e,s,t)=>{s.read!==t&&(await Ds(e,s,{onlyMarkAsRead:!0,markAsRead:t,delete:!1}),s.read=t)},ws=(e,s)=>({id:e.N,title:e.L,category:s.find((s=>s.id===e.categorie.V.N)),creationDate:z(e.dateCreation.V),startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V),author:e.auteur,public:e.public.V,read:e.lue}),Cs=e=>({value:e.L,position:e.rang,isTextInput:!!e.estReponseLibre}),As=(e,s)=>{const t=e.genreReponse,n=e.reponse.V.avecReponse;let i,a;return n&&e.reponse.V.valeurReponse&&("string"==typeof e.reponse.V.valeurReponse?a=e.reponse.V.valeurReponse:(i=m(e.reponse.V.valeurReponse.V),a=e.reponse.V.valeurReponseLibre)),{id:e.N,fullTitle:e.L,title:e.titre,position:e.rang,kind:t,maximumLength:e.tailleReponse,shouldRespectMaximumChoices:e.avecMaximum,maximumChoices:e.nombreReponsesMax,content:e.texte.V,attachments:e.listePiecesJointes.V.map((e=>ae(e,s))),answerID:e.reponse.V.N,answered:n,shouldAnswer:e.reponse.V.estReponseAttendue,answerDate:e.reponse.V.reponduLe?.V&&z(e.reponse.V.reponduLe.V),choices:t===_.TextInput?[]:e.listeChoix.V.map(Cs),selectedAnswers:i,textInputAnswer:a}},Es=(e,s,t)=>({is:"information",...ws(e,t),question:As(e.listeQuestions.V[0],s),get attachments(){return this.question.attachments},get acknowledged(){return this.question.answered},get acknowledgedDate(){return this.question.answerDate},get needToAcknowledge(){return this.question.shouldAnswer},get content(){return this.question.content}}),vs=e=>({id:e.N,name:e.L,default:e.estDefaut??!1}),ys=(e,s,t)=>({is:"survey",...ws(e,t),questions:e.listeQuestions.V.map((e=>As(e,s))),isAnonymous:e.reponseAnonyme}),Ms=e=>{const[s,t]=e.NbrHeures.split("h").map(Number),n=e.estMotifNonEncoreConnu;return{id:e.N,startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V),justified:e.justifie,opened:e.ouverte,hoursMissed:s,minutesMissed:t,daysMissed:e.NbrJours,shouldParentsJustify:e.aJustifierParParents,administrativelyFixed:e.reglee,isReasonUnknown:n,reason:!n&&e.listeMotifs.V[0].L}},xs=e=>{const s=e.estMotifNonEncoreConnu,t=e.justifie;return{id:e.N,date:z(e.date.V),minutes:e.duree,justified:t,justification:t&&e.justification,shouldParentsJustify:e.aJustifierParParents,administrativelyFixed:e.reglee,isReasonUnknown:s,reason:!s&&e.listeMotifs.V[0].L}},Vs=(e,s)=>({id:e.N,title:e.nature.V.L,reasons:e.listeMotifs.V.map((e=>e.L)),exclusion:e.estUneExclusion,isDuringLesson:!e.horsCours,workToDo:e.travailAFaire,workToDoDocuments:e.documentsTAF.V.map((e=>ae(e,s))),circumstances:e.circonstances,circumstancesDocuments:e.documentsCirconstances.V.map((e=>ae(e,s))),giver:e.demandeur.V.L,dateGiven:z(e.dateDemande.V),durationMinutes:e.duree}),Ps=e=>{let s;return"L"in e.matiere.V&&"0"!==e.matiere.V.N&&(s=Le(e.matiere.V)),{id:e.N,date:z(e.date.V),opened:e.estLue,shouldParentsJustify:e.avecARObservation,name:e.L,kind:e.genreObservation,sectionID:e.rubrique.V.N,subject:s,reason:e.commentaire}},Ss=(e,s)=>({id:e.N,title:e.nature.V.L,comments:e.commentaire,reasons:e.listeMotifs.V.map((e=>e.L)),exclusion:e.estUneExclusion,circumstances:e.circonstances,circumstancesDocuments:e.documentsCirconstances.V.map((e=>ae(e,s))),decisionMaker:e.decideur.V.L,giver:e.demandeur.V.L,dateGiven:z(e.dateDemande.V),startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V),disallowedAccesses:m(e.interditAcces.V)}),Ns=(e,s)=>({id:e.N,startDate:z(e.Date.V),endDate:z(e.DateFin.V),subject:Le(e.Matiere.V),haveAssignment:void 0!==e.dateTAF,assignmentDeadline:e.dateTAF?.V&&z(e.dateTAF.V),teachers:e.listeProfesseurs.V.map((e=>e.L)),groups:e.listeGroupes.V.map((e=>e.L)),backgroundColor:e.CouleurFond,contents:e.listeContenus.V.map((e=>((e,s)=>({id:e.N,title:e.L,description:e.descriptif.V,category:e.categorie.V.G,categoryText:e.categorie.V.L,files:e.ListePieceJointe.V.map((e=>ae(e,s))),themes:e.ListeThemes.V.map((e=>Re(e))),educativeValue:e.parcoursEducatif}))(e,s)))}),Is=(e,s)=>s.ListeCahierDeTextes.V.map((s=>Ns(s,e))),Ls=(e,s)=>({[e]:s,[e[0].toUpperCase()+e.substring(1)]:s}),Rs=(e,s)=>{const t=z(e.DateDuCours.V),n=e.place,i=e.duree;let a;if("string"==typeof e.DateDuCoursFin?.V)a=z(e.DateDuCoursFin.V);else{const e=(({instance:{endings:e}},s)=>{s>e.length&&(s%=e.length-1);const t=e[s],[n,i]=t.split("h").map(Number);return{hours:n,minutes:i}})(s,n%s.instance.blocksPerDay+i-1);a=new Date(t),a.setHours(e.hours,e.minutes)}return{id:e.N,backgroundColor:e.CouleurFond,notes:e.memo,startDate:t,endDate:a,blockLength:i,blockPosition:n,weekNumber:Pe(t,s.instance.firstMonday)}},Ts=(e,s)=>({absences:e.absences,withCanceledClasses:e.avecCoursAnnule??!0,classes:(e.ListeCours??[]).map((e=>(e=>"estSortiePedagogique"in e&&e.estSortiePedagogique)(e)?((e,s)=>({is:"activity",...Rs(e,s),title:e.motif,attendants:e.accompagnateurs,resourceTypeName:e.strGenreRess,resourceValue:e.strRess}))(e,s):(e=>"estRetenue"in e&&void 0!==e.estRetenue)(e)?((e,s)=>{let t;const n=[],i=[],a=[];if("ListeContenus"in e)for(const s of e.ListeContenus.V){const e=s.L;if(s.estHoraire)t=e;else if("G"in s)switch(s.G){case 3:i.push(e);break;case 34:n.push(e);break;case 17:a.push(e)}}return{is:"detention",...Rs(e,s),title:t,personalNames:n,teacherNames:i,classrooms:a}})(e,s):((e,s)=>{const t=[],n=[],i=[],a=[],r=[];let o,c;if(e.listeVisios)for(const s of e.listeVisios.V)t.push(s.url);if(e.ListeContenus)for(const s of e.ListeContenus.V)switch(s.G){case 16:o=Le(s);break;case 3:n.push(s.L);break;case 34:i.push(s.L);break;case 17:a.push(s.L);break;case 2:r.push(s.L)}return e.AvecCdT&&e.cahierDeTextes&&(c=e.cahierDeTextes.V.N),{is:"lesson",...Rs(e,s),kind:e.G,status:e.Statut,canceled:e.estAnnule??!1,exempted:e.dispenseEleve??!1,test:e.cahierDeTextes?.V.estDevoir??!1,virtualClassrooms:t,personalNames:i,teacherNames:n,classrooms:a,groupNames:r,subject:o,lessonResourceID:c}})(e,s))).sort(((e,s)=>e.startDate.getTime()-s.startDate.getTime()))}),ks=async(e,s={})=>{const t=se(e),n=new H(e,"PageEmploiDuTemps",{[t.signature]:{onglet:G.Timetable},[t.data]:{estEDTAnnuel:!1,estEDTPermanence:!1,avecAbsencesEleve:!1,avecRessourcesLibrePiedHoraire:!1,avecAbsencesRessource:!0,avecInfosPrefsGrille:!0,avecConseilDeClasse:!0,avecCoursSortiePeda:!0,avecDisponibilites:!0,avecRetenuesEleve:!0,edt:{G:16,L:"Emploi du temps"},...Ls("ressource",(i=e.userResource,{G:i.kind,L:i.name,N:i.id})),...s}});var i;const a=await n.send();return Ts(a.data[t.data],e)};exports.AccessDeniedError=u,exports.AccountDisabledError=l,exports.AccountKind=M,exports.AssignmentDifficulty={None:0,Easy:1,Medium:2,Hard:3},exports.AssignmentReturnKind=x,exports.AttachmentKind=V,exports.AuthenticateError=c,exports.BadCredentialsError=o,exports.BusyPageError=w,exports.DiscussionActionError=d,exports.DiscussionCommand=P,exports.DiscussionFolderKind={OCEM_Utilisateur:0,OCEM_Pre_Reception:1,OCEM_Pre_Archive:2,OCEM_Pre_Envoye:3,OCEM_Pre_Brouillon:4,OCEM_Pre_Poubelle:5,OCEM_Pre_Signalement:6,OCEM_Expl_Bleu:7,OCEM_Expl_Vert:8,OCEM_Expl_Rouge:9,OCEM_Pre_CarnetLiaison:10,OCEM_Pre_Alerte:11,OCEM_Pre_ContactVS:12,OCEM_Pre_Conversation:13,OCEM_Pre_InvisiblePlageDesactivee:14},exports.DiscussionMessagesMissingError=p,exports.DiscussionSendAction=S,exports.DishKind=N,exports.DocumentFileFormat={UNKNOWN:0,TEXT:1,PDF:2,EXCEL:3,ARCHIVE:4,IMAGE:5,SOUND:6,VIDEO:7,DIAPORAMA:8,GEOGEBRA:9},exports.DocumentKind=I,exports.DoubleAuthClientAction=L,exports.DoubleAuthMode={MGDA_PasEncoreChoisi:0,MGDA_Inactive:1,MGDA_NotificationSeulement:2,MGDA_SaisieCodePIN:3},exports.DoubleAuthServerAction=R,exports.EntityKind=T,exports.EntityState=k,exports.GradeKind=O,exports.MealKind=F,exports.NewsQuestionKind=_,exports.NewsView={Reception:0,Broadcast:1,Draft:2,Template:3},exports.NotebookObservationKind={LogBookIssue:0,Observation:1,Encouragement:2,Other:3},exports.PageUnavailableError=b,exports.RateLimitedError=C,exports.ResourceContentCategory={NONE:0,LESSON:1,CORRECTION:2,DST:3,ORAL_INTERROGATION:4,TD:5,TP:6,EVALUATION_COMPETENCES:7,EPI:8,AP:9,VISIO:12},exports.SecurityError=f,exports.SecuritySourceTooLongError=h,exports.ServerSideError=A,exports.SessionAccessKind=U,exports.SessionExpiredError=D,exports.SuspendedIPError=g,exports.TabLocation=G,exports.UnreachableError=E,exports.UploadFailedError=y,exports.UploadSizeError=v,exports.account=async e=>{const s=se(e),t=new H(e,"PageInfosPerso",{[s.signature]:{onglet:G.Account}});return((e,s)=>{const t=e.Informations;let n;return s.instance.version[0]>=2024&&(n=e.iCal?.liste.V[0]?.paramICal),{address:[t.adresse1,t.adresse2,t.adresse3,t.adresse4],postalCode:t.codePostal,province:t.province,country:t.pays,city:t.ville,email:t.eMail,phone:`+${t.indicatifTel}${t.telephonePortable}`,INE:t.numeroINE,iCalToken:n}})((await t.send()).data[s.data],e)},exports.assignmentRemoveFile=async(e,s)=>{const t=se(e),n=new H(e,"SaisieTAFARendreEleve",{[t.signature]:{onglet:G.Assignments},[t.data]:{listeFichiers:[{E:k.DELETION,TAF:{N:s}}]}});await n.send()},exports.assignmentStatus=async(e,s,t)=>{const n=se(e),i=new H(e,"SaisieTAFFaitEleve",{[n.signature]:{onglet:G.Assignments},[n.data]:{listeTAF:[{E:k.MODIFICATION,TAFFait:t,N:s}]}});await i.send()},exports.assignmentUploadFile=async(e,s,t,n)=>{const i=t.size||t.byteLength,a=e.user.authorizations.maxAssignmentFileUploadSize;if("number"==typeof i&&i>a)throw new v(a);const r=new Ie(e,"SaisieTAFARendreEleve",t,n);await r.send();const o=se(e),c=new H(e,"SaisieTAFARendreEleve",{[o.signature]:{onglet:G.Assignments},[o.data]:{listeFichiers:[{E:k.CREATION,G:I.FILE,L:n,N:Ne(),idFichier:r.id,TAF:{N:s}}]}});await c.send()},exports.assignmentsFromIntervals=async(e,s,t)=>{const n=await Oe(e,G.Assignments,s,t);return Fe(e,n).filter((e=>s<=e.deadline&&e.deadline<=t))},exports.assignmentsFromWeek=async(e,s,t)=>{const n=await ke(e,G.Assignments,s,t);return Fe(e,n)},exports.cleanURL=r,exports.clearPresenceInterval=ye,exports.createSessionHandle=(s=e.defaultFetcher)=>({information:null,instance:null,user:null,queue:new Me,fetcher:s,presence:null}),exports.discussionCreateDraft=async(e,s,t,n=s.messages?.defaultReplyMessageID)=>{await _e(e,P.brouillon,{id:Ne(),content:t,replyMessageID:n}),await Ge(e,s.cache),await He(e,s)},exports.discussionDelete=async(e,s)=>{await _e(e,P.Delete,{possessions:s.possessions}),await Ge(e,s.cache)},exports.discussionMessages=He,exports.discussionRead=async(e,s)=>{await He(e,s,!0)},exports.discussionRecipients=async(e,s)=>{const t=se(e),n=new H(e,"SaisiePublicMessage",{[t.signature]:{onglet:G.Discussions},[t.data]:{message:{N:s.participantsMessageID},estPublicParticipant:!0,estDestinatairesReponse:!1}});return(await n.send()).data[t.data].listeDest.V.map(Ke)},exports.discussionRemoteMutateDraft=async(e,s,t)=>{await _e(e,P.brouillon,{id:t.possessionID,content:t.content,replyMessageID:t.replyMessageID}),await Ge(e,s.cache),await He(e,s)},exports.discussionRemoveDraft=async(e,s,t)=>{await _e(e,P.Delete,{possessions:[{N:t.possessionID}]}),await Ge(e,s.cache),await He(e,s)},exports.discussionRestoreTrash=async(e,s)=>{await _e(e,P.Restore,{possessions:s.possessions}),await Ge(e,s.cache)},exports.discussionSendDraft=async(e,s,t,n=!1)=>{if(void 0===s.messages?.sendAction)throw new d;await _e(e,"",{button:Je(s.messages.sendAction,n),content:t.content,id:t.possessionID,replyMessageID:t.replyMessageID}),await Ge(e,s.cache),await He(e,s)},exports.discussionSendMessage=async(e,s,t,n=!1,i=s.messages?.defaultReplyMessageID)=>{if(!s.messages)throw new p;if(void 0===s.messages.sendAction)throw new d;const a=se(e),r=Je(s.messages.sendAction,n),o=new H(e,"SaisieMessage",{[a.data]:{contenu:e.user.authorizations.hasAdvancedDiscussionEditor?{_T:21,V:t}:t,bouton:{N:0,G:r},brouillon:{N:Ne(),E:k.CREATION},genreDiscussion:0,messagePourReponse:{G:0,N:i},listeFichiers:[]},[a.signature]:{onglet:G.Discussions}});await o.send(),await Ge(e,s.cache),await He(e,s)},exports.discussionTrash=async(e,s)=>{await _e(e,P.Trash,{possessions:s.possessions}),await Ge(e,s.cache)},exports.discussions=Ge,exports.evaluations=async(e,s)=>{const t=se(e),n=new H(e,"DernieresEvaluations",{[t.signature]:{onglet:G.Evaluations},[t.data]:{periode:ze(s)}});return(await n.send()).data[t.data].listeEvaluations.V.map(We)},exports.finishLoginManually=be,exports.frequency=(e,s)=>e.instance.weekFrequencies.get(s),exports.geolocation=async(s,t=e.defaultFetcher)=>{const n=`data={"nomFonction":"geoLoc","lat":"${s.latitude}","long":"${s.longitude}"}`,i=await t({url:new URL("https://www.index-education.com/swie/geoloc.php"),method:"POST",content:n,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});if("{}"===i.content)return[];const a=JSON.parse(i.content).map((e=>((e,s)=>{const t=parseFloat(e.lat),n=parseFloat(e.long);return{url:e.url.toLowerCase(),name:e.nomEtab.trim().replace("COLLEGE","COLLÈGE").replace("LYCEE","LYCÉE"),latitude:t,longitude:n,postalCode:parseInt(e.cp),distance:Xe(s,[t,n])}})(e,[s.latitude,s.longitude])));return a.sort(((e,s)=>e.distance>s.distance?1:e.distance<s.distance?-1:e.name>s.name?1:e.name<s.name?-1:0)),a},exports.gradebook=async(e,s)=>{const t=se(e);s={...s,kind:2};const n=new H(e,"PageBulletins",{[t.data]:{classe:{},eleve:{},periode:ze(s)},[t.signature]:{onglet:G.Gradebook}}),i=await n.send();return await(async(e,s,t)=>{if(0==Object.keys(t).length||t.message)throw new b;let n=t.ObjetListeAppreciations.V.ListeAppreciations.V.map((e=>({name:e.Intitule,value:e.L})));const i=t.ListeServices.V.map((e=>({subject:Le(e.Matiere?.V),subjectGroup:e.SurMatiere.V,coef:parseInt(e.Coefficient.V),averages:{student:parseFloat(e.MoyenneEleve.V.replace(",",".")),classOverall:parseFloat(e.MoyenneClasse.V.replace(",",".")),max:parseFloat(e.MoyenneSup.V.replace(",",".")),min:parseFloat(e.MoyenneInf.V.replace(",","."))},assessments:e.ListeAppreciations.V.map((e=>e.L)),teachers:e.ListeElements?.V.map((e=>e.ListeProfesseurs?.V.map((e=>e.L))))??e.ListeProfesseurs?.V.map((e=>e.L))??[]})));return{overallAssessments:n,graph:t?.graphe?.replace("\\n",""),subjects:i,url:await es(e,s)}})(e,s,i.data[t.data])},exports.gradebookPDF=es,exports.gradesOverview=async(e,s)=>{const t=se(e),n=new H(e,"DernieresNotes",{[t.signature]:{onglet:G.Grades},[t.data]:{Periode:ze(s)}}),i=await n.send();return ns(i.data[t.data],e)},exports.homepage=async(e,s=e.instance.nextBusinessDay)=>{const t=se(e),n=Pe(s,e.instance.firstMonday),i=is(s),a=new H(e,"PageAccueil",{[t.signature]:{onglet:G.Presence},[t.data]:{avecConseilDeClasse:!0,dateGrille:{_T:7,V:i},numeroSemaine:n,coursNonAssures:{numeroSemaine:n},personnelsAbsents:{numeroSemaine:n},incidents:{numeroSemaine:n},exclusions:{numeroSemaine:n},donneesVS:{numeroSemaine:n},registreAppel:{date:{_T:7,V:i}},previsionnelAbsServiceAnnexe:{date:{_T:7,V:i}},donneesProfs:{numeroSemaine:n},EDT:{numeroSemaine:n},TAFARendre:{date:{_T:7,V:i}},TAFEtActivites:{date:{_T:7,V:i}},partenaireCDI:{CDI:{}},tableauDeBord:{date:{_T:7,V:i}},modificationsEDT:{date:{_T:7,V:i}}}}),r=await a.send();return cs(r.data[t.data])},exports.instance=async(s,t=e.defaultFetcher)=>{s=r(s),s+="/infoMobileApp.json?id=0D264427-EEFC-4810-A9E9-346942A862A4";const n={url:new URL(s)},i=await t(n);return(e=>{let s,t;return e.CAS.actif&&(s=e.CAS.casURL,t=e.CAS.jetonCAS),{name:e.nomEtab,version:e.version,date:new Date(e.date),accounts:e.espaces.map((e=>({name:e.nom,path:e.URL}))),casURL:s,casToken:t}})(JSON.parse(i.content))},exports.loginCredentials=async(e,s)=>{const t=r(s.url);e.information=await B({base:t,kind:s.kind,cookies:[],params:{...le,bydlg:"A6ABB224-12DD-4E31-AD3E-8A39A1C2C335"}},e.fetcher),e.instance=await X(e,s.navigatorIdentifier);const n=await te(e,{username:s.username,deviceUUID:s.deviceUUID,requestFirstMobileAuthentication:!0,reuseMobileAuthentication:!1,requestFromQRCode:!1,useCAS:!1});fe(s,"password",n);const i=me(n,s.username,s.password),a=he(e,n,i),o=await ne(e,a);return ge(e,o,i),De(o)?pe(e,{token:o.jetonConnexionAppliMobile,username:n.login??s.username,deviceUUID:s.deviceUUID}):be(e,o,n,s.username)},exports.loginQrCode=async(e,s)=>{const t=(e=>{const s=e.url,t=s.lastIndexOf("/")+1,n=s.substring(0,t-1),i=s.substring(t);return{kind:ce(i),url:n,token:e.jeton,username:e.login}})(s.qr),n=i.default.util.createBuffer(s.pin),a=e=>j.decrypt(i.default.util.encodeUtf8(t[e]),n,i.default.util.createBuffer()),r={username:a("username"),token:a("token")};e.information=await B({base:t.url,kind:t.kind,cookies:["appliMobile=1"],params:le},e.fetcher),e.instance=await X(e,s.navigatorIdentifier);const o=await te(e,{username:r.username,deviceUUID:s.deviceUUID,requestFirstMobileAuthentication:!0,reuseMobileAuthentication:!1,requestFromQRCode:!0,useCAS:!1});fe(r,"token",o);const c=me(o,r.username,r.token),u=he(e,o,c),l=await ne(e,u);return ge(e,l,c),De(l)?pe(e,{token:l.jetonConnexionAppliMobile,username:o.login??r.username,deviceUUID:s.deviceUUID}):be(e,l,o,r.username)},exports.loginToken=de,exports.menus=async(e,s=new Date)=>{const t=se(e),n=new H(e,"PageMenus",{[t.signature]:{onglet:G.Menus},[t.data]:{date:{_T:7,V:is(s)}}}),i=await n.send();return{containsLunch:(a=i.data[t.data]).AvecRepasMidi,containsDinner:a.AvecRepasSoir,days:a.ListeJours.V.map(ps),weeks:m(a.DomaineDePresence.V),allergens:a.ListeAllergenes.V.map(us),labels:a.Listelabels.V.map(ls)};var a},exports.newDiscussion=async(e,s,t,n)=>{const i=se(e),a=new H(e,"SaisieMessage",{[i.signature]:{onglet:G.Discussions},[i.data]:{contenu:e.user.authorizations.hasAdvancedDiscussionEditor?{_T:21,V:t}:t,objet:s,estCreationCarnetLiaison:!1,listeFichiers:[],listeDestinataires:n.map((e=>({E:k.MODIFICATION,G:e.kind,N:e.id})))}});await a.send()},exports.newDiscussionRecipients=async(e,s)=>{const t=se(e),n=e.userResource,i=new H(e,"ListeRessourcesPourCommunication",{[t.signature]:{onglet:G.Discussions},[t.data]:{filtreElement:{G:n.kind,L:n.name,N:n.id},onglet:{N:0,G:s}}});return(await i.send()).data[t.data].listeRessources