@fern-api/go-dynamic-snippets 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/DynamicSnippetsGenerator.cjs +6 -6
- package/cjs/DynamicSnippetsGenerator.d.cts +4 -2
- package/cjs/{DynamicSnippetsGeneratorContext-lz2pTZw3.d.cts → DynamicSnippetsGeneratorContext-CpOvS1wA.d.cts} +2 -1
- package/cjs/EndpointSnippetGenerator.cjs +6 -6
- package/cjs/EndpointSnippetGenerator.d.cts +1 -1
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +6 -6
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +1 -1
- package/cjs/context/DynamicTypeInstantiationMapper.cjs +6 -6
- package/cjs/context/DynamicTypeInstantiationMapper.d.cts +1 -1
- package/cjs/context/DynamicTypeMapper.cjs +6 -6
- package/cjs/context/DynamicTypeMapper.d.cts +1 -1
- package/cjs/context/FilePropertyMapper.cjs +6 -6
- package/cjs/context/FilePropertyMapper.d.cts +1 -1
- package/cjs/index.cjs +16 -16
- package/cjs/index.d.cts +2 -1
- package/esm/DynamicSnippetsGenerator.d.ts +4 -2
- package/esm/DynamicSnippetsGenerator.js +1 -1
- package/esm/{DynamicSnippetsGeneratorContext-lz2pTZw3.d.ts → DynamicSnippetsGeneratorContext-CpOvS1wA.d.ts} +2 -1
- package/esm/EndpointSnippetGenerator.d.ts +1 -1
- package/esm/EndpointSnippetGenerator.js +1 -1
- package/esm/{chunk-I3VUX77R.js → chunk-55JFNSPF.js} +1 -1
- package/esm/chunk-EQTG6W6V.js +1 -0
- package/esm/chunk-H7X5SHRQ.js +1 -0
- package/esm/chunk-IYOA724T.js +1 -0
- package/esm/chunk-LZIEHSJ7.js +1 -0
- package/esm/{chunk-D3UUM672.js → chunk-RX5QSNXP.js} +1 -1
- package/esm/chunk-SX53R7DQ.js +1 -0
- package/esm/chunk-XL5OWIY6.js +29 -0
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +1 -1
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
- package/esm/context/DynamicTypeInstantiationMapper.d.ts +1 -1
- package/esm/context/DynamicTypeInstantiationMapper.js +1 -1
- package/esm/context/DynamicTypeMapper.d.ts +1 -1
- package/esm/context/DynamicTypeMapper.js +1 -1
- package/esm/context/FilePropertyMapper.d.ts +1 -1
- package/esm/context/FilePropertyMapper.js +1 -1
- package/esm/index.d.ts +2 -1
- package/esm/index.js +10 -10
- package/package.json +1 -1
- package/esm/chunk-5HP3T45N.js +0 -1
- package/esm/chunk-J745U74Q.js +0 -1
- package/esm/chunk-SS6XZXHU.js +0 -1
- package/esm/chunk-TUE3DOHS.js +0 -29
- package/esm/chunk-X7QP3WH3.js +0 -1
- package/esm/chunk-YAGEU3HO.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var he=Object.defineProperty,gt=Object.defineProperties,xt=Object.getOwnPropertyDescriptor,wt=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var Fe=(n,t,e)=>t in n?he(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,De=(n,t)=>{for(var e in t||(t={}))Pe.call(t,e)&&Fe(n,e,t[e]);if(fe)for(var e of fe(t))Le.call(t,e)&&Fe(n,e,t[e]);return n},Ve=(n,t)=>gt(n,wt(t));var $e=n=>typeof n=="symbol"?n:n+"",Oe=(n,t)=>{var e={};for(var r in n)Pe.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&fe)for(var r of fe(n))t.indexOf(r)<0&&Le.call(n,r)&&(e[r]=n[r]);return e};var be=(n,t)=>()=>(n&&(t=n(n=0)),t);var qe=(n,t)=>{for(var e in t)he(n,e,{get:t[e],enumerable:!0})},Tt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of vt(t))!Pe.call(n,i)&&i!==e&&he(n,i,{get:()=>t[i],enumerable:!(r=xt(t,i))||r.enumerable});return n};var It=n=>Tt(he({},"__esModule",{value:!0}),n);var l=(n,t,e)=>Fe(n,typeof t!="symbol"?t+"":t,e);function Ye(){throw new Error("setTimeout has not been defined")}function We(){throw new Error("clearTimeout has not been defined")}function He(n){if(V===setTimeout)return setTimeout(n,0);if((V===Ye||!V)&&setTimeout)return V=setTimeout,setTimeout(n,0);try{return V(n,0)}catch(t){try{return V.call(null,n,0)}catch(e){return V.call(this,n,0)}}}function Rt(n){if($===clearTimeout)return clearTimeout(n);if(($===We||!$)&&clearTimeout)return $=clearTimeout,clearTimeout(n);try{return $(n)}catch(t){try{return $.call(null,n)}catch(e){return $.call(this,n)}}}function At(){!Z||!q||(Z=!1,q.length?_=q.concat(_):de=-1,_.length&&je())}function je(){if(!Z){var n=He(At);Z=!0;for(var t=_.length;t;){for(q=_,_=[];++de<t;)q&&q[de].run();de=-1,t=_.length}q=null,Z=!1,Rt(n)}}function Et(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];_.push(new ze(n,t)),_.length===1&&!Z&&He(je)}function ze(n,t){this.fun=n,this.array=t}function G(){}function qt(n){throw new Error("process.binding is not supported")}function Gt(){return"/"}function Yt(n){throw new Error("process.chdir is not supported")}function Wt(){return 0}function jt(n){var t=Ht.call(K)*.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 V,$,_,Z,q,de,Nt,Ft,Pt,bt,Ut,St,Bt,kt,Ct,_t,Mt,Lt,Dt,Vt,$t,Ot,K,Ht,zt,d,Ge,u=be(()=>{"use strict";V=Ye,$=We;typeof globalThis.setTimeout=="function"&&(V=setTimeout);typeof globalThis.clearTimeout=="function"&&($=clearTimeout);_=[],Z=!1,de=-1;ze.prototype.run=function(){this.fun.apply(null,this.array)};Nt="browser",Ft="browser",Pt=!0,bt={},Ut=[],St="",Bt={},kt={},Ct={};_t=G,Mt=G,Lt=G,Dt=G,Vt=G,$t=G,Ot=G;K=globalThis.performance||{},Ht=K.now||K.mozNow||K.msNow||K.oNow||K.webkitNow||function(){return new Date().getTime()};zt=new Date;d={nextTick:Et,title:Nt,browser:Pt,env:bt,argv:Ut,version:St,versions:Bt,on:_t,addListener:Mt,once:Lt,off:Dt,removeListener:Vt,removeAllListeners:$t,emit:Ot,binding:qt,cwd:Gt,chdir:Yt,umask:Wt,hrtime:jt,platform:Ft,release:kt,config:Ct,uptime:Xt},Ge={};Object.keys(Ge).forEach(n=>{let t=n.split("."),e=d;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 Ke(){Se=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)S[t]=n[t],F[n.charCodeAt(t)]=t;F[45]=62,F[95]=63}function Qt(n){Se||Ke();var t,e,r,i,o,s,f=n.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=n[f-2]==="="?2:n[f-1]==="="?1:0,s=new Jt(f*3/4-o),r=o>0?f-4:f;var h=0;for(t=0,e=0;t<r;t+=4,e+=3)i=F[n.charCodeAt(t)]<<18|F[n.charCodeAt(t+1)]<<12|F[n.charCodeAt(t+2)]<<6|F[n.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=F[n.charCodeAt(t)]<<2|F[n.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=F[n.charCodeAt(t)]<<10|F[n.charCodeAt(t+1)]<<4|F[n.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function Kt(n){return S[n>>18&63]+S[n>>12&63]+S[n>>6&63]+S[n&63]}function Zt(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(Kt(r));return i.join("")}function Xe(n){Se||Ke();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,f=0,h=e-r;f<h;f+=s)o.push(Zt(n,f,f+s>h?h:f+s));return r===1?(t=n[e-1],i+=S[t>>2],i+=S[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=S[t>>10],i+=S[t>>4&63],i+=S[t<<2&63],i+="="),o.push(i),o.join("")}function me(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function M(n,t){if(me()<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 Be(this,n)}return Ze(this,n,t,e)}function Ze(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?rr(n,t,e,r):typeof t=="string"?tr(n,t,e):nr(n,t)}function et(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 er(n,t,e,r){return et(t),t<=0?M(n,t):e!==void 0?typeof r=="string"?M(n,t).fill(e,r):M(n,t).fill(e):M(n,t)}function Be(n,t){if(et(t),n=M(n,t<0?0:ke(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function tr(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=tt(t,e)|0;n=M(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ue(n,t){var e=t.length<0?0:ke(t.length)|0;n=M(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function rr(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=Ue(n,t),n}function nr(n,t){if(B(t)){var e=ke(t.length)|0;return n=M(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"||Ir(t.length)?M(n,0):Ue(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ue(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function ke(n){if(n>=me())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+me().toString(16)+" bytes");return n|0}function B(n){return!!(n!=null&&n._isBuffer)}function tt(n,t){if(B(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 ye(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return ct(n).length;default:if(r)return ye(n).length;t=(""+t).toLowerCase(),r=!0}}function ir(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 dr(this,t,e);case"utf8":case"utf-8":return it(this,t,e);case"ascii":return fr(this,t,e);case"latin1":case"binary":return hr(this,t,e);case"base64":return pr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mr(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function Y(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function rt(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)),B(t))return t.length===0?-1:Je(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):Je(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function Je(n,t,e,r,i){var o=1,s=n.length,f=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,f/=2,e/=2}function h(R,N){return o===1?R[N]:R.readUInt16BE(N*o)}var y;if(i){var g=-1;for(y=e;y<s;y++)if(h(n,y)===h(t,g===-1?0:y-g)){if(g===-1&&(g=y),y-g+1===f)return g*o}else g!==-1&&(y-=y-g),g=-1}else for(e+f>s&&(e=s-f),y=e;y>=0;y--){for(var m=!0,T=0;T<f;T++)if(h(n,y+T)!==h(t,T)){m=!1;break}if(m)return y}return-1}function or(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 f=parseInt(t.substr(s*2,2),16);if(isNaN(f))return s;n[e+s]=f}return s}function sr(n,t,e,r){return we(ye(t,n.length-e),n,e,r)}function nt(n,t,e,r){return we(vr(t),n,e,r)}function ar(n,t,e,r){return nt(n,t,e,r)}function cr(n,t,e,r){return we(ct(t),n,e,r)}function ur(n,t,e,r){return we(Tr(t,n.length-e),n,e,r)}function pr(n,t,e){return t===0&&e===n.length?Xe(n):Xe(n.slice(t,e))}function it(n,t,e){e=Math.min(n.length,e);for(var r=[],i=t;i<e;){var o=n[i],s=null,f=o>239?4:o>223?3:o>191?2:1;if(i+f<=e){var h,y,g,m;switch(f){case 1:o<128&&(s=o);break;case 2:h=n[i+1],(h&192)===128&&(m=(o&31)<<6|h&63,m>127&&(s=m));break;case 3:h=n[i+1],y=n[i+2],(h&192)===128&&(y&192)===128&&(m=(o&15)<<12|(h&63)<<6|y&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:h=n[i+1],y=n[i+2],g=n[i+3],(h&192)===128&&(y&192)===128&&(g&192)===128&&(m=(o&15)<<18|(h&63)<<12|(y&63)<<6|g&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,f=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=f}return lr(r)}function lr(n){var t=n.length;if(t<=Qe)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=Qe));return e}function fr(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 hr(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 dr(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+=wr(n[o]);return i}function mr(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 A(n,t,e,r,i,o){if(!B(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 ge(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 xe(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 ot(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 st(n,t,e,r,i){return i||ot(n,t,e,4,34028234663852886e22,-34028234663852886e22),pt(n,t,e,r,23,4),e+4}function at(n,t,e,r,i){return i||ot(n,t,e,8,17976931348623157e292,-17976931348623157e292),pt(n,t,e,r,52,8),e+8}function gr(n){if(n=xr(n).replace(yr,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function xr(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function wr(n){return n<16?"0"+n.toString(16):n.toString(16)}function ye(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 vr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Tr(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 ct(n){return Qt(gr(n))}function we(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 Ir(n){return n!==n}function Rr(n){return n!=null&&(!!n._isBuffer||ut(n)||Ar(n))}function ut(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Ar(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&ut(n.slice(0,0))}function ve(n,t,e,r,i){var o,s,f=i*8-r-1,h=(1<<f)-1,y=h>>1,g=-7,m=e?i-1:0,T=e?-1:1,R=n[t+m];for(m+=T,o=R&(1<<-g)-1,R>>=-g,g+=f;g>0;o=o*256+n[t+m],m+=T,g-=8);for(s=o&(1<<-g)-1,o>>=-g,g+=r;g>0;s=s*256+n[t+m],m+=T,g-=8);if(o===0)o=1-y;else{if(o===h)return s?NaN:(R?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-y}return(R?-1:1)*s*Math.pow(2,o-r)}function pt(n,t,e,r,i,o){var s,f,h,y=o*8-i-1,g=(1<<y)-1,m=g>>1,T=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=r?0:o-1,N=r?1:-1,yt=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,s=g):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+m>=1?t+=T/h:t+=T*Math.pow(2,1-m),t*h>=2&&(s++,h/=2),s+m>=g?(f=0,s=g):s+m>=1?(f=(t*h-1)*Math.pow(2,i),s=s+m):(f=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;n[e+R]=f&255,R+=N,f/=256,i-=8);for(s=s<<i|f,y+=i;y>0;n[e+R]=s&255,R+=N,s/=256,y-=8);n[e+R-N]|=yt*128}var S,F,Jt,Se,Qe,yr,lt=be(()=>{"use strict";u();p();S=[],F=[],Jt=typeof Uint8Array!="undefined"?Uint8Array:Array,Se=!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 Ze(null,n,t,e)};a.kMaxLength=me();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 er(null,n,t,e)};a.allocUnsafe=function(n){return Be(null,n)};a.allocUnsafeSlow=function(n){return Be(null,n)};a.isBuffer=Rr;a.compare=function(t,e){if(!B(t)||!B(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(!B(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=tt;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)Y(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)Y(this,e,e+3),Y(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)Y(this,e,e+7),Y(this,e+1,e+6),Y(this,e+2,e+5),Y(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?it(this,0,t):ir.apply(this,arguments)};a.prototype.equals=function(t){if(!B(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,r,i,o){if(!B(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,f=r-e,h=Math.min(s,f),y=this.slice(i,o),g=t.slice(e,r),m=0;m<h;++m)if(y[m]!==g[m]){s=y[m],f=g[m];break}return s<f?-1:f<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 rt(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return rt(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 or(this,t,e,r);case"utf8":case"utf-8":return sr(this,t,e,r);case"ascii":return nt(this,t,e,r);case"latin1":case"binary":return ar(this,t,e,r);case"base64":return cr(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ur(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)}};Qe=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),ve(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||I(t,4,this.length),ve(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||I(t,8,this.length),ve(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||I(t,8,this.length),ve(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;A(this,t,e,r,o,0)}var s=1,f=0;for(this[e]=t&255;++f<r&&(s*=256);)this[e+f]=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;A(this,t,e,r,o,0)}var s=r-1,f=1;for(this[e+s]=t&255;--s>=0&&(f*=256);)this[e+s]=t/f&255;return e+r};a.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||A(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||A(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):ge(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||A(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):ge(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||A(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):xe(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||A(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):xe(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);A(this,t,e,r,o-1,-o)}var s=0,f=1,h=0;for(this[e]=t&255;++s<r&&(f*=256);)t<0&&h===0&&this[e+s-1]!==0&&(h=1),this[e+s]=(t/f>>0)-h&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);A(this,t,e,r,o-1,-o)}var s=r-1,f=1,h=0;for(this[e+s]=t&255;--s>=0&&(f*=256);)t<0&&h===0&&this[e+s+1]!==0&&(h=1),this[e+s]=(t/f>>0)-h&255;return e+r};a.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||A(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||A(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):ge(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||A(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):ge(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||A(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):xe(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||A(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):xe(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return st(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return st(this,t,e,!1,r)};a.prototype.writeDoubleLE=function(t,e,r){return at(this,t,e,!0,r)};a.prototype.writeDoubleBE=function(t,e,r){return at(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 f=B(t)?t:ye(new a(t,i).toString()),h=f.length;for(s=0;s<r-e;++s)this[s+e]=f[s%h]}return this};yr=/[^+\/0-9A-Za-z-_]/g});var p=be(()=>{"use strict";lt()});var on={};qe(on,{DynamicSnippetsGenerator:()=>Me});module.exports=It(on);u();p();u();p();u();p();function w(n){throw new Error("Unexpected value: "+JSON.stringify(n))}u();p();function te(n){return Object.keys(n)}u();p();u();p();var W=class{};u();p();u();p();var O=class extends W{constructor(e){super();l(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var Er=4,re=class{constructor(){l(this,"buffer","");l(this,"indentLevel",0);l(this,"hasWrittenAnything",!1);l(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
|
|
1
|
+
"use strict";var de=Object.defineProperty,xt=Object.defineProperties,wt=Object.getOwnPropertyDescriptor,vt=Object.getOwnPropertyDescriptors,Tt=Object.getOwnPropertyNames,he=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable;var be=(n,t,e)=>t in n?de(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,$e=(n,t)=>{for(var e in t||(t={}))Se.call(t,e)&&be(n,e,t[e]);if(he)for(var e of he(t))Ve.call(t,e)&&be(n,e,t[e]);return n},Oe=(n,t)=>xt(n,vt(t));var Ge=n=>typeof n=="symbol"?n:n+"",qe=(n,t)=>{var e={};for(var r in n)Se.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&he)for(var r of he(n))t.indexOf(r)<0&&Ve.call(n,r)&&(e[r]=n[r]);return e};var Ue=(n,t)=>()=>(n&&(t=n(n=0)),t);var Ye=(n,t)=>{for(var e in t)de(n,e,{get:t[e],enumerable:!0})},It=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Tt(t))!Se.call(n,i)&&i!==e&&de(n,i,{get:()=>t[i],enumerable:!(r=wt(t,i))||r.enumerable});return n};var Rt=n=>It(de({},"__esModule",{value:!0}),n);var l=(n,t,e)=>be(n,typeof t!="symbol"?t+"":t,e);function He(){throw new Error("setTimeout has not been defined")}function je(){throw new Error("clearTimeout has not been defined")}function ze(n){if($===setTimeout)return setTimeout(n,0);if(($===He||!$)&&setTimeout)return $=setTimeout,setTimeout(n,0);try{return $(n,0)}catch(t){try{return $.call(null,n,0)}catch(e){return $.call(this,n,0)}}}function At(n){if(O===clearTimeout)return clearTimeout(n);if((O===je||!O)&&clearTimeout)return O=clearTimeout,clearTimeout(n);try{return O(n)}catch(t){try{return O.call(null,n)}catch(e){return O.call(this,n)}}}function Et(){!ee||!G||(ee=!1,G.length?M=G.concat(M):me=-1,M.length&&Xe())}function Xe(){if(!ee){var n=ze(Et);ee=!0;for(var t=M.length;t;){for(G=M,M=[];++me<t;)G&&G[me].run();me=-1,t=M.length}G=null,ee=!1,At(n)}}function Nt(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 Je(n,t)),M.length===1&&!ee&&ze(Xe)}function Je(n,t){this.fun=n,this.array=t}function q(){}function qt(n){throw new Error("process.binding is not supported")}function Yt(){return"/"}function Wt(n){throw new Error("process.chdir is not supported")}function Ht(){return 0}function zt(n){var t=jt.call(Z)*.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 Jt(){var n=new Date,t=n-Xt;return t/1e3}var $,O,M,ee,G,me,Ft,Pt,bt,St,Ut,Bt,Ct,kt,_t,Mt,Lt,Dt,Vt,$t,Ot,Gt,Z,jt,Xt,d,We,u=Ue(()=>{"use strict";$=He,O=je;typeof globalThis.setTimeout=="function"&&($=setTimeout);typeof globalThis.clearTimeout=="function"&&(O=clearTimeout);M=[],ee=!1,me=-1;Je.prototype.run=function(){this.fun.apply(null,this.array)};Ft="browser",Pt="browser",bt=!0,St={},Ut=[],Bt="",Ct={},kt={},_t={};Mt=q,Lt=q,Dt=q,Vt=q,$t=q,Ot=q,Gt=q;Z=globalThis.performance||{},jt=Z.now||Z.mozNow||Z.msNow||Z.oNow||Z.webkitNow||function(){return new Date().getTime()};Xt=new Date;d={nextTick:Nt,title:Ft,browser:bt,env:St,argv:Ut,version:Bt,versions:Ct,on:Mt,addListener:Lt,once:Dt,off:Vt,removeListener:$t,removeAllListeners:Ot,emit:Gt,binding:qt,cwd:Yt,chdir:Wt,umask:Ht,hrtime:zt,platform:Pt,release:kt,config:_t,uptime:Jt},We={};Object.keys(We).forEach(n=>{let t=n.split("."),e=d;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=We[n]:e=e[i]||(e[i]={})}})});function et(){Ce=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)U[t]=n[t],F[n.charCodeAt(t)]=t;F[45]=62,F[95]=63}function Qt(n){Ce||et();var t,e,r,i,o,s,f=n.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=n[f-2]==="="?2:n[f-1]==="="?1:0,s=new Kt(f*3/4-o),r=o>0?f-4:f;var h=0;for(t=0,e=0;t<r;t+=4,e+=3)i=F[n.charCodeAt(t)]<<18|F[n.charCodeAt(t+1)]<<12|F[n.charCodeAt(t+2)]<<6|F[n.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=F[n.charCodeAt(t)]<<2|F[n.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=F[n.charCodeAt(t)]<<10|F[n.charCodeAt(t+1)]<<4|F[n.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function Zt(n){return U[n>>18&63]+U[n>>12&63]+U[n>>6&63]+U[n&63]}function er(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(Zt(r));return i.join("")}function Ke(n){Ce||et();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,f=0,h=e-r;f<h;f+=s)o.push(er(n,f,f+s>h?h:f+s));return r===1?(t=n[e-1],i+=U[t>>2],i+=U[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=U[t>>10],i+=U[t>>4&63],i+=U[t<<2&63],i+="="),o.push(i),o.join("")}function ye(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function L(n,t){if(ye()<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 ke(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?nr(n,t,e,r):typeof t=="string"?rr(n,t,e):ir(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 tr(n,t,e,r){return rt(t),t<=0?L(n,t):e!==void 0?typeof r=="string"?L(n,t).fill(e,r):L(n,t).fill(e):L(n,t)}function ke(n,t){if(rt(t),n=L(n,t<0?0:_e(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function rr(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=L(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:_e(t.length)|0;n=L(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function nr(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 ir(n,t){if(B(t)){var e=_e(t.length)|0;return n=L(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"||Rr(t.length)?L(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 _e(n){if(n>=ye())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye().toString(16)+" bytes");return n|0}function B(n){return!!(n!=null&&n._isBuffer)}function nt(n,t){if(B(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 ge(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 ge(n).length;t=(""+t).toLowerCase(),r=!0}}function or(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 mr(this,t,e);case"utf8":case"utf-8":return st(this,t,e);case"ascii":return hr(this,t,e);case"latin1":case"binary":return dr(this,t,e);case"base64":return lr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yr(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function Y(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)),B(t))return t.length===0?-1:Qe(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):Qe(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function Qe(n,t,e,r,i){var o=1,s=n.length,f=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,f/=2,e/=2}function h(T,A){return o===1?T[A]:T.readUInt16BE(A*o)}var y;if(i){var g=-1;for(y=e;y<s;y++)if(h(n,y)===h(t,g===-1?0:y-g)){if(g===-1&&(g=y),y-g+1===f)return g*o}else g!==-1&&(y-=y-g),g=-1}else for(e+f>s&&(e=s-f),y=e;y>=0;y--){for(var m=!0,R=0;R<f;R++)if(h(n,y+R)!==h(t,R)){m=!1;break}if(m)return y}return-1}function sr(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 f=parseInt(t.substr(s*2,2),16);if(isNaN(f))return s;n[e+s]=f}return s}function ar(n,t,e,r){return ve(ge(t,n.length-e),n,e,r)}function ot(n,t,e,r){return ve(Tr(t),n,e,r)}function cr(n,t,e,r){return ot(n,t,e,r)}function ur(n,t,e,r){return ve(pt(t),n,e,r)}function pr(n,t,e,r){return ve(Ir(t,n.length-e),n,e,r)}function lr(n,t,e){return t===0&&e===n.length?Ke(n):Ke(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,f=o>239?4:o>223?3:o>191?2:1;if(i+f<=e){var h,y,g,m;switch(f){case 1:o<128&&(s=o);break;case 2:h=n[i+1],(h&192)===128&&(m=(o&31)<<6|h&63,m>127&&(s=m));break;case 3:h=n[i+1],y=n[i+2],(h&192)===128&&(y&192)===128&&(m=(o&15)<<12|(h&63)<<6|y&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:h=n[i+1],y=n[i+2],g=n[i+3],(h&192)===128&&(y&192)===128&&(g&192)===128&&(m=(o&15)<<18|(h&63)<<12|(y&63)<<6|g&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,f=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=f}return fr(r)}function fr(n){var t=n.length;if(t<=Ze)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=Ze));return e}function hr(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 dr(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 mr(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 yr(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(!B(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 xe(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 we(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 xr(n){if(n=wr(n).replace(gr,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function wr(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 ge(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 Tr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Ir(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 Qt(xr(n))}function ve(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 Rr(n){return n!==n}function Ar(n){return n!=null&&(!!n._isBuffer||lt(n)||Er(n))}function lt(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Er(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&<(n.slice(0,0))}function Te(n,t,e,r,i){var o,s,f=i*8-r-1,h=(1<<f)-1,y=h>>1,g=-7,m=e?i-1:0,R=e?-1:1,T=n[t+m];for(m+=R,o=T&(1<<-g)-1,T>>=-g,g+=f;g>0;o=o*256+n[t+m],m+=R,g-=8);for(s=o&(1<<-g)-1,o>>=-g,g+=r;g>0;s=s*256+n[t+m],m+=R,g-=8);if(o===0)o=1-y;else{if(o===h)return s?NaN:(T?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-y}return(T?-1:1)*s*Math.pow(2,o-r)}function ft(n,t,e,r,i,o){var s,f,h,y=o*8-i-1,g=(1<<y)-1,m=g>>1,R=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=r?0:o-1,A=r?1:-1,te=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,s=g):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+m>=1?t+=R/h:t+=R*Math.pow(2,1-m),t*h>=2&&(s++,h/=2),s+m>=g?(f=0,s=g):s+m>=1?(f=(t*h-1)*Math.pow(2,i),s=s+m):(f=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;n[e+T]=f&255,T+=A,f/=256,i-=8);for(s=s<<i|f,y+=i;y>0;n[e+T]=s&255,T+=A,s/=256,y-=8);n[e+T-A]|=te*128}var U,F,Kt,Ce,Ze,gr,ht=Ue(()=>{"use strict";u();p();U=[],F=[],Kt=typeof Uint8Array!="undefined"?Uint8Array:Array,Ce=!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=ye();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 tr(null,n,t,e)};a.allocUnsafe=function(n){return ke(null,n)};a.allocUnsafeSlow=function(n){return ke(null,n)};a.isBuffer=Ar;a.compare=function(t,e){if(!B(t)||!B(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(!B(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)Y(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)Y(this,e,e+3),Y(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)Y(this,e,e+7),Y(this,e+1,e+6),Y(this,e+2,e+5),Y(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):or.apply(this,arguments)};a.prototype.equals=function(t){if(!B(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,r,i,o){if(!B(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,f=r-e,h=Math.min(s,f),y=this.slice(i,o),g=t.slice(e,r),m=0;m<h;++m)if(y[m]!==g[m]){s=y[m],f=g[m];break}return s<f?-1:f<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 sr(this,t,e,r);case"utf8":case"utf-8":return ar(this,t,e,r);case"ascii":return ot(this,t,e,r);case"latin1":case"binary":return cr(this,t,e,r);case"base64":return ur(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pr(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)}};Ze=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),Te(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||I(t,4,this.length),Te(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||I(t,8,this.length),Te(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||I(t,8,this.length),Te(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,f=0;for(this[e]=t&255;++f<r&&(s*=256);)this[e+f]=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,f=1;for(this[e+s]=t&255;--s>=0&&(f*=256);)this[e+s]=t/f&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):xe(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):xe(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):we(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):we(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,f=1,h=0;for(this[e]=t&255;++s<r&&(f*=256);)t<0&&h===0&&this[e+s-1]!==0&&(h=1),this[e+s]=(t/f>>0)-h&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,f=1,h=0;for(this[e+s]=t&255;--s>=0&&(f*=256);)t<0&&h===0&&this[e+s+1]!==0&&(h=1),this[e+s]=(t/f>>0)-h&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):xe(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):xe(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):we(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):we(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 f=B(t)?t:ge(new a(t,i).toString()),h=f.length;for(s=0;s<r-e;++s)this[s+e]=f[s%h]}return this};gr=/[^+\/0-9A-Za-z-_]/g});var p=Ue(()=>{"use strict";ht()});var an={};Ye(an,{DynamicSnippetsGenerator:()=>De});module.exports=Rt(an);u();p();u();p();u();p();function v(n){throw new Error("Unexpected value: "+JSON.stringify(n))}u();p();function re(n){return Object.keys(n)}u();p();u();p();var W=class{};u();p();u();p();var C=class extends W{constructor(e){super();l(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var Nr=4,ne=class{constructor(){l(this,"buffer","");l(this,"indentLevel",0);l(this,"hasWrittenAnything",!1);l(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
|
|
2
2
|
`),r=e?t.substring(0,t.length-1):t,i=this.getIndentString(),o=r.replaceAll(`
|
|
3
3
|
`,`
|
|
4
4
|
${i}`);this.isAtStartOfLine()&&(o=i+o),e&&(o+=`
|
|
5
|
-
`),this.writeInternal(o)}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){t.write(this)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new
|
|
5
|
+
`),this.writeInternal(o)}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){t.write(this)}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 C(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new C(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 C(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}alternativeControlFlow(t){this.dedent(),this.write("} "),new C(t).write(this),this.write(" {"),this.writeNewLineIfLastLineNot(),this.indent()}openBlock(t,e="{",r,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(),r(),this.dedent()}finally{this.write(i!=null?i:"")}}writeLine(t=""){this.write(t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
6
6
|
`)}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
7
7
|
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}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){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*Er)}};u();p();var Te=class{},ne=class extends Te{async format(t){return t}formatSync(t){return t}};u();p();function Ce(n){return(n==null?void 0:n.name)!=null}u();p();u();p();var ie=class{constructor(t){l(this,"context");this.context=t}};u();p();u();p();u();p();var oe=class{constructor(){l(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH)\s(\/[a-zA-Z0-9\/{}_-]*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let r=t.match(this.REFERENCE_REGEX);if(!(r==null||r[1]==null||r[2]==null))return{method:r[1],path:r[2]}}};u();p();var x={Critical:"CRITICAL",Warning:"WARNING"},se=class n{constructor(){l(this,"errors");l(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push(Ve(De({},t),{path:[...this.path]}))}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let t=new n;return t.errors=[...this.errors],t.path=[...this.path],t}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(t=>({severity:t.severity,path:t.path!=null?this.pathToStringArray(t.path):void 0,message:t.message}))}pathToStringArray(t){let e=[];for(let r of t){if(typeof r=="string"){e.push(r);continue}e[e.length-1]+=`[${r.index}]`}return e}};var ae=class{constructor({ir:t,config:e}){l(this,"config");l(this,"errors");l(this,"_ir");l(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.errors=new se,this.httpEndpointReferenceParser=new oe}associateQueryParametersByWireValue({parameters:t,values:e}){let r=[];for(let[i,o]of Object.entries(e)){this.errors.scope(i);try{let s=t.find(h=>h.name.wireValue===i);if(s==null)throw this.newParameterNotRecognizedError(i);let f=this.isListTypeReference(s.typeReference)&&!Array.isArray(o)?[o]:o;r.push({name:s.name,typeReference:s.typeReference,value:f})}finally{this.errors.unscope()}}return r}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:r}){let i=[];for(let[o,s]of Object.entries(e)){this.errors.scope(o);try{let f=t.find(h=>h.name.wireValue===o);if(f==null){if(r)continue;this.errors.add({severity:x.Critical,message:this.newParameterNotRecognizedError(o).message});continue}i.push({name:f.name,typeReference:f.typeReference,value:s})}finally{this.errors.unscope()}}return i}getSingleFileValue({property:t,record:e}){let r=e[t.wireValue];if(r!=null){if(typeof r!="string"){this.errors.add({severity:x.Critical,message:`Expected file value to be a string, got ${typeof r}`});return}return r}}getFileArrayValues({property:t,record:e}){let r=e[t.wireValue];if(r==null)return;if(!Array.isArray(r)){this.errors.add({severity:x.Critical,message:`Expected file array value to be an array of strings, got ${typeof r}`});return}let i=[];for(let o of r){if(typeof o!="string"){this.errors.add({severity:x.Critical,message:`Expected file array value to be an array of strings, got ${typeof o}`});return}i.push(o)}return i}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:x.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t==null?{}:t}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:x.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let r=this.getRecord(e);if(r==null)return;let i=t.discriminant.wireValue,o=r[i];if(o==null){this.errors.add({severity:x.Critical,message:this.newParameterNotRecognizedError(i).message});return}if(typeof o!="string"){this.errors.add({severity:x.Critical,message:`Expected discriminant value to be a string but got: ${typeof o}`});return}let s=t.types[o];if(s==null){this.errors.add({severity:x.Critical,message:`No type found for discriminant value "${o}"`});return}let y=r,{[i]:f}=y,h=Oe(y,[$e(i)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:h}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocationOrThrow(t){let e=[];for(let r of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:r,parsedEndpoint:t})&&e.push(r);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:r}){var i;return this.includePathParametersInWrappedRequest({request:t,inlinePathParameters:e})||t.queryParameters!=null&&t.queryParameters.length>0||t.headers!=null&&t.headers.length>0?!0:t.body!=null?this.includeRequestBodyInWrappedRequest({body:t.body,inlineFileProperties:r}):!((i=t.metadata)!=null&&i.onlyPathParameters)}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){var r,i;return e&&((i=(r=t.metadata)==null?void 0:r.includePathParameters)!=null?i:!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:w(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let r=e.environments.find(i=>i.id===t);return r==null?void 0:r.name}case"multipleBaseUrls":{let r=e.environments.find(i=>i.id===t);return r==null?void 0:r.name}default:w(e)}}isSingleEnvironmentID(t){return typeof t=="string"}isMultiEnvironmentValues(t){return typeof t=="object"}validateMultiEnvironmentUrlValues(t){if(this._ir.environments==null)return this.errors.add({severity:x.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":return this.errors.add({severity:x.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let r=e.environments[0];if(r==null)return this.errors.add({severity:x.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let i=new Set(te(r.urls));for(let o of te(t))i.has(o)&&i.delete(o);return i.size>0?(this.errors.add({severity:x.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${te(r.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:x.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:x.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:x.Critical,message:this.newTypeMismatchError({expected:"string",value:t}).message});return}return t}isOptional(t){switch(t.type){case"nullable":return this.isOptional(t.value);case"optional":return!0;case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}isNullable(t){switch(t.type){case"nullable":return!0;case"optional":return this.isNullable(t.value);case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}newAuthMismatchError({auth:t,values:e}){return new Error(`Expected auth type ${t.type}, got ${e.type}`)}newParameterNotRecognizedError(t){return new Error(`"${t}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:t,value:e}){return new Error(`Expected ${t}, got ${typeof e}`)}includeRequestBodyInWrappedRequest({body:t,inlineFileProperties:e}){switch(t.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e});default:w(t)}}includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e}){return this.fileUploadHasBodyProperties({fileUpload:t})||e&&this.fileUploadHasFileProperties({fileUpload:t})}fileUploadHasBodyProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:w(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:w(e)}})}isListTypeReference(t){return t.type==="optional"?this.isListTypeReference(t.value):t.type==="list"||t.type==="set"}parsedEndpointMatches({endpoint:t,parsedEndpoint:e}){return t.location.method===e.method&&t.location.path===e.path}};u();p();var ee=class{constructor(){l(this,"reporter");l(this,"snippet");l(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:t,snippet:e}){(this.reporter==null||this.reporter.size()>t.errors.size())&&(this.reporter=t.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:t}){var e;if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw(e=this.err)!=null?e:new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}};u();p();var k={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};u();p();u();p();function ce(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();u();p();u();p();u();p();u();p();var Nr=/[^0-9a-zA-Z_]/g,H=class extends re{constructor({packageName:e,rootImportPath:r,importPath:i,customConfig:o,formatter:s}){super();l(this,"packageName");l(this,"rootImportPath");l(this,"importPath");l(this,"customConfig");l(this,"formatter");l(this,"imports",{});this.packageName=e,this.rootImportPath=r,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new ne}addImport(e){let r=this.imports[e];if(r!=null)return r;let i=this.getValidAlias(ce(e));for(;i in this.imports;)i="_"+i;return this.imports[e]=i,i}getValidAlias(e){let r=e.split("-");return r[0]==null?e:r[0].replace(Nr,"")}};var ue=class extends H{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}
|
|
8
|
+
`)),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*Nr)}};u();p();var Ie=class{},ie=class extends Ie{async format(t){return t}formatSync(t){return t}};u();p();function Me(n){return(n==null?void 0:n.name)!=null}u();p();u();p();u();p();var oe=class{constructor(){l(this,"reporter");l(this,"snippet");l(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:t,snippet:e}){(this.reporter==null||this.reporter.size()>t.errors.size())&&(this.reporter=t.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:t}){var e;if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw(e=this.err)!=null?e:new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}};var se=class{constructor(t){l(this,"context");this.context=t}async generate(t){let e=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(e.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let r=new oe;for(let i of e){let o=this.context.clone(),s=this.createSnippetGenerator(o);try{let f=await s.generateSnippet({endpoint:i,request:t});if(o.errors.empty())return{snippet:f,errors:void 0};r.update({context:o,snippet:f})}catch(f){r.err==null&&(r.err=f)}}return r.getResponseOrThrow({endpoint:t.endpoint})}generateSync(t){let e=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(e.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let r=new oe;for(let i of e){let o=this.context.clone(),s=this.createSnippetGenerator(o);try{let f=s.generateSnippetSync({endpoint:i,request:t});if(o.errors.empty())return{snippet:f,errors:void 0};r.update({context:o,snippet:f})}catch(f){r.err==null&&(r.err=f)}}return r.getResponseOrThrow({endpoint:t.endpoint})}};u();p();u();p();u();p();var ae=class{constructor(){l(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH)\s(\/[a-zA-Z0-9\/{}_-]*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let r=t.match(this.REFERENCE_REGEX);if(!(r==null||r[1]==null||r[2]==null))return{method:r[1],path:r[2]}}};u();p();var x={Critical:"CRITICAL",Warning:"WARNING"},ce=class n{constructor(){l(this,"errors");l(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push(Oe($e({},t),{path:[...this.path]}))}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let t=new n;return t.errors=[...this.errors],t.path=[...this.path],t}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(t=>({severity:t.severity,path:t.path!=null?this.pathToStringArray(t.path):void 0,message:t.message}))}pathToStringArray(t){let e=[];for(let r of t){if(typeof r=="string"){e.push(r);continue}e[e.length-1]+=`[${r.index}]`}return e}};var ue=class{constructor({ir:t,config:e}){l(this,"config");l(this,"errors");l(this,"_ir");l(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.errors=new ce,this.httpEndpointReferenceParser=new ae}associateQueryParametersByWireValue({parameters:t,values:e}){let r=[];for(let[i,o]of Object.entries(e)){this.errors.scope(i);try{let s=t.find(h=>h.name.wireValue===i);if(s==null)throw this.newParameterNotRecognizedError(i);let f=this.isListTypeReference(s.typeReference)&&!Array.isArray(o)?[o]:o;r.push({name:s.name,typeReference:s.typeReference,value:f})}finally{this.errors.unscope()}}return r}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:r}){let i=[];for(let[o,s]of Object.entries(e)){this.errors.scope(o);try{let f=t.find(h=>h.name.wireValue===o);if(f==null){if(r)continue;this.errors.add({severity:x.Critical,message:this.newParameterNotRecognizedError(o).message});continue}i.push({name:f.name,typeReference:f.typeReference,value:s})}finally{this.errors.unscope()}}return i}getSingleFileValue({property:t,record:e}){let r=e[t.wireValue];if(r!=null){if(typeof r!="string"){this.errors.add({severity:x.Critical,message:`Expected file value to be a string, got ${typeof r}`});return}return r}}getFileArrayValues({property:t,record:e}){let r=e[t.wireValue];if(r==null)return;if(!Array.isArray(r)){this.errors.add({severity:x.Critical,message:`Expected file array value to be an array of strings, got ${typeof r}`});return}let i=[];for(let o of r){if(typeof o!="string"){this.errors.add({severity:x.Critical,message:`Expected file array value to be an array of strings, got ${typeof o}`});return}i.push(o)}return i}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:x.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t==null?{}:t}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:x.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let r=this.getRecord(e);if(r==null)return;let i=t.discriminant.wireValue,o=r[i];if(o==null){this.errors.add({severity:x.Critical,message:this.newParameterNotRecognizedError(i).message});return}if(typeof o!="string"){this.errors.add({severity:x.Critical,message:`Expected discriminant value to be a string but got: ${typeof o}`});return}let s=t.types[o];if(s==null){this.errors.add({severity:x.Critical,message:`No type found for discriminant value "${o}"`});return}let y=r,{[i]:f}=y,h=qe(y,[Ge(i)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:h}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocationOrThrow(t){let e=[];for(let r of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:r,parsedEndpoint:t})&&e.push(r);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:r}){var i;return this.includePathParametersInWrappedRequest({request:t,inlinePathParameters:e})||t.queryParameters!=null&&t.queryParameters.length>0||t.headers!=null&&t.headers.length>0?!0:t.body!=null?this.includeRequestBodyInWrappedRequest({body:t.body,inlineFileProperties:r}):!((i=t.metadata)!=null&&i.onlyPathParameters)}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){var r,i;return e&&((i=(r=t.metadata)==null?void 0:r.includePathParameters)!=null?i:!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:v(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let r=e.environments.find(i=>i.id===t);return r==null?void 0:r.name}case"multipleBaseUrls":{let r=e.environments.find(i=>i.id===t);return r==null?void 0:r.name}default:v(e)}}isSingleEnvironmentID(t){return typeof t=="string"}isMultiEnvironmentValues(t){return typeof t=="object"}validateMultiEnvironmentUrlValues(t){if(this._ir.environments==null)return this.errors.add({severity:x.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":return this.errors.add({severity:x.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let r=e.environments[0];if(r==null)return this.errors.add({severity:x.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let i=new Set(re(r.urls));for(let o of re(t))i.has(o)&&i.delete(o);return i.size>0?(this.errors.add({severity:x.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${re(r.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:x.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:x.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:x.Critical,message:this.newTypeMismatchError({expected:"string",value:t}).message});return}return t}isOptional(t){switch(t.type){case"nullable":return this.isOptional(t.value);case"optional":return!0;case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}isNullable(t){switch(t.type){case"nullable":return!0;case"optional":return this.isNullable(t.value);case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}newAuthMismatchError({auth:t,values:e}){return new Error(`Expected auth type ${t.type}, got ${e.type}`)}newParameterNotRecognizedError(t){return new Error(`"${t}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:t,value:e}){return new Error(`Expected ${t}, got ${typeof e}`)}includeRequestBodyInWrappedRequest({body:t,inlineFileProperties:e}){switch(t.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e});default:v(t)}}includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e}){return this.fileUploadHasBodyProperties({fileUpload:t})||e&&this.fileUploadHasFileProperties({fileUpload:t})}fileUploadHasBodyProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:v(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:v(e)}})}isListTypeReference(t){return t.type==="optional"?this.isListTypeReference(t.value):t.type==="list"||t.type==="set"}parsedEndpointMatches({endpoint:t,parsedEndpoint:e}){return t.location.method===e.method&&t.location.path===e.path}};u();p();var k={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};u();p();u();p();function pe(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();u();p();u();p();u();p();u();p();var Fr=/[^0-9a-zA-Z_]/g,H=class extends ne{constructor({packageName:e,rootImportPath:r,importPath:i,customConfig:o,formatter:s}){super();l(this,"packageName");l(this,"rootImportPath");l(this,"importPath");l(this,"customConfig");l(this,"formatter");l(this,"imports",{});this.packageName=e,this.rootImportPath=r,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new ie}addImport(e){let r=this.imports[e];if(r!=null)return r;let i=new Set(Object.values(this.imports)),o=this.getValidAlias(pe(e));for(;i.has(o);)o="_"+o;return this.imports[e]=o,o}getValidAlias(e){let r=e.split("-");return r[0]==null?e:r[0].replace(Fr,"")}};var le=class extends H{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
9
|
${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
10
|
${t}`)}return t}getContent(){let t=`package ${this.packageName}
|
|
11
11
|
|
|
@@ -14,9 +14,9 @@ ${t}`)}return t}getContent(){let t=`package ${this.packageName}
|
|
|
14
14
|
${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.imports).filter(([e,r])=>e!==this.importPath).map(([e,r])=>` ${r} "${e}"`).join(`
|
|
15
15
|
`);return t?`import (
|
|
16
16
|
${t}
|
|
17
|
-
)`:""}};var
|
|
18
|
-
`).forEach(r=>{e.writeLine(`// ${r}`)})}};var j=class extends
|
|
19
|
-
`)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(Or({value:this.internalType.value}));break;default:w(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}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:r})})}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("[]interface{}"),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]interface{}");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=qr({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(Lr.has(r.internalType.type)){e.writeNode(Dr({writer:e,type:r}));return}if(ft.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"||ft.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);let i=Gr({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 Dr({writer:n,type:t}){return new U({func:new E({name:Vr({type:t}),importPath:n.rootImportPath}),arguments_:[t]})}function Vr({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 $r({writer:n,type:t}){let e=t instanceof Date?"MustParseDate":"MustParseDateTime";return new U({func:new E({name:e,importPath:n.rootImportPath}),arguments_:[new C(`"${t.value}"`)]})}function Or({value:n}){return new U({func:new E({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new C(`"${n}"`)]})}function qr({entries:n}){return n.filter(t=>!b.isNop(t.key)&&!b.isNop(t.value))}function Gr({fields:n}){return n.filter(t=>!b.isNop(t.value))}function Yr({values:n}){return n.filter(t=>!b.isNop(t))}function Ie({writer:n,arguments_:t}){let e=Hr(t);if(e.length===0){n.write("()");return}n.writeLine("("),n.indent();for(let r of e)Wr({writer:n,argument:r}),n.writeLine(",");n.dedent(),n.write(")")}function Wr({writer:n,argument:t}){Ce(t)?t.assignment.write(n):t.write(n)}function Hr(n){return n.filter(t=>!(t instanceof b&&b.isNop(t)))}var U=class extends v{constructor({func:e,arguments_:r}){super();l(this,"func");l(this,"arguments_");this.func=e,this.arguments_=r}write(e){e.writeNode(this.func),Ie({writer:e,arguments_:this.arguments_})}};u();p();var J=class extends v{constructor({name:e,type:r,docs:i}){super();l(this,"name");l(this,"type");l(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new P({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};u();p();var Q=class extends v{constructor({name:e,importPath:r,docs:i}){super();l(this,"name");l(this,"importPath");l(this,"docs");l(this,"fields",[]);l(this,"methods",[]);this.name=e,this.importPath=r,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 r of this.fields)e.writeNode(r),e.newLine();e.dedent(),e.writeLine("}")}(this.constructor!=null||this.methods.length>0)&&e.newLine();for(let r of this.methods)e.writeNode(r),e.newLine()}};var c={};qe(c,{AstNode:()=>v,CodeBlock:()=>C,Enum:()=>j,Field:()=>z,Func:()=>X,FuncInvocation:()=>U,Method:()=>L,MethodInvocation:()=>D,Parameter:()=>J,Struct:()=>Q,Type:()=>pe,TypeInstantiation:()=>b,TypeReference:()=>E,Writer:()=>H,codeblock:()=>jr,enum_:()=>zr,field:()=>Xr,func:()=>Jr,invokeFunc:()=>Qr,invokeMethod:()=>Kr,method:()=>Zr,parameter:()=>en,struct:()=>tn,typeReference:()=>rn});u();p();function jr(n){return new C(n)}function zr(n){return new j(n)}function Xr(n){return new z(n)}function Jr(n){return new X(n)}function Qr(n){return new U(n)}function Kr(n){return new D(n)}function Zr(n){return new L(n)}function en(n){return new J(n)}function tn(n){return new Q(n)}function rn(n){return new E(n)}var ht="example",dt="fern",nn="do",mt="client",le=class{constructor({context:t,formatter:e}){l(this,"context");l(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:ht,importPath:dt,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:ht,importPath:dt,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return c.func({name:nn,parameters:[],return_:[],body:c.codeblock(r=>{r.writeNode(this.constructClient({endpoint:t,snippet:e})),r.writeLine(),r.writeNode(this.callMethod({endpoint:t,snippet:e}))})})}constructClient({endpoint:t,snippet:e}){return c.codeblock(r=>{r.write(`${mt} := `),r.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}callMethod({endpoint:t,snippet:e}){return c.invokeMethod({on:c.codeblock(mt),method:this.getMethod({endpoint:t}),arguments_:[this.context.getContextTodoFunctionInvocation(),...this.getMethodArgs({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:x.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(k.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}getConstructorAuthArg({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.context.errors.add({severity:x.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),c.TypeInstantiation.nop()):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.context.errors.add({severity:x.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),c.TypeInstantiation.nop()):this.getConstructorBearerAuthArg({auth:t,values:e});case"header":return e.type!=="header"?(this.context.errors.add({severity:x.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),c.TypeInstantiation.nop()):this.getConstructorHeaderAuthArg({auth:t,values:e});default:w(t)}}getConstructorBasicAuthArg({auth:t,values:e}){return c.codeblock(r=>{r.writeNode(c.invokeFunc({func:c.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[c.TypeInstantiation.string(e.username),c.TypeInstantiation.string(e.password)]}))})}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let r=this.getBaseUrlArg({baseUrl:t,environment:e});if(r!=null)return c.codeblock(i=>{i.writeNode(c.invokeFunc({func:c.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[r]}))})}getBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:x.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return c.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:x.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return c.TypeInstantiation.reference(r)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:x.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 c.codeblock(r=>{r.writeNode(c.invokeFunc({func:c.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[c.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return c.codeblock(r=>{r.writeNode(c.invokeFunc({func:c.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(!c.TypeInstantiation.isNop(r))return c.codeblock(i=>{i.writeNode(c.invokeFunc({func:c.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:w(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let r=[];if(this.context.errors.scope(k.PathParameters),t.pathParameters!=null){let i=this.getPathParameters({namedParameters:t.pathParameters,snippet:e});r.push(...i.map(o=>o.value))}return this.context.errors.unscope(),this.context.errors.scope(k.RequestBody),t.body!=null&&r.push(this.getBodyRequestArg({body:t.body,value:e.requestBody})),this.context.errors.unscope(),r}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:w(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:x.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),c.TypeInstantiation.nop()):c.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){var h,y,g,m;let r=[],{inlinePathParameters:i,inlineFileProperties:o}={inlinePathParameters:(y=(h=this.context.customConfig)==null?void 0:h.inlinePathParameters)!=null?y:!1,inlineFileProperties:(m=(g=this.context.customConfig)==null?void 0:g.inlineFileProperties)!=null?m:!1};this.context.errors.scope(k.PathParameters);let s=[];t.pathParameters!=null&&s.push(...this.getPathParameters({namedParameters:t.pathParameters,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(k.RequestBody);let f=this.getFilePropertyInfo({request:t,snippet:e});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})||r.push(...s.map(T=>T.value)),o||r.push(...f.fileFields.map(T=>T.value)),this.context.needsRequestParameter({request:t,inlinePathParameters:i,inlineFileProperties:o})&&r.push(this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})?s:[],filePropertyInfo:f})),r}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 g,m,T,R;this.context.errors.scope(k.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(g=t.queryParameters)!=null?g:[],values:(m=e.queryParameters)!=null?m:{}}).map(N=>({name:N.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(N)}));this.context.errors.unscope(),this.context.errors.scope(k.Headers);let h=this.context.associateByWireValue({parameters:(T=t.headers)!=null?T:[],values:(R=e.headers)!=null?R:{}}).map(N=>({name:N.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(N)}));this.context.errors.unscope(),this.context.errors.scope(k.RequestBody);let y=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),c.TypeInstantiation.structPointer({typeReference:c.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:[...r,...s,...h,...y]})}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:w(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:w(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.convert(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 c.invokeFunc({func:c.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}};u();p();u();p();var Re=class{constructor({context:t}){l(this,"context");this.context=t}convert(t){if(t.value===null&&!this.context.isNullable(t.typeReference)&&this.context.errors.add({severity:x.Critical,message:"Expected non-null value, but got null"}),t.value==null)return c.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return c.TypeInstantiation.nop();case"map":return this.convertMap({map:t.typeReference,value:t.value});case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?c.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"nullable":return c.TypeInstantiation.optional(this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as}));case"optional":return c.TypeInstantiation.optional(this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertList({list:t.typeReference.value,value:t.value});case"unknown":return this.convertUnknown({value:t.value});default:w(t.typeReference)}}convertList({list:t,value:e}){return Array.isArray(e)?c.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:t}),values:e.map((r,i)=>{this.context.errors.scope({index:i});try{return this.convert({typeReference:t,value:r})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:x.Critical,message:`Expected array but got: ${typeof e}`}),c.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:x.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),c.TypeInstantiation.nop()):c.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries:Object.entries(e).map(([r,i])=>{this.context.errors.scope(r);try{return{key:this.convert({typeReference:t.key,value:r,as:"key"}),value:this.convert({typeReference:t.value,value:i})}}finally{this.context.errors.unscope()}})})}convertNamed({named:t,value:e,as:r}){switch(t.type){case"alias":return this.convert({typeReference:t.typeReference,value:e,as:r});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:e});case"enum":return this.convertEnum({enum_:t,value:e});case"object":return this.convertObject({object_:t,value:e});case"undiscriminatedUnion":return this.convertUndicriminatedUnion({undicriminatedUnion:t,value:e});default:w(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let r=this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(i==null)return c.TypeInstantiation.nop();let o=i.singleDiscriminatedUnionType,s=this.getBaseFields({discriminatedUnionTypeInstance:i,singleDiscriminatedUnionType:o});switch(o.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:o.typeId});return f==null?c.TypeInstantiation.nop():c.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(o.discriminantValue.name),value:this.convertNamed({named:f,value:i.value})},...s]})}case"singleProperty":{let f=this.context.getRecord(i.value);if(f==null)return c.TypeInstantiation.nop();try{return this.context.errors.scope(o.discriminantValue.wireValue),c.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(o.discriminantValue.name),value:this.convert({typeReference:o.typeReference,value:f[o.discriminantValue.wireValue]})},...s]})}finally{this.context.errors.unscope()}}case"noProperties":return c.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(i.discriminantValue.name),value:c.TypeInstantiation.string(o.discriminantValue.wireValue)},...s]});default:w(o)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){var i,o;return this.context.associateByWireValue({parameters:(i=e.properties)!=null?i:[],values:(o=this.context.getRecord(t.value))!=null?o:{},ignoreMissingParameters:!0}).map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getTypeName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})}convertObject({object_:t,value:e}){var i;let r=this.context.associateByWireValue({parameters:t.properties,values:(i=this.context.getRecord(e))!=null?i:{}});return c.TypeInstantiation.structPointer({typeReference:c.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:r.map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getTypeName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:t,value:e}){let r=this.getEnumValueName({enum_:t,value:e});return r==null?c.TypeInstantiation.nop():c.TypeInstantiation.enum(c.typeReference({name:r,importPath:this.context.getImportPath(t.declaration.fernFilepath)}))}getEnumValueName({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:x.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let r=t.values.find(i=>i.wireValue===e);if(r==null){this.context.errors.add({severity:x.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return`${this.context.getTypeName(t.declaration.name)}${this.context.getTypeName(r.name)}`}convertUndicriminatedUnion({undicriminatedUnion:t,value:e}){let r=this.findMatchingUndiscriminatedUnionType({undicriminatedUnion:t,value:e});if(r==null)return c.TypeInstantiation.nop();let i=this.getUndiscriminatedUnionFieldName({typeReference:r.valueTypeReference});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),fields:[{name:i,value:r.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undicriminatedUnion:t,value:e}){for(let r of t.types)try{let i=this.convert({typeReference:r,value:e});return{valueTypeReference:r,typeInstantiation:i}}catch(i){continue}this.context.errors.add({severity:x.Critical,message:`None of the types in the undicriminated union matched the given "${typeof e}" value`})}getUndiscriminatedUnionFieldName({typeReference:t}){switch(t.type){case"list":return this.getUndiscriminatedUnionFieldNameForList({list:t});case"literal":return this.getUndiscriminatedUnionFieldNameForLiteral({literal:t.value});case"map":return this.getUndiscriminatedUnionFieldNameForMap({map:t});case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?void 0:this.context.getTypeName(e.declaration.name)}case"optional":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"nullable":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:t.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:t});case"unknown":return"Unknown";default:w(t)}}getUndiscriminatedUnionFieldNameForList({list:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}List`}getUndiscriminatedUnionFieldNameForMap({map:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.key});if(e==null)return;let r=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(r!=null)return`${e}${r}Map`}getUndiscriminatedUnionFieldNameForOptional({typeReference:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Set`}getUndiscriminatedUnionFieldNameForLiteral({literal:t}){switch(t.type){case"boolean":return t.value?"TrueLiteral":"FalseLiteral";case"string":return`${t.value}StringLiteral`;default:w(t)}}getUndiscriminatedUnionFieldNameForPrimitive({primitive:t}){switch(t){case"INTEGER":case"UINT":return"Integer";case"LONG":case"UINT_64":return"Long";case"FLOAT":case"DOUBLE":return"Double";case"BOOLEAN":return"Boolean";case"BIG_INTEGER":case"STRING":return"String";case"UUID":return"Uuid";case"DATE":return"Date";case"DATE_TIME":return"DateTime";case"BASE_64":return"Base64";default:w(t)}}convertUnknown({value:t}){return c.TypeInstantiation.any(t)}convertPrimitive({primitive:t,value:e,as:r}){switch(t){case"INTEGER":case"UINT":{let i=this.getValueAsNumber({value:e,as:r});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.int(i)}case"LONG":case"UINT_64":{let i=this.getValueAsNumber({value:e,as:r});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.int64(i)}case"FLOAT":case"DOUBLE":{let i=this.getValueAsNumber({value:e,as:r});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.float64(i)}case"BOOLEAN":{let i=this.getValueAsBoolean({value:e,as:r});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.bool(i)}case"STRING":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.string(i)}case"DATE":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.date(i)}case"DATE_TIME":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.dateTime(i)}case"UUID":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.uuid(i)}case"BASE_64":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.bytes(i)}case"BIG_INTEGER":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.string(i)}default:w(t)}}getValueAsNumber({value:t,as:e}){let r=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:r})}getValueAsBoolean({value:t,as:e}){let r=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:r})}};u();p();var Ae=class{constructor({context:t}){l(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return c.Type.slice(this.convert({typeReference:t.typeReference}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return c.Type.map(this.convert({typeReference:t.typeReference.key}),this.convert({typeReference:t.typeReference.value}));case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?this.convertUnknown():this.convertNamed({named:e})}case"optional":return c.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return c.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return c.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:w(t.typeReference)}}convertLiteral({literal:t}){switch(t.type){case"boolean":return c.Type.bool();case"string":return c.Type.string()}}convertNamed({named:t}){let e=c.Type.reference(c.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}));switch(t.type){case"alias":case"enum":return e;case"discriminatedUnion":case"object":case"undiscriminatedUnion":return c.Type.pointer(e);default:w(t)}}convertUnknown(){return c.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return c.Type.int();case"UINT":return c.Type.int();case"LONG":return c.Type.int64();case"UINT_64":return c.Type.int64();case"FLOAT":return c.Type.float64();case"DOUBLE":return c.Type.float64();case"BOOLEAN":return c.Type.bool();case"STRING":return c.Type.string();case"DATE":return c.Type.date();case"DATE_TIME":return c.Type.dateTime();case"UUID":return c.Type.uuid();case"BASE_64":return c.Type.bytes();case"BIG_INTEGER":return c.Type.string();default:w(t)}}};u();p();var Ee=class{constructor({context:t}){l(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){var o;let r={fileFields:[],bodyPropertyFields:[]},i=(o=this.context.getRecord(e))!=null?o:{};for(let s of t.properties)switch(s.type){case"file":r.fileFields.push({name:this.context.getTypeName(s.name),value:this.getSingleFileProperty({property:s,record:i})});break;case"fileArray":r.fileFields.push({name:this.context.getTypeName(s.name),value:this.getArrayFileProperty({property:s,record:i})});break;case"bodyProperty":r.bodyPropertyFields.push({name:this.context.getTypeName(s.name.name),value:this.getBodyProperty({property:s,record:i})});break;default:w(s)}return r}getSingleFileProperty({property:t,record:e}){let r=this.context.getSingleFileValue({property:t,record:e});return r==null?c.TypeInstantiation.nop():c.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(r))}getArrayFileProperty({property:t,record:e}){let r=this.context.getFileArrayValues({property:t,record:e});return r==null?c.TypeInstantiation.nop():c.TypeInstantiation.slice({valueType:c.Type.reference(this.context.getIoReaderTypeReference()),values:r.map(i=>c.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i)))})}getBodyProperty({property:t,record:e}){let r=e[t.name.wireValue];return r==null?c.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:r})}};var Ne=class n extends ae{constructor({ir:e,config:r}){super({ir:e,config:r});l(this,"ir");l(this,"customConfig");l(this,"dynamicTypeMapper");l(this,"dynamicTypeInstantiationMapper");l(this,"filePropertyMapper");l(this,"rootImportPath");this.ir=e,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeMapper=new Ae({context:this}),this.dynamicTypeInstantiationMapper=new Re({context:this}),this.filePropertyMapper=new Ee({context:this}),this.rootImportPath=_e({config:r,customConfig:this.customConfig})}clone(){return new n({ir:this.ir,config:this.config})}getMethodName(e){return e.pascalCase.unsafeName}getTypeName(e){return e.pascalCase.unsafeName}getImportPath(e){let r=e.packagePath.map(i=>i.pascalCase.unsafeName.toLowerCase());return[this.rootImportPath,...r].join("/")}getContextTypeReference(){return c.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return c.invokeFunc({func:c.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return c.typeReference({name:"Reader",importPath:"io"})}getNewStringsReaderFunctionInvocation(e){return c.invokeFunc({func:c.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[c.TypeInstantiation.string(e)]})}getClientConstructorName(){var e;return((e=this.customConfig)==null?void 0:e.exportedClientName)!=null?`New${this.customConfig.exportedClientName}`:"NewClient"}getClientImportPath(){return`${this.rootImportPath}/client`}getOptionImportPath(){return`${this.rootImportPath}/option`}getGoTypeReferenceFromDeclaration({declaration:e}){return c.typeReference({name:e.name.pascalCase.unsafeName,importPath:this.getImportPath(e.fernFilepath)})}getEnvironmentTypeReferenceFromID(e){let r=this.resolveEnvironmentName(e);if(r!=null)return this.getEnvironmentTypeReference(r)}getEnvironmentTypeReference(e){return c.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}};var Me=class extends ie{constructor({ir:e,config:r,formatter:i}){super(new Ne({ir:e,config:r}));l(this,"formatter");this.formatter=i}async generate(e){let r=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let i=new ee;for(let o of r){let s=this.context.clone(),f=new le({context:s,formatter:this.formatter});try{let h=await f.generateSnippet({endpoint:o,request:e});if(s.errors.empty())return{snippet:h,errors:void 0};i.update({context:s,snippet:h})}catch(h){i.err==null&&(i.err=h)}}return i.getResponseOrThrow({endpoint:e.endpoint})}generateSync(e){let r=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let i=new ee;for(let o of r){let s=this.context.clone(),f=new le({context:s,formatter:this.formatter});try{let h=f.generateSnippetSync({endpoint:o,request:e});if(s.errors.empty())return{snippet:h,errors:void 0};i.update({context:s,snippet:h})}catch(h){i.err==null&&(i.err=h)}}return i.getResponseOrThrow({endpoint:e.endpoint})}};0&&(module.exports={DynamicSnippetsGenerator});
|
|
17
|
+
)`:""}};var w=class extends W{async toStringAsync({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new le({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 le({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toString()}};var N=class extends w{constructor({name:e,importPath:r}){super();l(this,"name");l(this,"importPath");this.name=e,this.importPath=r}write(e){if(e.importPath===this.importPath){e.write(this.name);return}let r=e.addImport(this.importPath);e.write(`${r}.${this.name}`)}};var Pr=new Set(["any","bytes","map","slice"]),fe=class n extends w{constructor(e){super();l(this,"internalType");this.internalType=e}write(e,{comment:r}={}){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(br);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(Sr);break;default:v(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,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 isAlreadyOptional(e){return e.internalType.type==="optional"||Pr.has(e.internalType.type)}},br=new N({importPath:"time",name:"Time"}),Sr=new N({importPath:"github.com/google/uuid",name:"UUID"});u();p();var Ur="sdk";function Le({config:n,customConfig:t}){let e=Cr({config:n}),r=Br({config:n,customConfig:t});return e!=null?_r({importPath:r,majorVersion:e}):r}function Br({config:n,customConfig:t}){var e,r,i;return(i=(r=t==null?void 0:t.importPath)!=null?r:(e=t==null?void 0:t.module)==null?void 0:e.path)!=null?i:n.output.mode.type==="github"?Mr(n.output.mode.repoUrl,"https://"):Ur}function Cr({config:n}){let t=kr({config:n});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function kr({config:n}){let t=Lr(n);if(t==null)return;let e=t.split(".");if(e[0]==null)return;let r=e[0];return r.startsWith("v")?r:`v${r}`}function _r({importPath:n,majorVersion:t}){return pe(n)===t?n:`${n}/${t}`}function Mr(n,t){return n.startsWith(t)?n.slice(t.length):n}function Lr(n){var e;let t=(e=n==null?void 0:n.output)==null?void 0:e.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}u();p();u();p();var _=class extends w{constructor(e){super();l(this,"arg");this.arg=e}write(e){return new C(this.arg).write(e)}};u();p();u();p();var P=class extends w{constructor({docs:e}={}){super();l(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
18
|
+
`).forEach(r=>{e.writeLine(`// ${r}`)})}};var j=class extends w{constructor({name:e,docs:r}){super();l(this,"name");l(this,"docs");l(this,"members",[]);this.name=e,this.docs=r}addMember(e){this.members.push(e)}write(e){e.writeNode(new P({docs:this.docs})),e.write(`type ${this.name} string`)}};u();p();var z=class extends w{constructor({name:e,type:r,docs:i}){super();l(this,"name");l(this,"type");l(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new P({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};u();p();var X=class extends w{constructor({nodes:e}={nodes:[]}){super();l(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 D=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s,typeReference:f}){super();l(this,"name");l(this,"parameters");l(this,"return_");l(this,"body");l(this,"docs");l(this,"typeReference");this.name=e,this.parameters=r,this.return_=i,this.body=o,this.docs=s,this.typeReference=f}write(e){var r;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(),(r=this.body)==null||r.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.writeLine("}")}writeReceiver({writer:e,typeReference:r}){e.write(`(${this.getReceiverName(r.name)} `),r.write(e),e.write(") ")}getReceiverName(e){return e.charAt(0).toLowerCase()}};var J=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s}){super();l(this,"func");this.func=new D({name:e,parameters:r,return_:i,body:o,docs:s})}get name(){return this.func.name}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};u();p();u();p();u();p();u();p();var V=class extends w{constructor({method:e,arguments_:r,on:i}){super();l(this,"on");l(this,"method");l(this,"arguments_");this.on=i,this.method=e,this.arguments_=r}write(e){this.on.write(e),e.write("."),e.write(this.method),Re({writer:e,arguments_:this.arguments_})}};var Dr=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),dt=new Set(["any","bytes","map","slice"]),b=class n extends w{constructor(e){super();l(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(Or({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(Gr({value:this.internalType.value}));break;default:v(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}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:r})})}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("[]interface{}"),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]interface{}");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=qr({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(Dr.has(r.internalType.type)){e.writeNode(Vr({writer:e,type:r}));return}if(dt.has(r.internalType.type)){r.write(e);return}if(r.internalType.type==="enum"){e.writeNode(new V({on:r.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),r.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||dt.has(e.internalType.type)}writeSlice({writer:e,slice:r}){e.write("[]"),e.writeNode(r.valueType);let i=Wr({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);let i=Yr({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 Vr({writer:n,type:t}){return new S({func:new N({name:$r({type:t}),importPath:n.rootImportPath}),arguments_:[t]})}function $r({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 Or({writer:n,type:t}){let e=t instanceof Date?"MustParseDate":"MustParseDateTime";return new S({func:new N({name:e,importPath:n.rootImportPath}),arguments_:[new _(`"${t.value}"`)]})}function Gr({value:n}){return new S({func:new N({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new _(`"${n}"`)]})}function qr({entries:n}){return n.filter(t=>!b.isNop(t.key)&&!b.isNop(t.value))}function Yr({fields:n}){return n.filter(t=>!b.isNop(t.value))}function Wr({values:n}){return n.filter(t=>!b.isNop(t))}function Re({writer:n,arguments_:t}){let e=jr(t);if(e.length===0){n.write("()");return}n.writeLine("("),n.indent();for(let r of e)Hr({writer:n,argument:r}),n.writeLine(",");n.dedent(),n.write(")")}function Hr({writer:n,argument:t}){Me(t)?n.writeNodeOrString(t.assignment):t.write(n)}function jr(n){return n.filter(t=>!(t instanceof b&&b.isNop(t)))}var S=class extends w{constructor({func:e,arguments_:r}){super();l(this,"func");l(this,"arguments_");this.func=e,this.arguments_=r}write(e){e.writeNode(this.func),Re({writer:e,arguments_:this.arguments_})}};u();p();var K=class extends w{constructor({name:e,type:r,docs:i}){super();l(this,"name");l(this,"type");l(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new P({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};u();p();var Q=class extends w{constructor({name:e,importPath:r,docs:i}){super();l(this,"name");l(this,"importPath");l(this,"docs");l(this,"fields",[]);l(this,"methods",[]);this.name=e,this.importPath=r,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 r of this.fields)e.writeNode(r),e.newLine();e.dedent(),e.writeLine("}")}if(this.methods.length>0){e.newLine();for(let r of this.methods)e.writeNode(r),e.newLine()}}};var c={};Ye(c,{AstNode:()=>w,CodeBlock:()=>_,Enum:()=>j,Field:()=>z,File:()=>X,Func:()=>J,FuncInvocation:()=>S,Method:()=>D,MethodInvocation:()=>V,Parameter:()=>K,Struct:()=>Q,Type:()=>fe,TypeInstantiation:()=>b,TypeReference:()=>N,Writer:()=>H,codeblock:()=>zr,enum_:()=>Xr,field:()=>Jr,file:()=>Kr,func:()=>Qr,invokeFunc:()=>Zr,invokeMethod:()=>en,method:()=>tn,parameter:()=>rn,struct:()=>nn,typeReference:()=>on});u();p();function zr(n){return new _(n)}function Xr(n){return new j(n)}function Jr(n){return new z(n)}function Kr(n={}){return new X(n)}function Qr(n){return new J(n)}function Zr(n){return new S(n)}function en(n){return new V(n)}function tn(n){return new D(n)}function rn(n){return new K(n)}function nn(n){return new Q(n)}function on(n){return new N(n)}var mt="example",yt="fern",sn="do",gt="client",Ae=class{constructor({context:t,formatter:e}){l(this,"context");l(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:mt,importPath:yt,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:mt,importPath:yt,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return c.func({name:sn,parameters:[],return_:[],body:c.codeblock(r=>{r.writeNode(this.constructClient({endpoint:t,snippet:e})),r.writeLine(),r.writeNode(this.callMethod({endpoint:t,snippet:e}))})})}constructClient({endpoint:t,snippet:e}){return c.codeblock(r=>{r.write(`${gt} := `),r.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}callMethod({endpoint:t,snippet:e}){return c.invokeMethod({on:c.codeblock(gt),method:this.getMethod({endpoint:t}),arguments_:[this.context.getContextTodoFunctionInvocation(),...this.getMethodArgs({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:x.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(k.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}getConstructorAuthArg({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.context.errors.add({severity:x.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),c.TypeInstantiation.nop()):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.context.errors.add({severity:x.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),c.TypeInstantiation.nop()):this.getConstructorBearerAuthArg({auth:t,values:e});case"header":return e.type!=="header"?(this.context.errors.add({severity:x.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),c.TypeInstantiation.nop()):this.getConstructorHeaderAuthArg({auth:t,values:e});case"oauth":return e.type!=="oauth"?(this.context.errors.add({severity:x.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),c.TypeInstantiation.nop()):(this.context.errors.add({severity:x.Warning,message:"The Go SDK doesn't support OAuth client credentials yet"}),c.TypeInstantiation.nop());default:v(t)}}getConstructorBasicAuthArg({auth:t,values:e}){return c.codeblock(r=>{r.writeNode(c.invokeFunc({func:c.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[c.TypeInstantiation.string(e.username),c.TypeInstantiation.string(e.password)]}))})}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let r=this.getBaseUrlArg({baseUrl:t,environment:e});if(r!=null)return c.codeblock(i=>{i.writeNode(c.invokeFunc({func:c.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[r]}))})}getBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:x.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return c.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:x.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return c.TypeInstantiation.reference(r)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:x.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 c.codeblock(r=>{r.writeNode(c.invokeFunc({func:c.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[c.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return c.codeblock(r=>{r.writeNode(c.invokeFunc({func:c.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(!c.TypeInstantiation.isNop(r))return c.codeblock(i=>{i.writeNode(c.invokeFunc({func:c.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:v(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){var o,s;let r=[];this.context.errors.scope(k.PathParameters);let i=[...(o=this.context.ir.pathParameters)!=null?o:[],...(s=t.pathParameters)!=null?s:[]];return i.length>0&&r.push(...this.getPathParameters({namedParameters:i,snippet:e}).map(f=>f.value)),this.context.errors.unscope(),this.context.errors.scope(k.RequestBody),t.body!=null&&r.push(this.getBodyRequestArg({body:t.body,value:e.requestBody})),this.context.errors.unscope(),r}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:v(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:x.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),c.TypeInstantiation.nop()):c.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){var y,g,m,R,T,A;let r=[],{inlinePathParameters:i,inlineFileProperties:o}={inlinePathParameters:(g=(y=this.context.customConfig)==null?void 0:y.inlinePathParameters)!=null?g:!1,inlineFileProperties:(R=(m=this.context.customConfig)==null?void 0:m.inlineFileProperties)!=null?R:!1};this.context.errors.scope(k.PathParameters);let s=[],f=[...(T=this.context.ir.pathParameters)!=null?T:[],...(A=t.pathParameters)!=null?A:[]];f.length>0&&s.push(...this.getPathParameters({namedParameters:f,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(k.RequestBody);let h=this.getFilePropertyInfo({request:t,snippet:e});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})||r.push(...s.map(te=>te.value)),o||r.push(...h.fileFields.map(te=>te.value)),this.context.needsRequestParameter({request:t,inlinePathParameters:i,inlineFileProperties:o})&&r.push(this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})?s:[],filePropertyInfo:h})),r}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 g,m,R,T;this.context.errors.scope(k.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(g=t.queryParameters)!=null?g:[],values:(m=e.queryParameters)!=null?m:{}}).map(A=>({name:A.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(A)}));this.context.errors.unscope(),this.context.errors.scope(k.Headers);let h=this.context.associateByWireValue({parameters:(R=t.headers)!=null?R:[],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(k.RequestBody);let y=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),c.TypeInstantiation.structPointer({typeReference:c.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:[...r,...s,...h,...y]})}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:v(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:v(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.convert(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 c.invokeFunc({func:c.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}};u();p();u();p();var Ee=class{constructor({context:t}){l(this,"context");this.context=t}convert(t){if(t.value===null&&!this.context.isNullable(t.typeReference)&&this.context.errors.add({severity:x.Critical,message:"Expected non-null value, but got null"}),t.value==null)return c.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return c.TypeInstantiation.nop();case"map":return this.convertMap({map:t.typeReference,value:t.value});case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?c.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"nullable":return c.TypeInstantiation.optional(this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as}));case"optional":return c.TypeInstantiation.optional(this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertList({list:t.typeReference.value,value:t.value});case"unknown":return this.convertUnknown({value:t.value});default:v(t.typeReference)}}convertList({list:t,value:e}){return Array.isArray(e)?c.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:t}),values:e.map((r,i)=>{this.context.errors.scope({index:i});try{return this.convert({typeReference:t,value:r})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:x.Critical,message:`Expected array but got: ${typeof e}`}),c.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:x.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),c.TypeInstantiation.nop()):c.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries:Object.entries(e).map(([r,i])=>{this.context.errors.scope(r);try{return{key:this.convert({typeReference:t.key,value:r,as:"key"}),value:this.convert({typeReference:t.value,value:i})}}finally{this.context.errors.unscope()}})})}convertNamed({named:t,value:e,as:r}){switch(t.type){case"alias":return this.convert({typeReference:t.typeReference,value:e,as:r});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:e});case"enum":return this.convertEnum({enum_:t,value:e});case"object":return this.convertObject({object_:t,value:e});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e});default:v(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let r=this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(i==null)return c.TypeInstantiation.nop();let o=i.singleDiscriminatedUnionType,s=this.getBaseFields({discriminatedUnionTypeInstance:i,singleDiscriminatedUnionType:o});switch(o.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:o.typeId});return f==null?c.TypeInstantiation.nop():c.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(o.discriminantValue.name),value:this.convertNamed({named:f,value:i.value})},...s]})}case"singleProperty":{let f=this.context.getRecord(i.value);if(f==null)return c.TypeInstantiation.nop();try{return this.context.errors.scope(o.discriminantValue.wireValue),c.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(o.discriminantValue.name),value:this.convert({typeReference:o.typeReference,value:f[o.discriminantValue.wireValue]})},...s]})}finally{this.context.errors.unscope()}}case"noProperties":return c.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(i.discriminantValue.name),value:c.TypeInstantiation.string(o.discriminantValue.wireValue)},...s]});default:v(o)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){var i,o;return this.context.associateByWireValue({parameters:(i=e.properties)!=null?i:[],values:(o=this.context.getRecord(t.value))!=null?o:{},ignoreMissingParameters:!0}).map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getTypeName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})}convertObject({object_:t,value:e}){var i;let r=this.context.associateByWireValue({parameters:t.properties,values:(i=this.context.getRecord(e))!=null?i:{}});return c.TypeInstantiation.structPointer({typeReference:c.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:r.map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getTypeName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:t,value:e}){let r=this.getEnumValueName({enum_:t,value:e});return r==null?c.TypeInstantiation.nop():c.TypeInstantiation.enum(c.typeReference({name:r,importPath:this.context.getImportPath(t.declaration.fernFilepath)}))}getEnumValueName({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:x.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let r=t.values.find(i=>i.wireValue===e);if(r==null){this.context.errors.add({severity:x.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return`${this.context.getTypeName(t.declaration.name)}${this.context.getTypeName(r.name)}`}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let r=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});if(r==null)return c.TypeInstantiation.nop();let i=this.getUndiscriminatedUnionFieldName({typeReference:r.valueTypeReference});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),fields:[{name:i,value:r.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let r of t.types)try{let i=this.convert({typeReference:r,value:e});return{valueTypeReference:r,typeInstantiation:i}}catch(i){continue}this.context.errors.add({severity:x.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}getUndiscriminatedUnionFieldName({typeReference:t}){switch(t.type){case"list":return this.getUndiscriminatedUnionFieldNameForList({list:t});case"literal":return this.getUndiscriminatedUnionFieldNameForLiteral({literal:t.value});case"map":return this.getUndiscriminatedUnionFieldNameForMap({map:t});case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?void 0:this.context.getTypeName(e.declaration.name)}case"optional":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"nullable":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:t.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:t});case"unknown":return"Unknown";default:v(t)}}getUndiscriminatedUnionFieldNameForList({list:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}List`}getUndiscriminatedUnionFieldNameForMap({map:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.key});if(e==null)return;let r=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(r!=null)return`${e}${r}Map`}getUndiscriminatedUnionFieldNameForOptional({typeReference:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Set`}getUndiscriminatedUnionFieldNameForLiteral({literal:t}){switch(t.type){case"boolean":return t.value?"TrueLiteral":"FalseLiteral";case"string":return`${t.value}StringLiteral`;default:v(t)}}getUndiscriminatedUnionFieldNameForPrimitive({primitive:t}){switch(t){case"INTEGER":case"UINT":return"Integer";case"LONG":case"UINT_64":return"Long";case"FLOAT":case"DOUBLE":return"Double";case"BOOLEAN":return"Boolean";case"BIG_INTEGER":case"STRING":return"String";case"UUID":return"Uuid";case"DATE":return"Date";case"DATE_TIME":return"DateTime";case"BASE_64":return"Base64";default:v(t)}}convertUnknown({value:t}){return c.TypeInstantiation.any(t)}convertPrimitive({primitive:t,value:e,as:r}){switch(t){case"INTEGER":case"UINT":{let i=this.getValueAsNumber({value:e,as:r});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.int(i)}case"LONG":case"UINT_64":{let i=this.getValueAsNumber({value:e,as:r});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.int64(i)}case"FLOAT":case"DOUBLE":{let i=this.getValueAsNumber({value:e,as:r});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.float64(i)}case"BOOLEAN":{let i=this.getValueAsBoolean({value:e,as:r});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.bool(i)}case"STRING":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.string(i)}case"DATE":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.date(i)}case"DATE_TIME":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.dateTime(i)}case"UUID":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.uuid(i)}case"BASE_64":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.bytes(i)}case"BIG_INTEGER":{let i=this.context.getValueAsString({value:e});return i==null?c.TypeInstantiation.nop():c.TypeInstantiation.string(i)}default:v(t)}}getValueAsNumber({value:t,as:e}){let r=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:r})}getValueAsBoolean({value:t,as:e}){let r=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:r})}};u();p();var Ne=class{constructor({context:t}){l(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return c.Type.slice(this.convert({typeReference:t.typeReference}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return c.Type.map(this.convert({typeReference:t.typeReference.key}),this.convert({typeReference:t.typeReference.value}));case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?this.convertUnknown():this.convertNamed({named:e})}case"optional":return c.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return c.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return c.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:v(t.typeReference)}}convertLiteral({literal:t}){switch(t.type){case"boolean":return c.Type.bool();case"string":return c.Type.string()}}convertNamed({named:t}){let e=c.Type.reference(c.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}));switch(t.type){case"alias":case"enum":return e;case"discriminatedUnion":case"object":case"undiscriminatedUnion":return c.Type.pointer(e);default:v(t)}}convertUnknown(){return c.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return c.Type.int();case"UINT":return c.Type.int();case"LONG":return c.Type.int64();case"UINT_64":return c.Type.int64();case"FLOAT":return c.Type.float64();case"DOUBLE":return c.Type.float64();case"BOOLEAN":return c.Type.bool();case"STRING":return c.Type.string();case"DATE":return c.Type.date();case"DATE_TIME":return c.Type.dateTime();case"UUID":return c.Type.uuid();case"BASE_64":return c.Type.bytes();case"BIG_INTEGER":return c.Type.string();default:v(t)}}};u();p();var Fe=class{constructor({context:t}){l(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){var o;let r={fileFields:[],bodyPropertyFields:[]},i=(o=this.context.getRecord(e))!=null?o:{};for(let s of t.properties)switch(s.type){case"file":r.fileFields.push({name:this.context.getTypeName(s.name),value:this.getSingleFileProperty({property:s,record:i})});break;case"fileArray":r.fileFields.push({name:this.context.getTypeName(s.name),value:this.getArrayFileProperty({property:s,record:i})});break;case"bodyProperty":r.bodyPropertyFields.push({name:this.context.getTypeName(s.name.name),value:this.getBodyProperty({property:s,record:i})});break;default:v(s)}return r}getSingleFileProperty({property:t,record:e}){let r=this.context.getSingleFileValue({property:t,record:e});return r==null?c.TypeInstantiation.nop():c.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(r))}getArrayFileProperty({property:t,record:e}){let r=this.context.getFileArrayValues({property:t,record:e});return r==null?c.TypeInstantiation.nop():c.TypeInstantiation.slice({valueType:c.Type.reference(this.context.getIoReaderTypeReference()),values:r.map(i=>c.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i)))})}getBodyProperty({property:t,record:e}){let r=e[t.name.wireValue];return r==null?c.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:r})}};var Pe=class n extends ue{constructor({ir:e,config:r}){super({ir:e,config:r});l(this,"ir");l(this,"customConfig");l(this,"dynamicTypeMapper");l(this,"dynamicTypeInstantiationMapper");l(this,"filePropertyMapper");l(this,"rootImportPath");this.ir=e,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeMapper=new Ne({context:this}),this.dynamicTypeInstantiationMapper=new Ee({context:this}),this.filePropertyMapper=new Fe({context:this}),this.rootImportPath=Le({config:r,customConfig:this.customConfig})}clone(){return new n({ir:this.ir,config:this.config})}getMethodName(e){return e.pascalCase.unsafeName}getTypeName(e){return e.pascalCase.unsafeName}getImportPath(e){let r=e.packagePath.map(i=>i.pascalCase.unsafeName.toLowerCase());return[this.rootImportPath,...r].join("/")}getContextTypeReference(){return c.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return c.invokeFunc({func:c.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return c.typeReference({name:"Reader",importPath:"io"})}getNewStringsReaderFunctionInvocation(e){return c.invokeFunc({func:c.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[c.TypeInstantiation.string(e)]})}getClientConstructorName(){var e,r;return((e=this.customConfig)==null?void 0:e.clientConstructorName)!=null?this.customConfig.clientConstructorName:((r=this.customConfig)==null?void 0:r.exportedClientName)!=null?`New${this.customConfig.exportedClientName}`:`New${this.getClientName()}`}getClientName(){var e;return((e=this.customConfig)==null?void 0:e.clientName)!=null?this.customConfig.clientName:"Client"}getClientImportPath(){var e;return((e=this.customConfig)==null?void 0:e.packageLayout)==="flat"?this.rootImportPath:`${this.rootImportPath}/client`}getOptionImportPath(){return`${this.rootImportPath}/option`}getGoTypeReferenceFromDeclaration({declaration:e}){return c.typeReference({name:e.name.pascalCase.unsafeName,importPath:this.getImportPath(e.fernFilepath)})}getEnvironmentTypeReferenceFromID(e){let r=this.resolveEnvironmentName(e);if(r!=null)return this.getEnvironmentTypeReference(r)}getEnvironmentTypeReference(e){return c.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}};var De=class extends se{constructor({ir:e,config:r,formatter:i}){super(new Pe({ir:e,config:r}));l(this,"formatter");this.formatter=i}async generate(e){return super.generate(e)}generateSync(e){return super.generateSync(e)}createSnippetGenerator(e){return new Ae({context:e,formatter:this.formatter})}};0&&(module.exports={DynamicSnippetsGenerator});
|
|
20
20
|
/*! Bundled license information:
|
|
21
21
|
|
|
22
22
|
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, AbstractFormatter } from '@fern-api/browser-compatible-base-generator';
|
|
2
2
|
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
|
-
import {
|
|
3
|
+
import { EndpointSnippetGenerator } from './EndpointSnippetGenerator.cjs';
|
|
4
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-CpOvS1wA.cjs';
|
|
4
5
|
import '@fern-api/go-ast';
|
|
5
6
|
|
|
6
|
-
declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext,
|
|
7
|
+
declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
|
|
7
8
|
private formatter;
|
|
8
9
|
constructor({ ir, config, formatter }: {
|
|
9
10
|
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
@@ -12,6 +13,7 @@ declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<
|
|
|
12
13
|
});
|
|
13
14
|
generate(request: FernIr.dynamic.EndpointSnippetRequest): Promise<FernIr.dynamic.EndpointSnippetResponse>;
|
|
14
15
|
generateSync(request: FernIr.dynamic.EndpointSnippetRequest): FernIr.dynamic.EndpointSnippetResponse;
|
|
16
|
+
protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export { DynamicSnippetsGenerator };
|
|
@@ -24,7 +24,7 @@ declare class DynamicTypeInstantiationMapper {
|
|
|
24
24
|
private convertObject;
|
|
25
25
|
private convertEnum;
|
|
26
26
|
private getEnumValueName;
|
|
27
|
-
private
|
|
27
|
+
private convertUndiscriminatedUnion;
|
|
28
28
|
private findMatchingUndiscriminatedUnionType;
|
|
29
29
|
private getUndiscriminatedUnionFieldName;
|
|
30
30
|
private getUndiscriminatedUnionFieldNameForList;
|
|
@@ -94,6 +94,7 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
94
94
|
getIoReaderTypeReference(): go.TypeReference;
|
|
95
95
|
getNewStringsReaderFunctionInvocation(s: string): go.FuncInvocation;
|
|
96
96
|
getClientConstructorName(): string;
|
|
97
|
+
getClientName(): string;
|
|
97
98
|
getClientImportPath(): string;
|
|
98
99
|
getOptionImportPath(): string;
|
|
99
100
|
getGoTypeReferenceFromDeclaration({ declaration }: {
|