1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8079],{78079:(t,n,a)=>{a.d(n,{AU:()=>v,Ee:()=>I,Gl:()=>h,IQ:()=>W,Kw:()=>U,L$:()=>O,Mz:()=>R,Nj:()=>z,OR:()=>b,SO:()=>S,WG:()=>A,Wb:()=>m,XK:()=>k,Ys:()=>P,b7:()=>T,gX:()=>w,hD:()=>f,hk:()=>y,iU:()=>s,n$:()=>C,nf:()=>E,p8:()=>j,t5:()=>g,uA:()=>u,uC:()=>D,uE:()=>p});var o=a(86146);let i="https://api.ecomitram.org",e=[1e3,2e3,4e3];function r(t){return new Promise(n=>setTimeout(n,t))}let c=null;function s(t){c=t}function u(){return c}let l=null;function m(t){l=t}let d=null;async function p(t){var n,a,c,s,u;let m,p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{body:h,headers:g,skipSessionExpiry:y,...w}=p,T=(n=w.method,"phase-production-build"===o.env.NEXT_PHASE&&(void 0===n||"GET"===n.toUpperCase()))?4:1,b="undefined"!=typeof FormData&&h instanceof FormData;for(let n=1;;n++){try{m=await fetch("".concat(i).concat(t),{credentials:"include",signal:AbortSignal.timeout(3e4),headers:{...b?{}:{"Content-Type":"application/json"},...g},...void 0!==h&&{body:b?h:JSON.stringify(h)},...w})}catch(i){if(n<T){await r(null!=(a=e[n-1])?a:4e3);continue}let o=i instanceof DOMException&&"TimeoutError"===i.name;throw new f(504,o?"Request to ".concat(t," timed out after ").concat(3e4,"ms"):"Upstream request to ".concat(t," failed"),o?"UPSTREAM_TIMEOUT":"UPSTREAM_UNREACHABLE")}if(m.status>=500&&n<T){await r(null!=(c=e[n-1])?c:4e3);continue}break}if(!m.ok){let n=await m.json().catch(()=>({message:m.statusText})),a=function(t){if("object"!=typeof t||null===t||!("message"in t))return null;let n=t.message;if("string"==typeof n)return n;if(Array.isArray(n)){let t=n.filter(t=>"string"==typeof t);return t.length>0?t.join("; "):null}return null}(n)||m.statusText||"HTTP ".concat(m.status),o="object"==typeof(s=n)&&null!==s&&"errorCode"in s&&"string"==typeof s.errorCode?n.errorCode:"object"==typeof(u=n)&&null!==u&&"code"in u&&"string"==typeof u.code?n.code:void 0;throw 401!==m.status||"AUTH_REQUIRED"===o||y||"/auth/me"===t||t.startsWith("/auth/me?")||t.startsWith("/auth/me/")||"/auth/logout"===t||t.startsWith("/auth/logout?")||t.startsWith("/auth/logout/")||"/auth/email/verify-otp"===t||t.startsWith("/auth/email/verify-otp?")||t.startsWith("/auth/email/verify-otp/")||!l||d||(d=Promise.resolve(l()).finally(()=>{d=null}).catch(()=>{})),new f(m.status,a,o)}if(204!==m.status)return m.json()}class f extends Error{constructor(t,n,a){super(n),this.status=t,this.name="ApiError",this.errorCode=a}}async function h(t,n){return(await p("/campaigns/".concat(t,"/certificate/").concat(n))).certificate}async function g(t,n){await p("/campaigns/".concat(t,"/certificate/").concat(n,"/downloaded"),{method:"PATCH",skipSessionExpiry:!0})}async function y(t){return(await p("/campaigns/".concat(t,"/my"),{skipSessionExpiry:!0})).participations}async function w(t,n,a){return(await p("/campaigns/".concat(t,"/participations/").concat(n,"/name"),{method:"PATCH",body:{name:a}})).participation}async function T(t){return(await p("/organizations",{method:"POST",body:t})).organization}async function b(){return(await p("/organizations/my")).organizations}async function E(t){return(await p("/organizations/".concat(t))).organization}async function v(t,n){return(await p("/organizations/".concat(t),{method:"PATCH",body:n})).organization}async function S(t,n){let{apiMutate:o}=await a.e(5114).then(a.bind(a,35114));return(await o("/organizations/".concat(t,"/members"),{method:"POST",body:n})).organization}async function z(t,n){return(await p("/organizations/".concat(t,"/members/").concat(n),{method:"DELETE"})).organization}async function k(t,n){let{apiMutate:o}=await a.e(5114).then(a.bind(a,35114));return(await o("/organizations/".concat(t,"/campaigns/").concat(n,"/join"),{method:"POST"})).enrollment}async function P(t,n){return p("/organizations/".concat(t,"/campaigns/").concat(n,"/certificate"))}async function C(t,n,a){let o=new URLSearchParams;(null==a?void 0:a.cursor)&&o.set("cursor",a.cursor),(null==a?void 0:a.cursorId)&&o.set("cursorId",a.cursorId),(null==a?void 0:a.limit)&&o.set("limit",String(a.limit)),(null==a?void 0:a.search)&&o.set("search",a.search);let i=o.toString();return p("/organizations/".concat(t,"/campaigns/").concat(n,"/participants").concat(i?"?".concat(i):""))}async function A(t){return(await p("/organizations/".concat(t,"/campaigns"))).enrollments}async function U(t){return!t||t.trim().length<3?[]:(await p("/users/lookup?q=".concat(encodeURIComponent(t.trim())))).users}function R(t,n){let a=new URLSearchParams({groupBy:n.groupBy,period:n.period});return n.state&&a.set("state",n.state),n.district&&a.set("district",n.district),"".concat(i,"/impact-board/").concat(t,"/export?").concat(a.toString())}async function I(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50;return p("/leaderboard?limit=".concat(t))}async function O(t,n,a){return(await p("/organizations/".concat(t,"/campaigns/").concat(n,"/links"),{method:"POST",body:a})).link}async function j(t,n,a){let o=new URLSearchParams;(null==a?void 0:a.cursor)&&o.set("cursor",a.cursor),(null==a?void 0:a.cursorId)&&o.set("cursorId",a.cursorId),(null==a?void 0:a.limit)&&o.set("limit",String(a.limit)),(null==a?void 0:a.search)&&o.set("search",a.search);let i=o.toString();return p("/organizations/".concat(t,"/links/").concat(n,"/participants").concat(i?"?".concat(i):""))}function D(t,n){return"".concat(i,"/organizations/").concat(t,"/links/").concat(n,"/participants.csv")}async function W(t,n){return p("/campaigns/".concat(t,"/register"),{method:"POST",body:{qrCode:n.qrCode,participant:{name:n.participant.name},...n.participant.formData?{formData:n.participant.formData}:{},...n.turnstileToken?{turnstileToken:n.turnstileToken}:{}}})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.