apifox-mcp-server 0.0.7-alpha.4 → 0.0.7
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.
- package/README.md +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -92,7 +92,7 @@ data: ${JSON.stringify(e)}
|
|
|
92
92
|
`,Kz=Eo.encode(Wr),Jz=2,sv=class{constructor(e,n){let{escapeName:r}=this.constructor,a=T.isString(n),s=`Content-Disposition: form-data; name="${r(e)}"${!a&&n.name?`; filename="${r(n.name)}"`:""}${Wr}`;a?n=Eo.encode(String(n).replace(/\r?\n|\r\n?/g,Wr)):s+=`Content-Type: ${n.type||"application/octet-stream"}${Wr}`,this.headers=Eo.encode(s+Wr),this.contentLength=a?n.byteLength:n.size,this.size=this.headers.byteLength+this.contentLength+Jz,this.name=e,this.value=n}async*encode(){yield this.headers;let{value:e}=this;T.isTypedArray(e)?yield e:yield*Pp(e),yield Kz}static escapeName(e){return String(e).replace(/[\r\n"]/g,n=>({"\r":"%0D","\n":"%0A",'"':"%22"})[n])}},Xz=(t,e,n)=>{let{tag:r="form-data-boundary",size:a=25,boundary:s=r+"-"+ke.generateString(a,Gz)}=n||{};if(!T.isFormData(t))throw TypeError("FormData instance required");if(s.length<1||s.length>70)throw Error("boundary must be 10-70 characters long");let c=Eo.encode("--"+s+Wr),u=Eo.encode("--"+s+"--"+Wr+Wr),l=u.byteLength,f=Array.from(t.entries()).map(([h,v])=>{let w=new sv(h,v);return l+=w.size,w});l+=c.byteLength*f.length,l=T.toFiniteNumber(l);let d={"Content-Type":`multipart/form-data; boundary=${s}`};return Number.isFinite(l)&&(d["Content-Length"]=l),e&&e(d),S5.Readable.from(async function*(){for(let h of f)yield c,yield*h.encode();yield u}())},E5=Xz;var k5=Fe(require("stream"),1),ov=class extends k5.default.Transform{__transform(e,n,r){this.push(e),r()}_transform(e,n,r){if(e.length!==0&&(this._transform=this.__transform,e[0]!==120)){let a=Buffer.alloc(2);a[0]=120,a[1]=156,this.push(a,n)}this.__transform(e,n,r)}},A5=ov;var Yz=(t,e)=>T.isAsyncFn(t)?function(...n){let r=n.pop();t.apply(this,n).then(a=>{try{e?r(null,...e(a)):r(null,a)}catch(s){r(s)}},r)}:t,T5=Yz;function Qz(t,e){t=t||10;let n=new Array(t),r=new Array(t),a=0,s=0,c;return e=e!==void 0?e:1e3,function(l){let f=Date.now(),d=r[s];c||(c=f),n[a]=l,r[a]=f;let h=s,v=0;for(;h!==a;)v+=n[h++],h=h%t;if(a=(a+1)%t,a===s&&(s=(s+1)%t),f-c<e)return;let w=d&&f-d;return w?Math.round(v*1e3/w):void 0}}var R5=Qz;function e$(t,e){let n=0,r=1e3/e,a,s,c=(f,d=Date.now())=>{n=d,a=null,s&&(clearTimeout(s),s=null),t.apply(null,f)};return[(...f)=>{let d=Date.now(),h=d-n;h>=r?c(f,d):(a=f,s||(s=setTimeout(()=>{s=null,c(a)},r-h)))},()=>a&&c(a)]}var O5=e$;var xr=(t,e,n=3)=>{let r=0,a=R5(50,250);return O5(s=>{let c=s.loaded,u=s.lengthComputable?s.total:void 0,l=c-r,f=a(l),d=c<=u;r=c;let h={loaded:c,total:u,progress:u?c/u:void 0,bytes:l,rate:f||void 0,estimated:f&&u&&d?(u-c)/f:void 0,event:s,lengthComputable:u!=null,[e?"download":"upload"]:!0};t(h)},n)},Gi=(t,e)=>{let n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},Ki=t=>(...e)=>T.asap(()=>t(...e));var C5={flush:br.default.constants.Z_SYNC_FLUSH,finishFlush:br.default.constants.Z_SYNC_FLUSH},t$={flush:br.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:br.default.constants.BROTLI_OPERATION_FLUSH},P5=T.isFunction(br.default.createBrotliDecompress),{http:n$,https:r$}=D5.default,a$=/https:?/,L5=ke.protocols.map(t=>t+":"),I5=(t,[e,n])=>(t.on("end",n).on("error",n),e);function i$(t,e){t.beforeRedirects.proxy&&t.beforeRedirects.proxy(t),t.beforeRedirects.config&&t.beforeRedirects.config(t,e)}function U5(t,e,n){let r=e;if(!r&&r!==!1){let a=j5.default.getProxyForUrl(n);a&&(r=new URL(a))}if(r){if(r.username&&(r.auth=(r.username||"")+":"+(r.password||"")),r.auth){(r.auth.username||r.auth.password)&&(r.auth=(r.auth.username||"")+":"+(r.auth.password||""));let s=Buffer.from(r.auth,"utf8").toString("base64");t.headers["Proxy-Authorization"]="Basic "+s}t.headers.host=t.hostname+(t.port?":"+t.port:"");let a=r.hostname||r.host;t.hostname=a,t.host=a,t.port=r.port,t.path=n,r.protocol&&(t.protocol=r.protocol.includes(":")?r.protocol:`${r.protocol}:`)}t.beforeRedirects.proxy=function(s){U5(s,e,s.href)}}var s$=typeof process<"u"&&T.kindOf(process)==="process",o$=t=>new Promise((e,n)=>{let r,a,s=(l,f)=>{a||(a=!0,r&&r(l,f))},c=l=>{s(l),e(l)},u=l=>{s(l,!0),n(l)};t(c,u,l=>r=l).catch(u)}),c$=({address:t,family:e})=>{if(!T.isString(t))throw TypeError("address must be a string");return{address:t,family:e||(t.indexOf(".")<0?6:4)}},q5=(t,e)=>c$(T.isObject(t)?t:{address:t,family:e}),z5=s$&&function(e){return o$(async function(r,a,s){let{data:c,lookup:u,family:l}=e,{responseType:f,responseEncoding:d}=e,h=e.method.toUpperCase(),v,w=!1,y;if(u){let Q=T5(u,Y=>T.isArray(Y)?Y:[Y]);u=(Y,se,Qe)=>{Q(Y,se,(ze,$t,Nn)=>{if(ze)return Qe(ze);let yt=T.isArray($t)?$t.map(Pt=>q5(Pt)):[q5($t,Nn)];se.all?Qe(ze,yt):Qe(ze,yt[0].address,yt[0].family)})}}let E=new M5.EventEmitter,k=()=>{e.cancelToken&&e.cancelToken.unsubscribe(L),e.signal&&e.signal.removeEventListener("abort",L),E.removeAllListeners()};s((Q,Y)=>{v=!0,Y&&(w=!0,k())});function L(Q){E.emit("abort",!Q||Q.type?new nn(null,e,y):Q)}E.once("abort",a),(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(L),e.signal&&(e.signal.aborted?L():e.signal.addEventListener("abort",L)));let F=Na(e.baseURL,e.url,e.allowAbsoluteUrls),I=new URL(F,ke.hasBrowserEnv?ke.origin:void 0),D=I.protocol||L5[0];if(D==="data:"){let Q;if(h!=="GET")return Xn(r,a,{status:405,statusText:"method not allowed",headers:{},config:e});try{Q=nv(e.url,f==="blob",{Blob:e.env&&e.env.Blob})}catch(Y){throw W.from(Y,W.ERR_BAD_REQUEST,e)}return f==="text"?(Q=Q.toString(d),(!d||d==="utf8")&&(Q=T.stripBOM(Q))):f==="stream"&&(Q=Ma.default.Readable.from(Q)),Xn(r,a,{data:Q,status:200,statusText:"OK",headers:new Ge,config:e})}if(L5.indexOf(D)===-1)return a(new W("Unsupported protocol "+D,W.ERR_BAD_REQUEST,e));let z=Ge.from(e.headers).normalize();z.set("User-Agent","axios/"+Da,!1);let{onUploadProgress:X,onDownloadProgress:$}=e,he=e.maxRate,Ee,Le;if(T.isSpecCompliantForm(c)){let Q=z.getContentType(/boundary=([-_\w\d]{10,70})/i);c=E5(c,Y=>{z.set(Y)},{tag:`axios-${Da}-boundary`,boundary:Q&&Q[1]||void 0})}else if(T.isFormData(c)&&T.isFunction(c.getHeaders)){if(z.set(c.getHeaders()),!z.hasContentLength())try{let Q=await B5.default.promisify(c.getLength).call(c);Number.isFinite(Q)&&Q>=0&&z.setContentLength(Q)}catch{}}else if(T.isBlob(c)||T.isFile(c))c.size&&z.setContentType(c.type||"application/octet-stream"),z.setContentLength(c.size||0),c=Ma.default.Readable.from(Pp(c));else if(c&&!T.isStream(c)){if(!Buffer.isBuffer(c))if(T.isArrayBuffer(c))c=Buffer.from(new Uint8Array(c));else if(T.isString(c))c=Buffer.from(c,"utf-8");else return a(new W("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",W.ERR_BAD_REQUEST,e));if(z.setContentLength(c.length,!1),e.maxBodyLength>-1&&c.length>e.maxBodyLength)return a(new W("Request body larger than maxBodyLength limit",W.ERR_BAD_REQUEST,e))}let Ue=T.toFiniteNumber(z.getContentLength());T.isArray(he)?(Ee=he[0],Le=he[1]):Ee=Le=he,c&&(X||Ee)&&(T.isStream(c)||(c=Ma.default.Readable.from(c,{objectMode:!1})),c=Ma.default.pipeline([c,new iv({maxRate:T.toFiniteNumber(Ee)})],T.noop),X&&c.on("progress",I5(c,Gi(Ue,xr(Ki(X),!1,3)))));let je;if(e.auth){let Q=e.auth.username||"",Y=e.auth.password||"";je=Q+":"+Y}if(!je&&I.username){let Q=I.username,Y=I.password;je=Q+":"+Y}je&&z.delete("authorization");let at;try{at=ja(I.pathname+I.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(Q){let Y=new Error(Q.message);return Y.config=e,Y.url=e.url,Y.exists=!0,a(Y)}z.set("Accept-Encoding","gzip, compress, deflate"+(P5?", br":""),!1);let xe={path:at,method:h,headers:z.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:je,protocol:D,family:l,beforeRedirect:i$,beforeRedirects:{}};!T.isUndefined(u)&&(xe.lookup=u),e.socketPath?xe.socketPath=e.socketPath:(xe.hostname=I.hostname.startsWith("[")?I.hostname.slice(1,-1):I.hostname,xe.port=I.port,U5(xe,e.proxy,D+"//"+I.hostname+(I.port?":"+I.port:"")+xe.path));let Ae,He=a$.test(xe.protocol);if(xe.agent=He?e.httpsAgent:e.httpAgent,e.transport?Ae=e.transport:e.maxRedirects===0?Ae=He?F5.default:N5.default:(e.maxRedirects&&(xe.maxRedirects=e.maxRedirects),e.beforeRedirect&&(xe.beforeRedirects.config=e.beforeRedirect),Ae=He?r$:n$),e.maxBodyLength>-1?xe.maxBodyLength=e.maxBodyLength:xe.maxBodyLength=1/0,e.insecureHTTPParser&&(xe.insecureHTTPParser=e.insecureHTTPParser),y=Ae.request(xe,function(Y){if(y.destroyed)return;let se=[Y],Qe=+Y.headers["content-length"];if($||Le){let Pt=new iv({maxRate:T.toFiniteNumber(Le)});$&&Pt.on("progress",I5(Pt,Gi(Qe,xr(Ki($),!0,3)))),se.push(Pt)}let ze=Y,$t=Y.req||y;if(e.decompress!==!1&&Y.headers["content-encoding"])switch((h==="HEAD"||Y.statusCode===204)&&delete Y.headers["content-encoding"],(Y.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":se.push(br.default.createUnzip(C5)),delete Y.headers["content-encoding"];break;case"deflate":se.push(new A5),se.push(br.default.createUnzip(C5)),delete Y.headers["content-encoding"];break;case"br":P5&&(se.push(br.default.createBrotliDecompress(t$)),delete Y.headers["content-encoding"])}ze=se.length>1?Ma.default.pipeline(se,T.noop):se[0];let Nn=Ma.default.finished(ze,()=>{Nn(),k()}),yt={status:Y.statusCode,statusText:Y.statusMessage,headers:new Ge(Y.headers),config:e,request:$t};if(f==="stream")yt.data=ze,Xn(r,a,yt);else{let Pt=[],yr=0;ze.on("data",function(ft){Pt.push(ft),yr+=ft.length,e.maxContentLength>-1&&yr>e.maxContentLength&&(w=!0,ze.destroy(),a(new W("maxContentLength size of "+e.maxContentLength+" exceeded",W.ERR_BAD_RESPONSE,e,$t)))}),ze.on("aborted",function(){if(w)return;let ft=new W("stream has been aborted",W.ERR_BAD_RESPONSE,e,$t);ze.destroy(ft),a(ft)}),ze.on("error",function(ft){y.destroyed||a(W.from(ft,null,e,$t))}),ze.on("end",function(){try{let ft=Pt.length===1?Pt[0]:Buffer.concat(Pt);f!=="arraybuffer"&&(ft=ft.toString(d),(!d||d==="utf8")&&(ft=T.stripBOM(ft))),yt.data=ft}catch(ft){return a(W.from(ft,null,e,yt.request,yt))}Xn(r,a,yt)})}E.once("abort",Pt=>{ze.destroyed||(ze.emit("error",Pt),ze.destroy())})}),E.once("abort",Q=>{a(Q),y.destroy(Q)}),y.on("error",function(Y){a(W.from(Y,null,e,y))}),y.on("socket",function(Y){Y.setKeepAlive(!0,1e3*60)}),e.timeout){let Q=parseInt(e.timeout,10);if(Number.isNaN(Q)){a(new W("error trying to parse `config.timeout` to int",W.ERR_BAD_OPTION_VALUE,e,y));return}y.setTimeout(Q,function(){if(v)return;let se=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",Qe=e.transitional||Hi;e.timeoutErrorMessage&&(se=e.timeoutErrorMessage),a(new W(se,Qe.clarifyTimeoutError?W.ETIMEDOUT:W.ECONNABORTED,e,y)),L()})}if(T.isStream(c)){let Q=!1,Y=!1;c.on("end",()=>{Q=!0}),c.once("error",se=>{Y=!0,y.destroy(se)}),c.on("close",()=>{!Q&&!Y&&L(new nn("Request stream has been aborted",e,y))}),c.pipe(y)}else y.end(c)})};var $5=ke.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,ke.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(ke.origin),ke.navigator&&/(msie|trident)/i.test(ke.navigator.userAgent)):()=>!0;var H5=ke.hasStandardBrowserEnv?{write(t,e,n,r,a,s){let c=[t+"="+encodeURIComponent(e)];T.isNumber(n)&&c.push("expires="+new Date(n).toGMTString()),T.isString(r)&&c.push("path="+r),T.isString(a)&&c.push("domain="+a),s===!0&&c.push("secure"),document.cookie=c.join("; ")},read(t){let e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var Z5=t=>t instanceof Ge?{...t}:t;function In(t,e){e=e||{};let n={};function r(f,d,h,v){return T.isPlainObject(f)&&T.isPlainObject(d)?T.merge.call({caseless:v},f,d):T.isPlainObject(d)?T.merge({},d):T.isArray(d)?d.slice():d}function a(f,d,h,v){if(T.isUndefined(d)){if(!T.isUndefined(f))return r(void 0,f,h,v)}else return r(f,d,h,v)}function s(f,d){if(!T.isUndefined(d))return r(void 0,d)}function c(f,d){if(T.isUndefined(d)){if(!T.isUndefined(f))return r(void 0,f)}else return r(void 0,d)}function u(f,d,h){if(h in e)return r(f,d);if(h in t)return r(void 0,f)}let l={url:s,method:s,data:s,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:u,headers:(f,d,h)=>a(Z5(f),Z5(d),h,!0)};return T.forEach(Object.keys(Object.assign({},t,e)),function(d){let h=l[d]||a,v=h(t[d],e[d],d);T.isUndefined(v)&&h!==u||(n[d]=v)}),n}var Lp=t=>{let e=In({},t),{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:s,headers:c,auth:u}=e;e.headers=c=Ge.from(c),e.url=ja(Na(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),u&&c.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?unescape(encodeURIComponent(u.password)):"")));let l;if(T.isFormData(n)){if(ke.hasStandardBrowserEnv||ke.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if((l=c.getContentType())!==!1){let[f,...d]=l?l.split(";").map(h=>h.trim()).filter(Boolean):[];c.setContentType([f||"multipart/form-data",...d].join("; "))}}if(ke.hasStandardBrowserEnv&&(r&&T.isFunction(r)&&(r=r(e)),r||r!==!1&&$5(e.url))){let f=a&&s&&H5.read(s);f&&c.set(a,f)}return e};var u$=typeof XMLHttpRequest<"u",W5=u$&&function(t){return new Promise(function(n,r){let a=Lp(t),s=a.data,c=Ge.from(a.headers).normalize(),{responseType:u,onUploadProgress:l,onDownloadProgress:f}=a,d,h,v,w,y;function E(){w&&w(),y&&y(),a.cancelToken&&a.cancelToken.unsubscribe(d),a.signal&&a.signal.removeEventListener("abort",d)}let k=new XMLHttpRequest;k.open(a.method.toUpperCase(),a.url,!0),k.timeout=a.timeout;function L(){if(!k)return;let I=Ge.from("getAllResponseHeaders"in k&&k.getAllResponseHeaders()),z={data:!u||u==="text"||u==="json"?k.responseText:k.response,status:k.status,statusText:k.statusText,headers:I,config:t,request:k};Xn(function($){n($),E()},function($){r($),E()},z),k=null}"onloadend"in k?k.onloadend=L:k.onreadystatechange=function(){!k||k.readyState!==4||k.status===0&&!(k.responseURL&&k.responseURL.indexOf("file:")===0)||setTimeout(L)},k.onabort=function(){k&&(r(new W("Request aborted",W.ECONNABORTED,t,k)),k=null)},k.onerror=function(){r(new W("Network Error",W.ERR_NETWORK,t,k)),k=null},k.ontimeout=function(){let D=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded",z=a.transitional||Hi;a.timeoutErrorMessage&&(D=a.timeoutErrorMessage),r(new W(D,z.clarifyTimeoutError?W.ETIMEDOUT:W.ECONNABORTED,t,k)),k=null},s===void 0&&c.setContentType(null),"setRequestHeader"in k&&T.forEach(c.toJSON(),function(D,z){k.setRequestHeader(z,D)}),T.isUndefined(a.withCredentials)||(k.withCredentials=!!a.withCredentials),u&&u!=="json"&&(k.responseType=a.responseType),f&&([v,y]=xr(f,!0),k.addEventListener("progress",v)),l&&k.upload&&([h,w]=xr(l),k.upload.addEventListener("progress",h),k.upload.addEventListener("loadend",w)),(a.cancelToken||a.signal)&&(d=I=>{k&&(r(!I||I.type?new nn(null,t,k):I),k.abort(),k=null)},a.cancelToken&&a.cancelToken.subscribe(d),a.signal&&(a.signal.aborted?d():a.signal.addEventListener("abort",d)));let F=So(a.url);if(F&&ke.protocols.indexOf(F)===-1){r(new W("Unsupported protocol "+F+":",W.ERR_BAD_REQUEST,t));return}k.send(s||null)})};var p$=(t,e)=>{let{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,a,s=function(f){if(!a){a=!0,u();let d=f instanceof Error?f:this.reason;r.abort(d instanceof W?d:new nn(d instanceof Error?d.message:d))}},c=e&&setTimeout(()=>{c=null,s(new W(`timeout ${e} of ms exceeded`,W.ETIMEDOUT))},e),u=()=>{t&&(c&&clearTimeout(c),c=null,t.forEach(f=>{f.unsubscribe?f.unsubscribe(s):f.removeEventListener("abort",s)}),t=null)};t.forEach(f=>f.addEventListener("abort",s));let{signal:l}=r;return l.unsubscribe=()=>T.asap(u),l}},V5=p$;var l$=function*(t,e){let n=t.byteLength;if(!e||n<e){yield t;return}let r=0,a;for(;r<n;)a=r+e,yield t.slice(r,a),r=a},f$=async function*(t,e){for await(let n of d$(t))yield*l$(n,e)},d$=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},cv=(t,e,n,r)=>{let a=f$(t,e),s=0,c,u=l=>{c||(c=!0,r&&r(l))};return new ReadableStream({async pull(l){try{let{done:f,value:d}=await a.next();if(f){u(),l.close();return}let h=d.byteLength;if(n){let v=s+=h;n(v)}l.enqueue(new Uint8Array(d))}catch(f){throw u(f),f}},cancel(l){return u(l),a.return()}},{highWaterMark:2})};var qp=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",K5=qp&&typeof ReadableStream=="function",m$=qp&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),J5=(t,...e)=>{try{return!!t(...e)}catch{return!1}},h$=K5&&J5(()=>{let t=!1,e=new Request(ke.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),G5=64*1024,uv=K5&&J5(()=>T.isReadableStream(new Response("").body)),Ip={stream:uv&&(t=>t.body)};qp&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Ip[e]&&(Ip[e]=T.isFunction(t[e])?n=>n[e]():(n,r)=>{throw new W(`Response type '${e}' is not supported`,W.ERR_NOT_SUPPORT,r)})})})(new Response);var v$=async t=>{if(t==null)return 0;if(T.isBlob(t))return t.size;if(T.isSpecCompliantForm(t))return(await new Request(ke.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(T.isArrayBufferView(t)||T.isArrayBuffer(t))return t.byteLength;if(T.isURLSearchParams(t)&&(t=t+""),T.isString(t))return(await m$(t)).byteLength},g$=async(t,e)=>{let n=T.toFiniteNumber(t.getContentLength());return n??v$(e)},X5=qp&&(async t=>{let{url:e,method:n,data:r,signal:a,cancelToken:s,timeout:c,onDownloadProgress:u,onUploadProgress:l,responseType:f,headers:d,withCredentials:h="same-origin",fetchOptions:v}=Lp(t);f=f?(f+"").toLowerCase():"text";let w=V5([a,s&&s.toAbortSignal()],c),y,E=w&&w.unsubscribe&&(()=>{w.unsubscribe()}),k;try{if(l&&h$&&n!=="get"&&n!=="head"&&(k=await g$(d,r))!==0){let z=new Request(e,{method:"POST",body:r,duplex:"half"}),X;if(T.isFormData(r)&&(X=z.headers.get("content-type"))&&d.setContentType(X),z.body){let[$,he]=Gi(k,xr(Ki(l)));r=cv(z.body,G5,$,he)}}T.isString(h)||(h=h?"include":"omit");let L="credentials"in Request.prototype;y=new Request(e,{...v,signal:w,method:n.toUpperCase(),headers:d.normalize().toJSON(),body:r,duplex:"half",credentials:L?h:void 0});let F=await fetch(y),I=uv&&(f==="stream"||f==="response");if(uv&&(u||I&&E)){let z={};["status","statusText","headers"].forEach(Ee=>{z[Ee]=F[Ee]});let X=T.toFiniteNumber(F.headers.get("content-length")),[$,he]=u&&Gi(X,xr(Ki(u),!0))||[];F=new Response(cv(F.body,G5,$,()=>{he&&he(),E&&E()}),z)}f=f||"text";let D=await Ip[T.findKey(Ip,f)||"text"](F,t);return!I&&E&&E(),await new Promise((z,X)=>{Xn(z,X,{data:D,headers:Ge.from(F.headers),status:F.status,statusText:F.statusText,config:t,request:y})})}catch(L){throw E&&E(),L&&L.name==="TypeError"&&/fetch/i.test(L.message)?Object.assign(new W("Network Error",W.ERR_NETWORK,t,y),{cause:L.cause||L}):W.from(L,L&&L.code,t,y)}});var pv={http:z5,xhr:W5,fetch:X5};T.forEach(pv,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});var Y5=t=>`- ${t}`,x$=t=>T.isFunction(t)||t===null||t===!1,jp={getAdapter:t=>{t=T.isArray(t)?t:[t];let{length:e}=t,n,r,a={};for(let s=0;s<e;s++){n=t[s];let c;if(r=n,!x$(n)&&(r=pv[(c=String(n)).toLowerCase()],r===void 0))throw new W(`Unknown adapter '${c}'`);if(r)break;a[c||"#"+s]=r}if(!r){let s=Object.entries(a).map(([u,l])=>`adapter ${u} `+(l===!1?"is not supported by the environment":"is not available in the build")),c=e?s.length>1?`since :
|
|
93
93
|
`+s.map(Y5).join(`
|
|
94
94
|
`):" "+Y5(s[0]):"as no adapter specified";throw new W("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return r},adapters:pv};function lv(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new nn(null,t)}function Np(t){return lv(t),t.headers=Ge.from(t.headers),t.data=go.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),jp.getAdapter(t.adapter||Zi.adapter)(t).then(function(r){return lv(t),r.data=go.call(t,t.transformResponse,r),r.headers=Ge.from(r.headers),r},function(r){return xo(r)||(lv(t),r&&r.response&&(r.response.data=go.call(t,t.transformResponse,r.response),r.response.headers=Ge.from(r.response.headers))),Promise.reject(r)})}var Fp={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Fp[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});var Q5={};Fp.transitional=function(e,n,r){function a(s,c){return"[Axios v"+Da+"] Transitional option '"+s+"'"+c+(r?". "+r:"")}return(s,c,u)=>{if(e===!1)throw new W(a(c," has been removed"+(n?" in "+n:"")),W.ERR_DEPRECATED);return n&&!Q5[c]&&(Q5[c]=!0,console.warn(a(c," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(s,c,u):!0}};Fp.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function b$(t,e,n){if(typeof t!="object")throw new W("options must be an object",W.ERR_BAD_OPTION_VALUE);let r=Object.keys(t),a=r.length;for(;a-- >0;){let s=r[a],c=e[s];if(c){let u=t[s],l=u===void 0||c(u,s,t);if(l!==!0)throw new W("option "+s+" must be "+l,W.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new W("Unknown option "+s,W.ERR_BAD_OPTION)}}var ko={assertOptions:b$,validators:Fp};var Yn=ko.validators,Ji=class{constructor(e){this.defaults=e,this.interceptors={request:new qh,response:new qh}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;let s=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
95
|
-
`+s):r.stack=s}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=In(this.defaults,n);let{transitional:r,paramsSerializer:a,headers:s}=n;r!==void 0&&ko.assertOptions(r,{silentJSONParsing:Yn.transitional(Yn.boolean),forcedJSONParsing:Yn.transitional(Yn.boolean),clarifyTimeoutError:Yn.transitional(Yn.boolean)},!1),a!=null&&(T.isFunction(a)?n.paramsSerializer={serialize:a}:ko.assertOptions(a,{encode:Yn.function,serialize:Yn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ko.assertOptions(n,{baseUrl:Yn.spelling("baseURL"),withXsrfToken:Yn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let c=s&&T.merge(s.common,s[n.method]);s&&T.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),n.headers=Ge.concat(c,s);let u=[],l=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(n)===!1||(l=l&&E.synchronous,u.unshift(E.fulfilled,E.rejected))});let f=[];this.interceptors.response.forEach(function(E){f.push(E.fulfilled,E.rejected)});let d,h=0,v;if(!l){let y=[Np.bind(this),void 0];for(y.unshift.apply(y,u),y.push.apply(y,f),v=y.length,d=Promise.resolve(n);h<v;)d=d.then(y[h++],y[h++]);return d}v=u.length;let w=n;for(h=0;h<v;){let y=u[h++],E=u[h++];try{w=y(w)}catch(k){E.call(this,k);break}}try{d=Np.call(this,w)}catch(y){return Promise.reject(y)}for(h=0,v=f.length;h<v;)d=d.then(f[h++],f[h++]);return d}getUri(e){e=In(this.defaults,e);let n=Na(e.baseURL,e.url,e.allowAbsoluteUrls);return ja(n,e.params,e.paramsSerializer)}};T.forEach(["delete","get","head","options"],function(e){Ji.prototype[e]=function(n,r){return this.request(In(r||{},{method:e,url:n,data:(r||{}).data}))}});T.forEach(["post","put","patch"],function(e){function n(r){return function(s,c,u){return this.request(In(u||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:c}))}}Ji.prototype[e]=n(),Ji.prototype[e+"Form"]=n(!0)});var Ao=Ji;var fv=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});let r=this;this.promise.then(a=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](a);r._listeners=null}),this.promise.then=a=>{let s,c=new Promise(u=>{r.subscribe(u),s=u}).then(a);return c.cancel=function(){r.unsubscribe(s)},c},e(function(s,c,u){r.reason||(r.reason=new nn(s,c,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){let e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new t(function(a){e=a}),cancel:e}}},e9=fv;function dv(t){return function(n){return t.apply(null,n)}}function mv(t){return T.isObject(t)&&t.isAxiosError===!0}var hv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(hv).forEach(([t,e])=>{hv[e]=t});var t9=hv;function n9(t){let e=new Ao(t),n=fo(Ao.prototype.request,e);return T.extend(n,Ao.prototype,e,{allOwnKeys:!0}),T.extend(n,e,null,{allOwnKeys:!0}),n.create=function(a){return n9(In(t,a))},n}var rt=n9(Zi);rt.Axios=Ao;rt.CanceledError=nn;rt.CancelToken=e9;rt.isCancel=xo;rt.VERSION=Da;rt.toFormData=Zr;rt.AxiosError=W;rt.Cancel=rt.CanceledError;rt.all=function(e){return Promise.all(e)};rt.spread=dv;rt.isAxiosError=mv;rt.mergeConfig=In;rt.AxiosHeaders=Ge;rt.formToJSON=t=>Op(T.isHTMLForm(t)?new FormData(t):t);rt.getAdapter=jp.getAdapter;rt.HttpStatusCode=t9;rt.default=rt;var Bp=rt;var{Axios:ZQ,AxiosError:WQ,CanceledError:VQ,isCancel:GQ,CancelToken:KQ,VERSION:JQ,all:XQ,Cancel:YQ,isAxiosError:QQ,spread:eee,toFormData:tee,AxiosHeaders:nee,HttpStatusCode:ree,formToJSON:aee,getAdapter:iee,mergeConfig:see}=Bp;var r9=Fe(require("os")),vv=Fe(require("path"));try{require("dotenv").config({path:vv.default.join(__dirname,"../.env")})}catch{}var a9="CN",Ua="apifox",i9=Ua?.toUpperCase(),Dp=Ua.charAt(0).toUpperCase()+Ua.slice(1),y$=process.env.MCP_S_DATA_LOCATION||r9.default.homedir(),To=vv.default.join(y$,`.${Ua}-mcp-server`);var qn=Fe(require("fs/promises")),jn=Fe(require("path"));var Oo=Fe(gv());function s9(t){if(!t||typeof t!="object")return t;let{components:e,...n}=t;if(!e)return t;let r={},a=c=>{let u=[],l=f=>{if(!(!f||typeof f!="object")){if(Array.isArray(f))for(let d of f)l(d);else for(let d in f)if(Object.prototype.hasOwnProperty.call(f,d)){if(d==="$ref"){let h=f[d];if(typeof h=="string"){h.startsWith("#/components/")&&u.push(h.substring(13));continue}}l(f[d])}}};return l(c),u},s=c=>{a(c)?.forEach(l=>{if((0,Oo.get)(r,l.replace(/\//g,".")))return;let f=(0,Oo.get)(e,l.replace(/\//g,"."));f&&((0,Oo.set)(r,l.replace(/\//g,"."),f),s(f))})};return s(n),{components:{...r,securitySchemes:e.securitySchemes},...n}}function Mp(t){return t.replace(/\//g,"_")}var Co=Fe(gv());async function w$(t,e,n=300){await qn.default.mkdir(jn.default.join(t,"paths"),{recursive:!0});let r=e.paths||{},a=Object.keys(r),s={};for(let u of a){let f=`./paths/${Mp(u)}.json`,d=jn.default.resolve(t,f),h=r[u]||{};await qn.default.writeFile(d,JSON.stringify(h,null,2));let v=Object.keys(h).reduce((w,y)=>(w[y]={summary:h[y].summary},w),{});s[u]={$ref:f,...v}}let c={page:Math.ceil(a.length/n),pageSize:n,otherPages:{}};if(c.page>1){await qn.default.mkdir(jn.default.join(t,"pages"),{recursive:!0});let u={...s},l=(0,Co.chunk)(a,n);for(let[f,d]of l.entries()){if(f===0){s=(0,Co.pick)(u,d);continue}let h=f+1,v=jn.default.resolve(t,`pages/${h}.json`),w=(0,Co.pick)(u,d);await qn.default.writeFile(v,JSON.stringify(w,null,2)),c.otherPages[h]={$ref:`./pages/${h}.json`}}s["x-pagination"]=c}return s}async function Up(t,e,n){let r=e.components?.[n];if(!r)return;let a=jn.default.join(t,"components",n);await qn.default.mkdir(a,{recursive:!0});let s=Object.keys(r),c={};for(let f of s){let d=`./components/${n}/${f}.json`,h=jn.default.resolve(t,d),v=r[f]||{};await qn.default.writeFile(h,JSON.stringify(v,null,2)),c[f]={$ref:d}}let u=`./components/${n}/index.json`,l=jn.default.resolve(t,u);return await qn.default.writeFile(l,JSON.stringify(c,null,2)),u}async function o9(t,e,n={}){let r=jn.default.join(To,`project-${t}`);await qn.default.mkdir(r,{recursive:!0});let a=s9(e);await qn.default.writeFile(jn.default.join(r,"original.json"),JSON.stringify(e,null,2));let s=await w$(r,a,n.pageSize),c=await Up(r,a,"schemas"),u=await Up(r,a,"securitySchemes"),l=await Up(r,a,"requestBodies"),f=await Up(r,a,"responses");return a.info={...a.info,"x-download-time":new Date().toISOString()},a.paths=s,a.components=a.components||{},c&&(a.components.schemas={$ref:c}),u&&(a.components.securitySchemes={$ref:u}),l&&(a.components.requestBodies={$ref:l}),f&&(a.components.responses={$ref:f}),a.tags=void 0,await qn.default.writeFile(jn.default.join(r,"index.json"),JSON.stringify(a,null,2)),a}var A9=Fe(require("os"));var ie=t=>typeof t=="string",Po=()=>{let t,e,n=new Promise((r,a)=>{t=r,e=a});return n.resolve=t,n.reject=e,n},c9=t=>t==null?"":""+t,_$=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},S$=/###/g,u9=t=>t&&t.indexOf("###")>-1?t.replace(S$,"."):t,p9=t=>!t||ie(t),Lo=(t,e,n)=>{let r=ie(e)?e.split("."):e,a=0;for(;a<r.length-1;){if(p9(t))return{};let s=u9(r[a]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++a}return p9(t)?{}:{obj:t,k:u9(r[a])}},l9=(t,e,n)=>{let{obj:r,k:a}=Lo(t,e,Object);if(r!==void 0||e.length===1){r[a]=n;return}let s=e[e.length-1],c=e.slice(0,e.length-1),u=Lo(t,c,Object);for(;u.obj===void 0&&c.length;)s=`${c[c.length-1]}.${s}`,c=c.slice(0,c.length-1),u=Lo(t,c,Object),u?.obj&&typeof u.obj[`${u.k}.${s}`]<"u"&&(u.obj=void 0);u.obj[`${u.k}.${s}`]=n},E$=(t,e,n,r)=>{let{obj:a,k:s}=Lo(t,e,Object);a[s]=a[s]||[],a[s].push(n)},$p=(t,e)=>{let{obj:n,k:r}=Lo(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},k$=(t,e,n)=>{let r=$p(t,n);return r!==void 0?r:$p(e,n)},b9=(t,e,n)=>{for(let r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?ie(t[r])||t[r]instanceof String||ie(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):b9(t[r],e[r],n):t[r]=e[r]);return t},Yi=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),A$={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},T$=t=>ie(t)?t.replace(/[&<>"'\/]/g,e=>A$[e]):t,bv=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(n!==void 0)return n;let r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}},R$=[" ",",","?","!",";"],O$=new bv(20),C$=(t,e,n)=>{e=e||"",n=n||"";let r=R$.filter(c=>e.indexOf(c)<0&&n.indexOf(c)<0);if(r.length===0)return!0;let a=O$.getRegExp(`(${r.map(c=>c==="?"?"\\?":c).join("|")})`),s=!a.test(t);if(!s){let c=t.indexOf(n);c>0&&!a.test(t.substring(0,c))&&(s=!0)}return s},yv=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;let r=e.split(n),a=t;for(let s=0;s<r.length;){if(!a||typeof a!="object")return;let c,u="";for(let l=s;l<r.length;++l)if(l!==s&&(u+=n),u+=r[l],c=a[u],c!==void 0){if(["string","number","boolean"].indexOf(typeof c)>-1&&l<r.length-1)continue;s+=l-s+1;break}a=c}return a},Hp=t=>t?.replace("_","-"),P$={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}},wv=class t{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||P$,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,a){return a&&!this.debug?null:(ie(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new t(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new t(this.logger,e)}},Qn=new wv,es=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);let a=this.observers[r].get(n)||0;this.observers[r].set(n,a+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(c=>{let[u,l]=c;for(let f=0;f<l;f++)u(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(c=>{let[u,l]=c;for(let f=0;f<l;f++)u.apply(u,[e,...r])})}},Zp=class extends es{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){let n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,c=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,u;e.indexOf(".")>-1?u=e.split("."):(u=[e,n],r&&(Array.isArray(r)?u.push(...r):ie(r)&&s?u.push(...r.split(s)):u.push(r)));let l=$p(this.data,u);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=u[0],n=u[1],r=u.slice(2).join(".")),l||!c||!ie(r)?l:yv(this.data?.[e]?.[n],r,s)}addResource(e,n,r,a){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},c=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,u=[e,n];r&&(u=u.concat(c?r.split(c):r)),e.indexOf(".")>-1&&(u=e.split("."),a=n,n=u[1]),this.addNamespaces(n),l9(this.data,u,a),s.silent||this.emit("added",e,n,r,a)}addResources(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(let s in r)(ie(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});a.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,a,s){let c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},u=[e,n];e.indexOf(".")>-1&&(u=e.split("."),a=r,r=n,n=u[1]),this.addNamespaces(n);let l=$p(this.data,u)||{};c.skipCopy||(r=JSON.parse(JSON.stringify(r))),a?b9(l,r,s):l={...l,...r},l9(this.data,u,l),c.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(a=>n[a]&&Object.keys(n[a]).length>0)}toJSON(){return this.data}},y9={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,a){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,a)??e}),e}},f9={},d9=t=>!ie(t)&&typeof t!="boolean"&&typeof t!="number",Wp=class t extends es{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),_$(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Qn.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};return e==null?!1:this.resolve(e,n)?.res!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");let a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,s=n.ns||this.options.defaultNS||[],c=r&&e.indexOf(r)>-1,u=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!C$(e,r,a);if(c&&!u){let l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:ie(s)?[s]:s};let f=e.split(r);(r!==a||r===a&&this.options.ns.indexOf(f[0])>-1)&&(s=f.shift()),e=f.join(a)}return{key:e,namespaces:ie(s)?[s]:s}}translate(e,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);let a=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:c,namespaces:u}=this.extractFromKey(e[e.length-1],n),l=u[u.length-1],f=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode"){if(d){let Ue=n.nsSeparator||this.options.nsSeparator;return a?{res:`${l}${Ue}${c}`,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${Ue}${c}`}return a?{res:c,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:c}let h=this.resolve(e,n),v=h?.res,w=h?.usedKey||c,y=h?.exactUsedKey||c,E=["[object Number]","[object Function]","[object RegExp]"],k=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,L=!this.i18nFormat||this.i18nFormat.handleAsObject,F=n.count!==void 0&&!ie(n.count),I=t.hasDefaultValue(n),D=F?this.pluralResolver.getSuffix(f,n.count,n):"",z=n.ordinal&&F?this.pluralResolver.getSuffix(f,n.count,{ordinal:!1}):"",X=F&&!n.ordinal&&n.count===0,$=X&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${D}`]||n[`defaultValue${z}`]||n.defaultValue,he=v;L&&!v&&I&&(he=$);let Ee=d9(he),Le=Object.prototype.toString.apply(he);if(L&&he&&Ee&&E.indexOf(Le)<0&&!(ie(k)&&Array.isArray(he))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let Ue=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,he,{...n,ns:u}):`key '${c} (${this.language})' returned an object instead of string.`;return a?(h.res=Ue,h.usedParams=this.getUsedParamsDetails(n),h):Ue}if(s){let Ue=Array.isArray(he),je=Ue?[]:{},at=Ue?y:w;for(let xe in he)if(Object.prototype.hasOwnProperty.call(he,xe)){let Ae=`${at}${s}${xe}`;I&&!v?je[xe]=this.translate(Ae,{...n,defaultValue:d9($)?$[xe]:void 0,joinArrays:!1,ns:u}):je[xe]=this.translate(Ae,{...n,joinArrays:!1,ns:u}),je[xe]===Ae&&(je[xe]=he[xe])}v=je}}else if(L&&ie(k)&&Array.isArray(v))v=v.join(k),v&&(v=this.extendTranslation(v,e,n,r));else{let Ue=!1,je=!1;!this.isValidLookup(v)&&I&&(Ue=!0,v=$),this.isValidLookup(v)||(je=!0,v=c);let xe=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&je?void 0:v,Ae=I&&$!==v&&this.options.updateMissing;if(je||Ue||Ae){if(this.logger.log(Ae?"updateKey":"missingKey",f,l,c,Ae?$:v),s){let se=this.resolve(c,{...n,keySeparator:!1});se&&se.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let He=[],Q=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Q&&Q[0])for(let se=0;se<Q.length;se++)He.push(Q[se]);else this.options.saveMissingTo==="all"?He=this.languageUtils.toResolveHierarchy(n.lng||this.language):He.push(n.lng||this.language);let Y=(se,Qe,ze)=>{let $t=I&&ze!==v?ze:xe;this.options.missingKeyHandler?this.options.missingKeyHandler(se,l,Qe,$t,Ae,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(se,l,Qe,$t,Ae,n),this.emit("missingKey",se,l,Qe,v)};this.options.saveMissing&&(this.options.saveMissingPlurals&&F?He.forEach(se=>{let Qe=this.pluralResolver.getSuffixes(se,n);X&&n[`defaultValue${this.options.pluralSeparator}zero`]&&Qe.indexOf(`${this.options.pluralSeparator}zero`)<0&&Qe.push(`${this.options.pluralSeparator}zero`),Qe.forEach(ze=>{Y([se],c+ze,n[`defaultValue${ze}`]||$)})}):Y(He,c,$))}v=this.extendTranslation(v,e,n,h,r),je&&v===c&&this.options.appendNamespaceToMissingKey&&(v=`${l}:${c}`),(je||Ue)&&this.options.parseMissingKeyHandler&&(v=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${c}`:c,Ue?v:void 0))}return a?(h.res=v,h.usedParams=this.getUsedParamsDetails(n),h):v}extendTranslation(e,n,r,a,s){var c=this;if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});let f=ie(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables),d;if(f){let v=e.match(this.interpolator.nestingRegexp);d=v&&v.length}let h=r.replace&&!ie(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(h={...this.options.interpolation.defaultVariables,...h}),e=this.interpolator.interpolate(e,h,r.lng||this.language||a.usedLng,r),f){let v=e.match(this.interpolator.nestingRegexp),w=v&&v.length;d<w&&(r.nest=!1)}!r.lng&&a&&a.res&&(r.lng=this.language||a.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var v=arguments.length,w=new Array(v),y=0;y<v;y++)w[y]=arguments[y];return s?.[0]===w[0]&&!r.context?(c.logger.warn(`It seems you are nesting recursively key: ${w[0]} in key: ${n[0]}`),null):c.translate(...w,n)},r)),r.interpolation&&this.interpolator.reset()}let u=r.postProcess||this.options.postProcess,l=ie(u)?[u]:u;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=y9.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,a,s,c,u;return ie(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;let f=this.extractFromKey(l,n),d=f.key;a=d;let h=f.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));let v=n.count!==void 0&&!ie(n.count),w=v&&!n.ordinal&&n.count===0,y=n.context!==void 0&&(ie(n.context)||typeof n.context=="number")&&n.context!=="",E=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(k=>{this.isValidLookup(r)||(u=k,!f9[`${E[0]}-${k}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(u)&&(f9[`${E[0]}-${k}`]=!0,this.logger.warn(`key "${a}" for languages "${E.join(", ")}" won't get resolved as namespace "${u}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),E.forEach(L=>{if(this.isValidLookup(r))return;c=L;let F=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(F,d,L,k,n);else{let D;v&&(D=this.pluralResolver.getSuffix(L,n.count,n));let z=`${this.options.pluralSeparator}zero`,X=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(v&&(F.push(d+D),n.ordinal&&D.indexOf(X)===0&&F.push(d+D.replace(X,this.options.pluralSeparator)),w&&F.push(d+z)),y){let $=`${d}${this.options.contextSeparator}${n.context}`;F.push($),v&&(F.push($+D),n.ordinal&&D.indexOf(X)===0&&F.push($+D.replace(X,this.options.pluralSeparator)),w&&F.push($+z))}}let I;for(;I=F.pop();)this.isValidLookup(r)||(s=I,r=this.getResource(L,k,I,n))}))})}),{res:r,usedKey:a,exactUsedKey:s,usedLng:c,usedNS:u}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,a):this.resourceStore.getResource(e,n,r,a)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!ie(e.replace),a=r?e.replace:e;if(r&&typeof e.count<"u"&&(a.count=e.count),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!r){a={...a};for(let s of n)delete a[s]}return a}static hasDefaultValue(e){let n="defaultValue";for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}},Vp=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Qn.create("languageUtils")}getScriptPartFromCode(e){if(e=Hp(e),!e||e.indexOf("-")<0)return null;let n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Hp(e),!e||e.indexOf("-")<0)return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(ie(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;let a=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(a))&&(n=a)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;let a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(s=>{if(s===a)return s;if(!(s.indexOf("-")<0&&a.indexOf("-")<0)&&(s.indexOf("-")>0&&a.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===a||s.indexOf(a)===0&&a.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),ie(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){let r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),a=[],s=c=>{c&&(this.isSupportedCode(c)?a.push(c):this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`))};return ie(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):ie(e)&&s(this.formatLanguageCode(e)),r.forEach(c=>{a.indexOf(c)<0&&s(this.formatLanguageCode(c))}),a}},m9={zero:0,one:1,two:2,few:3,many:4,other:5},h9={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},_v=class{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=Qn.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=Hp(e==="dev"?"en":e),a=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:a});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let c;try{c=new Intl.PluralRules(r,{type:a})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),h9;if(!e.match(/-|_/))return h9;let l=this.languageUtils.getLanguagePartFromCode(e);c=this.getRule(l,n)}return this.pluralRulesCache[s]=c,c}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(a=>`${n}${a}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((a,s)=>m9[a]-m9[s]).map(a=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=this.getRule(e,r);return a?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${a.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}},v9=function(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=k$(t,e,n);return!s&&a&&ie(n)&&(s=yv(t,n,r),s===void 0&&(s=yv(e,n,r))),s},xv=t=>t.replace(/\$/g,"$$$$"),Sv=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Qn.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});let{escape:n,escapeValue:r,useRawValueToEscape:a,prefix:s,prefixEscaped:c,suffix:u,suffixEscaped:l,formatSeparator:f,unescapeSuffix:d,unescapePrefix:h,nestingPrefix:v,nestingPrefixEscaped:w,nestingSuffix:y,nestingSuffixEscaped:E,nestingOptionsSeparator:k,maxReplaces:L,alwaysFormat:F}=e.interpolation;this.escape=n!==void 0?n:T$,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=a!==void 0?a:!1,this.prefix=s?Yi(s):c||"{{",this.suffix=u?Yi(u):l||"}}",this.formatSeparator=f||",",this.unescapePrefix=d?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=v?Yi(v):w||Yi("$t("),this.nestingSuffix=y?Yi(y):E||Yi(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=L||1e3,this.alwaysFormat=F!==void 0?F:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,n,r,a){let s,c,u,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},f=w=>{if(w.indexOf(this.formatSeparator)<0){let L=v9(n,l,w,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(L,void 0,r,{...a,...n,interpolationkey:w}):L}let y=w.split(this.formatSeparator),E=y.shift().trim(),k=y.join(this.formatSeparator).trim();return this.format(v9(n,l,E,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...a,...n,interpolationkey:E})};this.resetRegExp();let d=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=a?.interpolation?.skipOnVariables!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:w=>xv(w)},{regex:this.regexp,safeValue:w=>this.escapeValue?xv(this.escape(w)):xv(w)}].forEach(w=>{for(u=0;s=w.regex.exec(e);){let y=s[1].trim();if(c=f(y),c===void 0)if(typeof d=="function"){let k=d(e,s,a);c=ie(k)?k:""}else if(a&&Object.prototype.hasOwnProperty.call(a,y))c="";else if(h){c=s[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${e}`),c="";else!ie(c)&&!this.useRawValueToEscape&&(c=c9(c));let E=w.safeValue(c);if(e=e.replace(s[0],E),h?(w.regex.lastIndex+=c.length,w.regex.lastIndex-=s[0].length):w.regex.lastIndex=0,u++,u>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a,s,c,u=(l,f)=>{let d=this.nestingOptionsSeparator;if(l.indexOf(d)<0)return l;let h=l.split(new RegExp(`${d}[ ]*{`)),v=`{${h[1]}`;l=h[0],v=this.interpolate(v,c);let w=v.match(/'/g),y=v.match(/"/g);((w?.length??0)%2===0&&!y||y.length%2!==0)&&(v=v.replace(/'/g,'"'));try{c=JSON.parse(v),f&&(c={...f,...c})}catch(E){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,E),`${l}${d}${v}`}return c.defaultValue&&c.defaultValue.indexOf(this.prefix)>-1&&delete c.defaultValue,l};for(;a=this.nestingRegexp.exec(e);){let l=[];c={...r},c=c.replace&&!ie(c.replace)?c.replace:c,c.applyPostProcessor=!1,delete c.defaultValue;let f=!1;if(a[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(a[1])){let d=a[1].split(this.formatSeparator).map(h=>h.trim());a[1]=d.shift(),l=d,f=!0}if(s=n(u.call(this,a[1].trim(),c),c),s&&a[0]===e&&!ie(s))return s;ie(s)||(s=c9(s)),s||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),s=""),f&&(s=l.reduce((d,h)=>this.format(d,h,r.lng,{...r,interpolationkey:a[1].trim()}),s.trim())),e=e.replace(a[0],s),this.regexp.lastIndex=0}return e}},L$=t=>{let e=t.toLowerCase().trim(),n={};if(t.indexOf("(")>-1){let r=t.split("(");e=r[0].toLowerCase().trim();let a=r[1].substring(0,r[1].length-1);e==="currency"&&a.indexOf(":")<0?n.currency||(n.currency=a.trim()):e==="relativetime"&&a.indexOf(":")<0?n.range||(n.range=a.trim()):a.split(";").forEach(c=>{if(c){let[u,...l]=c.split(":"),f=l.join(":").trim().replace(/^'+|'+$/g,""),d=u.trim();n[d]||(n[d]=f),f==="false"&&(n[d]=!1),f==="true"&&(n[d]=!0),isNaN(f)||(n[d]=parseInt(f,10))}})}return{formatName:e,formatOptions:n}},Qi=t=>{let e={};return(n,r,a)=>{let s=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(s={...s,[a.interpolationkey]:void 0});let c=r+JSON.stringify(s),u=e[c];return u||(u=t(Hp(r),a),e[c]=u),u(n)}},Ev=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Qn.create("formatter"),this.options=e,this.formats={number:Qi((n,r)=>{let a=new Intl.NumberFormat(n,{...r});return s=>a.format(s)}),currency:Qi((n,r)=>{let a=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>a.format(s)}),datetime:Qi((n,r)=>{let a=new Intl.DateTimeFormat(n,{...r});return s=>a.format(s)}),relativetime:Qi((n,r)=>{let a=new Intl.RelativeTimeFormat(n,{...r});return s=>a.format(s,r.range||"day")}),list:Qi((n,r)=>{let a=new Intl.ListFormat(n,{...r});return s=>a.format(s)})},this.init(e)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Qi(n)}format(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(u=>u.indexOf(")")>-1)){let u=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,u)].join(this.formatSeparator)}return s.reduce((u,l)=>{let{formatName:f,formatOptions:d}=L$(l);if(this.formats[f]){let h=u;try{let v=a?.formatParams?.[a.interpolationkey]||{},w=v.locale||v.lng||a.locale||a.lng||r;h=this.formats[f](u,w,{...d,...a,...v})}catch(v){this.logger.warn(v)}return h}else this.logger.warn(`there was no format function for ${f}`);return u},e)}},I$=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)},kv=class extends es{constructor(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=a,this.logger=Qn.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,a.backend,a)}queueLoad(e,n,r,a){let s={},c={},u={},l={};return e.forEach(f=>{let d=!0;n.forEach(h=>{let v=`${f}|${h}`;!r.reload&&this.store.hasResourceBundle(f,h)?this.state[v]=2:this.state[v]<0||(this.state[v]===1?c[v]===void 0&&(c[v]=!0):(this.state[v]=1,d=!1,c[v]===void 0&&(c[v]=!0),s[v]===void 0&&(s[v]=!0),l[h]===void 0&&(l[h]=!0)))}),d||(u[f]=!0)}),(Object.keys(s).length||Object.keys(c).length)&&this.queue.push({pending:c,pendingCount:Object.keys(c).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(s),pending:Object.keys(c),toLoadLanguages:Object.keys(u),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){let a=e.split("|"),s=a[0],c=a[1];n&&this.emit("failedLoading",s,c,n),!n&&r&&this.store.addResourceBundle(s,c,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);let u={};this.queue.forEach(l=>{E$(l.loaded,[s],c),I$(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(f=>{u[f]||(u[f]={});let d=l.loaded[f];d.length&&d.forEach(h=>{u[f][h]===void 0&&(u[f][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",u),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,c=arguments.length>5?arguments[5]:void 0;if(!e.length)return c(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:a,wait:s,callback:c});return}this.readingCalls++;let u=(f,d)=>{if(this.readingCalls--,this.waitingReads.length>0){let h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(f&&d&&a<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,a+1,s*2,c)},s);return}c(f,d)},l=this.backend[r].bind(this.backend);if(l.length===2){try{let f=l(e,n);f&&typeof f.then=="function"?f.then(d=>u(null,d)).catch(u):u(null,f)}catch(f){u(f)}return}return l(e,n,u)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();ie(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ie(n)&&(n=[n]);let s=this.queueLoad(e,n,r,a);if(!s.toLoad.length)return s.pending.length||a(),null;s.toLoad.forEach(c=>{this.loadOne(c)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",r=e.split("|"),a=r[0],s=r[1];this.read(a,s,"read",void 0,void 0,(c,u)=>{c&&this.logger.warn(`${n}loading namespace ${s} for language ${a} failed`,c),!c&&u&&this.logger.log(`${n}loaded namespace ${s} for language ${a}`,u),this.loaded(e,c,u)})}saveMissing(e,n,r,a,s){let c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},u=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){let l={...c,isUpdate:s},f=this.backend.create.bind(this.backend);if(f.length<6)try{let d;f.length===5?d=f(e,n,r,a,l):d=f(e,n,r,a),d&&typeof d.then=="function"?d.then(h=>u(null,h)).catch(u):u(null,d)}catch(d){u(d)}else f(e,n,r,a,u,l)}!e||!e[0]||this.store.addResource(e[0],n,r,a)}}},g9=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),ie(t[1])&&(e.defaultValue=t[1]),ie(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){let n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),x9=t=>(ie(t.ns)&&(t.ns=[t.ns]),ie(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ie(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),zp=()=>{},q$=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})},Gp=class t extends es{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=x9(e),this.services={},this.logger=Qn,this.modules={external:[]},q$(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),n.defaultNS==null&&n.ns&&(ie(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));let a=g9();this.options={...a,...this.options,...x9(n)},this.options.interpolation={...a.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);let s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Qn.init(s(this.modules.logger),this.options):Qn.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=Ev;let h=new Vp(this.options);this.store=new Zp(this.options.resources,this.options);let v=this.services;v.logger=Qn,v.resourceStore=this.store,v.languageUtils=h,v.pluralResolver=new _v(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),d&&(!this.options.interpolation.format||this.options.interpolation.format===a.interpolation.format)&&(v.formatter=s(d),v.formatter.init(v,this.options),this.options.interpolation.format=v.formatter.format.bind(v.formatter)),v.interpolator=new Sv(this.options),v.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},v.backendConnector=new kv(s(this.modules.backend),v.resourceStore,v,this.options),v.backendConnector.on("*",function(w){for(var y=arguments.length,E=new Array(y>1?y-1:0),k=1;k<y;k++)E[k-1]=arguments[k];e.emit(w,...E)}),this.modules.languageDetector&&(v.languageDetector=s(this.modules.languageDetector),v.languageDetector.init&&v.languageDetector.init(v,this.options.detection,this.options)),this.modules.i18nFormat&&(v.i18nFormat=s(this.modules.i18nFormat),v.i18nFormat.init&&v.i18nFormat.init(this)),this.translator=new Wp(this.services,this.options),this.translator.on("*",function(w){for(var y=arguments.length,E=new Array(y>1?y-1:0),k=1;k<y;k++)E[k-1]=arguments[k];e.emit(w,...E)}),this.modules.external.forEach(w=>{w.init&&w.init(this)})}if(this.format=this.options.interpolation.format,r||(r=zp),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=function(){return e.store[d](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=function(){return e.store[d](...arguments),e}});let l=Po(),f=()=>{let d=(h,v)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(v),r(h,v)};if(this.languages&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?f():setTimeout(f,0),l}loadResources(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:zp,a=ie(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(a?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();let s=[],c=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(f=>{f!=="cimode"&&s.indexOf(f)<0&&s.push(f)})};a?c(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>c(l)),this.options.preload?.forEach?.(u=>c(u)),this.services.backendConnector.load(s,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(u)})}else r(null)}reloadResources(e,n,r){let a=Po();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=zp),this.services.backendConnector.reload(e,n,s=>{a.resolve(),r(s)}),a}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&y9.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let n=0;n<this.languages.length;n++){let r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;let a=Po();this.emit("languageChanging",e);let s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},c=(l,f)=>{f?(s(f),this.translator.changeLanguage(f),this.isLanguageChangingTo=void 0,this.emit("languageChanged",f),this.logger.log("languageChanged",f)):this.isLanguageChangingTo=void 0,a.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},u=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);let f=ie(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);f&&(this.language||s(f),this.translator.language||this.translator.changeLanguage(f),this.services.languageDetector?.cacheUserLanguage?.(f)),this.loadResources(f,d=>{c(d,f)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?u(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(u):this.services.languageDetector.detect(u):u(e),a}getFixedT(e,n,r){var a=this;let s=function(c,u){let l;if(typeof u!="object"){for(var f=arguments.length,d=new Array(f>2?f-2:0),h=2;h<f;h++)d[h-2]=arguments[h];l=a.options.overloadTranslationOptionHandler([c,u].concat(d))}else l={...u};l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||s.keyPrefix);let v=a.options.keySeparator||".",w;return l.keyPrefix&&Array.isArray(c)?w=c.map(y=>`${l.keyPrefix}${v}${y}`):w=l.keyPrefix?`${l.keyPrefix}${v}${c}`:c,a.t(w,l)};return ie(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.translator?.translate(...n)}exists(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.translator?.exists(...n)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let r=n.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;let c=(u,l)=>{let f=this.services.backendConnector.state[`${u}|${l}`];return f===-1||f===0||f===2};if(n.precheck){let u=n.precheck(this,c);if(u!==void 0)return u}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||c(r,e)&&(!a||c(s,e)))}loadNamespaces(e,n){let r=Po();return this.options.ns?(ie(e)&&(e=[e]),e.forEach(a=>{this.options.ns.indexOf(a)<0&&this.options.ns.push(a)}),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){let r=Po();ie(e)&&(e=[e]);let a=this.options.preload||[],s=e.filter(c=>a.indexOf(c)<0&&this.services.languageUtils.isSupportedCode(c));return s.length?(this.options.preload=a.concat(s),this.loadResources(c=>{r.resolve(),n&&n(c)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";let n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new Vp(g9());return n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new t(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:zp,r=e.forkResourceStore;r&&delete e.forkResourceStore;let a={...this.options,...e,isClone:!0},s=new t(a);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(u=>{s[u]=this[u]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){let u=Object.keys(this.store.data).reduce((l,f)=>(l[f]={...this.store.data[f]},Object.keys(l[f]).reduce((d,h)=>(d[h]={...l[f][h]},d),{})),{});s.store=new Zp(u,a),s.services.resourceStore=s.store}return s.translator=new Wp(s.services,a),s.translator.on("*",function(u){for(var l=arguments.length,f=new Array(l>1?l-1:0),d=1;d<l;d++)f[d-1]=arguments[d];s.emit(u,...f)}),s.init(a,n),s.translator.options=a,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},Ct=Gp.createInstance();Ct.createInstance=Gp.createInstance;var hee=Ct.createInstance,vee=Ct.dir,w9=Ct.init,gee=Ct.loadResources,xee=Ct.reloadResources,bee=Ct.use,yee=Ct.changeLanguage,wee=Ct.getFixedT,Io=Ct.t,_ee=Ct.exists,See=Ct.setDefaultNamespace,Eee=Ct.hasLoadedNamespace,kee=Ct.loadNamespaces,Aee=Ct.loadLanguages;var _9={translation:{"tool.read_project_oas.desc":"Read the project's OpenAPI Spec file","tool.read_project_oas_ref_resources.desc":"Read the file content of $ref in the project OpenAPI Spec file. You can get the content of multiple files at the same time","tool.read_project_oas_ref_resources.params.path.desc":'The value of $ref in the OpenAPI Spec file can retrieve the contents of multiple files at the same time, such as: ["./paths/_get_pet.json", "./paths/_get_order.json"]',"tool.refresh_project_oas.desc":"Re-download the latest OpenAPI Spec file from the server"}};var S9={translation:{"tool.read_project_oas.desc":"\u8BFB\u53D6\u9879\u76EE\u7684 OpenAPI Spec \u6587\u4EF6","tool.read_project_oas_ref_resources.desc":"\u8BFB\u53D6\u9879\u76EE OpenAPI Spec \u6587\u4EF6\u5185 $ref \u7684\u6587\u4EF6\u5185\u5BB9\uFF0C\u53EF\u4EE5\u540C\u65F6\u83B7\u53D6\u591A\u4E2A\u6587\u4EF6\u5185\u5BB9","tool.read_project_oas_ref_resources.params.path.desc":'OpenAPI Spec \u6587\u4EF6\u5185 $ref \u7684\u503C\uFF0C\u53EF\u4EE5\u540C\u65F6\u83B7\u53D6\u591A\u4E2A\u6587\u4EF6\u5185\u5BB9\uFF0C\u5982\uFF1A["./paths/_get_pet.json", "./paths/_get_order.json"]',"tool.refresh_project_oas.desc":"\u4ECE\u670D\u52A1\u5668\u91CD\u65B0\u4E0B\u8F7D\u6700\u65B0\u7684 OpenAPI Spec \u6587\u4EF6"}};var T9=Number.MAX_SAFE_INTEGER,R9="0.0.7-alpha.4",O9=a9==="CN"?"zh":"en",$a=(0,k9.default)(process.argv.slice(2)),C9=$a.token||process.env[`${i9}_ACCESS_TOKEN`],Jp=$a.project,N$=$a["api-page-size"]||T9.toString(),F$=$a["api-version"]||"2024-03-28",B$=$a.lang||O9,Av=$a.sse,D$=$a[`${Ua}-api-base-url`]||`https://api.${Ua}.com`,P9=!1;(async()=>{try{w9({lng:B$,fallbackLng:O9,resources:{en:_9,zh:S9}})}catch(t){console.log(t)}})();Jp||(console.error("Please provide a project ID"),process.exit(1));C9||(console.error("Please provide a token"),process.exit(1));var ts=new nu({name:`${Dp} MCP Server`,version:R9}),Ov=za.default.join(To,`project-${Jp}`),Tv=za.default.join(Ov,"index.json");function M$(){let t=new au;ts.connect(t)}function U$(t){let e=t,n="127.0.0.1";if(t.includes(":")){let[c,u]=t.split(":");n=c||"",e=u||""}let r=parseInt(e);isNaN(r)&&(r=3001);let a=(0,E9.default)(),s;a.get("/sse",async(c,u)=>{s=new _u("/messages",u),await ts.connect(s)}),a.post("/messages",async(c,u)=>{await s.handlePostMessage(c,u)}),a.listen(r,n)}function z$(){ts.tool("read_project_oas",Io("tool.read_project_oas.desc"),{},async()=>{try{return{content:[{type:"text",text:await Xp(Tv)}]}}catch(t){try{return await Kp.default.access(Tv),{content:[{type:"text",text:String(t)}]}}catch{return{content:[{type:"text",text:await Rv()}]}}}}),ts.tool("read_project_oas_ref_resources",Io("tool.read_project_oas_ref_resources.desc"),{path:_.array(_.string()).describe(Io("tool.read_project_oas_ref_resources.params.path.desc"))},async({path:t})=>{try{await Kp.default.writeFile(za.default.join(A9.default.homedir(),"mcp.log"),JSON.stringify({path:t}),"utf-8");let e=Array.isArray(t)?t:[t],n={};for(let r of e){let a=await Xp(za.default.resolve(Ov,r));n[r]=a}return{content:[{type:"text",text:JSON.stringify(n)}]}}catch{return{content:[{type:"text",text:"API definition reference file not found, maybe it is a broken link, please download the latest API definition from the server."}]}}}),ts.tool("refresh_project_oas",Io("tool.refresh_project_oas.desc"),{},async()=>({content:[{type:"text",text:await Rv()}]}))}async function $$(){P9&&await H$(),z$(),typeof Av=="string"&&Av?U$(Av):M$()}$$();async function Xp(t){return await Kp.default.readFile(za.default.resolve(To,t),"utf8")}async function Rv(){let t=`/api/v1/projects/${Jp}/export-openapi`,e=await Bp.post(D$+t,{scope:{type:"ALL"}},{headers:{[`X-${Dp}-Version`]:F$,Authorization:`Bearer ${C9}`,"User-Agent":`${Dp}-MCP-Server/${R9}`}}),n=parseInt(N$);isNaN(n)&&(n=T9);let r=await o9(Jp,e.data,{pageSize:n});return P9&&L9(r),JSON.stringify(r)}async function L9(t){for(let e of Object.keys(t?.paths||{}))for(let n of Object.keys(t?.paths?.[e]||{}))((r,a)=>{if(a==="$ref")return;let s=Mp(r);try{ts.tool(`${a}_${s}`,t.paths?.[r]?.[a]?.summary||"",{},async()=>({content:[{type:"text",text:await Xp(za.default.join(Ov,"paths",`${s}.json`))}]}))}catch(c){console.log(c)}})(e,n)}async function H$(){try{let t=await Xp(Tv),e=JSON.parse(t);L9(e)}catch(t){console.log(t),Rv()}}
|
|
95
|
+
`+s):r.stack=s}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=In(this.defaults,n);let{transitional:r,paramsSerializer:a,headers:s}=n;r!==void 0&&ko.assertOptions(r,{silentJSONParsing:Yn.transitional(Yn.boolean),forcedJSONParsing:Yn.transitional(Yn.boolean),clarifyTimeoutError:Yn.transitional(Yn.boolean)},!1),a!=null&&(T.isFunction(a)?n.paramsSerializer={serialize:a}:ko.assertOptions(a,{encode:Yn.function,serialize:Yn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ko.assertOptions(n,{baseUrl:Yn.spelling("baseURL"),withXsrfToken:Yn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let c=s&&T.merge(s.common,s[n.method]);s&&T.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),n.headers=Ge.concat(c,s);let u=[],l=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(n)===!1||(l=l&&E.synchronous,u.unshift(E.fulfilled,E.rejected))});let f=[];this.interceptors.response.forEach(function(E){f.push(E.fulfilled,E.rejected)});let d,h=0,v;if(!l){let y=[Np.bind(this),void 0];for(y.unshift.apply(y,u),y.push.apply(y,f),v=y.length,d=Promise.resolve(n);h<v;)d=d.then(y[h++],y[h++]);return d}v=u.length;let w=n;for(h=0;h<v;){let y=u[h++],E=u[h++];try{w=y(w)}catch(k){E.call(this,k);break}}try{d=Np.call(this,w)}catch(y){return Promise.reject(y)}for(h=0,v=f.length;h<v;)d=d.then(f[h++],f[h++]);return d}getUri(e){e=In(this.defaults,e);let n=Na(e.baseURL,e.url,e.allowAbsoluteUrls);return ja(n,e.params,e.paramsSerializer)}};T.forEach(["delete","get","head","options"],function(e){Ji.prototype[e]=function(n,r){return this.request(In(r||{},{method:e,url:n,data:(r||{}).data}))}});T.forEach(["post","put","patch"],function(e){function n(r){return function(s,c,u){return this.request(In(u||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:c}))}}Ji.prototype[e]=n(),Ji.prototype[e+"Form"]=n(!0)});var Ao=Ji;var fv=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});let r=this;this.promise.then(a=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](a);r._listeners=null}),this.promise.then=a=>{let s,c=new Promise(u=>{r.subscribe(u),s=u}).then(a);return c.cancel=function(){r.unsubscribe(s)},c},e(function(s,c,u){r.reason||(r.reason=new nn(s,c,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){let e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new t(function(a){e=a}),cancel:e}}},e9=fv;function dv(t){return function(n){return t.apply(null,n)}}function mv(t){return T.isObject(t)&&t.isAxiosError===!0}var hv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(hv).forEach(([t,e])=>{hv[e]=t});var t9=hv;function n9(t){let e=new Ao(t),n=fo(Ao.prototype.request,e);return T.extend(n,Ao.prototype,e,{allOwnKeys:!0}),T.extend(n,e,null,{allOwnKeys:!0}),n.create=function(a){return n9(In(t,a))},n}var rt=n9(Zi);rt.Axios=Ao;rt.CanceledError=nn;rt.CancelToken=e9;rt.isCancel=xo;rt.VERSION=Da;rt.toFormData=Zr;rt.AxiosError=W;rt.Cancel=rt.CanceledError;rt.all=function(e){return Promise.all(e)};rt.spread=dv;rt.isAxiosError=mv;rt.mergeConfig=In;rt.AxiosHeaders=Ge;rt.formToJSON=t=>Op(T.isHTMLForm(t)?new FormData(t):t);rt.getAdapter=jp.getAdapter;rt.HttpStatusCode=t9;rt.default=rt;var Bp=rt;var{Axios:ZQ,AxiosError:WQ,CanceledError:VQ,isCancel:GQ,CancelToken:KQ,VERSION:JQ,all:XQ,Cancel:YQ,isAxiosError:QQ,spread:eee,toFormData:tee,AxiosHeaders:nee,HttpStatusCode:ree,formToJSON:aee,getAdapter:iee,mergeConfig:see}=Bp;var r9=Fe(require("os")),vv=Fe(require("path"));try{require("dotenv").config({path:vv.default.join(__dirname,"../.env")})}catch{}var a9="CN",Ua="apifox",i9=Ua?.toUpperCase(),Dp=Ua.charAt(0).toUpperCase()+Ua.slice(1),y$=process.env.MCP_S_DATA_LOCATION||r9.default.homedir(),To=vv.default.join(y$,`.${Ua}-mcp-server`);var qn=Fe(require("fs/promises")),jn=Fe(require("path"));var Oo=Fe(gv());function s9(t){if(!t||typeof t!="object")return t;let{components:e,...n}=t;if(!e)return t;let r={},a=c=>{let u=[],l=f=>{if(!(!f||typeof f!="object")){if(Array.isArray(f))for(let d of f)l(d);else for(let d in f)if(Object.prototype.hasOwnProperty.call(f,d)){if(d==="$ref"){let h=f[d];if(typeof h=="string"){h.startsWith("#/components/")&&u.push(h.substring(13));continue}}l(f[d])}}};return l(c),u},s=c=>{a(c)?.forEach(l=>{if((0,Oo.get)(r,l.replace(/\//g,".")))return;let f=(0,Oo.get)(e,l.replace(/\//g,"."));f&&((0,Oo.set)(r,l.replace(/\//g,"."),f),s(f))})};return s(n),{components:{...r,securitySchemes:e.securitySchemes},...n}}function Mp(t){return t.replace(/\//g,"_")}var Co=Fe(gv());async function w$(t,e,n=300){await qn.default.mkdir(jn.default.join(t,"paths"),{recursive:!0});let r=e.paths||{},a=Object.keys(r),s={};for(let u of a){let f=`./paths/${Mp(u)}.json`,d=jn.default.resolve(t,f),h=r[u]||{};await qn.default.writeFile(d,JSON.stringify(h,null,2));let v=Object.keys(h).reduce((w,y)=>(w[y]={summary:h[y].summary},w),{});s[u]={$ref:f,...v}}let c={page:Math.ceil(a.length/n),pageSize:n,otherPages:{}};if(c.page>1){await qn.default.mkdir(jn.default.join(t,"pages"),{recursive:!0});let u={...s},l=(0,Co.chunk)(a,n);for(let[f,d]of l.entries()){if(f===0){s=(0,Co.pick)(u,d);continue}let h=f+1,v=jn.default.resolve(t,`pages/${h}.json`),w=(0,Co.pick)(u,d);await qn.default.writeFile(v,JSON.stringify(w,null,2)),c.otherPages[h]={$ref:`./pages/${h}.json`}}s["x-pagination"]=c}return s}async function Up(t,e,n){let r=e.components?.[n];if(!r)return;let a=jn.default.join(t,"components",n);await qn.default.mkdir(a,{recursive:!0});let s=Object.keys(r),c={};for(let f of s){let d=`./components/${n}/${f}.json`,h=jn.default.resolve(t,d),v=r[f]||{};await qn.default.writeFile(h,JSON.stringify(v,null,2)),c[f]={$ref:d}}let u=`./components/${n}/index.json`,l=jn.default.resolve(t,u);return await qn.default.writeFile(l,JSON.stringify(c,null,2)),u}async function o9(t,e,n={}){let r=jn.default.join(To,`project-${t}`);await qn.default.mkdir(r,{recursive:!0});let a=s9(e);await qn.default.writeFile(jn.default.join(r,"original.json"),JSON.stringify(e,null,2));let s=await w$(r,a,n.pageSize),c=await Up(r,a,"schemas"),u=await Up(r,a,"securitySchemes"),l=await Up(r,a,"requestBodies"),f=await Up(r,a,"responses");return a.info={...a.info,"x-download-time":new Date().toISOString()},a.paths=s,a.components=a.components||{},c&&(a.components.schemas={$ref:c}),u&&(a.components.securitySchemes={$ref:u}),l&&(a.components.requestBodies={$ref:l}),f&&(a.components.responses={$ref:f}),a.tags=void 0,await qn.default.writeFile(jn.default.join(r,"index.json"),JSON.stringify(a,null,2)),a}var A9=Fe(require("os"));var ie=t=>typeof t=="string",Po=()=>{let t,e,n=new Promise((r,a)=>{t=r,e=a});return n.resolve=t,n.reject=e,n},c9=t=>t==null?"":""+t,_$=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},S$=/###/g,u9=t=>t&&t.indexOf("###")>-1?t.replace(S$,"."):t,p9=t=>!t||ie(t),Lo=(t,e,n)=>{let r=ie(e)?e.split("."):e,a=0;for(;a<r.length-1;){if(p9(t))return{};let s=u9(r[a]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++a}return p9(t)?{}:{obj:t,k:u9(r[a])}},l9=(t,e,n)=>{let{obj:r,k:a}=Lo(t,e,Object);if(r!==void 0||e.length===1){r[a]=n;return}let s=e[e.length-1],c=e.slice(0,e.length-1),u=Lo(t,c,Object);for(;u.obj===void 0&&c.length;)s=`${c[c.length-1]}.${s}`,c=c.slice(0,c.length-1),u=Lo(t,c,Object),u?.obj&&typeof u.obj[`${u.k}.${s}`]<"u"&&(u.obj=void 0);u.obj[`${u.k}.${s}`]=n},E$=(t,e,n,r)=>{let{obj:a,k:s}=Lo(t,e,Object);a[s]=a[s]||[],a[s].push(n)},$p=(t,e)=>{let{obj:n,k:r}=Lo(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},k$=(t,e,n)=>{let r=$p(t,n);return r!==void 0?r:$p(e,n)},b9=(t,e,n)=>{for(let r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?ie(t[r])||t[r]instanceof String||ie(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):b9(t[r],e[r],n):t[r]=e[r]);return t},Yi=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),A$={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},T$=t=>ie(t)?t.replace(/[&<>"'\/]/g,e=>A$[e]):t,bv=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(n!==void 0)return n;let r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}},R$=[" ",",","?","!",";"],O$=new bv(20),C$=(t,e,n)=>{e=e||"",n=n||"";let r=R$.filter(c=>e.indexOf(c)<0&&n.indexOf(c)<0);if(r.length===0)return!0;let a=O$.getRegExp(`(${r.map(c=>c==="?"?"\\?":c).join("|")})`),s=!a.test(t);if(!s){let c=t.indexOf(n);c>0&&!a.test(t.substring(0,c))&&(s=!0)}return s},yv=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;let r=e.split(n),a=t;for(let s=0;s<r.length;){if(!a||typeof a!="object")return;let c,u="";for(let l=s;l<r.length;++l)if(l!==s&&(u+=n),u+=r[l],c=a[u],c!==void 0){if(["string","number","boolean"].indexOf(typeof c)>-1&&l<r.length-1)continue;s+=l-s+1;break}a=c}return a},Hp=t=>t?.replace("_","-"),P$={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}},wv=class t{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||P$,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,a){return a&&!this.debug?null:(ie(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new t(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new t(this.logger,e)}},Qn=new wv,es=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);let a=this.observers[r].get(n)||0;this.observers[r].set(n,a+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(c=>{let[u,l]=c;for(let f=0;f<l;f++)u(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(c=>{let[u,l]=c;for(let f=0;f<l;f++)u.apply(u,[e,...r])})}},Zp=class extends es{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){let n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,c=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,u;e.indexOf(".")>-1?u=e.split("."):(u=[e,n],r&&(Array.isArray(r)?u.push(...r):ie(r)&&s?u.push(...r.split(s)):u.push(r)));let l=$p(this.data,u);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=u[0],n=u[1],r=u.slice(2).join(".")),l||!c||!ie(r)?l:yv(this.data?.[e]?.[n],r,s)}addResource(e,n,r,a){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},c=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,u=[e,n];r&&(u=u.concat(c?r.split(c):r)),e.indexOf(".")>-1&&(u=e.split("."),a=n,n=u[1]),this.addNamespaces(n),l9(this.data,u,a),s.silent||this.emit("added",e,n,r,a)}addResources(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(let s in r)(ie(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});a.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,a,s){let c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},u=[e,n];e.indexOf(".")>-1&&(u=e.split("."),a=r,r=n,n=u[1]),this.addNamespaces(n);let l=$p(this.data,u)||{};c.skipCopy||(r=JSON.parse(JSON.stringify(r))),a?b9(l,r,s):l={...l,...r},l9(this.data,u,l),c.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(a=>n[a]&&Object.keys(n[a]).length>0)}toJSON(){return this.data}},y9={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,a){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,a)??e}),e}},f9={},d9=t=>!ie(t)&&typeof t!="boolean"&&typeof t!="number",Wp=class t extends es{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),_$(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Qn.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};return e==null?!1:this.resolve(e,n)?.res!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");let a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,s=n.ns||this.options.defaultNS||[],c=r&&e.indexOf(r)>-1,u=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!C$(e,r,a);if(c&&!u){let l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:ie(s)?[s]:s};let f=e.split(r);(r!==a||r===a&&this.options.ns.indexOf(f[0])>-1)&&(s=f.shift()),e=f.join(a)}return{key:e,namespaces:ie(s)?[s]:s}}translate(e,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);let a=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:c,namespaces:u}=this.extractFromKey(e[e.length-1],n),l=u[u.length-1],f=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode"){if(d){let Ue=n.nsSeparator||this.options.nsSeparator;return a?{res:`${l}${Ue}${c}`,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${Ue}${c}`}return a?{res:c,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:c}let h=this.resolve(e,n),v=h?.res,w=h?.usedKey||c,y=h?.exactUsedKey||c,E=["[object Number]","[object Function]","[object RegExp]"],k=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,L=!this.i18nFormat||this.i18nFormat.handleAsObject,F=n.count!==void 0&&!ie(n.count),I=t.hasDefaultValue(n),D=F?this.pluralResolver.getSuffix(f,n.count,n):"",z=n.ordinal&&F?this.pluralResolver.getSuffix(f,n.count,{ordinal:!1}):"",X=F&&!n.ordinal&&n.count===0,$=X&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${D}`]||n[`defaultValue${z}`]||n.defaultValue,he=v;L&&!v&&I&&(he=$);let Ee=d9(he),Le=Object.prototype.toString.apply(he);if(L&&he&&Ee&&E.indexOf(Le)<0&&!(ie(k)&&Array.isArray(he))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let Ue=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,he,{...n,ns:u}):`key '${c} (${this.language})' returned an object instead of string.`;return a?(h.res=Ue,h.usedParams=this.getUsedParamsDetails(n),h):Ue}if(s){let Ue=Array.isArray(he),je=Ue?[]:{},at=Ue?y:w;for(let xe in he)if(Object.prototype.hasOwnProperty.call(he,xe)){let Ae=`${at}${s}${xe}`;I&&!v?je[xe]=this.translate(Ae,{...n,defaultValue:d9($)?$[xe]:void 0,joinArrays:!1,ns:u}):je[xe]=this.translate(Ae,{...n,joinArrays:!1,ns:u}),je[xe]===Ae&&(je[xe]=he[xe])}v=je}}else if(L&&ie(k)&&Array.isArray(v))v=v.join(k),v&&(v=this.extendTranslation(v,e,n,r));else{let Ue=!1,je=!1;!this.isValidLookup(v)&&I&&(Ue=!0,v=$),this.isValidLookup(v)||(je=!0,v=c);let xe=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&je?void 0:v,Ae=I&&$!==v&&this.options.updateMissing;if(je||Ue||Ae){if(this.logger.log(Ae?"updateKey":"missingKey",f,l,c,Ae?$:v),s){let se=this.resolve(c,{...n,keySeparator:!1});se&&se.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let He=[],Q=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Q&&Q[0])for(let se=0;se<Q.length;se++)He.push(Q[se]);else this.options.saveMissingTo==="all"?He=this.languageUtils.toResolveHierarchy(n.lng||this.language):He.push(n.lng||this.language);let Y=(se,Qe,ze)=>{let $t=I&&ze!==v?ze:xe;this.options.missingKeyHandler?this.options.missingKeyHandler(se,l,Qe,$t,Ae,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(se,l,Qe,$t,Ae,n),this.emit("missingKey",se,l,Qe,v)};this.options.saveMissing&&(this.options.saveMissingPlurals&&F?He.forEach(se=>{let Qe=this.pluralResolver.getSuffixes(se,n);X&&n[`defaultValue${this.options.pluralSeparator}zero`]&&Qe.indexOf(`${this.options.pluralSeparator}zero`)<0&&Qe.push(`${this.options.pluralSeparator}zero`),Qe.forEach(ze=>{Y([se],c+ze,n[`defaultValue${ze}`]||$)})}):Y(He,c,$))}v=this.extendTranslation(v,e,n,h,r),je&&v===c&&this.options.appendNamespaceToMissingKey&&(v=`${l}:${c}`),(je||Ue)&&this.options.parseMissingKeyHandler&&(v=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${c}`:c,Ue?v:void 0))}return a?(h.res=v,h.usedParams=this.getUsedParamsDetails(n),h):v}extendTranslation(e,n,r,a,s){var c=this;if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});let f=ie(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables),d;if(f){let v=e.match(this.interpolator.nestingRegexp);d=v&&v.length}let h=r.replace&&!ie(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(h={...this.options.interpolation.defaultVariables,...h}),e=this.interpolator.interpolate(e,h,r.lng||this.language||a.usedLng,r),f){let v=e.match(this.interpolator.nestingRegexp),w=v&&v.length;d<w&&(r.nest=!1)}!r.lng&&a&&a.res&&(r.lng=this.language||a.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var v=arguments.length,w=new Array(v),y=0;y<v;y++)w[y]=arguments[y];return s?.[0]===w[0]&&!r.context?(c.logger.warn(`It seems you are nesting recursively key: ${w[0]} in key: ${n[0]}`),null):c.translate(...w,n)},r)),r.interpolation&&this.interpolator.reset()}let u=r.postProcess||this.options.postProcess,l=ie(u)?[u]:u;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=y9.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,a,s,c,u;return ie(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;let f=this.extractFromKey(l,n),d=f.key;a=d;let h=f.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));let v=n.count!==void 0&&!ie(n.count),w=v&&!n.ordinal&&n.count===0,y=n.context!==void 0&&(ie(n.context)||typeof n.context=="number")&&n.context!=="",E=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(k=>{this.isValidLookup(r)||(u=k,!f9[`${E[0]}-${k}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(u)&&(f9[`${E[0]}-${k}`]=!0,this.logger.warn(`key "${a}" for languages "${E.join(", ")}" won't get resolved as namespace "${u}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),E.forEach(L=>{if(this.isValidLookup(r))return;c=L;let F=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(F,d,L,k,n);else{let D;v&&(D=this.pluralResolver.getSuffix(L,n.count,n));let z=`${this.options.pluralSeparator}zero`,X=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(v&&(F.push(d+D),n.ordinal&&D.indexOf(X)===0&&F.push(d+D.replace(X,this.options.pluralSeparator)),w&&F.push(d+z)),y){let $=`${d}${this.options.contextSeparator}${n.context}`;F.push($),v&&(F.push($+D),n.ordinal&&D.indexOf(X)===0&&F.push($+D.replace(X,this.options.pluralSeparator)),w&&F.push($+z))}}let I;for(;I=F.pop();)this.isValidLookup(r)||(s=I,r=this.getResource(L,k,I,n))}))})}),{res:r,usedKey:a,exactUsedKey:s,usedLng:c,usedNS:u}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,a):this.resourceStore.getResource(e,n,r,a)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!ie(e.replace),a=r?e.replace:e;if(r&&typeof e.count<"u"&&(a.count=e.count),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!r){a={...a};for(let s of n)delete a[s]}return a}static hasDefaultValue(e){let n="defaultValue";for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}},Vp=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Qn.create("languageUtils")}getScriptPartFromCode(e){if(e=Hp(e),!e||e.indexOf("-")<0)return null;let n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Hp(e),!e||e.indexOf("-")<0)return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(ie(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;let a=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(a))&&(n=a)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;let a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(s=>{if(s===a)return s;if(!(s.indexOf("-")<0&&a.indexOf("-")<0)&&(s.indexOf("-")>0&&a.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===a||s.indexOf(a)===0&&a.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),ie(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){let r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),a=[],s=c=>{c&&(this.isSupportedCode(c)?a.push(c):this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`))};return ie(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):ie(e)&&s(this.formatLanguageCode(e)),r.forEach(c=>{a.indexOf(c)<0&&s(this.formatLanguageCode(c))}),a}},m9={zero:0,one:1,two:2,few:3,many:4,other:5},h9={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},_v=class{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=Qn.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=Hp(e==="dev"?"en":e),a=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:a});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let c;try{c=new Intl.PluralRules(r,{type:a})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),h9;if(!e.match(/-|_/))return h9;let l=this.languageUtils.getLanguagePartFromCode(e);c=this.getRule(l,n)}return this.pluralRulesCache[s]=c,c}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(a=>`${n}${a}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((a,s)=>m9[a]-m9[s]).map(a=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=this.getRule(e,r);return a?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${a.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}},v9=function(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=k$(t,e,n);return!s&&a&&ie(n)&&(s=yv(t,n,r),s===void 0&&(s=yv(e,n,r))),s},xv=t=>t.replace(/\$/g,"$$$$"),Sv=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Qn.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});let{escape:n,escapeValue:r,useRawValueToEscape:a,prefix:s,prefixEscaped:c,suffix:u,suffixEscaped:l,formatSeparator:f,unescapeSuffix:d,unescapePrefix:h,nestingPrefix:v,nestingPrefixEscaped:w,nestingSuffix:y,nestingSuffixEscaped:E,nestingOptionsSeparator:k,maxReplaces:L,alwaysFormat:F}=e.interpolation;this.escape=n!==void 0?n:T$,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=a!==void 0?a:!1,this.prefix=s?Yi(s):c||"{{",this.suffix=u?Yi(u):l||"}}",this.formatSeparator=f||",",this.unescapePrefix=d?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=v?Yi(v):w||Yi("$t("),this.nestingSuffix=y?Yi(y):E||Yi(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=L||1e3,this.alwaysFormat=F!==void 0?F:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,n,r,a){let s,c,u,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},f=w=>{if(w.indexOf(this.formatSeparator)<0){let L=v9(n,l,w,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(L,void 0,r,{...a,...n,interpolationkey:w}):L}let y=w.split(this.formatSeparator),E=y.shift().trim(),k=y.join(this.formatSeparator).trim();return this.format(v9(n,l,E,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...a,...n,interpolationkey:E})};this.resetRegExp();let d=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=a?.interpolation?.skipOnVariables!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:w=>xv(w)},{regex:this.regexp,safeValue:w=>this.escapeValue?xv(this.escape(w)):xv(w)}].forEach(w=>{for(u=0;s=w.regex.exec(e);){let y=s[1].trim();if(c=f(y),c===void 0)if(typeof d=="function"){let k=d(e,s,a);c=ie(k)?k:""}else if(a&&Object.prototype.hasOwnProperty.call(a,y))c="";else if(h){c=s[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${e}`),c="";else!ie(c)&&!this.useRawValueToEscape&&(c=c9(c));let E=w.safeValue(c);if(e=e.replace(s[0],E),h?(w.regex.lastIndex+=c.length,w.regex.lastIndex-=s[0].length):w.regex.lastIndex=0,u++,u>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a,s,c,u=(l,f)=>{let d=this.nestingOptionsSeparator;if(l.indexOf(d)<0)return l;let h=l.split(new RegExp(`${d}[ ]*{`)),v=`{${h[1]}`;l=h[0],v=this.interpolate(v,c);let w=v.match(/'/g),y=v.match(/"/g);((w?.length??0)%2===0&&!y||y.length%2!==0)&&(v=v.replace(/'/g,'"'));try{c=JSON.parse(v),f&&(c={...f,...c})}catch(E){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,E),`${l}${d}${v}`}return c.defaultValue&&c.defaultValue.indexOf(this.prefix)>-1&&delete c.defaultValue,l};for(;a=this.nestingRegexp.exec(e);){let l=[];c={...r},c=c.replace&&!ie(c.replace)?c.replace:c,c.applyPostProcessor=!1,delete c.defaultValue;let f=!1;if(a[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(a[1])){let d=a[1].split(this.formatSeparator).map(h=>h.trim());a[1]=d.shift(),l=d,f=!0}if(s=n(u.call(this,a[1].trim(),c),c),s&&a[0]===e&&!ie(s))return s;ie(s)||(s=c9(s)),s||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),s=""),f&&(s=l.reduce((d,h)=>this.format(d,h,r.lng,{...r,interpolationkey:a[1].trim()}),s.trim())),e=e.replace(a[0],s),this.regexp.lastIndex=0}return e}},L$=t=>{let e=t.toLowerCase().trim(),n={};if(t.indexOf("(")>-1){let r=t.split("(");e=r[0].toLowerCase().trim();let a=r[1].substring(0,r[1].length-1);e==="currency"&&a.indexOf(":")<0?n.currency||(n.currency=a.trim()):e==="relativetime"&&a.indexOf(":")<0?n.range||(n.range=a.trim()):a.split(";").forEach(c=>{if(c){let[u,...l]=c.split(":"),f=l.join(":").trim().replace(/^'+|'+$/g,""),d=u.trim();n[d]||(n[d]=f),f==="false"&&(n[d]=!1),f==="true"&&(n[d]=!0),isNaN(f)||(n[d]=parseInt(f,10))}})}return{formatName:e,formatOptions:n}},Qi=t=>{let e={};return(n,r,a)=>{let s=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(s={...s,[a.interpolationkey]:void 0});let c=r+JSON.stringify(s),u=e[c];return u||(u=t(Hp(r),a),e[c]=u),u(n)}},Ev=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Qn.create("formatter"),this.options=e,this.formats={number:Qi((n,r)=>{let a=new Intl.NumberFormat(n,{...r});return s=>a.format(s)}),currency:Qi((n,r)=>{let a=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>a.format(s)}),datetime:Qi((n,r)=>{let a=new Intl.DateTimeFormat(n,{...r});return s=>a.format(s)}),relativetime:Qi((n,r)=>{let a=new Intl.RelativeTimeFormat(n,{...r});return s=>a.format(s,r.range||"day")}),list:Qi((n,r)=>{let a=new Intl.ListFormat(n,{...r});return s=>a.format(s)})},this.init(e)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Qi(n)}format(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(u=>u.indexOf(")")>-1)){let u=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,u)].join(this.formatSeparator)}return s.reduce((u,l)=>{let{formatName:f,formatOptions:d}=L$(l);if(this.formats[f]){let h=u;try{let v=a?.formatParams?.[a.interpolationkey]||{},w=v.locale||v.lng||a.locale||a.lng||r;h=this.formats[f](u,w,{...d,...a,...v})}catch(v){this.logger.warn(v)}return h}else this.logger.warn(`there was no format function for ${f}`);return u},e)}},I$=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)},kv=class extends es{constructor(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=a,this.logger=Qn.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,a.backend,a)}queueLoad(e,n,r,a){let s={},c={},u={},l={};return e.forEach(f=>{let d=!0;n.forEach(h=>{let v=`${f}|${h}`;!r.reload&&this.store.hasResourceBundle(f,h)?this.state[v]=2:this.state[v]<0||(this.state[v]===1?c[v]===void 0&&(c[v]=!0):(this.state[v]=1,d=!1,c[v]===void 0&&(c[v]=!0),s[v]===void 0&&(s[v]=!0),l[h]===void 0&&(l[h]=!0)))}),d||(u[f]=!0)}),(Object.keys(s).length||Object.keys(c).length)&&this.queue.push({pending:c,pendingCount:Object.keys(c).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(s),pending:Object.keys(c),toLoadLanguages:Object.keys(u),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){let a=e.split("|"),s=a[0],c=a[1];n&&this.emit("failedLoading",s,c,n),!n&&r&&this.store.addResourceBundle(s,c,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);let u={};this.queue.forEach(l=>{E$(l.loaded,[s],c),I$(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(f=>{u[f]||(u[f]={});let d=l.loaded[f];d.length&&d.forEach(h=>{u[f][h]===void 0&&(u[f][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",u),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r){let a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,c=arguments.length>5?arguments[5]:void 0;if(!e.length)return c(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:a,wait:s,callback:c});return}this.readingCalls++;let u=(f,d)=>{if(this.readingCalls--,this.waitingReads.length>0){let h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(f&&d&&a<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,a+1,s*2,c)},s);return}c(f,d)},l=this.backend[r].bind(this.backend);if(l.length===2){try{let f=l(e,n);f&&typeof f.then=="function"?f.then(d=>u(null,d)).catch(u):u(null,f)}catch(f){u(f)}return}return l(e,n,u)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();ie(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ie(n)&&(n=[n]);let s=this.queueLoad(e,n,r,a);if(!s.toLoad.length)return s.pending.length||a(),null;s.toLoad.forEach(c=>{this.loadOne(c)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",r=e.split("|"),a=r[0],s=r[1];this.read(a,s,"read",void 0,void 0,(c,u)=>{c&&this.logger.warn(`${n}loading namespace ${s} for language ${a} failed`,c),!c&&u&&this.logger.log(`${n}loaded namespace ${s} for language ${a}`,u),this.loaded(e,c,u)})}saveMissing(e,n,r,a,s){let c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},u=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){let l={...c,isUpdate:s},f=this.backend.create.bind(this.backend);if(f.length<6)try{let d;f.length===5?d=f(e,n,r,a,l):d=f(e,n,r,a),d&&typeof d.then=="function"?d.then(h=>u(null,h)).catch(u):u(null,d)}catch(d){u(d)}else f(e,n,r,a,u,l)}!e||!e[0]||this.store.addResource(e[0],n,r,a)}}},g9=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),ie(t[1])&&(e.defaultValue=t[1]),ie(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){let n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),x9=t=>(ie(t.ns)&&(t.ns=[t.ns]),ie(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ie(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),zp=()=>{},q$=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})},Gp=class t extends es{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=x9(e),this.services={},this.logger=Qn,this.modules={external:[]},q$(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),n.defaultNS==null&&n.ns&&(ie(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));let a=g9();this.options={...a,...this.options,...x9(n)},this.options.interpolation={...a.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);let s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Qn.init(s(this.modules.logger),this.options):Qn.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=Ev;let h=new Vp(this.options);this.store=new Zp(this.options.resources,this.options);let v=this.services;v.logger=Qn,v.resourceStore=this.store,v.languageUtils=h,v.pluralResolver=new _v(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),d&&(!this.options.interpolation.format||this.options.interpolation.format===a.interpolation.format)&&(v.formatter=s(d),v.formatter.init(v,this.options),this.options.interpolation.format=v.formatter.format.bind(v.formatter)),v.interpolator=new Sv(this.options),v.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},v.backendConnector=new kv(s(this.modules.backend),v.resourceStore,v,this.options),v.backendConnector.on("*",function(w){for(var y=arguments.length,E=new Array(y>1?y-1:0),k=1;k<y;k++)E[k-1]=arguments[k];e.emit(w,...E)}),this.modules.languageDetector&&(v.languageDetector=s(this.modules.languageDetector),v.languageDetector.init&&v.languageDetector.init(v,this.options.detection,this.options)),this.modules.i18nFormat&&(v.i18nFormat=s(this.modules.i18nFormat),v.i18nFormat.init&&v.i18nFormat.init(this)),this.translator=new Wp(this.services,this.options),this.translator.on("*",function(w){for(var y=arguments.length,E=new Array(y>1?y-1:0),k=1;k<y;k++)E[k-1]=arguments[k];e.emit(w,...E)}),this.modules.external.forEach(w=>{w.init&&w.init(this)})}if(this.format=this.options.interpolation.format,r||(r=zp),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=function(){return e.store[d](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=function(){return e.store[d](...arguments),e}});let l=Po(),f=()=>{let d=(h,v)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(v),r(h,v)};if(this.languages&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?f():setTimeout(f,0),l}loadResources(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:zp,a=ie(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(a?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();let s=[],c=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(f=>{f!=="cimode"&&s.indexOf(f)<0&&s.push(f)})};a?c(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>c(l)),this.options.preload?.forEach?.(u=>c(u)),this.services.backendConnector.load(s,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(u)})}else r(null)}reloadResources(e,n,r){let a=Po();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=zp),this.services.backendConnector.reload(e,n,s=>{a.resolve(),r(s)}),a}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&y9.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let n=0;n<this.languages.length;n++){let r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;let a=Po();this.emit("languageChanging",e);let s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},c=(l,f)=>{f?(s(f),this.translator.changeLanguage(f),this.isLanguageChangingTo=void 0,this.emit("languageChanged",f),this.logger.log("languageChanged",f)):this.isLanguageChangingTo=void 0,a.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},u=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);let f=ie(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);f&&(this.language||s(f),this.translator.language||this.translator.changeLanguage(f),this.services.languageDetector?.cacheUserLanguage?.(f)),this.loadResources(f,d=>{c(d,f)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?u(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(u):this.services.languageDetector.detect(u):u(e),a}getFixedT(e,n,r){var a=this;let s=function(c,u){let l;if(typeof u!="object"){for(var f=arguments.length,d=new Array(f>2?f-2:0),h=2;h<f;h++)d[h-2]=arguments[h];l=a.options.overloadTranslationOptionHandler([c,u].concat(d))}else l={...u};l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||s.keyPrefix);let v=a.options.keySeparator||".",w;return l.keyPrefix&&Array.isArray(c)?w=c.map(y=>`${l.keyPrefix}${v}${y}`):w=l.keyPrefix?`${l.keyPrefix}${v}${c}`:c,a.t(w,l)};return ie(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.translator?.translate(...n)}exists(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.translator?.exists(...n)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let r=n.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;let c=(u,l)=>{let f=this.services.backendConnector.state[`${u}|${l}`];return f===-1||f===0||f===2};if(n.precheck){let u=n.precheck(this,c);if(u!==void 0)return u}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||c(r,e)&&(!a||c(s,e)))}loadNamespaces(e,n){let r=Po();return this.options.ns?(ie(e)&&(e=[e]),e.forEach(a=>{this.options.ns.indexOf(a)<0&&this.options.ns.push(a)}),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){let r=Po();ie(e)&&(e=[e]);let a=this.options.preload||[],s=e.filter(c=>a.indexOf(c)<0&&this.services.languageUtils.isSupportedCode(c));return s.length?(this.options.preload=a.concat(s),this.loadResources(c=>{r.resolve(),n&&n(c)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";let n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new Vp(g9());return n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new t(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:zp,r=e.forkResourceStore;r&&delete e.forkResourceStore;let a={...this.options,...e,isClone:!0},s=new t(a);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(u=>{s[u]=this[u]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){let u=Object.keys(this.store.data).reduce((l,f)=>(l[f]={...this.store.data[f]},Object.keys(l[f]).reduce((d,h)=>(d[h]={...l[f][h]},d),{})),{});s.store=new Zp(u,a),s.services.resourceStore=s.store}return s.translator=new Wp(s.services,a),s.translator.on("*",function(u){for(var l=arguments.length,f=new Array(l>1?l-1:0),d=1;d<l;d++)f[d-1]=arguments[d];s.emit(u,...f)}),s.init(a,n),s.translator.options=a,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},Ct=Gp.createInstance();Ct.createInstance=Gp.createInstance;var hee=Ct.createInstance,vee=Ct.dir,w9=Ct.init,gee=Ct.loadResources,xee=Ct.reloadResources,bee=Ct.use,yee=Ct.changeLanguage,wee=Ct.getFixedT,Io=Ct.t,_ee=Ct.exists,See=Ct.setDefaultNamespace,Eee=Ct.hasLoadedNamespace,kee=Ct.loadNamespaces,Aee=Ct.loadLanguages;var _9={translation:{"tool.read_project_oas.desc":"Read the project's OpenAPI Spec file","tool.read_project_oas_ref_resources.desc":"Read the file content of $ref in the project OpenAPI Spec file. You can get the content of multiple files at the same time","tool.read_project_oas_ref_resources.params.path.desc":'The value of $ref in the OpenAPI Spec file can retrieve the contents of multiple files at the same time, such as: ["./paths/_get_pet.json", "./paths/_get_order.json"]',"tool.refresh_project_oas.desc":"Re-download the latest OpenAPI Spec file from the server"}};var S9={translation:{"tool.read_project_oas.desc":"\u8BFB\u53D6\u9879\u76EE\u7684 OpenAPI Spec \u6587\u4EF6","tool.read_project_oas_ref_resources.desc":"\u8BFB\u53D6\u9879\u76EE OpenAPI Spec \u6587\u4EF6\u5185 $ref \u7684\u6587\u4EF6\u5185\u5BB9\uFF0C\u53EF\u4EE5\u540C\u65F6\u83B7\u53D6\u591A\u4E2A\u6587\u4EF6\u5185\u5BB9","tool.read_project_oas_ref_resources.params.path.desc":'OpenAPI Spec \u6587\u4EF6\u5185 $ref \u7684\u503C\uFF0C\u53EF\u4EE5\u540C\u65F6\u83B7\u53D6\u591A\u4E2A\u6587\u4EF6\u5185\u5BB9\uFF0C\u5982\uFF1A["./paths/_get_pet.json", "./paths/_get_order.json"]',"tool.refresh_project_oas.desc":"\u4ECE\u670D\u52A1\u5668\u91CD\u65B0\u4E0B\u8F7D\u6700\u65B0\u7684 OpenAPI Spec \u6587\u4EF6"}};var T9=Number.MAX_SAFE_INTEGER,R9="0.0.7",O9=a9==="CN"?"zh":"en",$a=(0,k9.default)(process.argv.slice(2)),C9=$a.token||process.env[`${i9}_ACCESS_TOKEN`],Jp=$a.project,N$=$a["api-page-size"]||T9.toString(),F$=$a["api-version"]||"2024-03-28",B$=$a.lang||O9,Av=$a.sse,D$=$a[`${Ua}-api-base-url`]||`https://api.${Ua}.com`,P9=!1;(async()=>{try{w9({lng:B$,fallbackLng:O9,resources:{en:_9,zh:S9}})}catch(t){console.log(t)}})();Jp||(console.error("Please provide a project ID"),process.exit(1));C9||(console.error("Please provide a token"),process.exit(1));var ts=new nu({name:`${Dp} MCP Server`,version:R9}),Ov=za.default.join(To,`project-${Jp}`),Tv=za.default.join(Ov,"index.json");function M$(){let t=new au;ts.connect(t)}function U$(t){let e=t,n="127.0.0.1";if(t.includes(":")){let[c,u]=t.split(":");n=c||"",e=u||""}let r=parseInt(e);isNaN(r)&&(r=3001);let a=(0,E9.default)(),s;a.get("/sse",async(c,u)=>{s=new _u("/messages",u),await ts.connect(s)}),a.post("/messages",async(c,u)=>{await s.handlePostMessage(c,u)}),a.listen(r,n)}function z$(){ts.tool("read_project_oas",Io("tool.read_project_oas.desc"),{},async()=>{try{return{content:[{type:"text",text:await Xp(Tv)}]}}catch(t){try{return await Kp.default.access(Tv),{content:[{type:"text",text:String(t)}]}}catch{return{content:[{type:"text",text:await Rv()}]}}}}),ts.tool("read_project_oas_ref_resources",Io("tool.read_project_oas_ref_resources.desc"),{path:_.array(_.string()).describe(Io("tool.read_project_oas_ref_resources.params.path.desc"))},async({path:t})=>{try{await Kp.default.writeFile(za.default.join(A9.default.homedir(),"mcp.log"),JSON.stringify({path:t}),"utf-8");let e=Array.isArray(t)?t:[t],n={};for(let r of e){let a=await Xp(za.default.resolve(Ov,r));n[r]=a}return{content:[{type:"text",text:JSON.stringify(n)}]}}catch{return{content:[{type:"text",text:"API definition reference file not found, maybe it is a broken link, please download the latest API definition from the server."}]}}}),ts.tool("refresh_project_oas",Io("tool.refresh_project_oas.desc"),{},async()=>({content:[{type:"text",text:await Rv()}]}))}async function $$(){P9&&await H$(),z$(),typeof Av=="string"&&Av?U$(Av):M$()}$$();async function Xp(t){return await Kp.default.readFile(za.default.resolve(To,t),"utf8")}async function Rv(){let t=`/api/v1/projects/${Jp}/export-openapi`,e=await Bp.post(D$+t,{scope:{type:"ALL"}},{headers:{[`X-${Dp}-Version`]:F$,Authorization:`Bearer ${C9}`,"User-Agent":`${Dp}-MCP-Server/${R9}`}}),n=parseInt(N$);isNaN(n)&&(n=T9);let r=await o9(Jp,e.data,{pageSize:n});return P9&&L9(r),JSON.stringify(r)}async function L9(t){for(let e of Object.keys(t?.paths||{}))for(let n of Object.keys(t?.paths?.[e]||{}))((r,a)=>{if(a==="$ref")return;let s=Mp(r);try{ts.tool(`${a}_${s}`,t.paths?.[r]?.[a]?.summary||"",{},async()=>({content:[{type:"text",text:await Xp(za.default.join(Ov,"paths",`${s}.json`))}]}))}catch(c){console.log(c)}})(e,n)}async function H$(){try{let t=await Xp(Tv),e=JSON.parse(t);L9(e)}catch(t){console.log(t),Rv()}}
|
|
96
96
|
/*! Bundled license information:
|
|
97
97
|
|
|
98
98
|
bytes/index.js:
|