@communecter/cocolight-api-client 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (()=>{"use strict";var e,t,o,n,r={3:e=>{e.exports=require("path")},27:(e,t,o)=>{o.d(t,{GN:()=>r,Ge:()=>i,u3:()=>n});class n{getAccessToken(){throw new Error("getAccessToken() doit être implémenté")}setAccessToken(e){throw new Error("setAccessToken() doit être implémenté")}getRefreshToken(){throw new Error("getRefreshToken() doit être implémenté")}setRefreshToken(e){throw new Error("setRefreshToken() doit être implémenté")}clear(){throw new Error("clear() doit être implémenté")}}class r extends n{constructor(){super(),this._accessToken=null,this._refreshToken=null}getAccessToken(){return this._accessToken}setAccessToken(e){this._accessToken=e}getRefreshToken(){return this._refreshToken}setRefreshToken(e){this._refreshToken=e}clear(){this._accessToken=null,this._refreshToken=null}}class i extends n{constructor(e="cocolight"){super(),this.prefix=e}getAccessToken(){return"undefined"!=typeof localStorage?localStorage.getItem(`${this.prefix}_accessToken`):null}setAccessToken(e){"undefined"!=typeof localStorage&&localStorage.setItem(`${this.prefix}_accessToken`,e)}getRefreshToken(){return"undefined"!=typeof localStorage?localStorage.getItem(`${this.prefix}_refreshToken`):null}setRefreshToken(e){"undefined"!=typeof localStorage&&localStorage.setItem(`${this.prefix}_refreshToken`,e)}clear(){"undefined"!=typeof localStorage&&(localStorage.removeItem(`${this.prefix}_accessToken`),localStorage.removeItem(`${this.prefix}_refreshToken`))}}},272:e=>{e.exports=require("stream")},366:e=>{e.exports=require("os")},383:e=>{e.exports=require("fs")}},i={};function s(e){var t=i[e];if(void 0!==t)return t.exports;var o=i[e]={exports:{}};return r[e](o,o.exports,s),o.exports}s.m=r,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(o,n){if(1&n&&(o=this(o)),8&n)return o;if("object"==typeof o&&o){if(4&n&&o.__esModule)return o;if(16&n&&"function"==typeof o.then)return o}var r=Object.create(null);s.r(r);var i={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&o;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>i[e]=()=>o[e]));return i.default=()=>o,s.d(r,i),r},s.d=(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,o)=>(s.f[o](e,t),t)),[])),s.u=e=>e+".cocolight-api-client.cjs",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},n="@communecter/cocolight-api-client:",s.l=(e,t,r,i)=>{if(o[e])o[e].push(t);else{var a,c;if(void 0!==r)for(var p=document.getElementsByTagName("script"),m=0;m<p.length;m++){var d=p[m];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==n+r){a=d;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",n+r),a.src=e),o[e]=[t];var l=(t,n)=>{a.onerror=a.onload=null,clearTimeout(u);var r=o[e];if(delete o[e],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((e=>e(n))),t)return t(n)},u=setTimeout(l.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=l.bind(null,a.onerror),a.onload=l.bind(null,a.onload),c&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;s.g.importScripts&&(e=s.g.location+"");var t=s.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var o=t.getElementsByTagName("script");if(o.length)for(var n=o.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=o[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=e})(),(()=>{var e={792:0};s.f.j=(t,o)=>{var n=s.o(e,t)?e[t]:void 0;if(0!==n)if(n)o.push(n[2]);else{var r=new Promise(((o,r)=>n=e[t]=[o,r]));o.push(n[2]=r);var i=s.p+s.u(t),a=new Error;s.l(i,(o=>{if(s.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var r=o&&("load"===o.type?"missing":o.type),i=o&&o.target&&o.target.src;a.message="Loading chunk "+t+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,n[1](a)}}),"chunk-"+t,t)}};var t=(t,o)=>{var n,r,[i,a,c]=o,p=0;if(i.some((t=>0!==e[t]))){for(n in a)s.o(a,n)&&(s.m[n]=a[n]);c&&c(s)}for(t&&t(o);p<i.length;p++)r=i[p],s.o(e,r)&&e[r]&&e[r][0](),e[r]=0},o=self.webpackChunk_communecter_cocolight_api_client=self.webpackChunk_communecter_cocolight_api_client||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var a={};s.r(a),s.d(a,{default:()=>G});var c={};s.r(c),s.d(c,{ApiAuthenticationError:()=>h,ApiClientError:()=>m,ApiError:()=>p,ApiResponseError:()=>u,ApiValidationError:()=>d,CircuitBreakerError:()=>l});class p extends Error{constructor(e,t,o){super(e),this.name="ApiError",this.status=t,this.details=o}}class m extends p{constructor(e,t,o){super(e,t,o),this.name="ApiClientError"}}class d extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiValidationError",this.status=t,this.messages=o,this.details=n}}class l extends p{constructor(e){super(e,503),this.name="CircuitBreakerError"}}class u extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiResponseError",this.status=t,this.responseData=o,this.details=n}}class h extends p{constructor(e,t,o){super(e,t,o),this.name="ApiAuthenticationError"}}const y=class{constructor(e){this.apiClient=e}get isConnected(){return this.apiClient.isConnected}get userId(){return this.apiClient.userId}async call(e,t={}){return this.apiClient.safeCall((async()=>{const o=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(o),o.data}))}async callNoConnected(e,t={}){if(this.isConnected)throw new h("Vous ne devez pas être connecté pour faire cette action.");return this.call(e,t)}async callIsConnected(e,t={}){if(!this.isConnected)throw new h("Vous devez être connecté pour effectuer cette action.");return this.call(e,t)}async personRegister(e={}){return this.callNoConnected("PERSON_REGISTER",e)}async authenticateUrl(e={}){return this.callNoConnected("AUTHENTICATE_URL",e)}async refreshTokenUrl(e={}){return this.call("REFRESH_TOKEN_URL",e)}async meInfoUrl(e={}){return this.callIsConnected("ME_INFO_URL",e)}async passwordRecovery(e={}){return this.callNoConnected("PASSWORD_RECOVERY",e)}async serverExchangeToken(e={}){return this.callIsConnected("SERVER_EXCHANGE_TOKEN",e)}async changePassword(e={}){return this.callIsConnected("CHANGE_PASSWORD",e)}async deleteAccount(e={}){return this.callIsConnected("DELETE_ACCOUNT",e)}async updateSettings(e={}){return this.callIsConnected("UPDATE_SETTINGS",e)}async updateBlockDescription(e={}){return this.callIsConnected("UPDATE_BLOCK_DESCRIPTION",e)}async updateBlockInfo(e={}){return this.callIsConnected("UPDATE_BLOCK_INFO",e)}async updateBlockSocial(e={}){return this.callIsConnected("UPDATE_BLOCK_SOCIAL",e)}async updateBlockLocality(e={}){return this.callIsConnected("UPDATE_BLOCK_LOCALITY",e)}async updateBlockSlug(e={}){return this.callIsConnected("UPDATE_BLOCK_SLUG",e)}async check(e={}){return this.callIsConnected("CHECK",e)}async profilImage(e={}){return this.callIsConnected("PROFIL_IMAGE",e)}async getElementsAbout(e={}){return this.call("GET_ELEMENTS_ABOUT",e)}async multiconnect(e={}){return this.callIsConnected("MULTICONNECT",e)}async getNews(e={}){return this.call("GET_NEWS",e)}async getNewsById(e={}){return this.call("GET_NEWS_BY_ID",e)}async addNews(e={}){return this.callIsConnected("ADD_NEWS",e)}async addImageNews(e={}){return this.callIsConnected("ADD_IMAGE_NEWS",e)}async addFileNews(e={}){return this.callIsConnected("ADD_FILE_NEWS",e)}async deleteNews(e={}){return this.callIsConnected("DELETE_NEWS",e)}async updateNews(e={}){return this.callIsConnected("UPDATE_NEWS",e)}async shareNews(e={}){return this.callIsConnected("SHARE_NEWS",e)}async getComments(e={}){return this.call("GET_COMMENTS",e)}async addComments(e={}){return this.callIsConnected("ADD_COMMENTS",e)}async deleteComments(e={}){return this.callIsConnected("DELETE_COMMENTS",e)}async updateComments(e={}){return this.callIsConnected("UPDATE_COMMENTS",e)}async searchTags(e={}){return this.call("SEARCH_TAGS",e)}async showVote(e={}){return this.call("SHOW_VOTE",e)}async globalAutocomplete(e={}){return this.call("GLOBAL_AUTOCOMPLETE",e)}async cityAutocomplete(e={}){return this.call("CITY_AUTOCOMPLETE",e)}async suggestionInput(e={}){return this.call("SUGGESTION_INPUT",e)}async getProjectsNoAdmin(e={}){return this.call("GET_PROJECTS_NO_ADMIN",e)}async getProjectsAdmin(e={}){return this.callIsConnected("GET_PROJECTS_ADMIN",e)}async getPoisNoAdmin(e={}){return this.call("GET_POIS_NO_ADMIN",e)}async getPoisAdmin(e={}){return this.callIsConnected("GET_POIS_ADMIN",e)}async getOrganizationsNoAdmin(e={}){return this.call("GET_ORGANIZATIONS_NO_ADMIN",e)}async getOrganizationsAdmin(e={}){return this.callIsConnected("GET_ORGANIZATIONS_ADMIN",e)}async getMembersNoAdmin(e={}){return this.call("GET_MEMBERS_NO_ADMIN",e)}async getMembersAdmin(e={}){return this.callIsConnected("GET_MEMBERS_ADMIN",e)}async getFriendsAdmin(e={}){return this.callIsConnected("GET_FRIENDS_ADMIN",e)}async getSubscriptions(e={}){return this.call("GET_SUBSCRIPTIONS",e)}async getSubscriptionsAdmin(e={}){return this.callIsConnected("GET_SUBSCRIPTIONS_ADMIN",e)}async getSubscribers(e={}){return this.call("GET_SUBSCRIBERS",e)}async getSubscribersAdmin(e={}){return this.callIsConnected("GET_SUBSCRIBERS_ADMIN",e)}async getContributors(e={}){return this.call("GET_CONTRIBUTORS",e)}async getContributorsAdmin(e={}){return this.callIsConnected("GET_CONTRIBUTORS_ADMIN",e)}async getBadges(e={}){return this.call("GET_BADGES",e)}async getBadgesFilters(e={}){return this.call("GET_BADGES_FILTERS",e)}async connect(e={}){return this.callIsConnected("CONNECT",e)}async disconnect(e={}){return this.callIsConnected("DISCONNECT",e)}async getElementsKey(e={}){return this.call("GET_ELEMENTS_KEY",e)}async getFavoris(e={}){return this.callIsConnected("GET_FAVORIS",e)}async deleteFavoris(e={}){return this.callIsConnected("DELETE_FAVORIS",e)}async addFavoris(e={}){return this.callIsConnected("ADD_FAVORIS",e)}async addOrganization(e={}){return this.callIsConnected("ADD_ORGANIZATION",e)}async addProject(e={}){return this.callIsConnected("ADD_PROJECT",e)}async addPoi(e={}){return this.callIsConnected("ADD_POI",e)}async addEvent(e={}){return this.callIsConnected("ADD_EVENT",e)}async deletePoi(e={}){return this.callIsConnected("DELETE_POI",e)}async deleteEvent(e={}){return this.callIsConnected("DELETE_EVENT",e)}async deleteElement(e={}){return this.callIsConnected("DELETE_ELEMENT",e)}async addImageElement(e={}){return this.callIsConnected("ADD_IMAGE_ELEMENT",e)}},f={createDraftProxy:(e,t={},o={},n=[],r={},i={})=>new Proxy({},{get:(e,n)=>{const i=n in o?o[n]:t[n],s=r[n];return"function"==typeof s?s(i):i},set:(t,r,s)=>{if(!n.includes(r)){const t=`[DraftProxy] Le champ "${r}" n'est pas autorisé.`;if(i.throwOnError)throw new d(t,400,null,{field:r,value:s,allowedFields:n});return e._logger.warn(t),!1}return o[r]=s,!0},deleteProperty:(e,t)=>!!n.includes(t)&&(delete o[t],!0),has:(e,n)=>n in o||n in t,ownKeys:()=>[...new Set([...Object.keys(t),...Object.keys(o)])],getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})}),_extractWritableFields(e={},t={},o={defs:{},visited:new Set}){if(!e||"object"!=typeof e)return[];if(e.$id&&o.visited.has(e.$id))return[];e.$id&&o.visited.add(e.$id),o.defs=e.$defs||e.definitions||o.defs;const n=[];if(e.$ref){const r=e.$ref.replace(/^#\/?(\$defs|definitions)\//,""),i=o.defs?.[r];i&&n.push(...this._extractWritableFields(i,t,o))}if(e.allOf&&e.allOf.forEach((e=>n.push(...this._extractWritableFields(e,t,o)))),e.if&&e.then){const r=e.if?.properties;let i=!0;if(r)for(const e in r){const o=r[e]?.const;if(t[e]!==o){i=!1;break}}i&&e.then?n.push(...this._extractWritableFields(e.then,t,o)):!i&&e.else&&n.push(...this._extractWritableFields(e.else,t,o))}return e.properties&&n.push(...Object.entries(e.properties).filter((([e,t])=>!0!==t.readOnly&&void 0===t.const)).map((([e])=>e))),[...new Set(n)]},buildDraftAndProxy({data:e={},serverData:t=null,constant:o,apiClient:n,transforms:r={},throwOnError:i=!0,removeFields:s=[]}){const a=Array.isArray(o)?o:[o],c={allOf:[],$defs:{}};for(const e of a){const t=n.getRequestSchema(e);if(!t)throw new p(`Unable to find schema for ${e}.`);if(t.$defs)for(const[o,r]of Object.entries(t.$defs))c.$defs[o]?n._logger.warn(`Duplicate $defs key '${o}' from schema '${e}'`):c.$defs[o]=r;c.allOf.push(t)}const m={};let d=this._extractWritableFields(c,e);e.id&&-1===d.indexOf("id")&&d.push("id"),e.slug&&-1===d.indexOf("slug")&&d.push("slug"),d=d.filter((e=>!s.includes(e)));for(const t of d){const o=e[t],n="function"==typeof r[t]?r[t](o,e):o;void 0!==n&&(m[t]=n)}return{draft:m,proxy:this.createDraftProxy(n,t,m,d,r,{throwOnError:i})}},extractChangedFieldsFromSchema(e,t,o={},n,r=[]){const i=e.getRequestSchema(t);let s=this._extractWritableFields(i,o);const a={},c=n?.()||{};s=s.filter((e=>!r.includes(e)));for(const e of s){if(void 0===o[e])continue;const t=o[e],n=c[e];JSON.stringify(t)!==JSON.stringify(n)&&(a[e]=t)}return Object.keys(a).length>0?a:null}},g=require("bson-objectid"),w=require("file-type"),T={async call(e,t={}){return this.apiClient.safeCall((async()=>{const o=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(o),o.data}))},async callNoConnected(e,t={}){if(this.isConnected)throw new h("Vous devez ne devez pas être connecté pour faire cette action.");return this.call(e,t)},async callIsConnected(e,t={}){if(!this.isConnected)throw new h("Vous devez être connecté pour faire cette action.");return"function"==typeof e?await e():this.call(e,t)},async callIsMe(e,t={}){if(!this.isMe)throw new h("Vous devez être vous-même pour faire cette action.");return"function"==typeof e?await e():await this.callIsConnected(e,t)},async validateImage(e){return await this._validateUploadInput(e,{allowedMimeTypes:["image/jpeg","image/png","image/jpg"],expectedType:"image"})},async validateFile(e){return await this._validateUploadInput(e,{allowedMimeTypes:["application/pdf","text/plain","text/csv"],expectedType:"file"})},async _validateUploadInput(e,{allowedMimeTypes:t=[],expectedType:o="any"}){if(!e)throw new d("Le fichier est requis.");const n="undefined"==typeof window&&"undefined"!=typeof process;let r="",i=e;if("undefined"!=typeof File&&e instanceof File){if(r=e.type,!t.includes(r))throw new d("Le type du fichier est invalide.")}else if("undefined"!=typeof Blob&&e instanceof Blob){if(r=e.type,!t.includes(r))throw new d("Le type du fichier est invalide.");const o=r.split("/")[1]||"bin",n=`${Date.now()}.${o}`;i=new File([e],n,{type:r})}else if(n&&Buffer.isBuffer(e)){const n=await(0,w.fileTypeFromBuffer)(e);if(r=n?.mime,!n||!t.includes(r))throw new d("Le type du fichier est invalide.");if("image"===o){const t=n.ext,o=`${Date.now()}.${t}`;i=await this._createReadStreamFromBuffer(e,o,r)}}else{if(!n||!e?.readable||"function"!=typeof e._read)throw new d("Type de fichier non reconnu.");{const o=[],n=await this._passThrough(),s=await this._passThrough(),a=4100;let c=0;e.on("data",(e=>{c<a&&(o.push(e),c+=e.length)})),e.pipe(n).pipe(s),await new Promise((e=>setTimeout(e,10)));const p=Buffer.concat(o),m=await(0,w.fileTypeFromBuffer)(p);if(r=m?.mime,!m||!t.includes(r))throw new d("Le type du fichier est invalide.");s.path=`${Date.now()}.${m.ext}`,s.mimeType=r,i=s}}return i},async _createReadStreamFromBuffer(e,t="file.bin",o="application/octet-stream"){const n=await this._bufferToReadable(e);return n.path=t,n.mimeType=o,n},async _bufferToReadable(e){if("undefined"==typeof window){const{bufferToReadable:t}=await s.e(931).then(s.bind(s,931));return t(e)}throw new Error("bufferToReadable ne doit pas être appelé dans le navigateur")},async _passThrough(){if("undefined"==typeof window){const{createPassThrough:e}=await s.e(931).then(s.bind(s,931));return e()}throw new Error("passThrough ne doit pas être appelé dans le navigateur")},_omitProps(e,t){if(!e||"object"!=typeof e)return{};const o={...e};for(const e of t)delete o[e];return o},_pickProps(e,t,o={}){if(!e||"object"!=typeof e)return{};const n={};for(const r of t)if(r in e){const t=e[r];"function"==typeof o[r]?n[r]=o[r](t,e):n[r]=t}return n},_createFilteredProxy:e=>new Proxy(e,{get:(e,t,o)=>"string"!=typeof t||isNaN(t)?"length"===t?e.filter((e=>!e._isDeleted)).length:"function"==typeof e[t]?(...o)=>e.filter((e=>!e._isDeleted))[t](...o):Reflect.get(e,t,o):e.filter((e=>!e._isDeleted))[t]}),_newId:()=>(new g).toString()};class _{#e={};#t={};#o=null;static entityType="news";static SCHEMA_CONSTANTS=["ADD_NEWS"];constructor(e,t={},o={}){if(this.__entityTag="News",!o.EndpointApi)throw new p("EndpointApi class must be injected to avoid circular dependency.");if(!o.User)throw new p("User class must be injected.");if(!e)throw new p("Parent is required.");if(this.deps=o,this.EndpointApiClass=o.EndpointApi,"User"!==e?.__entityTag&&"Organization"!==e?.__entityTag&&"Project"!==e?.__entityTag)throw new p("Invalid parent for News.");this.apiClient=e.apiClient,this.parent=e,this.endpointApi="function"==typeof o.EndpointApi?new o.EndpointApi(this.apiClient):"object"==typeof o.EndpointApi?o.EndpointApi:(()=>{throw new p("deps.EndpointApi must be a class or instance.")})(),this.#o=null;const{draft:n,proxy:r}=this.buildDraftAndProxy({data:{...t,...this.defaultFields},serverData:this.#o,constant:_.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(n)),this.#e=n,this.data=r}get id(){return this.#e.id||null}get isConnected(){return this.apiClient.isConnected}get draftData(){return this.#e}get initialDraftData(){return this.#t}get serverData(){return this.#o}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.parent.id}_setData(e){this.#o={...e};const{draft:t,proxy:o}=this.buildDraftAndProxy({data:{...e,...this.defaultFields},serverData:this.#o,constant:_.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(t)),this.#e=t,this.data=o}getEntityType(){return _.entityType}static fromServerData(e,t,o){const n=new _(t,{},o);n.#o={...e};const{draft:r,proxy:i}=n.buildDraftAndProxy({data:{...e,...n.defaultFields},serverData:n.#o,constant:_.SCHEMA_CONSTANTS,apiClient:n.apiClient,transforms:n.transforms,removeFields:n.removeFields});return n.#e=r,n.data=i,n}async refresh(){if(!this.id)throw new p("Impossible de rafraîchir sans ID.");return this.get()}async get(){if(!this.id)throw new p("Impossible de rafraîchir sans ID.");const e=await this.callIsConnected((()=>this.endpointApi.getNewsById({ids:[this.id]})));if(e&&Array.isArray(e)&&1===e.length){const t=e[0];return this.#o={...t},this._setData(t),this.#o}throw new p(`Aucune actualité trouvée pour l'ID ${this.id}`)}async save(){if(!this.isConnected)throw new p("Impossible de sauvegarder sans être connecté.");""===this.#e?.text&&(this.#e.text=" ");const e={...this.#e};if(e.parentId=this.parent.id,e.parentType=this.parent.getEntityType(),this.id){e.id&&delete e.id;const t=await this.callIsConnected((()=>this.endpointApi.updateNews({...e,idNews:this.id})));return t?.object&&(this.#o={...t.object}),t}{const t=await this.callIsConnected((()=>this.endpointApi.addNews(e)));return this.#e.id=t.object.id,t?.object&&(this.#o={...t.object}),t}}async addMention({slug:e,id:t}){try{if(!e&&!t)throw new p("Vous devez fournir un slug ou un id pour ajouter une mention.");const o=new this.deps.User(this.apiClient,{id:t,slug:e},{EndpointApi:this.endpointApi}),n=o.serverData;if(this.#e.mentions||(this.#e.mentions=[]),this.#e.mentions.find((e=>e.id===n.id)))return this.#e.mentions=this.#e.mentions.map((e=>(e.id===n.id&&(e.count+=1),e))),this.#e.mentions;const r={id:n.id,slug:n.slug,type:o.getEntityType(),name:n.name,value:n.name,count:1};return this.#e.mentions.push(r),this.#e.mentions}catch(e){throw this.apiClient._logger.error("Erreur lors de l'ajout de la mention :",e),e}}async addImage(e){e=await this.validateImage(e);const t={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsImage:e},o=await this.callIsConnected((()=>this.endpointApi.addImageNews(t)));return this.#e.mediaImg?(this.#e.mediaImg.countImages=this.#e.mediaImg.countImages+1,this.#e.mediaImg.images.push(o.id)):this.#e.mediaImg={countImages:1,images:[o.id]},o}async addFile(e){e=await this.validateFile(e);const t={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsFile:e},o=await this.callIsConnected((()=>this.endpointApi.addFileNews(t)));return this.#e.mediaFile?(this.#e.mediaFile.countFiles=this.#e.mediaFile.countFiles+1,this.#e.mediaFile.files.push(o)):this.#e.mediaFile={countFiles:1,files:[o]},o}async delete(){if(!this.id)throw new p("Vous devez fournir un id pour supprimer une news.");const e={pathParams:{id:this.id}};await this.callIsConnected((()=>this.endpointApi.deleteNews(e))),this.#e={},this.#o=null,this.#e.id=null,this._isDeleted=!0}_updateInitialDraftSnapshot(){this.#t=JSON.parse(JSON.stringify(this.#e))}hasChanges(){return JSON.stringify(this.#e)!==JSON.stringify(this.#t)}defaultFields={};removeFields=[];transforms={scope:e=>e?.type,mentions:e=>Array.isArray(e)?e.map((e=>({...e,count:parseInt(e.count)}))):[],mediaImg:e=>{const t=e?.images?.map((e=>e.id)).filter(Boolean)||[];return t.length>0?{countImages:t.length,images:t}:void 0},mediaFile:e=>{const t=e?.files?.map((e=>e.id)).filter(Boolean)||[];return t.length>0?{countFiles:t.length,files:t}:void 0}}}Object.assign(_.prototype,T,f);const b={async get(){return this.apiClient.safeCall((async()=>{const e=await this.getPublicProfile();return this._setData(e),e}))},async updateSettings(e={}){return e.idEntity=this.id,e.typeEntity=this.getEntityType(),this.callIsConnected((()=>this.endpointApi.updateSettings(e)))},async updateDescription(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockDescription(e)))},async updateInfo(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockInfo(e)))},async updateSocial(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockSocial(e)))},async updateLocality(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockLocality(e)))},async updateSlug({slug:e}){try{await this.endpointApi.check({type:this.getEntityType(),id:this.id,slug:e})}catch(e){if(e instanceof u)throw new u("Erreur lors de la vérification du slug.",e.status,e.data);throw e}return this.callIsConnected((()=>this.endpointApi.updateBlockSlug({typeElement:this.getEntityType(),id:this.id,slug:e})))},async updateImageProfil({profil_avatar:e}){e=await this.validateImage(e);const t={pathParams:{folder:this.getEntityType(),ownerId:this.id},profil_avatar:e};return this.callIsConnected((()=>this.endpointApi.profilImage(t)))}},A={async resolveId(e){if(!this.id&&this.slug)try{const t=await this.endpointApi.getElementsKey({pathParams:{slug:this.slug}});if(!t?.contextId||t?.contextType!==e)throw new u(`Le slug ${this.slug} ne correspond pas à un ${e}`,200,t);this._id(t.contextId)}catch(t){throw t instanceof u?t?.responseData?.contextType!==e?t:new u(`Impossible de récupérer l'identifiant pour le slug ${this.slug}`,t.status,t.responseData):t}return this.id},async getPublicProfile(){return await this.resolveId(this.getEntityType()),this.endpointApi.getElementsAbout({pathParams:{id:this.id,type:this.getEntityType()}})}},E={async getNews(e={}){e.pathParams={type:this.getEntityType(),id:this.id};const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new u("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>this.deps.News.fromServerData(e,this,{User:this.deps.User,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)},async news(e){try{const t=new this.deps.News(this,e,{User:this.deps.User,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.getEntityType()}.news] Erreur lors de la création d'une instance news :`,e.message),e}}};class P{#e={};#t={};#o=null;static entityType="organizations";static SCHEMA_CONSTANTS=["ADD_ORGANIZATION","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static ADD_BLOCKS=new Map([["ADD_ORGANIZATION","addOrganization"],["PROFIL_IMAGE",""]]);static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);constructor(e,t={},o={}){if(this.__entityTag="Organization",!o.EndpointApi)throw new p("EndpointApi class must be injected to avoid circular dependency.");if(!o.User)throw new p("User class must be injected.");if(!o.Project)throw new p("Project class must be injected.");if(!o.News)throw new p("News class must be injected.");if(!e)throw new p("Parent is required.");if(this.deps=o,this.EndpointApiClass=o.EndpointApi,"ApiClient"===e?.__entityTag)this.apiClient=e,this.parent=null;else{if("User"!==e?.__entityTag)throw new p("Invalid parent for Organization.");this.apiClient=e.apiClient,this.parent=e}this.endpointApi="function"==typeof o.EndpointApi?new o.EndpointApi(this.apiClient):"object"==typeof o.EndpointApi?o.EndpointApi:(()=>{throw new p("deps.EndpointApi must be a class or instance.")})(),this.#o=null;const{draft:n,proxy:r}=this.buildDraftAndProxy({data:{...t,...this.defaultFields},serverData:this.#o,constant:P.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(n)),this.#e=n,this.data=r}get id(){return this.#e.id||null}_id(e){this.#e.id=e}get slug(){return this.#e.slug||null}get isConnected(){return this.apiClient.isConnected}_setData(e){this.#o={...e};const{draft:t,proxy:o}=this.buildDraftAndProxy({data:{...e,...this.defaultFields},serverData:this.#o,constant:P.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(t)),this.#e=t,this.data=o}get userId(){return this.apiClient.userId}get draftData(){return this.#e}get initialDraftData(){return this.#t}get serverData(){return this.#o}get isMe(){return this.isConnected&&this.userId===this.parent?.id}getEntityType(){return P.entityType}static fromServerData(e,t,o){const n=new P(t,{},o);n.#o={...e};const{draft:r,proxy:i}=n.buildDraftAndProxy({data:{...e,...n.defaultFields},serverData:n.#o,constant:P.SCHEMA_CONSTANTS,apiClient:n.apiClient,transforms:n.transforms,removeFields:n.removeFields});return n.#e=r,n.data=i,n}async refresh(){if(!this.id)throw new p("Impossible de rafraîchir sans ID.");return this.get()}async save(){if(!this.isConnected)throw new p("Impossible de sauvegarder sans être connecté.");const e={...this.#e};return this.id?(await this._update(e)&&await this.refresh(),this.#o):(await this._add(e),await this.refresh(),this.#o)}async _add(e){e.id=this._newId(),e.slug&&delete e.slug;for(const[t,o]of P.ADD_BLOCKS){const n=this.extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(n&&Object.keys(n).length>0){const e=await this[o](n);!this.id&&e?.map?.id&&(this.#e.id=e.map.id,this.#e.slug=e.map.slug)}}}async _update(e){e.id&&delete e.id;let t=!1;for(const[o,n]of P.UPDATE_BLOCKS){const r=this.extractChangedFieldsFromSchema(this.apiClient,o,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);r&&Object.keys(r).length>0&&(await this[n](r),t=!0)}return t}addOrganization(e={}){return this.callIsConnected((()=>this.endpointApi.addOrganization(e)))}_updateInitialDraftSnapshot(){this.#t=JSON.parse(JSON.stringify(this.#e))}hasChanges(){return JSON.stringify(this.#e)!==JSON.stringify(this.#t)}defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={github:(e,t)=>t?.socialNetwork?.github,gitlab:(e,t)=>t?.socialNetwork?.gitlab,facebook:(e,t)=>t?.socialNetwork?.facebook,twitter:(e,t)=>t?.socialNetwork?.twitter,instagram:(e,t)=>t?.socialNetwork?.instagram,diaspora:(e,t)=>t?.socialNetwork?.diaspora,mastodon:(e,t)=>t?.socialNetwork?.mastodon,telegram:(e,t)=>t?.socialNetwork?.telegram,signal:(e,t)=>t?.socialNetwork?.signal};async project(e={}){try{const t=new this.deps.Project(this,e,{User:this.deps.User,News:this.deps.News,EndpointApi:this.deps.EndpointApi});return(e.id||e.slug)&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.project] Erreur lors de la création d'une instance project :`,e.message),e}}}Object.assign(P.prototype,T,A,b,E,f);class I{#e={};#t={};#o=null;static entityType="projects";static SCHEMA_CONSTANTS=["ADD_PROJECT","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static ADD_BLOCKS=new Map([["ADD_PROJECT","addProject"],["PROFIL_IMAGE","updateImageProfil"]]);static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);constructor(e,t={},o={}){if(this.__entityTag="Project",!o.EndpointApi)throw new p("EndpointApi class must be injected to avoid circular dependency.");if(!o.User)throw new p("User class must be injected.");if(!o.News)throw new p("News class must be injected.");if(!e)throw new p("Parent is required.");if(this.deps=o,this.EndpointApiClass=o.EndpointApi,"ApiClient"===e?.__entityTag)this.apiClient=e,this.parent=null;else{if("User"!==e?.__entityTag&&"Organization"!==e?.__entityTag&&"Project"!==e?.__entityTag)throw new p("Invalid parent for Project.");this.apiClient=e.apiClient,this.parent=e}this.endpointApi="function"==typeof o.EndpointApi?new o.EndpointApi(this.apiClient):"object"==typeof o.EndpointApi?o.EndpointApi:(()=>{throw new p("deps.EndpointApi must be a class or instance.")})();const{draft:n,proxy:r}=this.buildDraftAndProxy({data:{...t,...this.defaultFields},serverData:this.#o,constant:I.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(n)),this.#e=n,this.data=r}get id(){return this.#e.id||null}_id(e){this.#e.id=e}get isConnected(){return this.apiClient.isConnected}get userId(){return this.apiClient.userId}get draftData(){return this.#e}get initialDraftData(){return this.#t}get serverData(){return this.#o}get isMe(){return this.isConnected&&this.userId===this.parent?.id}getEntityType(){return I.entityType}_updateInitialDraftSnapshot(){this.#t=JSON.parse(JSON.stringify(this.#e))}hasChanges(){return JSON.stringify(this.#e)!==JSON.stringify(this.#t)}_setData(e){this.#o={...e};const{draft:t,proxy:o}=this.buildDraftAndProxy({data:{...e,...this.defaultFields},serverData:this.#o,constant:I.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(t)),this.#e=t,this.data=o}async refresh(){if(!this.id)throw new p("Impossible de rafraîchir sans ID.");return this.get()}async save(){if(!this.isConnected)throw new p("Impossible de sauvegarder sans être connecté.");const e={...this.#e};return this.id?(await this._update(e)&&await this.refresh(),this.#o):(await this._add(e),await this.refresh(),this.#o)}async _add(e){e.id=this._newId(),e.slug&&delete e.slug;for(const[t,o]of I.ADD_BLOCKS){const n=this.extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(n&&Object.keys(n).length>0){const e=await this[o](n);!this.id&&e?.map?.id&&(this.#e.id=e.map.id,this.#e.slug=e.map.slug)}}}async _update(e){e.id&&delete e.id;let t=!1;for(const[o,n]of I.UPDATE_BLOCKS){const r=this.extractChangedFieldsFromSchema(this.apiClient,o,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);r&&Object.keys(r).length>0&&(await this[n](r),t=!0)}return t}addProject(e={}){return this.isMe||(e.parent={},e.parent[`${this.parent.id}`]={type:this.parent.getEntityType(),name:this.parent.name}),this.callIsConnected((()=>this.endpointApi.addProject(e)))}static fromServerData(e,t,o){const n=new I(t,{},o);n.#o={...e};const{draft:r,proxy:i}=n.buildDraftAndProxy({data:{...e,...n.defaultFields},serverData:n.#o,constant:I.SCHEMA_CONSTANTS,apiClient:n.apiClient,transforms:n.transforms,removeFields:n.removeFields});return n.#e=r,n.data=i,n}defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={github:(e,t)=>t?.socialNetwork?.github,gitlab:(e,t)=>t?.socialNetwork?.gitlab,facebook:(e,t)=>t?.socialNetwork?.facebook,twitter:(e,t)=>t?.socialNetwork?.twitter,instagram:(e,t)=>t?.socialNetwork?.instagram,diaspora:(e,t)=>t?.socialNetwork?.diaspora,mastodon:(e,t)=>t?.socialNetwork?.mastodon,telegram:(e,t)=>t?.socialNetwork?.telegram,signal:(e,t)=>t?.socialNetwork?.signal,parent:e=>e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map((([e,t])=>[e,{type:t?.type??null,name:t?.name??null}]))):null};async project(e={}){try{const t=new I(this,e,{User:this.deps.User,News:this.deps.News,EndpointApi:this.deps.EndpointApi});return(e.id||e.slug)&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.project] Erreur lors de la création d'une instance project :`,e.message),e}}}Object.assign(I.prototype,T,A,b,E,f);class O{#e={};#t={};#o=null;static entityType="citoyens";static SCHEMA_CONSTANTS=["UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);constructor(e,t={},o={}){if(this.__entityTag="User",!o.EndpointApi)throw new p("EndpointApi class must be injected to avoid circular dependency.");if(!t?.id&&!t?.slug)throw new p("Vous devez fournir un id ou un slug pour créer un User.");if(!o.Organization)throw new p("Organization class must be injected.");if(!o.Project)throw new p("Project class must be injected.");if(!o.News)throw new p("News class must be injected.");if(this.apiClient=e,this.deps=o,"function"==typeof o.EndpointApi)this.endpointApi=new o.EndpointApi(this.apiClient);else{if("object"!=typeof o.EndpointApi)throw new p("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=o.EndpointApi}this.#o=null;const{draft:n,proxy:r}=this.buildDraftAndProxy({data:{...t,...this.defaultFields},serverData:this.#o,constant:O.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(n)),this.#e=n,this.data=r}get id(){return this.#e.id||null}_id(e){this.#e.id=e}get slug(){return this.#e.slug||null}get isConnected(){return this.apiClient.isConnected}_setData(e){this.#o={...e};const{draft:t,proxy:o}=this.buildDraftAndProxy({data:{...e,...this.defaultFields},serverData:this.#o,constant:O.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(t)),this.#e=t,this.data=o}getEntityType(){return O.entityType}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}get draftData(){return this.#e}get initialDraftData(){return this.#t}get serverData(){return this.#o}async refresh(){if(!this.id)throw new p("Impossible de rafraîchir sans ID.");return this.get()}async get(){return this.apiClient.safeCall((async()=>{if(this.isMe){const e=await this.endpointApi.meInfoUrl();return this._setData(e),e}{const e=await this.getPublicProfile();return this._setData(e),e}}))}async changePassword(e={}){return this.callIsMe((()=>this.endpointApi.changePassword(e)))}async delete(e={}){return this.callIsMe((()=>this.endpointApi.deleteAccount(e)))}async save(){if(!this.isMe)throw new p("Vous devez être connecté et être l'utilisateur pour sauvegarder.");const e={...this.#e};if(this.id)return await this._update(e)&&await this.refresh(),this.#o}async _update(e){e.id&&delete e.id;let t=!1;for(const[o,n]of O.UPDATE_BLOCKS){const r=this.extractChangedFieldsFromSchema(this.apiClient,o,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);r&&Object.keys(r).length>0&&(await this[n](r),t=!0)}return t}async updateSettings(e={}){await this.callIsMe((()=>this.endpointApi.updateSettings(e))),await this.refresh()}async updateDescription(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockDescription(e)))}async updateInfo(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockInfo(e)))}async updateSocial(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockSocial(e)))}async updateLocality(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockLocality(e)))}async updateSlug({slug:e}){try{await this.endpointApi.check({slug:e})}catch(e){if(e instanceof u)throw new u("Erreur lors de la vérification du slug.",e.status,e.data);throw e}return this.callIsMe((()=>this.endpointApi.updateBlockSlug({slug:e})))}async updateImageProfil({profil_avatar:e}){return e=await this.validateImage(e),this.callIsMe((()=>this.endpointApi.profilImage({profil_avatar:e})))}async getOrganizations(e={}){delete e?.pathParams;const t=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getOrganizationsAdmin(e))):()=>this.endpointApi.getOrganizationsNoAdmin(e);this.isMe||e.filters||(e.filters={[`links.members.${this.id}`]:{$exists:!0},[`links.members.${this.id}.toBeValidated`]:{$exists:!1},[`links.members.${this.id}.isInviting`]:{$exists:!1}});const o=await t();if(!Array.isArray(o.results))throw new u("Erreur lors de la récupération des organisations.",500,o.results);delete o?.count?.spam;const n=Object.values(o.count||{}).reduce(((e,t)=>e+t),0);o.count.total=n;const r=o.results.map((e=>this.deps.Organization.fromServerData(e,this,{User:O,Project:this.deps.Project,News:this.deps.News,EndpointApi:this.deps.EndpointApi})));return{count:o.count,results:r}}async organization(e={}){try{const t=new this.deps.Organization(this,e,{User:O,Project:this.deps.Project,News:this.deps.News,EndpointApi:this.deps.EndpointApi});return(e.id||e.slug)&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.organization] Erreur lors de la création d'une instance organization :`,e.message),e}}async getProjects(e={}){delete e?.pathParams;const t=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getProjectsAdmin(e))):()=>this.endpointApi.getProjectsNoAdmin(e);this.isMe||e.filters||(e.filters={$or:{[`links.contributors.${this.id}`]:{$exists:!0},[`parent.${this.id}`]:{$exists:!0}},[`links.contributors.${this.id}`]:{$exists:!0}});const o=await t();if(!Array.isArray(o.results))throw new u("Erreur lors de la récupération des projets.",500,o.results);const n=o.results.map((e=>this.deps.Project.fromServerData(e,this,{User:O,News:this.deps.News,EndpointApi:this.deps.EndpointApi})));return{count:o?.count?.projects??0,results:n}}async project(e={}){try{const t=new this.deps.Project(this,e,{User:O,News:this.deps.News,EndpointApi:this.deps.EndpointApi});return(e.id||e.slug)&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.project] Erreur lors de la création d'une instance project :`,e.message),e}}async getNews(e={}){e.pathParams&&delete e.pathParams,this.isMe||(e.pathParams={id:this.id});const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new u("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>this.deps.News.fromServerData(e,this,{User:O,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)}async news(e={}){try{const t=new this.deps.News(this,e,{User:O,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.news] Erreur lors de la création d'une instance news :`,e.message),e}}_updateInitialDraftSnapshot(){this.#t=JSON.parse(JSON.stringify(this.#e))}hasChanges(){return JSON.stringify(this.#e)!==JSON.stringify(this.#t)}defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={github:(e,t)=>t?.socialNetwork?.github,gitlab:(e,t)=>t?.socialNetwork?.gitlab,facebook:(e,t)=>t?.socialNetwork?.facebook,twitter:(e,t)=>t?.socialNetwork?.twitter,instagram:(e,t)=>t?.socialNetwork?.instagram,diaspora:(e,t)=>t?.socialNetwork?.diaspora,mastodon:(e,t)=>t?.socialNetwork?.mastodon,telegram:(e,t)=>t?.socialNetwork?.telegram,signal:(e,t)=>t?.socialNetwork?.signal}}Object.assign(O.prototype,A,T,{},f);const S=require("events"),D=require("@segment/ajv-human-errors"),v=require("ajv"),C=require("ajv-formats"),j=require("axios"),k=require("axios-retry"),N=require("ejson"),x=require("jwt-decode"),$=require("pino"),q={_looksLikeObjectID:e=>24===e.length&&/^[0-9a-f]*$/.test(e),ObjectID:class{constructor(e){if(e){if(e=e.toLowerCase(),!q._looksLikeObjectID(e))throw new Error("Invalid hexadecimal string for creating an ObjectID");this._str=e}}equals(e){return e instanceof q.ObjectID&&this.valueOf()===e.valueOf()}toString(){return`ObjectID("${this._str}")`}clone(){return new q.ObjectID(this._str)}typeName(){return"oid"}getTimestamp(){return Number.parseInt(this._str.substr(0,8),16)}valueOf(){return this._str}toJSONValue(){return this.valueOf()}toHexString(){return this.valueOf()}}},L=q,z={common1:{type:"string"},common2:{format:"email",type:"string"},common3:{type:"boolean"},common4:{format:"uri",type:"string"},common5:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common6:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},required:["id"],type:"object"},common7:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},common8:{additionalProperties:!1,properties:{reason:{default:"",type:"string"}},required:["reason"],type:"object"},common9:{reason:{default:"",type:"string"}},common10:{default:"",type:"string"},common11:{pattern:"^[a-f0-9]{24}$",type:"string"},common12:{const:"citoyens"},common13:{properties:{value:{type:"boolean"}}},common14:{value:{type:"boolean"}},common15:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},common16:{},common17:{else:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},if:{properties:{typeElement:{const:"citoyens"}}},then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}}},common18:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},common19:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},common20:{properties:{typeElement:{const:"citoyens"}}},common21:{typeElement:{const:"citoyens"}},common22:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}},common23:{not:{type:"null"}},common24:{type:"null"},common25:{anyOf:[{items:{type:"string"},type:"array"},{enum:[""],type:"string"}]},common26:{items:{type:"string"},type:"array"},common27:{enum:[""],type:"string"},common28:{properties:{name:{not:{type:"null"}}},required:["name"]},common29:{name:{not:{type:"null"}}},common30:{properties:{url:{not:{type:"null"}}},required:["url"]},common31:{url:{not:{type:"null"}}},common32:{properties:{tags:{not:{type:"null"}}},required:["tags"]},common33:{tags:{not:{type:"null"}}},common34:{properties:{email:{not:{type:"null"}}},required:["email"]},common35:{email:{not:{type:"null"}}},common36:{const:"info",default:"info",type:"string"},common37:{$ref:"#/$defs/sharedFields/email"},common38:{$ref:"#/$defs/sharedFields/name"},common39:{$ref:"#/$defs/sharedFields/tags"},common40:{$ref:"#/$defs/sharedFields/url"},common41:{const:"projects"},common42:{name:{type:"string"},type:{type:"string"}},common43:{const:"organizations"},common44:{$ref:"#/$defs/socialField"},common45:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},common46:{id:{pattern:"^[a-f0-9]{24}$"}},common47:{pattern:"^[a-f0-9]{24}$"},common48:{additionalProperties:!1,properties:{"@type":{const:"PostalAddress",type:"string"},addressCountry:{type:"string"},addressLocality:{type:"string"},codeInsee:{type:"string"},level1:{type:"string"},level1Name:{type:"string"},level3:{minLength:0,type:"string"},level3Name:{minLength:0,type:"string"},level4:{minLength:0,type:"string"},level4Name:{minLength:0,type:"string"},localityId:{type:"string"},postalCode:{type:"string"},streetAddress:{type:"string"}},required:["@type","addressCountry","codeInsee","addressLocality","localityId","level1","level1Name"],type:"object"},common49:{"@type":{const:"PostalAddress",type:"string"},addressCountry:{type:"string"},addressLocality:{type:"string"},codeInsee:{type:"string"},level1:{type:"string"},level1Name:{type:"string"},level3:{minLength:0,type:"string"},level3Name:{minLength:0,type:"string"},level4:{minLength:0,type:"string"},level4Name:{minLength:0,type:"string"},localityId:{type:"string"},postalCode:{type:"string"},streetAddress:{type:"string"}},common50:{const:"PostalAddress",type:"string"},common51:{minLength:0,type:"string"},common52:{additionalProperties:!1,properties:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},required:["latitude","longitude"],type:"object"},common53:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},common54:{const:"GeoCoordinates",type:"string"},common55:{type:["string","number"]},common56:{additionalProperties:!0,properties:{coordinates:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},float:{const:!0,default:!0,type:"boolean"},type:{const:"Point",type:"string"}},required:["type","coordinates","float"],type:"object"},common57:{coordinates:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},float:{const:!0,default:!0,type:"boolean"},type:{const:"Point",type:"string"}},common58:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},common59:{type:"number"},common60:{const:!0,default:!0,type:"boolean"},common61:{const:"Point",type:"string"},common62:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common63:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common64:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"},common65:{maxLength:100,minLength:3,pattern:"^[a-zA-Z0-9]+$",type:"string"},common66:{properties:{type:{const:"citoyens"}}},common67:{type:{const:"citoyens"}},common68:{additionalProperties:!1,else:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{folder:{const:"citoyens"}}},properties:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},required:["folder","ownerId"],then:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common69:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},common70:{ownerId:{pattern:"^[a-f0-9]{24}$"}},common71:{properties:{folder:{const:"citoyens"}}},common72:{folder:{const:"citoyens"}},common73:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},common74:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common75:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common76:{additionalProperties:!1,else:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{type:{const:"citoyens"}}},properties:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},required:["type","id"],then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common77:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},common78:{properties:{parentId:{pattern:"^[a-f0-9]{24}$"}}},common79:{parentId:{pattern:"^[a-f0-9]{24}$"}},common80:{properties:{parentType:{const:"citoyens"}}},common81:{parentType:{const:"citoyens"}},common82:{properties:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common83:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common84:{default:!0,type:"boolean"},common85:{required:["text"]},common86:{required:["mediaImg"]},common87:{required:["mediaFile"]},common88:{additionalProperties:!1,properties:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},required:["countFiles","files"],type:"object"},common89:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},common90:{additionalProperties:!1,properties:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},required:["countImages","images"],type:"object"},common91:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},common92:{items:{properties:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common93:{properties:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},common94:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common95:{minimum:1,type:"integer"},common96:{default:"public",enum:["public","private","restricted"],type:"string"},common97:{const:"news",default:"news",type:"string"},common98:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},required:["id"],type:"object"},common99:{default:!1,type:"boolean"},common100:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},required:["type","id"],type:"object"},common101:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},common102:{default:"news",enum:["news"],type:"string"},common103:{items:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common104:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},common105:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common106:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],type:"string"},common107:{const:!1,default:!1,type:"boolean"},common108:{const:"",default:"",type:"string"},common109:{additionalProperties:!1,properties:{indexMax:{type:"number"},indexMin:{type:"number"}},required:["indexMin","indexMax"],type:"object"},common110:{indexMax:{type:"number"},indexMin:{type:"number"}},common111:{default:0,minimum:0,type:"integer"},common112:{const:["projects"],default:["projects"],items:{enum:["projects"],type:"string"},type:"array"},common113:{enum:["projects"],type:"string"},common114:{$exists:!0},common115:{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},common116:{$exists:{const:!0}},common117:{const:!0},common118:{default:30,type:"integer"},common119:{const:["poi"],default:["poi"],items:{enum:["poi"],type:"string"},type:"array"},common120:{enum:["poi"],type:"string"},common121:{const:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],default:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],items:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},type:"array"},common122:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},common123:{$exists:!1},common124:{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},common125:{$exists:{const:!1}},common126:{const:!1},common127:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common128:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common129:{additionalProperties:!1,properties:{$exists:{default:!1,type:"boolean"}},required:["$exists"],type:"object"},common130:{$exists:{default:!1,type:"boolean"}},common131:{additionalProperties:!1,properties:{$in:{items:{type:"string"},minItems:1,type:"array"}},required:["$in"],type:"object"},common132:{$in:{items:{type:"string"},minItems:1,type:"array"}},common133:{items:{type:"string"},minItems:1,type:"array"},common134:{const:["citoyens"],default:["citoyens"],items:{enum:["citoyens"],type:"string"},type:"array"},common135:{enum:["citoyens"],type:"string"},common136:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},type:"array"},common137:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},common138:{not:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common139:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common140:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common141:{"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"}},common142:{not:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common143:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common144:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common145:{const:["badges"],default:["badges"],items:{enum:["badges"],type:"string"},type:"array"},common146:{enum:["badges"],type:"string"},common147:{const:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common148:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common149:{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"},common150:{$exists:{const:!0,type:"boolean"}},common151:{const:!0,type:"boolean"},common152:{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},common153:{$exists:{const:!1,type:"boolean"}},common154:{const:!1,type:"boolean"},common155:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"}},common156:{indexMax:30,indexMin:0},common157:{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{connectType:{const:"friend",default:"friend"}}}},common158:{properties:{connectType:{const:"friend",default:"friend"}}},common159:{connectType:{const:"friend",default:"friend"}},common160:{const:"friend",default:"friend"},common161:{if:{properties:{parentType:{const:"organizations"}}},then:{properties:{connectType:{enum:["admin","member"]}}}},common162:{properties:{parentType:{const:"organizations"}}},common163:{parentType:{const:"organizations"}},common164:{properties:{connectType:{enum:["admin","member"]}}},common165:{connectType:{enum:["admin","member"]}},common166:{enum:["admin","member"]},common167:{if:{properties:{parentType:{const:"projects"}}},then:{properties:{connectType:{enum:["admin","contributor"]}}}},common168:{properties:{parentType:{const:"projects"}}},common169:{parentType:{const:"projects"}},common170:{properties:{connectType:{enum:["admin","contributor"]}}},common171:{connectType:{enum:["admin","contributor"]}},common172:{enum:["admin","contributor"]},common173:{properties:{parentType:{const:"events"}}},common174:{parentType:{const:"events"}},common175:{const:"events"},common176:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},common177:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},common178:{enum:["citoyens","organizations","projects","events"],type:"string"},common179:{const:"citoyens",default:"citoyens",type:"string"},common180:{const:"@userId",default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common181:{additionalProperties:!1,default:{"@userId":{type:"citoyens"}},patternProperties:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},type:"object"},common182:{"@userId":{type:"citoyens"}},common183:{type:"citoyens"},common184:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},common185:{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"},common186:{const:"poi",default:"poi",type:"string"},common187:{format:"date-time",type:"string"},common188:{pattern:"^([01]\\d|2[0-3]):[0-5]\\d$",type:"string"}},M=[{auth:"none",constant:"PERSON_REGISTER",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/register",request:{additionalProperties:!1,properties:{app:z.common1,email:z.common2,isInvitation:z.common3,mode:z.common1,name:z.common1,pendingUserId:z.common1,pwd:z.common1,username:z.common1},required:["name","username","email","pwd"],type:"object"}},{auth:"none",constant:"AUTHENTICATE_URL",contentType:"application/json",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/api/cocolight/authenticate",postActions:[{path:"accessToken",type:"setToken"},{path:"refreshToken",type:"setRefreshToken"},{event:"userLoggedIn",path:"user",type:"emitEvent"}],request:{additionalProperties:!1,properties:{email:z.common2,password:z.common1},required:["email","password"],type:"object"}},{auth:"none",constant:"REFRESH_TOKEN_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/refreshtoken",request:{additionalProperties:!1,properties:{refreshToken:z.common1},required:["refreshToken"],type:"object"}},{auth:"bearer",constant:"ME_INFO_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/me"},{auth:"none",constant:"PASSWORD_RECOVERY",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/sendemail",request:{additionalProperties:!1,properties:{email:z.common2,type:{const:"password",default:"password",type:"string"}},required:["email","type"],type:"object"}},{auth:"bearer",constant:"SERVER_EXCHANGE_TOKEN",contentType:"application/json",method:"POST",path:"/api/cocolight/exchangetoken",request:{additionalProperties:!1,properties:{serverUrl:z.common4},required:["serverUrl"],type:"object"}},{auth:"bearer",constant:"CHANGE_PASSWORD",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/person/changepassword",request:{additionalProperties:!1,properties:{mode:{const:"changePassword",default:"changePassword",type:"string"},newPassword:z.common1,newPassword2:z.common1,oldPassword:z.common1,scope:{default:"",type:["string"]},userId:z.common5},required:["mode","userId","oldPassword","newPassword","newPassword2"],type:"object"}},{auth:"bearer",constant:"DELETE_ACCOUNT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/id/{id}/type/citoyens",pathParams:z.common6,postActions:[{type:"resetSession"},{event:"accountDeleted",path:null,type:"emitEvent"}],request:z.common8},{auth:"bearer",constant:"UPDATE_SETTINGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatesettings",request:{additionalProperties:!1,allOf:[{else:{properties:{idEntity:z.common11}},if:{properties:{typeEntity:z.common12}},then:{properties:{idEntity:z.common5}}},{if:{properties:{type:{enum:["birthDate","email","locality","phone","directory"]},typeEntity:z.common12}},then:{properties:{value:{enum:["private","public","mask"],type:"string"}}}},{if:{properties:{type:{enum:["activitypub","isOpenData"]},typeEntity:z.common12}},then:z.common13},{if:{properties:{type:{enum:["isOpenData","isOpenEdition","private","feedback"]},typeEntity:{not:z.common12}}},then:z.common13}],properties:{idEntity:z.common1,type:z.common1,typeEntity:z.common15,value:z.common16},required:["type","value","typeEntity","idEntity"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_DESCRIPTION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{additionalProperties:!1,allOf:[z.common17,{anyOf:[{properties:{description:z.common23},required:["description"]},{properties:{shortDescription:z.common23},required:["shortDescription"]}]}],properties:{block:{const:"descriptions",default:"descriptions",type:"string"},descMentions:z.common10,description:z.common1,id:z.common1,scope:{default:"",type:["string","null"]},shortDescription:z.common1,typeElement:z.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_INFO",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{sharedFields:{email:z.common2,name:z.common1,tags:z.common25,url:z.common4}},allOf:[{if:z.common20,then:{additionalProperties:!1,anyOf:[z.common28,{properties:{birthDate:z.common23},required:["birthDate"]},{properties:{fixe:z.common23},required:["fixe"]},{properties:{mobile:z.common23},required:["mobile"]},z.common30,z.common32,z.common34],properties:{birthDate:{format:"date",type:"string"},block:z.common36,email:z.common37,fixe:z.common1,id:z.common5,mobile:z.common1,name:z.common38,scope:z.common10,tags:z.common39,typeElement:z.common15,url:z.common40}}},{if:{properties:{typeElement:z.common41}},then:{additionalProperties:!1,anyOf:[z.common28,z.common30,z.common32,z.common34,{properties:{avancement:z.common23},required:["avancement"]},{properties:{parent:z.common23},required:["parent"]}],properties:{avancement:{enum:["abandoned","concept","development","production","started","testing","idea","mature","qa","finished"],type:"string"},block:z.common36,email:z.common37,id:z.common1,name:z.common38,parent:{additionalProperties:!1,patternProperties:{"^[a-fA-F0-9]{24}$":{additionalProperties:!1,properties:z.common42,required:["type","name"],type:"object"}},type:"object"},scope:z.common10,tags:z.common39,typeElement:z.common15,url:z.common40}}},{if:{properties:{typeElement:z.common43}},then:{additionalProperties:!1,anyOf:[z.common28,z.common30,z.common32,z.common34,{properties:{type:z.common23},required:["type"]}],properties:{block:z.common36,email:z.common37,id:z.common1,name:z.common38,scope:z.common10,tags:z.common39,type:{enum:["NGO","Cooperative","LocalBusiness","GovernmentOrganizationautre"],type:"string"},typeElement:z.common15,url:z.common40}}}],properties:{block:z.common36,id:z.common1,scope:z.common10,typeElement:z.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SOCIAL",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{socialField:{anyOf:[z.common27,z.common4]}},allOf:[z.common17,{anyOf:[{properties:{gitlab:z.common23},required:["gitlab"]},{properties:{github:z.common23},required:["github"]},{properties:{twitter:z.common23},required:["twitter"]},{properties:{facebook:z.common23},required:["facebook"]},{properties:{instagram:z.common23},required:["instagram"]},{properties:{diaspora:z.common23},required:["diaspora"]},{properties:{mastodon:z.common23},required:["mastodon"]},{properties:{telegram:z.common23},required:["telegram"]},{properties:{signal:z.common23},required:["signal"]}]}],properties:{block:{const:"network",default:"network",type:"string"},diaspora:z.common44,facebook:z.common44,github:z.common44,gitlab:z.common44,id:z.common1,instagram:z.common44,mastodon:z.common44,scope:z.common10,signal:z.common44,telegram:z.common44,twitter:z.common44,typeElement:z.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_LOCALITY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:z.common45,if:z.common20,properties:{address:z.common48,block:{const:"localities",default:"localities",type:"string"},geo:z.common52,geoPosition:z.common56,id:z.common1,scope:z.common10,typeElement:z.common15},required:["block","typeElement","id","address"],then:z.common62,type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SLUG",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:z.common45,if:z.common20,properties:{block:z.common36,id:z.common1,scope:z.common10,slug:z.common65,typeElement:z.common15},required:["block","typeElement","id","slug"],then:z.common62,type:"object"}},{auth:"bearer",constant:"CHECK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/check",request:{additionalProperties:!1,else:z.common45,if:z.common66,properties:{block:z.common36,id:z.common1,slug:z.common65,type:z.common15},required:["block","type","id","slug"],then:z.common62,type:"object"}},{auth:"bearer",constant:"PROFIL_IMAGE",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/profil_avatar/contentKey/profil/docType/image",pathParams:z.common68,request:{additionalProperties:!1,properties:{profil_avatar:z.common16},required:["profil_avatar"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_ABOUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/about/type/{type}/id/{id}/json/true",pathParams:z.common76,request:{additionalProperties:!1,properties:{tpl:{const:"ficheInfoElement",default:"ficheInfoElement",type:"string"}},required:["tpl"],type:"object"}},{auth:"bearer",constant:"MULTICONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/multiconnect",request:{additionalProperties:!1,else:z.common78,if:z.common80,properties:{listInvite:{additionalProperties:!1,patternProperties:{"^(citoyens|projects|organizations)$":{additionalProperties:!1,patternProperties:{"^[0-9a-fA-F]{24}$":{additionalProperties:!1,properties:{name:z.common1},required:["name"],type:"object"}},type:"object"}},type:"object"},parentId:z.common1,parentType:z.common15},required:["parentId","parentType","listInvite"],then:z.common82,type:"object"}},{auth:"none",constant:"GET_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/get/type/{type}/id/{id}/isLive/{isLive}/json/true",pathParams:{additionalProperties:!1,else:z.common45,if:z.common66,properties:{id:z.common1,isLive:z.common84,type:z.common15},required:["isLive","type","id"],then:z.common62,type:"object"},request:{additionalProperties:!1,properties:{dateLimit:{default:0,type:"integer"},indexStep:{default:12,type:"integer"},search:{additionalProperties:!1,properties:{name:z.common10},required:["name"],type:"object"}},required:["dateLimit","indexStep"],type:"object"}},{auth:"none",constant:"GET_NEWS_BY_ID",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/getbyids",request:{additionalProperties:!1,properties:{ids:{items:z.common11,type:"array"}},required:["ids"],type:"object"}},{auth:"bearer",constant:"ADD_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/save",request:{additionalProperties:!1,anyOf:[z.common85,z.common86,z.common87],else:z.common78,if:z.common80,properties:{json:z.common60,markdownActive:z.common84,mediaFile:z.common88,mediaImg:z.common90,mentions:z.common92,parentId:z.common1,parentType:z.common15,scope:z.common96,tags:z.common25,text:z.common1,type:z.common97},required:["scope","markdownActive","parentId","parentType","type","json"],then:z.common82,type:"object"}},{auth:"bearer",constant:"ADD_IMAGE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/newsImage/docType/image/contentKey/slider",pathParams:z.common68,request:{additionalProperties:!1,properties:{newsImage:z.common16},required:["newsImage"],type:"object"}},{auth:"bearer",constant:"ADD_FILE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}}/input/newsFile/docType/file",pathParams:z.common68,request:{additionalProperties:!1,properties:{newsFile:z.common16},required:["newsFile"],type:"object"}},{auth:"bearer",constant:"DELETE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/delete/id/{id}",pathParams:z.common98,request:{additionalProperties:!1,properties:{isLive:z.common99},required:["isLive"],type:"object"}},{auth:"bearer",constant:"UPDATE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/update",request:{additionalProperties:!1,anyOf:[z.common85,z.common86,z.common87],else:z.common78,if:z.common80,properties:{idNews:z.common11,markdownActive:z.common84,mediaFile:z.common88,mediaImg:z.common90,mentions:z.common92,parentId:z.common1,parentType:z.common15,scope:z.common96,tags:z.common25,text:z.common1,type:z.common97},required:["idNews","scope","markdownActive","parentId","parentType","type"],then:z.common82,type:"object"}},{auth:"bearer",constant:"SHARE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:{properties:{childId:z.common47}},if:{properties:{childType:z.common12}},properties:{childId:z.common11,childType:z.common15,comment:z.common1,connectType:{const:"share",default:"share",type:"string"},parentId:z.common11,parentType:z.common97},required:["parentId","parentType","childId","childType","connectType"],then:{properties:{childId:z.common64}},type:"object"}},{auth:"none",constant:"GET_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/index/type/{type}/id/{id}/json/true",pathParams:z.common100},{auth:"bearer",constant:"ADD_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/save",request:{additionalProperties:!1,properties:{argval:z.common10,contextId:z.common11,contextType:z.common102,mentions:z.common103,parentCommentId:z.common11,path:z.common10,text:z.common1},required:["text","contextId","contextType"],type:"object"}},{auth:"bearer",constant:"DELETE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/delete/id/{id}",pathParams:z.common98},{auth:"bearer",constant:"UPDATE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/update",request:{additionalProperties:!1,properties:{id:z.common11,params:{properties:{mentions:z.common103,text:z.common1},required:["text"],type:"object"}},required:["id","params"],type:"object"}},{auth:"none",constant:"SEARCH_TAGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/tags/search?q={q}",pathParams:{additionalProperties:!1,properties:{q:z.common1},required:["q"],type:"object"}},{auth:"none",constant:"SHOW_VOTE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/action/list/type/{type}/id/{id}/actionType/vote/json/true",pathParams:z.common100},{auth:"none",constant:"GLOBAL_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:{const:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],default:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],items:z.common106,type:"array"},fediverse:z.common107,filters:z.common108,indexMin:{const:0,default:0,type:"number"},indexStep:z.common59,initType:z.common108,locality:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":{additionalProperties:!1,properties:{id:z.common1,type:{enum:["cities","level1"],type:"string"}},required:["id","type"],type:"object"}},type:"object"},name:z.common1,notSourceKey:z.common60,ranges:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":z.common109},type:"object"},searchTags:z.common26,searchType:{items:z.common106,type:"array"}},required:["name","searchType","countType","indexMin","indexStep","initType","count","notSourceKey","filters","fediverse"],type:"object"}},{auth:"none",constant:"CITY_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{minimum:5,type:"integer"},indexMin:{minimum:0,type:"integer"},locality:z.common108,name:z.common1,searchBy:{const:"ALL",default:"ALL",type:"string"},searchType:{const:["cities"],default:["cities"],items:{enum:["cities"],type:"string"},type:"array"}},required:["name","locality","searchType"],type:"object"}},{auth:"none",constant:"SUGGESTION_INPUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{default:20,minimum:20,type:"integer"},indexMin:z.common111,name:z.common1,searchType:{items:{enum:["organizations","projects","poi"],type:"string"},type:"array"}},required:["name","searchType","indexMin","indexMax"],type:"object"}},{auth:"none",constant:"GET_PROJECTS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common112,fediverse:z.common107,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@userId":z.common114,"parent.@userId":z.common114},"links.contributors.@userId":z.common114},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":z.common115},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":z.common115,"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":z.common115},type:"object"}},required:["$or"],type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common112},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_PROJECTS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:z.common76,request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common112,fediverse:z.common107,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@{pathParams.id}":z.common114,"parent.@{pathParams.id}":z.common114},"links.contributors.@{pathParams.id}":z.common114},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115,"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115},type:"object"}},required:["$or"],type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common112},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_POIS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common119,fediverse:z.common107,filters:{additionalProperties:!1,default:{"parent.@userId":z.common114},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":z.common115},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common119},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_POIS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:z.common76,request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common119,fediverse:z.common107,filters:{additionalProperties:!1,default:{"parent.@{pathParams.id}":z.common114},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common119},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_ORGANIZATIONS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common121,fediverse:z.common107,filters:{additionalProperties:!1,default:{"links.members.@userId":z.common114,"links.members.@userId.isInviting":z.common123,"links.members.@userId.toBeValidated":z.common123},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)$":z.common115,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":z.common124,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":z.common124},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_ORGANIZATIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,else:z.common45,if:z.common66,properties:{id:z.common1,type:{default:"citoyens",enum:["citoyens","organizations"],type:"string"}},required:["type","id"],then:z.common62,type:"object"},request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common121,fediverse:z.common107,filters:{additionalProperties:!1,default:{"links.members.@{pathParams.id}":z.common114,"links.members.@{pathParams.id}.isInviting":z.common123,"links.members.@{pathParams.id}.toBeValidated":z.common123},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":z.common124,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":z.common124},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_MEMBERS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common127,fediverse:z.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$":z.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":z.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":z.common129,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":z.common131,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":z.common124},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common127},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_MEMBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/organizations/id/{id}/canSee/true",pathParams:z.common98,request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common127,fediverse:z.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.memberOf.@{pathParams.id}":z.common114,"links.memberOf.@{pathParams.id}.isInviting":z.common123,"links.memberOf.@{pathParams.id}.toBeValidated":z.common123},patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":z.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":z.common129,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":z.common131,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":z.common129},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common127},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_FRIENDS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:z.common6,request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common134,fediverse:z.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.friends.@{pathParams.id}":z.common114,"links.friends.@{pathParams.id}.isInviting":z.common123,"links.friends.@{pathParams.id}.toBeValidated":z.common123},patternProperties:{"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":z.common129,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":z.common129},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIPTIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common136,fediverse:z.common107,filters:{additionalProperties:!1,allOf:[z.common138],default:{"links.followers.@userId":z.common114,"links.followers.@{userId}.isInviting":z.common123,"links.followers.@{userId}.toBeValidated":z.common123},patternProperties:z.common141,type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common136},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIPTIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:z.common6,request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common136,fediverse:z.common107,filters:{additionalProperties:!1,allOf:[z.common138],default:{"links.followers.@{pathParams.id}":z.common114,"links.followers.@{pathParams.id}.isInviting":z.common123,"links.followers.@{pathParams.id}.toBeValidated":z.common123},patternProperties:z.common141,type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common136},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIBERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common134,fediverse:z.common107,filters:{additionalProperties:!1,allOf:[z.common142],default:{"links.follows.@userId":z.common114,"links.follows.@{userId}.isInviting":z.common123,"links.follows.@{userId}.toBeValidated":z.common123},patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":z.common124,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":z.common124},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,allOf:[{else:z.common45,if:z.common66,then:z.common62}],properties:{id:z.common1,type:{default:"citoyens",enum:["citoyens","organizations","projects"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common134,fediverse:z.common107,filters:{additionalProperties:!1,allOf:[z.common142],default:{"links.follows.@{pathParams.id}":z.common114},maxProperties:1,minProperties:1,patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_CONTRIBUTORS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common127,fediverse:z.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$":z.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":z.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":z.common129,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":z.common131,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":z.common124},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common127},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_CONTRIBUTORS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/projects/id/{id}/canSee/true",pathParams:z.common98,request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common127,fediverse:z.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.projects.@{pathParams.id}":z.common114,"links.projects.@{pathParams.id}.isInviting":z.common123,"links.projects.@{pathParams.id}.toBeValidated":z.common123},patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":z.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":z.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":z.common129,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":z.common131,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":z.common129},type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common127},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common145,fediverse:z.common107,filters:{properties:{$or:{additionalProperties:!1,minProperties:1,patternProperties:{"^issuer\\.(?:[a-f0-9]{24}|@\\w+)$":z.common115},type:"object"},isParcours:z.common3,"preferences.private":z.common107},required:["preferences.private"],type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,searchType:z.common145},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES_FILTERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:z.common60,countType:z.common147,fediverse:z.common107,fields:z.common145,filters:{oneOf:[{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":z.common149}},{additionalProperties:!1,maxProperties:3,minProperties:3,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":z.common149,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":z.common152,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":z.common152}},{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:z.common155},{additionalProperties:!1,maxProperties:1,minProperties:1,properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:z.common155,type:"object"}},required:["$or"]},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.revoke$":z.common151}},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":z.common149}}],type:"object"},indexMin:z.common111,indexStep:z.common118,initType:z.common108,locality:z.common108,name:z.common1,notSourceKey:z.common60,ranges:{additionalProperties:!1,default:{Cooperative:z.common156,GovernmentOrganization:z.common156,Group:z.common156,LocalBusiness:z.common156,NGO:z.common156,citoyens:z.common156,projects:z.common156},maxProperties:7,minProperties:7,patternProperties:{"^[a-zA-Z][a-zA-Z0-9]*$":z.common109},type:"object"},searchType:z.common147},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"CONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/connect",request:{additionalProperties:!1,allOf:[z.common157,z.common161,z.common167,{if:z.common173,then:{properties:{connectType:{default:"attendee",enum:["attendee","connect"]}}}}],properties:{childId:z.common176,childType:z.common177,connectType:{enum:["admin","member","contributor","attendee","friend","connect"],type:"string"},parentId:z.common11,parentType:z.common178},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"bearer",constant:"DISCONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/disconnect",request:{additionalProperties:!1,allOf:[z.common157,z.common161,z.common167,{if:z.common173,then:{properties:{connectType:{const:"attendee",default:"attendee"}}}}],properties:{childId:z.common176,childType:z.common177,connectType:{enum:["admin","member","contributor","attendee","friend"],type:"string"},parentId:z.common11,parentType:z.common178},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_KEY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/getinfo/key/{slug}",pathParams:{additionalProperties:!1,properties:{slug:{pattern:"^([a-zA-Z0-9-_]+)$",type:"string"}},required:["slug"],type:"object"}},{auth:"bearer",constant:"GET_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/config/type/citoyens/id/{id}/json/true",pathParams:z.common6},{auth:"bearer",constant:"DELETE_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue?index={index}",pathParams:{properties:{index:z.common59},type:"object"},request:{additionalProperties:!1,properties:{collection:z.common179,id:z.common180,path:{const:"preferences.search.@{pathParams.index}",default:"preferences.search.@{pathParams.index}",type:"string"},pull:{const:"preferences.search",type:"string"},value:z.common108},required:["id","collection","path","pull","value"],type:"object"}},{auth:"bearer",constant:"ADD_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue",request:{additionalProperties:!1,properties:{arrayForm:z.common151,collection:z.common179,id:z.common180,path:{const:"preferences.search",default:"preferences.search",type:"string"},value:{additionalProperties:!1,properties:{description:z.common1,locality:{patternProperties:{"^[a-f0-9]{24}$":{additionalProperties:!1,properties:z.common42,required:["name","type"]}},type:"object"},name:z.common1,tags:z.common26,url:z.common1},required:["url","name"],type:"object"}},required:["id","collection","path","arrayForm","value"],type:"object"}},{auth:"bearer",constant:"ADD_ORGANIZATION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:z.common48,collection:{const:"organizations",default:"organizations",type:"string"},email:z.common2,geo:z.common52,geoPosition:z.common56,id:z.common11,key:{const:"organization",default:"organization",type:"string"},name:{minLength:3,type:"string"},preferences:{default:{isOpenData:!0,isOpenEdition:!0},properties:{isOpenData:z.common84,isOpenEdition:z.common84},required:["isOpenData","isOpenEdition"],type:"object"},role:{enum:["admin","member"],type:"string"},scope:z.common108,shortDescription:z.common1,tags:z.common26,type:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},url:z.common4},required:["id","collection","key","name","type","role","scope"],type:"object"}},{auth:"bearer",constant:"ADD_PROJECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:z.common48,collection:{const:"projects",default:"projects",type:"string"},geo:z.common52,geoPosition:z.common56,id:z.common11,key:{const:"project",default:"project",type:"string"},name:z.common1,parent:z.common181,preferences:{default:{crowdfunding:!0,isOpenData:!1,isOpenEdition:!1},properties:{crowdfunding:z.common84,isOpenData:z.common99,isOpenEdition:z.common99},required:["isOpenData","isOpenEdition"],type:"object"},public:z.common84,scope:z.common108,shortDescription:z.common1,tags:z.common26,url:z.common4},required:["id","collection","key","parent","name","public","scope"],type:"object"}},{auth:"bearer",constant:"ADD_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:z.common48,collection:z.common186,description:z.common1,geo:z.common52,geoPosition:z.common56,id:z.common11,key:z.common186,name:z.common1,parent:z.common181,scope:z.common108,tags:z.common26,type:{enum:["link","tool","machine","software","rh","Resource material","Financial Ressource","ficheBlanche","geoJson","compostPickup","video","sharedLibrary","recoveryCenter","trash","history","something2See","funPlace","place","artPiece","streetArts","openScene","stand","parking","other"],type:"string"},urls:z.common26},required:["id","collection","key","parent","type","name"],type:"object"}},{auth:"bearer",constant:"ADD_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,else:{required:["openingHours"]},if:{properties:{recurrency:z.common126}},properties:{address:z.common48,collection:{const:"events",default:"events",type:"string"},email:z.common2,endDate:z.common187,geo:z.common52,geoPosition:z.common56,id:z.common11,key:{const:"event",default:"event",type:"string"},name:z.common1,openingHours:{default:["","","","","","",""],items:{anyOf:[{const:"",type:"string"},{additionalProperties:!1,properties:{dayOfWeek:{enum:["Mo","Tu","We","Th","Fr","Sa","Su"],type:"string"},hours:{default:[],items:{additionalProperties:!1,properties:{closes:z.common188,opens:z.common188},required:["opens","closes"],type:"object"},type:"array"}},required:["dayOfWeek","hours"],type:"object"}]},maxItems:7,minItems:7,type:"array"},organizer:z.common181,parent:{additionalProperties:!1,patternProperties:z.common184,type:"object"},preferences:{default:{isOpenData:!1,isOpenEdition:!1},properties:{isOpenData:z.common99,isOpenEdition:z.common99},required:["isOpenData","isOpenEdition"],type:"object"},public:z.common84,recurrency:z.common99,scope:z.common108,shortDescription:z.common1,startDate:z.common187,tags:z.common26,timeZone:z.common1,type:{enum:["workshop","competition","concert","contest","conference","debate","exhibition","festival","crowdfunding","fair","course","protest","market","film","getTogether","meeting","spectacle","internship","stand","others"],type:"string"},url:z.common4},required:["id","collection","key","organizer","type","name","scope"],startBeforeEnd:!0,then:{required:["startDate","endDate"]},type:"object"}},{auth:"bearer",constant:"DELETE_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/poi/id/{id}",pathParams:z.common98,request:z.common8},{auth:"bearer",constant:"DELETE_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/events/id/{id}/",pathParams:z.common98,request:z.common8},{auth:"bearer",constant:"DELETE_ELEMENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/{type}/id/{id}",pathParams:{additionalProperties:!1,properties:{id:z.common11,type:z.common1},required:["type","id"],type:"object"},request:z.common8},{auth:"bearer",constant:"ADD_IMAGE_ELEMENT",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/qqfile/docType/image/contentKey/profil",pathParams:{additionalProperties:!1,properties:{folder:{enum:["badges","events"],type:"string"},ownerId:z.common11},required:["folder","ownerId"],type:"object"},request:{additionalProperties:!1,properties:{qqfile:z.common16,qqfilename:z.common1,qqtotalfilesize:{type:"integer"},qquuid:z.common11},required:["qquuid","qqfilename","qqtotalfilesize","qqfile"],type:"object"}}];var B=s(27);N.addType("oid",(e=>new L.ObjectID(e)));class U extends S.EventEmitter{constructor({baseURL:e,accessToken:t,refreshToken:o,refreshUrl:n="/api/cocolight/refreshtoken",endpoints:r=M,timeout:i=3e4,debug:s=!1,maxRetries:a=0,circuitBreakerThreshold:c=5,circuitBreakerResetTime:p=6e4,fromJSONValue:d=!0,tokenStorageStrategy:l=null}={}){if(super(),!e)throw new m('Le paramètre "baseURL" est obligatoire.',500);this.__entityTag="ApiClient",this._baseURL=e,this._refreshUrl=n,this._endpoints=r,this._debug=s;let u=null;this._fromJSONValue=d,Object.defineProperty(this,"userId",{get:()=>u,set:()=>{throw new Error("Modification directe de userId non autorisée.")},enumerable:!0}),this._setUserId=e=>{u=e,this._logger.debug(`[ApiClient] userId set: ${e}`)},this._ajv=new v({strict:!1,useDefaults:!0,allErrors:!0,verbose:!0}),C(this._ajv),this._ajv.addKeyword({keyword:"startBeforeEnd",type:"object",errors:!0,validate:this._startBeforeEndValidate}),this._logger=$({transport:{target:"pino-pretty",options:{colorize:!0}},level:s?"debug":"info"}),this._client=j.create({baseURL:e,timeout:i}),a>0&&(k(this._client,{retries:a,retryDelay:k.exponentialDelay,retryCondition:e=>k.isNetworkError(e)||k.isRetryableError(e)}),this._logger.info(`[ApiClient] Retry activé : ${a} max`)),this._breakerThreshold=c,this._breakerResetTime=p,this._breakerErrorCount=0,this._breakerOpen=!1,this._lastBreakerOpenTime=null,this._accessToken=null,this._refreshToken=null,o&&this.setRefreshToken(o),t&&this.setToken(t),this._tokenStorage=l||new B.GN;const h=this._tokenStorage.getAccessToken();h&&this.setToken(h);const y=this._tokenStorage.getRefreshToken();y&&this.setRefreshToken(y),this._client.interceptors.response.use((e=>e),(async e=>{const t=e.config;if(t._retry)throw this._logger.error("[ApiClient] Requête déjà retentée, échec définitif."),e;if(e.response&&401===e.response.status&&this._refreshToken){t._retry=!0;try{if(this._logger.info("[ApiClient] Tentative de refresh du token..."),await this._refreshAccessToken())return this._logger.info("[ApiClient] Token rafraîchi avec succès."),t.headers.Authorization="Bearer "+this.getToken(),this._logger.info("[ApiClient] Retente la requête originale avec le nouveau token."),this._client.request(t);throw this.resetSession(),new m("Impossible de rafraîchir le token.",401)}catch(e){throw this.resetSession(),new m("Erreur lors du rafraîchissement du token.",401,e)}}throw e}))}setToken(e){this._accessToken=e,this._tokenStorage.setAccessToken(e),this._client.defaults.headers.common.Authorization="Bearer "+e;const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait et défini : ${t}`)),this._logger.debug(`[ApiClient] setToken: ${e}`)}getToken(){return this._accessToken}setRefreshToken(e){if(this._refreshToken=e,this._tokenStorage.setRefreshToken(e),null===this.userId){const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait depuis refreshToken : ${t}`))}this._logger.debug(`[ApiClient] setRefreshToken: ${e}`)}getRefreshToken(){return this._refreshToken}get isConnected(){return!!this._accessToken}_getIdFromToken(e){if(!e)return null;try{const t=(0,x.jwtDecode)(e);return this._logger.debug("[ApiClient] Payload décodé :",t),t.id||t.userId||null}catch(e){return this._logger.error("[ApiClient] Erreur lors du décodage du token :",e),null}}async _refreshAccessToken(){if(!this._refreshToken)return!1;const e=j.create({baseURL:this._baseURL,timeout:1e4,headers:{"Content-Type":"application/json"}});try{const t=await e.post(this._refreshUrl,{refreshToken:this._refreshToken});return!(!t.data||!t.data.token||(this.setToken(t.data.token),t.data.refreshToken&&this.setRefreshToken(t.data.refreshToken),this.emit("refreshSuccess",t.data),0))}catch(e){return this.resetSession(),this._logger.error(`[ApiClient] Refresh Error : ${e.message}`),!1}}_checkCircuitBreaker(){return!this._breakerOpen||Date.now()-this._lastBreakerOpenTime>this._breakerResetTime&&(this._breakerOpen=!1,this._breakerErrorCount=0,this._logger.warn("[ApiClient] Circuit breaker réinitialisé"),!0)}_updateCircuitBreakerError(){this._breakerErrorCount+=1,this._logger.warn(`[ApiClient] Erreur #${this._breakerErrorCount} sur ${this._breakerThreshold}`),this._breakerErrorCount>=this._breakerThreshold&&(this._breakerOpen=!0,this._lastBreakerOpenTime=Date.now(),this._logger.error("[ApiClient] Circuit breaker ACTIVÉ - L'API est considérée indisponible"))}_resetCircuitBreakerSuccess(){this._breakerErrorCount=0,this._breakerOpen&&(this._breakerOpen=!1,this._logger.warn("[ApiClient] Circuit breaker refermé suite à un succès"))}static stripNullsInPlace(e){if(e&&"object"==typeof e&&e.value&&"function"==typeof e.value.pipe)return e;if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)null===e[t]||void 0===e[t]?e.splice(t,1):"object"==typeof e[t]&&U.stripNullsInPlace(e[t]);else if(e&&"object"==typeof e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(null===e[t]||void 0===e[t]?delete e[t]:"object"==typeof e[t]&&U.stripNullsInPlace(e[t]));return e}_resolveSpecialValuesInPlace(e,t={}){const o={userId:()=>this.userId,accessToken:()=>this._accessToken,refreshToken:()=>this._refreshToken,baseURL:()=>this._baseURL,pathParams:e=>{const o=this._getValueByPath(t,e);return null!=o?o:void 0}},n=/@(?:\{([^}]+)\}|([\w.]+))/g,r=e=>"string"!=typeof e?e:e.replace(n,((t,n,r)=>{if(n){if(n.startsWith("pathParams.")){const e=n.substring(11),t=o.pathParams(e);return null!=t?t:`@{${n}}`}{const e=o[n];if("function"==typeof e){const t=e();return null!=t?t:`@{${n}}`}return`@{${n}}`}}if(r){if(r.startsWith("pathParams.")){const e=r.match(/^pathParams\.([^.]+)(.*)$/);if(e){const t=e[1],n=e[2],i=o.pathParams(t);return null!=i?i+n:`@${r}`}return`@${r}`}{const e=o[r];if("function"==typeof e){const t=e();return null!=t?t:`@${r}`}return`@${r}`}}return e})),i=e=>{if((e=>e&&"object"==typeof e&&("function"==typeof e.pipe||"undefined"!=typeof Buffer&&e instanceof Buffer))(e))return e;if(Array.isArray(e))return e.map(i);if((e=>"[object Object]"===Object.prototype.toString.call(e))(e)){const t={};for(const[o,n]of Object.entries(e))t[r(o)]=i(n);return t}return"string"==typeof e?r(e):e};return i(e)}_cleanSchemaLeftoverAlias(e){const t=/@\w+/;if(Array.isArray(e))return e.map((e=>this._cleanSchemaLeftoverAlias(e)));if(e&&"object"==typeof e){const o={};for(const n of Object.keys(e)){const r=e[n];if(!t.test(n)){if("default"===n){if("string"==typeof r&&t.test(r))continue;if(r&&"object"==typeof r){const e=this._cleanSchemaLeftoverAlias(r);Object.keys(e).length>0&&(o[n]=e);continue}}"string"==typeof r&&t.test(r)||(o[n]=this._cleanSchemaLeftoverAlias(r))}}return o}return e}async safeCall(e,...t){try{return await e(...t)}catch(e){throw this._logger.error(`[ApiClient.safeCall] Erreur: ${e.message}`),e}}async callEndpoint(e,t={},o=!0,n=!0){if(!this._checkCircuitBreaker())throw new l("Le circuit breaker est activé, impossible d'appeler l'API");const r=this._endpoints.find((t=>t.constant===e));if(!r)throw new m(`Endpoint introuvable : ${e}`,404);const{path:i,method:s,contentType:a,auth:c,pathParams:p,request:u,responses:h}=r,y=(s||"GET").toLowerCase(),f=a||"application/json",g={"Content-Type":f};if(this._accessToken)"bearer"===c?g.Authorization=`Bearer ${this._accessToken}`:c&&"none"!==c||g.Authorization||(g.Authorization=`Bearer ${this._accessToken}`);else if("bearer"===c)throw new m(`Token requis pour l'endpoint sécurisé : ${e}`,401);let w,T=i,_={};if(p){let e=p;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(p));const o=t.pathParams||{},n=this._ajv.compile(e);if(!n(o)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"pathParams",errors:n.errors}),new d("Path parameter validation failed.",400,e,n.errors)}_=this._resolveSpecialValuesInPlace(o),T=T.replace(/\{(\w+)\}/g,((e,t)=>{const o=_[t];if(void 0!==o)return encodeURIComponent(o);throw new m(`Path param manquant ou non résolu : {${t}}`,400)}))}if(u){let e=u;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(u));const o={...t};delete o.pathParams;const n=U.stripNullsInPlace(o),r=this._ajv.compile(e);if(!r(n)){const e=r.errors?this._ajvErrorHuman(r.errors):[];throw this.emit("validationError",{stage:"request",errors:r.errors}),new d("Request validation failed.",400,e,r.errors)}t=this._resolveSpecialValuesInPlace(n,_)}"application/json"===f||"multipart/form-data"===f?w=t:"application/x-www-form-urlencoded"===f&&(w=U.toURLSearchParams(t)),this._logger.debug(`[ApiClient] callEndpoint: ${e} -> ${T}, method=${y}`);try{const e=await this._client.request({url:T,method:y,headers:g,["get"===y?"params":"data"]:w});if(n){const t=e.status.toString(),o=h?.[t];if(o){const n=this._ajv.compile(o);if(!n(e.data)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"response",errors:n.errors}),new d("Response validation failed.",t,e,n.errors)}}}return this._resetCircuitBreakerSuccess(),"function"==typeof o?e.data=o(e.data):!0===o&&(e.data=this._transformData(e.data)),Array.isArray(r.postActions)&&r.postActions.forEach((t=>{const o=t.path?this._getValueByPath(e.data,t.path):null;switch(t.type){case"setToken":this.setToken(o);break;case"setRefreshToken":this.setRefreshToken(o);break;case"resetSession":this.resetSession();break;case"emitEvent":t.event&&(this.emit(t.event,o),this._logger.debug(`[ApiClient] Event émis : ${t.event}`,o));break;case"callMethod":"function"==typeof this[t.method]?(this[t.method](),this._logger.debug(`[ApiClient] Méthode appelée : ${t.method}`)):this._logger.warn(`[ApiClient] Méthode inconnue : ${t.method}`);break;default:this._logger.warn(`[ApiClient] Action inconnue : ${t.type}`)}})),e}catch(t){throw this._updateCircuitBreakerError(),this._logger.error(`[ApiClient] Erreur lors de l'appel de ${e}: ${t.message}`),t instanceof d?t:new m(`Erreur lors de l'appel de l'API : ${t.message}`,t.response?t.response.status:500,t.response?t.response.data:null)}}_ajvErrorHuman(e){try{return new D.AggregateAjvError(e).errors.map((({message:e})=>e))}catch(t){return this._logger.error("[ApiClient] _ajvErrorHuman",t),e.map((({message:e})=>e))}}checkAndThrowApiResponseError(e){const t=e.data;if(!t||"object"!=typeof t)return e;if("boolean"==typeof t.result&&!1===t.result)throw new u(t.msg||"Erreur inconnue",e.status,t);if(t.resultErrors&&"object"==typeof t.resultErrors&&"boolean"==typeof t.resultErrors.result&&!1===t.resultErrors.result)throw new u(t.resultErrors.msg||"Erreur inconnue",e.status,t);return e}resetSession(){this.setToken(null),this.setRefreshToken(null),this._setUserId(null),this._tokenStorage.clear(),delete this._client.defaults.headers.common.Authorization,this._logger.info("[ApiClient] Session utilisateur réinitialisée."),this.emit("sessionReset")}_getValueByPath(e,t){if(t)return t.split(".").reduce(((e,t)=>e&&e[t]),e)}static toURLSearchParams(e,t={}){return this._buildParams(e,new URLSearchParams,t)}static _buildParams(e,t,o={}){if("object"!=typeof e||null===e)throw new TypeError("La donnée doit être un objet non nul.");const{dots:n=!1,indexes:r=!1,metaTokens:i=!0}=o,s=[];function a(e){return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)}function c(e){return e.endsWith("[]")?e.slice(0,-2):e}function p(e,t,o=!1){return e?e.concat(t).map(((e,t)=>(e=c(e),!o&&t?`[${e}]`:e))).join(o?".":""):t}function m(e){return null==e?"":e instanceof Date?e.toISOString():(e instanceof Blob||e instanceof File||e instanceof ArrayBuffer||ArrayBuffer.isView(e),e)}return function e(o,d=[]){null==o||s.includes(o)||(s.push(o),Object.entries(o).forEach((([o,s])=>{void 0!==s&&function(e,o,s){if(e&&"object"==typeof e){if(o.endsWith("{}"))return o=i?o:o.slice(0,-2),t.append(p(s,o,n),JSON.stringify(e)),!1;if(Array.isArray(e)&&!e.some(a)||o.endsWith("[]"))return o=c(o),e.forEach(((e,i)=>{if(null!=e){const a=r?p(s.concat(o),i,n):`${p(s,o,n)}[]`;t.append(a,m(e))}})),!1}return!!a(e)||(t.append(p(s,o,n),m(e)),!1)}(s,o.trim(),d)&&e(s,d.concat(c(o)))})),s.pop())}(e),t}_transformData(e){if(e&&"object"==typeof e)if(e.resultGoods?.msg)e=this._normalizeJsonData({msg:e.resultGoods.msg,...e});else if(e.resultErrors?.msg)e=this._normalizeJsonData({msg:e.resultErrors.msg,...e});else if(e.results&&"object"==typeof e.results&&!Array.isArray(e.results))e.results=Object.keys(e.results).map((t=>this._normalizeJsonData({id:t,...e.results[t]})));else if(Array.isArray(e.results))e.results=e.results.map((e=>this._normalizeJsonData(e)));else if(e.news&&Array.isArray(e.news)&&0===e.news.length)e=e.news;else if(e.news&&"object"==typeof e.news&&!Array.isArray(e.news))e=Object.keys(e.news).map((t=>this._normalizeJsonData({id:t,...e.news[t]})));else if(e.notif&&"object"==typeof e.notif&&!Array.isArray(e.notif))e.notif=Object.keys(e.notif).map((t=>this._normalizeJsonData({id:t,...e.notif[t]})));else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens)&&e.organizations&&"object"==typeof e.organizations&&!Array.isArray(e.organizations))e=[...Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]}))),...Object.keys(e.organizations).map((t=>this._normalizeJsonData({id:t,...e.organizations[t]})))];else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens))e=Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]})));else if(e.cities&&"object"==typeof e.cities&&!Array.isArray(e.cities))e=Object.keys(e.cities).map((t=>this._normalizeJsonData({id:t,...e.cities[t]})));else if(e.cities&&Array.isArray(e.cities)&&0===e.cities.length)e=e.cities;else if(e.newComment&&"object"==typeof e.newComment)e.newComment=this._normalizeJsonData({...e.newComment});else if(Array.isArray(e))e=e.map((e=>this._normalizeJsonData(e)));else if(e.map&&"object"==typeof e.map)e.map=this._normalizeJsonData(e.map);else if(e.object&&"object"==typeof e.object)e.object=this._normalizeJsonData(e.object);else if("object"==typeof e&&Object.keys(e).length>0){const t=Object.keys(e).every((e=>/^[0-9a-fA-F]{24}$/.test(e)));e=t?Object.keys(e).map((t=>({id:t,...this._normalizeJsonData(e[t])}))):this._normalizeJsonData(e)}return e}_normalizeJsonData(e){if(!e||"object"!=typeof e)return e;if(e=this._normalizeRecursively(e),e?.mediaImg?.images&&Array.isArray(e.mediaImg.images)&&e.mediaImg.images.length>0&&(e.mediaImg.countImages=e.mediaImg.images.length),e?.mediaFile?.files&&Array.isArray(e.mediaFile.files)&&e.mediaFile.files.length>0&&(e.mediaFile.countFiles=e.mediaFile.files.length),e?.src?.changes&&"object"==typeof e.src.changes&&Object.keys(e.src.changes).length>0&&Object.keys(e.src.changes).forEach((t=>{e.src.changes[t]&&(e.src.changes[t]=this._ensureFullURL(e.src.changes[t]))})),e?.openingHours&&Array.isArray(e.openingHours)&&e.openingHours.length>0&&(e.openingHours=e.openingHours.filter((e=>e.dayOfWeek&&e.hours&&e.hours[0]&&e.hours[0].opens))),e.replies&&"object"==typeof e.replies&&Object.keys(e.replies).length>0&&(e.replies=Object.keys(e.replies).map((t=>this._normalizeJsonData({id:t,...e.replies[t]})))),e?.author&&"object"==typeof e.author&&Object.keys(e.author).length>0&&!("profilThumbImageUrl"in e.author)){const t=Object.keys(e.author)[0];e.author={...e.author[t]}}return e?.timeAgo&&delete e.timeAgo,this._fromJSONValue?N.fromJSONValue(e):e}_ensureFullURL(e){if(!e)return e;if(!(e=e.trim())||/^https?:\/\//i.test(e))return e;let t="/";return t=this._baseURL.endsWith("/")&&e.startsWith("/")||this._baseURL.endsWith("/")||e.startsWith("/")?"":"/",`${this._baseURL}${t}${e}`}_normalizeString(e){return"true"===e||"false"!==e&&e}_normalizeId(e){return e._id&&e._id.$id&&/^[0-9a-fA-F]{24}$/.test(e._id.$id)&&(e.id=e._id.$id,e._id={$type:"oid",$value:e._id.$id}),e.id&&e.id.$id&&/^[0-9a-fA-F]{24}$/.test(e.id.$id)&&(e._id={$type:"oid",$value:e.id.$id},e.id=e.id.$id),e}_normalizeDate(e){return e&&"object"==typeof e&&"number"==typeof e.sec?{$date:1e3*e.sec}:"number"==typeof e?{$date:1e3*e}:e}_normalizeImage(e){return"string"==typeof e&&""!==e.trim()?this._ensureFullURL(e):e}_imageFields=["profilImageUrl","profilThumbImageUrl","profilMediumImageUrl","profilMarkerImageUrl","profilBannerUrl","profilRealBannerUrl","imagePath","imageThumbPath","docPath"];_dateFields=["modified","created","updated","birthDate","lastLoginDate","startDate","endDate","date"];_normalizeRecursively(e){if("string"==typeof e)return this._normalizeString(e);if(Array.isArray(e))return e.map((e=>this._normalizeRecursively(e)));if(null!==e&&"object"==typeof e){const t={};return Object.keys(e).forEach((o=>{let n=this._normalizeRecursively(e[o]);this._dateFields.includes(o)&&(n=this._normalizeDate(n)),this._imageFields.includes(o)&&(n=this._normalizeImage(n)),"content"===o&&n&&"object"==typeof n&&n.image&&(n.image=this._normalizeImage(n.image)),t[o]=n})),this._normalizeId(t)}return e}_startBeforeEndValidate=(e,t)=>{if(!t.startDate||!t.endDate)return!0;const o=new Date(t.startDate)<new Date(t.endDate);return o||(this._startBeforeEndValidate.errors=[{instancePath:"",schemaPath:"#/startBeforeEnd",keyword:"startBeforeEnd",params:{},message:"startDate must be before endDate"}]),o};getRequestSchema(e){const t=this._endpoints.find((t=>t.constant===e));return t?.request||null}getPathSchema(e){return this._endpoints.find((t=>t.constant===e))?.pathParams||null}}class R{constructor(e){this.client=new U(e),this.loggedUser=null}get isConnected(){return this.client.isConnected}get userId(){return this.client.userId}async login(e,t){return this.client.safeCall((async()=>{const o=await this.client.callEndpoint("AUTHENTICATE_URL",{email:e,password:t});return this.loggedUser=new O(this.client,o.data.user,{EndpointApi:y,Organization:P,Project:I,News:_}),this.loggedUser}))}async meIsconnected(){if(!this.client.isConnected||!this.client.userId)throw new p("User not connected",401);return this.client._logger.info("UserApi","meIsconnected",this.client.userId),this.loggedUser=new O(this.client,{id:this.client.userId},{EndpointApi:y,Organization:P,Project:I,News:_}),this.loggedUser}async register({name:e,username:t,email:o,pwd:n}={}){return this.client.safeCall((async()=>{const r=await this.client.callEndpoint("PERSON_REGISTER",{name:e,username:t,email:o,pwd:n});if(!1===r?.data?.result)throw new u(r.data.msg,r.status,r.data);return r.data}))}async recoverPassword(e){return this.client.safeCall((async()=>{const t=await this.client.callEndpoint("PASSWORD_RECOVERY",{email:e});if(!1===t?.data?.result)throw new u(t.data.msg,t.status,t.data);return t.data}))}}class F{static async userLogin(e,t,o){const n=F.userApi(o);return await F.userApiLogin(n,e,t)}static userApi(e){try{return new R(e)}catch(e){throw console.error("[Api.userApi] Erreur lors de la création d'un objet utilisateur :",e.message),e}}static async userApiLogin(e,t,o){try{if(!e)throw new p("userApi is not defined");if(!e.client)throw new p("userApi.client is not defined");if(e.client.isConnected){const t=await e.meIsconnected();return new F(t,e.client)}{if(!t||!o)throw new p("email and password are required");const n=await e.login(t,o);return new F(n,e.client)}}catch(e){if(e instanceof m&&e?.details?.error)throw new h(e.details.error,e.status,e.details);throw e}}constructor(e,t){this._loggedUser=e,this._client=t}async me(){if(!this._loggedUser)throw new h("Accès refusé : utilisateur non authentifié.");return await this._loggedUser.get(),this._loggedUser}async user(e){try{if(e.id||e.slug){const t=new O(this._client,e,{EndpointApi:y,Organization:P,Project:I,News:_});return await t.get(),t}return new O(this._client,e,{EndpointApi:y,Organization:P,Project:I,News:_})}catch(e){throw console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :",e.message),e}}async organization(e){try{const t=new P(this._client,e,{EndpointApi:y,User:O,Project:I,News:_});if(!e.id&&!e.slug)throw new Error("Vous devez fournir un id ou un slug pour créer une instance Organization.");return await t.get(),t}catch(e){throw console.error("[Api.organization] Erreur lors de la création d'un objet organisation :",e.message),e}}async project(e){try{const t=new I(this._client,e,{User:O,News:_,EndpointApi:y});if(!e.id&&!e.slug)throw new Error("Vous devez fournir un id ou un slug pour créer une instance Project.");return await t.get(),t}catch(e){throw console.error("[Api.project] Erreur lors de la création d'un objet projet :",e.message),e}}get client(){return this._client}get endpointApi(){return new y(this._client)}logout(){this.loggedUser=null,this._client.resetSession(),this._client._logger.info("UserApi: User logged out")}}const G={ApiClient:U,Api:F,error:c,tokenStorageStrategy:{createDefaultTokenStorageStrategy:async function(e="auto"){if("memory"===e)return new B.GN;if("localStorage"===e){if("undefined"!=typeof window&&window.localStorage)return new B.Ge;throw new Error("localStorage is not available in this environment.")}if("file"===e){if("undefined"!=typeof window&&window.localStorage)throw new Error("file storage is not available in this environment.");const{FileStorageStrategy:e}=await s.e(405).then(s.bind(s,405));return new e}if("auto"===e){if("undefined"!=typeof window&&window.localStorage)return new B.Ge;{const{FileStorageStrategy:e}=await s.e(405).then(s.bind(s,405));return new e}}},TokenStorageStrategy:B.u3}};module.exports=a})();
1
+ (()=>{"use strict";var e,t,o,n={3:e=>{e.exports=require("path")},27:(e,t,o)=>{o.d(t,{GN:()=>r,Ge:()=>i,u3:()=>n});class n{getAccessToken(){throw new Error("getAccessToken() doit être implémenté")}setAccessToken(e){throw new Error("setAccessToken() doit être implémenté")}getRefreshToken(){throw new Error("getRefreshToken() doit être implémenté")}setRefreshToken(e){throw new Error("setRefreshToken() doit être implémenté")}clear(){throw new Error("clear() doit être implémenté")}}class r extends n{constructor(){super(),this._accessToken=null,this._refreshToken=null}getAccessToken(){return this._accessToken}setAccessToken(e){this._accessToken=e}getRefreshToken(){return this._refreshToken}setRefreshToken(e){this._refreshToken=e}clear(){this._accessToken=null,this._refreshToken=null}}class i extends n{constructor(e="cocolight"){super(),this.prefix=e}getAccessToken(){return"undefined"!=typeof localStorage?localStorage.getItem(`${this.prefix}_accessToken`):null}setAccessToken(e){"undefined"!=typeof localStorage&&localStorage.setItem(`${this.prefix}_accessToken`,e)}getRefreshToken(){return"undefined"!=typeof localStorage?localStorage.getItem(`${this.prefix}_refreshToken`):null}setRefreshToken(e){"undefined"!=typeof localStorage&&localStorage.setItem(`${this.prefix}_refreshToken`,e)}clear(){"undefined"!=typeof localStorage&&(localStorage.removeItem(`${this.prefix}_accessToken`),localStorage.removeItem(`${this.prefix}_refreshToken`))}}},272:e=>{e.exports=require("stream")},366:e=>{e.exports=require("os")},383:e=>{e.exports=require("fs")}},r={};function i(e){var t=r[e];if(void 0!==t)return t.exports;var o=r[e]={exports:{}};return n[e](o,o.exports,i),o.exports}i.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(o,n){if(1&n&&(o=this(o)),8&n)return o;if("object"==typeof o&&o){if(4&n&&o.__esModule)return o;if(16&n&&"function"==typeof o.then)return o}var r=Object.create(null);i.r(r);var a={};e=e||[null,t({}),t([]),t(t)];for(var s=2&n&&o;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach((e=>a[e]=()=>o[e]));return a.default=()=>o,i.d(r,a),r},i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,o)=>(i.f[o](e,t),t)),[])),i.u=e=>e+".cocolight-api-client.cjs",i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o={792:1},i.f.require=(e,t)=>{o[e]||(e=>{var t=e.modules,n=e.ids,r=e.runtime;for(var a in t)i.o(t,a)&&(i.m[a]=t[a]);r&&r(i);for(var s=0;s<n.length;s++)o[n[s]]=1})(require("./"+i.u(e)))};var a={};i.r(a),i.d(a,{default:()=>G});var s={};i.r(s),i.d(s,{ApiAuthenticationError:()=>u,ApiClientError:()=>p,ApiError:()=>c,ApiResponseError:()=>l,ApiValidationError:()=>m,CircuitBreakerError:()=>d});class c extends Error{constructor(e,t,o){super(e),this.name="ApiError",this.status=t,this.details=o}}class p extends c{constructor(e,t,o){super(e,t,o),this.name="ApiClientError"}}class m extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiValidationError",this.status=t,this.messages=o,this.details=n}}class d extends c{constructor(e){super(e,503),this.name="CircuitBreakerError"}}class l extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiResponseError",this.status=t,this.responseData=o,this.details=n}}class u extends c{constructor(e,t,o){super(e,t,o),this.name="ApiAuthenticationError"}}const h=class{constructor(e){this.apiClient=e}get isConnected(){return this.apiClient.isConnected}get userId(){return this.apiClient.userId}async call(e,t={}){return this.apiClient.safeCall((async()=>{const o=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(o),o.data}))}async callNoConnected(e,t={}){if(this.isConnected)throw new u("Vous ne devez pas être connecté pour faire cette action.");return this.call(e,t)}async callIsConnected(e,t={}){if(!this.isConnected)throw new u("Vous devez être connecté pour effectuer cette action.");return this.call(e,t)}async personRegister(e={}){return this.callNoConnected("PERSON_REGISTER",e)}async authenticateUrl(e={}){return this.callNoConnected("AUTHENTICATE_URL",e)}async refreshTokenUrl(e={}){return this.call("REFRESH_TOKEN_URL",e)}async meInfoUrl(e={}){return this.callIsConnected("ME_INFO_URL",e)}async passwordRecovery(e={}){return this.callNoConnected("PASSWORD_RECOVERY",e)}async serverExchangeToken(e={}){return this.callIsConnected("SERVER_EXCHANGE_TOKEN",e)}async changePassword(e={}){return this.callIsConnected("CHANGE_PASSWORD",e)}async deleteAccount(e={}){return this.callIsConnected("DELETE_ACCOUNT",e)}async updateSettings(e={}){return this.callIsConnected("UPDATE_SETTINGS",e)}async updateBlockDescription(e={}){return this.callIsConnected("UPDATE_BLOCK_DESCRIPTION",e)}async updateBlockInfo(e={}){return this.callIsConnected("UPDATE_BLOCK_INFO",e)}async updateBlockSocial(e={}){return this.callIsConnected("UPDATE_BLOCK_SOCIAL",e)}async updateBlockLocality(e={}){return this.callIsConnected("UPDATE_BLOCK_LOCALITY",e)}async updateBlockSlug(e={}){return this.callIsConnected("UPDATE_BLOCK_SLUG",e)}async check(e={}){return this.callIsConnected("CHECK",e)}async profilImage(e={}){return this.callIsConnected("PROFIL_IMAGE",e)}async getElementsAbout(e={}){return this.call("GET_ELEMENTS_ABOUT",e)}async multiconnect(e={}){return this.callIsConnected("MULTICONNECT",e)}async getNews(e={}){return this.call("GET_NEWS",e)}async getNewsById(e={}){return this.call("GET_NEWS_BY_ID",e)}async addNews(e={}){return this.callIsConnected("ADD_NEWS",e)}async addImageNews(e={}){return this.callIsConnected("ADD_IMAGE_NEWS",e)}async addFileNews(e={}){return this.callIsConnected("ADD_FILE_NEWS",e)}async deleteNews(e={}){return this.callIsConnected("DELETE_NEWS",e)}async updateNews(e={}){return this.callIsConnected("UPDATE_NEWS",e)}async shareNews(e={}){return this.callIsConnected("SHARE_NEWS",e)}async getComments(e={}){return this.call("GET_COMMENTS",e)}async addComments(e={}){return this.callIsConnected("ADD_COMMENTS",e)}async deleteComments(e={}){return this.callIsConnected("DELETE_COMMENTS",e)}async updateComments(e={}){return this.callIsConnected("UPDATE_COMMENTS",e)}async searchTags(e={}){return this.call("SEARCH_TAGS",e)}async showVote(e={}){return this.call("SHOW_VOTE",e)}async globalAutocomplete(e={}){return this.call("GLOBAL_AUTOCOMPLETE",e)}async cityAutocomplete(e={}){return this.call("CITY_AUTOCOMPLETE",e)}async suggestionInput(e={}){return this.call("SUGGESTION_INPUT",e)}async getProjectsNoAdmin(e={}){return this.call("GET_PROJECTS_NO_ADMIN",e)}async getProjectsAdmin(e={}){return this.callIsConnected("GET_PROJECTS_ADMIN",e)}async getPoisNoAdmin(e={}){return this.call("GET_POIS_NO_ADMIN",e)}async getPoisAdmin(e={}){return this.callIsConnected("GET_POIS_ADMIN",e)}async getOrganizationsNoAdmin(e={}){return this.call("GET_ORGANIZATIONS_NO_ADMIN",e)}async getOrganizationsAdmin(e={}){return this.callIsConnected("GET_ORGANIZATIONS_ADMIN",e)}async getMembersNoAdmin(e={}){return this.call("GET_MEMBERS_NO_ADMIN",e)}async getMembersAdmin(e={}){return this.callIsConnected("GET_MEMBERS_ADMIN",e)}async getFriendsAdmin(e={}){return this.callIsConnected("GET_FRIENDS_ADMIN",e)}async getSubscriptions(e={}){return this.call("GET_SUBSCRIPTIONS",e)}async getSubscriptionsAdmin(e={}){return this.callIsConnected("GET_SUBSCRIPTIONS_ADMIN",e)}async getSubscribers(e={}){return this.call("GET_SUBSCRIBERS",e)}async getSubscribersAdmin(e={}){return this.callIsConnected("GET_SUBSCRIBERS_ADMIN",e)}async getContributors(e={}){return this.call("GET_CONTRIBUTORS",e)}async getContributorsAdmin(e={}){return this.callIsConnected("GET_CONTRIBUTORS_ADMIN",e)}async getBadges(e={}){return this.call("GET_BADGES",e)}async getBadgesFilters(e={}){return this.call("GET_BADGES_FILTERS",e)}async connect(e={}){return this.callIsConnected("CONNECT",e)}async disconnect(e={}){return this.callIsConnected("DISCONNECT",e)}async getElementsKey(e={}){return this.call("GET_ELEMENTS_KEY",e)}async getFavoris(e={}){return this.callIsConnected("GET_FAVORIS",e)}async deleteFavoris(e={}){return this.callIsConnected("DELETE_FAVORIS",e)}async addFavoris(e={}){return this.callIsConnected("ADD_FAVORIS",e)}async addOrganization(e={}){return this.callIsConnected("ADD_ORGANIZATION",e)}async addProject(e={}){return this.callIsConnected("ADD_PROJECT",e)}async addPoi(e={}){return this.callIsConnected("ADD_POI",e)}async addEvent(e={}){return this.callIsConnected("ADD_EVENT",e)}async deletePoi(e={}){return this.callIsConnected("DELETE_POI",e)}async deleteEvent(e={}){return this.callIsConnected("DELETE_EVENT",e)}async deleteElement(e={}){return this.callIsConnected("DELETE_ELEMENT",e)}async addImageElement(e={}){return this.callIsConnected("ADD_IMAGE_ELEMENT",e)}async linkValidate(e={}){return this.callIsConnected("LINK_VALIDATE",e)}async searchMemberAutocomplete(e={}){return this.call("SEARCH_MEMBER_AUTOCOMPLETE",e)}async getNotifications(e={}){return this.callIsConnected("GET_NOTIFICATIONS",e)}async getNotificationsCount(e={}){return this.callIsConnected("GET_NOTIFICATIONS_COUNT",e)}async notificationUpdate(e={}){return this.callIsConnected("NOTIFICATION_UPDATE",e)}async removeAllNotifications(e={}){return this.callIsConnected("REMOVE_ALL_NOTIFICATIONS",e)}async markNotificationAsRead(e={}){return this.callIsConnected("MARK_NOTIFICATION_AS_READ",e)}async activitypubSearch(e={}){return this.call("ACTIVITYPUB_SEARCH",e)}async activitypubLink(e={}){return this.callIsConnected("ACTIVITYPUB_LINK",e)}async activitypubGetCommunity(e={}){return this.call("ACTIVITYPUB_GET_COMMUNITY",e)}async getBadge(e={}){return this.call("GET_BADGE",e)}async getEmetteurBadges(e={}){return this.call("GET_EMETTEUR_BADGES",e)}async addBadges(e={}){return this.callIsConnected("ADD_BADGES",e)}async assignBadges(e={}){return this.callIsConnected("ASSIGN_BADGES",e)}async getEvents(e={}){return this.call("GET_EVENTS",e)}async shareEvents(e={}){return this.callIsConnected("SHARE_EVENTS",e)}async inviteEvent(e={}){return this.callIsConnected("INVITE_EVENT",e)}},y={_createDraftProxy:(e,t={},o={},n=[],r={},i={})=>new Proxy({},{get:(e,n)=>{const i=n in o?o[n]:t[n],a=r[n];return"function"==typeof a?a(i):i},set:(t,r,a)=>{if(!n.includes(r)){const t=`[DraftProxy] Le champ "${r}" n'est pas autorisé.`;if(i.throwOnError)throw new m(t,400,null,{field:r,value:a,allowedFields:n});return e._logger.warn(t),!1}return o[r]=a,!0},deleteProperty:(e,t)=>!!n.includes(t)&&(delete o[t],!0),has:(e,n)=>n in o||n in t,ownKeys:()=>[...new Set([...Object.keys(t),...Object.keys(o)])],getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})}),_extractWritableFields(e={},t={},o={defs:{},visited:new Set}){if(!e||"object"!=typeof e)return[];if(e.$id&&o.visited.has(e.$id))return[];e.$id&&o.visited.add(e.$id),o.defs=e.$defs||e.definitions||o.defs;const n=[];if(e.$ref){const r=e.$ref.replace(/^#\/?(\$defs|definitions)\//,""),i=o.defs?.[r];i&&n.push(...this._extractWritableFields(i,t,o))}if(e.allOf&&e.allOf.forEach((e=>n.push(...this._extractWritableFields(e,t,o)))),e.if&&e.then){const r=e.if?.properties;let i=!0;if(r)for(const e in r){const o=r[e]?.const;if(t[e]!==o){i=!1;break}}i&&e.then?n.push(...this._extractWritableFields(e.then,t,o)):!i&&e.else&&n.push(...this._extractWritableFields(e.else,t,o))}return e.properties&&n.push(...Object.entries(e.properties).filter((([e,t])=>!0!==t.readOnly&&void 0===t.const)).map((([e])=>e))),[...new Set(n)]},_buildDraftAndProxy({data:e={},serverData:t=null,constant:o,apiClient:n,transforms:r={},throwOnError:i=!0,removeFields:a=[]}){const s=Array.isArray(o)?o:[o],p={allOf:[],$defs:{}};for(const e of s){const t=n.getRequestSchema(e);if(!t)throw new c(`Unable to find schema for ${e}.`);if(t.$defs)for(const[o,r]of Object.entries(t.$defs))p.$defs[o]?n._logger.warn(`Duplicate $defs key '${o}' from schema '${e}'`):p.$defs[o]=r;p.allOf.push(t)}const m={};let d=this._extractWritableFields(p,e);e.id&&-1===d.indexOf("id")&&d.push("id"),e.slug&&-1===d.indexOf("slug")&&d.push("slug"),d=d.filter((e=>!a.includes(e)));for(const t of d){const o=e[t],n="function"==typeof r[t]?r[t](o,e):o;void 0!==n&&(m[t]=n)}return{draft:m,proxy:this._createDraftProxy(n,t,m,d,r,{throwOnError:i})}},_extractChangedFieldsFromSchema(e,t,o={},n,r=[]){const i=e.getRequestSchema(t);let a=this._extractWritableFields(i,o);const s={},c=n?.()||{};a=a.filter((e=>!r.includes(e)));for(const e of a){if(void 0===o[e])continue;const t=o[e],n=c[e];JSON.stringify(t)!==JSON.stringify(n)&&(s[e]=t)}return Object.keys(s).length>0?s:null}},f=require("bson-objectid"),g=require("file-type"),T={async call(e,t={}){return this.apiClient.safeCall((async()=>{const o=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(o),o.data}))},async callNoConnected(e,t={}){if(this.isConnected)throw new u("Vous devez ne devez pas être connecté pour faire cette action.");return this.call(e,t)},async callIsConnected(e,t={}){if(!this.isConnected)throw new u("Vous devez être connecté pour faire cette action.");return"function"==typeof e?await e():this.call(e,t)},async callIsMe(e,t={}){if(!this.isMe)throw new u("Vous devez être vous-même pour faire cette action.");return"function"==typeof e?await e():await this.callIsConnected(e,t)},async _validateImage(e){return await this._validateUploadInput(e,{allowedMimeTypes:["image/jpeg","image/png","image/jpg"],expectedType:"image"})},async _validateFile(e){return await this._validateUploadInput(e,{allowedMimeTypes:["application/pdf","text/plain","text/csv"],expectedType:"file"})},async _validateUploadInput(e,{allowedMimeTypes:t=[],expectedType:o="any"}){if(!e)throw new m("Le fichier est requis.");const n="undefined"==typeof window&&"undefined"!=typeof process;let r="",i=e;if("undefined"!=typeof File&&e instanceof File){if(r=e.type,!t.includes(r))throw new m("Le type du fichier est invalide.")}else if("undefined"!=typeof Blob&&e instanceof Blob){if(r=e.type,!t.includes(r))throw new m("Le type du fichier est invalide.");const o=r.split("/")[1]||"bin",n=`${Date.now()}.${o}`;i=new File([e],n,{type:r})}else if(n&&Buffer.isBuffer(e)){const n=await(0,g.fileTypeFromBuffer)(e);if(r=n?.mime,!n||!t.includes(r))throw new m("Le type du fichier est invalide.");if("image"===o){const t=n.ext,o=`${Date.now()}.${t}`;i=await this._createReadStreamFromBuffer(e,o,r)}}else{if(!n||!e?.readable||"function"!=typeof e._read)throw new m("Type de fichier non reconnu.");{const o=[],n=await this._passThrough(),a=await this._passThrough(),s=4100;let c=0;e.on("data",(e=>{c<s&&(o.push(e),c+=e.length)})),e.pipe(n).pipe(a),await new Promise((e=>setTimeout(e,10)));const p=Buffer.concat(o),d=await(0,g.fileTypeFromBuffer)(p);if(r=d?.mime,!d||!t.includes(r))throw new m("Le type du fichier est invalide.");a.path=`${Date.now()}.${d.ext}`,a.mimeType=r,i=a}}return i},async _createReadStreamFromBuffer(e,t="file.bin",o="application/octet-stream"){const n=await this._bufferToReadable(e);return n.path=t,n.mimeType=o,n},async _bufferToReadable(e){if("undefined"==typeof window){const{bufferToReadable:t}=await i.e(931).then(i.bind(i,931));return t(e)}throw new Error("bufferToReadable ne doit pas être appelé dans le navigateur")},async _passThrough(){if("undefined"==typeof window){const{createPassThrough:e}=await i.e(931).then(i.bind(i,931));return e()}throw new Error("passThrough ne doit pas être appelé dans le navigateur")},_omitProps(e,t){if(!e||"object"!=typeof e)return{};const o={...e};for(const e of t)delete o[e];return o},_pickProps(e,t,o={}){if(!e||"object"!=typeof e)return{};const n={};for(const r of t)if(r in e){const t=e[r];"function"==typeof o[r]?n[r]=o[r](t,e):n[r]=t}return n},_createFilteredProxy:e=>new Proxy(e,{get:(e,t,o)=>"string"!=typeof t||isNaN(t)?"length"===t?e.filter((e=>!e._isDeleted)).length:"function"==typeof e[t]?(...o)=>e.filter((e=>!e._isDeleted))[t](...o):Reflect.get(e,t,o):e.filter((e=>!e._isDeleted))[t]}),_newId:()=>(new f).toString()};class w{#e={};#t={};#o=null;static entityType="news";static SCHEMA_CONSTANTS=["ADD_NEWS"];constructor(e,t={},o={}){if(this.__entityTag="News",!o.EndpointApi)throw new c("EndpointApi class must be injected to avoid circular dependency.");if(!o.User)throw new c("User class must be injected.");if(!e)throw new c("Parent is required.");if(this.deps=o,this.EndpointApiClass=o.EndpointApi,"User"!==e?.__entityTag&&"Organization"!==e?.__entityTag&&"Project"!==e?.__entityTag)throw new c("Invalid parent for News.");this.apiClient=e.apiClient,this.parent=e,this.endpointApi="function"==typeof o.EndpointApi?new o.EndpointApi(this.apiClient):"object"==typeof o.EndpointApi?o.EndpointApi:(()=>{throw new c("deps.EndpointApi must be a class or instance.")})(),this.#o=null;const{draft:n,proxy:r}=this._buildDraftAndProxy({data:{...t,...this.defaultFields},serverData:this.#o,constant:w.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(n)),this.#e=n,this.data=r}get id(){return this.#e.id||null}get isConnected(){return this.apiClient.isConnected}get draftData(){return this.#e}get initialDraftData(){return this.#t}get serverData(){return this.#o}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.parent.id}_setData(e){this.#o={...e};const{draft:t,proxy:o}=this._buildDraftAndProxy({data:{...e,...this.defaultFields},serverData:this.#o,constant:w.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(t)),this.#e=t,this.data=o}getEntityType(){return w.entityType}static fromServerData(e,t,o){const n=new w(t,{},o);n.#o={...e};const{draft:r,proxy:i}=n._buildDraftAndProxy({data:{...e,...n.defaultFields},serverData:n.#o,constant:w.SCHEMA_CONSTANTS,apiClient:n.apiClient,transforms:n.transforms,removeFields:n.removeFields});return n.#e=r,n.data=i,n}async refresh(){if(!this.id)throw new c("Impossible de rafraîchir sans ID.");return this.get()}async get(){if(!this.id)throw new c("Impossible de rafraîchir sans ID.");const e=await this.callIsConnected((()=>this.endpointApi.getNewsById({ids:[this.id]})));if(e&&Array.isArray(e)&&1===e.length){const t=e[0];return this.#o={...t},this._setData(t),this.#o}throw new c(`Aucune actualité trouvée pour l'ID ${this.id}`)}async save(){if(!this.isConnected)throw new c("Impossible de sauvegarder sans être connecté.");""===this.#e?.text&&(this.#e.text=" ");const e={...this.#e};if(e.parentId=this.parent.id,e.parentType=this.parent.getEntityType(),this.id){e.id&&delete e.id;const t=await this.callIsConnected((()=>this.endpointApi.updateNews({...e,idNews:this.id})));return t?.object&&(this.#o={...t.object}),t}{const t=await this.callIsConnected((()=>this.endpointApi.addNews(e)));return this.#e.id=t.object.id,t?.object&&(this.#o={...t.object}),t}}async addMention({slug:e,id:t}){try{if(!e&&!t)throw new c("Vous devez fournir un slug ou un id pour ajouter une mention.");const o=new this.deps.User(this.apiClient,{id:t,slug:e},{EndpointApi:this.endpointApi}),n=o.serverData;if(this.#e.mentions||(this.#e.mentions=[]),this.#e.mentions.find((e=>e.id===n.id)))return this.#e.mentions=this.#e.mentions.map((e=>(e.id===n.id&&(e.count+=1),e))),this.#e.mentions;const r={id:n.id,slug:n.slug,type:o.getEntityType(),name:n.name,value:n.name,count:1};return this.#e.mentions.push(r),this.#e.mentions}catch(e){throw this.apiClient._logger.error("Erreur lors de l'ajout de la mention :",e),e}}async addImage(e){e=await this._validateImage(e);const t={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsImage:e},o=await this.callIsConnected((()=>this.endpointApi.addImageNews(t)));return this.#e.mediaImg?(this.#e.mediaImg.countImages=this.#e.mediaImg.countImages+1,this.#e.mediaImg.images.push(o.id)):this.#e.mediaImg={countImages:1,images:[o.id]},o}async addFile(e){e=await this._validateFile(e);const t={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsFile:e},o=await this.callIsConnected((()=>this.endpointApi.addFileNews(t)));return this.#e.mediaFile?(this.#e.mediaFile.countFiles=this.#e.mediaFile.countFiles+1,this.#e.mediaFile.files.push(o)):this.#e.mediaFile={countFiles:1,files:[o]},o}async delete(){if(!this.id)throw new c("Vous devez fournir un id pour supprimer une news.");const e={pathParams:{id:this.id}};await this.callIsConnected((()=>this.endpointApi.deleteNews(e))),this.#e={},this.#o=null,this.#e.id=null,this._isDeleted=!0}_updateInitialDraftSnapshot(){this.#t=JSON.parse(JSON.stringify(this.#e))}hasChanges(){return JSON.stringify(this.#e)!==JSON.stringify(this.#t)}defaultFields={};removeFields=[];transforms={scope:e=>e?.type,mentions:e=>Array.isArray(e)?e.map((e=>({...e,count:parseInt(e.count)}))):[],mediaImg:e=>{const t=e?.images?.map((e=>e.id)).filter(Boolean)||[];return t.length>0?{countImages:t.length,images:t}:void 0},mediaFile:e=>{const t=e?.files?.map((e=>e.id)).filter(Boolean)||[];return t.length>0?{countFiles:t.length,files:t}:void 0}}}Object.assign(w.prototype,T,y);const _={async get(){return this.apiClient.safeCall((async()=>{const e=await this.getPublicProfile();return this._setData(e),e}))},async updateSettings(e={}){return e.idEntity=this.id,e.typeEntity=this.getEntityType(),this.callIsConnected((()=>this.endpointApi.updateSettings(e)))},async updateDescription(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockDescription(e)))},async updateInfo(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockInfo(e)))},async updateSocial(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockSocial(e)))},async updateLocality(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockLocality(e)))},async updateSlug({slug:e}){try{await this.endpointApi.check({type:this.getEntityType(),id:this.id,slug:e})}catch(e){if(e instanceof l)throw new l("Erreur lors de la vérification du slug.",e.status,e.data);throw e}return this.callIsConnected((()=>this.endpointApi.updateBlockSlug({typeElement:this.getEntityType(),id:this.id,slug:e})))},async updateImageProfil({profil_avatar:e}){e=await this._validateImage(e);const t={pathParams:{folder:this.getEntityType(),ownerId:this.id},profil_avatar:e};return this.callIsConnected((()=>this.endpointApi.profilImage(t)))}},b={async resolveId(e){if(!this.id&&this.slug)try{const t=await this.endpointApi.getElementsKey({pathParams:{slug:this.slug}});if(!t?.contextId||t?.contextType!==e)throw new l(`Le slug ${this.slug} ne correspond pas à un ${e}`,200,t);this._id(t.contextId)}catch(t){throw t instanceof l?t?.responseData?.contextType!==e?t:new l(`Impossible de récupérer l'identifiant pour le slug ${this.slug}`,t.status,t.responseData):t}return this.id},async getPublicProfile(){return await this.resolveId(this.getEntityType()),this.endpointApi.getElementsAbout({pathParams:{id:this.id,type:this.getEntityType()}})}},A={async getNews(e={}){e.pathParams={type:this.getEntityType(),id:this.id};const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new l("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>this.deps.News.fromServerData(e,this,{User:this.deps.User,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)},async news(e){try{const t=new this.deps.News(this,e,{User:this.deps.User,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.getEntityType()}.news] Erreur lors de la création d'une instance news :`,e.message),e}}};class E{#e={};#t={};#o=null;static entityType="organizations";static SCHEMA_CONSTANTS=["ADD_ORGANIZATION","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static ADD_BLOCKS=new Map([["ADD_ORGANIZATION","addOrganization"],["PROFIL_IMAGE",""]]);static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);constructor(e,t={},o={}){if(this.__entityTag="Organization",!o.EndpointApi)throw new c("EndpointApi class must be injected to avoid circular dependency.");if(!o.User)throw new c("User class must be injected.");if(!o.Project)throw new c("Project class must be injected.");if(!o.News)throw new c("News class must be injected.");if(!e)throw new c("Parent is required.");if(this.deps=o,this.EndpointApiClass=o.EndpointApi,"ApiClient"===e?.__entityTag)this.apiClient=e,this.parent=null;else{if("User"!==e?.__entityTag)throw new c("Invalid parent for Organization.");this.apiClient=e.apiClient,this.parent=e}this.endpointApi="function"==typeof o.EndpointApi?new o.EndpointApi(this.apiClient):"object"==typeof o.EndpointApi?o.EndpointApi:(()=>{throw new c("deps.EndpointApi must be a class or instance.")})(),this.#o=null;const{draft:n,proxy:r}=this._buildDraftAndProxy({data:{...t,...this.defaultFields},serverData:this.#o,constant:E.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(n)),this.#e=n,this.data=r}get id(){return this.#e.id||null}_id(e){this.#e.id=e}get slug(){return this.#e.slug||null}get isConnected(){return this.apiClient.isConnected}_setData(e){this.#o={...e};const{draft:t,proxy:o}=this._buildDraftAndProxy({data:{...e,...this.defaultFields},serverData:this.#o,constant:E.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(t)),this.#e=t,this.data=o}get userId(){return this.apiClient.userId}get draftData(){return this.#e}get initialDraftData(){return this.#t}get serverData(){return this.#o}get isMe(){return this.isConnected&&this.userId===this.parent?.id}getEntityType(){return E.entityType}static fromServerData(e,t,o){const n=new E(t,{},o);n.#o={...e};const{draft:r,proxy:i}=n._buildDraftAndProxy({data:{...e,...n.defaultFields},serverData:n.#o,constant:E.SCHEMA_CONSTANTS,apiClient:n.apiClient,transforms:n.transforms,removeFields:n.removeFields});return n.#e=r,n.data=i,n}async refresh(){if(!this.id)throw new c("Impossible de rafraîchir sans ID.");return this.get()}async save(){if(!this.isConnected)throw new c("Impossible de sauvegarder sans être connecté.");const e={...this.#e};return this.id?(await this._update(e)&&await this.refresh(),this.#o):(await this._add(e),await this.refresh(),this.#o)}async _add(e){e.id=this._newId(),e.slug&&delete e.slug;for(const[t,o]of E.ADD_BLOCKS){const n=this._extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(n&&Object.keys(n).length>0){const e=await this[o](n);!this.id&&e?.map?.id&&(this.#e.id=e.map.id,this.#e.slug=e.map.slug)}}}async _update(e){e.id&&delete e.id;let t=!1;for(const[o,n]of E.UPDATE_BLOCKS){const r=this._extractChangedFieldsFromSchema(this.apiClient,o,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);r&&Object.keys(r).length>0&&(await this[n](r),t=!0)}return t}addOrganization(e={}){return this.callIsConnected((()=>this.endpointApi.addOrganization(e)))}_updateInitialDraftSnapshot(){this.#t=JSON.parse(JSON.stringify(this.#e))}hasChanges(){return JSON.stringify(this.#e)!==JSON.stringify(this.#t)}defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={github:(e,t)=>t?.socialNetwork?.github,gitlab:(e,t)=>t?.socialNetwork?.gitlab,facebook:(e,t)=>t?.socialNetwork?.facebook,twitter:(e,t)=>t?.socialNetwork?.twitter,instagram:(e,t)=>t?.socialNetwork?.instagram,diaspora:(e,t)=>t?.socialNetwork?.diaspora,mastodon:(e,t)=>t?.socialNetwork?.mastodon,telegram:(e,t)=>t?.socialNetwork?.telegram,signal:(e,t)=>t?.socialNetwork?.signal};async project(e={}){try{const t=new this.deps.Project(this,e,{User:this.deps.User,News:this.deps.News,EndpointApi:this.deps.EndpointApi});return(e.id||e.slug)&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.project] Erreur lors de la création d'une instance project :`,e.message),e}}}Object.assign(E.prototype,T,b,_,A,y);class I{#e={};#t={};#o=null;static entityType="projects";static SCHEMA_CONSTANTS=["ADD_PROJECT","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static ADD_BLOCKS=new Map([["ADD_PROJECT","addProject"],["PROFIL_IMAGE","updateImageProfil"]]);static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);constructor(e,t={},o={}){if(this.__entityTag="Project",!o.EndpointApi)throw new c("EndpointApi class must be injected to avoid circular dependency.");if(!o.User)throw new c("User class must be injected.");if(!o.News)throw new c("News class must be injected.");if(!e)throw new c("Parent is required.");if(this.deps=o,this.EndpointApiClass=o.EndpointApi,"ApiClient"===e?.__entityTag)this.apiClient=e,this.parent=null;else{if("User"!==e?.__entityTag&&"Organization"!==e?.__entityTag&&"Project"!==e?.__entityTag)throw new c("Invalid parent for Project.");this.apiClient=e.apiClient,this.parent=e}this.endpointApi="function"==typeof o.EndpointApi?new o.EndpointApi(this.apiClient):"object"==typeof o.EndpointApi?o.EndpointApi:(()=>{throw new c("deps.EndpointApi must be a class or instance.")})();const{draft:n,proxy:r}=this._buildDraftAndProxy({data:{...t,...this.defaultFields},serverData:this.#o,constant:I.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(n)),this.#e=n,this.data=r}get id(){return this.#e.id||null}_id(e){this.#e.id=e}get isConnected(){return this.apiClient.isConnected}get userId(){return this.apiClient.userId}get draftData(){return this.#e}get initialDraftData(){return this.#t}get serverData(){return this.#o}get isMe(){return this.isConnected&&this.userId===this.parent?.id}getEntityType(){return I.entityType}_updateInitialDraftSnapshot(){this.#t=JSON.parse(JSON.stringify(this.#e))}hasChanges(){return JSON.stringify(this.#e)!==JSON.stringify(this.#t)}_setData(e){this.#o={...e};const{draft:t,proxy:o}=this._buildDraftAndProxy({data:{...e,...this.defaultFields},serverData:this.#o,constant:I.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(t)),this.#e=t,this.data=o}async refresh(){if(!this.id)throw new c("Impossible de rafraîchir sans ID.");return this.get()}async save(){if(!this.isConnected)throw new c("Impossible de sauvegarder sans être connecté.");const e={...this.#e};return this.id?(await this._update(e)&&await this.refresh(),this.#o):(await this._add(e),await this.refresh(),this.#o)}async _add(e){e.id=this._newId(),e.slug&&delete e.slug;for(const[t,o]of I.ADD_BLOCKS){const n=this._extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(n&&Object.keys(n).length>0){const e=await this[o](n);!this.id&&e?.map?.id&&(this.#e.id=e.map.id,this.#e.slug=e.map.slug)}}}async _update(e){e.id&&delete e.id;let t=!1;for(const[o,n]of I.UPDATE_BLOCKS){const r=this._extractChangedFieldsFromSchema(this.apiClient,o,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);r&&Object.keys(r).length>0&&(await this[n](r),t=!0)}return t}addProject(e={}){return this.isMe||(e.parent={},e.parent[`${this.parent.id}`]={type:this.parent.getEntityType(),name:this.parent.name}),this.callIsConnected((()=>this.endpointApi.addProject(e)))}static fromServerData(e,t,o){const n=new I(t,{},o);n.#o={...e};const{draft:r,proxy:i}=n._buildDraftAndProxy({data:{...e,...n.defaultFields},serverData:n.#o,constant:I.SCHEMA_CONSTANTS,apiClient:n.apiClient,transforms:n.transforms,removeFields:n.removeFields});return n.#e=r,n.data=i,n}defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={github:(e,t)=>t?.socialNetwork?.github,gitlab:(e,t)=>t?.socialNetwork?.gitlab,facebook:(e,t)=>t?.socialNetwork?.facebook,twitter:(e,t)=>t?.socialNetwork?.twitter,instagram:(e,t)=>t?.socialNetwork?.instagram,diaspora:(e,t)=>t?.socialNetwork?.diaspora,mastodon:(e,t)=>t?.socialNetwork?.mastodon,telegram:(e,t)=>t?.socialNetwork?.telegram,signal:(e,t)=>t?.socialNetwork?.signal,parent:e=>e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map((([e,t])=>[e,{type:t?.type??null,name:t?.name??null}]))):null};async project(e={}){try{const t=new I(this,e,{User:this.deps.User,News:this.deps.News,EndpointApi:this.deps.EndpointApi});return(e.id||e.slug)&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.project] Erreur lors de la création d'une instance project :`,e.message),e}}}Object.assign(I.prototype,T,b,_,A,y);class P{#e={};#t={};#o=null;static entityType="citoyens";static SCHEMA_CONSTANTS=["UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);constructor(e,t={},o={}){if(this.__entityTag="User",!o.EndpointApi)throw new c("EndpointApi class must be injected to avoid circular dependency.");if(!t?.id&&!t?.slug)throw new c("Vous devez fournir un id ou un slug pour créer un User.");if(!o.Organization)throw new c("Organization class must be injected.");if(!o.Project)throw new c("Project class must be injected.");if(!o.News)throw new c("News class must be injected.");if(this.apiClient=e,this.deps=o,"function"==typeof o.EndpointApi)this.endpointApi=new o.EndpointApi(this.apiClient);else{if("object"!=typeof o.EndpointApi)throw new c("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=o.EndpointApi}this.#o=null;const{draft:n,proxy:r}=this._buildDraftAndProxy({data:{...t,...this.defaultFields},serverData:this.#o,constant:P.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(n)),this.#e=n,this.data=r}get id(){return this.#e.id||null}_id(e){this.#e.id=e}get slug(){return this.#e.slug||null}get isConnected(){return this.apiClient.isConnected}_setData(e){this.#o={...e};const{draft:t,proxy:o}=this._buildDraftAndProxy({data:{...e,...this.defaultFields},serverData:this.#o,constant:P.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this.#t=JSON.parse(JSON.stringify(t)),this.#e=t,this.data=o}getEntityType(){return P.entityType}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}get draftData(){return this.#e}get initialDraftData(){return this.#t}get serverData(){return this.#o}async refresh(){if(!this.id)throw new c("Impossible de rafraîchir sans ID.");return this.get()}async get(){return this.apiClient.safeCall((async()=>{if(this.isMe){const e=await this.endpointApi.meInfoUrl();return this._setData(e),e}{const e=await this.getPublicProfile();return this._setData(e),e}}))}async changePassword(e={}){return this.callIsMe((()=>this.endpointApi.changePassword(e)))}async delete(e={}){return this.callIsMe((()=>this.endpointApi.deleteAccount(e)))}async save(){if(!this.isMe)throw new c("Vous devez être connecté et être l'utilisateur pour sauvegarder.");const e={...this.#e};if(this.id)return await this._update(e)&&await this.refresh(),this.#o}async _update(e){e.id&&delete e.id;let t=!1;for(const[o,n]of P.UPDATE_BLOCKS){const r=this._extractChangedFieldsFromSchema(this.apiClient,o,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);r&&Object.keys(r).length>0&&(await this[n](r),t=!0)}return t}async updateSettings(e={}){await this.callIsMe((()=>this.endpointApi.updateSettings(e))),await this.refresh()}async updateDescription(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockDescription(e)))}async updateInfo(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockInfo(e)))}async updateSocial(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockSocial(e)))}async updateLocality(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockLocality(e)))}async updateSlug({slug:e}){try{await this.endpointApi.check({slug:e})}catch(e){if(e instanceof l)throw new l("Erreur lors de la vérification du slug.",e.status,e.data);throw e}return this.callIsMe((()=>this.endpointApi.updateBlockSlug({slug:e})))}async updateImageProfil({profil_avatar:e}){return e=await this._validateImage(e),this.callIsMe((()=>this.endpointApi.profilImage({profil_avatar:e})))}async getOrganizations(e={}){delete e?.pathParams;const t=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getOrganizationsAdmin(e))):()=>this.endpointApi.getOrganizationsNoAdmin(e);this.isMe||e.filters||(e.filters={[`links.members.${this.id}`]:{$exists:!0},[`links.members.${this.id}.toBeValidated`]:{$exists:!1},[`links.members.${this.id}.isInviting`]:{$exists:!1}});const o=await t();if(!Array.isArray(o.results))throw new l("Erreur lors de la récupération des organisations.",500,o.results);delete o?.count?.spam;const n=Object.values(o.count||{}).reduce(((e,t)=>e+t),0);o.count.total=n;const r=o.results.map((e=>this.deps.Organization.fromServerData(e,this,{User:P,Project:this.deps.Project,News:this.deps.News,EndpointApi:this.deps.EndpointApi})));return{count:o.count,results:r}}async organization(e={}){try{const t=new this.deps.Organization(this,e,{User:P,Project:this.deps.Project,News:this.deps.News,EndpointApi:this.deps.EndpointApi});return(e.id||e.slug)&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.organization] Erreur lors de la création d'une instance organization :`,e.message),e}}async getProjects(e={}){delete e?.pathParams;const t=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getProjectsAdmin(e))):()=>this.endpointApi.getProjectsNoAdmin(e);this.isMe||e.filters||(e.filters={$or:{[`links.contributors.${this.id}`]:{$exists:!0},[`parent.${this.id}`]:{$exists:!0}},[`links.contributors.${this.id}`]:{$exists:!0}});const o=await t();if(!Array.isArray(o.results))throw new l("Erreur lors de la récupération des projets.",500,o.results);const n=o.results.map((e=>this.deps.Project.fromServerData(e,this,{User:P,News:this.deps.News,EndpointApi:this.deps.EndpointApi})));return{count:o?.count?.projects??0,results:n}}async project(e={}){try{const t=new this.deps.Project(this,e,{User:P,News:this.deps.News,EndpointApi:this.deps.EndpointApi});return(e.id||e.slug)&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.project] Erreur lors de la création d'une instance project :`,e.message),e}}async getNews(e={}){e.pathParams&&delete e.pathParams,this.isMe||(e.pathParams={id:this.id});const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new l("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>this.deps.News.fromServerData(e,this,{User:P,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)}async news(e={}){try{const t=new this.deps.News(this,e,{User:P,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.news] Erreur lors de la création d'une instance news :`,e.message),e}}_updateInitialDraftSnapshot(){this.#t=JSON.parse(JSON.stringify(this.#e))}hasChanges(){return JSON.stringify(this.#e)!==JSON.stringify(this.#t)}defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={github:(e,t)=>t?.socialNetwork?.github,gitlab:(e,t)=>t?.socialNetwork?.gitlab,facebook:(e,t)=>t?.socialNetwork?.facebook,twitter:(e,t)=>t?.socialNetwork?.twitter,instagram:(e,t)=>t?.socialNetwork?.instagram,diaspora:(e,t)=>t?.socialNetwork?.diaspora,mastodon:(e,t)=>t?.socialNetwork?.mastodon,telegram:(e,t)=>t?.socialNetwork?.telegram,signal:(e,t)=>t?.socialNetwork?.signal}}Object.assign(P.prototype,b,T,{},y);const O=require("events"),S=require("@segment/ajv-human-errors"),D=require("ajv"),C=require("ajv-formats"),v=require("axios"),j=require("axios-retry"),N=require("ejson"),k=require("jwt-decode"),x=require("pino"),$={_looksLikeObjectID:e=>24===e.length&&/^[0-9a-f]*$/.test(e),ObjectID:class{constructor(e){if(e){if(e=e.toLowerCase(),!$._looksLikeObjectID(e))throw new Error("Invalid hexadecimal string for creating an ObjectID");this._str=e}}equals(e){return e instanceof $.ObjectID&&this.valueOf()===e.valueOf()}toString(){return`ObjectID("${this._str}")`}clone(){return new $.ObjectID(this._str)}typeName(){return"oid"}getTimestamp(){return Number.parseInt(this._str.substr(0,8),16)}valueOf(){return this._str}toJSONValue(){return this.valueOf()}toHexString(){return this.valueOf()}}},q=$,L={common1:{type:"string"},common2:{format:"email",type:"string"},common3:{type:"boolean"},common4:{format:"uri",type:"string"},common5:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common6:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},required:["id"],type:"object"},common7:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},common8:{additionalProperties:!1,properties:{reason:{default:"",type:"string"}},required:["reason"],type:"object"},common9:{reason:{default:"",type:"string"}},common10:{default:"",type:"string"},common11:{pattern:"^[a-f0-9]{24}$",type:"string"},common12:{const:"citoyens"},common13:{properties:{value:{type:"boolean"}}},common14:{value:{type:"boolean"}},common15:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},common16:{},common17:{else:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},if:{properties:{typeElement:{const:"citoyens"}}},then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}}},common18:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},common19:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},common20:{properties:{typeElement:{const:"citoyens"}}},common21:{typeElement:{const:"citoyens"}},common22:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}},common23:{not:{type:"null"}},common24:{type:"null"},common25:{anyOf:[{items:{type:"string"},type:"array"},{enum:[""],type:"string"}]},common26:{items:{type:"string"},type:"array"},common27:{enum:[""],type:"string"},common28:{properties:{name:{not:{type:"null"}}},required:["name"]},common29:{name:{not:{type:"null"}}},common30:{properties:{url:{not:{type:"null"}}},required:["url"]},common31:{url:{not:{type:"null"}}},common32:{properties:{tags:{not:{type:"null"}}},required:["tags"]},common33:{tags:{not:{type:"null"}}},common34:{properties:{email:{not:{type:"null"}}},required:["email"]},common35:{email:{not:{type:"null"}}},common36:{const:"info",default:"info",type:"string"},common37:{$ref:"#/$defs/sharedFields/email"},common38:{$ref:"#/$defs/sharedFields/name"},common39:{$ref:"#/$defs/sharedFields/tags"},common40:{$ref:"#/$defs/sharedFields/url"},common41:{const:"projects"},common42:{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type","name"],type:"object"},common43:{name:{type:"string"},type:{type:"string"}},common44:{const:"organizations"},common45:{$ref:"#/$defs/socialField"},common46:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},common47:{id:{pattern:"^[a-f0-9]{24}$"}},common48:{pattern:"^[a-f0-9]{24}$"},common49:{additionalProperties:!1,properties:{"@type":{const:"PostalAddress",type:"string"},addressCountry:{type:"string"},addressLocality:{type:"string"},codeInsee:{type:"string"},level1:{type:"string"},level1Name:{type:"string"},level3:{minLength:0,type:"string"},level3Name:{minLength:0,type:"string"},level4:{minLength:0,type:"string"},level4Name:{minLength:0,type:"string"},localityId:{type:"string"},postalCode:{type:"string"},streetAddress:{type:"string"}},required:["@type","addressCountry","codeInsee","addressLocality","localityId","level1","level1Name"],type:"object"},common50:{"@type":{const:"PostalAddress",type:"string"},addressCountry:{type:"string"},addressLocality:{type:"string"},codeInsee:{type:"string"},level1:{type:"string"},level1Name:{type:"string"},level3:{minLength:0,type:"string"},level3Name:{minLength:0,type:"string"},level4:{minLength:0,type:"string"},level4Name:{minLength:0,type:"string"},localityId:{type:"string"},postalCode:{type:"string"},streetAddress:{type:"string"}},common51:{const:"PostalAddress",type:"string"},common52:{minLength:0,type:"string"},common53:{additionalProperties:!1,properties:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},required:["latitude","longitude"],type:"object"},common54:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},common55:{const:"GeoCoordinates",type:"string"},common56:{type:["string","number"]},common57:{additionalProperties:!0,properties:{coordinates:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},float:{const:!0,default:!0,type:"boolean"},type:{const:"Point",type:"string"}},required:["type","coordinates","float"],type:"object"},common58:{coordinates:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},float:{const:!0,default:!0,type:"boolean"},type:{const:"Point",type:"string"}},common59:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},common60:{type:"number"},common61:{const:!0,default:!0,type:"boolean"},common62:{const:"Point",type:"string"},common63:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common64:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common65:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"},common66:{maxLength:100,minLength:3,pattern:"^[a-zA-Z0-9]+$",type:"string"},common67:{properties:{type:{const:"citoyens"}}},common68:{type:{const:"citoyens"}},common69:{additionalProperties:!1,else:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{folder:{const:"citoyens"}}},properties:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},required:["folder","ownerId"],then:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common70:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},common71:{ownerId:{pattern:"^[a-f0-9]{24}$"}},common72:{properties:{folder:{const:"citoyens"}}},common73:{folder:{const:"citoyens"}},common74:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},common75:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common76:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common77:{additionalProperties:!1,else:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{type:{const:"citoyens"}}},properties:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},required:["type","id"],then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common78:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},common79:{properties:{parentId:{pattern:"^[a-f0-9]{24}$"}}},common80:{parentId:{pattern:"^[a-f0-9]{24}$"}},common81:{properties:{parentType:{const:"citoyens"}}},common82:{parentType:{const:"citoyens"}},common83:{properties:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common84:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common85:{default:!0,type:"boolean"},common86:{default:0,type:"integer"},common87:{required:["text"]},common88:{required:["mediaImg"]},common89:{required:["mediaFile"]},common90:{additionalProperties:!1,properties:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},required:["countFiles","files"],type:"object"},common91:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},common92:{additionalProperties:!1,properties:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},required:["countImages","images"],type:"object"},common93:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},common94:{items:{properties:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common95:{properties:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},common96:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common97:{minimum:1,type:"integer"},common98:{default:"public",enum:["public","private","restricted"],type:"string"},common99:{const:"news",default:"news",type:"string"},common100:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},required:["id"],type:"object"},common101:{default:!1,type:"boolean"},common102:{properties:{childId:{pattern:"^[a-f0-9]{24}$"}}},common103:{childId:{pattern:"^[a-f0-9]{24}$"}},common104:{properties:{childType:{const:"citoyens"}}},common105:{childType:{const:"citoyens"}},common106:{const:"share",default:"share",type:"string"},common107:{properties:{childId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common108:{childId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common109:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},required:["type","id"],type:"object"},common110:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},common111:{default:"news",enum:["news"],type:"string"},common112:{items:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common113:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},common114:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common115:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],type:"string"},common116:{const:!1,default:!1,type:"boolean"},common117:{const:"",default:"",type:"string"},common118:{additionalProperties:!1,properties:{indexMax:{type:"number"},indexMin:{type:"number"}},required:["indexMin","indexMax"],type:"object"},common119:{indexMax:{type:"number"},indexMin:{type:"number"}},common120:{default:0,minimum:0,type:"integer"},common121:{const:["projects"],default:["projects"],items:{enum:["projects"],type:"string"},type:"array"},common122:{enum:["projects"],type:"string"},common123:{$exists:!0},common124:{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},common125:{$exists:{const:!0}},common126:{const:!0},common127:{default:30,type:"integer"},common128:{const:["poi"],default:["poi"],items:{enum:["poi"],type:"string"},type:"array"},common129:{enum:["poi"],type:"string"},common130:{const:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],default:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],items:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},type:"array"},common131:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},common132:{$exists:!1},common133:{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},common134:{$exists:{const:!1}},common135:{const:!1},common136:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common137:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common138:{additionalProperties:!1,properties:{$exists:{default:!1,type:"boolean"}},required:["$exists"],type:"object"},common139:{$exists:{default:!1,type:"boolean"}},common140:{additionalProperties:!1,properties:{$in:{items:{type:"string"},minItems:1,type:"array"}},required:["$in"],type:"object"},common141:{$in:{items:{type:"string"},minItems:1,type:"array"}},common142:{items:{type:"string"},minItems:1,type:"array"},common143:{const:["citoyens"],default:["citoyens"],items:{enum:["citoyens"],type:"string"},type:"array"},common144:{enum:["citoyens"],type:"string"},common145:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},type:"array"},common146:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},common147:{not:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common148:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common149:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common150:{"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"}},common151:{not:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common152:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common153:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common154:{const:["badges"],default:["badges"],items:{enum:["badges"],type:"string"},type:"array"},common155:{enum:["badges"],type:"string"},common156:{const:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common157:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common158:{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"},common159:{$exists:{const:!0,type:"boolean"}},common160:{const:!0,type:"boolean"},common161:{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},common162:{$exists:{const:!1,type:"boolean"}},common163:{const:!1,type:"boolean"},common164:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"}},common165:{indexMax:30,indexMin:0},common166:{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{connectType:{const:"friend",default:"friend"}}}},common167:{properties:{connectType:{const:"friend",default:"friend"}}},common168:{connectType:{const:"friend",default:"friend"}},common169:{const:"friend",default:"friend"},common170:{if:{properties:{parentType:{const:"organizations"}}},then:{properties:{connectType:{enum:["admin","member"]}}}},common171:{properties:{parentType:{const:"organizations"}}},common172:{parentType:{const:"organizations"}},common173:{properties:{connectType:{enum:["admin","member"]}}},common174:{connectType:{enum:["admin","member"]}},common175:{enum:["admin","member"]},common176:{if:{properties:{parentType:{const:"projects"}}},then:{properties:{connectType:{enum:["admin","contributor"]}}}},common177:{properties:{parentType:{const:"projects"}}},common178:{parentType:{const:"projects"}},common179:{properties:{connectType:{enum:["admin","contributor"]}}},common180:{connectType:{enum:["admin","contributor"]}},common181:{enum:["admin","contributor"]},common182:{properties:{parentType:{const:"events"}}},common183:{parentType:{const:"events"}},common184:{const:"events"},common185:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},common186:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},common187:{enum:["citoyens","organizations","projects","events"],type:"string"},common188:{const:"citoyens",default:"citoyens",type:"string"},common189:{const:"@userId",default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common190:{default:{isOpenData:!0,isOpenEdition:!0},properties:{isOpenData:{default:!0,type:"boolean"},isOpenEdition:{default:!0,type:"boolean"}},required:["isOpenData","isOpenEdition"],type:"object"},common191:{isOpenData:!0,isOpenEdition:!0},common192:{isOpenData:{default:!0,type:"boolean"},isOpenEdition:{default:!0,type:"boolean"}},common193:{additionalProperties:!1,default:{"@userId":{type:"citoyens"}},patternProperties:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},type:"object"},common194:{"@userId":{type:"citoyens"}},common195:{type:"citoyens"},common196:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},common197:{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"},common198:{const:"poi",default:"poi",type:"string"},common199:{const:"events",default:"events",type:"string"},common200:{format:"date-time",type:"string"},common201:{pattern:"^([01]\\d|2[0-3]):[0-5]\\d$",type:"string"},common202:{enum:["workshop","competition","concert","contest","conference","debate","exhibition","festival","crowdfunding","fair","course","protest","market","film","getTogether","meeting","spectacle","internship","stand","others"],type:"string"},common203:{type:"integer"},common204:{default:"@userId",pattern:"^[a-f0-9]{24}$",type:"string"},common205:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^[a-f0-9]{24}$",type:"string"},type:{const:"citoyens",default:"citoyens",type:"string"}},required:["type","id"],type:"object"},common206:{id:{default:"@userId",pattern:"^[a-f0-9]{24}$",type:"string"},type:{const:"citoyens",default:"citoyens",type:"string"}},common207:{const:"badges",default:"badges",type:"string"},common208:{const:"badge",default:"badge",type:"string"},common209:{patternProperties:{"^[0-9a-f]{24}$":{additionalProperties:!1,properties:{isAdmin:{default:"",enum:["","admin"],type:"string"},name:{type:"string"},roles:{items:{type:"string"},type:"array"}},required:["name"],type:"object"}},type:"object"},common210:{"^[0-9a-f]{24}$":{additionalProperties:!1,properties:{isAdmin:{default:"",enum:["","admin"],type:"string"},name:{type:"string"},roles:{items:{type:"string"},type:"array"}},required:["name"],type:"object"}},common211:{additionalProperties:!1,properties:{isAdmin:{default:"",enum:["","admin"],type:"string"},name:{type:"string"},roles:{items:{type:"string"},type:"array"}},required:["name"],type:"object"},common212:{isAdmin:{default:"",enum:["","admin"],type:"string"},name:{type:"string"},roles:{items:{type:"string"},type:"array"}},common213:{default:"",enum:["","admin"],type:"string"}},M=[{auth:"none",constant:"PERSON_REGISTER",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/register",request:{additionalProperties:!1,properties:{app:L.common1,email:L.common2,isInvitation:L.common3,mode:L.common1,name:L.common1,pendingUserId:L.common1,pwd:L.common1,username:L.common1},required:["name","username","email","pwd"],type:"object"}},{auth:"none",constant:"AUTHENTICATE_URL",contentType:"application/json",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/api/cocolight/authenticate",postActions:[{path:"accessToken",type:"setToken"},{path:"refreshToken",type:"setRefreshToken"},{event:"userLoggedIn",path:"user",type:"emitEvent"}],request:{additionalProperties:!1,properties:{email:L.common2,password:L.common1},required:["email","password"],type:"object"}},{auth:"none",constant:"REFRESH_TOKEN_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/refreshtoken",request:{additionalProperties:!1,properties:{refreshToken:L.common1},required:["refreshToken"],type:"object"}},{auth:"bearer",constant:"ME_INFO_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/me"},{auth:"none",constant:"PASSWORD_RECOVERY",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/sendemail",request:{additionalProperties:!1,properties:{email:L.common2,type:{const:"password",default:"password",type:"string"}},required:["email","type"],type:"object"}},{auth:"bearer",constant:"SERVER_EXCHANGE_TOKEN",contentType:"application/json",method:"POST",path:"/api/cocolight/exchangetoken",request:{additionalProperties:!1,properties:{serverUrl:L.common4},required:["serverUrl"],type:"object"}},{auth:"bearer",constant:"CHANGE_PASSWORD",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/person/changepassword",request:{additionalProperties:!1,properties:{mode:{const:"changePassword",default:"changePassword",type:"string"},newPassword:L.common1,newPassword2:L.common1,oldPassword:L.common1,scope:{default:"",type:["string"]},userId:L.common5},required:["mode","userId","oldPassword","newPassword","newPassword2"],type:"object"}},{auth:"bearer",constant:"DELETE_ACCOUNT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/id/{id}/type/citoyens",pathParams:L.common6,postActions:[{type:"resetSession"},{event:"accountDeleted",path:null,type:"emitEvent"}],request:L.common8},{auth:"bearer",constant:"UPDATE_SETTINGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatesettings",request:{additionalProperties:!1,allOf:[{else:{properties:{idEntity:L.common11}},if:{properties:{typeEntity:L.common12}},then:{properties:{idEntity:L.common5}}},{if:{properties:{type:{enum:["birthDate","email","locality","phone","directory"]},typeEntity:L.common12}},then:{properties:{value:{enum:["private","public","mask"],type:"string"}}}},{if:{properties:{type:{enum:["activitypub","isOpenData"]},typeEntity:L.common12}},then:L.common13},{if:{properties:{type:{enum:["isOpenData","isOpenEdition","private","feedback"]},typeEntity:{not:L.common12}}},then:L.common13}],properties:{idEntity:L.common1,type:L.common1,typeEntity:L.common15,value:L.common16},required:["type","value","typeEntity","idEntity"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_DESCRIPTION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{additionalProperties:!1,allOf:[L.common17,{anyOf:[{properties:{description:L.common23},required:["description"]},{properties:{shortDescription:L.common23},required:["shortDescription"]}]}],properties:{block:{const:"descriptions",default:"descriptions",type:"string"},descMentions:L.common10,description:L.common1,id:L.common1,scope:{default:"",type:["string","null"]},shortDescription:L.common1,typeElement:L.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_INFO",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{sharedFields:{email:L.common2,name:L.common1,tags:L.common25,url:L.common4}},allOf:[{if:L.common20,then:{additionalProperties:!1,anyOf:[L.common28,{properties:{birthDate:L.common23},required:["birthDate"]},{properties:{fixe:L.common23},required:["fixe"]},{properties:{mobile:L.common23},required:["mobile"]},L.common30,L.common32,L.common34],properties:{birthDate:{format:"date",type:"string"},block:L.common36,email:L.common37,fixe:L.common1,id:L.common5,mobile:L.common1,name:L.common38,scope:L.common10,tags:L.common39,typeElement:L.common15,url:L.common40}}},{if:{properties:{typeElement:L.common41}},then:{additionalProperties:!1,anyOf:[L.common28,L.common30,L.common32,L.common34,{properties:{avancement:L.common23},required:["avancement"]},{properties:{parent:L.common23},required:["parent"]}],properties:{avancement:{enum:["abandoned","concept","development","production","started","testing","idea","mature","qa","finished"],type:"string"},block:L.common36,email:L.common37,id:L.common1,name:L.common38,parent:{additionalProperties:!1,patternProperties:{"^[a-fA-F0-9]{24}$":L.common42},type:"object"},scope:L.common10,tags:L.common39,typeElement:L.common15,url:L.common40}}},{if:{properties:{typeElement:L.common44}},then:{additionalProperties:!1,anyOf:[L.common28,L.common30,L.common32,L.common34,{properties:{type:L.common23},required:["type"]}],properties:{block:L.common36,email:L.common37,id:L.common1,name:L.common38,scope:L.common10,tags:L.common39,type:{enum:["NGO","Cooperative","LocalBusiness","GovernmentOrganizationautre"],type:"string"},typeElement:L.common15,url:L.common40}}}],properties:{block:L.common36,id:L.common1,scope:L.common10,typeElement:L.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SOCIAL",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{socialField:{anyOf:[L.common27,L.common4]}},allOf:[L.common17,{anyOf:[{properties:{gitlab:L.common23},required:["gitlab"]},{properties:{github:L.common23},required:["github"]},{properties:{twitter:L.common23},required:["twitter"]},{properties:{facebook:L.common23},required:["facebook"]},{properties:{instagram:L.common23},required:["instagram"]},{properties:{diaspora:L.common23},required:["diaspora"]},{properties:{mastodon:L.common23},required:["mastodon"]},{properties:{telegram:L.common23},required:["telegram"]},{properties:{signal:L.common23},required:["signal"]}]}],properties:{block:{const:"network",default:"network",type:"string"},diaspora:L.common45,facebook:L.common45,github:L.common45,gitlab:L.common45,id:L.common1,instagram:L.common45,mastodon:L.common45,scope:L.common10,signal:L.common45,telegram:L.common45,twitter:L.common45,typeElement:L.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_LOCALITY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:L.common46,if:L.common20,properties:{address:L.common49,block:{const:"localities",default:"localities",type:"string"},geo:L.common53,geoPosition:L.common57,id:L.common1,scope:L.common10,typeElement:L.common15},required:["block","typeElement","id","address"],then:L.common63,type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SLUG",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:L.common46,if:L.common20,properties:{block:L.common36,id:L.common1,scope:L.common10,slug:L.common66,typeElement:L.common15},required:["block","typeElement","id","slug"],then:L.common63,type:"object"}},{auth:"bearer",constant:"CHECK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/check",request:{additionalProperties:!1,else:L.common46,if:L.common67,properties:{block:L.common36,id:L.common1,slug:L.common66,type:L.common15},required:["block","type","id","slug"],then:L.common63,type:"object"}},{auth:"bearer",constant:"PROFIL_IMAGE",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/profil_avatar/contentKey/profil/docType/image",pathParams:L.common69,request:{additionalProperties:!1,properties:{profil_avatar:L.common16},required:["profil_avatar"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_ABOUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/about/type/{type}/id/{id}/json/true",pathParams:L.common77,request:{additionalProperties:!1,properties:{tpl:{const:"ficheInfoElement",default:"ficheInfoElement",type:"string"}},required:["tpl"],type:"object"}},{auth:"bearer",constant:"MULTICONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/multiconnect",request:{additionalProperties:!1,else:L.common79,if:L.common81,properties:{listInvite:{additionalProperties:!1,patternProperties:{"^(citoyens|projects|organizations)$":{additionalProperties:!1,patternProperties:{"^[0-9a-fA-F]{24}$":{additionalProperties:!1,properties:{name:L.common1},required:["name"],type:"object"}},type:"object"}},type:"object"},parentId:L.common1,parentType:L.common15},required:["parentId","parentType","listInvite"],then:L.common83,type:"object"}},{auth:"none",constant:"GET_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/get/type/{type}/id/{id}/isLive/{isLive}/json/true",pathParams:{additionalProperties:!1,else:L.common46,if:L.common67,properties:{id:L.common1,isLive:L.common85,type:L.common15},required:["isLive","type","id"],then:L.common63,type:"object"},request:{additionalProperties:!1,properties:{dateLimit:L.common86,indexStep:{default:12,type:"integer"},search:{additionalProperties:!1,properties:{name:L.common10},required:["name"],type:"object"}},required:["dateLimit","indexStep"],type:"object"}},{auth:"none",constant:"GET_NEWS_BY_ID",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/getbyids",request:{additionalProperties:!1,properties:{ids:{items:L.common11,type:"array"}},required:["ids"],type:"object"}},{auth:"bearer",constant:"ADD_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/save",request:{additionalProperties:!1,anyOf:[L.common87,L.common88,L.common89],else:L.common79,if:L.common81,properties:{json:L.common61,markdownActive:L.common85,mediaFile:L.common90,mediaImg:L.common92,mentions:L.common94,parentId:L.common1,parentType:L.common15,scope:L.common98,tags:L.common25,text:L.common1,type:L.common99},required:["scope","markdownActive","parentId","parentType","type","json"],then:L.common83,type:"object"}},{auth:"bearer",constant:"ADD_IMAGE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/newsImage/docType/image/contentKey/slider",pathParams:L.common69,request:{additionalProperties:!1,properties:{newsImage:L.common16},required:["newsImage"],type:"object"}},{auth:"bearer",constant:"ADD_FILE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}}/input/newsFile/docType/file",pathParams:L.common69,request:{additionalProperties:!1,properties:{newsFile:L.common16},required:["newsFile"],type:"object"}},{auth:"bearer",constant:"DELETE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/delete/id/{id}",pathParams:L.common100,request:{additionalProperties:!1,properties:{isLive:L.common101},required:["isLive"],type:"object"}},{auth:"bearer",constant:"UPDATE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/update",request:{additionalProperties:!1,anyOf:[L.common87,L.common88,L.common89],else:L.common79,if:L.common81,properties:{idNews:L.common11,markdownActive:L.common85,mediaFile:L.common90,mediaImg:L.common92,mentions:L.common94,parentId:L.common1,parentType:L.common15,scope:L.common98,tags:L.common25,text:L.common1,type:L.common99},required:["idNews","scope","markdownActive","parentId","parentType","type"],then:L.common83,type:"object"}},{auth:"bearer",constant:"SHARE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:L.common102,if:L.common104,properties:{childId:L.common11,childType:L.common15,comment:L.common1,connectType:L.common106,parentId:L.common11,parentType:L.common99},required:["parentId","parentType","childId","childType","connectType"],then:L.common107,type:"object"}},{auth:"none",constant:"GET_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/index/type/{type}/id/{id}/json/true",pathParams:L.common109},{auth:"bearer",constant:"ADD_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/save",request:{additionalProperties:!1,properties:{argval:L.common10,contextId:L.common11,contextType:L.common111,mentions:L.common112,parentCommentId:L.common11,path:L.common10,text:L.common1},required:["text","contextId","contextType"],type:"object"}},{auth:"bearer",constant:"DELETE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/delete/id/{id}",pathParams:L.common100},{auth:"bearer",constant:"UPDATE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/update",request:{additionalProperties:!1,properties:{id:L.common11,params:{properties:{mentions:L.common112,text:L.common1},required:["text"],type:"object"}},required:["id","params"],type:"object"}},{auth:"none",constant:"SEARCH_TAGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/tags/search?q={q}",pathParams:{additionalProperties:!1,properties:{q:L.common1},required:["q"],type:"object"}},{auth:"none",constant:"SHOW_VOTE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/action/list/type/{type}/id/{id}/actionType/vote/json/true",pathParams:L.common109},{auth:"none",constant:"GLOBAL_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:{const:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],default:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],items:L.common115,type:"array"},fediverse:L.common116,filters:L.common117,indexMin:{const:0,default:0,type:"number"},indexStep:L.common60,initType:L.common117,locality:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":{additionalProperties:!1,properties:{id:L.common1,type:{enum:["cities","level1"],type:"string"}},required:["id","type"],type:"object"}},type:"object"},name:L.common1,notSourceKey:L.common61,ranges:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":L.common118},type:"object"},searchTags:L.common26,searchType:{items:L.common115,type:"array"}},required:["name","searchType","countType","indexMin","indexStep","initType","count","notSourceKey","filters","fediverse"],type:"object"}},{auth:"none",constant:"CITY_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{minimum:5,type:"integer"},indexMin:{minimum:0,type:"integer"},locality:L.common117,name:L.common1,searchBy:{const:"ALL",default:"ALL",type:"string"},searchType:{const:["cities"],default:["cities"],items:{enum:["cities"],type:"string"},type:"array"}},required:["name","locality","searchType"],type:"object"}},{auth:"none",constant:"SUGGESTION_INPUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{default:20,minimum:20,type:"integer"},indexMin:L.common120,name:L.common1,searchType:{items:{enum:["organizations","projects","poi"],type:"string"},type:"array"}},required:["name","searchType","indexMin","indexMax"],type:"object"}},{auth:"none",constant:"GET_PROJECTS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common121,fediverse:L.common116,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@userId":L.common123,"parent.@userId":L.common123},"links.contributors.@userId":L.common123},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":L.common124},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":L.common124,"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":L.common124},type:"object"}},required:["$or"],type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_PROJECTS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:L.common77,request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common121,fediverse:L.common116,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@{pathParams.id}":L.common123,"parent.@{pathParams.id}":L.common123},"links.contributors.@{pathParams.id}":L.common123},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124,"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124},type:"object"}},required:["$or"],type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_POIS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common128,fediverse:L.common116,filters:{additionalProperties:!1,default:{"parent.@userId":L.common123},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":L.common124},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common128},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_POIS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:L.common77,request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common128,fediverse:L.common116,filters:{additionalProperties:!1,default:{"parent.@{pathParams.id}":L.common123},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common128},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_ORGANIZATIONS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common130,fediverse:L.common116,filters:{additionalProperties:!1,default:{"links.members.@userId":L.common123,"links.members.@userId.isInviting":L.common132,"links.members.@userId.toBeValidated":L.common132},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)$":L.common124,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":L.common133,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":L.common133},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common130},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_ORGANIZATIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,else:L.common46,if:L.common67,properties:{id:L.common1,type:{default:"citoyens",enum:["citoyens","organizations"],type:"string"}},required:["type","id"],then:L.common63,type:"object"},request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common130,fediverse:L.common116,filters:{additionalProperties:!1,default:{"links.members.@{pathParams.id}":L.common123,"links.members.@{pathParams.id}.isInviting":L.common132,"links.members.@{pathParams.id}.toBeValidated":L.common132},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":L.common133,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":L.common133},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common130},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_MEMBERS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common136,fediverse:L.common116,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$":L.common124,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":L.common124,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":L.common138,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":L.common140,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":L.common133},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common136},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_MEMBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/organizations/id/{id}/canSee/true",pathParams:L.common100,request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common136,fediverse:L.common116,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.memberOf.@{pathParams.id}":L.common123,"links.memberOf.@{pathParams.id}.isInviting":L.common132,"links.memberOf.@{pathParams.id}.toBeValidated":L.common132},patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":L.common124,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":L.common138,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":L.common140,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":L.common138},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common136},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_FRIENDS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:L.common6,request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common143,fediverse:L.common116,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.friends.@{pathParams.id}":L.common123,"links.friends.@{pathParams.id}.isInviting":L.common132,"links.friends.@{pathParams.id}.toBeValidated":L.common132},patternProperties:{"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":L.common138,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":L.common138},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common143},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIPTIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common145,fediverse:L.common116,filters:{additionalProperties:!1,allOf:[L.common147],default:{"links.followers.@userId":L.common123,"links.followers.@{userId}.isInviting":L.common132,"links.followers.@{userId}.toBeValidated":L.common132},patternProperties:L.common150,type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common145},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIPTIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:L.common6,request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common145,fediverse:L.common116,filters:{additionalProperties:!1,allOf:[L.common147],default:{"links.followers.@{pathParams.id}":L.common123,"links.followers.@{pathParams.id}.isInviting":L.common132,"links.followers.@{pathParams.id}.toBeValidated":L.common132},patternProperties:L.common150,type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common145},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIBERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common143,fediverse:L.common116,filters:{additionalProperties:!1,allOf:[L.common151],default:{"links.follows.@userId":L.common123,"links.follows.@{userId}.isInviting":L.common132,"links.follows.@{userId}.toBeValidated":L.common132},patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":L.common133,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":L.common133},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common143},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,allOf:[{else:L.common46,if:L.common67,then:L.common63}],properties:{id:L.common1,type:{default:"citoyens",enum:["citoyens","organizations","projects"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common143,fediverse:L.common116,filters:{additionalProperties:!1,allOf:[L.common151],default:{"links.follows.@{pathParams.id}":L.common123},maxProperties:1,minProperties:1,patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common143},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_CONTRIBUTORS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common136,fediverse:L.common116,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$":L.common124,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":L.common124,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":L.common138,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":L.common140,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":L.common133},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common136},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_CONTRIBUTORS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/projects/id/{id}/canSee/true",pathParams:L.common100,request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common136,fediverse:L.common116,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.projects.@{pathParams.id}":L.common123,"links.projects.@{pathParams.id}.isInviting":L.common132,"links.projects.@{pathParams.id}.toBeValidated":L.common132},patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":L.common124,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":L.common124,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":L.common138,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":L.common140,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":L.common138},type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common136},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common154,fediverse:L.common116,filters:{properties:{$or:{additionalProperties:!1,minProperties:1,patternProperties:{"^issuer\\.(?:[a-f0-9]{24}|@\\w+)$":L.common124},type:"object"},isParcours:L.common3,"preferences.private":L.common116},required:["preferences.private"],type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,searchType:L.common154},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES_FILTERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:L.common61,countType:L.common156,fediverse:L.common116,fields:L.common154,filters:{oneOf:[{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":L.common158}},{additionalProperties:!1,maxProperties:3,minProperties:3,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":L.common158,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":L.common161,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":L.common161}},{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:L.common164},{additionalProperties:!1,maxProperties:1,minProperties:1,properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:L.common164,type:"object"}},required:["$or"]},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.revoke$":L.common160}},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":L.common158}}],type:"object"},indexMin:L.common120,indexStep:L.common127,initType:L.common117,locality:L.common117,name:L.common1,notSourceKey:L.common61,ranges:{additionalProperties:!1,default:{Cooperative:L.common165,GovernmentOrganization:L.common165,Group:L.common165,LocalBusiness:L.common165,NGO:L.common165,citoyens:L.common165,projects:L.common165},maxProperties:7,minProperties:7,patternProperties:{"^[a-zA-Z][a-zA-Z0-9]*$":L.common118},type:"object"},searchType:L.common156},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"CONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/connect",request:{additionalProperties:!1,allOf:[L.common166,L.common170,L.common176,{if:L.common182,then:{properties:{connectType:{default:"attendee",enum:["attendee","connect"]}}}}],properties:{childId:L.common185,childType:L.common186,connectType:{enum:["admin","member","contributor","attendee","friend","connect"],type:"string"},parentId:L.common11,parentType:L.common187},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"bearer",constant:"DISCONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/disconnect",request:{additionalProperties:!1,allOf:[L.common166,L.common170,L.common176,{if:L.common182,then:{properties:{connectType:{const:"attendee",default:"attendee"}}}}],properties:{childId:L.common185,childType:L.common186,connectType:{enum:["admin","member","contributor","attendee","friend"],type:"string"},parentId:L.common11,parentType:L.common187},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_KEY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/getinfo/key/{slug}",pathParams:{additionalProperties:!1,properties:{slug:{pattern:"^([a-zA-Z0-9-_]+)$",type:"string"}},required:["slug"],type:"object"}},{auth:"bearer",constant:"GET_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/config/type/citoyens/id/{id}/json/true",pathParams:L.common6},{auth:"bearer",constant:"DELETE_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue?index={index}",pathParams:{properties:{index:L.common60},type:"object"},request:{additionalProperties:!1,properties:{collection:L.common188,id:L.common189,path:{const:"preferences.search.@{pathParams.index}",default:"preferences.search.@{pathParams.index}",type:"string"},pull:{const:"preferences.search",type:"string"},value:L.common117},required:["id","collection","path","pull","value"],type:"object"}},{auth:"bearer",constant:"ADD_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue",request:{additionalProperties:!1,properties:{arrayForm:L.common160,collection:L.common188,id:L.common189,path:{const:"preferences.search",default:"preferences.search",type:"string"},value:{additionalProperties:!1,properties:{description:L.common1,locality:{patternProperties:{"^[a-f0-9]{24}$":{additionalProperties:!1,properties:L.common43,required:["name","type"]}},type:"object"},name:L.common1,tags:L.common26,url:L.common1},required:["url","name"],type:"object"}},required:["id","collection","path","arrayForm","value"],type:"object"}},{auth:"bearer",constant:"ADD_ORGANIZATION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:L.common49,collection:{const:"organizations",default:"organizations",type:"string"},email:L.common2,geo:L.common53,geoPosition:L.common57,id:L.common11,key:{const:"organization",default:"organization",type:"string"},name:{minLength:3,type:"string"},preferences:L.common190,role:{enum:["admin","member"],type:"string"},scope:L.common117,shortDescription:L.common1,tags:L.common26,type:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},url:L.common4},required:["id","collection","key","name","type","role","scope"],type:"object"}},{auth:"bearer",constant:"ADD_PROJECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:L.common49,collection:{const:"projects",default:"projects",type:"string"},geo:L.common53,geoPosition:L.common57,id:L.common11,key:{const:"project",default:"project",type:"string"},name:L.common1,parent:L.common193,preferences:{default:{crowdfunding:!0,isOpenData:!1,isOpenEdition:!1},properties:{crowdfunding:L.common85,isOpenData:L.common101,isOpenEdition:L.common101},required:["isOpenData","isOpenEdition"],type:"object"},public:L.common85,scope:L.common117,shortDescription:L.common1,tags:L.common26,url:L.common4},required:["id","collection","key","parent","name","public","scope"],type:"object"}},{auth:"bearer",constant:"ADD_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:L.common49,collection:L.common198,description:L.common1,geo:L.common53,geoPosition:L.common57,id:L.common11,key:L.common198,name:L.common1,parent:L.common193,scope:L.common117,tags:L.common26,type:{enum:["link","tool","machine","software","rh","Resource material","Financial Ressource","ficheBlanche","geoJson","compostPickup","video","sharedLibrary","recoveryCenter","trash","history","something2See","funPlace","place","artPiece","streetArts","openScene","stand","parking","other"],type:"string"},urls:L.common26},required:["id","collection","key","parent","type","name"],type:"object"}},{auth:"bearer",constant:"ADD_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,else:{required:["openingHours"]},if:{properties:{recurrency:L.common135}},properties:{address:L.common49,collection:L.common199,email:L.common2,endDate:L.common200,geo:L.common53,geoPosition:L.common57,id:L.common11,key:{const:"event",default:"event",type:"string"},name:L.common1,openingHours:{default:["","","","","","",""],items:{anyOf:[{const:"",type:"string"},{additionalProperties:!1,properties:{dayOfWeek:{enum:["Mo","Tu","We","Th","Fr","Sa","Su"],type:"string"},hours:{default:[],items:{additionalProperties:!1,properties:{closes:L.common201,opens:L.common201},required:["opens","closes"],type:"object"},type:"array"}},required:["dayOfWeek","hours"],type:"object"}]},maxItems:7,minItems:7,type:"array"},organizer:L.common193,parent:{additionalProperties:!1,patternProperties:L.common196,type:"object"},preferences:{default:{isOpenData:!1,isOpenEdition:!1},properties:{isOpenData:L.common101,isOpenEdition:L.common101},required:["isOpenData","isOpenEdition"],type:"object"},public:L.common85,recurrency:L.common101,scope:L.common117,shortDescription:L.common1,startDate:L.common200,tags:L.common26,timeZone:L.common1,type:L.common202,url:L.common4},required:["id","collection","key","organizer","type","name","scope"],startBeforeEnd:!0,then:{required:["startDate","endDate"]},type:"object"}},{auth:"bearer",constant:"DELETE_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/poi/id/{id}",pathParams:L.common100,request:L.common8},{auth:"bearer",constant:"DELETE_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/events/id/{id}/",pathParams:L.common100,request:L.common8},{auth:"bearer",constant:"DELETE_ELEMENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/{type}/id/{id}",pathParams:{additionalProperties:!1,properties:{id:L.common11,type:L.common1},required:["type","id"],type:"object"},request:L.common8},{auth:"bearer",constant:"ADD_IMAGE_ELEMENT",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/qqfile/docType/image/contentKey/profil",pathParams:{additionalProperties:!1,properties:{folder:{enum:["badges","events"],type:"string"},ownerId:L.common11},required:["folder","ownerId"],type:"object"},request:{additionalProperties:!1,properties:{qqfile:L.common16,qqfilename:L.common1,qqtotalfilesize:L.common203,qquuid:L.common11},required:["qquuid","qqfilename","qqtotalfilesize","qqfile"],type:"object"}},{auth:"bearer",constant:"LINK_VALIDATE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/validate",request:{additionalProperties:!1,properties:{childId:L.common204,childType:{default:"citoyens",enum:["citoyens"],type:"string"},linkOption:{enum:["isInviting","toBeValidated","isAdminPending"],type:"string"},parentId:L.common11,parentType:L.common187},required:["childId","childType","parentType","parentId"],type:"object"}},{auth:"none",constant:"SEARCH_MEMBER_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/searchmemberautocomplete",request:{additionalProperties:!1,properties:{search:L.common1,searchMode:{default:"personOnly",enum:["personOnly","organizationOnly","mixte"],type:"string"}},required:["search","searchMode"],type:"object"}},{auth:"bearer",constant:"GET_NOTIFICATIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/getnotifications/type/{type}/id/{id}",pathParams:L.common205,request:{additionalProperties:!1,properties:{indexMin:L.common86},type:"object"}},{auth:"bearer",constant:"GET_NOTIFICATIONS_COUNT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/getnotifications/type/{type}/id/{id}",pathParams:L.common205,request:{additionalProperties:!1,properties:{refreshTimestamp:L.common203},type:"object"}},{auth:"bearer",constant:"NOTIFICATION_UPDATE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/update",request:{additionalProperties:!1,properties:{action:{enum:["seen","read"],type:"string"},all:L.common61},required:["action","all"],type:"object"}},{auth:"bearer",constant:"REMOVE_ALL_NOTIFICATIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/removeall"},{auth:"bearer",constant:"MARK_NOTIFICATION_AS_READ",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/marknotificationasread",request:L.common100},{auth:"none",constant:"ACTIVITYPUB_SEARCH",contentType:"application/x-www-form-urlencoded",method:"GET",params:[L.common16],path:"/api/activitypub/search?address={address}",pathParams:{additionalProperties:!1,properties:{address:L.common1},required:["address"],type:"object"}},{auth:"bearer",constant:"ACTIVITYPUB_LINK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/activitypub/link",request:{additionalProperties:!1,properties:{action:{enum:["undo_follow","accept_invitation","reject_invitation","undo_accept","undo_request_follow","follow","remove_follow","accept_follower","reject_follower","remove_follower","remove_invitation"],type:"string"},actor:{additionalProperties:!1,properties:{id:L.common1,name:L.common1,type:{enum:["person"],type:"string"}},required:["id","type","name"],type:"object"},payload:L.common4},required:["action","payload","actor"],type:"object"}},{auth:"none",constant:"ACTIVITYPUB_GET_COMMUNITY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/activitypub/getcommunity/userId/${userId}/type/${type}/actor/person",pathParams:{additionalProperties:!1,properties:{type:{enum:["follows","followers"],type:"string"},userId:L.common11},required:["userId","type"],type:"object"}},{auth:"none",constant:"GET_BADGE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/page/type/badges/id/{id}/json/true",pathParams:L.common100},{auth:"none",constant:"GET_EMETTEUR_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/badge/json/true"},{auth:"bearer",constant:"ADD_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{collection:L.common207,criteria:{additionalProperties:!1,properties:{narrative:L.common1},required:["narrative"],type:"object"},description:L.common1,id:L.common11,isParcours:L.common101,issuer:{additionalProperties:!1,patternProperties:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:L.common1,type:{enum:["citoyens","organizations","projects"],type:"string"}},required:["type"],type:"object"}},type:"object"},key:L.common208,name:L.common1,parent:{additionalProperties:!1,patternProperties:{"^[a-f0-9]{24}$":{additionalProperties:!1,properties:{name:L.common1,type:L.common207},required:["type"],type:"object"}},type:"object"},preferences:L.common190,public:L.common85,scope:L.common117,tags:L.common26},required:["id","collection","key","name","public","scope","issuer","criteria"],type:"object"}},{auth:"bearer",constant:"ASSIGN_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/badges/assign",request:{additionalProperties:!1,properties:{award:{patternProperties:{"^[0-9a-f]{24}$":L.common42},type:"object"},badgeId:L.common11,collection:L.common207,evidences:{items:{additionalProperties:!1,properties:{narative:L.common1,url:L.common4},required:["narative"],type:"object"},type:"array"},key:L.common208,narative:L.common1,scope:L.common117},required:["key","collection","badgeId","award"],type:"object"}},{auth:"none",constant:"GET_EVENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/agenda",request:{additionalProperties:!1,properties:{count:L.common101,countType:{const:["events"],default:["events"],type:"array"},endDateUTC:L.common200,fediverse:L.common101,indexMin:L.common86,indexStep:{default:100,type:"integer"},locality:{patternProperties:{"^[^\\s]+$":{type:"object"}},type:"object"},name:L.common1,searchType:{const:["events"],default:["events"],items:L.common1,type:"array"},startDate:L.common60,startDateUTC:L.common200,type:L.common202},required:["searchType","indexMin","indexStep","startDate","startDateUTC","fediverse"],type:"object"}},{auth:"bearer",constant:"SHARE_EVENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:L.common102,if:L.common104,properties:{childId:L.common11,childType:L.common15,comment:L.common1,connectType:L.common106,parentId:L.common11,parentType:L.common199},required:["parentId","childId","childType","connectType","parentType"],then:L.common107,type:"object"}},{auth:"bearer",constant:"INVITE_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/multiconnect",request:{additionalProperties:!1,else:L.common79,if:L.common81,properties:{listInvite:{additionalProperties:!1,minProperties:1,properties:{citoyens:L.common209,invites:{patternProperties:{"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$":{additionalProperties:!1,properties:{email:L.common2,isAdmin:L.common213,msg:L.common1,name:L.common1,roles:L.common26},required:["name","email"],type:"object"}},type:"object"},organizations:L.common209,projects:L.common209},type:"object"},parentId:L.common1,parentType:L.common15},required:["parentId","parentType","listInvite"],then:L.common83,type:"object"}}];var B=i(27);N.addType("oid",(e=>new q.ObjectID(e)));class z extends O.EventEmitter{constructor({baseURL:e,accessToken:t,refreshToken:o,refreshUrl:n="/api/cocolight/refreshtoken",endpoints:r=M,timeout:i=3e4,debug:a=!1,maxRetries:s=0,circuitBreakerThreshold:c=5,circuitBreakerResetTime:m=6e4,fromJSONValue:d=!0,tokenStorageStrategy:l=null}={}){if(super(),!e)throw new p('Le paramètre "baseURL" est obligatoire.',500);this.__entityTag="ApiClient",this._baseURL=e,this._refreshUrl=n,this._endpoints=r,this._debug=a;let u=null;this._fromJSONValue=d,Object.defineProperty(this,"userId",{get:()=>u,set:()=>{throw new Error("Modification directe de userId non autorisée.")},enumerable:!0}),this._setUserId=e=>{u=e,this._logger.debug(`[ApiClient] userId set: ${e}`)},this._ajv=new D({strict:!1,useDefaults:!0,allErrors:!0,verbose:!0}),C(this._ajv),this._ajv.addKeyword({keyword:"startBeforeEnd",type:"object",errors:!0,validate:this._startBeforeEndValidate}),this._logger=x({transport:{target:"pino-pretty",options:{colorize:!0}},level:a?"debug":"info"}),this._client=v.create({baseURL:e,timeout:i}),s>0&&(j(this._client,{retries:s,retryDelay:j.exponentialDelay,retryCondition:e=>j.isNetworkError(e)||j.isRetryableError(e)}),this._logger.info(`[ApiClient] Retry activé : ${s} max`)),this._breakerThreshold=c,this._breakerResetTime=m,this._breakerErrorCount=0,this._breakerOpen=!1,this._lastBreakerOpenTime=null,this._accessToken=null,this._refreshToken=null,o&&this.setRefreshToken(o),t&&this.setToken(t),this._tokenStorage=l||new B.GN;const h=this._tokenStorage.getAccessToken();h&&this.setToken(h);const y=this._tokenStorage.getRefreshToken();y&&this.setRefreshToken(y),this._client.interceptors.response.use((e=>e),(async e=>{const t=e.config;if(t._retry)throw this._logger.error("[ApiClient] Requête déjà retentée, échec définitif."),e;if(e.response&&401===e.response.status&&this._refreshToken){t._retry=!0;try{if(this._logger.info("[ApiClient] Tentative de refresh du token..."),await this._refreshAccessToken())return this._logger.info("[ApiClient] Token rafraîchi avec succès."),t.headers.Authorization="Bearer "+this.getToken(),this._logger.info("[ApiClient] Retente la requête originale avec le nouveau token."),this._client.request(t);throw this.resetSession(),new p("Impossible de rafraîchir le token.",401)}catch(e){throw this.resetSession(),new p("Erreur lors du rafraîchissement du token.",401,e)}}throw e}))}setToken(e){this._accessToken=e,this._tokenStorage.setAccessToken(e),this._client.defaults.headers.common.Authorization="Bearer "+e;const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait et défini : ${t}`)),this._logger.debug(`[ApiClient] setToken: ${e}`)}getToken(){return this._accessToken}setRefreshToken(e){if(this._refreshToken=e,this._tokenStorage.setRefreshToken(e),null===this.userId){const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait depuis refreshToken : ${t}`))}this._logger.debug(`[ApiClient] setRefreshToken: ${e}`)}getRefreshToken(){return this._refreshToken}get isConnected(){return!!this._accessToken}_getIdFromToken(e){if(!e)return null;try{const t=(0,k.jwtDecode)(e);return this._logger.debug("[ApiClient] Payload décodé :",t),t.id||t.userId||null}catch(e){return this._logger.error("[ApiClient] Erreur lors du décodage du token :",e),null}}async _refreshAccessToken(){if(!this._refreshToken)return!1;const e=v.create({baseURL:this._baseURL,timeout:1e4,headers:{"Content-Type":"application/json"}});try{const t=await e.post(this._refreshUrl,{refreshToken:this._refreshToken});return!(!t.data||!t.data.token||(this.setToken(t.data.token),t.data.refreshToken&&this.setRefreshToken(t.data.refreshToken),this.emit("refreshSuccess",t.data),0))}catch(e){return this.resetSession(),this._logger.error(`[ApiClient] Refresh Error : ${e.message}`),!1}}_checkCircuitBreaker(){return!this._breakerOpen||Date.now()-this._lastBreakerOpenTime>this._breakerResetTime&&(this._breakerOpen=!1,this._breakerErrorCount=0,this._logger.warn("[ApiClient] Circuit breaker réinitialisé"),!0)}_updateCircuitBreakerError(){this._breakerErrorCount+=1,this._logger.warn(`[ApiClient] Erreur #${this._breakerErrorCount} sur ${this._breakerThreshold}`),this._breakerErrorCount>=this._breakerThreshold&&(this._breakerOpen=!0,this._lastBreakerOpenTime=Date.now(),this._logger.error("[ApiClient] Circuit breaker ACTIVÉ - L'API est considérée indisponible"))}_resetCircuitBreakerSuccess(){this._breakerErrorCount=0,this._breakerOpen&&(this._breakerOpen=!1,this._logger.warn("[ApiClient] Circuit breaker refermé suite à un succès"))}static stripNullsInPlace(e){if(e&&"object"==typeof e&&e.value&&"function"==typeof e.value.pipe)return e;if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)null===e[t]||void 0===e[t]?e.splice(t,1):"object"==typeof e[t]&&z.stripNullsInPlace(e[t]);else if(e&&"object"==typeof e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(null===e[t]||void 0===e[t]?delete e[t]:"object"==typeof e[t]&&z.stripNullsInPlace(e[t]));return e}_resolveSpecialValuesInPlace(e,t={}){const o={userId:()=>this.userId,accessToken:()=>this._accessToken,refreshToken:()=>this._refreshToken,baseURL:()=>this._baseURL,pathParams:e=>{const o=this._getValueByPath(t,e);return null!=o?o:void 0}},n=/@(?:\{([^}]+)\}|([\w.]+))/g,r=e=>"string"!=typeof e?e:e.replace(n,((t,n,r)=>{if(n){if(n.startsWith("pathParams.")){const e=n.substring(11),t=o.pathParams(e);return null!=t?t:`@{${n}}`}{const e=o[n];if("function"==typeof e){const t=e();return null!=t?t:`@{${n}}`}return`@{${n}}`}}if(r){if(r.startsWith("pathParams.")){const e=r.match(/^pathParams\.([^.]+)(.*)$/);if(e){const t=e[1],n=e[2],i=o.pathParams(t);return null!=i?i+n:`@${r}`}return`@${r}`}{const e=o[r];if("function"==typeof e){const t=e();return null!=t?t:`@${r}`}return`@${r}`}}return e})),i=e=>{if((e=>e&&"object"==typeof e&&("function"==typeof e.pipe||"undefined"!=typeof Buffer&&e instanceof Buffer))(e))return e;if(Array.isArray(e))return e.map(i);if((e=>"[object Object]"===Object.prototype.toString.call(e))(e)){const t={};for(const[o,n]of Object.entries(e))t[r(o)]=i(n);return t}return"string"==typeof e?r(e):e};return i(e)}_cleanSchemaLeftoverAlias(e){const t=/@\w+/;if(Array.isArray(e))return e.map((e=>this._cleanSchemaLeftoverAlias(e)));if(e&&"object"==typeof e){const o={};for(const n of Object.keys(e)){const r=e[n];if(!t.test(n)){if("default"===n){if("string"==typeof r&&t.test(r))continue;if(r&&"object"==typeof r){const e=this._cleanSchemaLeftoverAlias(r);Object.keys(e).length>0&&(o[n]=e);continue}}"string"==typeof r&&t.test(r)||(o[n]=this._cleanSchemaLeftoverAlias(r))}}return o}return e}async safeCall(e,...t){try{return await e(...t)}catch(e){throw this._logger.error(`[ApiClient.safeCall] Erreur: ${e.message}`),e}}async callEndpoint(e,t={},o=!0,n=!0){if(!this._checkCircuitBreaker())throw new d("Le circuit breaker est activé, impossible d'appeler l'API");const r=this._endpoints.find((t=>t.constant===e));if(!r)throw new p(`Endpoint introuvable : ${e}`,404);const{path:i,method:a,contentType:s,auth:c,pathParams:l,request:u,responses:h}=r,y=(a||"GET").toLowerCase(),f=s||"application/json",g={"Content-Type":f};if(this._accessToken)"bearer"===c?g.Authorization=`Bearer ${this._accessToken}`:c&&"none"!==c||g.Authorization||(g.Authorization=`Bearer ${this._accessToken}`);else if("bearer"===c)throw new p(`Token requis pour l'endpoint sécurisé : ${e}`,401);let T,w=i,_={};if(l){let e=l;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(l));const o=t.pathParams||{},n=this._ajv.compile(e);if(!n(o)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"pathParams",errors:n.errors}),new m("Path parameter validation failed.",400,e,n.errors)}_=this._resolveSpecialValuesInPlace(o),w=w.replace(/\{(\w+)\}/g,((e,t)=>{const o=_[t];if(void 0!==o)return encodeURIComponent(o);throw new p(`Path param manquant ou non résolu : {${t}}`,400)}))}if(u){let e=u;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(u));const o={...t};delete o.pathParams;const n=z.stripNullsInPlace(o),r=this._ajv.compile(e);if(!r(n)){const e=r.errors?this._ajvErrorHuman(r.errors):[];throw this.emit("validationError",{stage:"request",errors:r.errors}),new m("Request validation failed.",400,e,r.errors)}t=this._resolveSpecialValuesInPlace(n,_)}"application/json"===f||"multipart/form-data"===f?T=t:"application/x-www-form-urlencoded"===f&&(T=z.toURLSearchParams(t)),this._logger.debug(`[ApiClient] callEndpoint: ${e} -> ${w}, method=${y}`);try{const e=await this._client.request({url:w,method:y,headers:g,["get"===y?"params":"data"]:T});if(n){const t=e.status.toString(),o=h?.[t];if(o){const n=this._ajv.compile(o);if(!n(e.data)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"response",errors:n.errors}),new m("Response validation failed.",t,e,n.errors)}}}return this._resetCircuitBreakerSuccess(),"function"==typeof o?e.data=o(e.data):!0===o&&(e.data=this._transformData(e.data)),Array.isArray(r.postActions)&&r.postActions.forEach((t=>{const o=t.path?this._getValueByPath(e.data,t.path):null;switch(t.type){case"setToken":this.setToken(o);break;case"setRefreshToken":this.setRefreshToken(o);break;case"resetSession":this.resetSession();break;case"emitEvent":t.event&&(this.emit(t.event,o),this._logger.debug(`[ApiClient] Event émis : ${t.event}`,o));break;case"callMethod":"function"==typeof this[t.method]?(this[t.method](),this._logger.debug(`[ApiClient] Méthode appelée : ${t.method}`)):this._logger.warn(`[ApiClient] Méthode inconnue : ${t.method}`);break;default:this._logger.warn(`[ApiClient] Action inconnue : ${t.type}`)}})),e}catch(t){throw this._updateCircuitBreakerError(),this._logger.error(`[ApiClient] Erreur lors de l'appel de ${e}: ${t.message}`),t instanceof m?t:new p(`Erreur lors de l'appel de l'API : ${t.message}`,t.response?t.response.status:500,t.response?t.response.data:null)}}_ajvErrorHuman(e){try{return new S.AggregateAjvError(e).errors.map((({message:e})=>e))}catch(t){return this._logger.error("[ApiClient] _ajvErrorHuman",t),e.map((({message:e})=>e))}}checkAndThrowApiResponseError(e){const t=e.data;if(!t||"object"!=typeof t)return e;if("boolean"==typeof t.result&&!1===t.result)throw new l(t.msg||"Erreur inconnue",e.status,t);if(t.resultErrors&&"object"==typeof t.resultErrors&&"boolean"==typeof t.resultErrors.result&&!1===t.resultErrors.result)throw new l(t.resultErrors.msg||"Erreur inconnue",e.status,t);return e}resetSession(){this.setToken(null),this.setRefreshToken(null),this._setUserId(null),this._tokenStorage.clear(),delete this._client.defaults.headers.common.Authorization,this._logger.info("[ApiClient] Session utilisateur réinitialisée."),this.emit("sessionReset")}_getValueByPath(e,t){if(t)return t.split(".").reduce(((e,t)=>e&&e[t]),e)}static toURLSearchParams(e,t={}){return this._buildParams(e,new URLSearchParams,t)}static _buildParams(e,t,o={}){if("object"!=typeof e||null===e)throw new TypeError("La donnée doit être un objet non nul.");const{dots:n=!1,indexes:r=!1,metaTokens:i=!0}=o,a=[];function s(e){return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)}function c(e){return e.endsWith("[]")?e.slice(0,-2):e}function p(e,t,o=!1){return e?e.concat(t).map(((e,t)=>(e=c(e),!o&&t?`[${e}]`:e))).join(o?".":""):t}function m(e){return null==e?"":e instanceof Date?e.toISOString():(e instanceof Blob||e instanceof File||e instanceof ArrayBuffer||ArrayBuffer.isView(e),e)}return function e(o,d=[]){null==o||a.includes(o)||(a.push(o),Object.entries(o).forEach((([o,a])=>{void 0!==a&&function(e,o,a){if(e&&"object"==typeof e){if(o.endsWith("{}"))return o=i?o:o.slice(0,-2),t.append(p(a,o,n),JSON.stringify(e)),!1;if(Array.isArray(e)&&!e.some(s)||o.endsWith("[]"))return o=c(o),e.forEach(((e,i)=>{if(null!=e){const s=r?p(a.concat(o),i,n):`${p(a,o,n)}[]`;t.append(s,m(e))}})),!1}return!!s(e)||(t.append(p(a,o,n),m(e)),!1)}(a,o.trim(),d)&&e(a,d.concat(c(o)))})),a.pop())}(e),t}_transformData(e){if(e&&"object"==typeof e)if(e.resultGoods?.msg)e=this._normalizeJsonData({msg:e.resultGoods.msg,...e});else if(e.resultErrors?.msg)e=this._normalizeJsonData({msg:e.resultErrors.msg,...e});else if(e.results&&"object"==typeof e.results&&!Array.isArray(e.results))e.results=Object.keys(e.results).map((t=>this._normalizeJsonData({id:t,...e.results[t]})));else if(Array.isArray(e.results))e.results=e.results.map((e=>this._normalizeJsonData(e)));else if(e.news&&Array.isArray(e.news)&&0===e.news.length)e=e.news;else if(e.news&&"object"==typeof e.news&&!Array.isArray(e.news))e=Object.keys(e.news).map((t=>this._normalizeJsonData({id:t,...e.news[t]})));else if(e.notif&&"object"==typeof e.notif&&!Array.isArray(e.notif))e.notif=Object.keys(e.notif).map((t=>this._normalizeJsonData({id:t,...e.notif[t]})));else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens)&&e.organizations&&"object"==typeof e.organizations&&!Array.isArray(e.organizations))e=[...Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]}))),...Object.keys(e.organizations).map((t=>this._normalizeJsonData({id:t,...e.organizations[t]})))];else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens))e=Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]})));else if(e.cities&&"object"==typeof e.cities&&!Array.isArray(e.cities))e=Object.keys(e.cities).map((t=>this._normalizeJsonData({id:t,...e.cities[t]})));else if(e.cities&&Array.isArray(e.cities)&&0===e.cities.length)e=e.cities;else if(e.newComment&&"object"==typeof e.newComment)e.newComment=this._normalizeJsonData({...e.newComment});else if(Array.isArray(e))e=e.map((e=>this._normalizeJsonData(e)));else if(e.map&&"object"==typeof e.map)e.map=this._normalizeJsonData(e.map);else if(e.object&&"object"==typeof e.object)e.object=this._normalizeJsonData(e.object);else if("object"==typeof e&&Object.keys(e).length>0){const t=Object.keys(e).every((e=>/^[0-9a-fA-F]{24}$/.test(e)));e=t?Object.keys(e).map((t=>({id:t,...this._normalizeJsonData(e[t])}))):this._normalizeJsonData(e)}return e}_normalizeJsonData(e){if(!e||"object"!=typeof e)return e;if(e=this._normalizeRecursively(e),e?.mediaImg?.images&&Array.isArray(e.mediaImg.images)&&e.mediaImg.images.length>0&&(e.mediaImg.countImages=e.mediaImg.images.length),e?.mediaFile?.files&&Array.isArray(e.mediaFile.files)&&e.mediaFile.files.length>0&&(e.mediaFile.countFiles=e.mediaFile.files.length),e?.src?.changes&&"object"==typeof e.src.changes&&Object.keys(e.src.changes).length>0&&Object.keys(e.src.changes).forEach((t=>{e.src.changes[t]&&(e.src.changes[t]=this._ensureFullURL(e.src.changes[t]))})),e?.openingHours&&Array.isArray(e.openingHours)&&e.openingHours.length>0&&(e.openingHours=e.openingHours.filter((e=>e.dayOfWeek&&e.hours&&e.hours[0]&&e.hours[0].opens))),e.replies&&"object"==typeof e.replies&&Object.keys(e.replies).length>0&&(e.replies=Object.keys(e.replies).map((t=>this._normalizeJsonData({id:t,...e.replies[t]})))),e?.author&&"object"==typeof e.author&&Object.keys(e.author).length>0&&!("profilThumbImageUrl"in e.author)){const t=Object.keys(e.author)[0];e.author={...e.author[t]}}return e?.timeAgo&&delete e.timeAgo,this._fromJSONValue?N.fromJSONValue(e):e}_ensureFullURL(e){if(!e)return e;if(!(e=e.trim())||/^https?:\/\//i.test(e))return e;let t="/";return t=this._baseURL.endsWith("/")&&e.startsWith("/")||this._baseURL.endsWith("/")||e.startsWith("/")?"":"/",`${this._baseURL}${t}${e}`}_normalizeString(e){return"true"===e||"false"!==e&&e}_normalizeId(e){return e._id&&e._id.$id&&/^[0-9a-fA-F]{24}$/.test(e._id.$id)&&(e.id=e._id.$id,e._id={$type:"oid",$value:e._id.$id}),e.id&&e.id.$id&&/^[0-9a-fA-F]{24}$/.test(e.id.$id)&&(e._id={$type:"oid",$value:e.id.$id},e.id=e.id.$id),e}_normalizeDate(e){return e&&"object"==typeof e&&"number"==typeof e.sec?{$date:1e3*e.sec}:"number"==typeof e?{$date:1e3*e}:e}_normalizeImage(e){return"string"==typeof e&&""!==e.trim()?this._ensureFullURL(e):e}_imageFields=["profilImageUrl","profilThumbImageUrl","profilMediumImageUrl","profilMarkerImageUrl","profilBannerUrl","profilRealBannerUrl","imagePath","imageThumbPath","docPath"];_dateFields=["modified","created","updated","birthDate","lastLoginDate","startDate","endDate","date"];_normalizeRecursively(e){if("string"==typeof e)return this._normalizeString(e);if(Array.isArray(e))return e.map((e=>this._normalizeRecursively(e)));if(null!==e&&"object"==typeof e){const t={};return Object.keys(e).forEach((o=>{let n=this._normalizeRecursively(e[o]);this._dateFields.includes(o)&&(n=this._normalizeDate(n)),this._imageFields.includes(o)&&(n=this._normalizeImage(n)),"content"===o&&n&&"object"==typeof n&&n.image&&(n.image=this._normalizeImage(n.image)),t[o]=n})),this._normalizeId(t)}return e}_startBeforeEndValidate=(e,t)=>{if(!t.startDate||!t.endDate)return!0;const o=new Date(t.startDate)<new Date(t.endDate);return o||(this._startBeforeEndValidate.errors=[{instancePath:"",schemaPath:"#/startBeforeEnd",keyword:"startBeforeEnd",params:{},message:"startDate must be before endDate"}]),o};getRequestSchema(e){const t=this._endpoints.find((t=>t.constant===e));return t?.request||null}getPathSchema(e){return this._endpoints.find((t=>t.constant===e))?.pathParams||null}}class U{constructor(e){this.client=new z(e),this.loggedUser=null}get isConnected(){return this.client.isConnected}get userId(){return this.client.userId}async login(e,t){return this.client.safeCall((async()=>{const o=await this.client.callEndpoint("AUTHENTICATE_URL",{email:e,password:t});return this.loggedUser=new P(this.client,o.data.user,{EndpointApi:h,Organization:E,Project:I,News:w}),this.loggedUser}))}async meIsconnected(){if(!this.client.isConnected||!this.client.userId)throw new c("User not connected",401);return this.client._logger.info("UserApi","meIsconnected",this.client.userId),this.loggedUser=new P(this.client,{id:this.client.userId},{EndpointApi:h,Organization:E,Project:I,News:w}),this.loggedUser}async register({name:e,username:t,email:o,pwd:n}={}){return this.client.safeCall((async()=>{const r=await this.client.callEndpoint("PERSON_REGISTER",{name:e,username:t,email:o,pwd:n});if(!1===r?.data?.result)throw new l(r.data.msg,r.status,r.data);return r.data}))}async recoverPassword(e){return this.client.safeCall((async()=>{const t=await this.client.callEndpoint("PASSWORD_RECOVERY",{email:e});if(!1===t?.data?.result)throw new l(t.data.msg,t.status,t.data);return t.data}))}}class R{static async userLogin(e,t,o){const n=R.userApi(o);return await R.userApiLogin(n,e,t)}static userApi(e){try{return new U(e)}catch(e){throw console.error("[Api.userApi] Erreur lors de la création d'un objet utilisateur :",e.message),e}}static async userApiLogin(e,t,o){try{if(!e)throw new c("userApi is not defined");if(!e.client)throw new c("userApi.client is not defined");if(e.client.isConnected){const t=await e.meIsconnected();return new R(t,e.client)}{if(!t||!o)throw new c("email and password are required");const n=await e.login(t,o);return new R(n,e.client)}}catch(e){if(e instanceof p&&e?.details?.error)throw new u(e.details.error,e.status,e.details);throw e}}constructor(e,t){this._loggedUser=e,this._client=t}async me(){if(!this._loggedUser)throw new u("Accès refusé : utilisateur non authentifié.");return await this._loggedUser.get(),this._loggedUser}async user(e){try{if(e.id||e.slug){const t=new P(this._client,e,{EndpointApi:h,Organization:E,Project:I,News:w});return await t.get(),t}return new P(this._client,e,{EndpointApi:h,Organization:E,Project:I,News:w})}catch(e){throw console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :",e.message),e}}async organization(e){try{const t=new E(this._client,e,{EndpointApi:h,User:P,Project:I,News:w});if(!e.id&&!e.slug)throw new Error("Vous devez fournir un id ou un slug pour créer une instance Organization.");return await t.get(),t}catch(e){throw console.error("[Api.organization] Erreur lors de la création d'un objet organisation :",e.message),e}}async project(e){try{const t=new I(this._client,e,{User:P,News:w,EndpointApi:h});if(!e.id&&!e.slug)throw new Error("Vous devez fournir un id ou un slug pour créer une instance Project.");return await t.get(),t}catch(e){throw console.error("[Api.project] Erreur lors de la création d'un objet projet :",e.message),e}}get client(){return this._client}get endpointApi(){return new h(this._client)}logout(){this.loggedUser=null,this._client.resetSession(),this._client._logger.info("UserApi: User logged out")}}const G={ApiClient:z,Api:R,error:s,tokenStorageStrategy:{createDefaultTokenStorageStrategy:async function(e="auto"){if("memory"===e)return new B.GN;if("localStorage"===e){if("undefined"!=typeof window&&window.localStorage)return new B.Ge;throw new Error("localStorage is not available in this environment.")}if("file"===e){if("undefined"!=typeof window&&window.localStorage)throw new Error("file storage is not available in this environment.");const{FileStorageStrategy:e}=await i.e(405).then(i.bind(i,405));return new e}if("auto"===e){if("undefined"!=typeof window&&window.localStorage)return new B.Ge;{const{FileStorageStrategy:e}=await i.e(405).then(i.bind(i,405));return new e}}},TokenStorageStrategy:B.u3}};module.exports=a})();