@fern-api/go-dynamic-snippets 0.0.15 → 0.0.16

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.
Files changed (69) hide show
  1. package/cjs/DynamicSnippetsGenerator.cjs +18 -10
  2. package/cjs/DynamicSnippetsGenerator.cjs.map +1 -0
  3. package/cjs/DynamicSnippetsGenerator.d.cts +4 -4
  4. package/cjs/{DynamicSnippetsGeneratorContext-CpOvS1wA.d.cts → DynamicSnippetsGeneratorContext-BusKoNq4.d.cts} +10 -1
  5. package/cjs/EndpointSnippetGenerator.cjs +19 -11
  6. package/cjs/EndpointSnippetGenerator.cjs.map +1 -0
  7. package/cjs/EndpointSnippetGenerator.d.cts +15 -4
  8. package/cjs/context/DynamicSnippetsGeneratorContext.cjs +18 -10
  9. package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -0
  10. package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +1 -1
  11. package/cjs/context/DynamicTypeInstantiationMapper.cjs +19 -11
  12. package/cjs/context/DynamicTypeInstantiationMapper.cjs.map +1 -0
  13. package/cjs/context/DynamicTypeInstantiationMapper.d.cts +1 -1
  14. package/cjs/context/DynamicTypeMapper.cjs +18 -10
  15. package/cjs/context/DynamicTypeMapper.cjs.map +1 -0
  16. package/cjs/context/DynamicTypeMapper.d.cts +1 -1
  17. package/cjs/context/FilePropertyMapper.cjs +18 -10
  18. package/cjs/context/FilePropertyMapper.cjs.map +1 -0
  19. package/cjs/context/FilePropertyMapper.d.cts +1 -1
  20. package/cjs/index.cjs +24 -28
  21. package/cjs/index.cjs.map +1 -0
  22. package/cjs/index.d.cts +2 -2
  23. package/esm/DynamicSnippetsGenerator.d.ts +4 -4
  24. package/esm/DynamicSnippetsGenerator.js +2 -1
  25. package/esm/DynamicSnippetsGenerator.js.map +1 -0
  26. package/esm/{DynamicSnippetsGeneratorContext-CpOvS1wA.d.ts → DynamicSnippetsGeneratorContext-BusKoNq4.d.ts} +10 -1
  27. package/esm/EndpointSnippetGenerator.d.ts +15 -4
  28. package/esm/EndpointSnippetGenerator.js +2 -1
  29. package/esm/EndpointSnippetGenerator.js.map +1 -0
  30. package/esm/chunk-2YRGTA73.js +2 -0
  31. package/esm/chunk-2YRGTA73.js.map +1 -0
  32. package/esm/chunk-BI26DLZ5.js +2 -0
  33. package/esm/chunk-BI26DLZ5.js.map +1 -0
  34. package/esm/chunk-D6NMQKNQ.js +2 -0
  35. package/esm/chunk-D6NMQKNQ.js.map +1 -0
  36. package/esm/chunk-FD44EP2P.js +2 -0
  37. package/esm/chunk-FD44EP2P.js.map +1 -0
  38. package/esm/chunk-GUJUKQKZ.js +37 -0
  39. package/esm/chunk-GUJUKQKZ.js.map +1 -0
  40. package/esm/chunk-Q6YO7G6Y.js +2 -0
  41. package/esm/chunk-Q6YO7G6Y.js.map +1 -0
  42. package/esm/chunk-UZEM7EUP.js +2 -0
  43. package/esm/chunk-UZEM7EUP.js.map +1 -0
  44. package/esm/chunk-VCNL2JWU.js +2 -0
  45. package/esm/chunk-VCNL2JWU.js.map +1 -0
  46. package/esm/context/DynamicSnippetsGeneratorContext.d.ts +1 -1
  47. package/esm/context/DynamicSnippetsGeneratorContext.js +2 -1
  48. package/esm/context/DynamicSnippetsGeneratorContext.js.map +1 -0
  49. package/esm/context/DynamicTypeInstantiationMapper.d.ts +1 -1
  50. package/esm/context/DynamicTypeInstantiationMapper.js +2 -1
  51. package/esm/context/DynamicTypeInstantiationMapper.js.map +1 -0
  52. package/esm/context/DynamicTypeMapper.d.ts +1 -1
  53. package/esm/context/DynamicTypeMapper.js +2 -1
  54. package/esm/context/DynamicTypeMapper.js.map +1 -0
  55. package/esm/context/FilePropertyMapper.d.ts +1 -1
  56. package/esm/context/FilePropertyMapper.js +2 -1
  57. package/esm/context/FilePropertyMapper.js.map +1 -0
  58. package/esm/index.d.ts +2 -2
  59. package/esm/index.js +2 -13
  60. package/esm/index.js.map +1 -0
  61. package/package.json +1 -1
  62. package/esm/chunk-55JFNSPF.js +0 -1
  63. package/esm/chunk-EQTG6W6V.js +0 -1
  64. package/esm/chunk-H7X5SHRQ.js +0 -1
  65. package/esm/chunk-IYOA724T.js +0 -1
  66. package/esm/chunk-LZIEHSJ7.js +0 -1
  67. package/esm/chunk-RX5QSNXP.js +0 -1
  68. package/esm/chunk-SX53R7DQ.js +0 -1
  69. package/esm/chunk-XL5OWIY6.js +0 -29
@@ -1,7 +1,7 @@
1
- import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, AbstractFormatter } from '@fern-api/browser-compatible-base-generator';
1
+ import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, AbstractFormatter, Options } from '@fern-api/browser-compatible-base-generator';
2
2
  import { FernIr } from '@fern-api/dynamic-ir-sdk';
3
+ import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-BusKoNq4.cjs';
3
4
  import { EndpointSnippetGenerator } from './EndpointSnippetGenerator.cjs';
4
- import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-CpOvS1wA.cjs';
5
5
  import '@fern-api/go-ast';
6
6
 
7
7
  declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
@@ -11,8 +11,8 @@ declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<
11
11
  config: FernGeneratorExec.GeneratorConfig;
12
12
  formatter?: AbstractFormatter;
13
13
  });
14
- generate(request: FernIr.dynamic.EndpointSnippetRequest): Promise<FernIr.dynamic.EndpointSnippetResponse>;
15
- generateSync(request: FernIr.dynamic.EndpointSnippetRequest): FernIr.dynamic.EndpointSnippetResponse;
14
+ generate(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): Promise<FernIr.dynamic.EndpointSnippetResponse>;
15
+ generateSync(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): FernIr.dynamic.EndpointSnippetResponse;
16
16
  protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
17
17
  }
18
18
 
@@ -16,9 +16,12 @@ declare class DynamicTypeInstantiationMapper {
16
16
  context: DynamicSnippetsGeneratorContext;
17
17
  });
18
18
  convert(args: DynamicTypeInstantiationMapper.Args): go.TypeInstantiation;
19
+ convertToPointerIfPossible(args: DynamicTypeInstantiationMapper.Args): go.TypeInstantiation;
19
20
  private convertList;
20
21
  private convertMap;
21
22
  private convertNamed;
23
+ private convertAlias;
24
+ private convertLiteralValue;
22
25
  private convertDiscriminatedUnion;
23
26
  private getBaseFields;
24
27
  private convertObject;
@@ -37,6 +40,7 @@ declare class DynamicTypeInstantiationMapper {
37
40
  private convertPrimitive;
38
41
  private getValueAsNumber;
39
42
  private getValueAsBoolean;
43
+ private normalizeDateTimeString;
40
44
  }
41
45
 
42
46
  declare namespace DynamicTypeMapper {
@@ -86,12 +90,16 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
86
90
  config: FernGeneratorExec.GeneratorConfig;
87
91
  });
88
92
  clone(): DynamicSnippetsGeneratorContext;
93
+ isOptional(typeReference: FernIr.dynamic.TypeReference): boolean;
89
94
  getMethodName(name: FernIr.Name): string;
95
+ getTestMethodName(endpoint: FernIr.dynamic.Endpoint): string;
90
96
  getTypeName(name: FernIr.Name): string;
91
- getImportPath(fernFilepath: FernIr.FernFilepath): string;
97
+ getImportPath(fernFilepath: FernIr.dynamic.FernFilepath): string;
98
+ getImportPathForRequest(fernFilepath: FernIr.dynamic.FernFilepath): string;
92
99
  getContextTypeReference(): go.TypeReference;
93
100
  getContextTodoFunctionInvocation(): go.FuncInvocation;
94
101
  getIoReaderTypeReference(): go.TypeReference;
102
+ getTestingTypeReference(): go.TypeReference;
95
103
  getNewStringsReaderFunctionInvocation(s: string): go.FuncInvocation;
96
104
  getClientConstructorName(): string;
97
105
  getClientName(): string;
@@ -102,6 +110,7 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
102
110
  }): go.TypeReference;
103
111
  getEnvironmentTypeReferenceFromID(environmentID: string): go.TypeReference | undefined;
104
112
  private getEnvironmentTypeReference;
113
+ static chainMethods(baseFunc: go.FuncInvocation, ...methods: Omit<go.MethodInvocation.Args, "on">[]): go.MethodInvocation;
105
114
  }
106
115
 
107
116
  export { DynamicSnippetsGeneratorContext as D, type FilePropertyInfo as F, DynamicTypeInstantiationMapper as a, DynamicTypeMapper as b, FilePropertyMapper as c };
@@ -1,22 +1,29 @@
1
- "use strict";var se=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var et=Object.prototype.hasOwnProperty;var tt=(r,t,e)=>t in r?se(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var ye=(r,t)=>()=>(r&&(t=r(r=0)),t);var Ee=(r,t)=>{for(var e in t)se(r,e,{get:t[e],enumerable:!0})},rt=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of je(t))!et.call(r,i)&&i!==e&&se(r,i,{get:()=>t[i],enumerable:!(n=Xe(t,i))||n.enumerable});return r};var nt=r=>rt(se({},"__esModule",{value:!0}),r);var h=(r,t,e)=>tt(r,typeof t!="symbol"?t+"":t,e);function Ne(){throw new Error("setTimeout has not been defined")}function Pe(){throw new Error("clearTimeout has not been defined")}function Fe(r){if(Y===setTimeout)return setTimeout(r,0);if((Y===Ne||!Y)&&setTimeout)return Y=setTimeout,setTimeout(r,0);try{return Y(r,0)}catch(t){try{return Y.call(null,r,0)}catch(e){return Y.call(this,r,0)}}}function it(r){if($===clearTimeout)return clearTimeout(r);if(($===Pe||!$)&&clearTimeout)return $=clearTimeout,clearTimeout(r);try{return $(r)}catch(t){try{return $.call(null,r)}catch(e){return $.call(this,r)}}}function ot(){!ee||!O||(ee=!1,O.length?L=O.concat(L):ae=-1,L.length&&Se())}function Se(){if(!ee){var r=Fe(ot);ee=!0;for(var t=L.length;t;){for(O=L,L=[];++ae<t;)O&&O[ae].run();ae=-1,t=L.length}O=null,ee=!1,it(r)}}function st(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];L.push(new Be(r,t)),L.length===1&&!ee&&Fe(Se)}function Be(r,t){this.fun=r,this.array=t}function W(){}function vt(r){throw new Error("process.binding is not supported")}function Et(){return"/"}function Rt(r){throw new Error("process.chdir is not supported")}function Nt(){return 0}function Ft(r){var t=Pt.call(j)*.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-St;return t/1e3}var Y,$,L,ee,O,ae,at,ut,ct,pt,ht,ft,lt,mt,dt,yt,wt,xt,gt,At,It,Tt,j,Pt,St,w,Re,u=ye(()=>{"use strict";Y=Ne,$=Pe;typeof globalThis.setTimeout=="function"&&(Y=setTimeout);typeof globalThis.clearTimeout=="function"&&($=clearTimeout);L=[],ee=!1,ae=-1;Be.prototype.run=function(){this.fun.apply(null,this.array)};at="browser",ut="browser",ct=!0,pt={},ht=[],ft="",lt={},mt={},dt={};yt=W,wt=W,xt=W,gt=W,At=W,It=W,Tt=W;j=globalThis.performance||{},Pt=j.now||j.mozNow||j.msNow||j.oNow||j.webkitNow||function(){return new Date().getTime()};St=new Date;w={nextTick:st,title:at,browser:ct,env:pt,argv:ht,version:ft,versions:lt,on:yt,addListener:wt,once:xt,off:gt,removeListener:At,removeAllListeners:It,emit:Tt,binding:vt,cwd:Et,chdir:Rt,umask:Nt,hrtime:Ft,platform:ut,release:mt,config:dt,uptime:Bt},Re={};Object.keys(Re).forEach(r=>{let t=r.split("."),e=w;for(let n=0;n<t.length;n++){let i=t[n];n===t.length-1?e[i]=Re[r]:e=e[i]||(e[i]={})}})});function Ce(){xe=!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 kt(r){xe||Ce();var t,e,n,i,o,s,p=r.length;if(p%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=r[p-2]==="="?2:r[p-1]==="="?1:0,s=new bt(p*3/4-o),n=o>0?p-4:p;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 _t(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(_t(n));return i.join("")}function be(r){xe||Ce();for(var t,e=r.length,n=e%3,i="",o=[],s=16383,p=0,f=e-n;p<f;p+=s)o.push(Ct(r,p,p+s>f?f:p+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 ue(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function M(r,t){if(ue()<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 ge(this,r)}return Ue(this,r,t,e)}function Ue(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"?Lt(r,t,e):qt(r,t)}function Le(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 Ut(r,t,e,n){return Le(t),t<=0?M(r,t):e!==void 0?typeof n=="string"?M(r,t).fill(e,n):M(r,t).fill(e):M(r,t)}function ge(r,t){if(Le(t),r=M(r,t<0?0:Ae(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)r[e]=0;return r}function Lt(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=Me(t,e)|0;r=M(r,n);var i=r.write(t,e);return i!==n&&(r=r.slice(0,i)),r}function we(r,t){var e=t.length<0?0:Ae(t.length)|0;r=M(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=we(r,t),r}function qt(r,t){if(k(t)){var e=Ae(t.length)|0;return r=M(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"||nr(t.length)?M(r,0):we(r,t);if(t.type==="Buffer"&&Array.isArray(t.data))return we(r,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Ae(r){if(r>=ue())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ue().toString(16)+" bytes");return r|0}function k(r){return!!(r!=null&&r._isBuffer)}function Me(r,t){if(k(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 ce(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ve(r).length;default:if(n)return ce(r).length;t=(""+t).toLowerCase(),n=!0}}function Dt(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 Ye(this,t,e);case"ascii":return Jt(this,t,e);case"latin1":case"binary":return Kt(this,t,e);case"base64":return Gt(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 V(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function qe(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)),k(t))return t.length===0?-1:ke(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):ke(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function ke(r,t,e,n,i){var o=1,s=r.length,p=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,p/=2,e/=2}function f(g,T){return o===1?g[T]:g.readUInt16BE(T*o)}var y;if(i){var d=-1;for(y=e;y<s;y++)if(f(r,y)===f(t,d===-1?0:y-d)){if(d===-1&&(d=y),y-d+1===p)return d*o}else d!==-1&&(y-=y-d),d=-1}else for(e+p>s&&(e=s-p),y=e;y>=0;y--){for(var l=!0,I=0;I<p;I++)if(f(r,y+I)!==f(t,I)){l=!1;break}if(l)return y}return-1}function Yt(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 p=parseInt(t.substr(s*2,2),16);if(isNaN(p))return s;r[e+s]=p}return s}function $t(r,t,e,n){return fe(ce(t,r.length-e),r,e,n)}function De(r,t,e,n){return fe(tr(t),r,e,n)}function Ot(r,t,e,n){return De(r,t,e,n)}function Wt(r,t,e,n){return fe(Ve(t),r,e,n)}function Vt(r,t,e,n){return fe(rr(t,r.length-e),r,e,n)}function Gt(r,t,e){return t===0&&e===r.length?be(r):be(r.slice(t,e))}function Ye(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i<e;){var o=r[i],s=null,p=o>239?4:o>223?3:o>191?2:1;if(i+p<=e){var f,y,d,l;switch(p){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],d=r[i+3],(f&192)===128&&(y&192)===128&&(d&192)===128&&(l=(o&15)<<18|(f&63)<<12|(y&63)<<6|d&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,p=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=p}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 Jt(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 Kt(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+=er(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 A(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(!k(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 pe(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 he(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 $e(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 Oe(r,t,e,n,i){return i||$e(r,t,e,4,34028234663852886e22,-34028234663852886e22),He(r,t,e,n,23,4),e+4}function We(r,t,e,n,i){return i||$e(r,t,e,8,17976931348623157e292,-17976931348623157e292),He(r,t,e,n,52,8),e+8}function Xt(r){if(r=jt(r).replace(Zt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function jt(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function er(r){return r<16?"0"+r.toString(16):r.toString(16)}function ce(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 tr(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function rr(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 Ve(r){return kt(Xt(r))}function fe(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 nr(r){return r!==r}function ir(r){return r!=null&&(!!r._isBuffer||Ge(r)||or(r))}function Ge(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function or(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&Ge(r.slice(0,0))}function le(r,t,e,n,i){var o,s,p=i*8-n-1,f=(1<<p)-1,y=f>>1,d=-7,l=e?i-1:0,I=e?-1:1,g=r[t+l];for(l+=I,o=g&(1<<-d)-1,g>>=-d,d+=p;d>0;o=o*256+r[t+l],l+=I,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=n;d>0;s=s*256+r[t+l],l+=I,d-=8);if(o===0)o=1-y;else{if(o===f)return s?NaN:(g?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-y}return(g?-1:1)*s*Math.pow(2,o-n)}function He(r,t,e,n,i,o){var s,p,f,y=o*8-i-1,d=(1<<y)-1,l=d>>1,I=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:o-1,T=n?1:-1,te=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(p=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+=I/f:t+=I*Math.pow(2,1-l),t*f>=2&&(s++,f/=2),s+l>=d?(p=0,s=d):s+l>=1?(p=(t*f-1)*Math.pow(2,i),s=s+l):(p=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;r[e+g]=p&255,g+=T,p/=256,i-=8);for(s=s<<i|p,y+=i;y>0;r[e+g]=s&255,g+=T,s/=256,y-=8);r[e+g-T]|=te*128}var b,R,bt,xe,_e,Zt,Je=ye(()=>{"use strict";u();c();b=[],R=[],bt=typeof Uint8Array!="undefined"?Uint8Array:Array,xe=!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 Ue(null,r,t,e)};a.kMaxLength=ue();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 Ut(null,r,t,e)};a.allocUnsafe=function(r){return ge(null,r)};a.allocUnsafeSlow=function(r){return ge(null,r)};a.isBuffer=ir;a.compare=function(t,e){if(!k(t)||!k(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(!k(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=Me;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)V(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)V(this,e,e+3),V(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)V(this,e,e+7),V(this,e+1,e+6),V(this,e+2,e+5),V(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Ye(this,0,t):Dt.apply(this,arguments)};a.prototype.equals=function(t){if(!k(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(!k(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,p=n-e,f=Math.min(s,p),y=this.slice(i,o),d=t.slice(e,n),l=0;l<f;++l)if(y[l]!==d[l]){s=y[l],p=d[l];break}return s<p?-1:p<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 qe(this,t,e,n,!0)};a.prototype.lastIndexOf=function(t,e,n){return qe(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 Yt(this,t,e,n);case"utf8":case"utf-8":return $t(this,t,e,n);case"ascii":return De(this,t,e,n);case"latin1":case"binary":return Ot(this,t,e,n);case"base64":return Wt(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vt(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||A(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||A(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||A(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||A(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||A(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||A(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||A(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||A(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||A(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||A(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||A(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||A(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||A(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||A(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||A(t,4,this.length),le(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||A(t,4,this.length),le(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||A(t,8,this.length),le(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||A(t,8,this.length),le(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,p=0;for(this[e]=t&255;++p<n&&(s*=256);)this[e+p]=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,p=1;for(this[e+s]=t&255;--s>=0&&(p*=256);)this[e+s]=t/p&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):pe(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):pe(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):he(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):he(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,p=1,f=0;for(this[e]=t&255;++s<n&&(p*=256);)t<0&&f===0&&this[e+s-1]!==0&&(f=1),this[e+s]=(t/p>>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,p=1,f=0;for(this[e+s]=t&255;--s>=0&&(p*=256);)t<0&&f===0&&this[e+s+1]!==0&&(f=1),this[e+s]=(t/p>>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):pe(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):pe(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):he(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):he(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,n){return Oe(this,t,e,!0,n)};a.prototype.writeFloatBE=function(t,e,n){return Oe(this,t,e,!1,n)};a.prototype.writeDoubleLE=function(t,e,n){return We(this,t,e,!0,n)};a.prototype.writeDoubleBE=function(t,e,n){return We(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 p=k(t)?t:ce(new a(t,i).toString()),f=p.length;for(s=0;s<n-e;++s)this[s+e]=p[s%f]}return this};Zt=/[^+\/0-9A-Za-z-_]/g});var c=ye(()=>{"use strict";Je()});var _r={};Ee(_r,{EndpointSnippetGenerator:()=>ve});module.exports=nt(_r);u();c();u();c();u();c();function S(r){throw new Error("Unexpected value: "+JSON.stringify(r))}u();c();u();c();var G=class{};u();c();u();c();var _=class extends G{constructor(e){super();h(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var sr=4,re=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
- `),n=e?t.substring(0,t.length-1):t,i=this.getIndentString(),o=n.replaceAll(`
1
+ "use strict";var Te=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var vt=Object.prototype.hasOwnProperty;var Nt=(n,t,e)=>t in n?Te(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var _e=(n,t)=>()=>(n&&(t=n(n=0)),t);var Ve=(n,t)=>{for(var e in t)Te(n,e,{get:t[e],enumerable:!0})},kt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of It(t))!vt.call(n,i)&&i!==e&&Te(n,i,{get:()=>t[i],enumerable:!(r=At(t,i))||r.enumerable});return n};var Et=n=>kt(Te({},"__esModule",{value:!0}),n);var c=(n,t,e)=>Nt(n,typeof t!="symbol"?t+"":t,e);function He(){throw new Error("setTimeout has not been defined")}function Ke(){throw new Error("clearTimeout has not been defined")}function je(n){if(Y===setTimeout)return setTimeout(n,0);if((Y===He||!Y)&&setTimeout)return Y=setTimeout,setTimeout(n,0);try{return Y(n,0)}catch(t){try{return Y.call(null,n,0)}catch(e){return Y.call(this,n,0)}}}function Rt(n){if(V===clearTimeout)return clearTimeout(n);if((V===Ke||!V)&&clearTimeout)return V=clearTimeout,clearTimeout(n);try{return V(n)}catch(t){try{return V.call(null,n)}catch(e){return V.call(this,n)}}}function bt(){!ce||!H||(ce=!1,H.length?M=H.concat(M):Ae=-1,M.length&&Je())}function Je(){if(!ce){var n=je(bt);ce=!0;for(var t=M.length;t;){for(H=M,M=[];++Ae<t;)H&&H[Ae].run();Ae=-1,t=M.length}H=null,ce=!1,Rt(n)}}function St(n){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];M.push(new ze(n,t)),M.length===1&&!ce&&je(Je)}function ze(n,t){this.fun=n,this.array=t}function K(){}function Ht(n){throw new Error("process.binding is not supported")}function Kt(){return"/"}function jt(n){throw new Error("process.chdir is not supported")}function Jt(){return 0}function Qt(n){var t=zt.call(ae)*.001,e=Math.floor(t),r=Math.floor(t%1*1e9);return n&&(e=e-n[0],r=r-n[1],r<0&&(e--,r+=1e9)),[e,r]}function Xt(){var n=new Date,t=n-Zt;return t/1e3}var Y,V,M,ce,H,Ae,Ft,Pt,Ct,_t,Bt,Lt,Mt,Ut,Wt,qt,$t,Dt,Ot,Yt,Vt,Gt,ae,zt,Zt,g,Ge,u=_e(()=>{"use strict";Y=He,V=Ke;typeof globalThis.setTimeout=="function"&&(Y=setTimeout);typeof globalThis.clearTimeout=="function"&&(V=clearTimeout);M=[],ce=!1,Ae=-1;ze.prototype.run=function(){this.fun.apply(null,this.array)};Ft="browser",Pt="browser",Ct=!0,_t={},Bt=[],Lt="",Mt={},Ut={},Wt={};qt=K,$t=K,Dt=K,Ot=K,Yt=K,Vt=K,Gt=K;ae=globalThis.performance||{},zt=ae.now||ae.mozNow||ae.msNow||ae.oNow||ae.webkitNow||function(){return new Date().getTime()};Zt=new Date;g={nextTick:St,title:Ft,browser:Ct,env:_t,argv:Bt,version:Lt,versions:Mt,on:qt,addListener:$t,once:Dt,off:Ot,removeListener:Yt,removeAllListeners:Vt,emit:Gt,binding:Ht,cwd:Kt,chdir:jt,umask:Jt,hrtime:Qt,platform:Pt,release:Ut,config:Wt,uptime:Xt},Ge={};Object.keys(Ge).forEach(n=>{let t=n.split("."),e=g;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=Ge[n]:e=e[i]||(e[i]={})}})});function et(){Le=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)P[t]=n[t],R[n.charCodeAt(t)]=t;R[45]=62,R[95]=63}function tr(n){Le||et();var t,e,r,i,o,s,h=n.length;if(h%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=n[h-2]==="="?2:n[h-1]==="="?1:0,s=new er(h*3/4-o),r=o>0?h-4:h;var l=0;for(t=0,e=0;t<r;t+=4,e+=3)i=R[n.charCodeAt(t)]<<18|R[n.charCodeAt(t+1)]<<12|R[n.charCodeAt(t+2)]<<6|R[n.charCodeAt(t+3)],s[l++]=i>>16&255,s[l++]=i>>8&255,s[l++]=i&255;return o===2?(i=R[n.charCodeAt(t)]<<2|R[n.charCodeAt(t+1)]>>4,s[l++]=i&255):o===1&&(i=R[n.charCodeAt(t)]<<10|R[n.charCodeAt(t+1)]<<4|R[n.charCodeAt(t+2)]>>2,s[l++]=i>>8&255,s[l++]=i&255),s}function rr(n){return P[n>>18&63]+P[n>>12&63]+P[n>>6&63]+P[n&63]}function nr(n,t,e){for(var r,i=[],o=t;o<e;o+=3)r=(n[o]<<16)+(n[o+1]<<8)+n[o+2],i.push(rr(r));return i.join("")}function Qe(n){Le||et();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,h=0,l=e-r;h<l;h+=s)o.push(nr(n,h,h+s>l?l:h+s));return r===1?(t=n[e-1],i+=P[t>>2],i+=P[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=P[t>>10],i+=P[t>>4&63],i+=P[t<<2&63],i+="="),o.push(i),o.join("")}function Ie(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function U(n,t){if(Ie()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(t),n.__proto__=a.prototype):(n===null&&(n=new a(t)),n.length=t),n}function a(n,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(n,t,e);if(typeof n=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return Me(this,n)}return tt(this,n,t,e)}function tt(n,t,e,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?sr(n,t,e,r):typeof t=="string"?or(n,t,e):ar(n,t)}function rt(n){if(typeof n!="number")throw new TypeError('"size" argument must be a number');if(n<0)throw new RangeError('"size" argument must not be negative')}function ir(n,t,e,r){return rt(t),t<=0?U(n,t):e!==void 0?typeof r=="string"?U(n,t).fill(e,r):U(n,t).fill(e):U(n,t)}function Me(n,t){if(rt(t),n=U(n,t<0?0:Ue(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function or(n,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=nt(t,e)|0;n=U(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Be(n,t){var e=t.length<0?0:Ue(t.length)|0;n=U(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function sr(n,t,e,r){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(r||0))throw new RangeError("'length' is out of bounds");return e===void 0&&r===void 0?t=new Uint8Array(t):r===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,r),a.TYPED_ARRAY_SUPPORT?(n=t,n.__proto__=a.prototype):n=Be(n,t),n}function ar(n,t){if(C(t)){var e=Ue(t.length)|0;return n=U(n,e),n.length===0||t.copy(n,0,0,e),n}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||Er(t.length)?U(n,0):Be(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Be(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Ue(n){if(n>=Ie())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ie().toString(16)+" bytes");return n|0}function C(n){return!!(n!=null&&n._isBuffer)}function nt(n,t){if(C(n))return n.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(n)||n instanceof ArrayBuffer))return n.byteLength;typeof n!="string"&&(n=""+n);var e=n.length;if(e===0)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return ve(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return pt(n).length;default:if(r)return ve(n).length;t=(""+t).toLowerCase(),r=!0}}function cr(n,t,e){var r=!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(n||(n="utf8");;)switch(n){case"hex":return wr(this,t,e);case"utf8":case"utf-8":return st(this,t,e);case"ascii":return yr(this,t,e);case"latin1":case"binary":return gr(this,t,e);case"base64":return dr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xr(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function j(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function it(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,r)),C(t))return t.length===0?-1:Ze(n,t,e,r,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):Ze(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function Ze(n,t,e,r,i){var o=1,s=n.length,h=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(n.length<2||t.length<2)return-1;o=2,s/=2,h/=2,e/=2}function l(T,A){return o===1?T[A]:T.readUInt16BE(A*o)}var m;if(i){var d=-1;for(m=e;m<s;m++)if(l(n,m)===l(t,d===-1?0:m-d)){if(d===-1&&(d=m),m-d+1===h)return d*o}else d!==-1&&(m-=m-d),d=-1}else for(e+h>s&&(e=s-h),m=e;m>=0;m--){for(var y=!0,x=0;x<h;x++)if(l(n,m+x)!==l(t,x)){y=!1;break}if(y)return m}return-1}function ur(n,t,e,r){e=Number(e)||0;var i=n.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var h=parseInt(t.substr(s*2,2),16);if(isNaN(h))return s;n[e+s]=h}return s}function pr(n,t,e,r){return Ee(ve(t,n.length-e),n,e,r)}function ot(n,t,e,r){return Ee(Nr(t),n,e,r)}function hr(n,t,e,r){return ot(n,t,e,r)}function fr(n,t,e,r){return Ee(pt(t),n,e,r)}function lr(n,t,e,r){return Ee(kr(t,n.length-e),n,e,r)}function dr(n,t,e){return t===0&&e===n.length?Qe(n):Qe(n.slice(t,e))}function st(n,t,e){e=Math.min(n.length,e);for(var r=[],i=t;i<e;){var o=n[i],s=null,h=o>239?4:o>223?3:o>191?2:1;if(i+h<=e){var l,m,d,y;switch(h){case 1:o<128&&(s=o);break;case 2:l=n[i+1],(l&192)===128&&(y=(o&31)<<6|l&63,y>127&&(s=y));break;case 3:l=n[i+1],m=n[i+2],(l&192)===128&&(m&192)===128&&(y=(o&15)<<12|(l&63)<<6|m&63,y>2047&&(y<55296||y>57343)&&(s=y));break;case 4:l=n[i+1],m=n[i+2],d=n[i+3],(l&192)===128&&(m&192)===128&&(d&192)===128&&(y=(o&15)<<18|(l&63)<<12|(m&63)<<6|d&63,y>65535&&y<1114112&&(s=y))}}s===null?(s=65533,h=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=h}return mr(r)}function mr(n){var t=n.length;if(t<=Xe)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=Xe));return e}function yr(n,t,e){var r="";e=Math.min(n.length,e);for(var i=t;i<e;++i)r+=String.fromCharCode(n[i]&127);return r}function gr(n,t,e){var r="";e=Math.min(n.length,e);for(var i=t;i<e;++i)r+=String.fromCharCode(n[i]);return r}function wr(n,t,e){var r=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>r)&&(e=r);for(var i="",o=t;o<e;++o)i+=vr(n[o]);return i}function xr(n,t,e){for(var r=n.slice(t,e),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+r[o+1]*256);return i}function I(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}function E(n,t,e,r,i,o){if(!C(n))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+r>n.length)throw new RangeError("Index out of range")}function Ne(n,t,e,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(n.length-e,2);i<o;++i)n[e+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}function ke(n,t,e,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(n.length-e,4);i<o;++i)n[e+i]=t>>>(r?i:3-i)*8&255}function at(n,t,e,r,i,o){if(e+r>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ct(n,t,e,r,i){return i||at(n,t,e,4,34028234663852886e22,-34028234663852886e22),ft(n,t,e,r,23,4),e+4}function ut(n,t,e,r,i){return i||at(n,t,e,8,17976931348623157e292,-17976931348623157e292),ft(n,t,e,r,52,8),e+8}function Ar(n){if(n=Ir(n).replace(Tr,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Ir(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function vr(n){return n<16?"0"+n.toString(16):n.toString(16)}function ve(n,t){t=t||1/0;for(var e,r=n.length,i=null,o=[],s=0;s<r;++s){if(e=n.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===r){(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 Nr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function kr(n,t){for(var e,r,i,o=[],s=0;s<n.length&&!((t-=2)<0);++s)e=n.charCodeAt(s),r=e>>8,i=e%256,o.push(i),o.push(r);return o}function pt(n){return tr(Ar(n))}function Ee(n,t,e,r){for(var i=0;i<r&&!(i+e>=t.length||i>=n.length);++i)t[i+e]=n[i];return i}function Er(n){return n!==n}function Rr(n){return n!=null&&(!!n._isBuffer||ht(n)||br(n))}function ht(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function br(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&ht(n.slice(0,0))}function Re(n,t,e,r,i){var o,s,h=i*8-r-1,l=(1<<h)-1,m=l>>1,d=-7,y=e?i-1:0,x=e?-1:1,T=n[t+y];for(y+=x,o=T&(1<<-d)-1,T>>=-d,d+=h;d>0;o=o*256+n[t+y],y+=x,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=s*256+n[t+y],y+=x,d-=8);if(o===0)o=1-m;else{if(o===l)return s?NaN:(T?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-m}return(T?-1:1)*s*Math.pow(2,o-r)}function ft(n,t,e,r,i,o){var s,h,l,m=o*8-i-1,d=(1<<m)-1,y=d>>1,x=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=r?0:o-1,A=r?1:-1,G=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(h=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+y>=1?t+=x/l:t+=x*Math.pow(2,1-y),t*l>=2&&(s++,l/=2),s+y>=d?(h=0,s=d):s+y>=1?(h=(t*l-1)*Math.pow(2,i),s=s+y):(h=t*Math.pow(2,y-1)*Math.pow(2,i),s=0));i>=8;n[e+T]=h&255,T+=A,h/=256,i-=8);for(s=s<<i|h,m+=i;m>0;n[e+T]=s&255,T+=A,s/=256,m-=8);n[e+T-A]|=G*128}var P,R,er,Le,Xe,Tr,lt=_e(()=>{"use strict";u();p();P=[],R=[],er=typeof Uint8Array!="undefined"?Uint8Array:Array,Le=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(n){return n.__proto__=a.prototype,n};a.from=function(n,t,e){return tt(null,n,t,e)};a.kMaxLength=Ie();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(n,t,e){return ir(null,n,t,e)};a.allocUnsafe=function(n){return Me(null,n)};a.allocUnsafeSlow=function(n){return Me(null,n)};a.isBuffer=Rr;a.compare=function(t,e){if(!C(t)||!C(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);o<s;++o)if(t[o]!==e[o]){r=t[o],i=e[o];break}return r<i?-1:i<r?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 r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=a.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!C(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=nt;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)j(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)j(this,e,e+3),j(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)j(this,e,e+7),j(this,e+1,e+6),j(this,e+2,e+5),j(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?st(this,0,t):cr.apply(this,arguments)};a.prototype.equals=function(t){if(!C(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,r,i,o){if(!C(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||r>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=r)return 0;if(i>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var s=o-i,h=r-e,l=Math.min(s,h),m=this.slice(i,o),d=t.slice(e,r),y=0;y<l;++y)if(m[y]!==d[y]){s=m[y],h=d[y];break}return s<h?-1:h<s?1:0};a.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};a.prototype.indexOf=function(t,e,r){return it(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return it(this,t,e,r,!1)};a.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(r)?(r=r|0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<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 ur(this,t,e,r);case"utf8":case"utf-8":return pr(this,t,e,r);case"ascii":return ot(this,t,e,r);case"latin1":case"binary":return hr(this,t,e,r);case"base64":return fr(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return lr(this,t,e,r);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)}};Xe=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),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,r){t=t|0,e=e|0,r||I(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,r){t=t|0,e=e|0,r||I(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||I(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||I(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||I(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||I(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||I(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,r){t=t|0,e=e|0,r||I(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,r){t=t|0,e=e|0,r||I(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||I(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||I(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};a.prototype.readInt16BE=function(t,e){e||I(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};a.prototype.readInt32LE=function(t,e){return e||I(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||I(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||I(t,4,this.length),Re(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||I(t,4,this.length),Re(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||I(t,8,this.length),Re(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||I(t,8,this.length),Re(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;E(this,t,e,r,o,0)}var s=1,h=0;for(this[e]=t&255;++h<r&&(s*=256);)this[e+h]=t/s&255;return e+r};a.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;E(this,t,e,r,o,0)}var s=r-1,h=1;for(this[e+s]=t&255;--s>=0&&(h*=256);)this[e+s]=t/h&255;return e+r};a.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||E(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,r){return t=+t,e=e|0,r||E(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):Ne(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):Ne(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||E(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):ke(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||E(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):ke(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);E(this,t,e,r,o-1,-o)}var s=0,h=1,l=0;for(this[e]=t&255;++s<r&&(h*=256);)t<0&&l===0&&this[e+s-1]!==0&&(l=1),this[e+s]=(t/h>>0)-l&255;return e+r};a.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);E(this,t,e,r,o-1,-o)}var s=r-1,h=1,l=0;for(this[e+s]=t&255;--s>=0&&(h*=256);)t<0&&l===0&&this[e+s+1]!==0&&(l=1),this[e+s]=(t/h>>0)-l&255;return e+r};a.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||E(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,r){return t=+t,e=e|0,r||E(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):Ne(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):Ne(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||E(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):ke(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||E(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):ke(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return ct(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return ct(this,t,e,!1,r)};a.prototype.writeDoubleLE=function(t,e,r){return ut(this,t,e,!0,r)};a.prototype.writeDoubleBE=function(t,e,r){return ut(this,t,e,!1,r)};a.prototype.copy=function(t,e,r,i){if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=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-r&&(i=t.length-e+r);var o=i-r,s;if(this===t&&r<e&&e<i)for(s=o-1;s>=0;--s)t[s+e]=this[s+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o};a.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=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<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<r;++s)this[s]=t;else{var h=C(t)?t:ve(new a(t,i).toString()),l=h.length;for(s=0;s<r-e;++s)this[s+e]=h[s%l]}return this};Tr=/[^+\/0-9A-Za-z-_]/g});var p=_e(()=>{"use strict";lt()});var fn={};Ve(fn,{EndpointSnippetGenerator:()=>Ye});module.exports=Et(fn);u();p();u();p();u();p();function b(n){throw new Error("Unexpected value: "+JSON.stringify(n))}u();p();u();p();u();p();var dt,mt,fe=(mt=(dt=g.env.FERN_STACK_TRACK)==null?void 0:dt.toLowerCase())!=null?mt:"",_=fe!==""&&fe!=="0"&&fe!=="false",We=["single","multiline","box"].includes(fe)?fe:"single";_&&(Error.stackTraceLimit=50);var Sr=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Fr=new Set(["stacktrace"]);function Se({maxFrames:n=50,skip:t=0,filterPaths:e=[],filterFunctions:r=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,formatFilename:h=l=>l}={}){var m;if(!_)return[];r=[...r,...Sr],e=[...e,...Fr],i=[...i,"runInteractiveTask"];let l=!1;return((m=new Error().stack)!=null?m:"").split(`
2
+ `).map(d=>{let y=d.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(y&&y.length===5){let[,x,T,A,G]=y;if(!x||!T||!A||!G)return;if(l||i.some(he=>x==null?void 0:x.includes(he))){l=!0;return}switch(x){case"Object.<anonymous>":x="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":x=`${x.substring(x.indexOf(".")+1)}()=> { ... }`;break}return{fn:x,path:h(T),position:`${A}:${G}`}}}).filter(d=>{var y,x;return d&&!r.some(T=>d.fn.includes(T))&&!(o&&((y=d.path)!=null&&y.startsWith("node:")))&&!(s&&((x=d.path)!=null&&x.endsWith(".js")))&&!e.some(T=>d.path.includes(T))}).slice(t,t+n)}var be=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:r=[],filterFunctions:i=[],stopOn:o=[],filterNode:s=!0,filterJs:h=!0,multiline:l=!1,formatFilename:m=d=>d}={}){c(this,"maxFrames");c(this,"skip");c(this,"filterPaths");c(this,"filterFunctions");c(this,"stopOn");c(this,"filterNode");c(this,"filterJs");c(this,"multiline");c(this,"formatFilename");c(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=r,this.filterFunctions=i,this.stopOn=o,this.filterNode=s,this.filterJs=h,this.multiline=l,this.formatFilename=m}tag(t){let e=this.tracking.get(t)||new Set;Se({maxFrames:this.maxFrames,skip:this.skip,filterPaths:this.filterPaths,filterFunctions:this.filterFunctions,stopOn:this.stopOn,filterNode:this.filterNode,filterJs:this.filterJs,formatFilename:this.formatFilename}).forEach(r=>e.add(r)),this.tracking.set(t,e)}trace(t){if(!_)return"";let e=this.tracking.get(t);return e?[...e].map(r=>`${this.multiline?`
3
+ `:""}${r.fn} - ${r.path}:${r.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},W;function yt({maxFrames:n=50,skip:t=0,filterPaths:e=[],filterFunctions:r=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,multiline:h=!1,formatFilename:l=m=>m}={}){_&&(W!=null||(W=new be({maxFrames:n,skip:t,filterPaths:e,filterFunctions:r,stopOn:i,filterNode:o,filterJs:s,multiline:h,formatFilename:l})))}function gt(n){W==null||W.tag(n)}function qe(n){var t;return(t=W==null?void 0:W.frames(n))!=null?t:[]}var J=class{constructor(){gt(this)}};u();p();var Fe=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},le=class extends Fe{async format(t){return t}formatSync(t){return t}};u();p();u();p();u();p();var S=class extends J{constructor(e){super();c(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):typeof this.value=="function"?this.value(e):this.value.write(e)}};var Pr=4;yt({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var de=class{constructor(){c(this,"lineBuffer",[]);c(this,"indentLevel",0);c(this,"hasWrittenAnything",!1);c(this,"lastCharacterIsSemicolon",!1);c(this,"lastCharacterIsNewline",!1);c(this,"nodeStackFrames",[])}get buffer(){return _&&this.nodeStackFrames.length>0&&this.writeInternal(`
4
+ `),this.lineBuffer.join(`
5
+ `)+(this.lastCharacterIsNewline?`
6
+ `:"")}write(...t){for(let e of t)if(e!=null)if(typeof e=="string"){let r=e.length>0&&e.endsWith(`
7
+ `),i=r?e.substring(0,e.length-1):e,o=this.getIndentString(),s=i.replaceAll(`
3
8
  `,`
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)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new _(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new _(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new _(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}alternativeControlFlow(t){this.dedent(),this.write("} "),new _(t).write(this),this.write(" {"),this.writeNewLineIfLastLineNot(),this.indent()}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
- `)}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
7
- `)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:n}){if(t.length>0){let i=t[0];i!=null&&n(i);for(let o=1;o<t.length;o++){this.write(e);let s=t[o];s!=null&&n(s)}}}toString(){return this.buffer}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*sr)}};u();c();var me=class{},ne=class extends me{async format(t){return t}formatSync(t){return t}};u();c();function Ie(r){return(r==null?void 0:r.name)!=null}u();c();u();c();var N={Critical:"CRITICAL",Warning:"WARNING"};u();c();var C={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};u();c();u();c();function Te(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}u();c();u();c();u();c();u();c();u();c();u();c();var ar=/[^0-9a-zA-Z_]/g,H=class extends re{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 ne}addImport(e){let n=this.imports[e];if(n!=null)return n;let i=new Set(Object.values(this.imports)),o=this.getValidAlias(Te(e));for(;i.has(o);)o="_"+o;return this.imports[e]=o,o}getValidAlias(e){let n=e.split("-");return n[0]==null?e:n[0].replace(ar,"")}};var ie=class extends H{constructor({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o}){super({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o})}async toStringAsync(){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
+ ${o}`);this.isAtStartOfLine()&&(s=o+s),r&&(s+=`
10
+ `),this.writeInternal(s)}else this.writeNode(e)}writeStatement(...t){this.write(...t),this.write(";"),this.writeNewLineIfLastLineNot()}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){_&&this.nodeStackFrames.push(...qe(t)),t.write(this),_&&We!=="single"&&this.writeInternal(`
11
+ `)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){this.writeNode(t),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new S(t).write(this),t.endsWith(";")||this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new S(t).write(this),this.write(" (",e,")"),this.pushScope()}controlFlowWithoutStatement(t){new S(t).write(this),this.pushScope()}endControlFlow(){this.popScope()}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new S(t).write(this),this.write(" (",e,")"),this.pushScope()}alternativeControlFlow(t){this.dedent(),this.write("} "),new S(t).write(this),this.pushScope()}pushScope(){this.writeLine("{"),this.indent()}popScope(t=!0){this.dedent(),this.writeNewLineIfLastLineNot(),t?this.writeLine("}"):this.write("}")}writeLine(...t){this.write(...t.length===0?[""]:t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
12
+ `)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
13
+ `)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:r}){if(t.length>0){let i=t[0];i!=null&&r(i);for(let o=1;o<t.length;o++){this.write(e);let s=t[o];s!=null&&r(s)}}}toString(){return this.buffer}writeInternal(t){if(t.length===0)return;let e=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
14
+ `),this.lastCharacterIsSemicolon=t.endsWith(";");let r=t.split(`
15
+ `),i=_&&!this.shouldSkipTracking(r)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${r.shift()||""}`),this.lastCharacterIsNewline&&r.pop(),this.lineBuffer.push(...r),i&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(r=>`${e?`(${e}) `:""} ${r.fn} - ${r.path} : ${r.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(Se({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,We){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return Pr}};u();p();u();p();var q={Critical:"CRITICAL",Warning:"WARNING"};u();p();var B={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};u();p();u();p();function $e(n,t){var r,i;let e=(r=n.split("/").pop())!=null?r:n;return t!=null&&t.stripExtension&&(i=e.split(".")[0])!=null?i:e}u();p();u();p();u();p();var Cr=/[^0-9a-zA-Z_]/g,_r=["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],z=class extends de{constructor({packageName:e,rootImportPath:r,importPath:i,customConfig:o,formatter:s}){super();c(this,"packageName");c(this,"rootImportPath");c(this,"importPath");c(this,"customConfig");c(this,"formatter");c(this,"imports",{});this.packageName=e,this.rootImportPath=r,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new le}addImport(e){let r=this.imports[e];if(r!=null)return r;if(e===this.rootImportPath&&this.customConfig.packageName!=null)return this.imports[e]=this.customConfig.packageName,this.customConfig.packageName;let i=new Set(Object.values(this.imports)),o=e.split("/");for(let h=1;h<=o.length;h++){let l=o.slice(-h),m=this.getValidAlias(l.join(""));if(!i.has(m))return this.imports[e]=m,m}let s=this.getValidAlias($e(e));for(;i.has(s);)s="_"+s;return this.imports[e]=s,s}isValidAlias(e){return!_r.includes(e)}getValidAlias(e){let r=e.split("-");if(r[0]==null)return e;let i=r.map(o=>o.replace(Cr,"")).join("");return this.isValidAlias(i)?i:"_"+i}};var me=class extends z{constructor({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){super({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o})}async toStringAsync(){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
16
  ${t}`)}return t}toString(){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
17
  ${t}`)}return t}getContent(){let t=`package ${this.packageName}
11
18
 
12
19
  `,e=this.stringifyImports();return e.length>0?`${t}${e}
13
20
 
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(`
21
+ ${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.imports).filter(([e,r])=>e!==this.importPath).map(([e,r])=>` ${r} "${e}"`).join(`
15
22
  `);return t?`import (
16
23
  ${t}
17
- )`:""}};var x=class extends G{async toStringAsync({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o}){let s=new ie({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o});return this.write(s),s.toStringAsync()}toString({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o}){let s=new ie({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o});return this.write(s),s.toString()}};var E=class extends x{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}`)}};var ur=new Set(["any","bytes","map","slice"]),oe=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(cr);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(pr);break;default:S(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"||ur.has(e.internalType.type)}},cr=new E({importPath:"time",name:"Time"}),pr=new E({importPath:"github.com/google/uuid",name:"UUID"});u();c();u();c();var U=class extends x{constructor(e){super();h(this,"arg");this.arg=e}write(e){return new _(this.arg).write(e)}};u();c();u();c();var P=class extends x{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 J=class extends x{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 P({docs:this.docs})),e.write(`type ${this.name} string`)}};u();c();var K=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();c();var Q=class extends x{constructor({nodes:e}={nodes:[]}){super();h(this,"nodes");this.nodes=e!=null?e:[]}add(...e){this.nodes.push(...e)}write(e){for(let n of this.nodes)n.write(e)}};u();c();u();c();var q=class extends x{constructor({name:e,parameters:n,return_:i,body:o,docs:s,typeReference:p}){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=p}write(e){var n;if(e.writeNode(new P({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 z=class extends x{constructor({name:e,parameters:n,return_:i,body:o,docs:s}){super();h(this,"func");this.func=new q({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();c();u();c();u();c();u();c();var D=class extends x{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),de({writer:e,arguments_:this.arguments_})}};var hr=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),Ke=new Set(["any","bytes","map","slice"]),F=class r extends x{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(mr({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(dr({value:this.internalType.value}));break;default:S(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=yr({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(hr.has(n.internalType.type)){e.writeNode(fr({writer:e,type:n}));return}if(Ke.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"||Ke.has(e.internalType.type)}writeSlice({writer:e,slice:n}){e.write("[]"),e.writeNode(n.valueType);let i=xr({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=wr({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 fr({writer:r,type:t}){return new B({func:new E({name:lr({type:t}),importPath:r.rootImportPath}),arguments_:[t]})}function lr({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 mr({writer:r,type:t}){let e=t instanceof Date?"MustParseDate":"MustParseDateTime";return new B({func:new E({name:e,importPath:r.rootImportPath}),arguments_:[new U(`"${t.value}"`)]})}function dr({value:r}){return new B({func:new E({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new U(`"${r}"`)]})}function yr({entries:r}){return r.filter(t=>!F.isNop(t.key)&&!F.isNop(t.value))}function wr({fields:r}){return r.filter(t=>!F.isNop(t.value))}function xr({values:r}){return r.filter(t=>!F.isNop(t))}function de({writer:r,arguments_:t}){let e=Ar(t);if(e.length===0){r.write("()");return}r.writeLine("("),r.indent();for(let n of e)gr({writer:r,argument:n}),r.writeLine(",");r.dedent(),r.write(")")}function gr({writer:r,argument:t}){Ie(t)?r.writeNodeOrString(t.assignment):t.write(r)}function Ar(r){return r.filter(t=>!(t instanceof F&&F.isNop(t)))}var B=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),de({writer:e,arguments_:this.arguments_})}};u();c();var Z=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();c();var X=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("}")}if(this.methods.length>0){e.newLine();for(let n of this.methods)e.writeNode(n),e.newLine()}}};var m={};Ee(m,{AstNode:()=>x,CodeBlock:()=>U,Enum:()=>J,Field:()=>K,File:()=>Q,Func:()=>z,FuncInvocation:()=>B,Method:()=>q,MethodInvocation:()=>D,Parameter:()=>Z,Struct:()=>X,Type:()=>oe,TypeInstantiation:()=>F,TypeReference:()=>E,Writer:()=>H,codeblock:()=>Ir,enum_:()=>Tr,field:()=>vr,file:()=>Er,func:()=>Rr,invokeFunc:()=>Nr,invokeMethod:()=>Pr,method:()=>Fr,parameter:()=>Sr,struct:()=>Br,typeReference:()=>br});u();c();function Ir(r){return new U(r)}function Tr(r){return new J(r)}function vr(r){return new K(r)}function Er(r={}){return new Q(r)}function Rr(r){return new z(r)}function Nr(r){return new B(r)}function Pr(r){return new D(r)}function Fr(r){return new q(r)}function Sr(r){return new Z(r)}function Br(r){return new X(r)}function br(r){return new E(r)}var Qe="example",ze="fern",kr="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}).toStringAsync({packageName:Qe,importPath:ze,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}).toString({packageName:Qe,importPath:ze,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return m.func({name:kr,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:N.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(C.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:N.Critical,message:this.context.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:N.Critical,message:this.context.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:N.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),m.TypeInstantiation.nop()):this.getConstructorHeaderAuthArg({auth:t,values:e});case"oauth":return e.type!=="oauth"?(this.context.errors.add({severity:N.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),m.TypeInstantiation.nop()):(this.context.errors.add({severity:N.Warning,message:"The Go SDK doesn't support OAuth client credentials yet"}),m.TypeInstantiation.nop());default:S(t)}}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:N.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:N.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return m.TypeInstantiation.reference(n)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:N.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});default:S(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){var o,s;let n=[];this.context.errors.scope(C.PathParameters);let i=[...(o=this.context.ir.pathParameters)!=null?o:[],...(s=t.pathParameters)!=null?s:[]];return i.length>0&&n.push(...this.getPathParameters({namedParameters:i,snippet:e}).map(p=>p.value)),this.context.errors.unscope(),this.context.errors.scope(C.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});default:S(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:N.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 y,d,l,I,g,T;let n=[],{inlinePathParameters:i,inlineFileProperties:o}={inlinePathParameters:(d=(y=this.context.customConfig)==null?void 0:y.inlinePathParameters)!=null?d:!1,inlineFileProperties:(I=(l=this.context.customConfig)==null?void 0:l.inlineFileProperties)!=null?I:!1};this.context.errors.scope(C.PathParameters);let s=[],p=[...(g=this.context.ir.pathParameters)!=null?g:[],...(T=t.pathParameters)!=null?T:[]];p.length>0&&s.push(...this.getPathParameters({namedParameters:p,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(C.RequestBody);let f=this.getFilePropertyInfo({request:t,snippet:e});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})||n.push(...s.map(te=>te.value)),o||n.push(...f.fileFields.map(te=>te.value)),this.context.needsRequestParameter({request:t,inlinePathParameters:i,inlineFileProperties:o})&&n.push(this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})?s:[],filePropertyInfo:f})),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,I,g;this.context.errors.scope(C.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(d=t.queryParameters)!=null?d:[],values:(l=e.queryParameters)!=null?l:{}}).map(T=>({name:T.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(T)}));this.context.errors.unscope(),this.context.errors.scope(C.Headers);let f=this.context.associateByWireValue({parameters:(I=t.headers)!=null?I:[],values:(g=e.headers)!=null?g:{}}).map(T=>({name:T.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(T)}));this.context.errors.unscope(),this.context.errors.scope(C.RequestBody);let y=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,...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});default:S(t)}}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});default:S(t)}}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})}};0&&(module.exports={EndpointSnippetGenerator});
24
+ )`:""}};var f={};Ve(f,{Alias:()=>Q,AstNode:()=>w,CodeBlock:()=>L,Enum:()=>Z,Field:()=>X,File:()=>ee,Func:()=>te,FuncInvocation:()=>F,IoReaderTypeReference:()=>De,Method:()=>O,MethodInvocation:()=>D,MultiNode:()=>ye,Parameter:()=>re,Pointer:()=>ne,Selector:()=>ie,Struct:()=>oe,TimeTypeReference:()=>Pe,Type:()=>we,TypeDeclaration:()=>se,TypeInstantiation:()=>N,TypeReference:()=>k,UuidTypeReference:()=>Ce,Writer:()=>z,alias:()=>Gr,codeblock:()=>Hr,enum_:()=>Kr,field:()=>jr,file:()=>Jr,func:()=>zr,identifier:()=>Qr,invokeFunc:()=>Zr,invokeMethod:()=>Xr,method:()=>en,parameter:()=>tn,pointer:()=>rn,selector:()=>nn,struct:()=>on,switch_:()=>sn,typeDeclaration:()=>an,typeReference:()=>cn});u();p();u();p();u();p();u();p();u();p();var w=class extends J{async toStringAsync({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new me({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toStringAsync()}toString({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new me({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toString()}};var v=class extends w{constructor({docs:e}={}){super();c(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
25
+ `).forEach(r=>{e.writeLine(`// ${r}`)})}};var Q=class extends w{constructor({name:e,type:r,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new v({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};u();p();var L=class extends w{constructor(e){super();c(this,"arg");this.arg=e}write(e){return new S(this.arg).write(e)}};u();p();u();p();var $=class extends w{constructor(e){super();c(this,"name");this.name=e}write(e){e.write(this.name)}};u();p();u();p();u();p();function ue({writer:n,arguments_:t,multiline:e=!0}){let r=t.map(i=>i instanceof N&&N.isNop(i)?N.nil():i);if(r.length===0){n.write("()");return}if(e){Br({writer:n,arguments_:r});return}Lr({writer:n,arguments_:r})}function Br({writer:n,arguments_:t}){n.writeLine("("),n.indent();for(let e of t)e.write(n),n.writeLine(",");n.dedent(),n.write(")")}function Lr({writer:n,arguments_:t}){n.write("("),t.forEach((e,r)=>{r>0&&n.write(", "),e.write(n)}),n.write(")")}var F=class extends w{constructor({func:e,arguments_:r,multiline:i=!0}){super();c(this,"func");c(this,"arguments_");c(this,"multiline");this.func=e,this.arguments_=r,this.multiline=i}write(e){e.writeNode(this.func),ue({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};u();p();u();p();function wt({writer:n,generics:t}){t.length!==0&&(n.write("["),t.forEach((e,r)=>{r>0&&n.write(", "),e!=null&&n.writeNode(e)}),n.write("]"))}var k=class extends w{constructor({name:e,importPath:r,generics:i}){super();c(this,"name");c(this,"importPath");c(this,"generics");this.name=e,this.importPath=r,this.generics=i}write(e){if(this.importPath==null||e.importPath===this.importPath){e.write(this.name);return}let r=e.addImport(this.importPath);e.write(`${r}.${this.name}`),this.generics!=null&&wt({writer:e,generics:this.generics})}};u();p();var D=class extends w{constructor({method:e,arguments_:r,on:i,multiline:o}){super();c(this,"on");c(this,"method");c(this,"arguments_");c(this,"multiline");this.on=i,this.method=e,this.arguments_=r,this.multiline=o}write(e){this.on.write(e),e.write("."),e.write(this.method),ue({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};var Mr=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),xt=new Set(["any","bytes","map","slice"]),N=class n extends w{constructor(e){super();c(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(qr({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(`
26
+ `)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode($r({value:this.internalType.value}));break;default:b(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:r,entries:i}){return new this({type:"map",keyType:e,valueType:r,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:r}){return new this({type:"slice",valueType:e,values:r})}static string(e){return new this({type:"string",value:e})}static struct({typeReference:e,fields:r}){return new this({type:"struct",typeReference:e,fields:r})}static structPointer({typeReference:e,fields:r,generics:i}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:r,generics:i})})}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:r}){switch(typeof r){case"boolean":e.write(r.toString());return;case"string":e.write(r.includes('"')?`\`${r}\``:`"${r}"`);return;case"number":e.write(r.toString());return;case"object":if(r==null){e.write("nil");return}if(Array.isArray(r)){this.writeAnyArray({writer:e,value:r});return}this.writeAnyObject({writer:e,value:r});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof r}`)}}writeAnyArray({writer:e,value:r}){if(e.write("[]any"),r.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let i of r)e.writeNode(n.any(i)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:r}){e.write("map[string]any");let i=Object.entries(r);if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[o,s]of i)e.write(`"${o}": `),e.writeNode(n.any(s)),e.writeLine(",");e.dedent(),e.write("}")}writeMap({writer:e,map:r}){e.write("map["),e.writeNode(r.keyType),e.write("]"),e.writeNode(r.valueType);let i=Dr({entries:r.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:r}){if(Mr.has(r.internalType.type)){e.writeNode(Ur({writer:e,type:r}));return}if(xt.has(r.internalType.type)){r.write(e);return}if(r.internalType.type==="enum"){e.writeNode(new D({on:r.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),r.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||xt.has(e.internalType.type)}writeSlice({writer:e,slice:r}){e.write("[]"),e.writeNode(r.valueType);let i=Yr({values:r.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:r}){e.writeNode(r.typeReference),r.generics!=null&&(e.write("["),r.generics.forEach((o,s)=>{s>0&&e.write(", "),e.writeNode(o)}),e.write("]"));let i=Or({fields:r.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:n,type:t}){return new F({func:new k({name:Wr({type:t}),importPath:n.rootImportPath}),arguments_:[t]})}function Wr({type:n}){switch(n.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 qr({writer:n,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new F({func:new k({name:e,importPath:n.rootImportPath}),arguments_:[new L(`"${t.value}"`)]})}function $r({value:n}){return new F({func:new k({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new L(`"${n}"`)]})}function Dr({entries:n}){return n.filter(t=>!N.isNop(t.key)&&!N.isNop(t.value))}function Or({fields:n}){return n.filter(t=>!N.isNop(t.value))}function Yr({values:n}){return n.filter(t=>!N.isNop(t))}var Z=class n extends w{constructor({name:e,docs:r}){super();c(this,"name");c(this,"docs");c(this,"members",[]);c(this,"methods",[]);c(this,"constructor_");this.name=e,this.docs=r}addConstructor(e){this.constructor_=e}addMember(e){this.members.push(e)}addMethod(e){this.methods.push(e)}write(e){this.writeType({writer:e}),this.writeMembers({writer:e}),this.writeConstructor({writer:e}),this.writeMethods({writer:e})}writeType({writer:e}){e.writeNode(new v({docs:this.docs})),e.writeLine(`type ${this.name} string`)}writeMembers({writer:e}){if(this.members.length!==0){e.newLine(),e.writeLine("const ("),e.indent();for(let r of this.members)e.writeNode(new v({docs:r.docs})),e.writeNode(n.getMemberIdentifier({name:this.name,member:r})),e.write(" = "),e.writeNode(N.string(r.value)),e.newLine();e.dedent(),e.write(")")}}writeConstructor({writer:e}){this.constructor_!=null&&(e.newLine(),e.writeNode(this.constructor_))}writeMethods({writer:e}){e.newLine();for(let r of this.methods)e.newLine(),e.writeNode(r),e.newLine()}static getMemberIdentifier({name:e,member:r}){return new $(`${e}${r.name}`)}};u();p();var X=class extends w{constructor({name:e,type:r,docs:i,tags:o}){super();c(this,"name");c(this,"type");c(this,"docs");c(this,"tags",[]);this.name=e,this.type=r,this.docs=i,this.tags=o!=null?o:[]}addTags(...e){this.tags.push(...e)}write(e){e.writeNode(new v({docs:this.docs})),e.write(`${this.name} `),this.type.write(e),this.writeTags({writer:e})}writeTags({writer:e}){this.tags.length!==0&&(e.write(" `"),this.tags.forEach((r,i)=>{i>0&&e.write(" "),e.write(`${r.name}:"${r.value}"`)}),e.write("`"))}};u();p();var ee=class extends w{constructor({nodes:e}={nodes:[]}){super();c(this,"nodes");this.nodes=e!=null?e:[]}add(...e){this.nodes.push(...e)}write(e){for(let r of this.nodes)r.write(e)}};u();p();u();p();var O=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s,typeReference:h,multiline:l,receiver:m,pointerReceiver:d}){super();c(this,"parameters");c(this,"return_");c(this,"name");c(this,"body");c(this,"docs");c(this,"typeReference");c(this,"multiline");c(this,"receiver");c(this,"pointerReceiver");this.name=e,this.parameters=r,this.return_=i,this.body=o,this.docs=s,this.typeReference=h,this.multiline=l,this.receiver=m,this.pointerReceiver=d}write(e){var r;e.writeNode(new v({docs:this.docs})),e.write("func"),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference,receiver:this.receiver}),this.name!=null&&e.write(` ${this.name}`),ue({writer:e,arguments_:this.parameters,multiline:this.multiline}),this.return_!=null&&(e.write(" "),this.return_.length>1&&e.write("("),this.return_.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),this.return_.length>1&&e.write(")")),e.writeLine("{"),e.indent(),(r=this.body)==null||r.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.write("}")}writeReceiver({writer:e,typeReference:r,receiver:i}){e.write(` (${this.getReceiverName({typeReference:r,receiver:i})} `),this.pointerReceiver&&e.write("*"),r.write(e),e.write(")")}getReceiverName({typeReference:e,receiver:r}){return r!=null?r:e.name.charAt(0).toLowerCase()}};var te=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s,multiline:h}){super();c(this,"func");this.func=new O({name:e,parameters:r,return_:i,body:o,docs:s,multiline:h})}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get name(){return this.func.name}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};u();p();var ye=class extends w{constructor({nodes:e}){super();c(this,"nodes");this.nodes=e}write(e){for(let r of this.nodes)e.newLine(),r.write(e),e.newLine()}};u();p();var re=class extends w{constructor({name:e,type:r,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new v({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};u();p();var ne=class extends w{constructor({node:e}){super();c(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};u();p();var ie=class extends w{constructor({on:e,selector:r}){super();c(this,"on");c(this,"selector");this.on=e,this.selector=r}write(e){e.writeNode(this.on),e.write("."),e.writeNode(this.selector)}};u();p();var oe=class extends w{constructor({name:e,embeds:r,fields:i,docs:o}){super();c(this,"name");c(this,"embeds",[]);c(this,"fields",[]);c(this,"docs");c(this,"methods",[]);c(this,"constructor_");this.name=e,this.docs=o,this.embeds=r!=null?r:[],this.fields=i!=null?i:[]}addConstructor(e){this.constructor_=e}addField(...e){this.fields.push(...e)}addMethod(...e){this.methods.push(...e)}write(e){this.writeType({writer:e}),this.constructor_!=null&&(e.newLine(),e.newLine(),this.writeConstructor({writer:e,constructor:this.constructor_})),this.writeMethods({writer:e})}writeType({writer:e}){if(e.writeNode(new v({docs:this.docs})),this.name!=null?e.write(`type ${this.name} struct {`):e.write("struct{"),this.embeds.length===0&&this.fields.length===0){e.writeLine("}");return}e.newLine(),e.indent();for(let o of this.embeds)e.writeNode(o),e.newLine();let r=this.fields.filter(o=>this.isExported(o));for(let o of r)e.writeNode(o),e.newLine();let i=this.fields.filter(o=>!this.isExported(o));r.length>0&&i.length>0&&e.newLine();for(let o of i)e.writeNode(o),e.newLine();e.dedent(),e.write("}")}writeConstructor({writer:e,constructor:r}){r.name!=null?e.write(`func ${r.name}(`):e.write(`func New${this.name}(`),r.parameters.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),e.write(`) *${this.name} {`),e.newLine(),e.indent(),e.writeNode(r.body),e.writeNewLineIfLastLineNot(),e.dedent(),e.writeLine("}")}writeMethods({writer:e}){if(this.methods.length!==0){e.writeNewLineIfLastLineNot();for(let r of this.methods)e.newLine(),e.writeNode(r),e.newLine()}}isExported(e){let r=e.name.charAt(0);return r===r.toUpperCase()}};u();p();var ge=class extends w{constructor({on:e,cases:r,default:i}){super();c(this,"on");c(this,"cases");c(this,"default");this.on=e,this.cases=r,this.default=i}write(e){let r=this.cases;this.default!=null&&r.push({on:new $("default"),body:this.default}),e.write("switch "),e.writeNode(this.on),e.writeLine("{"),e.indent();for(let i of r)e.write("case "),e.writeNode(i.on),e.writeLine(":"),e.indent(),e.writeNode(i.body),e.dedent(),e.writeNewLineIfLastLineNot();e.dedent(),e.write("}")}};u();p();var Vr=new Set(["any","bytes","map","slice"]),we=class n extends w{constructor(e){super();c(this,"internalType");this.internalType=e}write(e,{comment:r}={}){switch(this.internalType.type){case"any":e.write("any");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(Pe);break;case"error":e.write("error");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(Ce);break;case"variadic":e.write("..."),this.internalType.value.write(e);break;default:b(this.internalType)}}isOptional(){return this.internalType.type==="optional"}isIterable(){return this.internalType.type==="slice"||this.internalType.type==="variadic"}iterableElement(){if(this.internalType.type==="slice"||this.internalType.type==="variadic")return this.internalType.value}underlying(){return this.internalType.type==="optional"?this.internalType.value:this}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 dereference(e){return e.internalType.type==="optional"?e.internalType.value:e}static error(){return new this({type:"error"})}static float64(){return new this({type:"float64"})}static int(){return new this({type:"int"})}static int64(){return new this({type:"int64"})}static map(e,r){return new this({type:"map",keyType:e,valueType:r})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static pointer(e){return n.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 variadic(e){return this.isAlreadyVariadic(e)?e:new this({type:"variadic",value:e})}static isAlreadyOptional(e){return e.internalType.type==="optional"||Vr.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},Pe=new k({importPath:"time",name:"Time"}),Ce=new k({importPath:"github.com/google/uuid",name:"UUID"}),De=new k({importPath:"io",name:"Reader"});u();p();var se=class extends w{constructor({name:e,type:r,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new v({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function Gr(n){return new Q(n)}function Hr(n){return new L(n)}function Kr(n){return new Z(n)}function jr(n){return new X(n)}function Jr(n={}){return new ee(n)}function zr(n){return new te(n)}function Qr(n){return new $(n)}function Zr(n){return new F(n)}function Xr(n){return new D(n)}function en(n){return new O(n)}function tn(n){return new re(n)}function rn(n){return new ne(n)}function nn(n){return new ie(n)}function on(n={}){return new oe(n)}function sn(n){return new ge(n)}function an(n){return new se(n)}function cn(n){return new k(n)}var Tt="example",Oe="fern",un="do",xe="client",pe=f.TypeInstantiation,pn="WireMockBaseURL",hn="WireMockClient",Ye=class{constructor({context:t,formatter:e}){c(this,"context");c(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e,options:r}){var s,h,l;return((h=(s=r==null?void 0:r.config)==null?void 0:s.outputWiremockTests)!=null?h:!1)?this.generateWiremockTest({endpoint:t,snippet:e}):await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({packageName:Tt,importPath:Oe,rootImportPath:this.context.rootImportPath,customConfig:(l=this.context.customConfig)!=null?l:{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e,options:r}){var s,h,l;return((h=(s=r==null?void 0:r.config)==null?void 0:s.outputWiremockTests)!=null?h:!1)?this.generateWiremockTest({endpoint:t,snippet:e}):this.buildCodeBlock({endpoint:t,snippet:e}).toString({packageName:Tt,importPath:Oe,rootImportPath:this.context.rootImportPath,customConfig:(l=this.context.customConfig)!=null?l:{},formatter:this.formatter})}generateWiremockTest({endpoint:t,snippet:e}){var i;return this.buildWiremockTestCodeBlock({endpoint:t,snippet:e}).toString({packageName:"wiremock",importPath:Oe,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return f.codeblock(r=>{r.writeNode(f.func({name:un,parameters:[],return_:[],body:f.codeblock(i=>{i.writeNode(this.constructClient({endpoint:t,snippet:e})),i.writeLine(),i.writeNode(this.callMethod({endpoint:t,snippet:e}))})})),r.writeNewLineIfLastLineNot()})}buildWiremockTestCodeBlock({endpoint:t,snippet:e}){return f.codeblock(r=>{r.writeNode(f.func({name:"Test"+this.context.getTestMethodName(t)+"WithWireMock",parameters:[f.parameter({name:"t",type:f.Type.pointer(f.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:f.codeblock(i=>{for(let o of this.buildWiremockTestSetup({endpoint:t}))i.writeNode(o),i.writeLine();i.writeLine(),i.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),i.writeLine(),i.writeNode(this.callClientMethodAndAssert({endpoint:t,snippet:e}))})})),r.writeNewLineIfLastLineNot()})}constructClient({endpoint:t,snippet:e}){return f.codeblock(r=>{r.write(`${xe} := `),r.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}constructWiremockTestClient({endpoint:t,snippet:e}){return f.codeblock(r=>{r.write(`${xe} := `),r.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:t,endpoint:e,snippet:r}){let{otherArgs:i,requestArg:o}=this.getMethodArgs({endpoint:e,snippet:r});if(o!=null)if(o instanceof f.TypeInstantiation&&f.TypeInstantiation.isNop(o))t.writeNode(f.invokeMethod({on:f.codeblock(xe),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...i,f.codeblock("nil")]}));else{t.write("request := "),t.writeNode(o),t.writeLine();let s=f.codeblock("request");t.writeNode(f.invokeMethod({on:f.codeblock(xe),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...i,s]}))}else t.writeNode(f.invokeMethod({on:f.codeblock(xe),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...i]}))}callMethod({endpoint:t,snippet:e}){return f.codeblock(r=>{this.writeMethodInvocation({writer:r,endpoint:t,snippet:e})})}getConstructorArgs({endpoint:t,snippet:e}){let r=[],i=this.getConstructorBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return i!=null&&r.push(i),t.auth!=null&&(e.auth!=null?r.push(this.getConstructorAuthArg({auth:t.auth,values:e.auth})):this.context.errors.add({severity:q.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(B.Headers),this.context.ir.headers!=null&&e.headers!=null&&r.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),r}getWiremockTestConstructorArgs(){return[f.codeblock(t=>{t.writeNode(f.invokeFunc({func:f.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[f.codeblock(pn)]}))})]}getConstructorAuthArg({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),pe.nop();switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArg({auth:t,values:e}):pe.nop();case"bearer":return e.type==="bearer"?this.getConstructorBearerAuthArg({auth:t,values:e}):pe.nop();case"header":return e.type==="header"?this.getConstructorHeaderAuthArg({auth:t,values:e}):pe.nop();case"oauth":return this.addWarning("The Go SDK doesn't support OAuth client credentials yet"),pe.nop();case"inferred":return this.addWarning("The Go SDK Generator does not support Inferred auth scheme yet"),pe.nop();default:b(t)}}addError(t){this.context.errors.add({severity:q.Critical,message:t})}addWarning(t){this.context.errors.add({severity:q.Warning,message:t})}getConstructorBasicAuthArg({auth:t,values:e}){return f.codeblock(r=>{r.writeNode(f.invokeFunc({func:f.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[f.TypeInstantiation.string(e.username),f.TypeInstantiation.string(e.password)]}))})}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let r=this.getBaseUrlArg({baseUrl:t,environment:e});if(r!=null)return f.codeblock(i=>{i.writeNode(f.invokeFunc({func:f.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[r]}))})}getBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:q.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return f.TypeInstantiation.string(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let r=this.context.getEnvironmentTypeReferenceFromID(e);if(r==null){this.context.errors.add({severity:q.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return f.TypeInstantiation.reference(r)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:q.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 f.codeblock(r=>{r.writeNode(f.invokeFunc({func:f.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[f.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return f.codeblock(r=>{r.writeNode(f.invokeFunc({func:f.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 r=[];for(let i of t){let o=this.getConstructorHeaderArg({header:i,value:e.value});o!=null&&r.push(o)}return r}getConstructorHeaderArg({header:t,value:e}){let r=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!f.TypeInstantiation.isNop(r))return f.codeblock(i=>{i.writeNode(f.invokeFunc({func:f.typeReference({name:`With${t.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[r]}))})}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});default:b(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){var s,h;let r=[];this.context.errors.scope(B.PathParameters);let i=[...(s=this.context.ir.pathParameters)!=null?s:[],...(h=t.pathParameters)!=null?h:[]];i.length>0&&r.push(...this.getPathParameters({namedParameters:i,snippet:e}).map(l=>l.value)),this.context.errors.unscope(),this.context.errors.scope(B.RequestBody);let o=t.body!=null?this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:r,requestArg:o}}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});default:b(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:q.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),f.TypeInstantiation.nop()):f.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){var d,y,x,T,A,G;let r=[],{inlinePathParameters:i,inlineFileProperties:o}={inlinePathParameters:(y=(d=this.context.customConfig)==null?void 0:d.inlinePathParameters)!=null?y:!0,inlineFileProperties:(T=(x=this.context.customConfig)==null?void 0:x.inlineFileProperties)!=null?T:!0};this.context.errors.scope(B.PathParameters);let s=[],h=[...(A=this.context.ir.pathParameters)!=null?A:[],...(G=t.pathParameters)!=null?G:[]];h.length>0&&s.push(...this.getPathParameters({namedParameters:h,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(B.RequestBody);let l=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})||r.push(...s.map(he=>he.value)),o||r.push(...l.fileFields.map(he=>he.value));let m=this.context.needsRequestParameter({request:t,inlinePathParameters:i,inlineFileProperties:o})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})?s:[],filePropertyInfo:l}):void 0;return{otherArgs:r,requestArg:m}}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:r,filePropertyInfo:i}){var d,y,x,T;this.context.errors.scope(B.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(d=t.queryParameters)!=null?d:[],values:(y=e.queryParameters)!=null?y:{}}).map(A=>({name:A.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(A)}));this.context.errors.unscope(),this.context.errors.scope(B.Headers);let l=this.context.associateByWireValue({parameters:(x=t.headers)!=null?x:[],values:(T=e.headers)!=null?T:{}}).map(A=>({name:A.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(A)}));this.context.errors.unscope(),this.context.errors.scope(B.RequestBody);let m=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),f.TypeInstantiation.structPointer({typeReference:f.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPathForRequest(t.declaration.fernFilepath)}),fields:[...r,...s,...l,...m]})}getInlinedRequestBodyStructFields({body:t,value:e,filePropertyInfo:r}){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:r});default:b(t)}}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});default:b(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=this.context.getRecord(e))!=null?o:{}});for(let s of i)r.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(s)});return r}getPathParameters({namedParameters:t,snippet:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=e.pathParameters)!=null?o:{}});for(let s of i)r.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(s)});return r}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 f.invokeFunc({func:f.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}buildWiremockTestSetup({endpoint:t,errorCase:e}){let r="stub";return[]}callClientMethodAndAssert({endpoint:t,snippet:e}){return f.codeblock(r=>{this.writeMethodInvocation({writer:r,endpoint:t,snippet:e}),r.writeLine(),r.writeLine(),r.write("ok, countErr := "),r.writeNode(f.invokeMethod({on:f.codeblock(hn),method:"Verify",arguments_:[f.invokeMethod({on:f.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),f.codeblock("1")],multiline:!1})),r.writeLine(),r.writeNode(f.invokeFunc({func:f.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[f.codeblock("t"),f.codeblock("countErr"),f.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),r.writeLine(),r.writeNode(f.invokeFunc({func:f.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[f.codeblock("t"),f.codeblock("ok"),f.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),r.writeLine()})}};0&&(module.exports={EndpointSnippetGenerator});
20
27
  /*! Bundled license information:
21
28
 
22
29
  @esbuild-plugins/node-globals-polyfill/Buffer.js:
@@ -27,3 +34,4 @@ ${t}
27
34
  * @license MIT
28
35
  *)
29
36
  */
37
+ //# sourceMappingURL=EndpointSnippetGenerator.cjs.map