@fern-api/go-dynamic-snippets 0.0.11 → 0.0.12
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/cjs/DynamicSnippetsGenerator.cjs +9 -9
- package/cjs/DynamicSnippetsGenerator.d.cts +1 -1
- package/cjs/{DynamicSnippetsGeneratorContext-DuDerGxa.d.cts → DynamicSnippetsGeneratorContext-f4OAff1R.d.cts} +5 -1
- package/cjs/EndpointSnippetGenerator.cjs +6 -6
- package/cjs/EndpointSnippetGenerator.d.cts +3 -1
- package/cjs/Result.d.cts +1 -1
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +5 -5
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +1 -1
- package/cjs/context/DynamicTypeInstantiationMapper.cjs +5 -5
- package/cjs/context/DynamicTypeInstantiationMapper.d.cts +1 -1
- package/cjs/context/DynamicTypeMapper.d.cts +1 -1
- package/cjs/context/FilePropertyMapper.d.cts +1 -1
- package/cjs/index.cjs +9 -9
- package/cjs/index.d.cts +1 -1
- package/esm/DynamicSnippetsGenerator.d.ts +1 -1
- package/esm/DynamicSnippetsGenerator.js +1 -1
- package/esm/{DynamicSnippetsGeneratorContext-DKWsHJSo.d.ts → DynamicSnippetsGeneratorContext-Dyk9qWMy.d.ts} +5 -1
- package/esm/EndpointSnippetGenerator.d.ts +3 -1
- package/esm/EndpointSnippetGenerator.js +1 -1
- package/esm/Result.d.ts +1 -1
- package/esm/chunk-575DWQWD.js +1 -0
- package/esm/chunk-DMDZDIA7.js +1 -0
- package/esm/{chunk-775WBLQ5.js → chunk-HBFOF5YT.js} +1 -1
- package/esm/chunk-M3DYFCFN.js +1 -0
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +1 -1
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
- package/esm/context/DynamicTypeInstantiationMapper.d.ts +1 -1
- package/esm/context/DynamicTypeInstantiationMapper.js +1 -1
- package/esm/context/DynamicTypeMapper.d.ts +1 -1
- package/esm/context/FilePropertyMapper.d.ts +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/package.json +2 -2
- package/esm/chunk-4PKXKUYU.js +0 -1
- package/esm/chunk-5XUC5IOB.js +0 -1
- package/esm/chunk-6JCPJA27.js +0 -1
- package/esm/chunk-BC35GX6S.js +0 -1
- package/esm/chunk-COBOWL3P.js +0 -1
- package/esm/chunk-I3J7ADQS.js +0 -1
- package/esm/chunk-IQODEXPX.js +0 -1
- package/esm/chunk-KJOW5AZT.js +0 -1
- package/esm/chunk-SUV3YIZ5.js +0 -1
- package/esm/chunk-UVYC4FWB.js +0 -1
- package/esm/chunk-VAYOWHUI.js +0 -19
- package/esm/chunk-ZQRLKIRW.js +0 -1
- package/esm/chunk-ZXKMRXFM.js +0 -1
- package/esm/chunk-ZYGZ4VN4.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, AbstractFormatter } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
-
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-
|
|
2
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-f4OAff1R.cjs';
|
|
3
3
|
import { dynamic } from '@fern-fern/ir-sdk/api';
|
|
4
4
|
import '@fern-api/go-ast';
|
|
5
5
|
import './TypeInstance.cjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec } from '@fern-api/browser-compatible-base-generator';
|
|
2
2
|
import { go, BaseGoCustomConfigSchema } from '@fern-api/go-ast';
|
|
3
|
-
import { dynamic, TypeId, Name, FernFilepath } from '@fern-fern/ir-sdk/api';
|
|
3
|
+
import { dynamic, TypeId, Name, FernFilepath, EnvironmentId } from '@fern-fern/ir-sdk/api';
|
|
4
4
|
import { TypeInstance } from './TypeInstance.cjs';
|
|
5
5
|
import { DiscriminatedUnionTypeInstance } from './DiscriminatedUnionTypeInstance.cjs';
|
|
6
6
|
import { ErrorReporter } from './context/ErrorReporter.cjs';
|
|
@@ -135,7 +135,11 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
135
135
|
getGoTypeReferenceFromDeclaration({ declaration }: {
|
|
136
136
|
declaration: dynamic.Declaration;
|
|
137
137
|
}): go.TypeReference;
|
|
138
|
+
getEnvironmentTypeReferenceFromID(environmentID: string): go.TypeReference | undefined;
|
|
139
|
+
isSingleEnvironmentID(environment: dynamic.EnvironmentValues): environment is EnvironmentId;
|
|
140
|
+
isMultiEnvironmentValues(environment: dynamic.EnvironmentValues): environment is dynamic.MultipleEnvironmentUrlValues;
|
|
138
141
|
newParameterNotRecognizedError(parameterName: string): Error;
|
|
142
|
+
private getEnvironmentTypeReference;
|
|
139
143
|
private isListTypeReference;
|
|
140
144
|
private parsedEndpointMatches;
|
|
141
145
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var ie=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var je=Object.prototype.hasOwnProperty;var et=(r,t,e)=>t in r?ie(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var me=(r,t)=>()=>(r&&(t=r(r=0)),t);var ve=(r,t)=>{for(var e in t)ie(r,e,{get:t[e],enumerable:!0})},tt=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Xe(t))!je.call(r,i)&&i!==e&&ie(r,i,{get:()=>t[i],enumerable:!(n=Ze(t,i))||n.enumerable});return r};var rt=r=>tt(ie({},"__esModule",{value:!0}),r);var h=(r,t,e)=>et(r,typeof t!="symbol"?t+"":t,e);function Ie(){throw new Error("setTimeout has not been defined")}function Re(){throw new Error("clearTimeout has not been defined")}function Pe(r){if(U===setTimeout)return setTimeout(r,0);if((U===Ie||!U)&&setTimeout)return U=setTimeout,setTimeout(r,0);try{return U(r,0)}catch(t){try{return U.call(null,r,0)}catch(e){return U.call(this,r,0)}}}function nt(r){if(L===clearTimeout)return clearTimeout(r);if((L===Re||!L)&&clearTimeout)return L=clearTimeout,clearTimeout(r);try{return L(r)}catch(t){try{return L.call(null,r)}catch(e){return L.call(this,r)}}}function it(){!Z||!Y||(Z=!1,Y.length?k=Y.concat(k):oe=-1,k.length&&Se())}function Se(){if(!Z){var r=Pe(it);Z=!0;for(var t=k.length;t;){for(Y=k,k=[];++oe<t;)Y&&Y[oe].run();oe=-1,t=k.length}Y=null,Z=!1,nt(r)}}function ot(r){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];k.push(new Ne(r,t)),k.length===1&&!Z&&Pe(Se)}function Ne(r,t){this.fun=r,this.array=t}function $(){}function vt(r){throw new Error("process.binding is not supported")}function Et(){return"/"}function It(r){throw new Error("process.chdir is not supported")}function Rt(){return 0}function St(r){var t=Pt.call(K)*.001,e=Math.floor(t),n=Math.floor(t%1*1e9);return r&&(e=e-r[0],n=n-r[1],n<0&&(e--,n+=1e9)),[e,n]}function Bt(){var r=new Date,t=r-Nt;return t/1e3}var U,L,k,Z,Y,oe,st,at,ut,pt,ct,ht,ft,lt,mt,dt,yt,wt,xt,gt,At,Tt,K,Pt,Nt,d,Ee,u=me(()=>{"use strict";U=Ie,L=Re;typeof globalThis.setTimeout=="function"&&(U=setTimeout);typeof globalThis.clearTimeout=="function"&&(L=clearTimeout);k=[],Z=!1,oe=-1;Ne.prototype.run=function(){this.fun.apply(null,this.array)};st="browser",at="browser",ut=!0,pt={},ct=[],ht="",ft={},lt={},mt={};dt=$,yt=$,wt=$,xt=$,gt=$,At=$,Tt=$;K=globalThis.performance||{},Pt=K.now||K.mozNow||K.msNow||K.oNow||K.webkitNow||function(){return new Date().getTime()};Nt=new Date;d={nextTick:ot,title:st,browser:ut,env:pt,argv:ct,version:ht,versions:ft,on:dt,addListener:yt,once:wt,off:xt,removeListener:gt,removeAllListeners:At,emit:Tt,binding:vt,cwd:Et,chdir:It,umask:Rt,hrtime:St,platform:at,release:lt,config:mt,uptime:Bt},Ee={};Object.keys(Ee).forEach(r=>{let t=r.split("."),e=d;for(let n=0;n<t.length;n++){let i=t[n];n===t.length-1?e[i]=Ee[r]:e=e[i]||(e[i]={})}})});function ke(){ye=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=r.length;t<e;++t)B[t]=r[t],R[r.charCodeAt(t)]=t;R[45]=62,R[95]=63}function _t(r){ye||ke();var t,e,n,i,o,s,c=r.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=r[c-2]==="="?2:r[c-1]==="="?1:0,s=new bt(c*3/4-o),n=o>0?c-4:c;var f=0;for(t=0,e=0;t<n;t+=4,e+=3)i=R[r.charCodeAt(t)]<<18|R[r.charCodeAt(t+1)]<<12|R[r.charCodeAt(t+2)]<<6|R[r.charCodeAt(t+3)],s[f++]=i>>16&255,s[f++]=i>>8&255,s[f++]=i&255;return o===2?(i=R[r.charCodeAt(t)]<<2|R[r.charCodeAt(t+1)]>>4,s[f++]=i&255):o===1&&(i=R[r.charCodeAt(t)]<<10|R[r.charCodeAt(t+1)]<<4|R[r.charCodeAt(t+2)]>>2,s[f++]=i>>8&255,s[f++]=i&255),s}function kt(r){return B[r>>18&63]+B[r>>12&63]+B[r>>6&63]+B[r&63]}function Ct(r,t,e){for(var n,i=[],o=t;o<e;o+=3)n=(r[o]<<16)+(r[o+1]<<8)+r[o+2],i.push(kt(n));return i.join("")}function Be(r){ye||ke();for(var t,e=r.length,n=e%3,i="",o=[],s=16383,c=0,f=e-n;c<f;c+=s)o.push(Ct(r,c,c+s>f?f:c+s));return n===1?(t=r[e-1],i+=B[t>>2],i+=B[t<<4&63],i+="=="):n===2&&(t=(r[e-2]<<8)+r[e-1],i+=B[t>>10],i+=B[t>>4&63],i+=B[t<<2&63],i+="="),o.push(i),o.join("")}function se(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function C(r,t){if(se()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(t),r.__proto__=a.prototype):(r===null&&(r=new a(t)),r.length=t),r}function a(r,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(r,t,e);if(typeof r=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return we(this,r)}return Ce(this,r,t,e)}function Ce(r,t,e,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?Mt(r,t,e,n):typeof t=="string"?Dt(r,t,e):Ut(r,t)}function Fe(r){if(typeof r!="number")throw new TypeError('"size" argument must be a number');if(r<0)throw new RangeError('"size" argument must not be negative')}function Ft(r,t,e,n){return Fe(t),t<=0?C(r,t):e!==void 0?typeof n=="string"?C(r,t).fill(e,n):C(r,t).fill(e):C(r,t)}function we(r,t){if(Fe(t),r=C(r,t<0?0:xe(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)r[e]=0;return r}function Dt(r,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=De(t,e)|0;r=C(r,n);var i=r.write(t,e);return i!==n&&(r=r.slice(0,i)),r}function de(r,t){var e=t.length<0?0:xe(t.length)|0;r=C(r,e);for(var n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Mt(r,t,e,n){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?t=new Uint8Array(t):n===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,n),a.TYPED_ARRAY_SUPPORT?(r=t,r.__proto__=a.prototype):r=de(r,t),r}function Ut(r,t){if(b(t)){var e=xe(t.length)|0;return r=C(r,e),r.length===0||t.copy(r,0,0,e),r}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||rr(t.length)?C(r,0):de(r,t);if(t.type==="Buffer"&&Array.isArray(t.data))return de(r,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function xe(r){if(r>=se())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+se().toString(16)+" bytes");return r|0}function b(r){return!!(r!=null&&r._isBuffer)}function De(r,t){if(b(r))return r.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var e=r.length;if(e===0)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return ae(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Oe(r).length;default:if(n)return ae(r).length;t=(""+t).toLowerCase(),n=!0}}function Lt(r,t,e){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Qt(this,t,e);case"utf8":case"utf-8":return Le(this,t,e);case"ascii":return Gt(this,t,e);case"latin1":case"binary":return Jt(this,t,e);case"base64":return Vt(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zt(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function O(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function Me(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,n)),b(t))return t.length===0?-1:be(r,t,e,n,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):be(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function be(r,t,e,n,i){var o=1,s=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;o=2,s/=2,c/=2,e/=2}function f(A,I){return o===1?A[I]:A.readUInt16BE(I*o)}var y;if(i){var m=-1;for(y=e;y<s;y++)if(f(r,y)===f(t,m===-1?0:y-m)){if(m===-1&&(m=y),y-m+1===c)return m*o}else m!==-1&&(y-=y-m),m=-1}else for(e+c>s&&(e=s-c),y=e;y>=0;y--){for(var l=!0,T=0;T<c;T++)if(f(r,y+T)!==f(t,T)){l=!1;break}if(l)return y}return-1}function qt(r,t,e,n){e=Number(e)||0;var i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var o=t.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var c=parseInt(t.substr(s*2,2),16);if(isNaN(c))return s;r[e+s]=c}return s}function Yt(r,t,e,n){return ce(ae(t,r.length-e),r,e,n)}function Ue(r,t,e,n){return ce(er(t),r,e,n)}function $t(r,t,e,n){return Ue(r,t,e,n)}function Ot(r,t,e,n){return ce(Oe(t),r,e,n)}function Wt(r,t,e,n){return ce(tr(t,r.length-e),r,e,n)}function Vt(r,t,e){return t===0&&e===r.length?Be(r):Be(r.slice(t,e))}function Le(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i<e;){var o=r[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=e){var f,y,m,l;switch(c){case 1:o<128&&(s=o);break;case 2:f=r[i+1],(f&192)===128&&(l=(o&31)<<6|f&63,l>127&&(s=l));break;case 3:f=r[i+1],y=r[i+2],(f&192)===128&&(y&192)===128&&(l=(o&15)<<12|(f&63)<<6|y&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:f=r[i+1],y=r[i+2],m=r[i+3],(f&192)===128&&(y&192)===128&&(m&192)===128&&(l=(o&15)<<18|(f&63)<<12|(y&63)<<6|m&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=c}return Ht(n)}function Ht(r){var t=r.length;if(t<=_e)return String.fromCharCode.apply(String,r);for(var e="",n=0;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=_e));return e}function Gt(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function Jt(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function Qt(r,t,e){var n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var i="",o=t;o<e;++o)i+=jt(r[o]);return i}function zt(r,t,e){for(var n=r.slice(t,e),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}function g(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}function v(r,t,e,n,i,o){if(!b(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}function ue(r,t,e,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(r.length-e,2);i<o;++i)r[e+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function pe(r,t,e,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(r.length-e,4);i<o;++i)r[e+i]=t>>>(n?i:3-i)*8&255}function qe(r,t,e,n,i,o){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ye(r,t,e,n,i){return i||qe(r,t,e,4,34028234663852886e22,-34028234663852886e22),Ve(r,t,e,n,23,4),e+4}function $e(r,t,e,n,i){return i||qe(r,t,e,8,17976931348623157e292,-17976931348623157e292),Ve(r,t,e,n,52,8),e+8}function Zt(r){if(r=Xt(r).replace(Kt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Xt(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function jt(r){return r<16?"0"+r.toString(16):r.toString(16)}function ae(r,t){t=t||1/0;for(var e,n=r.length,i=null,o=[],s=0;s<n;++s){if(e=r.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function er(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function tr(r,t){for(var e,n,i,o=[],s=0;s<r.length&&!((t-=2)<0);++s)e=r.charCodeAt(s),n=e>>8,i=e%256,o.push(i),o.push(n);return o}function Oe(r){return _t(Zt(r))}function ce(r,t,e,n){for(var i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function rr(r){return r!==r}function nr(r){return r!=null&&(!!r._isBuffer||We(r)||ir(r))}function We(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function ir(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&We(r.slice(0,0))}function he(r,t,e,n,i){var o,s,c=i*8-n-1,f=(1<<c)-1,y=f>>1,m=-7,l=e?i-1:0,T=e?-1:1,A=r[t+l];for(l+=T,o=A&(1<<-m)-1,A>>=-m,m+=c;m>0;o=o*256+r[t+l],l+=T,m-=8);for(s=o&(1<<-m)-1,o>>=-m,m+=n;m>0;s=s*256+r[t+l],l+=T,m-=8);if(o===0)o=1-y;else{if(o===f)return s?NaN:(A?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-y}return(A?-1:1)*s*Math.pow(2,o-n)}function Ve(r,t,e,n,i,o){var s,c,f,y=o*8-i-1,m=(1<<y)-1,l=m>>1,T=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=n?0:o-1,I=n?1:-1,Ke=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=m):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+l>=1?t+=T/f:t+=T*Math.pow(2,1-l),t*f>=2&&(s++,f/=2),s+l>=m?(c=0,s=m):s+l>=1?(c=(t*f-1)*Math.pow(2,i),s=s+l):(c=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;r[e+A]=c&255,A+=I,c/=256,i-=8);for(s=s<<i|c,y+=i;y>0;r[e+A]=s&255,A+=I,s/=256,y-=8);r[e+A-I]|=Ke*128}var B,R,bt,ye,_e,Kt,He=me(()=>{"use strict";u();p();B=[],R=[],bt=typeof Uint8Array!="undefined"?Uint8Array:Array,ye=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(r){return r.__proto__=a.prototype,r};a.from=function(r,t,e){return Ce(null,r,t,e)};a.kMaxLength=se();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(r,t,e){return Ft(null,r,t,e)};a.allocUnsafe=function(r){return we(null,r)};a.allocUnsafeSlow=function(r){return we(null,r)};a.isBuffer=nr;a.compare=function(t,e){if(!b(t)||!b(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,i=e.length,o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==e[o]){n=t[o],i=e[o];break}return n<i?-1:i<n?1:0};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var i=a.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var s=t[n];if(!b(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=De;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)O(this,e,e+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)O(this,e,e+3),O(this,e+1,e+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)O(this,e,e+7),O(this,e+1,e+6),O(this,e+2,e+5),O(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Le(this,0,t):Lt.apply(this,arguments)};a.prototype.equals=function(t){if(!b(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,n,i,o){if(!b(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=n)return 0;if(i>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var s=o-i,c=n-e,f=Math.min(s,c),y=this.slice(i,o),m=t.slice(e,n),l=0;l<f;++l)if(y[l]!==m[l]){s=y[l],c=m[l];break}return s<c?-1:c<s?1:0};a.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};a.prototype.indexOf=function(t,e,n){return Me(this,t,e,n,!0)};a.prototype.lastIndexOf=function(t,e,n){return Me(this,t,e,n,!1)};a.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return qt(this,t,e,n);case"utf8":case"utf-8":return Yt(this,t,e,n);case"ascii":return Ue(this,t,e,n);case"latin1":case"binary":return $t(this,t,e,n);case"base64":return Ot(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wt(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};_e=4096;a.prototype.slice=function(t,e){var n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=a.prototype;else{var o=e-t;i=new a(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};a.prototype.readUIntLE=function(t,e,n){t=t|0,e=e|0,n||g(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};a.prototype.readUIntBE=function(t,e,n){t=t|0,e=e|0,n||g(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};a.prototype.readUInt8=function(t,e){return e||g(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||g(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||g(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||g(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,e){return e||g(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,n){t=t|0,e=e|0,n||g(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};a.prototype.readIntBE=function(t,e,n){t=t|0,e=e|0,n||g(t,e,this.length);for(var i=e,o=1,s=this[t+--i];i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};a.prototype.readInt8=function(t,e){return e||g(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||g(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};a.prototype.readInt16BE=function(t,e){e||g(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};a.prototype.readInt32LE=function(t,e){return e||g(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,e){return e||g(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,e){return e||g(t,4,this.length),he(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||g(t,4,this.length),he(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||g(t,8,this.length),he(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||g(t,8,this.length),he(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;v(this,t,e,n,o,0)}var s=1,c=0;for(this[e]=t&255;++c<n&&(s*=256);)this[e+c]=t/s&255;return e+n};a.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;v(this,t,e,n,o,0)}var s=n-1,c=1;for(this[e+s]=t&255;--s>=0&&(c*=256);)this[e+s]=t/c&255;return e+n};a.prototype.writeUInt8=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};a.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):ue(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):ue(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):pe(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):pe(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*n-1);v(this,t,e,n,o-1,-o)}var s=0,c=1,f=0;for(this[e]=t&255;++s<n&&(c*=256);)t<0&&f===0&&this[e+s-1]!==0&&(f=1),this[e+s]=(t/c>>0)-f&255;return e+n};a.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*n-1);v(this,t,e,n,o-1,-o)}var s=n-1,c=1,f=0;for(this[e+s]=t&255;--s>=0&&(c*=256);)t<0&&f===0&&this[e+s+1]!==0&&(f=1),this[e+s]=(t/c>>0)-f&255;return e+n};a.prototype.writeInt8=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};a.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):ue(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):ue(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):pe(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e|0,n||v(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):pe(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,n){return Ye(this,t,e,!0,n)};a.prototype.writeFloatBE=function(t,e,n){return Ye(this,t,e,!1,n)};a.prototype.writeDoubleLE=function(t,e,n){return $e(this,t,e,!0,n)};a.prototype.writeDoubleBE=function(t,e,n){return $e(this,t,e,!1,n)};a.prototype.copy=function(t,e,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);var o=i-n,s;if(this===t&&n<e&&e<i)for(s=o-1;s>=0;--s)t[s+e]=this[s+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o};a.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<n;++s)this[s]=t;else{var c=b(t)?t:ae(new a(t,i).toString()),f=c.length;for(s=0;s<n-e;++s)this[s+e]=c[s%f]}return this};Kt=/[^+\/0-9A-Za-z-_]/g});var p=me(()=>{"use strict";He()});var _r={};ve(_r,{EndpointSnippetGenerator:()=>Te});module.exports=rt(_r);u();p();u();p();u();p();u();p();function j(r){throw new Error("Unexpected value: "+JSON.stringify(r))}u();p();u();p();var W=class{};u();p();u();p();var q=class extends W{constructor(e){super();h(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var or=4,ee=class{constructor(){h(this,"buffer","");h(this,"indentLevel",0);h(this,"hasWrittenAnything",!1);h(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
|
|
1
|
+
"use strict";var ie=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var je=Object.prototype.hasOwnProperty;var et=(r,t,e)=>t in r?ie(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var me=(r,t)=>()=>(r&&(t=r(r=0)),t);var Te=(r,t)=>{for(var e in t)ie(r,e,{get:t[e],enumerable:!0})},tt=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Xe(t))!je.call(r,i)&&i!==e&&ie(r,i,{get:()=>t[i],enumerable:!(n=Ze(t,i))||n.enumerable});return r};var rt=r=>tt(ie({},"__esModule",{value:!0}),r);var h=(r,t,e)=>et(r,typeof t!="symbol"?t+"":t,e);function Ie(){throw new Error("setTimeout has not been defined")}function Re(){throw new Error("clearTimeout has not been defined")}function Se(r){if(L===setTimeout)return setTimeout(r,0);if((L===Ie||!L)&&setTimeout)return L=setTimeout,setTimeout(r,0);try{return L(r,0)}catch(t){try{return L.call(null,r,0)}catch(e){return L.call(this,r,0)}}}function nt(r){if(q===clearTimeout)return clearTimeout(r);if((q===Re||!q)&&clearTimeout)return q=clearTimeout,clearTimeout(r);try{return q(r)}catch(t){try{return q.call(null,r)}catch(e){return q.call(this,r)}}}function it(){!X||!$||(X=!1,$.length?k=$.concat(k):oe=-1,k.length&&Pe())}function Pe(){if(!X){var r=Se(it);X=!0;for(var t=k.length;t;){for($=k,k=[];++oe<t;)$&&$[oe].run();oe=-1,t=k.length}$=null,X=!1,nt(r)}}function ot(r){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];k.push(new Ne(r,t)),k.length===1&&!X&&Se(Pe)}function Ne(r,t){this.fun=r,this.array=t}function W(){}function Tt(r){throw new Error("process.binding is not supported")}function Et(){return"/"}function It(r){throw new Error("process.chdir is not supported")}function Rt(){return 0}function Pt(r){var t=St.call(Z)*.001,e=Math.floor(t),n=Math.floor(t%1*1e9);return r&&(e=e-r[0],n=n-r[1],n<0&&(e--,n+=1e9)),[e,n]}function bt(){var r=new Date,t=r-Nt;return t/1e3}var L,q,k,X,$,oe,st,at,ut,pt,ct,ht,ft,lt,mt,dt,yt,xt,wt,gt,At,vt,Z,St,Nt,y,Ee,u=me(()=>{"use strict";L=Ie,q=Re;typeof globalThis.setTimeout=="function"&&(L=setTimeout);typeof globalThis.clearTimeout=="function"&&(q=clearTimeout);k=[],X=!1,oe=-1;Ne.prototype.run=function(){this.fun.apply(null,this.array)};st="browser",at="browser",ut=!0,pt={},ct=[],ht="",ft={},lt={},mt={};dt=W,yt=W,xt=W,wt=W,gt=W,At=W,vt=W;Z=globalThis.performance||{},St=Z.now||Z.mozNow||Z.msNow||Z.oNow||Z.webkitNow||function(){return new Date().getTime()};Nt=new Date;y={nextTick:ot,title:st,browser:ut,env:pt,argv:ct,version:ht,versions:ft,on:dt,addListener:yt,once:xt,off:wt,removeListener:gt,removeAllListeners:At,emit:vt,binding:Tt,cwd:Et,chdir:It,umask:Rt,hrtime:Pt,platform:at,release:lt,config:mt,uptime:bt},Ee={};Object.keys(Ee).forEach(r=>{let t=r.split("."),e=y;for(let n=0;n<t.length;n++){let i=t[n];n===t.length-1?e[i]=Ee[r]:e=e[i]||(e[i]={})}})});function ke(){ye=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=r.length;t<e;++t)b[t]=r[t],R[r.charCodeAt(t)]=t;R[45]=62,R[95]=63}function _t(r){ye||ke();var t,e,n,i,o,s,c=r.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=r[c-2]==="="?2:r[c-1]==="="?1:0,s=new Bt(c*3/4-o),n=o>0?c-4:c;var f=0;for(t=0,e=0;t<n;t+=4,e+=3)i=R[r.charCodeAt(t)]<<18|R[r.charCodeAt(t+1)]<<12|R[r.charCodeAt(t+2)]<<6|R[r.charCodeAt(t+3)],s[f++]=i>>16&255,s[f++]=i>>8&255,s[f++]=i&255;return o===2?(i=R[r.charCodeAt(t)]<<2|R[r.charCodeAt(t+1)]>>4,s[f++]=i&255):o===1&&(i=R[r.charCodeAt(t)]<<10|R[r.charCodeAt(t+1)]<<4|R[r.charCodeAt(t+2)]>>2,s[f++]=i>>8&255,s[f++]=i&255),s}function kt(r){return b[r>>18&63]+b[r>>12&63]+b[r>>6&63]+b[r&63]}function Ct(r,t,e){for(var n,i=[],o=t;o<e;o+=3)n=(r[o]<<16)+(r[o+1]<<8)+r[o+2],i.push(kt(n));return i.join("")}function be(r){ye||ke();for(var t,e=r.length,n=e%3,i="",o=[],s=16383,c=0,f=e-n;c<f;c+=s)o.push(Ct(r,c,c+s>f?f:c+s));return n===1?(t=r[e-1],i+=b[t>>2],i+=b[t<<4&63],i+="=="):n===2&&(t=(r[e-2]<<8)+r[e-1],i+=b[t>>10],i+=b[t>>4&63],i+=b[t<<2&63],i+="="),o.push(i),o.join("")}function se(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function C(r,t){if(se()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(t),r.__proto__=a.prototype):(r===null&&(r=new a(t)),r.length=t),r}function a(r,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(r,t,e);if(typeof r=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return xe(this,r)}return Ce(this,r,t,e)}function Ce(r,t,e,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?Ut(r,t,e,n):typeof t=="string"?Ft(r,t,e):Mt(r,t)}function De(r){if(typeof r!="number")throw new TypeError('"size" argument must be a number');if(r<0)throw new RangeError('"size" argument must not be negative')}function Dt(r,t,e,n){return De(t),t<=0?C(r,t):e!==void 0?typeof n=="string"?C(r,t).fill(e,n):C(r,t).fill(e):C(r,t)}function xe(r,t){if(De(t),r=C(r,t<0?0:we(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)r[e]=0;return r}function Ft(r,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=Fe(t,e)|0;r=C(r,n);var i=r.write(t,e);return i!==n&&(r=r.slice(0,i)),r}function de(r,t){var e=t.length<0?0:we(t.length)|0;r=C(r,e);for(var n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Ut(r,t,e,n){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?t=new Uint8Array(t):n===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,n),a.TYPED_ARRAY_SUPPORT?(r=t,r.__proto__=a.prototype):r=de(r,t),r}function Mt(r,t){if(B(t)){var e=we(t.length)|0;return r=C(r,e),r.length===0||t.copy(r,0,0,e),r}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||rr(t.length)?C(r,0):de(r,t);if(t.type==="Buffer"&&Array.isArray(t.data))return de(r,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function we(r){if(r>=se())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+se().toString(16)+" bytes");return r|0}function B(r){return!!(r!=null&&r._isBuffer)}function Fe(r,t){if(B(r))return r.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var e=r.length;if(e===0)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return ae(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return We(r).length;default:if(n)return ae(r).length;t=(""+t).toLowerCase(),n=!0}}function Lt(r,t,e){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Qt(this,t,e);case"utf8":case"utf-8":return Le(this,t,e);case"ascii":return Ht(this,t,e);case"latin1":case"binary":return Jt(this,t,e);case"base64":return Vt(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zt(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function O(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function Ue(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,n)),B(t))return t.length===0?-1:Be(r,t,e,n,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Be(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function Be(r,t,e,n,i){var o=1,s=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;o=2,s/=2,c/=2,e/=2}function f(A,I){return o===1?A[I]:A.readUInt16BE(I*o)}var x;if(i){var d=-1;for(x=e;x<s;x++)if(f(r,x)===f(t,d===-1?0:x-d)){if(d===-1&&(d=x),x-d+1===c)return d*o}else d!==-1&&(x-=x-d),d=-1}else for(e+c>s&&(e=s-c),x=e;x>=0;x--){for(var l=!0,v=0;v<c;v++)if(f(r,x+v)!==f(t,v)){l=!1;break}if(l)return x}return-1}function qt(r,t,e,n){e=Number(e)||0;var i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var o=t.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var c=parseInt(t.substr(s*2,2),16);if(isNaN(c))return s;r[e+s]=c}return s}function Yt(r,t,e,n){return ce(ae(t,r.length-e),r,e,n)}function Me(r,t,e,n){return ce(er(t),r,e,n)}function $t(r,t,e,n){return Me(r,t,e,n)}function Wt(r,t,e,n){return ce(We(t),r,e,n)}function Ot(r,t,e,n){return ce(tr(t,r.length-e),r,e,n)}function Vt(r,t,e){return t===0&&e===r.length?be(r):be(r.slice(t,e))}function Le(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i<e;){var o=r[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=e){var f,x,d,l;switch(c){case 1:o<128&&(s=o);break;case 2:f=r[i+1],(f&192)===128&&(l=(o&31)<<6|f&63,l>127&&(s=l));break;case 3:f=r[i+1],x=r[i+2],(f&192)===128&&(x&192)===128&&(l=(o&15)<<12|(f&63)<<6|x&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:f=r[i+1],x=r[i+2],d=r[i+3],(f&192)===128&&(x&192)===128&&(d&192)===128&&(l=(o&15)<<18|(f&63)<<12|(x&63)<<6|d&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=c}return Gt(n)}function Gt(r){var t=r.length;if(t<=_e)return String.fromCharCode.apply(String,r);for(var e="",n=0;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=_e));return e}function Ht(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function Jt(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function Qt(r,t,e){var n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var i="",o=t;o<e;++o)i+=jt(r[o]);return i}function zt(r,t,e){for(var n=r.slice(t,e),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}function g(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}function T(r,t,e,n,i,o){if(!B(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}function ue(r,t,e,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(r.length-e,2);i<o;++i)r[e+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function pe(r,t,e,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(r.length-e,4);i<o;++i)r[e+i]=t>>>(n?i:3-i)*8&255}function qe(r,t,e,n,i,o){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ye(r,t,e,n,i){return i||qe(r,t,e,4,34028234663852886e22,-34028234663852886e22),Ve(r,t,e,n,23,4),e+4}function $e(r,t,e,n,i){return i||qe(r,t,e,8,17976931348623157e292,-17976931348623157e292),Ve(r,t,e,n,52,8),e+8}function Zt(r){if(r=Xt(r).replace(Kt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Xt(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function jt(r){return r<16?"0"+r.toString(16):r.toString(16)}function ae(r,t){t=t||1/0;for(var e,n=r.length,i=null,o=[],s=0;s<n;++s){if(e=r.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function er(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function tr(r,t){for(var e,n,i,o=[],s=0;s<r.length&&!((t-=2)<0);++s)e=r.charCodeAt(s),n=e>>8,i=e%256,o.push(i),o.push(n);return o}function We(r){return _t(Zt(r))}function ce(r,t,e,n){for(var i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function rr(r){return r!==r}function nr(r){return r!=null&&(!!r._isBuffer||Oe(r)||ir(r))}function Oe(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function ir(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&Oe(r.slice(0,0))}function he(r,t,e,n,i){var o,s,c=i*8-n-1,f=(1<<c)-1,x=f>>1,d=-7,l=e?i-1:0,v=e?-1:1,A=r[t+l];for(l+=v,o=A&(1<<-d)-1,A>>=-d,d+=c;d>0;o=o*256+r[t+l],l+=v,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=n;d>0;s=s*256+r[t+l],l+=v,d-=8);if(o===0)o=1-x;else{if(o===f)return s?NaN:(A?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-x}return(A?-1:1)*s*Math.pow(2,o-n)}function Ve(r,t,e,n,i,o){var s,c,f,x=o*8-i-1,d=(1<<x)-1,l=d>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=n?0:o-1,I=n?1:-1,Ke=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+l>=1?t+=v/f:t+=v*Math.pow(2,1-l),t*f>=2&&(s++,f/=2),s+l>=d?(c=0,s=d):s+l>=1?(c=(t*f-1)*Math.pow(2,i),s=s+l):(c=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;r[e+A]=c&255,A+=I,c/=256,i-=8);for(s=s<<i|c,x+=i;x>0;r[e+A]=s&255,A+=I,s/=256,x-=8);r[e+A-I]|=Ke*128}var b,R,Bt,ye,_e,Kt,Ge=me(()=>{"use strict";u();p();b=[],R=[],Bt=typeof Uint8Array!="undefined"?Uint8Array:Array,ye=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(r){return r.__proto__=a.prototype,r};a.from=function(r,t,e){return Ce(null,r,t,e)};a.kMaxLength=se();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(r,t,e){return Dt(null,r,t,e)};a.allocUnsafe=function(r){return xe(null,r)};a.allocUnsafeSlow=function(r){return xe(null,r)};a.isBuffer=nr;a.compare=function(t,e){if(!B(t)||!B(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,i=e.length,o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==e[o]){n=t[o],i=e[o];break}return n<i?-1:i<n?1:0};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var i=a.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var s=t[n];if(!B(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=Fe;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)O(this,e,e+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)O(this,e,e+3),O(this,e+1,e+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)O(this,e,e+7),O(this,e+1,e+6),O(this,e+2,e+5),O(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Le(this,0,t):Lt.apply(this,arguments)};a.prototype.equals=function(t){if(!B(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,n,i,o){if(!B(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=n)return 0;if(i>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var s=o-i,c=n-e,f=Math.min(s,c),x=this.slice(i,o),d=t.slice(e,n),l=0;l<f;++l)if(x[l]!==d[l]){s=x[l],c=d[l];break}return s<c?-1:c<s?1:0};a.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};a.prototype.indexOf=function(t,e,n){return Ue(this,t,e,n,!0)};a.prototype.lastIndexOf=function(t,e,n){return Ue(this,t,e,n,!1)};a.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return qt(this,t,e,n);case"utf8":case"utf-8":return Yt(this,t,e,n);case"ascii":return Me(this,t,e,n);case"latin1":case"binary":return $t(this,t,e,n);case"base64":return Wt(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ot(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};_e=4096;a.prototype.slice=function(t,e){var n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=a.prototype;else{var o=e-t;i=new a(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};a.prototype.readUIntLE=function(t,e,n){t=t|0,e=e|0,n||g(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};a.prototype.readUIntBE=function(t,e,n){t=t|0,e=e|0,n||g(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};a.prototype.readUInt8=function(t,e){return e||g(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||g(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||g(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||g(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,e){return e||g(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,n){t=t|0,e=e|0,n||g(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};a.prototype.readIntBE=function(t,e,n){t=t|0,e=e|0,n||g(t,e,this.length);for(var i=e,o=1,s=this[t+--i];i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};a.prototype.readInt8=function(t,e){return e||g(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||g(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};a.prototype.readInt16BE=function(t,e){e||g(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};a.prototype.readInt32LE=function(t,e){return e||g(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,e){return e||g(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,e){return e||g(t,4,this.length),he(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||g(t,4,this.length),he(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||g(t,8,this.length),he(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||g(t,8,this.length),he(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;T(this,t,e,n,o,0)}var s=1,c=0;for(this[e]=t&255;++c<n&&(s*=256);)this[e+c]=t/s&255;return e+n};a.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;T(this,t,e,n,o,0)}var s=n-1,c=1;for(this[e+s]=t&255;--s>=0&&(c*=256);)this[e+s]=t/c&255;return e+n};a.prototype.writeUInt8=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};a.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):ue(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):ue(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):pe(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):pe(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*n-1);T(this,t,e,n,o-1,-o)}var s=0,c=1,f=0;for(this[e]=t&255;++s<n&&(c*=256);)t<0&&f===0&&this[e+s-1]!==0&&(f=1),this[e+s]=(t/c>>0)-f&255;return e+n};a.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*n-1);T(this,t,e,n,o-1,-o)}var s=n-1,c=1,f=0;for(this[e+s]=t&255;--s>=0&&(c*=256);)t<0&&f===0&&this[e+s+1]!==0&&(f=1),this[e+s]=(t/c>>0)-f&255;return e+n};a.prototype.writeInt8=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};a.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):ue(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):ue(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):pe(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e|0,n||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):pe(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,n){return Ye(this,t,e,!0,n)};a.prototype.writeFloatBE=function(t,e,n){return Ye(this,t,e,!1,n)};a.prototype.writeDoubleLE=function(t,e,n){return $e(this,t,e,!0,n)};a.prototype.writeDoubleBE=function(t,e,n){return $e(this,t,e,!1,n)};a.prototype.copy=function(t,e,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);var o=i-n,s;if(this===t&&n<e&&e<i)for(s=o-1;s>=0;--s)t[s+e]=this[s+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o};a.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<n;++s)this[s]=t;else{var c=B(t)?t:ae(new a(t,i).toString()),f=c.length;for(s=0;s<n-e;++s)this[s+e]=c[s%f]}return this};Kt=/[^+\/0-9A-Za-z-_]/g});var p=me(()=>{"use strict";Ge()});var _r={};Te(_r,{EndpointSnippetGenerator:()=>ve});module.exports=rt(_r);u();p();u();p();u();p();u();p();function j(r){throw new Error("Unexpected value: "+JSON.stringify(r))}u();p();u();p();var V=class{};u();p();u();p();var Y=class extends V{constructor(e){super();h(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var or=4,ee=class{constructor(){h(this,"buffer","");h(this,"indentLevel",0);h(this,"hasWrittenAnything",!1);h(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
|
|
2
2
|
`),n=e?t.substring(0,t.length-1):t,i=this.getIndentString(),o=n.replaceAll(`
|
|
3
3
|
`,`
|
|
4
4
|
${i}`);this.isAtStartOfLine()&&(o=i+o),e&&(o+=`
|
|
5
|
-
`),this.writeInternal(o)}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){t.write(this)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new
|
|
5
|
+
`),this.writeInternal(o)}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){t.write(this)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new Y(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new Y(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}openBlock(t,e="{",n,i="}"){let o=t.filter(s=>s!==void 0).join(" ");o?this.write(`${o} ${e!=null?e:""}`):this.write(e!=null?e:"");try{this.indent(),n(),this.dedent()}finally{this.write(i!=null?i:"")}}writeLine(t=""){this.write(t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
6
6
|
`)}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
7
7
|
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}writeInternal(t){return t.length>0&&(this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
8
|
-
`)),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*or)}};u();p();var fe=class{},te=class extends fe{async format(t){return t}formatSync(t){return t}};u();p();function ge(r){return(r==null?void 0:r.name)!=null}u();p();u();p();u();p();u();p();u();p();u();p();u();p();function Ae(r,t){var n,i;let e=(n=r.split("/").pop())!=null?n:r;return t!=null&&t.stripExtension&&(i=e.split(".")[0])!=null?i:e}var sr=/[^0-9a-zA-Z_]/g,
|
|
8
|
+
`)),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*or)}};u();p();var fe=class{},te=class extends fe{async format(t){return t}formatSync(t){return t}};u();p();function ge(r){return(r==null?void 0:r.name)!=null}u();p();u();p();u();p();u();p();u();p();u();p();u();p();function Ae(r,t){var n,i;let e=(n=r.split("/").pop())!=null?n:r;return t!=null&&t.stripExtension&&(i=e.split(".")[0])!=null?i:e}var sr=/[^0-9a-zA-Z_]/g,G=class extends ee{constructor({packageName:e,rootImportPath:n,importPath:i,customConfig:o,formatter:s}){super();h(this,"packageName");h(this,"rootImportPath");h(this,"importPath");h(this,"customConfig");h(this,"formatter");h(this,"imports",{});this.packageName=e,this.rootImportPath=n,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new te}addImport(e){let n=this.imports[e];if(n!=null)return n;let i=this.getValidAlias(Ae(e));for(;i in this.imports;)i="_"+i;return this.imports[e]=i,i}getValidAlias(e){let n=e.split("-");return n[0]==null?e:n[0].replace(sr,"")}};var re=class extends G{constructor({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o}){super({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o})}async toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.format(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
|
|
9
9
|
${t}`)}return t}toStringSync(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
|
|
10
10
|
${t}`)}return t}getContent(){let t=`package ${this.packageName}
|
|
11
11
|
|
|
@@ -14,9 +14,9 @@ ${t}`)}return t}getContent(){let t=`package ${this.packageName}
|
|
|
14
14
|
${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.imports).filter(([e,n])=>e!==this.importPath).map(([e,n])=>` ${n} "${e}"`).join(`
|
|
15
15
|
`);return t?`import (
|
|
16
16
|
${t}
|
|
17
|
-
)`:""}};var
|
|
18
|
-
`).forEach(n=>{e.writeLine(`// ${n}`)})}};var H=class extends
|
|
19
|
-
`)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(hr({value:this.internalType.value}));break;default:j(this.internalType)}}static any(e){return new this({type:"any",value:e})}static bool(e){return new this({type:"bool",value:e})}static bytes(e){return new this({type:"bytes",value:e})}static date(e){return new this({type:"date",value:e})}static dateTime(e){return new this({type:"dateTime",value:e})}static enum(e){return new this({type:"enum",typeReference:e})}static float64(e){return new this({type:"float64",value:e})}static int(e){return new this({type:"int",value:e})}static int64(e){return new this({type:"int64",value:e})}static map({keyType:e,valueType:n,entries:i}){return new this({type:"map",keyType:e,valueType:n,entries:i})}static nil(){return new this({type:"nil"})}static nop(){return new this({type:"nop"})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static reference(e){return new this({type:"reference",value:e})}static slice({valueType:e,values:n}){return new this({type:"slice",valueType:e,values:n})}static string(e){return new this({type:"string",value:e})}static struct({typeReference:e,fields:n}){return new this({type:"struct",typeReference:e,fields:n})}static structPointer({typeReference:e,fields:n}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:n})})}static uuid(e){return new this({type:"uuid",value:e})}static isNop(e){return e.internalType.type==="optional"?this.isNop(e.internalType.value):e.internalType.type==="nop"}writeAny({writer:e,value:n}){switch(typeof n){case"boolean":e.write(n.toString());return;case"string":e.write(n.includes('"')?`\`${n}\``:`"${n}"`);return;case"number":e.write(n.toString());return;case"object":if(n==null){e.write("nil");return}if(Array.isArray(n)){this.writeAnyArray({writer:e,value:n});return}this.writeAnyObject({writer:e,value:n});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof n}`)}}writeAnyArray({writer:e,value:n}){if(e.write("[]interface{}"),n.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let i of n)e.writeNode(r.any(i)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:n}){e.write("map[string]interface{}");let i=Object.entries(n);if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[o,s]of i)e.write(`"${o}": `),e.writeNode(r.any(s)),e.writeLine(",");e.dedent(),e.write("}")}writeMap({writer:e,map:n}){e.write("map["),e.writeNode(n.keyType),e.write("]"),e.writeNode(n.valueType);let i=fr({entries:n.entries});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.key.write(e),e.write(": "),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:n}){if(ar.has(n.internalType.type)){e.writeNode(ur({writer:e,type:n}));return}if(Ge.has(n.internalType.type)){n.write(e);return}if(n.internalType.type==="enum"){e.writeNode(new D({on:n.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),n.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||Ge.has(e.internalType.type)}writeSlice({writer:e,slice:n}){e.write("[]"),e.writeNode(n.valueType);let i=mr({values:n.values});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeStruct({writer:e,struct:n}){e.writeNode(n.typeReference);let i=lr({fields:n.fields});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)e.write(`${o.name}: `),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function ur({writer:r,type:t}){return new N({func:new E({name:pr({type:t}),importPath:r.rootImportPath}),arguments_:[t]})}function pr({type:r}){switch(r.internalType.type){case"bool":return"Bool";case"date":case"dateTime":return"Time";case"float64":return"Float64";case"int":return"Int";case"int64":return"Int64";case"string":return"String";case"uuid":return"UUID";default:return""}}function cr({writer:r,type:t}){let e=t instanceof Date?"MustParseDate":"MustParseDateTime";return new N({func:new E({name:e,importPath:r.rootImportPath}),arguments_:[new _(`"${t.value}"`)]})}function hr({value:r}){return new N({func:new E({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new _(`"${r}"`)]})}function fr({entries:r}){return r.filter(t=>!S.isNop(t.key)&&!S.isNop(t.value))}function lr({fields:r}){return r.filter(t=>!S.isNop(t.value))}function mr({values:r}){return r.filter(t=>!S.isNop(t))}function le({writer:r,arguments_:t}){let e=yr(t);if(e.length===0){r.write("()");return}r.writeLine("("),r.indent();for(let n of e)dr({writer:r,argument:n}),r.writeLine(",");r.dedent(),r.write(")")}function dr({writer:r,argument:t}){ge(t)?t.assignment.write(r):t.write(r)}function yr(r){return r.filter(t=>!(t instanceof S&&S.isNop(t)))}var N=class extends x{constructor({func:e,arguments_:n}){super();h(this,"func");h(this,"arguments_");this.func=e,this.arguments_=n}write(e){e.writeNode(this.func),le({writer:e,arguments_:this.arguments_})}};u();p();var Q=class extends x{constructor({name:e,type:n,docs:i}){super();h(this,"name");h(this,"type");h(this,"docs");this.name=e,this.type=n,this.docs=i}write(e){e.writeNode(new P({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};u();p();var z=class extends x{constructor({name:e,importPath:n,docs:i}){super();h(this,"name");h(this,"importPath");h(this,"docs");h(this,"fields",[]);h(this,"methods",[]);this.name=e,this.importPath=n,this.docs=i}addField(e){this.fields.push(e)}addMethod(e){this.methods.push(e)}write(e){if(e.writeNode(new P({docs:this.docs})),e.write(`type ${this.name} struct {`),this.fields.length>0)e.writeLine("}");else{e.newLine(),e.indent();for(let n of this.fields)e.writeNode(n),e.newLine();e.dedent(),e.writeLine("}")}(this.constructor!=null||this.methods.length>0)&&e.newLine();for(let n of this.methods)e.writeNode(n),e.newLine()}};u();p();var wr=new Set(["any","bytes","map","slice"]),ne=class r extends x{constructor(e){super();h(this,"internalType");this.internalType=e}write(e,{comment:n}={}){switch(this.internalType.type){case"any":e.write("interface{}");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(xr);break;case"float64":e.write("float64");break;case"int":e.write("int");break;case"int64":e.write("int64");break;case"map":{e.write("map["),this.internalType.keyType.write(e),e.write("]"),this.internalType.valueType.write(e);break}case"optional":{e.write("*"),this.internalType.value.write(e);break}case"reference":e.writeNode(this.internalType.value);break;case"slice":e.write("[]"),this.internalType.value.write(e);break;case"string":e.write("string");break;case"uuid":e.writeNode(gr);break;default:j(this.internalType)}}isOptional(){return this.internalType.type==="optional"}static any(){return new this({type:"any"})}static bool(){return new this({type:"bool"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static float64(){return new this({type:"float64"})}static int(){return new this({type:"int"})}static int64(){return new this({type:"int64"})}static map(e,n){return new this({type:"map",keyType:e,valueType:n})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static pointer(e){return r.optional(e)}static reference(e){return new this({type:"reference",value:e})}static slice(e){return new this({type:"slice",value:e})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static isAlreadyOptional(e){return e.internalType.type==="optional"||wr.has(e.internalType.type)}},xr=new E({importPath:"time",name:"Time"}),gr=new E({importPath:"github.com/google/uuid",name:"UUID"});var w={};ve(w,{AstNode:()=>x,CodeBlock:()=>_,Enum:()=>H,Field:()=>G,Func:()=>J,FuncInvocation:()=>N,Method:()=>F,MethodInvocation:()=>D,Parameter:()=>Q,Struct:()=>z,Type:()=>ne,TypeInstantiation:()=>S,TypeReference:()=>E,Writer:()=>V,codeblock:()=>Ar,enum_:()=>Tr,field:()=>vr,func:()=>Er,invokeFunc:()=>Ir,invokeMethod:()=>Rr,method:()=>Pr,parameter:()=>Sr,struct:()=>Nr,typeReference:()=>Br});u();p();function Ar(r){return new _(r)}function Tr(r){return new H(r)}function vr(r){return new G(r)}function Er(r){return new J(r)}function Ir(r){return new N(r)}function Rr(r){return new D(r)}function Pr(r){return new F(r)}function Sr(r){return new Q(r)}function Nr(r){return new z(r)}function Br(r){return new E(r)}u();p();var X={Critical:"CRITICAL",Warning:"WARNING"};u();p();var M={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};var Je="example",Qe="fern",br="do",ze="client",Te=class{constructor({context:t,formatter:e}){h(this,"context");h(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e}){var i;return await this.buildCodeBlock({endpoint:t,snippet:e}).toString({packageName:Je,importPath:Qe,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e}){var i;return this.buildCodeBlock({endpoint:t,snippet:e}).toStringSync({packageName:Je,importPath:Qe,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return w.func({name:br,parameters:[],return_:[],body:w.codeblock(n=>{n.writeNode(this.constructClient({endpoint:t,snippet:e})),n.writeLine(),n.writeNode(this.callMethod({endpoint:t,snippet:e}))})})}constructClient({endpoint:t,snippet:e}){return w.codeblock(n=>{n.write(`${ze} := `),n.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}callMethod({endpoint:t,snippet:e}){return w.invokeMethod({on:w.codeblock(ze),method:this.getMethod({endpoint:t}),arguments_:[this.context.getContextTodoFunctionInvocation(),...this.getMethodArgs({endpoint:t,snippet:e})]})}getConstructorArgs({endpoint:t,snippet:e}){let n=[];return t.auth!=null&&(e.auth!=null?n.push(this.getConstructorAuthArg({auth:t.auth,values:e.auth})):this.context.errors.add({severity:X.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(M.Headers),this.context.ir.headers!=null&&e.headers!=null&&n.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),n}getConstructorAuthArg({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.context.errors.add({severity:X.Critical,message:this.newAuthMismatchError({auth:t,values:e}).message}),w.TypeInstantiation.nop()):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.context.errors.add({severity:X.Critical,message:this.newAuthMismatchError({auth:t,values:e}).message}),w.TypeInstantiation.nop()):this.getConstructorBearerAuthArg({auth:t,values:e});case"header":return e.type!=="header"?(this.context.errors.add({severity:X.Critical,message:this.newAuthMismatchError({auth:t,values:e}).message}),w.TypeInstantiation.nop()):this.getConstructorHeaderAuthArg({auth:t,values:e})}}getConstructorBasicAuthArg({auth:t,values:e}){return w.codeblock(n=>{n.writeNode(w.invokeFunc({func:w.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[w.TypeInstantiation.string(e.username),w.TypeInstantiation.string(e.password)]}))})}getConstructorBearerAuthArg({auth:t,values:e}){return w.codeblock(n=>{n.writeNode(w.invokeFunc({func:w.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[w.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return w.codeblock(n=>{n.writeNode(w.invokeFunc({func:w.typeReference({name:`With${t.header.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.header.typeReference,value:e.value})]}))})}getConstructorHeaderArgs({headers:t,values:e}){let n=[];for(let i of t){let o=this.getConstructorHeaderArg({header:i,value:e.value});o!=null&&n.push(o)}return n}getConstructorHeaderArg({header:t,value:e}){let n=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!w.TypeInstantiation.isNop(n))return w.codeblock(i=>{i.writeNode(w.invokeFunc({func:w.typeReference({name:`With${t.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[n]}))})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e})}}getMethodArgsForBodyRequest({request:t,snippet:e}){let n=[];if(this.context.errors.scope(M.PathParameters),t.pathParameters!=null){let i=this.getPathParameters({namedParameters:t.pathParameters,snippet:e});n.push(...i.map(o=>o.value))}return this.context.errors.unscope(),this.context.errors.scope(M.RequestBody),t.body!=null&&n.push(this.getBodyRequestArg({body:t.body,value:e.requestBody})),this.context.errors.unscope(),n}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e})}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:X.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),w.TypeInstantiation.nop()):w.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){var s;let n=[];this.context.errors.scope(M.PathParameters);let i=[];t.pathParameters!=null&&i.push(...this.getPathParameters({namedParameters:t.pathParameters,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(M.RequestBody);let o=this.getFilePropertyInfo({request:t,snippet:e});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t})||n.push(...i.map(c=>c.value)),(s=this.context.customConfig)!=null&&s.inlineFileProperties||n.push(...o.fileFields.map(c=>c.value)),this.context.needsRequestParameter({request:t})&&n.push(this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t})?i:[],filePropertyInfo:o})),n}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArg({request:t,snippet:e,pathParameterFields:n,filePropertyInfo:i}){var m,l,T,A;this.context.errors.scope(M.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(m=t.queryParameters)!=null?m:[],values:(l=e.queryParameters)!=null?l:{}}).map(I=>({name:I.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(I)}));this.context.errors.unscope(),this.context.errors.scope(M.Headers);let f=this.context.associateByWireValue({parameters:(T=t.headers)!=null?T:[],values:(A=e.headers)!=null?A:{}}).map(I=>({name:I.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(I)}));this.context.errors.unscope(),this.context.errors.scope(M.RequestBody);let y=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),w.TypeInstantiation.structPointer({typeReference:w.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:[...n,...s,...f,...y]})}getInlinedRequestBodyStructFields({body:t,value:e,filePropertyInfo:n}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyStructFields({parameters:t.value,value:e});case"referenced":return[this.getReferencedRequestBodyPropertyStructField({body:t,value:e})];case"fileUpload":return this.getFileUploadRequestBodyStructFields({filePropertyInfo:n})}}getFileUploadRequestBodyStructFields({filePropertyInfo:t}){var e;return(e=this.context.customConfig)!=null&&e.inlineFileProperties?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyStructField({body:t,value:e}){return{name:this.context.getTypeName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeInstantiation({body:t.bodyType,value:e})}}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e})}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){var o;let n=[],i=this.context.associateByWireValue({parameters:t,values:(o=this.context.getRecord(e))!=null?o:{}});for(let s of i)n.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(s)});return n}getPathParameters({namedParameters:t,snippet:e}){var o;let n=[],i=this.context.associateByWireValue({parameters:t,values:(o=e.pathParameters)!=null?o:{}});for(let s of i)n.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(s)});return n}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getMethodName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}getRootClientFuncInvocation(t){return w.invokeFunc({func:w.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}newAuthMismatchError({auth:t,values:e}){return new Error(`Expected auth type ${t.type}, got ${e.type}`)}};0&&(module.exports={EndpointSnippetGenerator});
|
|
17
|
+
)`:""}};var w=class extends V{async toString({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o}){let s=new re({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o});return this.write(s),s.toString()}toStringSync({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o}){let s=new re({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o});return this.write(s),s.toStringSync()}};var _=class extends w{constructor(e){super();h(this,"arg");this.arg=e}write(e){return new Y(this.arg).write(e)}};u();p();u();p();var S=class extends w{constructor({docs:e}={}){super();h(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
18
|
+
`).forEach(n=>{e.writeLine(`// ${n}`)})}};var H=class extends w{constructor({name:e,docs:n}){super();h(this,"name");h(this,"docs");h(this,"members",[]);this.name=e,this.docs=n}addMember(e){this.members.push(e)}write(e){e.writeNode(new S({docs:this.docs})),e.write(`type ${this.name} string`)}};u();p();var J=class extends w{constructor({name:e,type:n,docs:i}){super();h(this,"name");h(this,"type");h(this,"docs");this.name=e,this.type=n,this.docs=i}write(e){e.writeNode(new S({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};u();p();u();p();var D=class extends w{constructor({name:e,parameters:n,return_:i,body:o,docs:s,typeReference:c}){super();h(this,"name");h(this,"parameters");h(this,"return_");h(this,"body");h(this,"docs");h(this,"typeReference");this.name=e,this.parameters=n,this.return_=i,this.body=o,this.docs=s,this.typeReference=c}write(e){var n;if(e.writeNode(new S({docs:this.docs})),e.write("func "),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference}),e.write(`${this.name}`),this.parameters.length===0)e.write("() ");else{e.writeLine("(");for(let i of this.parameters)e.writeNode(i),e.writeLine(",");e.write(")")}this.return_!=null&&(e.write("("),this.return_.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),e.write(")")),e.writeLine(" {"),e.indent(),(n=this.body)==null||n.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.writeLine("}")}writeReceiver({writer:e,typeReference:n}){e.write(`(${this.getReceiverName(n.name)} `),n.write(e),e.write(") ")}getReceiverName(e){return e.charAt(0).toLowerCase()}};var Q=class extends w{constructor({name:e,parameters:n,return_:i,body:o,docs:s}){super();h(this,"func");this.func=new D({name:e,parameters:n,return_:i,body:o,docs:s})}get name(){return this.func.name}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};u();p();u();p();u();p();u();p();var E=class extends w{constructor({name:e,importPath:n}){super();h(this,"name");h(this,"importPath");this.name=e,this.importPath=n}write(e){if(e.importPath===this.importPath){e.write(this.name);return}let n=e.addImport(this.importPath);e.write(`${n}.${this.name}`)}};u();p();var F=class extends w{constructor({method:e,arguments_:n,on:i}){super();h(this,"on");h(this,"method");h(this,"arguments_");this.on=i,this.method=e,this.arguments_=n}write(e){this.on.write(e),e.write("."),e.write(this.method),le({writer:e,arguments_:this.arguments_})}};var ar=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),He=new Set(["any","bytes","map","slice"]),P=class r extends w{constructor(e){super();h(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"any":this.writeAny({writer:e,value:this.internalType.value});break;case"bool":e.write(this.internalType.value.toString());break;case"bytes":e.write(`[]byte("${this.internalType.value}")`);break;case"date":case"dateTime":e.writeNode(cr({writer:e,type:this.internalType}));break;case"enum":e.writeNode(this.internalType.typeReference);break;case"float64":e.write(this.internalType.value.toString());break;case"int":case"int64":e.write(this.internalType.value.toString());break;case"map":this.writeMap({writer:e,map:this.internalType});break;case"nil":e.write("nil");break;case"nop":break;case"optional":this.writeOptional({writer:e,type:this.internalType.value});break;case"reference":e.writeNode(this.internalType.value);break;case"slice":this.writeSlice({writer:e,slice:this.internalType});break;case"string":e.write(this.internalType.value.includes('"')||this.internalType.value.includes(`
|
|
19
|
+
`)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(hr({value:this.internalType.value}));break;default:j(this.internalType)}}static any(e){return new this({type:"any",value:e})}static bool(e){return new this({type:"bool",value:e})}static bytes(e){return new this({type:"bytes",value:e})}static date(e){return new this({type:"date",value:e})}static dateTime(e){return new this({type:"dateTime",value:e})}static enum(e){return new this({type:"enum",typeReference:e})}static float64(e){return new this({type:"float64",value:e})}static int(e){return new this({type:"int",value:e})}static int64(e){return new this({type:"int64",value:e})}static map({keyType:e,valueType:n,entries:i}){return new this({type:"map",keyType:e,valueType:n,entries:i})}static nil(){return new this({type:"nil"})}static nop(){return new this({type:"nop"})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static reference(e){return new this({type:"reference",value:e})}static slice({valueType:e,values:n}){return new this({type:"slice",valueType:e,values:n})}static string(e){return new this({type:"string",value:e})}static struct({typeReference:e,fields:n}){return new this({type:"struct",typeReference:e,fields:n})}static structPointer({typeReference:e,fields:n}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:n})})}static uuid(e){return new this({type:"uuid",value:e})}static isNop(e){return e.internalType.type==="optional"?this.isNop(e.internalType.value):e.internalType.type==="nop"}writeAny({writer:e,value:n}){switch(typeof n){case"boolean":e.write(n.toString());return;case"string":e.write(n.includes('"')?`\`${n}\``:`"${n}"`);return;case"number":e.write(n.toString());return;case"object":if(n==null){e.write("nil");return}if(Array.isArray(n)){this.writeAnyArray({writer:e,value:n});return}this.writeAnyObject({writer:e,value:n});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof n}`)}}writeAnyArray({writer:e,value:n}){if(e.write("[]interface{}"),n.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let i of n)e.writeNode(r.any(i)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:n}){e.write("map[string]interface{}");let i=Object.entries(n);if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[o,s]of i)e.write(`"${o}": `),e.writeNode(r.any(s)),e.writeLine(",");e.dedent(),e.write("}")}writeMap({writer:e,map:n}){e.write("map["),e.writeNode(n.keyType),e.write("]"),e.writeNode(n.valueType);let i=fr({entries:n.entries});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.key.write(e),e.write(": "),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:n}){if(ar.has(n.internalType.type)){e.writeNode(ur({writer:e,type:n}));return}if(He.has(n.internalType.type)){n.write(e);return}if(n.internalType.type==="enum"){e.writeNode(new F({on:n.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),n.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||He.has(e.internalType.type)}writeSlice({writer:e,slice:n}){e.write("[]"),e.writeNode(n.valueType);let i=mr({values:n.values});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeStruct({writer:e,struct:n}){e.writeNode(n.typeReference);let i=lr({fields:n.fields});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)e.write(`${o.name}: `),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function ur({writer:r,type:t}){return new N({func:new E({name:pr({type:t}),importPath:r.rootImportPath}),arguments_:[t]})}function pr({type:r}){switch(r.internalType.type){case"bool":return"Bool";case"date":case"dateTime":return"Time";case"float64":return"Float64";case"int":return"Int";case"int64":return"Int64";case"string":return"String";case"uuid":return"UUID";default:return""}}function cr({writer:r,type:t}){let e=t instanceof Date?"MustParseDate":"MustParseDateTime";return new N({func:new E({name:e,importPath:r.rootImportPath}),arguments_:[new _(`"${t.value}"`)]})}function hr({value:r}){return new N({func:new E({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new _(`"${r}"`)]})}function fr({entries:r}){return r.filter(t=>!P.isNop(t.key)&&!P.isNop(t.value))}function lr({fields:r}){return r.filter(t=>!P.isNop(t.value))}function mr({values:r}){return r.filter(t=>!P.isNop(t))}function le({writer:r,arguments_:t}){let e=yr(t);if(e.length===0){r.write("()");return}r.writeLine("("),r.indent();for(let n of e)dr({writer:r,argument:n}),r.writeLine(",");r.dedent(),r.write(")")}function dr({writer:r,argument:t}){ge(t)?t.assignment.write(r):t.write(r)}function yr(r){return r.filter(t=>!(t instanceof P&&P.isNop(t)))}var N=class extends w{constructor({func:e,arguments_:n}){super();h(this,"func");h(this,"arguments_");this.func=e,this.arguments_=n}write(e){e.writeNode(this.func),le({writer:e,arguments_:this.arguments_})}};u();p();var z=class extends w{constructor({name:e,type:n,docs:i}){super();h(this,"name");h(this,"type");h(this,"docs");this.name=e,this.type=n,this.docs=i}write(e){e.writeNode(new S({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};u();p();var K=class extends w{constructor({name:e,importPath:n,docs:i}){super();h(this,"name");h(this,"importPath");h(this,"docs");h(this,"fields",[]);h(this,"methods",[]);this.name=e,this.importPath=n,this.docs=i}addField(e){this.fields.push(e)}addMethod(e){this.methods.push(e)}write(e){if(e.writeNode(new S({docs:this.docs})),e.write(`type ${this.name} struct {`),this.fields.length>0)e.writeLine("}");else{e.newLine(),e.indent();for(let n of this.fields)e.writeNode(n),e.newLine();e.dedent(),e.writeLine("}")}(this.constructor!=null||this.methods.length>0)&&e.newLine();for(let n of this.methods)e.writeNode(n),e.newLine()}};u();p();var xr=new Set(["any","bytes","map","slice"]),ne=class r extends w{constructor(e){super();h(this,"internalType");this.internalType=e}write(e,{comment:n}={}){switch(this.internalType.type){case"any":e.write("interface{}");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(wr);break;case"float64":e.write("float64");break;case"int":e.write("int");break;case"int64":e.write("int64");break;case"map":{e.write("map["),this.internalType.keyType.write(e),e.write("]"),this.internalType.valueType.write(e);break}case"optional":{e.write("*"),this.internalType.value.write(e);break}case"reference":e.writeNode(this.internalType.value);break;case"slice":e.write("[]"),this.internalType.value.write(e);break;case"string":e.write("string");break;case"uuid":e.writeNode(gr);break;default:j(this.internalType)}}isOptional(){return this.internalType.type==="optional"}static any(){return new this({type:"any"})}static bool(){return new this({type:"bool"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static float64(){return new this({type:"float64"})}static int(){return new this({type:"int"})}static int64(){return new this({type:"int64"})}static map(e,n){return new this({type:"map",keyType:e,valueType:n})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static pointer(e){return r.optional(e)}static reference(e){return new this({type:"reference",value:e})}static slice(e){return new this({type:"slice",value:e})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static isAlreadyOptional(e){return e.internalType.type==="optional"||xr.has(e.internalType.type)}},wr=new E({importPath:"time",name:"Time"}),gr=new E({importPath:"github.com/google/uuid",name:"UUID"});var m={};Te(m,{AstNode:()=>w,CodeBlock:()=>_,Enum:()=>H,Field:()=>J,Func:()=>Q,FuncInvocation:()=>N,Method:()=>D,MethodInvocation:()=>F,Parameter:()=>z,Struct:()=>K,Type:()=>ne,TypeInstantiation:()=>P,TypeReference:()=>E,Writer:()=>G,codeblock:()=>Ar,enum_:()=>vr,field:()=>Tr,func:()=>Er,invokeFunc:()=>Ir,invokeMethod:()=>Rr,method:()=>Sr,parameter:()=>Pr,struct:()=>Nr,typeReference:()=>br});u();p();function Ar(r){return new _(r)}function vr(r){return new H(r)}function Tr(r){return new J(r)}function Er(r){return new Q(r)}function Ir(r){return new N(r)}function Rr(r){return new F(r)}function Sr(r){return new D(r)}function Pr(r){return new z(r)}function Nr(r){return new K(r)}function br(r){return new E(r)}u();p();var U={Critical:"CRITICAL",Warning:"WARNING"};u();p();var M={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};var Je="example",Qe="fern",Br="do",ze="client",ve=class{constructor({context:t,formatter:e}){h(this,"context");h(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e}){var i;return await this.buildCodeBlock({endpoint:t,snippet:e}).toString({packageName:Je,importPath:Qe,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e}){var i;return this.buildCodeBlock({endpoint:t,snippet:e}).toStringSync({packageName:Je,importPath:Qe,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return m.func({name:Br,parameters:[],return_:[],body:m.codeblock(n=>{n.writeNode(this.constructClient({endpoint:t,snippet:e})),n.writeLine(),n.writeNode(this.callMethod({endpoint:t,snippet:e}))})})}constructClient({endpoint:t,snippet:e}){return m.codeblock(n=>{n.write(`${ze} := `),n.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}callMethod({endpoint:t,snippet:e}){return m.invokeMethod({on:m.codeblock(ze),method:this.getMethod({endpoint:t}),arguments_:[this.context.getContextTodoFunctionInvocation(),...this.getMethodArgs({endpoint:t,snippet:e})]})}getConstructorArgs({endpoint:t,snippet:e}){let n=[],i=this.getConstructorBaseUrlArg({baseUrl:e.baseUrl,environment:e.environment});return i!=null&&n.push(i),t.auth!=null&&(e.auth!=null?n.push(this.getConstructorAuthArg({auth:t.auth,values:e.auth})):this.context.errors.add({severity:U.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(M.Headers),this.context.ir.headers!=null&&e.headers!=null&&n.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),n}getConstructorAuthArg({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.context.errors.add({severity:U.Critical,message:this.newAuthMismatchError({auth:t,values:e}).message}),m.TypeInstantiation.nop()):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.context.errors.add({severity:U.Critical,message:this.newAuthMismatchError({auth:t,values:e}).message}),m.TypeInstantiation.nop()):this.getConstructorBearerAuthArg({auth:t,values:e});case"header":return e.type!=="header"?(this.context.errors.add({severity:U.Critical,message:this.newAuthMismatchError({auth:t,values:e}).message}),m.TypeInstantiation.nop()):this.getConstructorHeaderAuthArg({auth:t,values:e})}}getConstructorBasicAuthArg({auth:t,values:e}){return m.codeblock(n=>{n.writeNode(m.invokeFunc({func:m.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[m.TypeInstantiation.string(e.username),m.TypeInstantiation.string(e.password)]}))})}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let n=this.getBaseUrlArg({baseUrl:t,environment:e});if(n!=null)return m.codeblock(i=>{i.writeNode(m.invokeFunc({func:m.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[n]}))})}getBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:U.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return m.TypeInstantiation.string(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let n=this.context.getEnvironmentTypeReferenceFromID(e);if(n==null){this.context.errors.add({severity:U.Warning,message:`Environment "${e}" was not found`});return}return m.TypeInstantiation.reference(n)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:U.Warning,message:"The Go SDK doesn't support a multi-environment client option yet; use the baseUrl option instead"})}}getConstructorBearerAuthArg({auth:t,values:e}){return m.codeblock(n=>{n.writeNode(m.invokeFunc({func:m.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[m.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return m.codeblock(n=>{n.writeNode(m.invokeFunc({func:m.typeReference({name:`With${t.header.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.header.typeReference,value:e.value})]}))})}getConstructorHeaderArgs({headers:t,values:e}){let n=[];for(let i of t){let o=this.getConstructorHeaderArg({header:i,value:e.value});o!=null&&n.push(o)}return n}getConstructorHeaderArg({header:t,value:e}){let n=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!m.TypeInstantiation.isNop(n))return m.codeblock(i=>{i.writeNode(m.invokeFunc({func:m.typeReference({name:`With${t.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[n]}))})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e})}}getMethodArgsForBodyRequest({request:t,snippet:e}){let n=[];if(this.context.errors.scope(M.PathParameters),t.pathParameters!=null){let i=this.getPathParameters({namedParameters:t.pathParameters,snippet:e});n.push(...i.map(o=>o.value))}return this.context.errors.unscope(),this.context.errors.scope(M.RequestBody),t.body!=null&&n.push(this.getBodyRequestArg({body:t.body,value:e.requestBody})),this.context.errors.unscope(),n}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e})}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:U.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),m.TypeInstantiation.nop()):m.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){var s;let n=[];this.context.errors.scope(M.PathParameters);let i=[];t.pathParameters!=null&&i.push(...this.getPathParameters({namedParameters:t.pathParameters,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(M.RequestBody);let o=this.getFilePropertyInfo({request:t,snippet:e});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t})||n.push(...i.map(c=>c.value)),(s=this.context.customConfig)!=null&&s.inlineFileProperties||n.push(...o.fileFields.map(c=>c.value)),this.context.needsRequestParameter({request:t})&&n.push(this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t})?i:[],filePropertyInfo:o})),n}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArg({request:t,snippet:e,pathParameterFields:n,filePropertyInfo:i}){var d,l,v,A;this.context.errors.scope(M.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(d=t.queryParameters)!=null?d:[],values:(l=e.queryParameters)!=null?l:{}}).map(I=>({name:I.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(I)}));this.context.errors.unscope(),this.context.errors.scope(M.Headers);let f=this.context.associateByWireValue({parameters:(v=t.headers)!=null?v:[],values:(A=e.headers)!=null?A:{}}).map(I=>({name:I.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(I)}));this.context.errors.unscope(),this.context.errors.scope(M.RequestBody);let x=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),m.TypeInstantiation.structPointer({typeReference:m.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:[...n,...s,...f,...x]})}getInlinedRequestBodyStructFields({body:t,value:e,filePropertyInfo:n}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyStructFields({parameters:t.value,value:e});case"referenced":return[this.getReferencedRequestBodyPropertyStructField({body:t,value:e})];case"fileUpload":return this.getFileUploadRequestBodyStructFields({filePropertyInfo:n})}}getFileUploadRequestBodyStructFields({filePropertyInfo:t}){var e;return(e=this.context.customConfig)!=null&&e.inlineFileProperties?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyStructField({body:t,value:e}){return{name:this.context.getTypeName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeInstantiation({body:t.bodyType,value:e})}}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e})}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){var o;let n=[],i=this.context.associateByWireValue({parameters:t,values:(o=this.context.getRecord(e))!=null?o:{}});for(let s of i)n.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(s)});return n}getPathParameters({namedParameters:t,snippet:e}){var o;let n=[],i=this.context.associateByWireValue({parameters:t,values:(o=e.pathParameters)!=null?o:{}});for(let s of i)n.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(s)});return n}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getMethodName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}getRootClientFuncInvocation(t){return m.invokeFunc({func:m.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}newAuthMismatchError({auth:t,values:e}){return new Error(`Expected auth type ${t.type}, got ${e.type}`)}};0&&(module.exports={EndpointSnippetGenerator});
|
|
20
20
|
/*! Bundled license information:
|
|
21
21
|
|
|
22
22
|
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractFormatter } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
-
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-
|
|
2
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-f4OAff1R.cjs';
|
|
3
3
|
import { dynamic } from '@fern-fern/ir-sdk/api';
|
|
4
4
|
import '@fern-api/go-ast';
|
|
5
5
|
import './TypeInstance.cjs';
|
|
@@ -27,6 +27,8 @@ declare class EndpointSnippetGenerator {
|
|
|
27
27
|
private getConstructorArgs;
|
|
28
28
|
private getConstructorAuthArg;
|
|
29
29
|
private getConstructorBasicAuthArg;
|
|
30
|
+
private getConstructorBaseUrlArg;
|
|
31
|
+
private getBaseUrlArg;
|
|
30
32
|
private getConstructorBearerAuthArg;
|
|
31
33
|
private getConstructorHeaderAuthArg;
|
|
32
34
|
private getConstructorHeaderArgs;
|
package/cjs/Result.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-
|
|
1
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-f4OAff1R.cjs';
|
|
2
2
|
import { ErrorReporter } from './context/ErrorReporter.cjs';
|
|
3
3
|
import { dynamic } from '@fern-fern/ir-sdk/api';
|
|
4
4
|
import '@fern-api/browser-compatible-base-generator';
|