@fern-api/go-dynamic-snippets 1.56.1 → 1.57.1
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/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";var nt=Object.defineProperty;var Xr=Object.getOwnPropertyDescriptor;var Qr=Object.getOwnPropertyNames;var Zr=Object.prototype.hasOwnProperty;var ei=(p,t,e)=>t in p?nt(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var oe=(p,t,e)=>()=>{if(e)throw e[0];try{return p&&(t=p(p=0)),t}catch(i){throw e=[i],i}};var xt=(p,t)=>{for(var e in t)nt(p,e,{get:t[e],enumerable:!0})},ti=(p,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Qr(t))!Zr.call(p,s)&&s!==e&&nt(p,s,{get:()=>t[s],enumerable:!(i=Xr(t,s))||i.enumerable});return p};var ni=p=>ti(nt({},"__esModule",{value:!0}),p);var m=(p,t,e)=>ei(p,typeof t!="symbol"?t+"":t,e);var y=oe(()=>{"use strict"});var N={};xt(N,{_debugEnd:()=>Wn,_debugProcess:()=>Vn,_events:()=>ir,_eventsCount:()=>or,_exiting:()=>xn,_fatalExceptions:()=>Mn,_getActiveHandles:()=>An,_getActiveRequests:()=>Nn,_kill:()=>Fn,_linkedBinding:()=>In,_maxListeners:()=>rr,_preload_modules:()=>er,_rawDebug:()=>vn,_startProfilerIdleNotifier:()=>Gn,_stopProfilerIdleNotifier:()=>qn,_tickCallback:()=>Dn,abort:()=>Yn,addListener:()=>sr,allowedNodeEnvironmentFlags:()=>Un,arch:()=>rn,argv:()=>an,argv0:()=>Zn,assert:()=>Ln,binding:()=>dn,browser:()=>gn,chdir:()=>mn,config:()=>En,cpuUsage:()=>ot,cwd:()=>hn,debugPort:()=>Qn,default:()=>mr,dlopen:()=>bn,domain:()=>Tn,emit:()=>lr,emitWarning:()=>ln,env:()=>sn,execArgv:()=>cn,execPath:()=>Xn,exit:()=>Bn,features:()=>_n,hasUncaughtExceptionCaptureCallback:()=>On,hrtime:()=>it,kill:()=>Sn,listeners:()=>hr,memoryUsage:()=>kn,moduleLoadList:()=>wn,nextTick:()=>en,off:()=>cr,on:()=>ae,once:()=>ar,openStdin:()=>Cn,pid:()=>Kn,platform:()=>on,ppid:()=>Jn,prependListener:()=>dr,prependOnceListener:()=>fr,reallyExit:()=>Rn,release:()=>yn,removeAllListeners:()=>pr,removeListener:()=>ur,resourceUsage:()=>Pn,setSourceMapsEnabled:()=>tr,setUncaughtExceptionCaptureCallback:()=>$n,stderr:()=>Hn,stdin:()=>zn,stdout:()=>jn,title:()=>nn,umask:()=>fn,uptime:()=>nr,version:()=>un,versions:()=>pn});function Nt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function ri(){!Ue||!ye||(Ue=!1,ye.length?se=ye.concat(se):rt=-1,se.length&&Zt())}function Zt(){if(!Ue){var p=setTimeout(ri,0);Ue=!0;for(var t=se.length;t;){for(ye=se,se=[];++rt<t;)ye&&ye[rt].run();rt=-1,t=se.length}ye=null,Ue=!1,clearTimeout(p)}}function en(p){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];se.push(new tn(p,t)),se.length===1&&!Ue&&setTimeout(Zt,0)}function tn(p,t){this.fun=p,this.array=t}function H(){}function In(p){Nt("_linkedBinding")}function bn(p){Nt("dlopen")}function Nn(){return[]}function An(){return[]}function Ln(p,t){if(!p)throw new Error(t||"assertion error")}function On(){return!1}function nr(){return fe.now()/1e3}function it(p){var t=Math.floor((Date.now()-fe.now())*.001),e=fe.now()*.001,i=Math.floor(e)+t,s=Math.floor(e%1*1e9);return p&&(i=i-p[0],s=s-p[1],s<0&&(i--,s+=bt)),[i,s]}function ae(){return mr}function hr(p){return[]}var se,Ue,ye,rt,nn,rn,on,sn,an,cn,un,pn,ln,dn,fn,hn,mn,yn,gn,vn,wn,Tn,xn,En,Rn,Fn,ot,Pn,kn,Sn,Bn,Cn,Un,_n,Mn,$n,Dn,Vn,Wn,Gn,qn,jn,Hn,zn,Yn,Kn,Jn,Xn,Qn,Zn,er,tr,fe,Et,bt,rr,ir,or,sr,ar,cr,ur,pr,lr,dr,fr,mr,yr=oe(()=>{"use strict";y();v();g();se=[],Ue=!1,rt=-1;tn.prototype.run=function(){this.fun.apply(null,this.array)};nn="browser",rn="x64",on="browser",sn={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},an=["/usr/bin/node"],cn=[],un="v16.8.0",pn={},ln=function(p,t){console.warn((t?t+": ":"")+p)},dn=function(p){Nt("binding")},fn=function(p){return 0},hn=function(){return"/"},mn=function(p){},yn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};gn=!0,vn=H,wn=[];Tn={},xn=!1,En={};Rn=H,Fn=H,ot=function(){return{}},Pn=ot,kn=ot,Sn=H,Bn=H,Cn=H,Un={};_n={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Mn=H,$n=H;Dn=H,Vn=H,Wn=H,Gn=H,qn=H,jn=void 0,Hn=void 0,zn=void 0,Yn=H,Kn=2,Jn=1,Xn="/bin/usr/node",Qn=9229,Zn="node",er=[],tr=H,fe={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};fe.now===void 0&&(Et=Date.now(),fe.timing&&fe.timing.navigationStart&&(Et=fe.timing.navigationStart),fe.now=()=>Date.now()-Et);bt=1e9;it.bigint=function(p){var t=it(p);return typeof BigInt>"u"?t[0]*bt+t[1]:BigInt(t[0]*bt)+BigInt(t[1])};rr=10,ir={},or=0;sr=ae,ar=ae,cr=ae,ur=ae,pr=ae,lr=H,dr=ae,fr=ae;mr={version:un,versions:pn,arch:rn,platform:on,browser:gn,release:yn,_rawDebug:vn,moduleLoadList:wn,binding:dn,_linkedBinding:In,_events:ir,_eventsCount:or,_maxListeners:rr,on:ae,addListener:sr,once:ar,off:cr,removeListener:ur,removeAllListeners:pr,emit:lr,prependListener:dr,prependOnceListener:fr,listeners:hr,domain:Tn,_exiting:xn,config:En,dlopen:bn,uptime:nr,_getActiveRequests:Nn,_getActiveHandles:An,reallyExit:Rn,_kill:Fn,cpuUsage:ot,resourceUsage:Pn,memoryUsage:kn,kill:Sn,exit:Bn,openStdin:Cn,allowedNodeEnvironmentFlags:Un,assert:Ln,features:_n,_fatalExceptions:Mn,setUncaughtExceptionCaptureCallback:$n,hasUncaughtExceptionCaptureCallback:On,emitWarning:ln,nextTick:en,_tickCallback:Dn,_debugProcess:Vn,_debugEnd:Wn,_startProfilerIdleNotifier:Gn,_stopProfilerIdleNotifier:qn,stdout:jn,stdin:zn,stderr:Hn,abort:Yn,umask:fn,chdir:mn,cwd:hn,env:sn,title:nn,argv:an,execArgv:cn,pid:Kn,ppid:Jn,execPath:Xn,debugPort:Qn,hrtime:it,argv0:Zn,_preload_modules:er,setSourceMapsEnabled:tr}});var g=oe(()=>{"use strict";yr()});function ii(){if(gr)return $e;gr=!0,$e.byteLength=f,$e.toByteArray=T,$e.fromByteArray=P;for(var p=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=i.length;s<c;++s)p[s]=i[s],t[i.charCodeAt(s)]=s;t[45]=62,t[95]=63;function o(b){var F=b.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=b.indexOf("=");B===-1&&(B=F);var S=B===F?0:4-B%4;return[B,S]}function f(b){var F=o(b),B=F[0],S=F[1];return(B+S)*3/4-S}function w(b,F,B){return(F+B)*3/4-B}function T(b){var F,B=o(b),S=B[0],q=B[1],$=new e(w(b,S,q)),V=0,Q=q>0?S-4:S,Y;for(Y=0;Y<Q;Y+=4)F=t[b.charCodeAt(Y)]<<18|t[b.charCodeAt(Y+1)]<<12|t[b.charCodeAt(Y+2)]<<6|t[b.charCodeAt(Y+3)],$[V++]=F>>16&255,$[V++]=F>>8&255,$[V++]=F&255;return q===2&&(F=t[b.charCodeAt(Y)]<<2|t[b.charCodeAt(Y+1)]>>4,$[V++]=F&255),q===1&&(F=t[b.charCodeAt(Y)]<<10|t[b.charCodeAt(Y+1)]<<4|t[b.charCodeAt(Y+2)]>>2,$[V++]=F>>8&255,$[V++]=F&255),$}function E(b){return p[b>>18&63]+p[b>>12&63]+p[b>>6&63]+p[b&63]}function x(b,F,B){for(var S,q=[],$=F;$<B;$+=3)S=(b[$]<<16&16711680)+(b[$+1]<<8&65280)+(b[$+2]&255),q.push(E(S));return q.join("")}function P(b){for(var F,B=b.length,S=B%3,q=[],$=16383,V=0,Q=B-S;V<Q;V+=$)q.push(x(b,V,V+$>Q?Q:V+$));return S===1?(F=b[B-1],q.push(p[F>>2]+p[F<<4&63]+"==")):S===2&&(F=(b[B-2]<<8)+b[B-1],q.push(p[F>>10]+p[F>>4&63]+p[F<<2&63]+"=")),q.join("")}return $e}function oi(){if(vr)return st;vr=!0;return st.read=function(p,t,e,i,s){var c,o,f=s*8-i-1,w=(1<<f)-1,T=w>>1,E=-7,x=e?s-1:0,P=e?-1:1,b=p[t+x];for(x+=P,c=b&(1<<-E)-1,b>>=-E,E+=f;E>0;c=c*256+p[t+x],x+=P,E-=8);for(o=c&(1<<-E)-1,c>>=-E,E+=i;E>0;o=o*256+p[t+x],x+=P,E-=8);if(c===0)c=1-T;else{if(c===w)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,i),c=c-T}return(b?-1:1)*o*Math.pow(2,c-i)},st.write=function(p,t,e,i,s,c){var o,f,w,T=c*8-s-1,E=(1<<T)-1,x=E>>1,P=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=i?0:c-1,F=i?1:-1,B=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,o=E):(o=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-o))<1&&(o--,w*=2),o+x>=1?t+=P/w:t+=P*Math.pow(2,1-x),t*w>=2&&(o++,w/=2),o+x>=E?(f=0,o=E):o+x>=1?(f=(t*w-1)*Math.pow(2,s),o=o+x):(f=t*Math.pow(2,x-1)*Math.pow(2,s),o=0));s>=8;p[e+b]=f&255,b+=F,f/=256,s-=8);for(o=o<<s|f,T+=s;T>0;p[e+b]=o&255,b+=F,o/=256,T-=8);p[e+b-F]|=B*128},st}function Ir(){if(wr)return ge;wr=!0;let p=ii(),t=oi(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ge.Buffer=o,ge.SlowBuffer=q,ge.INSPECT_MAX_BYTES=50;let i=2147483647;ge.kMaxLength=i,o.TYPED_ARRAY_SUPPORT=s(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{let a=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(a,n),a.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function c(a){if(a>i)throw new RangeError('The value "'+a+'" is invalid for option "size"');let n=new Uint8Array(a);return Object.setPrototypeOf(n,o.prototype),n}function o(a,n,r){if(typeof a=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(a)}return f(a,n,r)}o.poolSize=8192;function f(a,n,r){if(typeof a=="string")return x(a,n);if(ArrayBuffer.isView(a))return b(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(te(a,ArrayBuffer)||a&&te(a.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(te(a,SharedArrayBuffer)||a&&te(a.buffer,SharedArrayBuffer)))return F(a,n,r);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=a.valueOf&&a.valueOf();if(u!=null&&u!==a)return o.from(u,n,r);let d=B(a);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return o.from(a[Symbol.toPrimitive]("string"),n,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}o.from=function(a,n,r){return f(a,n,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function w(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function T(a,n,r){return w(a),a<=0?c(a):n!==void 0?typeof r=="string"?c(a).fill(n,r):c(a).fill(n):c(a)}o.alloc=function(a,n,r){return T(a,n,r)};function E(a){return w(a),c(a<0?0:S(a)|0)}o.allocUnsafe=function(a){return E(a)},o.allocUnsafeSlow=function(a){return E(a)};function x(a,n){if((typeof n!="string"||n==="")&&(n="utf8"),!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n);let r=$(a,n)|0,u=c(r),d=u.write(a,n);return d!==r&&(u=u.slice(0,d)),u}function P(a){let n=a.length<0?0:S(a.length)|0,r=c(n);for(let u=0;u<n;u+=1)r[u]=a[u]&255;return r}function b(a){if(te(a,Uint8Array)){let n=new Uint8Array(a);return F(n.buffer,n.byteOffset,n.byteLength)}return P(a)}function F(a,n,r){if(n<0||a.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<n+(r||0))throw new RangeError('"length" is outside of buffer bounds');let u;return n===void 0&&r===void 0?u=new Uint8Array(a):r===void 0?u=new Uint8Array(a,n):u=new Uint8Array(a,n,r),Object.setPrototypeOf(u,o.prototype),u}function B(a){if(o.isBuffer(a)){let n=S(a.length)|0,r=c(n);return r.length===0||a.copy(r,0,0,n),r}if(a.length!==void 0)return typeof a.length!="number"||Tt(a.length)?c(0):P(a);if(a.type==="Buffer"&&Array.isArray(a.data))return P(a.data)}function S(a){if(a>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return a|0}function q(a){return+a!=a&&(a=0),o.alloc(+a)}o.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==o.prototype},o.compare=function(n,r){if(te(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),te(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(n)||!o.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===r)return 0;let u=n.length,d=r.length;for(let h=0,I=Math.min(u,d);h<I;++h)if(n[h]!==r[h]){u=n[h],d=r[h];break}return u<d?-1:d<u?1:0},o.isEncoding=function(n){switch(String(n).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}},o.concat=function(n,r){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return o.alloc(0);let u;if(r===void 0)for(r=0,u=0;u<n.length;++u)r+=n[u].length;let d=o.allocUnsafe(r),h=0;for(u=0;u<n.length;++u){let I=n[u];if(te(I,Uint8Array))h+I.length>d.length?(o.isBuffer(I)||(I=o.from(I)),I.copy(d,h)):Uint8Array.prototype.set.call(d,I,h);else if(o.isBuffer(I))I.copy(d,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=I.length}return d};function $(a,n){if(o.isBuffer(a))return a.length;if(ArrayBuffer.isView(a)||te(a,ArrayBuffer))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);let r=a.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&r===0)return 0;let d=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return It(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Qt(a).length;default:if(d)return u?-1:It(a).length;n=(""+n).toLowerCase(),d=!0}}o.byteLength=$;function V(a,n,r){let u=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,n>>>=0,r<=n))return"";for(a||(a="utf8");;)switch(a){case"hex":return Wr(this,n,r);case"utf8":case"utf-8":return Gt(this,n,r);case"ascii":return Dr(this,n,r);case"latin1":case"binary":return Vr(this,n,r);case"base64":return $r(this,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gr(this,n,r);default:if(u)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),u=!0}}o.prototype._isBuffer=!0;function Q(a,n,r){let u=a[n];a[n]=a[r],a[r]=u}o.prototype.swap16=function(){let n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<n;r+=2)Q(this,r,r+1);return this},o.prototype.swap32=function(){let n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<n;r+=4)Q(this,r,r+3),Q(this,r+1,r+2);return this},o.prototype.swap64=function(){let n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<n;r+=8)Q(this,r,r+7),Q(this,r+1,r+6),Q(this,r+2,r+5),Q(this,r+3,r+4);return this},o.prototype.toString=function(){let n=this.length;return n===0?"":arguments.length===0?Gt(this,0,n):V.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(n){if(!o.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:o.compare(this,n)===0},o.prototype.inspect=function(){let n="",r=ge.INSPECT_MAX_BYTES;return n=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(n+=" ... "),"<Buffer "+n+">"},e&&(o.prototype[e]=o.prototype.inspect),o.prototype.compare=function(n,r,u,d,h){if(te(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),!o.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(r===void 0&&(r=0),u===void 0&&(u=n?n.length:0),d===void 0&&(d=0),h===void 0&&(h=this.length),r<0||u>n.length||d<0||h>this.length)throw new RangeError("out of range index");if(d>=h&&r>=u)return 0;if(d>=h)return-1;if(r>=u)return 1;if(r>>>=0,u>>>=0,d>>>=0,h>>>=0,this===n)return 0;let I=h-d,C=u-r,O=Math.min(I,C),M=this.slice(d,h),D=n.slice(r,u);for(let _=0;_<O;++_)if(M[_]!==D[_]){I=M[_],C=D[_];break}return I<C?-1:C<I?1:0};function Y(a,n,r,u,d){if(a.length===0)return-1;if(typeof r=="string"?(u=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Tt(r)&&(r=d?0:a.length-1),r<0&&(r=a.length+r),r>=a.length){if(d)return-1;r=a.length-1}else if(r<0)if(d)r=0;else return-1;if(typeof n=="string"&&(n=o.from(n,u)),o.isBuffer(n))return n.length===0?-1:Wt(a,n,r,u,d);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(a,n,r):Uint8Array.prototype.lastIndexOf.call(a,n,r):Wt(a,[n],r,u,d);throw new TypeError("val must be string, number or Buffer")}function Wt(a,n,r,u,d){let h=1,I=a.length,C=n.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(a.length<2||n.length<2)return-1;h=2,I/=2,C/=2,r/=2}function O(D,_){return h===1?D[_]:D.readUInt16BE(_*h)}let M;if(d){let D=-1;for(M=r;M<I;M++)if(O(a,M)===O(n,D===-1?0:M-D)){if(D===-1&&(D=M),M-D+1===C)return D*h}else D!==-1&&(M-=M-D),D=-1}else for(r+C>I&&(r=I-C),M=r;M>=0;M--){let D=!0;for(let _=0;_<C;_++)if(O(a,M+_)!==O(n,_)){D=!1;break}if(D)return M}return-1}o.prototype.includes=function(n,r,u){return this.indexOf(n,r,u)!==-1},o.prototype.indexOf=function(n,r,u){return Y(this,n,r,u,!0)},o.prototype.lastIndexOf=function(n,r,u){return Y(this,n,r,u,!1)};function Cr(a,n,r,u){r=Number(r)||0;let d=a.length-r;u?(u=Number(u),u>d&&(u=d)):u=d;let h=n.length;u>h/2&&(u=h/2);let I;for(I=0;I<u;++I){let C=parseInt(n.substr(I*2,2),16);if(Tt(C))return I;a[r+I]=C}return I}function Ur(a,n,r,u){return tt(It(n,a.length-r),a,r,u)}function Lr(a,n,r,u){return tt(zr(n),a,r,u)}function _r(a,n,r,u){return tt(Qt(n),a,r,u)}function Mr(a,n,r,u){return tt(Yr(n,a.length-r),a,r,u)}o.prototype.write=function(n,r,u,d){if(r===void 0)d="utf8",u=this.length,r=0;else if(u===void 0&&typeof r=="string")d=r,u=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(u)?(u=u>>>0,d===void 0&&(d="utf8")):(d=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-r;if((u===void 0||u>h)&&(u=h),n.length>0&&(u<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let I=!1;for(;;)switch(d){case"hex":return Cr(this,n,r,u);case"utf8":case"utf-8":return Ur(this,n,r,u);case"ascii":case"latin1":case"binary":return Lr(this,n,r,u);case"base64":return _r(this,n,r,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mr(this,n,r,u);default:if(I)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),I=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $r(a,n,r){return n===0&&r===a.length?p.fromByteArray(a):p.fromByteArray(a.slice(n,r))}function Gt(a,n,r){r=Math.min(a.length,r);let u=[],d=n;for(;d<r;){let h=a[d],I=null,C=h>239?4:h>223?3:h>191?2:1;if(d+C<=r){let O,M,D,_;switch(C){case 1:h<128&&(I=h);break;case 2:O=a[d+1],(O&192)===128&&(_=(h&31)<<6|O&63,_>127&&(I=_));break;case 3:O=a[d+1],M=a[d+2],(O&192)===128&&(M&192)===128&&(_=(h&15)<<12|(O&63)<<6|M&63,_>2047&&(_<55296||_>57343)&&(I=_));break;case 4:O=a[d+1],M=a[d+2],D=a[d+3],(O&192)===128&&(M&192)===128&&(D&192)===128&&(_=(h&15)<<18|(O&63)<<12|(M&63)<<6|D&63,_>65535&&_<1114112&&(I=_))}}I===null?(I=65533,C=1):I>65535&&(I-=65536,u.push(I>>>10&1023|55296),I=56320|I&1023),u.push(I),d+=C}return Or(u)}let qt=4096;function Or(a){let n=a.length;if(n<=qt)return String.fromCharCode.apply(String,a);let r="",u=0;for(;u<n;)r+=String.fromCharCode.apply(String,a.slice(u,u+=qt));return r}function Dr(a,n,r){let u="";r=Math.min(a.length,r);for(let d=n;d<r;++d)u+=String.fromCharCode(a[d]&127);return u}function Vr(a,n,r){let u="";r=Math.min(a.length,r);for(let d=n;d<r;++d)u+=String.fromCharCode(a[d]);return u}function Wr(a,n,r){let u=a.length;(!n||n<0)&&(n=0),(!r||r<0||r>u)&&(r=u);let d="";for(let h=n;h<r;++h)d+=Kr[a[h]];return d}function Gr(a,n,r){let u=a.slice(n,r),d="";for(let h=0;h<u.length-1;h+=2)d+=String.fromCharCode(u[h]+u[h+1]*256);return d}o.prototype.slice=function(n,r){let u=this.length;n=~~n,r=r===void 0?u:~~r,n<0?(n+=u,n<0&&(n=0)):n>u&&(n=u),r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),r<n&&(r=n);let d=this.subarray(n,r);return Object.setPrototypeOf(d,o.prototype),d};function G(a,n,r){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+n>r)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(n,r,u){n=n>>>0,r=r>>>0,u||G(n,r,this.length);let d=this[n],h=1,I=0;for(;++I<r&&(h*=256);)d+=this[n+I]*h;return d},o.prototype.readUintBE=o.prototype.readUIntBE=function(n,r,u){n=n>>>0,r=r>>>0,u||G(n,r,this.length);let d=this[n+--r],h=1;for(;r>0&&(h*=256);)d+=this[n+--r]*h;return d},o.prototype.readUint8=o.prototype.readUInt8=function(n,r){return n=n>>>0,r||G(n,1,this.length),this[n]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(n,r){return n=n>>>0,r||G(n,2,this.length),this[n]|this[n+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(n,r){return n=n>>>0,r||G(n,2,this.length),this[n]<<8|this[n+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(n,r){return n=n>>>0,r||G(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(n,r){return n=n>>>0,r||G(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},o.prototype.readBigUInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],u=this[n+7];(r===void 0||u===void 0)&&Me(n,this.length-8);let d=r+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,h=this[++n]+this[++n]*2**8+this[++n]*2**16+u*2**24;return BigInt(d)+(BigInt(h)<<BigInt(32))}),o.prototype.readBigUInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],u=this[n+7];(r===void 0||u===void 0)&&Me(n,this.length-8);let d=r*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],h=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+u;return(BigInt(d)<<BigInt(32))+BigInt(h)}),o.prototype.readIntLE=function(n,r,u){n=n>>>0,r=r>>>0,u||G(n,r,this.length);let d=this[n],h=1,I=0;for(;++I<r&&(h*=256);)d+=this[n+I]*h;return h*=128,d>=h&&(d-=Math.pow(2,8*r)),d},o.prototype.readIntBE=function(n,r,u){n=n>>>0,r=r>>>0,u||G(n,r,this.length);let d=r,h=1,I=this[n+--d];for(;d>0&&(h*=256);)I+=this[n+--d]*h;return h*=128,I>=h&&(I-=Math.pow(2,8*r)),I},o.prototype.readInt8=function(n,r){return n=n>>>0,r||G(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},o.prototype.readInt16LE=function(n,r){n=n>>>0,r||G(n,2,this.length);let u=this[n]|this[n+1]<<8;return u&32768?u|4294901760:u},o.prototype.readInt16BE=function(n,r){n=n>>>0,r||G(n,2,this.length);let u=this[n+1]|this[n]<<8;return u&32768?u|4294901760:u},o.prototype.readInt32LE=function(n,r){return n=n>>>0,r||G(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},o.prototype.readInt32BE=function(n,r){return n=n>>>0,r||G(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},o.prototype.readBigInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],u=this[n+7];(r===void 0||u===void 0)&&Me(n,this.length-8);let d=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(u<<24);return(BigInt(d)<<BigInt(32))+BigInt(r+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),o.prototype.readBigInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],u=this[n+7];(r===void 0||u===void 0)&&Me(n,this.length-8);let d=(r<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(d)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+u)}),o.prototype.readFloatLE=function(n,r){return n=n>>>0,r||G(n,4,this.length),t.read(this,n,!0,23,4)},o.prototype.readFloatBE=function(n,r){return n=n>>>0,r||G(n,4,this.length),t.read(this,n,!1,23,4)},o.prototype.readDoubleLE=function(n,r){return n=n>>>0,r||G(n,8,this.length),t.read(this,n,!0,52,8)},o.prototype.readDoubleBE=function(n,r){return n=n>>>0,r||G(n,8,this.length),t.read(this,n,!1,52,8)};function X(a,n,r,u,d,h){if(!o.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>d||n<h)throw new RangeError('"value" argument is out of bounds');if(r+u>a.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(n,r,u,d){if(n=+n,r=r>>>0,u=u>>>0,!d){let C=Math.pow(2,8*u)-1;X(this,n,r,u,C,0)}let h=1,I=0;for(this[r]=n&255;++I<u&&(h*=256);)this[r+I]=n/h&255;return r+u},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(n,r,u,d){if(n=+n,r=r>>>0,u=u>>>0,!d){let C=Math.pow(2,8*u)-1;X(this,n,r,u,C,0)}let h=u-1,I=1;for(this[r+h]=n&255;--h>=0&&(I*=256);)this[r+h]=n/I&255;return r+u},o.prototype.writeUint8=o.prototype.writeUInt8=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,1,255,0),this[r]=n&255,r+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,2,65535,0),this[r]=n&255,this[r+1]=n>>>8,r+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,2,65535,0),this[r]=n>>>8,this[r+1]=n&255,r+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,4,4294967295,0),this[r+3]=n>>>24,this[r+2]=n>>>16,this[r+1]=n>>>8,this[r]=n&255,r+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,4,4294967295,0),this[r]=n>>>24,this[r+1]=n>>>16,this[r+2]=n>>>8,this[r+3]=n&255,r+4};function jt(a,n,r,u,d){Xt(n,u,d,a,r,7);let h=Number(n&BigInt(4294967295));a[r++]=h,h=h>>8,a[r++]=h,h=h>>8,a[r++]=h,h=h>>8,a[r++]=h;let I=Number(n>>BigInt(32)&BigInt(4294967295));return a[r++]=I,I=I>>8,a[r++]=I,I=I>>8,a[r++]=I,I=I>>8,a[r++]=I,r}function Ht(a,n,r,u,d){Xt(n,u,d,a,r,7);let h=Number(n&BigInt(4294967295));a[r+7]=h,h=h>>8,a[r+6]=h,h=h>>8,a[r+5]=h,h=h>>8,a[r+4]=h;let I=Number(n>>BigInt(32)&BigInt(4294967295));return a[r+3]=I,I=I>>8,a[r+2]=I,I=I>>8,a[r+1]=I,I=I>>8,a[r]=I,r+8}o.prototype.writeBigUInt64LE=de(function(n,r=0){return jt(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=de(function(n,r=0){return Ht(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(n,r,u,d){if(n=+n,r=r>>>0,!d){let O=Math.pow(2,8*u-1);X(this,n,r,u,O-1,-O)}let h=0,I=1,C=0;for(this[r]=n&255;++h<u&&(I*=256);)n<0&&C===0&&this[r+h-1]!==0&&(C=1),this[r+h]=(n/I>>0)-C&255;return r+u},o.prototype.writeIntBE=function(n,r,u,d){if(n=+n,r=r>>>0,!d){let O=Math.pow(2,8*u-1);X(this,n,r,u,O-1,-O)}let h=u-1,I=1,C=0;for(this[r+h]=n&255;--h>=0&&(I*=256);)n<0&&C===0&&this[r+h+1]!==0&&(C=1),this[r+h]=(n/I>>0)-C&255;return r+u},o.prototype.writeInt8=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,1,127,-128),n<0&&(n=255+n+1),this[r]=n&255,r+1},o.prototype.writeInt16LE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,2,32767,-32768),this[r]=n&255,this[r+1]=n>>>8,r+2},o.prototype.writeInt16BE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,2,32767,-32768),this[r]=n>>>8,this[r+1]=n&255,r+2},o.prototype.writeInt32LE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,4,2147483647,-2147483648),this[r]=n&255,this[r+1]=n>>>8,this[r+2]=n>>>16,this[r+3]=n>>>24,r+4},o.prototype.writeInt32BE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[r]=n>>>24,this[r+1]=n>>>16,this[r+2]=n>>>8,this[r+3]=n&255,r+4},o.prototype.writeBigInt64LE=de(function(n,r=0){return jt(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=de(function(n,r=0){return Ht(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function zt(a,n,r,u,d,h){if(r+u>a.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Yt(a,n,r,u,d){return n=+n,r=r>>>0,d||zt(a,n,r,4),t.write(a,n,r,u,23,4),r+4}o.prototype.writeFloatLE=function(n,r,u){return Yt(this,n,r,!0,u)},o.prototype.writeFloatBE=function(n,r,u){return Yt(this,n,r,!1,u)};function Kt(a,n,r,u,d){return n=+n,r=r>>>0,d||zt(a,n,r,8),t.write(a,n,r,u,52,8),r+8}o.prototype.writeDoubleLE=function(n,r,u){return Kt(this,n,r,!0,u)},o.prototype.writeDoubleBE=function(n,r,u){return Kt(this,n,r,!1,u)},o.prototype.copy=function(n,r,u,d){if(!o.isBuffer(n))throw new TypeError("argument should be a Buffer");if(u||(u=0),!d&&d!==0&&(d=this.length),r>=n.length&&(r=n.length),r||(r=0),d>0&&d<u&&(d=u),d===u||n.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),n.length-r<d-u&&(d=n.length-r+u);let h=d-u;return this===n&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,u,d):Uint8Array.prototype.set.call(n,this.subarray(u,d),r),h},o.prototype.fill=function(n,r,u,d){if(typeof n=="string"){if(typeof r=="string"?(d=r,r=0,u=this.length):typeof u=="string"&&(d=u,u=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!o.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(n.length===1){let I=n.charCodeAt(0);(d==="utf8"&&I<128||d==="latin1")&&(n=I)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(r<0||this.length<r||this.length<u)throw new RangeError("Out of range index");if(u<=r)return this;r=r>>>0,u=u===void 0?this.length:u>>>0,n||(n=0);let h;if(typeof n=="number")for(h=r;h<u;++h)this[h]=n;else{let I=o.isBuffer(n)?n:o.from(n,d),C=I.length;if(C===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(h=0;h<u-r;++h)this[h+r]=I[h%C]}return this};let Be={};function wt(a,n,r){Be[a]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}}}wt("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),wt("ERR_INVALID_ARG_TYPE",function(a,n){return`The "${a}" argument must be of type number. Received type ${typeof n}`},TypeError),wt("ERR_OUT_OF_RANGE",function(a,n,r){let u=`The value of "${a}" is out of range.`,d=r;return Number.isInteger(r)&&Math.abs(r)>2**32?d=Jt(String(r)):typeof r=="bigint"&&(d=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(d=Jt(d)),d+="n"),u+=` It must be ${n}. Received ${d}`,u},RangeError);function Jt(a){let n="",r=a.length,u=a[0]==="-"?1:0;for(;r>=u+4;r-=3)n=`_${a.slice(r-3,r)}${n}`;return`${a.slice(0,r)}${n}`}function qr(a,n,r){Ce(n,"offset"),(a[n]===void 0||a[n+r]===void 0)&&Me(n,a.length-(r+1))}function Xt(a,n,r,u,d,h){if(a>r||a<n){let I=typeof n=="bigint"?"n":"",C;throw n===0||n===BigInt(0)?C=`>= 0${I} and < 2${I} ** ${(h+1)*8}${I}`:C=`>= -(2${I} ** ${(h+1)*8-1}${I}) and < 2 ** ${(h+1)*8-1}${I}`,new Be.ERR_OUT_OF_RANGE("value",C,a)}qr(u,d,h)}function Ce(a,n){if(typeof a!="number")throw new Be.ERR_INVALID_ARG_TYPE(n,"number",a)}function Me(a,n,r){throw Math.floor(a)!==a?(Ce(a,r),new Be.ERR_OUT_OF_RANGE("offset","an integer",a)):n<0?new Be.ERR_BUFFER_OUT_OF_BOUNDS:new Be.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,a)}let jr=/[^+/0-9A-Za-z-_]/g;function Hr(a){if(a=a.split("=")[0],a=a.trim().replace(jr,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}function It(a,n){n=n||1/0;let r,u=a.length,d=null,h=[];for(let I=0;I<u;++I){if(r=a.charCodeAt(I),r>55295&&r<57344){if(!d){if(r>56319){(n-=3)>-1&&h.push(239,191,189);continue}else if(I+1===u){(n-=3)>-1&&h.push(239,191,189);continue}d=r;continue}if(r<56320){(n-=3)>-1&&h.push(239,191,189),d=r;continue}r=(d-55296<<10|r-56320)+65536}else d&&(n-=3)>-1&&h.push(239,191,189);if(d=null,r<128){if((n-=1)<0)break;h.push(r)}else if(r<2048){if((n-=2)<0)break;h.push(r>>6|192,r&63|128)}else if(r<65536){if((n-=3)<0)break;h.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((n-=4)<0)break;h.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return h}function zr(a){let n=[];for(let r=0;r<a.length;++r)n.push(a.charCodeAt(r)&255);return n}function Yr(a,n){let r,u,d,h=[];for(let I=0;I<a.length&&!((n-=2)<0);++I)r=a.charCodeAt(I),u=r>>8,d=r%256,h.push(d),h.push(u);return h}function Qt(a){return p.toByteArray(Hr(a))}function tt(a,n,r,u){let d;for(d=0;d<u&&!(d+r>=n.length||d>=a.length);++d)n[d+r]=a[d];return d}function te(a,n){return a instanceof n||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===n.name}function Tt(a){return a!==a}let Kr=(function(){let a="0123456789abcdef",n=new Array(256);for(let r=0;r<16;++r){let u=r*16;for(let d=0;d<16;++d)n[u+d]=a[r]+a[d]}return n})();function de(a){return typeof BigInt>"u"?Jr:a}function Jr(){throw new Error("BigInt not supported")}return ge}var $e,gr,st,vr,ge,wr,Tr=oe(()=>{"use strict";y();v();g();$e={},gr=!1;st={},vr=!1;ge={},wr=!1});var ve,A,bs,Ns,xr=oe(()=>{"use strict";y();v();g();Tr();ve=Ir();ve.Buffer;ve.SlowBuffer;ve.INSPECT_MAX_BYTES;ve.kMaxLength;A=ve.Buffer,bs=ve.INSPECT_MAX_BYTES,Ns=ve.kMaxLength});var v=oe(()=>{"use strict";xr()});function Bt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function ci(){!Le||!Ie||(Le=!1,Ie.length?ce=Ie.concat(ce):pt=-1,ce.length&&Nr())}function Nr(){if(!Le){var p=setTimeout(ci,0);Le=!0;for(var t=ce.length;t;){for(Ie=ce,ce=[];++pt<t;)Ie&&Ie[pt].run();pt=-1,t=ce.length}Ie=null,Le=!1,clearTimeout(p)}}function ui(p){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];ce.push(new Ar(p,t)),ce.length===1&&!Le&&setTimeout(Nr,0)}function Ar(p,t){this.fun=p,this.array=t}function z(){}function Ai(p){Bt("_linkedBinding")}function ki(p){Bt("dlopen")}function Si(){return[]}function Bi(){return[]}function Vi(p,t){if(!p)throw new Error(t||"assertion error")}function ji(){return!1}function co(){return he.now()/1e3}function St(p){var t=Math.floor((Date.now()-he.now())*.001),e=he.now()*.001,i=Math.floor(e)+t,s=Math.floor(e%1*1e9);return p&&(i=i-p[0],s=s-p[1],s<0&&(i--,s+=kt)),[i,s]}function me(){return Ut}function To(p){return[]}var ce,Le,Ie,pt,pi,li,di,fi,hi,mi,yi,gi,vi,wi,Ii,Ti,xi,Ei,bi,Ni,Ri,Fi,Pi,Ci,Ui,Ct,Li,_i,Mi,$i,Oi,Di,Wi,Gi,qi,Hi,zi,Yi,Ki,Ji,Xi,Qi,Zi,eo,to,no,ro,io,oo,so,ao,he,Pt,kt,uo,po,lo,fo,ho,mo,yo,go,vo,wo,Io,Ut,Lt=oe(()=>{"use strict";y();v();g();ce=[],Le=!1,pt=-1;Ar.prototype.run=function(){this.fun.apply(null,this.array)};pi="browser",li="x64",di="browser",fi={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},hi=["/usr/bin/node"],mi=[],yi="v16.8.0",gi={},vi=function(p,t){console.warn((t?t+": ":"")+p)},wi=function(p){Bt("binding")},Ii=function(p){return 0},Ti=function(){return"/"},xi=function(p){},Ei={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};bi=z,Ni=[];Ri={},Fi=!1,Pi={};Ci=z,Ui=z,Ct=function(){return{}},Li=Ct,_i=Ct,Mi=z,$i=z,Oi=z,Di={};Wi={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Gi=z,qi=z;Hi=z,zi=z,Yi=z,Ki=z,Ji=z,Xi=void 0,Qi=void 0,Zi=void 0,eo=z,to=2,no=1,ro="/bin/usr/node",io=9229,oo="node",so=[],ao=z,he={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};he.now===void 0&&(Pt=Date.now(),he.timing&&he.timing.navigationStart&&(Pt=he.timing.navigationStart),he.now=()=>Date.now()-Pt);kt=1e9;St.bigint=function(p){var t=St(p);return typeof BigInt>"u"?t[0]*kt+t[1]:BigInt(t[0]*kt)+BigInt(t[1])};uo=10,po={},lo=0;fo=me,ho=me,mo=me,yo=me,go=me,vo=z,wo=me,Io=me;Ut={version:yi,versions:gi,arch:li,platform:di,release:Ei,_rawDebug:bi,moduleLoadList:Ni,binding:wi,_linkedBinding:Ai,_events:po,_eventsCount:lo,_maxListeners:uo,on:me,addListener:fo,once:ho,off:mo,removeListener:yo,removeAllListeners:go,emit:vo,prependListener:wo,prependOnceListener:Io,listeners:To,domain:Ri,_exiting:Fi,config:Pi,dlopen:ki,uptime:co,_getActiveRequests:Si,_getActiveHandles:Bi,reallyExit:Ci,_kill:Ui,cpuUsage:Ct,resourceUsage:Li,memoryUsage:_i,kill:Mi,exit:$i,openStdin:Oi,allowedNodeEnvironmentFlags:Di,assert:Vi,features:Wi,_fatalExceptions:Gi,setUncaughtExceptionCaptureCallback:qi,hasUncaughtExceptionCaptureCallback:ji,emitWarning:vi,nextTick:ui,_tickCallback:Hi,_debugProcess:zi,_debugEnd:Yi,_startProfilerIdleNotifier:Ki,_stopProfilerIdleNotifier:Ji,stdout:Xi,stdin:Zi,stderr:Qi,abort:eo,umask:Ii,chdir:xi,cwd:Ti,env:fi,title:pi,argv:hi,execArgv:mi,pid:to,ppid:no,execPath:ro,debugPort:io,hrtime:St,argv0:oo,_preload_modules:so,setSourceMapsEnabled:ao}});function xo(){if(Rr)return _t;Rr=!0;var p=Ut;function t(c){if(typeof c!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(c))}function e(c,o){for(var f="",w=0,T=-1,E=0,x,P=0;P<=c.length;++P){if(P<c.length)x=c.charCodeAt(P);else{if(x===47)break;x=47}if(x===47){if(!(T===P-1||E===1))if(T!==P-1&&E===2){if(f.length<2||w!==2||f.charCodeAt(f.length-1)!==46||f.charCodeAt(f.length-2)!==46){if(f.length>2){var b=f.lastIndexOf("/");if(b!==f.length-1){b===-1?(f="",w=0):(f=f.slice(0,b),w=f.length-1-f.lastIndexOf("/")),T=P,E=0;continue}}else if(f.length===2||f.length===1){f="",w=0,T=P,E=0;continue}}o&&(f.length>0?f+="/..":f="..",w=2)}else f.length>0?f+="/"+c.slice(T+1,P):f=c.slice(T+1,P),w=P-T-1;T=P,E=0}else x===46&&E!==-1?++E:E=-1}return f}function i(c,o){var f=o.dir||o.root,w=o.base||(o.name||"")+(o.ext||"");return f?f===o.root?f+w:f+c+w:w}var s={resolve:function(){for(var o="",f=!1,w,T=arguments.length-1;T>=-1&&!f;T--){var E;T>=0?E=arguments[T]:(w===void 0&&(w=p.cwd()),E=w),t(E),E.length!==0&&(o=E+"/"+o,f=E.charCodeAt(0)===47)}return o=e(o,!f),f?o.length>0?"/"+o:"/":o.length>0?o:"."},normalize:function(o){if(t(o),o.length===0)return".";var f=o.charCodeAt(0)===47,w=o.charCodeAt(o.length-1)===47;return o=e(o,!f),o.length===0&&!f&&(o="."),o.length>0&&w&&(o+="/"),f?"/"+o:o},isAbsolute:function(o){return t(o),o.length>0&&o.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var o,f=0;f<arguments.length;++f){var w=arguments[f];t(w),w.length>0&&(o===void 0?o=w:o+="/"+w)}return o===void 0?".":s.normalize(o)},relative:function(o,f){if(t(o),t(f),o===f||(o=s.resolve(o),f=s.resolve(f),o===f))return"";for(var w=1;w<o.length&&o.charCodeAt(w)===47;++w);for(var T=o.length,E=T-w,x=1;x<f.length&&f.charCodeAt(x)===47;++x);for(var P=f.length,b=P-x,F=E<b?E:b,B=-1,S=0;S<=F;++S){if(S===F){if(b>F){if(f.charCodeAt(x+S)===47)return f.slice(x+S+1);if(S===0)return f.slice(x+S)}else E>F&&(o.charCodeAt(w+S)===47?B=S:S===0&&(B=0));break}var q=o.charCodeAt(w+S),$=f.charCodeAt(x+S);if(q!==$)break;q===47&&(B=S)}var V="";for(S=w+B+1;S<=T;++S)(S===T||o.charCodeAt(S)===47)&&(V.length===0?V+="..":V+="/..");return V.length>0?V+f.slice(x+B):(x+=B,f.charCodeAt(x)===47&&++x,f.slice(x))},_makeLong:function(o){return o},dirname:function(o){if(t(o),o.length===0)return".";for(var f=o.charCodeAt(0),w=f===47,T=-1,E=!0,x=o.length-1;x>=1;--x)if(f=o.charCodeAt(x),f===47){if(!E){T=x;break}}else E=!1;return T===-1?w?"/":".":w&&T===1?"//":o.slice(0,T)},basename:function(o,f){if(f!==void 0&&typeof f!="string")throw new TypeError('"ext" argument must be a string');t(o);var w=0,T=-1,E=!0,x;if(f!==void 0&&f.length>0&&f.length<=o.length){if(f.length===o.length&&f===o)return"";var P=f.length-1,b=-1;for(x=o.length-1;x>=0;--x){var F=o.charCodeAt(x);if(F===47){if(!E){w=x+1;break}}else b===-1&&(E=!1,b=x+1),P>=0&&(F===f.charCodeAt(P)?--P===-1&&(T=x):(P=-1,T=b))}return w===T?T=b:T===-1&&(T=o.length),o.slice(w,T)}else{for(x=o.length-1;x>=0;--x)if(o.charCodeAt(x)===47){if(!E){w=x+1;break}}else T===-1&&(E=!1,T=x+1);return T===-1?"":o.slice(w,T)}},extname:function(o){t(o);for(var f=-1,w=0,T=-1,E=!0,x=0,P=o.length-1;P>=0;--P){var b=o.charCodeAt(P);if(b===47){if(!E){w=P+1;break}continue}T===-1&&(E=!1,T=P+1),b===46?f===-1?f=P:x!==1&&(x=1):f!==-1&&(x=-1)}return f===-1||T===-1||x===0||x===1&&f===T-1&&f===w+1?"":o.slice(f,T)},format:function(o){if(o===null||typeof o!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof o);return i("/",o)},parse:function(o){t(o);var f={root:"",dir:"",base:"",ext:"",name:""};if(o.length===0)return f;var w=o.charCodeAt(0),T=w===47,E;T?(f.root="/",E=1):E=0;for(var x=-1,P=0,b=-1,F=!0,B=o.length-1,S=0;B>=E;--B){if(w=o.charCodeAt(B),w===47){if(!F){P=B+1;break}continue}b===-1&&(F=!1,b=B+1),w===46?x===-1?x=B:S!==1&&(S=1):x!==-1&&(S=-1)}return x===-1||b===-1||S===0||S===1&&x===b-1&&x===P+1?b!==-1&&(P===0&&T?f.base=f.name=o.slice(1,b):f.base=f.name=o.slice(P,b)):(P===0&&T?(f.name=o.slice(1,x),f.base=o.slice(1,b)):(f.name=o.slice(P,x),f.base=o.slice(P,b)),f.ext=o.slice(x,b)),P>0?f.dir=o.slice(0,P-1):T&&(f.dir="/"),f},sep:"/",delimiter:":",win32:null,posix:null};return s.posix=s,_t=s,_t}var _t,Rr,W,Fr=oe(()=>{"use strict";y();v();g();Lt();_t={},Rr=!1;W=xo()});var Tu,xu,Eu,bu,Nu,Au,Ru,Fu,Pu,ku,Su,Bu,Cu,Uu,Lu,Pr=oe(()=>{"use strict";y();v();g();Fr();Lt();Tu=W._makeLong,xu=W.basename,Eu=W.delimiter,bu=W.dirname,Nu=W.extname,Au=W.format,Ru=W.isAbsolute,Fu=W.join,Pu=W.normalize,ku=W.parse,Su=W.posix,Bu=W.relative,Cu=W.resolve,Uu=W.sep,Lu=W.win32});var ls={};xt(ls,{DynamicSnippetsGenerator:()=>vt});module.exports=ni(ls);y();v();g();y();v();g();y();v();g();y();v();g();function U(p){throw new Error("Unexpected value: "+JSON.stringify(p))}y();v();g();function Oe(p){return Object.keys(p)}y();v();g();y();v();g();y();v();g();var De=N.env.FERN_STACK_TRACK?.toLowerCase()??"",ne=De!==""&&De!=="0"&&De!=="false",At=["single","multiline","box"].includes(De)?De:"single";ne&&(Error.stackTraceLimit=50);var si=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),ai=new Set(["stacktrace"]);function ct({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:s=[],filterNode:c=!0,filterJs:o=!0,formatFilename:f=w=>w}={}){if(!ne)return[];i=[...i,...si],e=[...e,...ai],s=[...s,"runInteractiveTask"];let w=!1;return(new Error().stack??"").split(`
|
|
2
|
-
`).map(T=>{let
|
|
3
|
-
`:""}${i.fn} - ${i.path}:${i.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},Rt;function
|
|
1
|
+
"use strict";var rt=Object.defineProperty;var Xn=Object.getOwnPropertyDescriptor;var Qn=Object.getOwnPropertyNames;var Zn=Object.prototype.hasOwnProperty;var ei=(p,t,e)=>t in p?rt(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var oe=(p,t,e)=>()=>{if(e)throw e[0];try{return p&&(t=p(p=0)),t}catch(i){throw e=[i],i}};var xt=(p,t)=>{for(var e in t)rt(p,e,{get:t[e],enumerable:!0})},ti=(p,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Qn(t))!Zn.call(p,s)&&s!==e&&rt(p,s,{get:()=>t[s],enumerable:!(i=Xn(t,s))||i.enumerable});return p};var ri=p=>ti(rt({},"__esModule",{value:!0}),p);var m=(p,t,e)=>ei(p,typeof t!="symbol"?t+"":t,e);var y=oe(()=>{"use strict"});var N={};xt(N,{_debugEnd:()=>Vr,_debugProcess:()=>Dr,_events:()=>nn,_eventsCount:()=>on,_exiting:()=>Tr,_fatalExceptions:()=>_r,_getActiveHandles:()=>Nr,_getActiveRequests:()=>Er,_kill:()=>Rr,_linkedBinding:()=>wr,_maxListeners:()=>rn,_preload_modules:()=>Zr,_rawDebug:()=>gr,_startProfilerIdleNotifier:()=>Wr,_stopProfilerIdleNotifier:()=>Gr,_tickCallback:()=>Or,abort:()=>zr,addListener:()=>sn,allowedNodeEnvironmentFlags:()=>Cr,arch:()=>nr,argv:()=>sr,argv0:()=>Qr,assert:()=>Ur,binding:()=>lr,browser:()=>yr,chdir:()=>hr,config:()=>xr,cpuUsage:()=>ot,cwd:()=>fr,debugPort:()=>Xr,default:()=>mn,dlopen:()=>br,domain:()=>Ir,emit:()=>ln,emitWarning:()=>pr,env:()=>or,execArgv:()=>ar,execPath:()=>Jr,exit:()=>Br,features:()=>Lr,hasUncaughtExceptionCaptureCallback:()=>$r,hrtime:()=>it,kill:()=>kr,listeners:()=>hn,memoryUsage:()=>Pr,moduleLoadList:()=>vr,nextTick:()=>er,off:()=>cn,on:()=>ae,once:()=>an,openStdin:()=>Sr,pid:()=>Yr,platform:()=>ir,ppid:()=>Kr,prependListener:()=>dn,prependOnceListener:()=>fn,reallyExit:()=>Ar,release:()=>mr,removeAllListeners:()=>pn,removeListener:()=>un,resourceUsage:()=>Fr,setSourceMapsEnabled:()=>en,setUncaughtExceptionCaptureCallback:()=>Mr,stderr:()=>jr,stdin:()=>Hr,stdout:()=>qr,title:()=>rr,umask:()=>dr,uptime:()=>tn,version:()=>cr,versions:()=>ur});function Nt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function ni(){!Ue||!ye||(Ue=!1,ye.length?se=ye.concat(se):nt=-1,se.length&&Zt())}function Zt(){if(!Ue){var p=setTimeout(ni,0);Ue=!0;for(var t=se.length;t;){for(ye=se,se=[];++nt<t;)ye&&ye[nt].run();nt=-1,t=se.length}ye=null,Ue=!1,clearTimeout(p)}}function er(p){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];se.push(new tr(p,t)),se.length===1&&!Ue&&setTimeout(Zt,0)}function tr(p,t){this.fun=p,this.array=t}function H(){}function wr(p){Nt("_linkedBinding")}function br(p){Nt("dlopen")}function Er(){return[]}function Nr(){return[]}function Ur(p,t){if(!p)throw new Error(t||"assertion error")}function $r(){return!1}function tn(){return fe.now()/1e3}function it(p){var t=Math.floor((Date.now()-fe.now())*.001),e=fe.now()*.001,i=Math.floor(e)+t,s=Math.floor(e%1*1e9);return p&&(i=i-p[0],s=s-p[1],s<0&&(i--,s+=Et)),[i,s]}function ae(){return mn}function hn(p){return[]}var se,Ue,ye,nt,rr,nr,ir,or,sr,ar,cr,ur,pr,lr,dr,fr,hr,mr,yr,gr,vr,Ir,Tr,xr,Ar,Rr,ot,Fr,Pr,kr,Br,Sr,Cr,Lr,_r,Mr,Or,Dr,Vr,Wr,Gr,qr,jr,Hr,zr,Yr,Kr,Jr,Xr,Qr,Zr,en,fe,bt,Et,rn,nn,on,sn,an,cn,un,pn,ln,dn,fn,mn,yn=oe(()=>{"use strict";y();v();g();se=[],Ue=!1,nt=-1;tr.prototype.run=function(){this.fun.apply(null,this.array)};rr="browser",nr="x64",ir="browser",or={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},sr=["/usr/bin/node"],ar=[],cr="v16.8.0",ur={},pr=function(p,t){console.warn((t?t+": ":"")+p)},lr=function(p){Nt("binding")},dr=function(p){return 0},fr=function(){return"/"},hr=function(p){},mr={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};yr=!0,gr=H,vr=[];Ir={},Tr=!1,xr={};Ar=H,Rr=H,ot=function(){return{}},Fr=ot,Pr=ot,kr=H,Br=H,Sr=H,Cr={};Lr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},_r=H,Mr=H;Or=H,Dr=H,Vr=H,Wr=H,Gr=H,qr=void 0,jr=void 0,Hr=void 0,zr=H,Yr=2,Kr=1,Jr="/bin/usr/node",Xr=9229,Qr="node",Zr=[],en=H,fe={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};fe.now===void 0&&(bt=Date.now(),fe.timing&&fe.timing.navigationStart&&(bt=fe.timing.navigationStart),fe.now=()=>Date.now()-bt);Et=1e9;it.bigint=function(p){var t=it(p);return typeof BigInt>"u"?t[0]*Et+t[1]:BigInt(t[0]*Et)+BigInt(t[1])};rn=10,nn={},on=0;sn=ae,an=ae,cn=ae,un=ae,pn=ae,ln=H,dn=ae,fn=ae;mn={version:cr,versions:ur,arch:nr,platform:ir,browser:yr,release:mr,_rawDebug:gr,moduleLoadList:vr,binding:lr,_linkedBinding:wr,_events:nn,_eventsCount:on,_maxListeners:rn,on:ae,addListener:sn,once:an,off:cn,removeListener:un,removeAllListeners:pn,emit:ln,prependListener:dn,prependOnceListener:fn,listeners:hn,domain:Ir,_exiting:Tr,config:xr,dlopen:br,uptime:tn,_getActiveRequests:Er,_getActiveHandles:Nr,reallyExit:Ar,_kill:Rr,cpuUsage:ot,resourceUsage:Fr,memoryUsage:Pr,kill:kr,exit:Br,openStdin:Sr,allowedNodeEnvironmentFlags:Cr,assert:Ur,features:Lr,_fatalExceptions:_r,setUncaughtExceptionCaptureCallback:Mr,hasUncaughtExceptionCaptureCallback:$r,emitWarning:pr,nextTick:er,_tickCallback:Or,_debugProcess:Dr,_debugEnd:Vr,_startProfilerIdleNotifier:Wr,_stopProfilerIdleNotifier:Gr,stdout:qr,stdin:Hr,stderr:jr,abort:zr,umask:dr,chdir:hr,cwd:fr,env:or,title:rr,argv:sr,execArgv:ar,pid:Yr,ppid:Kr,execPath:Jr,debugPort:Xr,hrtime:it,argv0:Qr,_preload_modules:Zr,setSourceMapsEnabled:en}});var g=oe(()=>{"use strict";yn()});function ii(){if(gn)return $e;gn=!0,$e.byteLength=f,$e.toByteArray=T,$e.fromByteArray=P;for(var p=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=i.length;s<c;++s)p[s]=i[s],t[i.charCodeAt(s)]=s;t[45]=62,t[95]=63;function o(E){var F=E.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var S=E.indexOf("=");S===-1&&(S=F);var B=S===F?0:4-S%4;return[S,B]}function f(E){var F=o(E),S=F[0],B=F[1];return(S+B)*3/4-B}function w(E,F,S){return(F+S)*3/4-S}function T(E){var F,S=o(E),B=S[0],q=S[1],$=new e(w(E,B,q)),V=0,Q=q>0?B-4:B,Y;for(Y=0;Y<Q;Y+=4)F=t[E.charCodeAt(Y)]<<18|t[E.charCodeAt(Y+1)]<<12|t[E.charCodeAt(Y+2)]<<6|t[E.charCodeAt(Y+3)],$[V++]=F>>16&255,$[V++]=F>>8&255,$[V++]=F&255;return q===2&&(F=t[E.charCodeAt(Y)]<<2|t[E.charCodeAt(Y+1)]>>4,$[V++]=F&255),q===1&&(F=t[E.charCodeAt(Y)]<<10|t[E.charCodeAt(Y+1)]<<4|t[E.charCodeAt(Y+2)]>>2,$[V++]=F>>8&255,$[V++]=F&255),$}function b(E){return p[E>>18&63]+p[E>>12&63]+p[E>>6&63]+p[E&63]}function x(E,F,S){for(var B,q=[],$=F;$<S;$+=3)B=(E[$]<<16&16711680)+(E[$+1]<<8&65280)+(E[$+2]&255),q.push(b(B));return q.join("")}function P(E){for(var F,S=E.length,B=S%3,q=[],$=16383,V=0,Q=S-B;V<Q;V+=$)q.push(x(E,V,V+$>Q?Q:V+$));return B===1?(F=E[S-1],q.push(p[F>>2]+p[F<<4&63]+"==")):B===2&&(F=(E[S-2]<<8)+E[S-1],q.push(p[F>>10]+p[F>>4&63]+p[F<<2&63]+"=")),q.join("")}return $e}function oi(){if(vn)return st;vn=!0;return st.read=function(p,t,e,i,s){var c,o,f=s*8-i-1,w=(1<<f)-1,T=w>>1,b=-7,x=e?s-1:0,P=e?-1:1,E=p[t+x];for(x+=P,c=E&(1<<-b)-1,E>>=-b,b+=f;b>0;c=c*256+p[t+x],x+=P,b-=8);for(o=c&(1<<-b)-1,c>>=-b,b+=i;b>0;o=o*256+p[t+x],x+=P,b-=8);if(c===0)c=1-T;else{if(c===w)return o?NaN:(E?-1:1)*(1/0);o=o+Math.pow(2,i),c=c-T}return(E?-1:1)*o*Math.pow(2,c-i)},st.write=function(p,t,e,i,s,c){var o,f,w,T=c*8-s-1,b=(1<<T)-1,x=b>>1,P=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=i?0:c-1,F=i?1:-1,S=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,o=b):(o=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-o))<1&&(o--,w*=2),o+x>=1?t+=P/w:t+=P*Math.pow(2,1-x),t*w>=2&&(o++,w/=2),o+x>=b?(f=0,o=b):o+x>=1?(f=(t*w-1)*Math.pow(2,s),o=o+x):(f=t*Math.pow(2,x-1)*Math.pow(2,s),o=0));s>=8;p[e+E]=f&255,E+=F,f/=256,s-=8);for(o=o<<s|f,T+=s;T>0;p[e+E]=o&255,E+=F,o/=256,T-=8);p[e+E-F]|=S*128},st}function In(){if(wn)return ge;wn=!0;let p=ii(),t=oi(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ge.Buffer=o,ge.SlowBuffer=q,ge.INSPECT_MAX_BYTES=50;let i=2147483647;ge.kMaxLength=i,o.TYPED_ARRAY_SUPPORT=s(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{let a=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(a,r),a.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function c(a){if(a>i)throw new RangeError('The value "'+a+'" is invalid for option "size"');let r=new Uint8Array(a);return Object.setPrototypeOf(r,o.prototype),r}function o(a,r,n){if(typeof a=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(a)}return f(a,r,n)}o.poolSize=8192;function f(a,r,n){if(typeof a=="string")return x(a,r);if(ArrayBuffer.isView(a))return E(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(te(a,ArrayBuffer)||a&&te(a.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(te(a,SharedArrayBuffer)||a&&te(a.buffer,SharedArrayBuffer)))return F(a,r,n);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=a.valueOf&&a.valueOf();if(u!=null&&u!==a)return o.from(u,r,n);let d=S(a);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return o.from(a[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}o.from=function(a,r,n){return f(a,r,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function w(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function T(a,r,n){return w(a),a<=0?c(a):r!==void 0?typeof n=="string"?c(a).fill(r,n):c(a).fill(r):c(a)}o.alloc=function(a,r,n){return T(a,r,n)};function b(a){return w(a),c(a<0?0:B(a)|0)}o.allocUnsafe=function(a){return b(a)},o.allocUnsafeSlow=function(a){return b(a)};function x(a,r){if((typeof r!="string"||r==="")&&(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let n=$(a,r)|0,u=c(n),d=u.write(a,r);return d!==n&&(u=u.slice(0,d)),u}function P(a){let r=a.length<0?0:B(a.length)|0,n=c(r);for(let u=0;u<r;u+=1)n[u]=a[u]&255;return n}function E(a){if(te(a,Uint8Array)){let r=new Uint8Array(a);return F(r.buffer,r.byteOffset,r.byteLength)}return P(a)}function F(a,r,n){if(r<0||a.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let u;return r===void 0&&n===void 0?u=new Uint8Array(a):n===void 0?u=new Uint8Array(a,r):u=new Uint8Array(a,r,n),Object.setPrototypeOf(u,o.prototype),u}function S(a){if(o.isBuffer(a)){let r=B(a.length)|0,n=c(r);return n.length===0||a.copy(n,0,0,r),n}if(a.length!==void 0)return typeof a.length!="number"||Tt(a.length)?c(0):P(a);if(a.type==="Buffer"&&Array.isArray(a.data))return P(a.data)}function B(a){if(a>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return a|0}function q(a){return+a!=a&&(a=0),o.alloc(+a)}o.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==o.prototype},o.compare=function(r,n){if(te(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),te(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),!o.isBuffer(r)||!o.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let u=r.length,d=n.length;for(let h=0,I=Math.min(u,d);h<I;++h)if(r[h]!==n[h]){u=r[h],d=n[h];break}return u<d?-1:d<u?1:0},o.isEncoding=function(r){switch(String(r).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}},o.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);let u;if(n===void 0)for(n=0,u=0;u<r.length;++u)n+=r[u].length;let d=o.allocUnsafe(n),h=0;for(u=0;u<r.length;++u){let I=r[u];if(te(I,Uint8Array))h+I.length>d.length?(o.isBuffer(I)||(I=o.from(I)),I.copy(d,h)):Uint8Array.prototype.set.call(d,I,h);else if(o.isBuffer(I))I.copy(d,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=I.length}return d};function $(a,r){if(o.isBuffer(a))return a.length;if(ArrayBuffer.isView(a)||te(a,ArrayBuffer))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);let n=a.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&n===0)return 0;let d=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return It(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Qt(a).length;default:if(d)return u?-1:It(a).length;r=(""+r).toLowerCase(),d=!0}}o.byteLength=$;function V(a,r,n){let u=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(a||(a="utf8");;)switch(a){case"hex":return Wn(this,r,n);case"utf8":case"utf-8":return Gt(this,r,n);case"ascii":return Dn(this,r,n);case"latin1":case"binary":return Vn(this,r,n);case"base64":return $n(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gn(this,r,n);default:if(u)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),u=!0}}o.prototype._isBuffer=!0;function Q(a,r,n){let u=a[r];a[r]=a[n],a[n]=u}o.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)Q(this,n,n+1);return this},o.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)Q(this,n,n+3),Q(this,n+1,n+2);return this},o.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)Q(this,n,n+7),Q(this,n+1,n+6),Q(this,n+2,n+5),Q(this,n+3,n+4);return this},o.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Gt(this,0,r):V.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="",n=ge.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},e&&(o.prototype[e]=o.prototype.inspect),o.prototype.compare=function(r,n,u,d,h){if(te(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),u===void 0&&(u=r?r.length:0),d===void 0&&(d=0),h===void 0&&(h=this.length),n<0||u>r.length||d<0||h>this.length)throw new RangeError("out of range index");if(d>=h&&n>=u)return 0;if(d>=h)return-1;if(n>=u)return 1;if(n>>>=0,u>>>=0,d>>>=0,h>>>=0,this===r)return 0;let I=h-d,U=u-n,O=Math.min(I,U),M=this.slice(d,h),D=r.slice(n,u);for(let _=0;_<O;++_)if(M[_]!==D[_]){I=M[_],U=D[_];break}return I<U?-1:U<I?1:0};function Y(a,r,n,u,d){if(a.length===0)return-1;if(typeof n=="string"?(u=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Tt(n)&&(n=d?0:a.length-1),n<0&&(n=a.length+n),n>=a.length){if(d)return-1;n=a.length-1}else if(n<0)if(d)n=0;else return-1;if(typeof r=="string"&&(r=o.from(r,u)),o.isBuffer(r))return r.length===0?-1:Wt(a,r,n,u,d);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(a,r,n):Uint8Array.prototype.lastIndexOf.call(a,r,n):Wt(a,[r],n,u,d);throw new TypeError("val must be string, number or Buffer")}function Wt(a,r,n,u,d){let h=1,I=a.length,U=r.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(a.length<2||r.length<2)return-1;h=2,I/=2,U/=2,n/=2}function O(D,_){return h===1?D[_]:D.readUInt16BE(_*h)}let M;if(d){let D=-1;for(M=n;M<I;M++)if(O(a,M)===O(r,D===-1?0:M-D)){if(D===-1&&(D=M),M-D+1===U)return D*h}else D!==-1&&(M-=M-D),D=-1}else for(n+U>I&&(n=I-U),M=n;M>=0;M--){let D=!0;for(let _=0;_<U;_++)if(O(a,M+_)!==O(r,_)){D=!1;break}if(D)return M}return-1}o.prototype.includes=function(r,n,u){return this.indexOf(r,n,u)!==-1},o.prototype.indexOf=function(r,n,u){return Y(this,r,n,u,!0)},o.prototype.lastIndexOf=function(r,n,u){return Y(this,r,n,u,!1)};function Cn(a,r,n,u){n=Number(n)||0;let d=a.length-n;u?(u=Number(u),u>d&&(u=d)):u=d;let h=r.length;u>h/2&&(u=h/2);let I;for(I=0;I<u;++I){let U=parseInt(r.substr(I*2,2),16);if(Tt(U))return I;a[n+I]=U}return I}function Un(a,r,n,u){return tt(It(r,a.length-n),a,n,u)}function Ln(a,r,n,u){return tt(zn(r),a,n,u)}function _n(a,r,n,u){return tt(Qt(r),a,n,u)}function Mn(a,r,n,u){return tt(Yn(r,a.length-n),a,n,u)}o.prototype.write=function(r,n,u,d){if(n===void 0)d="utf8",u=this.length,n=0;else if(u===void 0&&typeof n=="string")d=n,u=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(u)?(u=u>>>0,d===void 0&&(d="utf8")):(d=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-n;if((u===void 0||u>h)&&(u=h),r.length>0&&(u<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let I=!1;for(;;)switch(d){case"hex":return Cn(this,r,n,u);case"utf8":case"utf-8":return Un(this,r,n,u);case"ascii":case"latin1":case"binary":return Ln(this,r,n,u);case"base64":return _n(this,r,n,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mn(this,r,n,u);default:if(I)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),I=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $n(a,r,n){return r===0&&n===a.length?p.fromByteArray(a):p.fromByteArray(a.slice(r,n))}function Gt(a,r,n){n=Math.min(a.length,n);let u=[],d=r;for(;d<n;){let h=a[d],I=null,U=h>239?4:h>223?3:h>191?2:1;if(d+U<=n){let O,M,D,_;switch(U){case 1:h<128&&(I=h);break;case 2:O=a[d+1],(O&192)===128&&(_=(h&31)<<6|O&63,_>127&&(I=_));break;case 3:O=a[d+1],M=a[d+2],(O&192)===128&&(M&192)===128&&(_=(h&15)<<12|(O&63)<<6|M&63,_>2047&&(_<55296||_>57343)&&(I=_));break;case 4:O=a[d+1],M=a[d+2],D=a[d+3],(O&192)===128&&(M&192)===128&&(D&192)===128&&(_=(h&15)<<18|(O&63)<<12|(M&63)<<6|D&63,_>65535&&_<1114112&&(I=_))}}I===null?(I=65533,U=1):I>65535&&(I-=65536,u.push(I>>>10&1023|55296),I=56320|I&1023),u.push(I),d+=U}return On(u)}let qt=4096;function On(a){let r=a.length;if(r<=qt)return String.fromCharCode.apply(String,a);let n="",u=0;for(;u<r;)n+=String.fromCharCode.apply(String,a.slice(u,u+=qt));return n}function Dn(a,r,n){let u="";n=Math.min(a.length,n);for(let d=r;d<n;++d)u+=String.fromCharCode(a[d]&127);return u}function Vn(a,r,n){let u="";n=Math.min(a.length,n);for(let d=r;d<n;++d)u+=String.fromCharCode(a[d]);return u}function Wn(a,r,n){let u=a.length;(!r||r<0)&&(r=0),(!n||n<0||n>u)&&(n=u);let d="";for(let h=r;h<n;++h)d+=Kn[a[h]];return d}function Gn(a,r,n){let u=a.slice(r,n),d="";for(let h=0;h<u.length-1;h+=2)d+=String.fromCharCode(u[h]+u[h+1]*256);return d}o.prototype.slice=function(r,n){let u=this.length;r=~~r,n=n===void 0?u:~~n,r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),n<0?(n+=u,n<0&&(n=0)):n>u&&(n=u),n<r&&(n=r);let d=this.subarray(r,n);return Object.setPrototypeOf(d,o.prototype),d};function G(a,r,n){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+r>n)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(r,n,u){r=r>>>0,n=n>>>0,u||G(r,n,this.length);let d=this[r],h=1,I=0;for(;++I<n&&(h*=256);)d+=this[r+I]*h;return d},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,n,u){r=r>>>0,n=n>>>0,u||G(r,n,this.length);let d=this[r+--n],h=1;for(;n>0&&(h*=256);)d+=this[r+--n]*h;return d},o.prototype.readUint8=o.prototype.readUInt8=function(r,n){return r=r>>>0,n||G(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||G(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||G(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||G(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||G(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=de(function(r){r=r>>>0,Ce(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let d=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,h=this[++r]+this[++r]*2**8+this[++r]*2**16+u*2**24;return BigInt(d)+(BigInt(h)<<BigInt(32))}),o.prototype.readBigUInt64BE=de(function(r){r=r>>>0,Ce(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let d=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],h=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u;return(BigInt(d)<<BigInt(32))+BigInt(h)}),o.prototype.readIntLE=function(r,n,u){r=r>>>0,n=n>>>0,u||G(r,n,this.length);let d=this[r],h=1,I=0;for(;++I<n&&(h*=256);)d+=this[r+I]*h;return h*=128,d>=h&&(d-=Math.pow(2,8*n)),d},o.prototype.readIntBE=function(r,n,u){r=r>>>0,n=n>>>0,u||G(r,n,this.length);let d=n,h=1,I=this[r+--d];for(;d>0&&(h*=256);)I+=this[r+--d]*h;return h*=128,I>=h&&(I-=Math.pow(2,8*n)),I},o.prototype.readInt8=function(r,n){return r=r>>>0,n||G(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,n){r=r>>>0,n||G(r,2,this.length);let u=this[r]|this[r+1]<<8;return u&32768?u|4294901760:u},o.prototype.readInt16BE=function(r,n){r=r>>>0,n||G(r,2,this.length);let u=this[r+1]|this[r]<<8;return u&32768?u|4294901760:u},o.prototype.readInt32LE=function(r,n){return r=r>>>0,n||G(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},o.prototype.readInt32BE=function(r,n){return r=r>>>0,n||G(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=de(function(r){r=r>>>0,Ce(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let d=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(u<<24);return(BigInt(d)<<BigInt(32))+BigInt(n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),o.prototype.readBigInt64BE=de(function(r){r=r>>>0,Ce(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let d=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(d)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u)}),o.prototype.readFloatLE=function(r,n){return r=r>>>0,n||G(r,4,this.length),t.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,n){return r=r>>>0,n||G(r,4,this.length),t.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||G(r,8,this.length),t.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||G(r,8,this.length),t.read(this,r,!1,52,8)};function X(a,r,n,u,d,h){if(!o.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>d||r<h)throw new RangeError('"value" argument is out of bounds');if(n+u>a.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,n,u,d){if(r=+r,n=n>>>0,u=u>>>0,!d){let U=Math.pow(2,8*u)-1;X(this,r,n,u,U,0)}let h=1,I=0;for(this[n]=r&255;++I<u&&(h*=256);)this[n+I]=r/h&255;return n+u},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,n,u,d){if(r=+r,n=n>>>0,u=u>>>0,!d){let U=Math.pow(2,8*u)-1;X(this,r,n,u,U,0)}let h=u-1,I=1;for(this[n+h]=r&255;--h>=0&&(I*=256);)this[n+h]=r/I&255;return n+u},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,1,255,0),this[n]=r&255,n+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function jt(a,r,n,u,d){Xt(r,u,d,a,n,7);let h=Number(r&BigInt(4294967295));a[n++]=h,h=h>>8,a[n++]=h,h=h>>8,a[n++]=h,h=h>>8,a[n++]=h;let I=Number(r>>BigInt(32)&BigInt(4294967295));return a[n++]=I,I=I>>8,a[n++]=I,I=I>>8,a[n++]=I,I=I>>8,a[n++]=I,n}function Ht(a,r,n,u,d){Xt(r,u,d,a,n,7);let h=Number(r&BigInt(4294967295));a[n+7]=h,h=h>>8,a[n+6]=h,h=h>>8,a[n+5]=h,h=h>>8,a[n+4]=h;let I=Number(r>>BigInt(32)&BigInt(4294967295));return a[n+3]=I,I=I>>8,a[n+2]=I,I=I>>8,a[n+1]=I,I=I>>8,a[n]=I,n+8}o.prototype.writeBigUInt64LE=de(function(r,n=0){return jt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=de(function(r,n=0){return Ht(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,n,u,d){if(r=+r,n=n>>>0,!d){let O=Math.pow(2,8*u-1);X(this,r,n,u,O-1,-O)}let h=0,I=1,U=0;for(this[n]=r&255;++h<u&&(I*=256);)r<0&&U===0&&this[n+h-1]!==0&&(U=1),this[n+h]=(r/I>>0)-U&255;return n+u},o.prototype.writeIntBE=function(r,n,u,d){if(r=+r,n=n>>>0,!d){let O=Math.pow(2,8*u-1);X(this,r,n,u,O-1,-O)}let h=u-1,I=1,U=0;for(this[n+h]=r&255;--h>=0&&(I*=256);)r<0&&U===0&&this[n+h+1]!==0&&(U=1),this[n+h]=(r/I>>0)-U&255;return n+u},o.prototype.writeInt8=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},o.prototype.writeInt16LE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeInt16BE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeInt32LE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},o.prototype.writeInt32BE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},o.prototype.writeBigInt64LE=de(function(r,n=0){return jt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=de(function(r,n=0){return Ht(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function zt(a,r,n,u,d,h){if(n+u>a.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Yt(a,r,n,u,d){return r=+r,n=n>>>0,d||zt(a,r,n,4),t.write(a,r,n,u,23,4),n+4}o.prototype.writeFloatLE=function(r,n,u){return Yt(this,r,n,!0,u)},o.prototype.writeFloatBE=function(r,n,u){return Yt(this,r,n,!1,u)};function Kt(a,r,n,u,d){return r=+r,n=n>>>0,d||zt(a,r,n,8),t.write(a,r,n,u,52,8),n+8}o.prototype.writeDoubleLE=function(r,n,u){return Kt(this,r,n,!0,u)},o.prototype.writeDoubleBE=function(r,n,u){return Kt(this,r,n,!1,u)},o.prototype.copy=function(r,n,u,d){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(u||(u=0),!d&&d!==0&&(d=this.length),n>=r.length&&(n=r.length),n||(n=0),d>0&&d<u&&(d=u),d===u||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),r.length-n<d-u&&(d=r.length-n+u);let h=d-u;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,u,d):Uint8Array.prototype.set.call(r,this.subarray(u,d),n),h},o.prototype.fill=function(r,n,u,d){if(typeof r=="string"){if(typeof n=="string"?(d=n,n=0,u=this.length):typeof u=="string"&&(d=u,u=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!o.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(r.length===1){let I=r.charCodeAt(0);(d==="utf8"&&I<128||d==="latin1")&&(r=I)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<u)throw new RangeError("Out of range index");if(u<=n)return this;n=n>>>0,u=u===void 0?this.length:u>>>0,r||(r=0);let h;if(typeof r=="number")for(h=n;h<u;++h)this[h]=r;else{let I=o.isBuffer(r)?r:o.from(r,d),U=I.length;if(U===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(h=0;h<u-n;++h)this[h+n]=I[h%U]}return this};let Se={};function wt(a,r,n){Se[a]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}}}wt("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),wt("ERR_INVALID_ARG_TYPE",function(a,r){return`The "${a}" argument must be of type number. Received type ${typeof r}`},TypeError),wt("ERR_OUT_OF_RANGE",function(a,r,n){let u=`The value of "${a}" is out of range.`,d=n;return Number.isInteger(n)&&Math.abs(n)>2**32?d=Jt(String(n)):typeof n=="bigint"&&(d=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(d=Jt(d)),d+="n"),u+=` It must be ${r}. Received ${d}`,u},RangeError);function Jt(a){let r="",n=a.length,u=a[0]==="-"?1:0;for(;n>=u+4;n-=3)r=`_${a.slice(n-3,n)}${r}`;return`${a.slice(0,n)}${r}`}function qn(a,r,n){Ce(r,"offset"),(a[r]===void 0||a[r+n]===void 0)&&Me(r,a.length-(n+1))}function Xt(a,r,n,u,d,h){if(a>n||a<r){let I=typeof r=="bigint"?"n":"",U;throw r===0||r===BigInt(0)?U=`>= 0${I} and < 2${I} ** ${(h+1)*8}${I}`:U=`>= -(2${I} ** ${(h+1)*8-1}${I}) and < 2 ** ${(h+1)*8-1}${I}`,new Se.ERR_OUT_OF_RANGE("value",U,a)}qn(u,d,h)}function Ce(a,r){if(typeof a!="number")throw new Se.ERR_INVALID_ARG_TYPE(r,"number",a)}function Me(a,r,n){throw Math.floor(a)!==a?(Ce(a,n),new Se.ERR_OUT_OF_RANGE("offset","an integer",a)):r<0?new Se.ERR_BUFFER_OUT_OF_BOUNDS:new Se.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,a)}let jn=/[^+/0-9A-Za-z-_]/g;function Hn(a){if(a=a.split("=")[0],a=a.trim().replace(jn,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}function It(a,r){r=r||1/0;let n,u=a.length,d=null,h=[];for(let I=0;I<u;++I){if(n=a.charCodeAt(I),n>55295&&n<57344){if(!d){if(n>56319){(r-=3)>-1&&h.push(239,191,189);continue}else if(I+1===u){(r-=3)>-1&&h.push(239,191,189);continue}d=n;continue}if(n<56320){(r-=3)>-1&&h.push(239,191,189),d=n;continue}n=(d-55296<<10|n-56320)+65536}else d&&(r-=3)>-1&&h.push(239,191,189);if(d=null,n<128){if((r-=1)<0)break;h.push(n)}else if(n<2048){if((r-=2)<0)break;h.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;h.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;h.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return h}function zn(a){let r=[];for(let n=0;n<a.length;++n)r.push(a.charCodeAt(n)&255);return r}function Yn(a,r){let n,u,d,h=[];for(let I=0;I<a.length&&!((r-=2)<0);++I)n=a.charCodeAt(I),u=n>>8,d=n%256,h.push(d),h.push(u);return h}function Qt(a){return p.toByteArray(Hn(a))}function tt(a,r,n,u){let d;for(d=0;d<u&&!(d+n>=r.length||d>=a.length);++d)r[d+n]=a[d];return d}function te(a,r){return a instanceof r||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===r.name}function Tt(a){return a!==a}let Kn=(function(){let a="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){let u=n*16;for(let d=0;d<16;++d)r[u+d]=a[n]+a[d]}return r})();function de(a){return typeof BigInt>"u"?Jn:a}function Jn(){throw new Error("BigInt not supported")}return ge}var $e,gn,st,vn,ge,wn,Tn=oe(()=>{"use strict";y();v();g();$e={},gn=!1;st={},vn=!1;ge={},wn=!1});var ve,A,Es,Ns,xn=oe(()=>{"use strict";y();v();g();Tn();ve=In();ve.Buffer;ve.SlowBuffer;ve.INSPECT_MAX_BYTES;ve.kMaxLength;A=ve.Buffer,Es=ve.INSPECT_MAX_BYTES,Ns=ve.kMaxLength});var v=oe(()=>{"use strict";xn()});function St(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function ci(){!Le||!Ie||(Le=!1,Ie.length?ce=Ie.concat(ce):pt=-1,ce.length&&Nn())}function Nn(){if(!Le){var p=setTimeout(ci,0);Le=!0;for(var t=ce.length;t;){for(Ie=ce,ce=[];++pt<t;)Ie&&Ie[pt].run();pt=-1,t=ce.length}Ie=null,Le=!1,clearTimeout(p)}}function ui(p){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];ce.push(new An(p,t)),ce.length===1&&!Le&&setTimeout(Nn,0)}function An(p,t){this.fun=p,this.array=t}function z(){}function Ai(p){St("_linkedBinding")}function ki(p){St("dlopen")}function Bi(){return[]}function Si(){return[]}function Vi(p,t){if(!p)throw new Error(t||"assertion error")}function ji(){return!1}function co(){return he.now()/1e3}function Bt(p){var t=Math.floor((Date.now()-he.now())*.001),e=he.now()*.001,i=Math.floor(e)+t,s=Math.floor(e%1*1e9);return p&&(i=i-p[0],s=s-p[1],s<0&&(i--,s+=kt)),[i,s]}function me(){return Ut}function To(p){return[]}var ce,Le,Ie,pt,pi,li,di,fi,hi,mi,yi,gi,vi,wi,Ii,Ti,xi,bi,Ei,Ni,Ri,Fi,Pi,Ci,Ui,Ct,Li,_i,Mi,$i,Oi,Di,Wi,Gi,qi,Hi,zi,Yi,Ki,Ji,Xi,Qi,Zi,eo,to,ro,no,io,oo,so,ao,he,Pt,kt,uo,po,lo,fo,ho,mo,yo,go,vo,wo,Io,Ut,Lt=oe(()=>{"use strict";y();v();g();ce=[],Le=!1,pt=-1;An.prototype.run=function(){this.fun.apply(null,this.array)};pi="browser",li="x64",di="browser",fi={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},hi=["/usr/bin/node"],mi=[],yi="v16.8.0",gi={},vi=function(p,t){console.warn((t?t+": ":"")+p)},wi=function(p){St("binding")},Ii=function(p){return 0},Ti=function(){return"/"},xi=function(p){},bi={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};Ei=z,Ni=[];Ri={},Fi=!1,Pi={};Ci=z,Ui=z,Ct=function(){return{}},Li=Ct,_i=Ct,Mi=z,$i=z,Oi=z,Di={};Wi={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Gi=z,qi=z;Hi=z,zi=z,Yi=z,Ki=z,Ji=z,Xi=void 0,Qi=void 0,Zi=void 0,eo=z,to=2,ro=1,no="/bin/usr/node",io=9229,oo="node",so=[],ao=z,he={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};he.now===void 0&&(Pt=Date.now(),he.timing&&he.timing.navigationStart&&(Pt=he.timing.navigationStart),he.now=()=>Date.now()-Pt);kt=1e9;Bt.bigint=function(p){var t=Bt(p);return typeof BigInt>"u"?t[0]*kt+t[1]:BigInt(t[0]*kt)+BigInt(t[1])};uo=10,po={},lo=0;fo=me,ho=me,mo=me,yo=me,go=me,vo=z,wo=me,Io=me;Ut={version:yi,versions:gi,arch:li,platform:di,release:bi,_rawDebug:Ei,moduleLoadList:Ni,binding:wi,_linkedBinding:Ai,_events:po,_eventsCount:lo,_maxListeners:uo,on:me,addListener:fo,once:ho,off:mo,removeListener:yo,removeAllListeners:go,emit:vo,prependListener:wo,prependOnceListener:Io,listeners:To,domain:Ri,_exiting:Fi,config:Pi,dlopen:ki,uptime:co,_getActiveRequests:Bi,_getActiveHandles:Si,reallyExit:Ci,_kill:Ui,cpuUsage:Ct,resourceUsage:Li,memoryUsage:_i,kill:Mi,exit:$i,openStdin:Oi,allowedNodeEnvironmentFlags:Di,assert:Vi,features:Wi,_fatalExceptions:Gi,setUncaughtExceptionCaptureCallback:qi,hasUncaughtExceptionCaptureCallback:ji,emitWarning:vi,nextTick:ui,_tickCallback:Hi,_debugProcess:zi,_debugEnd:Yi,_startProfilerIdleNotifier:Ki,_stopProfilerIdleNotifier:Ji,stdout:Xi,stdin:Zi,stderr:Qi,abort:eo,umask:Ii,chdir:xi,cwd:Ti,env:fi,title:pi,argv:hi,execArgv:mi,pid:to,ppid:ro,execPath:no,debugPort:io,hrtime:Bt,argv0:oo,_preload_modules:so,setSourceMapsEnabled:ao}});function xo(){if(Rn)return _t;Rn=!0;var p=Ut;function t(c){if(typeof c!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(c))}function e(c,o){for(var f="",w=0,T=-1,b=0,x,P=0;P<=c.length;++P){if(P<c.length)x=c.charCodeAt(P);else{if(x===47)break;x=47}if(x===47){if(!(T===P-1||b===1))if(T!==P-1&&b===2){if(f.length<2||w!==2||f.charCodeAt(f.length-1)!==46||f.charCodeAt(f.length-2)!==46){if(f.length>2){var E=f.lastIndexOf("/");if(E!==f.length-1){E===-1?(f="",w=0):(f=f.slice(0,E),w=f.length-1-f.lastIndexOf("/")),T=P,b=0;continue}}else if(f.length===2||f.length===1){f="",w=0,T=P,b=0;continue}}o&&(f.length>0?f+="/..":f="..",w=2)}else f.length>0?f+="/"+c.slice(T+1,P):f=c.slice(T+1,P),w=P-T-1;T=P,b=0}else x===46&&b!==-1?++b:b=-1}return f}function i(c,o){var f=o.dir||o.root,w=o.base||(o.name||"")+(o.ext||"");return f?f===o.root?f+w:f+c+w:w}var s={resolve:function(){for(var o="",f=!1,w,T=arguments.length-1;T>=-1&&!f;T--){var b;T>=0?b=arguments[T]:(w===void 0&&(w=p.cwd()),b=w),t(b),b.length!==0&&(o=b+"/"+o,f=b.charCodeAt(0)===47)}return o=e(o,!f),f?o.length>0?"/"+o:"/":o.length>0?o:"."},normalize:function(o){if(t(o),o.length===0)return".";var f=o.charCodeAt(0)===47,w=o.charCodeAt(o.length-1)===47;return o=e(o,!f),o.length===0&&!f&&(o="."),o.length>0&&w&&(o+="/"),f?"/"+o:o},isAbsolute:function(o){return t(o),o.length>0&&o.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var o,f=0;f<arguments.length;++f){var w=arguments[f];t(w),w.length>0&&(o===void 0?o=w:o+="/"+w)}return o===void 0?".":s.normalize(o)},relative:function(o,f){if(t(o),t(f),o===f||(o=s.resolve(o),f=s.resolve(f),o===f))return"";for(var w=1;w<o.length&&o.charCodeAt(w)===47;++w);for(var T=o.length,b=T-w,x=1;x<f.length&&f.charCodeAt(x)===47;++x);for(var P=f.length,E=P-x,F=b<E?b:E,S=-1,B=0;B<=F;++B){if(B===F){if(E>F){if(f.charCodeAt(x+B)===47)return f.slice(x+B+1);if(B===0)return f.slice(x+B)}else b>F&&(o.charCodeAt(w+B)===47?S=B:B===0&&(S=0));break}var q=o.charCodeAt(w+B),$=f.charCodeAt(x+B);if(q!==$)break;q===47&&(S=B)}var V="";for(B=w+S+1;B<=T;++B)(B===T||o.charCodeAt(B)===47)&&(V.length===0?V+="..":V+="/..");return V.length>0?V+f.slice(x+S):(x+=S,f.charCodeAt(x)===47&&++x,f.slice(x))},_makeLong:function(o){return o},dirname:function(o){if(t(o),o.length===0)return".";for(var f=o.charCodeAt(0),w=f===47,T=-1,b=!0,x=o.length-1;x>=1;--x)if(f=o.charCodeAt(x),f===47){if(!b){T=x;break}}else b=!1;return T===-1?w?"/":".":w&&T===1?"//":o.slice(0,T)},basename:function(o,f){if(f!==void 0&&typeof f!="string")throw new TypeError('"ext" argument must be a string');t(o);var w=0,T=-1,b=!0,x;if(f!==void 0&&f.length>0&&f.length<=o.length){if(f.length===o.length&&f===o)return"";var P=f.length-1,E=-1;for(x=o.length-1;x>=0;--x){var F=o.charCodeAt(x);if(F===47){if(!b){w=x+1;break}}else E===-1&&(b=!1,E=x+1),P>=0&&(F===f.charCodeAt(P)?--P===-1&&(T=x):(P=-1,T=E))}return w===T?T=E:T===-1&&(T=o.length),o.slice(w,T)}else{for(x=o.length-1;x>=0;--x)if(o.charCodeAt(x)===47){if(!b){w=x+1;break}}else T===-1&&(b=!1,T=x+1);return T===-1?"":o.slice(w,T)}},extname:function(o){t(o);for(var f=-1,w=0,T=-1,b=!0,x=0,P=o.length-1;P>=0;--P){var E=o.charCodeAt(P);if(E===47){if(!b){w=P+1;break}continue}T===-1&&(b=!1,T=P+1),E===46?f===-1?f=P:x!==1&&(x=1):f!==-1&&(x=-1)}return f===-1||T===-1||x===0||x===1&&f===T-1&&f===w+1?"":o.slice(f,T)},format:function(o){if(o===null||typeof o!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof o);return i("/",o)},parse:function(o){t(o);var f={root:"",dir:"",base:"",ext:"",name:""};if(o.length===0)return f;var w=o.charCodeAt(0),T=w===47,b;T?(f.root="/",b=1):b=0;for(var x=-1,P=0,E=-1,F=!0,S=o.length-1,B=0;S>=b;--S){if(w=o.charCodeAt(S),w===47){if(!F){P=S+1;break}continue}E===-1&&(F=!1,E=S+1),w===46?x===-1?x=S:B!==1&&(B=1):x!==-1&&(B=-1)}return x===-1||E===-1||B===0||B===1&&x===E-1&&x===P+1?E!==-1&&(P===0&&T?f.base=f.name=o.slice(1,E):f.base=f.name=o.slice(P,E)):(P===0&&T?(f.name=o.slice(1,x),f.base=o.slice(1,E)):(f.name=o.slice(P,x),f.base=o.slice(P,E)),f.ext=o.slice(x,E)),P>0?f.dir=o.slice(0,P-1):T&&(f.dir="/"),f},sep:"/",delimiter:":",win32:null,posix:null};return s.posix=s,_t=s,_t}var _t,Rn,W,Fn=oe(()=>{"use strict";y();v();g();Lt();_t={},Rn=!1;W=xo()});var Tu,xu,bu,Eu,Nu,Au,Ru,Fu,Pu,ku,Bu,Su,Cu,Uu,Lu,Pn=oe(()=>{"use strict";y();v();g();Fn();Lt();Tu=W._makeLong,xu=W.basename,bu=W.delimiter,Eu=W.dirname,Nu=W.extname,Au=W.format,Ru=W.isAbsolute,Fu=W.join,Pu=W.normalize,ku=W.parse,Bu=W.posix,Su=W.relative,Cu=W.resolve,Uu=W.sep,Lu=W.win32});var ls={};xt(ls,{DynamicSnippetsGenerator:()=>vt});module.exports=ri(ls);y();v();g();y();v();g();y();v();g();y();v();g();function C(p){throw new Error("Unexpected value: "+JSON.stringify(p))}y();v();g();function Oe(p){return Object.keys(p)}y();v();g();y();v();g();y();v();g();var De=N.env.FERN_STACK_TRACK?.toLowerCase()??"",re=De!==""&&De!=="0"&&De!=="false",At=["single","multiline","box"].includes(De)?De:"single";re&&(Error.stackTraceLimit=50);var si=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),ai=new Set(["stacktrace"]);function ct({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:s=[],filterNode:c=!0,filterJs:o=!0,formatFilename:f=w=>w}={}){if(!re)return[];i=[...i,...si],e=[...e,...ai],s=[...s,"runInteractiveTask"];let w=!1;return(new Error().stack??"").split(`
|
|
2
|
+
`).map(T=>{let b=T.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(b&&b.length===5){let[,x,P,E,F]=b;if(!x||!P||!E||!F)return;if(w||s.some(S=>x?.includes(S))){w=!0;return}switch(x){case"Object.<anonymous>":x="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":x=`${x.substring(x.indexOf(".")+1)}()=> { ... }`;break}return{fn:x,path:f(P),position:`${E}:${F}`}}}).filter(T=>T&&!i.some(b=>T.fn.includes(b))&&!(c&&T.path?.startsWith("node:"))&&!(o&&T.path?.endsWith(".js"))&&!e.some(b=>T.path.includes(b))).slice(t,t+p)}var at=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:i=[],filterFunctions:s=[],stopOn:c=[],filterNode:o=!0,filterJs:f=!0,multiline:w=!1,formatFilename:T=b=>b}={}){m(this,"maxFrames");m(this,"skip");m(this,"filterPaths");m(this,"filterFunctions");m(this,"stopOn");m(this,"filterNode");m(this,"filterJs");m(this,"multiline");m(this,"formatFilename");m(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=i,this.filterFunctions=s,this.stopOn=c,this.filterNode=o,this.filterJs=f,this.multiline=w,this.formatFilename=T}tag(t){let e=this.tracking.get(t)||new Set;ct({maxFrames:this.maxFrames,skip:this.skip,filterPaths:this.filterPaths,filterFunctions:this.filterFunctions,stopOn:this.stopOn,filterNode:this.filterNode,filterJs:this.filterJs,formatFilename:this.formatFilename}).forEach(i=>e.add(i)),this.tracking.set(t,e)}trace(t){if(!re)return"";let e=this.tracking.get(t);return e?[...e].map(i=>`${this.multiline?`
|
|
3
|
+
`:""}${i.fn} - ${i.path}:${i.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},Rt;function bn({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:s=[],filterNode:c=!0,filterJs:o=!0,multiline:f=!1,formatFilename:w=T=>T}={}){re&&(Rt??(Rt=new at({maxFrames:p,skip:t,filterPaths:e,filterFunctions:i,stopOn:s,filterNode:c,filterJs:o,multiline:f,formatFilename:w})))}function En(p){Rt?.tag(p)}function Ft(p){return Rt?.frames(p)??[]}var we=class{constructor(){En(this)}};y();v();g();var ut=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}dispose(){}},Ve=class extends ut{async format(t){return t}formatSync(t){return t}};y();v();g();y();v();g();y();v();g();function Mt(p){return p.output.mode._visit({publish:t=>t.version,downloadFiles:()=>{},github:t=>t.version,_other:()=>{throw new Error("Unrecognized output mode.")}})}y();v();g();var Z=class extends we{constructor(e){super();m(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):typeof this.value=="function"?this.value(e):this.value.write(e)}};var bo=4;bn({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var We=class{constructor(){m(this,"lineBuffer",[]);m(this,"indentLevel",0);m(this,"hasWrittenAnything",!1);m(this,"lastCharacterIsSemicolon",!1);m(this,"lastCharacterIsNewline",!1);m(this,"nodeStackFrames",[])}get buffer(){return re&&this.nodeStackFrames.length>0&&this.writeInternal(`
|
|
4
4
|
`),this.lineBuffer.join(`
|
|
5
5
|
`)+(this.lastCharacterIsNewline?`
|
|
6
6
|
`:"")}write(...t){for(let e of t)if(e!=null)if(typeof e=="string"){let i=e.length>0&&e.endsWith(`
|
|
7
7
|
`),s=i?e.substring(0,e.length-1):e,c=this.getIndentString(),o=s.replaceAll(`
|
|
8
8
|
`,`
|
|
9
9
|
${c}`);this.isAtStartOfLine()&&(o=c+o),i&&(o+=`
|
|
10
|
-
`),this.writeInternal(o)}else this.writeNode(e)}writeStatement(...t){this.write(...t),this.write(";"),this.writeNewLineIfLastLineNot()}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){
|
|
10
|
+
`),this.writeInternal(o)}else this.writeNode(e)}writeStatement(...t){this.write(...t),this.write(";"),this.writeNewLineIfLastLineNot()}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){re&&this.nodeStackFrames.push(...Ft(t)),t.write(this),re&&At!=="single"&&this.writeInternal(`
|
|
11
11
|
`)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){this.writeNode(t),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new Z(t).write(this),t.endsWith(";")||this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new Z(t).write(this),this.write(" (",e,")"),this.pushScope()}controlFlowWithoutStatement(t){new Z(t).write(this),this.pushScope()}endControlFlow(){this.popScope()}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new Z(t).write(this),this.write(" (",e,")"),this.pushScope()}alternativeControlFlow(t){this.dedent(),this.write("} "),new Z(t).write(this),this.pushScope()}pushScope(){this.writeLine("{"),this.indent()}popScope(t=!0){this.dedent(),this.writeNewLineIfLastLineNot(),t?this.writeLine("}"):this.write("}")}writeLine(...t){this.write(...t.length===0?[""]:t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
12
12
|
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
13
13
|
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:i}){if(t.length>0){let s=t[0];s!=null&&i(s);for(let c=1;c<t.length;c++){this.write(e);let o=t[c];o!=null&&i(o)}}}toString(){return this.buffer}writeInternal(t){if(t.length===0)return;let e=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
14
14
|
`),this.lastCharacterIsSemicolon=t.endsWith(";");let i=t.split(`
|
|
15
|
-
`),s=ne&&!this.shouldSkipTracking(i)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${i.shift()||""}`),this.lastCharacterIsNewline&&i.pop(),this.lineBuffer.push(...i),s&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(i=>`${e?`(${e}) `:""} ${i.fn} - ${i.path} : ${i.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(ct({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,At){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return Eo}};y();v();g();y();v();g();y();v();g();var Ge=class{constructor(){m(this,"reporter");m(this,"snippet");m(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:t,snippet:e}){this.shouldUpdate({snippet:e,reporter:t.errors})&&(this.reporter=t.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:t}){if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw this.err??new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}shouldUpdate({snippet:t,reporter:e}){return this.reporter==null||this.reporter.size()>0&&e.size()===0?!0:t.length>(this.snippet?.length??0)}};var qe=class{constructor(t){m(this,"context");this.context=t}async generate(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let s=new Ge;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{let w=await f.generateSnippet({endpoint:c,request:t,options:e});if(o.errors.empty())return{snippet:w,errors:void 0};s.update({context:o,snippet:w})}catch(w){s.err==null&&(s.err=w)}}return s.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let s;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{return await f.generateSnippetAst({endpoint:c,request:t,options:e})}catch(w){s=w}}throw s??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let s=new Ge;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{let w=f.generateSnippetSync({endpoint:c,request:t,options:e});if(o.errors.empty())return{snippet:w,errors:void 0};s.update({context:o,snippet:w})}catch(w){s.err==null&&(s.err=w)}}return s.getResponseOrThrow({endpoint:t.endpoint})}resolveEndpoints({request:t,options:e}){if(e.endpointId!=null){let i=this.context.resolveEndpointById(e.endpointId);if(i==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[i]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}};y();v();g();y();v();g();y();v();g();var je=class{constructor(){m(this,"REFERENCE_REGEX",/^(?:(\w+)::)?(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[2]==null||i[3]==null))return{namespace:i[1],method:i[2],path:i[3]}}};y();v();g();var L={Critical:"CRITICAL",Warning:"WARNING"},He=class p{constructor(){m(this,"errors");m(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push({...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}truncate(t){this.errors.length=t}clone(){let t=new p;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 i of t){if(typeof i=="string"){e.push(i);continue}e[e.length-1]+=`[${i.index}]`}return e}};var ze=class{constructor({ir:t,config:e,options:i={}}){m(this,"config");m(this,"options");m(this,"errors");m(this,"_ir");m(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=i,this.errors=new He,this.httpEndpointReferenceParser=new je}associateQueryParametersByWireValue({parameters:t,values:e}){let i=[];for(let[s,c]of Object.entries(e))if(c!==void 0){this.errors.scope(s);try{let o=t.find(w=>w.name.wireValue===s);if(o==null)throw this.newParameterNotRecognizedError(s);let f=this.isListTypeReference(o.typeReference)&&!Array.isArray(c)?[c]:c;i.push({name:o.name,typeReference:o.typeReference,value:f})}finally{this.errors.unscope()}}return i}associateByWireValueOrDefault({parameters:t,values:e}){let i=[];for(let s of t){this.errors.scope(s.name.wireValue);try{let c=e[s.name.wireValue];if(c==null)if(s.typeReference.type==="primitive"&&s.typeReference.value==="STRING")c=`<${s.name.wireValue}>`;else{this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(s.name.wireValue).message});continue}i.push({name:s.name,typeReference:s.typeReference,value:c})}finally{this.errors.unscope()}}return i}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:i}){let s=[],c=new Set;for(let o of t){let f=o.name.wireValue,w=e[f];if(w!==void 0){c.add(f),this.errors.scope(f);try{s.push({name:o.name,typeReference:o.typeReference,value:w})}finally{this.errors.unscope()}}}if(!i){for(let[o,f]of Object.entries(e))if(!(f===void 0||c.has(o))){this.errors.scope(o);try{this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(o).message})}finally{this.errors.unscope()}}}return s}getExampleObjectProperties({parameters:t,snippetObject:e}){let i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},s=[];for(let c of t){let o=i[c.name.wireValue];o==null?c.typeReference.type==="nullable"&&s.push({name:c.name,typeReference:c.typeReference,value:null}):s.push({name:c.name,typeReference:c.typeReference,value:o})}return s}getSingleFileValue({property:t,record:e}){let i=e[t.wireValue];if(i!=null){if(typeof i!="string"){this.errors.add({severity:L.Critical,message:`Expected file value to be a string, got ${typeof i}`});return}return i}}getFileArrayValues({property:t,record:e}){let i=e[t.wireValue];if(i==null)return;if(!Array.isArray(i)){this.errors.add({severity:L.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}let s=[];for(let c of i){if(typeof c!="string"){this.errors.add({severity:L.Critical,message:`Expected file array value to be an array of strings, got ${typeof c}`});return}s.push(c)}return s}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:L.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t??{}}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:L.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let i=this.getRecord(e);if(i==null)return;let s=t.discriminant.wireValue,c=i[s];if(c==null){this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(s).message});return}if(typeof c!="string"){this.errors.add({severity:L.Critical,message:`Expected discriminant value to be a string but got: ${typeof c}`});return}let o=t.types[c];if(o==null){this.errors.add({severity:L.Critical,message:`No type found for discriminant value "${c}"`});return}let{[s]:f,...w}=i;return{singleDiscriminatedUnionType:o,discriminantValue:o.discriminantValue,value:w}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocation(t){let e=[];for(let i of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:i,parsedEndpoint:t})&&e.push(i);return e}resolveEndpointLocationOrThrow(t){let e=this.resolveEndpointLocation(t);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}resolveEndpointById(t){return this._ir.endpoints[t]}resolveEndpointByIdOrThrow(t){let e=this.resolveEndpointById(t);if(e==null)throw new Error(`Failed to find endpoint with ID "${t}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties: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:i}):!t.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){return e&&(t.metadata?.includePathParameters??!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:U(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let i=e.environments.find(s=>s.id===t);return i?.name}case"multipleBaseUrls":{let i=e.environments.find(s=>s.id===t);return i?.name}default:U(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:L.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:L.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let i=e.environments[0];if(i==null)return this.errors.add({severity:L.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let s=new Set(Oe(i.urls));for(let c of Oe(t))s.has(c)&&s.delete(c);return s.size>0?(this.errors.add({severity:L.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${Oe(i.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:L.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:L.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:L.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:U(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:U(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:U(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}};y();v();g();var re={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};y();v();g();y();v();g();function Ye(p,t){let e=p.split("/").pop()??p;return t?.stripExtension?e.split(".")[0]??e:e}y();v();g();y();v();g();y();v();g();y();v();g();var bo=/[^0-9a-zA-Z_]/g,No=["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],Te=class extends We{constructor({packageName:e,rootImportPath:i,importPath:s,customConfig:c,formatter:o}){super();m(this,"packageName");m(this,"rootImportPath");m(this,"importPath");m(this,"customConfig");m(this,"formatter");m(this,"imports",{});this.packageName=e,this.rootImportPath=i,this.importPath=s,this.customConfig=c,this.formatter=o??new Ve}addImport(e){let i=this.imports[e];if(i!=null)return i;if(e===this.rootImportPath&&this.customConfig.packageName!=null)return this.imports[e]=this.customConfig.packageName,this.customConfig.packageName;let s=new Set(Object.values(this.imports)),c=e.split("/");for(let f=1;f<=c.length;f++){let w=c.slice(-f),T=this.getValidAlias(w.join(""));if(!s.has(T))return this.imports[e]=T,T}let o=this.getValidAlias(Ye(e));for(;s.has(o);)o="_"+o;return this.imports[e]=o,o}isValidAlias(e){return!No.includes(e)}getValidAlias(e){let i=e.split("-");if(i[0]==null)return e;let s=i.map(c=>c.replace(bo,"")).join("");return this.isValidAlias(s)?s:"_"+s}};var Ke=class extends Te{constructor({packageName:t,rootImportPath:e,importPath:i,customConfig:s,formatter:c}){super({packageName:t,rootImportPath:e,importPath:i,customConfig:s,formatter:c})}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}
|
|
15
|
+
`),s=re&&!this.shouldSkipTracking(i)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${i.shift()||""}`),this.lastCharacterIsNewline&&i.pop(),this.lineBuffer.push(...i),s&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(i=>`${e?`(${e}) `:""} ${i.fn} - ${i.path} : ${i.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(ct({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,At){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return bo}};y();v();g();y();v();g();y();v();g();var Ge=class{constructor(){m(this,"reporter");m(this,"snippet");m(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:t,snippet:e}){this.shouldUpdate({snippet:e,reporter:t.errors})&&(this.reporter=t.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:t}){if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw this.err??new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}shouldUpdate({snippet:t,reporter:e}){return this.reporter==null||this.reporter.size()>0&&e.size()===0?!0:t.length>(this.snippet?.length??0)}};var qe=class{constructor(t){m(this,"context");this.context=t}async generate(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let s=new Ge;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{let w=await f.generateSnippet({endpoint:c,request:t,options:e});if(o.errors.empty())return{snippet:w,errors:void 0};s.update({context:o,snippet:w})}catch(w){s.err==null&&(s.err=w)}}return s.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let s;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{return await f.generateSnippetAst({endpoint:c,request:t,options:e})}catch(w){s=w}}throw s??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let s=new Ge;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{let w=f.generateSnippetSync({endpoint:c,request:t,options:e});if(o.errors.empty())return{snippet:w,errors:void 0};s.update({context:o,snippet:w})}catch(w){s.err==null&&(s.err=w)}}return s.getResponseOrThrow({endpoint:t.endpoint})}resolveEndpoints({request:t,options:e}){if(e.endpointId!=null){let i=this.context.resolveEndpointById(e.endpointId);if(i==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[i]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}};y();v();g();y();v();g();y();v();g();var je=class{constructor(){m(this,"REFERENCE_REGEX",/^(?:(\w+)::)?(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[2]==null||i[3]==null))return{namespace:i[1],method:i[2],path:i[3]}}};y();v();g();var L={Critical:"CRITICAL",Warning:"WARNING"},He=class p{constructor(){m(this,"errors");m(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push({...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}truncate(t){this.errors.length=t}clone(){let t=new p;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 i of t){if(typeof i=="string"){e.push(i);continue}e[e.length-1]+=`[${i.index}]`}return e}};var ze=class{constructor({ir:t,config:e,options:i={}}){m(this,"config");m(this,"options");m(this,"errors");m(this,"_ir");m(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=i,this.errors=new He,this.httpEndpointReferenceParser=new je}associateQueryParametersByWireValue({parameters:t,values:e}){let i=[];for(let[s,c]of Object.entries(e))if(c!==void 0){this.errors.scope(s);try{let o=t.find(w=>w.name.wireValue===s);if(o==null)throw this.newParameterNotRecognizedError(s);let f=this.isListTypeReference(o.typeReference)&&!Array.isArray(c)?[c]:c;i.push({name:o.name,typeReference:o.typeReference,value:f})}finally{this.errors.unscope()}}return i}associateByWireValueOrDefault({parameters:t,values:e}){let i=[];for(let s of t){this.errors.scope(s.name.wireValue);try{let c=e[s.name.wireValue];if(c==null)if(s.typeReference.type==="primitive"&&s.typeReference.value==="STRING")c=`<${s.name.wireValue}>`;else{this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(s.name.wireValue).message});continue}i.push({name:s.name,typeReference:s.typeReference,value:c})}finally{this.errors.unscope()}}return i}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:i}){let s=[],c=new Set;for(let o of t){let f=o.name.wireValue,w=e[f];if(w!==void 0){c.add(f),this.errors.scope(f);try{s.push({name:o.name,typeReference:o.typeReference,value:w})}finally{this.errors.unscope()}}}if(!i){for(let[o,f]of Object.entries(e))if(!(f===void 0||c.has(o))){this.errors.scope(o);try{this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(o).message})}finally{this.errors.unscope()}}}return s}getExampleObjectProperties({parameters:t,snippetObject:e}){let i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},s=[];for(let c of t){let o=i[c.name.wireValue];o==null?c.typeReference.type==="nullable"&&s.push({name:c.name,typeReference:c.typeReference,value:null}):s.push({name:c.name,typeReference:c.typeReference,value:o})}return s}getSingleFileValue({property:t,record:e}){let i=e[t.wireValue];if(i!=null){if(typeof i!="string"){this.errors.add({severity:L.Critical,message:`Expected file value to be a string, got ${typeof i}`});return}return i}}getFileArrayValues({property:t,record:e}){let i=e[t.wireValue];if(i==null)return;if(!Array.isArray(i)){this.errors.add({severity:L.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}let s=[];for(let c of i){if(typeof c!="string"){this.errors.add({severity:L.Critical,message:`Expected file array value to be an array of strings, got ${typeof c}`});return}s.push(c)}return s}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:L.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t??{}}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:L.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let i=this.getRecord(e);if(i==null)return;let s=t.discriminant.wireValue,c=i[s];if(c==null){this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(s).message});return}if(typeof c!="string"){this.errors.add({severity:L.Critical,message:`Expected discriminant value to be a string but got: ${typeof c}`});return}let o=t.types[c];if(o==null){this.errors.add({severity:L.Critical,message:`No type found for discriminant value "${c}"`});return}let{[s]:f,...w}=i;return{singleDiscriminatedUnionType:o,discriminantValue:o.discriminantValue,value:w}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocation(t){let e=[];for(let i of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:i,parsedEndpoint:t})&&e.push(i);return e}resolveEndpointLocationOrThrow(t){let e=this.resolveEndpointLocation(t);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}resolveEndpointById(t){return this._ir.endpoints[t]}resolveEndpointByIdOrThrow(t){let e=this.resolveEndpointById(t);if(e==null)throw new Error(`Failed to find endpoint with ID "${t}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties: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:i}):!t.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){return e&&(t.metadata?.includePathParameters??!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:C(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let i=e.environments.find(s=>s.id===t);return i?.name}case"multipleBaseUrls":{let i=e.environments.find(s=>s.id===t);return i?.name}default:C(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:L.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:L.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let i=e.environments[0];if(i==null)return this.errors.add({severity:L.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let s=new Set(Oe(i.urls));for(let c of Oe(t))s.has(c)&&s.delete(c);return s.size>0?(this.errors.add({severity:L.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${Oe(i.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:L.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:L.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:L.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:C(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:C(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:C(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}};y();v();g();var ne={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};y();v();g();y();v();g();function Ye(p,t){let e=p.split("/").pop()??p;return t?.stripExtension?e.split(".")[0]??e:e}y();v();g();y();v();g();y();v();g();y();v();g();var Eo=/[^0-9a-zA-Z_]/g,No=["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],Te=class extends We{constructor({packageName:e,rootImportPath:i,importPath:s,customConfig:c,formatter:o}){super();m(this,"packageName");m(this,"rootImportPath");m(this,"importPath");m(this,"customConfig");m(this,"formatter");m(this,"imports",{});this.packageName=e,this.rootImportPath=i,this.importPath=s,this.customConfig=c,this.formatter=o??new Ve}addImport(e){let i=this.imports[e];if(i!=null)return i;if(e===this.rootImportPath&&this.customConfig.packageName!=null)return this.imports[e]=this.customConfig.packageName,this.customConfig.packageName;let s=new Set(Object.values(this.imports)),c=e.split("/");for(let f=1;f<=c.length;f++){let w=c.slice(-f),T=this.getValidAlias(w.join(""));if(!s.has(T))return this.imports[e]=T,T}let o=this.getValidAlias(Ye(e));for(;s.has(o);)o="_"+o;return this.imports[e]=o,o}isValidAlias(e){return!No.includes(e)}getValidAlias(e){let i=e.split("-");if(i[0]==null)return e;let s=i.map(c=>c.replace(Eo,"")).join("");return this.isValidAlias(s)?s:"_"+s}};var Ke=class extends Te{constructor({packageName:t,rootImportPath:e,importPath:i,customConfig:s,formatter:c}){super({packageName:t,rootImportPath:e,importPath:i,customConfig:s,formatter:c})}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}
|
|
16
16
|
${t}`)}return t}toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
|
|
17
17
|
${t}`)}return t}getContent(){let t=`package ${this.packageName}
|
|
18
18
|
|
|
@@ -24,10 +24,10 @@ ${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.impor
|
|
|
24
24
|
${o.join(`
|
|
25
25
|
|
|
26
26
|
`)}
|
|
27
|
-
)`}};var l={};xt(l,{Alias:()=>xe,AstNode:()=>k,CodeBlock:()=>ie,Enum:()=>
|
|
28
|
-
`).forEach(i=>{e.writeLine(`// ${i}`)})}};var xe=class extends k{constructor({name:e,type:i,docs:s}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=s}write(e){e.writeNode(new j({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};y();v();g();var ie=class extends k{constructor(e){super();m(this,"arg");this.arg=e}write(e){return new Z(this.arg).write(e)}};y();v();g();y();v();g();var ue=class extends k{constructor(e){super();m(this,"name");this.name=e}write(e){e.write(this.name)}};y();v();g();y();v();g();y();v();g();function _e({writer:p,arguments_:t,multiline:e=!0}){let i=t.map(s=>s instanceof K&&K.isNop(s)?K.nil():s);if(i.length===0){p.write("()");return}if(e){Ao({writer:p,arguments_:i});return}Ro({writer:p,arguments_:i})}function Ao({writer:p,arguments_:t}){p.writeLine("("),p.indent();for(let e of t)e.write(p),p.writeLine(",");p.dedent(),p.write(")")}function Ro({writer:p,arguments_:t}){p.write("("),t.forEach((e,i)=>{i>0&&p.write(", "),e.write(p)}),p.write(")")}var ee=class extends k{constructor({func:e,arguments_:i,multiline:s=!0}){super();m(this,"func");m(this,"arguments_");m(this,"multiline");this.func=e,this.arguments_=i,this.multiline=s}write(e){e.writeNode(this.func),_e({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};y();v();g();y();v();g();function
|
|
29
|
-
`)?`\`${this.internalType.value}\``:`"${Je(this.internalType.value)}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(
|
|
30
|
-
`)?`\`${i}\``:`"${Je(i)}"`);return;case"number":e.write(i.toString());return;case"object":if(i==null){e.write("nil");return}if(Array.isArray(i)){this.writeAnyArray({writer:e,value:i});return}this.writeAnyObject({writer:e,value:i});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof i}`)}}writeAnyArray({writer:e,value:i}){if(e.write("[]any"),i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let s of i)e.writeNode(p.any(s)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:i}){e.write("map[string]any");let s=Object.entries(i).sort(([c],[o])=>c<o?-1:c>o?1:0);if(s.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[c,o]of s)e.write(`"${Je(c)}": `),e.writeNode(p.any(o)),e.writeLine(",");e.dedent(),e.write("}")}writeMap({writer:e,map:i}){e.write("map["),e.writeNode(i.keyType),e.write("]"),e.writeNode(i.valueType);let s=Co({entries:i.entries});if(s.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of s)c.key.write(e),e.write(": "),c.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:i}){if(Fo.has(i.internalType.type)){e.writeNode(Po({writer:e,type:i}));return}if(Sr.has(i.internalType.type)){i.write(e);return}if(i.internalType.type==="enum"){e.writeNode(new pe({on:i.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),i.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||Sr.has(e.internalType.type)}writeSlice({writer:e,slice:i}){e.write("[]"),e.writeNode(i.valueType);let s=Lo({values:i.values});if(s.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of s)c.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeStruct({writer:e,struct:i}){e.writeNode(i.typeReference),i.generics!=null&&(e.write("["),i.generics.forEach((c,o)=>{o>0&&e.write(", "),e.writeNode(c)}),e.write("]"));let s=Uo({fields:i.fields});if(s.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of s)e.write(`${c.name}: `),c.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Po({writer:p,type:t}){return new ee({func:new J({name:ko({type:t}),importPath:p.rootImportPath}),arguments_:[t]})}function ko({type:p}){switch(p.internalType.type){case"bool":return"Bool";case"bytes":return"Bytes";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 So({writer:p,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new ee({func:new J({name:e,importPath:p.rootImportPath}),arguments_:[new ie(`"${t.value}"`)]})}function Bo({value:p}){return new ee({func:new J({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new ie(`"${p}"`)]})}function Je(p){return p.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Co({entries:p}){return p.filter(t=>!K.isNop(t.key)&&!K.isNop(t.value))}function Uo({fields:p}){return p.filter(t=>!K.isNop(t.value))}function Lo({values:p}){return p.filter(t=>!K.isNop(t))}var Ee=class p extends k{constructor({name:e,docs:i}){super();m(this,"name");m(this,"docs");m(this,"members",[]);m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=i}addConstructor(e){this.constructor_=e}addMember(e){this.members.push(e)}addMethod(e){this.methods.push(e)}write(e){this.writeType({writer:e}),this.writeMembers({writer:e}),this.writeConstructor({writer:e}),this.writeMethods({writer:e})}writeType({writer:e}){e.writeNode(new j({docs:this.docs})),e.writeLine(`type ${this.name} string`)}writeMembers({writer:e}){if(this.members.length!==0){e.newLine(),e.writeLine("const ("),e.indent();for(let i of this.members)e.writeNode(new j({docs:i.docs})),e.writeNode(p.getMemberIdentifier({name:this.name,member:i})),e.write(" = "),e.writeNode(K.string(i.value)),e.newLine();e.dedent(),e.write(")")}}writeConstructor({writer:e}){this.constructor_!=null&&(e.newLine(),e.writeNode(this.constructor_))}writeMethods({writer:e}){e.newLine();for(let i of this.methods)e.newLine(),e.writeNode(i),e.newLine()}static getMemberIdentifier({name:e,member:i}){return new ue(`${e}${i.name}`)}};y();v();g();var be=class extends k{constructor({name:e,type:i,docs:s,tags:c}){super();m(this,"name");m(this,"type");m(this,"docs");m(this,"tags",[]);this.name=e,this.type=i,this.docs=s,this.tags=c??[]}addTags(...e){this.tags.push(...e)}write(e){e.writeNode(new j({docs:this.docs})),e.write(`${this.name} `),this.type.write(e),this.writeTags({writer:e})}writeTags({writer:e}){this.tags.length!==0&&(e.write(" `"),this.tags.forEach((i,s)=>{s>0&&e.write(" "),e.write(`${i.name}:"${i.value}"`)}),e.write("`"))}};y();v();g();var Ne=class extends k{constructor({nodes:e}={nodes:[]}){super();m(this,"nodes");this.nodes=e??[]}add(...e){this.nodes.push(...e)}write(e){for(let i of this.nodes)i.write(e)}};y();v();g();y();v();g();var le=class extends k{constructor({name:e,parameters:i,return_:s,body:c,docs:o,typeReference:f,multiline:w,receiver:T,pointerReceiver:E}){super();m(this,"parameters");m(this,"return_");m(this,"name");m(this,"body");m(this,"docs");m(this,"typeReference");m(this,"multiline");m(this,"receiver");m(this,"pointerReceiver");this.name=e,this.parameters=i,this.return_=s,this.body=c,this.docs=o,this.typeReference=f,this.multiline=w,this.receiver=T,this.pointerReceiver=E}write(e){e.writeNode(new j({docs:this.docs})),e.write("func"),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference,receiver:this.receiver}),this.name!=null&&e.write(` ${this.name}`),_e({writer:e,arguments_:this.parameters,multiline:this.multiline}),this.return_!=null&&(e.write(" "),this.return_.length>1&&e.write("("),this.return_.forEach((i,s)=>{s>0&&e.write(", "),e.writeNode(i)}),this.return_.length>1&&e.write(")")),e.writeLine("{"),e.indent(),this.body?.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.write("}")}writeReceiver({writer:e,typeReference:i,receiver:s}){e.write(` (${this.getReceiverName({typeReference:i,receiver:s})} `),this.pointerReceiver&&e.write("*"),i.write(e),e.write(")")}getReceiverName({typeReference:e,receiver:i}){return i??e.name.charAt(0).toLowerCase()}};var Ae=class extends k{constructor({name:e,parameters:i,return_:s,body:c,docs:o,multiline:f}){super();m(this,"func");this.func=new le({name:e,parameters:i,return_:s,body:c,docs:o,multiline:f})}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get name(){return this.func.name}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};y();v();g();var Xe=class extends k{constructor({nodes:e}){super();m(this,"nodes");this.nodes=e}write(e){for(let i of this.nodes)e.newLine(),i.write(e),e.newLine()}};y();v();g();var Re=class extends k{constructor({name:e,type:i,docs:s}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=s}write(e){e.writeNode(new j({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};y();v();g();var Fe=class extends k{constructor({node:e}){super();m(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};y();v();g();var Pe=class extends k{constructor({on:e,selector:i}){super();m(this,"on");m(this,"selector");this.on=e,this.selector=i}write(e){e.writeNode(this.on),e.write("."),e.writeNode(this.selector)}};y();v();g();var ke=class extends k{constructor({name:e,embeds:i,fields:s,docs:c}){super();m(this,"name");m(this,"embeds",[]);m(this,"fields",[]);m(this,"docs");m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=c,this.embeds=i??[],this.fields=s??[]}addConstructor(e){this.constructor_=e}addField(...e){this.fields.push(...e)}addMethod(...e){this.methods.push(...e)}write(e){this.writeType({writer:e}),this.constructor_!=null&&(e.newLine(),e.newLine(),this.writeConstructor({writer:e,constructor:this.constructor_})),this.writeMethods({writer:e})}writeType({writer:e}){if(e.writeNode(new j({docs:this.docs})),this.name!=null?e.write(`type ${this.name} struct {`):e.write("struct{"),this.embeds.length===0&&this.fields.length===0){e.writeLine("}");return}e.newLine(),e.indent();for(let c of this.embeds)e.writeNode(c),e.newLine();let i=this.fields.filter(c=>this.isExported(c));for(let c of i)e.writeNode(c),e.newLine();let s=this.fields.filter(c=>!this.isExported(c));i.length>0&&s.length>0&&e.newLine();for(let c of s)e.writeNode(c),e.newLine();e.dedent(),e.write("}")}writeConstructor({writer:e,constructor:i}){i.name!=null?e.write(`func ${i.name}(`):e.write(`func New${this.name}(`),i.parameters.forEach((s,c)=>{c>0&&e.write(", "),e.writeNode(s)}),e.write(`) *${this.name} {`),e.newLine(),e.indent(),e.writeNode(i.body),e.writeNewLineIfLastLineNot(),e.dedent(),e.writeLine("}")}writeMethods({writer:e}){if(this.methods.length!==0){e.writeNewLineIfLastLineNot();for(let i of this.methods)e.newLine(),e.writeNode(i),e.newLine()}}isExported(e){let i=e.name.charAt(0);return i===i.toUpperCase()}};y();v();g();var Qe=class extends k{constructor({on:e,cases:i,default:s}){super();m(this,"on");m(this,"cases");m(this,"default");this.on=e,this.cases=i,this.default=s}write(e){let i=this.cases;this.default!=null&&i.push({on:new ue("default"),body:this.default}),e.write("switch "),e.writeNode(this.on),e.writeLine("{"),e.indent();for(let s of i)e.write("case "),e.writeNode(s.on),e.writeLine(":"),e.indent(),e.writeNode(s.body),e.dedent(),e.writeNewLineIfLastLineNot();e.dedent(),e.write("}")}};y();v();g();var _o=new Set(["any","bytes","map","slice"]),Ze=class p extends k{constructor(e){super();m(this,"internalType");this.internalType=e}write(e,{comment:i}={}){switch(this.internalType.type){case"any":e.write("any");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(lt);break;case"error":e.write("error");break;case"float64":e.write("float64");break;case"int":e.write("int");break;case"int64":e.write("int64");break;case"map":{e.write("map["),this.internalType.keyType.write(e),e.write("]"),this.internalType.valueType.write(e);break}case"optional":{e.write("*"),this.internalType.value.write(e);break}case"reference":e.writeNode(this.internalType.value);break;case"slice":e.write("[]"),this.internalType.value.write(e);break;case"string":e.write("string");break;case"uuid":e.writeNode(dt);break;case"variadic":e.write("..."),this.internalType.value.write(e);break;default:U(this.internalType)}}isOptional(){return this.internalType.type==="optional"}isIterable(){return this.internalType.type==="slice"||this.internalType.type==="variadic"}iterableElement(){if(this.internalType.type==="slice"||this.internalType.type==="variadic")return this.internalType.value}underlying(){return this.internalType.type==="optional"?this.internalType.value:this}static any(){return new this({type:"any"})}static bool(){return new this({type:"bool"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static dereference(e){return e.internalType.type==="optional"?e.internalType.value:e}static error(){return new this({type:"error"})}static float64(){return new this({type:"float64"})}static int(){return new this({type:"int"})}static int64(){return new this({type:"int64"})}static map(e,i){return new this({type:"map",keyType:e,valueType:i})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static pointer(e){return p.optional(e)}static reference(e){return new this({type:"reference",value:e})}static slice(e){return new this({type:"slice",value:e})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static variadic(e){return this.isAlreadyVariadic(e)?e:new this({type:"variadic",value:e})}static isAlreadyOptional(e){return e.internalType.type==="optional"||_o.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},lt=new J({importPath:"time",name:"Time"}),dt=new J({importPath:"github.com/google/uuid",name:"UUID"}),$t=new J({importPath:"io",name:"Reader"});y();v();g();var Se=class extends k{constructor({name:e,type:i,docs:s}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=s}write(e){e.writeNode(new j({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function Mo(p){return new xe(p)}function $o(p){return new ie(p)}function Oo(p){return new Ee(p)}function Do(p){return new be(p)}function Vo(p={}){return new Ne(p)}function Wo(p){return new Ae(p)}function Go(p){return new ue(p)}function qo(p){return new ee(p)}function jo(p){return new pe(p)}function Ho(p){return new le(p)}function zo(p){return new Re(p)}function Yo(p){return new Fe(p)}function Ko(p){return new Pe(p)}function Jo(p={}){return new ke(p)}function Xo(p){return new Qe(p)}function Qo(p){return new Se(p)}function Zo(p){return new J(p)}y();v();g();var es=new Set(["string"]);function Ot(p){if(p==="")return"Underscore";let t=p;for(;t.startsWith("_");)t=t.slice(1);if(t==="")return"Underscore";if(t.length>0&&/^\d/.test(t))return"Field"+t;let e=t,i=t[0];return t.length>0&&i!=null&&i!==i.toUpperCase()&&(e=i.toUpperCase()+t.slice(1)),es.has(e.toLowerCase())?"Field"+e:e}y();v();g();Pr();var ts="sdk";function Dt({config:p,customConfig:t}){let e=rs({config:p}),i=ns({config:p,customConfig:t,isModulePath:!0}),s=e!=null?os({importPath:i,majorVersion:e}):i,c=t?.packagePath??"";return c?W.join(s,c):s}function ns({config:p,customConfig:t,isModulePath:e=!1}){let i=t?.importPath??t?.module?.path??(p.output.mode.type==="github"?ss(p.output.mode.repoUrl,"https://"):ts);return e?i:W.join(i,t?.packagePath??"")}function rs({config:p}){let t=is({config:p});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function is({config:p}){let t=as(p);if(t==null||t==="")return;let e=t.split(".");if(e[0]==null||e[0]===""||e[0]==="v")return;let i=e[0];return i.startsWith("v")?i:`v${i}`}function os({importPath:p,majorVersion:t}){return Ye(p)===t?p:`${p}/${t}`}function ss(p,t){return p.startsWith(t)?p.slice(t.length):p}function as(p){let t=p?.output?.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}y();v();g();var ft=class{constructor({context:t}){m(this,"context");this.context=t}convert(t){if(t.value===null&&!this.context.isNullable(t.typeReference)&&this.context.errors.add({severity:L.Critical,message:"Expected non-null value, but got null"}),t.value==null)return l.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return l.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?l.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"nullable":{let e=t.typeReference.value;if(e.type==="named"){let i=this.context.resolveNamedType({typeId:e.value});if(i?.type==="alias"&&["list","set","map"].includes(i.typeReference.type)){let s=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),c=this.context.getTypeName(i.declaration.name),o=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:s,aliasName:c,aliasImportPath:o})}if(i?.type==="alias"&&i.typeReference.type==="literal")return this.convertLiteralToOptionalPrimitive(i.typeReference.value)}return e.type==="literal"?this.convertLiteralToOptionalPrimitive(e.value):l.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"optional":{let e=t.typeReference.value;if(e.type==="named"){let i=this.context.resolveNamedType({typeId:e.value});if(i?.type==="alias"&&["list","set","map"].includes(i.typeReference.type)){let s=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),c=this.context.getTypeName(i.declaration.name),o=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:s,aliasName:c,aliasImportPath:o})}if(i?.type==="alias"&&i.typeReference.type==="literal")return this.convertLiteralToOptionalPrimitive(i.typeReference.value)}return e.type==="literal"?this.convertLiteralToOptionalPrimitive(e.value):l.TypeInstantiation.optional(this.convert({typeReference:e,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:U(t.typeReference)}}convertToPointerIfPossible(t){let e=this.convert(t);return t.typeReference.type==="named"&&this.context.resolveNamedType({typeId:t.typeReference.value})?.type==="enum"?l.TypeInstantiation.reference(l.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e}convertList({list:t,value:e}){return Array.isArray(e)?l.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:t}),values:e.map((i,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:t,value:i})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:L.Critical,message:`Expected array but got: ${typeof e}`}),l.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:L.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),l.TypeInstantiation.nop()):l.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries:Object.entries(e).sort(([i],[s])=>i<s?-1:i>s?1:0).map(([i,s])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:t.key,value:i,as:"key"}),value:this.convert({typeReference:t.value,value:s})}}finally{this.context.errors.unscope()}})})}convertNamed({named:t,value:e,as:i}){switch(t.type){case"alias":return this.convertAlias({aliasType:t,value:e,as:i});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:U(t)}}convertAlias({aliasType:t,value:e,as:i}){return t.typeReference.type==="literal"?l.TypeInstantiation.reference(l.invokeFunc({func:l.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(t.typeReference.value)]})):this.convert({typeReference:t.typeReference,value:e,as:i})}reconstructAliasCollectionLiteral({collectionLiteral:t,aliasName:e,aliasImportPath:i}){let s=t.internalType;return s.type==="slice"?l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(l.typeReference({name:e,importPath:i}));let o=s.values;if(o.length===0){c.write("{}");return}c.writeLine("{"),c.indent();for(let f of o)c.writeNode(f),c.writeLine(",");c.dedent(),c.write("}")})):s.type==="map"?l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(l.typeReference({name:e,importPath:i}));let o=s.entries;if(o.length===0){c.write("{}");return}c.writeLine("{"),c.indent();for(let f of o)c.writeNode(f.key),c.write(": "),c.writeNode(f.value),c.writeLine(",");c.dedent(),c.write("}")})):l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(t)}))}convertLiteral(t){return this.convertLiteralValue(t)}convertLiteralValue(t){switch(t.type){case"boolean":return l.TypeInstantiation.bool(t.value);case"string":return l.TypeInstantiation.string(t.value);default:U(t)}}convertLiteralToOptionalPrimitive(t){switch(t.type){case"boolean":return l.TypeInstantiation.optional(l.TypeInstantiation.bool(t.value));case"string":return l.TypeInstantiation.optional(l.TypeInstantiation.string(t.value));default:U(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let i=this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),s=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(s==null)return l.TypeInstantiation.nop();let c=s.singleDiscriminatedUnionType,o=this.getBaseFields({discriminatedUnionTypeInstance:s,singleDiscriminatedUnionType:c,excludeWireValues:this.getDedupedBasePropertyWireValues(t)});switch(c.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:c.typeId});return f==null?l.TypeInstantiation.nop():l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(c.discriminantValue.name),value:this.convertNamed({named:f,value:s.value})},...o]})}case"singleProperty":{let f=this.context.getRecord(s.value);if(f==null)return l.TypeInstantiation.nop();try{return this.context.errors.scope(c.discriminantValue.wireValue),l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(c.discriminantValue.name),value:this.convert({typeReference:c.typeReference,value:f[c.discriminantValue.wireValue]})},...o]})}finally{this.context.errors.unscope()}}case"noProperties":return l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(s.discriminantValue.name),value:l.TypeInstantiation.string(c.discriminantValue.wireValue)},...o]});default:U(c)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e,excludeWireValues:i}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).filter(c=>!(i?.has(c.name.wireValue)??!1)).map(c=>{this.context.errors.scope(c.name.wireValue);try{return{name:this.context.getFieldName(c.name.name),value:this.convert(c)}}finally{this.context.errors.unscope()}})}getDedupedBasePropertyWireValues(t){if(!this.context.customConfig?.dedupeUnionBaseProperties)return new Set;let e=Object.values(t.types);if(e.length===0||!e.every(o=>o.type==="samePropertiesAsObject"))return new Set;let i=e[0]?.properties??[];if(i.length===0)return new Set;let s=new Set((t.inheritedBaseProperties??[]).map(o=>o.wireValue)),c=this.context.errors.size();try{let o=e.map(T=>this.getObjectExportedProperties(T.typeId)),f=T=>o.every(E=>{let x=E.get(T);return x!=null&&x.typeReference.type!=="literal"}),w=new Set;for(let T of i){if(T.typeReference.type==="literal")continue;let E=this.context.getFieldName(T.name.name);if(s.has(T.name.wireValue)){f(E)&&w.add(T.name.wireValue);continue}let x=this.getGoGetterTypeString(T.typeReference);o.every(b=>{let F=b.get(E);return F!=null&&F.typeReference.type!=="literal"&&this.getGoGetterTypeString(F.typeReference)===x})&&w.add(T.name.wireValue)}return w}finally{this.context.errors.truncate(c)}}getObjectExportedProperties(t){let e=new Map,i=new Set,s=c=>{if(i.has(c))return;i.add(c);let o=this.context.resolveNamedType({typeId:c});if(o?.type==="object"){for(let f of o.extends??[])s(f);for(let f of o.properties)e.set(this.context.getFieldName(f.name.name),f)}};return s(t),e}getGoGetterTypeString(t){let e=t;if(this.context.customConfig?.gettersPassByValue)for(;e.type==="optional"||e.type==="nullable";)e=e.value;return this.context.dynamicTypeMapper.convert({typeReference:e}).toString({packageName:"example",importPath:"fern",rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{}})}convertObject({object_:t,value:e}){let i=this.context.associateByWireValue({parameters:t.properties,values:this.context.getRecord(e)??{}});return l.TypeInstantiation.structPointer({typeReference:l.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:i.map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getFieldName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:t,value:e}){let i=this.getEnumValueName({enum_:t,value:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.enum(l.typeReference({name:i,importPath:this.context.getImportPath(t.declaration.fernFilepath)}))}getEnumValueName({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:L.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let i=t.values.find(s=>s.wireValue===e);if(i==null){this.context.errors.add({severity:L.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return`${this.context.getTypeName(t.declaration.name)}${this.context.getTypeName(i.name)}`}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});if(i==null)return l.TypeInstantiation.nop();let s=this.getUndiscriminatedUnionFieldName({typeReference:i.valueTypeReference});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),fields:[{name:s,value:i.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let i of t.types){let s=this.context.errors.size();try{let c=this.convert({typeReference:i,value:e});if(l.TypeInstantiation.isNop(c)||this.context.errors.size()>s){this.context.errors.truncate(s);continue}return{valueTypeReference:i,typeInstantiation:c}}catch{this.context.errors.truncate(s);continue}}this.context.errors.add({severity:L.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:U(t)}}getUndiscriminatedUnionFieldNameForList({list:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(e!=null)return`${e}List`}getUndiscriminatedUnionFieldNameForMap({map:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.key});if(e==null)return;let i=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(i!=null)return`${e}${i}Map`}getUndiscriminatedUnionFieldNameForOptional({typeReference:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});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:U(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":case"DATE_TIME_RFC_2822":return"DateTime";case"BASE_64":return"Base64";default:U(t)}}convertUnknown({value:t}){return l.TypeInstantiation.any(t)}convertPrimitive({primitive:t,value:e,as:i}){switch(t){case"INTEGER":case"UINT":{let s=this.getValueAsNumber({value:e,as:i});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.int(s)}case"LONG":case"UINT_64":{let s=this.getValueAsNumber({value:e,as:i});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.int64(s)}case"FLOAT":case"DOUBLE":{let s=this.getValueAsNumber({value:e,as:i});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.float64(s)}case"BOOLEAN":{let s=this.getValueAsBoolean({value:e,as:i});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.bool(s)}case"STRING":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(s)}case"DATE":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.date(s)}case"DATE_TIME":case"DATE_TIME_RFC_2822":{let s=this.context.getValueAsString({value:e});if(s==null)return l.TypeInstantiation.nop();let c=this.normalizeDateTimeString(s);return l.TypeInstantiation.dateTime(c)}case"UUID":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.uuid(s)}case"BASE_64":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.bytes(s)}case"BIG_INTEGER":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(s)}default:U(t)}}getValueAsNumber({value:t,as:e}){let i=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:t,as:e}){let i=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:i})}normalizeDateTimeString(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t}T00:00:00Z`:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(t)?`${t}Z`:t}};y();v();g();var ht=class{constructor({context:t}){m(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return l.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return l.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 this.convertOptionalOrNullable(t.typeReference.value);case"nullable":return this.convertOptionalOrNullable(t.typeReference.value);case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return l.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:U(t.typeReference)}}convertOptionalOrNullable(t){return this.isPointerAliasReference(t)?this.convert({typeReference:t}):l.Type.optional(this.convert({typeReference:t}))}isPointerAliasReference(t){if(t.type==="named")return this.isAliasToPointerType(t.value);if(t.type==="optional"||t.type==="nullable"){let e=t.value;if(e.type==="named")return this.isAliasToPointerType(e.value)}return!1}isAliasToPointerType(t){let e=new Set,i=t;for(;;){if(e.has(i))return!1;e.add(i);let s=this.context.resolveNamedType({typeId:i});if(s==null||s.type!=="alias")return!1;let c=s.typeReference;if(c.type==="optional"||c.type==="nullable")return!0;if(c.type==="named"){i=c.value;continue}return!1}}convertLiteral({literal:t}){switch(t.type){case"boolean":return l.Type.bool();case"string":return l.Type.string()}}convertNamed({named:t}){let e=l.Type.reference(l.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 l.Type.pointer(e);default:U(t)}}convertUnknown(){return l.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return l.Type.int();case"UINT":return l.Type.int();case"LONG":return l.Type.int64();case"UINT_64":return l.Type.int64();case"FLOAT":return l.Type.float64();case"DOUBLE":return l.Type.float64();case"BOOLEAN":return l.Type.bool();case"STRING":return l.Type.string();case"DATE":return l.Type.date();case"DATE_TIME":case"DATE_TIME_RFC_2822":return l.Type.dateTime();case"UUID":return l.Type.uuid();case"BASE_64":return l.Type.bytes();case"BIG_INTEGER":return l.Type.string();default:U(t)}}};y();v();g();var mt=class{constructor({context:t}){m(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){let i={fileFields:[],bodyPropertyFields:[]},s=this.context.getRecord(e)??{};for(let c of t.properties)switch(c.type){case"file":i.fileFields.push({name:this.context.getFieldName(c.name),value:this.getSingleFileProperty({property:c,record:s})});break;case"fileArray":i.fileFields.push({name:this.context.getFieldName(c.name),value:this.getArrayFileProperty({property:c,record:s})});break;case"bodyProperty":i.bodyPropertyFields.push({name:this.context.getFieldName(c.name.name),value:this.getBodyProperty({property:c,record:s})});break;default:U(c)}return i}getSingleFileProperty({property:t,record:e}){let i=this.context.getSingleFileValue({property:t,record:e})||"";return l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i))}getArrayFileProperty({property:t,record:e}){let i=this.context.getFileArrayValues({property:t,record:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.slice({valueType:l.Type.reference(this.context.getIoReaderTypeReference()),values:i.map(s=>l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(s)))})}getBodyProperty({property:t,record:e}){let i=e[t.name.wireValue];return i==null?l.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:i})}};var yt=class p extends ze{constructor({ir:e,config:i}){super({ir:e,config:i});m(this,"ir");m(this,"customConfig");m(this,"dynamicTypeMapper");m(this,"dynamicTypeInstantiationMapper");m(this,"filePropertyMapper");m(this,"rootImportPath");this.ir=e;let s=this.buildEffectiveConfig({ir:e,config:i});this.customConfig=s.customConfig!=null?s.customConfig:void 0,this.dynamicTypeMapper=new ht({context:this}),this.dynamicTypeInstantiationMapper=new ft({context:this}),this.filePropertyMapper=new mt({context:this}),this.rootImportPath=Dt({config:s,customConfig:this.customConfig})}clone(){return new p({ir:this.ir,config:this.config})}isOptional(e){switch(e.type){case"optional":case"map":return!0;case"nullable":case"list":case"set":return this.isOptional(e.value);case"named":case"literal":case"primitive":case"unknown":return!1;default:U(e)}}getMethodName(e){return e.pascalCase.unsafeName}getTestMethodName(e){return e.declaration.fernFilepath.allParts.map(i=>i.pascalCase.unsafeName).join("")+e.declaration.name.pascalCase.unsafeName}getTypeName(e){return e.pascalCase.unsafeName}getFieldName(e){return Ot(e.pascalCase.unsafeName)}getImportPath(e){let i=e.packagePath.map(s=>s.camelCase.safeName.toLowerCase());return[this.rootImportPath,...i].join("/")}getImportPathForRequest(e){return this.customConfig?.exportAllRequestsAtRoot?this.rootImportPath:this.getImportPath(e)}getContextTypeReference(){return l.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return l.invokeFunc({func:l.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return l.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return l.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return l.invokeFunc({func:l.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[l.TypeInstantiation.string(e)]})}getClientConstructorName(){return this.customConfig?.clientConstructorName!=null?this.customConfig.clientConstructorName:this.customConfig?.exportedClientName!=null?`New${this.customConfig.exportedClientName}`:`New${this.getClientName()}`}getClientName(){return this.customConfig?.clientName!=null?this.customConfig.clientName:"Client"}getClientImportPath(){return`${this.rootImportPath}/client`}getOptionImportPath(){return`${this.rootImportPath}/option`}getGoTypeReferenceFromDeclaration({declaration:e}){return l.typeReference({name:e.name.pascalCase.unsafeName,importPath:this.getImportPath(e.fernFilepath)})}getEnvironmentTypeReferenceFromID(e){let i=this.resolveEnvironmentName(e);if(i!=null)return this.getEnvironmentTypeReference(i)}getEnvironmentTypeReference(e){return l.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}buildEffectiveConfig({ir:e,config:i}){let s=e.generatorConfig;if(s==null||s.outputConfig.type!=="publish")return i;let c=s.outputConfig.value;if(c.type!=="go")return i;let o=Mt(i);return{...i,customConfig:s.customConfig??i.customConfig,output:{...i.output,mode:{type:"github",version:o??c.version,repoUrl:c.repoUrl}}}}static chainMethods(e,...i){if(i.length===0)throw new Error("Must have methods to chain");let s=e;for(let c of i)s=l.invokeMethod({on:s,method:c.method,arguments_:c.arguments_,multiline:c.multiline});return s}};y();v();g();var Br="example",Vt="fern",cs="do",et="client",xh=l.TypeInstantiation,us="WireMockBaseURL",ps="WireMockClient",gt=class{constructor({context:t,formatter:e}){m(this,"context");m(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e,options:i}){return i?.config?.outputWiremockTests??!1?this.generateWiremockTest({endpoint:t,snippet:e}):await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({packageName:Br,importPath:Vt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e,options:i}){return i?.config?.outputWiremockTests??!1?this.generateWiremockTest({endpoint:t,snippet:e}):this.buildCodeBlock({endpoint:t,snippet:e}).toString({packageName:Br,importPath:Vt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}async generateSnippetAst({endpoint:t,request:e,options:i}){throw new Error("Unsupported")}generateWiremockTest({endpoint:t,snippet:e}){return this.buildWiremockTestCodeBlock({endpoint:t,snippet:e}).toString({packageName:"wiremock",importPath:Vt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return l.codeblock(i=>{i.writeNode(l.func({name:cs,parameters:[],return_:[],body:l.codeblock(s=>{s.writeNode(this.constructClient({endpoint:t,snippet:e})),s.writeLine(),s.writeNode(this.callMethod({endpoint:t,snippet:e}))})})),i.writeNewLineIfLastLineNot()})}buildWiremockTestCodeBlock({endpoint:t,snippet:e}){return l.codeblock(i=>{i.writeNode(l.func({name:"Test"+this.context.getTestMethodName(t)+"WithWireMock",parameters:[l.parameter({name:"t",type:l.Type.pointer(l.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:l.codeblock(s=>{for(let c of this.buildWiremockTestSetup({endpoint:t}))s.writeNode(c),s.writeLine();s.writeLine(),s.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),s.writeLine(),s.writeNode(this.callClientMethodAndAssert({endpoint:t,snippet:e,includeTestIdHeader:!0}))})})),i.writeNewLineIfLastLineNot()})}constructClient({endpoint:t,snippet:e}){return l.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}constructWiremockTestClient({endpoint:t,snippet:e}){return l.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:t,endpoint:e,snippet:i,includeTestIdHeader:s}){let{otherArgs:c,requestArg:o}=this.getMethodArgs({endpoint:e,snippet:i}),f=s?[l.codeblock(w=>{w.writeNode(l.invokeFunc({func:l.typeReference({name:"WithHTTPHeader",importPath:this.context.getOptionImportPath()}),arguments_:[l.codeblock('http.Header{"X-Test-Id": []string{"TEST-ID-PLACEHOLDER"}}')]}))})]:[];if(o!=null)if(o instanceof l.TypeInstantiation&&l.TypeInstantiation.isNop(o))t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,l.codeblock("nil"),...f]}));else{t.write("request := "),t.writeNode(o),t.writeLine();let w=l.codeblock("request");t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,w,...f]}))}else t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,...f]}))}callMethod({endpoint:t,snippet:e}){return l.codeblock(i=>{this.writeMethodInvocation({writer:i,endpoint:t,snippet:e})})}getConstructorArgs({endpoint:t,snippet:e}){let i=[],s=this.getConstructorBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return s!=null&&i.push(s),t.auth!=null&&(e.auth!=null?i.push(...this.getConstructorAuthArgs({auth:t.auth,values:e.auth})):this.context.errors.add({severity:L.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(re.Headers),this.context.ir.headers!=null&&e.headers!=null&&i.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),i}getWiremockTestConstructorArgs(){return[l.codeblock(t=>{t.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[l.codeblock(us)]}))})]}getConstructorAuthArgs({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),[];switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArgs({auth:t,values:e}):[];case"bearer":return e.type==="bearer"?[this.getConstructorBearerAuthArg({auth:t,values:e})]:[];case"header":return e.type==="header"?[this.getConstructorHeaderAuthArg({auth:t,values:e})]:[];case"oauth":return e.type==="oauth"?[this.getConstructorOAuthAuthArg({values:e})]:[];case"inferred":return e.type==="inferred"?this.getConstructorInferredAuthArgs({auth:t,values:e}):[];default:U(t)}}addError(t){this.context.errors.add({severity:L.Critical,message:t})}addWarning(t){this.context.errors.add({severity:L.Warning,message:t})}getConstructorBasicAuthArgs({auth:t,values:e}){let i=t,s=!!i.usernameOmit,c=!!i.passwordOmit;if(s&&c)return[];let o=[];return s||o.push(l.TypeInstantiation.string(e.username)),c||o.push(l.TypeInstantiation.string(e.password)),[l.codeblock(f=>{f.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:o}))})]}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let i=this.getBaseUrlArg({baseUrl:t,environment:e});if(i!=null)return l.codeblock(s=>{s.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[i]}))})}getBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:L.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return l.TypeInstantiation.string(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let i=this.context.getEnvironmentTypeReferenceFromID(e);if(i==null){this.context.errors.add({severity:L.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return l.TypeInstantiation.reference(i)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:L.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 l.codeblock(i=>{i.writeNode(l.invokeFunc({func:l.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[l.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return l.codeblock(i=>{i.writeNode(l.invokeFunc({func:l.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})]}))})}getConstructorOAuthAuthArg({values:t}){return l.codeblock(e=>{e.writeNode(l.invokeFunc({func:l.typeReference({name:"WithClientCredentials",importPath:this.context.getOptionImportPath()}),arguments_:[l.TypeInstantiation.string(t.clientId),l.TypeInstantiation.string(t.clientSecret)]}))})}getConstructorInferredAuthArgs({auth:t,values:e}){let i=t.parameters;if(i==null||i.length===0)return[];let s=[];for(let c of i){if(this.isInferredAuthConstructorParamSkipped(c.typeReference))continue;let o=c.name.wireValue,f=e.values?.[o]??c.name.name.originalName,w=this.context.dynamicTypeInstantiationMapper.convert({typeReference:this.getInferredAuthConstructorTypeReference(c.typeReference),value:f});l.TypeInstantiation.isNop(w)||s.push(l.codeblock(T=>{T.writeNode(l.invokeFunc({func:l.typeReference({name:`With${c.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[w]}))}))}return s}isInferredAuthConstructorParamSkipped(t,e=new Set){switch(t.type){case"optional":case"literal":return!0;case"named":{if(e.has(t.value))return!1;e.add(t.value);let i=this.context.resolveNamedType({typeId:t.value});return i?.type==="alias"&&this.isInferredAuthConstructorParamSkipped(i.typeReference,e)}case"list":case"map":case"nullable":case"primitive":case"set":case"unknown":return!1;default:U(t)}}getInferredAuthConstructorTypeReference(t,e=new Set){switch(t.type){case"nullable":return this.getInferredAuthConstructorTypeReference(t.value,e);case"named":{if(e.has(t.value))return t;e.add(t.value);let i=this.context.resolveNamedType({typeId:t.value});return i?.type==="alias"&&i.typeReference.type==="nullable"?this.getInferredAuthConstructorTypeReference(i.typeReference,e):t}case"list":case"literal":case"map":case"optional":case"primitive":case"set":case"unknown":return t;default:U(t)}}getConstructorHeaderArgs({headers:t,values:e}){let i=[];for(let s of t){let c=e[s.name.wireValue],o=this.getConstructorHeaderArg({header:s,value:c});o!=null&&i.push(o)}return i}getConstructorHeaderArg({header:t,value:e}){let i=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!l.TypeInstantiation.isNop(i))return l.codeblock(s=>{s.writeNode(l.invokeFunc({func:l.typeReference({name:`With${t.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[i]}))})}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:U(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let i=[];this.context.errors.scope(re.PathParameters);let s=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];s.length>0&&i.push(...this.getPathParameters({namedParameters:s,snippet:e,asPointer:!0}).map(o=>o.value)),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let c=t.body!=null?this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:i,requestArg:c}}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible({typeReference:t.value,value:e});default:U(t)}}getBytesBodyRequestArg({value:t}){let e=typeof t=="string"?t:"";return this.context.customConfig?.useReaderForBytesRequest??!0?l.TypeInstantiation.reference(l.invokeFunc({func:l.typeReference({name:"NewReader",importPath:"bytes"}),arguments_:[l.TypeInstantiation.bytes(e)]})):l.TypeInstantiation.bytes(e)}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[],{inlinePathParameters:s,inlineFileProperties:c}={inlinePathParameters:this.context.customConfig?.inlinePathParameters??!0,inlineFileProperties:this.context.customConfig?.inlineFileProperties??!0},o=this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:s});this.context.errors.scope(re.PathParameters);let f=[],w=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];w.length>0&&f.push(...this.getPathParameters({namedParameters:w,snippet:e,asPointer:!o})),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let T=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),o||i.push(...f.map(x=>x.value)),c||i.push(...T.fileFields.map(x=>x.value));let E=this.context.needsRequestParameter({request:t,inlinePathParameters:s,inlineFileProperties:c})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:o?f:[],filePropertyInfo:T}):void 0;return{otherArgs:i,requestArg:E}}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:i,filePropertyInfo:s}){this.context.errors.scope(re.QueryParameters);let o=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:e.queryParameters??{}}).map(E=>({name:E.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(E)}));this.context.errors.unscope(),this.context.errors.scope(re.Headers);let w=this.context.associateByWireValue({parameters:t.headers??[],values:e.headers??{}}).map(E=>({name:E.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(E)}));this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let T=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:s}):[];return this.context.errors.unscope(),l.TypeInstantiation.structPointer({typeReference:l.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPathForRequest(t.declaration.fernFilepath)}),fields:[...i,...o,...w,...T]})}getInlinedRequestBodyStructFields({body:t,value:e,filePropertyInfo:i}){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:i});default:U(t)}}getFileUploadRequestBodyStructFields({filePropertyInfo:t}){return this.context.customConfig?.inlineFileProperties??!0?[...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 l.TypeInstantiation.bytes(typeof e=="string"?e:"");case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:U(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){let i=[],s=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}});for(let c of s)i.push({name:this.context.getFieldName(c.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(c)});return i}getPathParameters({namedParameters:t,snippet:e,asPointer:i}){let s=[],c=this.context.associateByWireValueOrDefault({parameters:t,values:e.pathParameters??{}});for(let o of c){let f=o.typeReference.type==="literal"?this.context.dynamicTypeInstantiationMapper.convertLiteral(o.typeReference.value):i?this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(o):this.context.dynamicTypeInstantiationMapper.convert(o);s.push({name:this.context.getTypeName(o.name.name),value:f})}return s}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 l.invokeFunc({func:l.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}buildWiremockTestSetup({endpoint:t,errorCase:e}){let i="stub";return[]}callClientMethodAndAssert({endpoint:t,snippet:e,includeTestIdHeader:i}){return l.codeblock(s=>{this.writeMethodInvocation({writer:s,endpoint:t,snippet:e,includeTestIdHeader:!0}),s.writeLine(),s.writeLine(),s.write("ok, countErr := "),s.writeNode(l.invokeMethod({on:l.codeblock(ps),method:"Verify",arguments_:[l.invokeMethod({on:l.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),l.codeblock("1")],multiline:!1})),s.writeLine(),s.writeNode(l.invokeFunc({func:l.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[l.codeblock("t"),l.codeblock("countErr"),l.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),s.writeLine(),s.writeNode(l.invokeFunc({func:l.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[l.codeblock("t"),l.codeblock("ok"),l.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),s.writeLine()})}};var vt=class extends qe{constructor({ir:e,config:i,formatter:s}){super(new yt({ir:e,config:i}));m(this,"formatter");this.formatter=s}async generate(e,i){return super.generate(e,i)}generateSync(e,i){return super.generateSync(e,i)}async generateSnippetAst(e){return super.generateSnippetAst(e)}createSnippetGenerator(e){return new gt({context:e,formatter:this.formatter})}};0&&(module.exports={DynamicSnippetsGenerator});
|
|
27
|
+
)`}};var l={};xt(l,{Alias:()=>xe,AstNode:()=>k,CodeBlock:()=>ie,Enum:()=>be,Field:()=>Ee,File:()=>Ne,Func:()=>Ae,FuncInvocation:()=>ee,IoReaderTypeReference:()=>$t,Method:()=>le,MethodInvocation:()=>pe,MultiNode:()=>Xe,Parameter:()=>Re,Pointer:()=>Fe,Selector:()=>Pe,Struct:()=>ke,TimeTypeReference:()=>lt,Type:()=>Ze,TypeDeclaration:()=>Be,TypeInstantiation:()=>K,TypeReference:()=>J,UuidTypeReference:()=>dt,Writer:()=>Te,alias:()=>Mo,codeblock:()=>$o,enum_:()=>Oo,field:()=>Do,file:()=>Vo,func:()=>Wo,identifier:()=>Go,invokeFunc:()=>qo,invokeMethod:()=>jo,method:()=>Ho,parameter:()=>zo,pointer:()=>Yo,selector:()=>Ko,struct:()=>Jo,switch_:()=>Xo,typeDeclaration:()=>Qo,typeReference:()=>Zo});y();v();g();y();v();g();y();v();g();y();v();g();y();v();g();var k=class extends we{async toStringAsync({packageName:t,rootImportPath:e,importPath:i,customConfig:s,formatter:c}){let o=new Ke({packageName:t,rootImportPath:e,importPath:i,customConfig:s,formatter:c});return this.write(o),o.toStringAsync()}toString({packageName:t,rootImportPath:e,importPath:i,customConfig:s,formatter:c}){let o=new Ke({packageName:t,rootImportPath:e,importPath:i,customConfig:s,formatter:c});return this.write(o),o.toString()}};var j=class extends k{constructor({docs:e}={}){super();m(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
28
|
+
`).forEach(i=>{e.writeLine(`// ${i}`)})}};var xe=class extends k{constructor({name:e,type:i,docs:s}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=s}write(e){e.writeNode(new j({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};y();v();g();var ie=class extends k{constructor(e){super();m(this,"arg");this.arg=e}write(e){return new Z(this.arg).write(e)}};y();v();g();y();v();g();var ue=class extends k{constructor(e){super();m(this,"name");this.name=e}write(e){e.write(this.name)}};y();v();g();y();v();g();y();v();g();function _e({writer:p,arguments_:t,multiline:e=!0}){let i=t.map(s=>s instanceof K&&K.isNop(s)?K.nil():s);if(i.length===0){p.write("()");return}if(e){Ao({writer:p,arguments_:i});return}Ro({writer:p,arguments_:i})}function Ao({writer:p,arguments_:t}){p.writeLine("("),p.indent();for(let e of t)e.write(p),p.writeLine(",");p.dedent(),p.write(")")}function Ro({writer:p,arguments_:t}){p.write("("),t.forEach((e,i)=>{i>0&&p.write(", "),e.write(p)}),p.write(")")}var ee=class extends k{constructor({func:e,arguments_:i,multiline:s=!0}){super();m(this,"func");m(this,"arguments_");m(this,"multiline");this.func=e,this.arguments_=i,this.multiline=s}write(e){e.writeNode(this.func),_e({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};y();v();g();y();v();g();function kn({writer:p,generics:t}){t.length!==0&&(p.write("["),t.forEach((e,i)=>{i>0&&p.write(", "),e!=null&&p.writeNode(e)}),p.write("]"))}var J=class extends k{constructor({name:e,importPath:i,generics:s}){super();m(this,"name");m(this,"importPath");m(this,"generics");this.name=e,this.importPath=i,this.generics=s}write(e){if(this.importPath==null||e.importPath===this.importPath){e.write(this.name);return}let i=e.addImport(this.importPath);e.write(`${i}.${this.name}`),this.generics!=null&&kn({writer:e,generics:this.generics})}};y();v();g();var pe=class extends k{constructor({method:e,arguments_:i,on:s,multiline:c}){super();m(this,"on");m(this,"method");m(this,"arguments_");m(this,"multiline");this.on=s,this.method=e,this.arguments_=i,this.multiline=c}write(e){this.on.write(e),e.write("."),e.write(this.method),_e({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};var Fo=new Set(["bool","bytes","date","dateTime","float64","int","int64","string","uuid"]),Bn=new Set(["any","map","slice"]),K=class p extends k{constructor(e){super();m(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(Bo({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":e.write(this.internalType.value.toString());break;case"int64":e.write(`int64(${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("`")?`"${Je(this.internalType.value)}"`:this.internalType.value.includes('"')||this.internalType.value.includes(`
|
|
29
|
+
`)?`\`${this.internalType.value}\``:`"${Je(this.internalType.value)}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(So({value:this.internalType.value}));break;default:C(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:i,entries:s}){return new this({type:"map",keyType:e,valueType:i,entries:s})}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:i}){return new this({type:"slice",valueType:e,values:i})}static string(e){return new this({type:"string",value:e})}static struct({typeReference:e,fields:i}){return new this({type:"struct",typeReference:e,fields:i})}static structPointer({typeReference:e,fields:i,generics:s}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:i,generics:s})})}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:i}){switch(typeof i){case"boolean":e.write(i.toString());return;case"string":e.write(i.includes("`")?`"${Je(i)}"`:i.includes('"')||i.includes(`
|
|
30
|
+
`)?`\`${i}\``:`"${Je(i)}"`);return;case"number":e.write(i.toString());return;case"object":if(i==null){e.write("nil");return}if(Array.isArray(i)){this.writeAnyArray({writer:e,value:i});return}this.writeAnyObject({writer:e,value:i});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof i}`)}}writeAnyArray({writer:e,value:i}){if(e.write("[]any"),i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let s of i)e.writeNode(p.any(s)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:i}){e.write("map[string]any");let s=Object.entries(i).sort(([c],[o])=>c<o?-1:c>o?1:0);if(s.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[c,o]of s)e.write(`"${Je(c)}": `),e.writeNode(p.any(o)),e.writeLine(",");e.dedent(),e.write("}")}writeMap({writer:e,map:i}){e.write("map["),e.writeNode(i.keyType),e.write("]"),e.writeNode(i.valueType);let s=Co({entries:i.entries});if(s.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of s)c.key.write(e),e.write(": "),c.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:i}){if(Fo.has(i.internalType.type)){e.writeNode(Po({writer:e,type:i}));return}if(Bn.has(i.internalType.type)){i.write(e);return}if(i.internalType.type==="enum"){e.writeNode(new pe({on:i.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),i.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||Bn.has(e.internalType.type)}writeSlice({writer:e,slice:i}){e.write("[]"),e.writeNode(i.valueType);let s=Lo({values:i.values});if(s.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of s)c.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeStruct({writer:e,struct:i}){e.writeNode(i.typeReference),i.generics!=null&&(e.write("["),i.generics.forEach((c,o)=>{o>0&&e.write(", "),e.writeNode(c)}),e.write("]"));let s=Uo({fields:i.fields});if(s.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of s)e.write(`${c.name}: `),c.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Po({writer:p,type:t}){return new ee({func:new J({name:ko({type:t}),importPath:p.rootImportPath}),arguments_:[t]})}function ko({type:p}){switch(p.internalType.type){case"bool":return"Bool";case"bytes":return"Bytes";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 Bo({writer:p,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new ee({func:new J({name:e,importPath:p.rootImportPath}),arguments_:[new ie(`"${t.value}"`)]})}function So({value:p}){return new ee({func:new J({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new ie(`"${p}"`)]})}function Je(p){return p.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Co({entries:p}){return p.filter(t=>!K.isNop(t.key)&&!K.isNop(t.value))}function Uo({fields:p}){return p.filter(t=>!K.isNop(t.value))}function Lo({values:p}){return p.filter(t=>!K.isNop(t))}var be=class p extends k{constructor({name:e,docs:i}){super();m(this,"name");m(this,"docs");m(this,"members",[]);m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=i}addConstructor(e){this.constructor_=e}addMember(e){this.members.push(e)}addMethod(e){this.methods.push(e)}write(e){this.writeType({writer:e}),this.writeMembers({writer:e}),this.writeConstructor({writer:e}),this.writeMethods({writer:e})}writeType({writer:e}){e.writeNode(new j({docs:this.docs})),e.writeLine(`type ${this.name} string`)}writeMembers({writer:e}){if(this.members.length!==0){e.newLine(),e.writeLine("const ("),e.indent();for(let i of this.members)e.writeNode(new j({docs:i.docs})),e.writeNode(p.getMemberIdentifier({name:this.name,member:i})),e.write(" = "),e.writeNode(K.string(i.value)),e.newLine();e.dedent(),e.write(")")}}writeConstructor({writer:e}){this.constructor_!=null&&(e.newLine(),e.writeNode(this.constructor_))}writeMethods({writer:e}){e.newLine();for(let i of this.methods)e.newLine(),e.writeNode(i),e.newLine()}static getMemberIdentifier({name:e,member:i}){return new ue(`${e}${i.name}`)}};y();v();g();var Ee=class extends k{constructor({name:e,type:i,docs:s,tags:c}){super();m(this,"name");m(this,"type");m(this,"docs");m(this,"tags",[]);this.name=e,this.type=i,this.docs=s,this.tags=c??[]}addTags(...e){this.tags.push(...e)}write(e){e.writeNode(new j({docs:this.docs})),e.write(`${this.name} `),this.type.write(e),this.writeTags({writer:e})}writeTags({writer:e}){this.tags.length!==0&&(e.write(" `"),this.tags.forEach((i,s)=>{s>0&&e.write(" "),e.write(`${i.name}:"${i.value}"`)}),e.write("`"))}};y();v();g();var Ne=class extends k{constructor({nodes:e}={nodes:[]}){super();m(this,"nodes");this.nodes=e??[]}add(...e){this.nodes.push(...e)}write(e){for(let i of this.nodes)i.write(e)}};y();v();g();y();v();g();var le=class extends k{constructor({name:e,parameters:i,return_:s,body:c,docs:o,typeReference:f,multiline:w,receiver:T,pointerReceiver:b}){super();m(this,"parameters");m(this,"return_");m(this,"name");m(this,"body");m(this,"docs");m(this,"typeReference");m(this,"multiline");m(this,"receiver");m(this,"pointerReceiver");this.name=e,this.parameters=i,this.return_=s,this.body=c,this.docs=o,this.typeReference=f,this.multiline=w,this.receiver=T,this.pointerReceiver=b}write(e){e.writeNode(new j({docs:this.docs})),e.write("func"),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference,receiver:this.receiver}),this.name!=null&&e.write(` ${this.name}`),_e({writer:e,arguments_:this.parameters,multiline:this.multiline}),this.return_!=null&&(e.write(" "),this.return_.length>1&&e.write("("),this.return_.forEach((i,s)=>{s>0&&e.write(", "),e.writeNode(i)}),this.return_.length>1&&e.write(")")),e.writeLine("{"),e.indent(),this.body?.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.write("}")}writeReceiver({writer:e,typeReference:i,receiver:s}){e.write(` (${this.getReceiverName({typeReference:i,receiver:s})} `),this.pointerReceiver&&e.write("*"),i.write(e),e.write(")")}getReceiverName({typeReference:e,receiver:i}){return i??e.name.charAt(0).toLowerCase()}};var Ae=class extends k{constructor({name:e,parameters:i,return_:s,body:c,docs:o,multiline:f}){super();m(this,"func");this.func=new le({name:e,parameters:i,return_:s,body:c,docs:o,multiline:f})}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get name(){return this.func.name}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};y();v();g();var Xe=class extends k{constructor({nodes:e}){super();m(this,"nodes");this.nodes=e}write(e){for(let i of this.nodes)e.newLine(),i.write(e),e.newLine()}};y();v();g();var Re=class extends k{constructor({name:e,type:i,docs:s}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=s}write(e){e.writeNode(new j({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};y();v();g();var Fe=class extends k{constructor({node:e}){super();m(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};y();v();g();var Pe=class extends k{constructor({on:e,selector:i}){super();m(this,"on");m(this,"selector");this.on=e,this.selector=i}write(e){e.writeNode(this.on),e.write("."),e.writeNode(this.selector)}};y();v();g();var ke=class extends k{constructor({name:e,embeds:i,fields:s,docs:c}){super();m(this,"name");m(this,"embeds",[]);m(this,"fields",[]);m(this,"docs");m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=c,this.embeds=i??[],this.fields=s??[]}addConstructor(e){this.constructor_=e}addField(...e){this.fields.push(...e)}addMethod(...e){this.methods.push(...e)}write(e){this.writeType({writer:e}),this.constructor_!=null&&(e.newLine(),e.newLine(),this.writeConstructor({writer:e,constructor:this.constructor_})),this.writeMethods({writer:e})}writeType({writer:e}){if(e.writeNode(new j({docs:this.docs})),this.name!=null?e.write(`type ${this.name} struct {`):e.write("struct{"),this.embeds.length===0&&this.fields.length===0){e.writeLine("}");return}e.newLine(),e.indent();for(let c of this.embeds)e.writeNode(c),e.newLine();let i=this.fields.filter(c=>this.isExported(c));for(let c of i)e.writeNode(c),e.newLine();let s=this.fields.filter(c=>!this.isExported(c));i.length>0&&s.length>0&&e.newLine();for(let c of s)e.writeNode(c),e.newLine();e.dedent(),e.write("}")}writeConstructor({writer:e,constructor:i}){i.name!=null?e.write(`func ${i.name}(`):e.write(`func New${this.name}(`),i.parameters.forEach((s,c)=>{c>0&&e.write(", "),e.writeNode(s)}),e.write(`) *${this.name} {`),e.newLine(),e.indent(),e.writeNode(i.body),e.writeNewLineIfLastLineNot(),e.dedent(),e.writeLine("}")}writeMethods({writer:e}){if(this.methods.length!==0){e.writeNewLineIfLastLineNot();for(let i of this.methods)e.newLine(),e.writeNode(i),e.newLine()}}isExported(e){let i=e.name.charAt(0);return i===i.toUpperCase()}};y();v();g();var Qe=class extends k{constructor({on:e,cases:i,default:s}){super();m(this,"on");m(this,"cases");m(this,"default");this.on=e,this.cases=i,this.default=s}write(e){let i=this.cases;this.default!=null&&i.push({on:new ue("default"),body:this.default}),e.write("switch "),e.writeNode(this.on),e.writeLine("{"),e.indent();for(let s of i)e.write("case "),e.writeNode(s.on),e.writeLine(":"),e.indent(),e.writeNode(s.body),e.dedent(),e.writeNewLineIfLastLineNot();e.dedent(),e.write("}")}};y();v();g();var _o=new Set(["any","bytes","map","slice"]),Ze=class p extends k{constructor(e){super();m(this,"internalType");this.internalType=e}write(e,{comment:i}={}){switch(this.internalType.type){case"any":e.write("any");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(lt);break;case"error":e.write("error");break;case"float64":e.write("float64");break;case"int":e.write("int");break;case"int64":e.write("int64");break;case"map":{e.write("map["),this.internalType.keyType.write(e),e.write("]"),this.internalType.valueType.write(e);break}case"optional":{e.write("*"),this.internalType.value.write(e);break}case"reference":e.writeNode(this.internalType.value);break;case"slice":e.write("[]"),this.internalType.value.write(e);break;case"string":e.write("string");break;case"uuid":e.writeNode(dt);break;case"variadic":e.write("..."),this.internalType.value.write(e);break;default:C(this.internalType)}}isOptional(){return this.internalType.type==="optional"}isNilable(){return this.internalType.type==="optional"||_o.has(this.internalType.type)}isIterable(){return this.internalType.type==="slice"||this.internalType.type==="variadic"}iterableElement(){if(this.internalType.type==="slice"||this.internalType.type==="variadic")return this.internalType.value}underlying(){return this.internalType.type==="optional"?this.internalType.value:this}static any(){return new this({type:"any"})}static bool(){return new this({type:"bool"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static dereference(e){return e.internalType.type==="optional"?e.internalType.value:e}static error(){return new this({type:"error"})}static float64(){return new this({type:"float64"})}static int(){return new this({type:"int"})}static int64(){return new this({type:"int64"})}static map(e,i){return new this({type:"map",keyType:e,valueType:i})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static pointer(e){return p.optional(e)}static reference(e){return new this({type:"reference",value:e})}static slice(e){return new this({type:"slice",value:e})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static variadic(e){return this.isAlreadyVariadic(e)?e:new this({type:"variadic",value:e})}static isAlreadyOptional(e){return e.isNilable()}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},lt=new J({importPath:"time",name:"Time"}),dt=new J({importPath:"github.com/google/uuid",name:"UUID"}),$t=new J({importPath:"io",name:"Reader"});y();v();g();var Be=class extends k{constructor({name:e,type:i,docs:s}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=s}write(e){e.writeNode(new j({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function Mo(p){return new xe(p)}function $o(p){return new ie(p)}function Oo(p){return new be(p)}function Do(p){return new Ee(p)}function Vo(p={}){return new Ne(p)}function Wo(p){return new Ae(p)}function Go(p){return new ue(p)}function qo(p){return new ee(p)}function jo(p){return new pe(p)}function Ho(p){return new le(p)}function zo(p){return new Re(p)}function Yo(p){return new Fe(p)}function Ko(p){return new Pe(p)}function Jo(p={}){return new ke(p)}function Xo(p){return new Qe(p)}function Qo(p){return new Be(p)}function Zo(p){return new J(p)}y();v();g();var es=new Set(["string"]);function Ot(p){if(p==="")return"Underscore";let t=p;for(;t.startsWith("_");)t=t.slice(1);if(t==="")return"Underscore";if(t.length>0&&/^\d/.test(t))return"Field"+t;let e=t,i=t[0];return t.length>0&&i!=null&&i!==i.toUpperCase()&&(e=i.toUpperCase()+t.slice(1)),es.has(e.toLowerCase())?"Field"+e:e}y();v();g();Pn();var ts="sdk";function Dt({config:p,customConfig:t}){let e=ns({config:p}),i=rs({config:p,customConfig:t,isModulePath:!0}),s=e!=null?os({importPath:i,majorVersion:e}):i,c=t?.packagePath??"";return c?W.join(s,c):s}function rs({config:p,customConfig:t,isModulePath:e=!1}){let i=t?.importPath??t?.module?.path??(p.output.mode.type==="github"?ss(p.output.mode.repoUrl,"https://"):ts);return e?i:W.join(i,t?.packagePath??"")}function ns({config:p}){let t=is({config:p});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function is({config:p}){let t=as(p);if(t==null||t==="")return;let e=t.split(".");if(e[0]==null||e[0]===""||e[0]==="v")return;let i=e[0];return i.startsWith("v")?i:`v${i}`}function os({importPath:p,majorVersion:t}){return Ye(p)===t?p:`${p}/${t}`}function ss(p,t){return p.startsWith(t)?p.slice(t.length):p}function as(p){let t=p?.output?.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}y();v();g();var ft=class{constructor({context:t}){m(this,"context");this.context=t}convert(t){if(t.value===null&&!this.context.isNullable(t.typeReference)&&this.context.errors.add({severity:L.Critical,message:"Expected non-null value, but got null"}),t.value==null)return l.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return l.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?l.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"nullable":{let e=t.typeReference.value;if(e.type==="named"){let i=this.context.resolveNamedType({typeId:e.value});if(i?.type==="alias"&&["list","set","map"].includes(i.typeReference.type)){let s=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),c=this.context.getTypeName(i.declaration.name),o=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:s,aliasName:c,aliasImportPath:o})}if(i?.type==="alias"&&i.typeReference.type==="literal")return this.convertLiteralToOptionalPrimitive(i.typeReference.value)}return e.type==="literal"?this.convertLiteralToOptionalPrimitive(e.value):l.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"optional":{let e=t.typeReference.value;if(e.type==="named"){let i=this.context.resolveNamedType({typeId:e.value});if(i?.type==="alias"&&["list","set","map"].includes(i.typeReference.type)){let s=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),c=this.context.getTypeName(i.declaration.name),o=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:s,aliasName:c,aliasImportPath:o})}if(i?.type==="alias"&&i.typeReference.type==="literal")return this.convertLiteralToOptionalPrimitive(i.typeReference.value)}return e.type==="literal"?this.convertLiteralToOptionalPrimitive(e.value):l.TypeInstantiation.optional(this.convert({typeReference:e,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:C(t.typeReference)}}convertToPointerIfPossible(t){let e=this.convert(t);return t.typeReference.type==="named"&&this.context.resolveNamedType({typeId:t.typeReference.value})?.type==="enum"?l.TypeInstantiation.reference(l.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e}convertList({list:t,value:e}){return Array.isArray(e)?l.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:t}),values:e.map((i,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:t,value:i})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:L.Critical,message:`Expected array but got: ${typeof e}`}),l.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:L.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),l.TypeInstantiation.nop()):l.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries:Object.entries(e).sort(([i],[s])=>i<s?-1:i>s?1:0).map(([i,s])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:t.key,value:i,as:"key"}),value:this.convert({typeReference:t.value,value:s})}}finally{this.context.errors.unscope()}})})}convertNamed({named:t,value:e,as:i}){switch(t.type){case"alias":return this.convertAlias({aliasType:t,value:e,as:i});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:C(t)}}convertAlias({aliasType:t,value:e,as:i}){return t.typeReference.type==="literal"?l.TypeInstantiation.reference(l.invokeFunc({func:l.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(t.typeReference.value)]})):this.convert({typeReference:t.typeReference,value:e,as:i})}reconstructAliasCollectionLiteral({collectionLiteral:t,aliasName:e,aliasImportPath:i}){let s=t.internalType;return s.type==="slice"?l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(l.typeReference({name:e,importPath:i}));let o=s.values;if(o.length===0){c.write("{}");return}c.writeLine("{"),c.indent();for(let f of o)c.writeNode(f),c.writeLine(",");c.dedent(),c.write("}")})):s.type==="map"?l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(l.typeReference({name:e,importPath:i}));let o=s.entries;if(o.length===0){c.write("{}");return}c.writeLine("{"),c.indent();for(let f of o)c.writeNode(f.key),c.write(": "),c.writeNode(f.value),c.writeLine(",");c.dedent(),c.write("}")})):l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(t)}))}convertLiteral(t){return this.convertLiteralValue(t)}convertLiteralValue(t){switch(t.type){case"boolean":return l.TypeInstantiation.bool(t.value);case"string":return l.TypeInstantiation.string(t.value);default:C(t)}}convertLiteralToOptionalPrimitive(t){switch(t.type){case"boolean":return l.TypeInstantiation.optional(l.TypeInstantiation.bool(t.value));case"string":return l.TypeInstantiation.optional(l.TypeInstantiation.string(t.value));default:C(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let i=this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),s=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(s==null)return l.TypeInstantiation.nop();let c=s.singleDiscriminatedUnionType,o=this.getBaseFields({discriminatedUnionTypeInstance:s,singleDiscriminatedUnionType:c,excludeWireValues:this.getDedupedBasePropertyWireValues(t)});switch(c.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:c.typeId});return f==null?l.TypeInstantiation.nop():l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(c.discriminantValue.name),value:this.convertNamed({named:f,value:s.value})},...o]})}case"singleProperty":{let f=this.context.getRecord(s.value);if(f==null)return l.TypeInstantiation.nop();try{return this.context.errors.scope(c.discriminantValue.wireValue),l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(c.discriminantValue.name),value:this.convert({typeReference:c.typeReference,value:f[c.discriminantValue.wireValue]})},...o]})}finally{this.context.errors.unscope()}}case"noProperties":return l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(s.discriminantValue.name),value:l.TypeInstantiation.string(c.discriminantValue.wireValue)},...o]});default:C(c)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e,excludeWireValues:i}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).filter(c=>!(i?.has(c.name.wireValue)??!1)).map(c=>{this.context.errors.scope(c.name.wireValue);try{return{name:this.context.getFieldName(c.name.name),value:this.convert(c)}}finally{this.context.errors.unscope()}})}getDedupedBasePropertyWireValues(t){if(!this.context.customConfig?.dedupeUnionBaseProperties)return new Set;let e=Object.values(t.types);if(e.length===0||!e.every(o=>o.type==="samePropertiesAsObject"))return new Set;let i=e[0]?.properties??[];if(i.length===0)return new Set;let s=new Set((t.inheritedBaseProperties??[]).map(o=>o.wireValue)),c=this.context.errors.size();try{let o=e.map(T=>this.getObjectExportedProperties(T.typeId)),f=T=>o.every(b=>{let x=b.get(T);return x!=null&&x.typeReference.type!=="literal"}),w=new Set;for(let T of i){if(T.typeReference.type==="literal")continue;let b=this.context.getFieldName(T.name.name);if(s.has(T.name.wireValue)){f(b)&&w.add(T.name.wireValue);continue}let x=this.getGoGetterTypeString(T.typeReference);o.every(E=>{let F=E.get(b);return F!=null&&F.typeReference.type!=="literal"&&this.getGoGetterTypeString(F.typeReference)===x})&&w.add(T.name.wireValue)}return w}finally{this.context.errors.truncate(c)}}getObjectExportedProperties(t){let e=new Map,i=new Set,s=c=>{if(i.has(c))return;i.add(c);let o=this.context.resolveNamedType({typeId:c});if(o?.type==="object"){for(let f of o.extends??[])s(f);for(let f of o.properties)e.set(this.context.getFieldName(f.name.name),f)}};return s(t),e}getGoGetterTypeString(t){let e=t;if(this.context.customConfig?.gettersPassByValue)for(;e.type==="optional"||e.type==="nullable";)e=e.value;return this.context.dynamicTypeMapper.convert({typeReference:e}).toString({packageName:"example",importPath:"fern",rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{}})}convertObject({object_:t,value:e}){let i=this.context.associateByWireValue({parameters:t.properties,values:this.context.getRecord(e)??{}});return l.TypeInstantiation.structPointer({typeReference:l.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:i.map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getFieldName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:t,value:e}){let i=this.getEnumValueName({enum_:t,value:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.enum(l.typeReference({name:i,importPath:this.context.getImportPath(t.declaration.fernFilepath)}))}getEnumValueName({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:L.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let i=t.values.find(s=>s.wireValue===e);if(i==null){this.context.errors.add({severity:L.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return`${this.context.getTypeName(t.declaration.name)}${this.context.getTypeName(i.name)}`}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});if(i==null)return l.TypeInstantiation.nop();let s=this.getUndiscriminatedUnionFieldName({typeReference:i.valueTypeReference});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),fields:[{name:s,value:i.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let i of t.types){let s=this.context.errors.size();try{let c=this.convert({typeReference:i,value:e});if(l.TypeInstantiation.isNop(c)||this.context.errors.size()>s){this.context.errors.truncate(s);continue}return{valueTypeReference:i,typeInstantiation:c}}catch{this.context.errors.truncate(s);continue}}this.context.errors.add({severity:L.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:C(t)}}getUndiscriminatedUnionFieldNameForList({list:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(e!=null)return`${e}List`}getUndiscriminatedUnionFieldNameForMap({map:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.key});if(e==null)return;let i=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(i!=null)return`${e}${i}Map`}getUndiscriminatedUnionFieldNameForOptional({typeReference:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});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:C(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":case"DATE_TIME_RFC_2822":return"DateTime";case"BASE_64":return"Base64";default:C(t)}}convertUnknown({value:t}){return l.TypeInstantiation.any(t)}convertPrimitive({primitive:t,value:e,as:i}){switch(t){case"INTEGER":case"UINT":{let s=this.getValueAsNumber({value:e,as:i});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.int(s)}case"LONG":case"UINT_64":{let s=this.getValueAsNumber({value:e,as:i});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.int64(s)}case"FLOAT":case"DOUBLE":{let s=this.getValueAsNumber({value:e,as:i});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.float64(s)}case"BOOLEAN":{let s=this.getValueAsBoolean({value:e,as:i});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.bool(s)}case"STRING":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(s)}case"DATE":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.date(s)}case"DATE_TIME":case"DATE_TIME_RFC_2822":{let s=this.context.getValueAsString({value:e});if(s==null)return l.TypeInstantiation.nop();let c=this.normalizeDateTimeString(s);return l.TypeInstantiation.dateTime(c)}case"UUID":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.uuid(s)}case"BASE_64":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.bytes(s)}case"BIG_INTEGER":{let s=this.context.getValueAsString({value:e});return s==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(s)}default:C(t)}}getValueAsNumber({value:t,as:e}){let i=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:t,as:e}){let i=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:i})}normalizeDateTimeString(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t}T00:00:00Z`:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(t)?`${t}Z`:t}};y();v();g();var ht=class{constructor({context:t}){m(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return l.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return l.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 this.convertOptionalOrNullable(t.typeReference.value);case"nullable":return this.convertOptionalOrNullable(t.typeReference.value);case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return l.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:C(t.typeReference)}}convertOptionalOrNullable(t){return this.isPointerAliasReference(t)?this.convert({typeReference:t}):l.Type.optional(this.convert({typeReference:t}))}isPointerAliasReference(t){if(t.type==="named")return this.isAliasToPointerType(t.value);if(t.type==="optional"||t.type==="nullable"){let e=t.value;if(e.type==="named")return this.isAliasToPointerType(e.value)}return!1}isAliasToPointerType(t){let e=new Set,i=t;for(;;){if(e.has(i))return!1;e.add(i);let s=this.context.resolveNamedType({typeId:i});if(s==null||s.type!=="alias")return!1;let c=s.typeReference;if(c.type==="optional"||c.type==="nullable")return!0;if(c.type==="named"){i=c.value;continue}return!1}}convertLiteral({literal:t}){switch(t.type){case"boolean":return l.Type.bool();case"string":return l.Type.string()}}convertNamed({named:t}){let e=l.Type.reference(l.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 l.Type.pointer(e);default:C(t)}}convertUnknown(){return l.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return l.Type.int();case"UINT":return l.Type.int();case"LONG":return l.Type.int64();case"UINT_64":return l.Type.int64();case"FLOAT":return l.Type.float64();case"DOUBLE":return l.Type.float64();case"BOOLEAN":return l.Type.bool();case"STRING":return l.Type.string();case"DATE":return l.Type.date();case"DATE_TIME":case"DATE_TIME_RFC_2822":return l.Type.dateTime();case"UUID":return l.Type.uuid();case"BASE_64":return l.Type.bytes();case"BIG_INTEGER":return l.Type.string();default:C(t)}}};y();v();g();var mt=class{constructor({context:t}){m(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){let i={fileFields:[],bodyPropertyFields:[]},s=this.context.getRecord(e)??{};for(let c of t.properties)switch(c.type){case"file":i.fileFields.push({name:this.context.getFieldName(c.name),value:this.getSingleFileProperty({property:c,record:s})});break;case"fileArray":i.fileFields.push({name:this.context.getFieldName(c.name),value:this.getArrayFileProperty({property:c,record:s})});break;case"bodyProperty":i.bodyPropertyFields.push({name:this.context.getFieldName(c.name.name),value:this.getBodyProperty({property:c,record:s})});break;default:C(c)}return i}getSingleFileProperty({property:t,record:e}){let i=this.context.getSingleFileValue({property:t,record:e})||"";return l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i))}getArrayFileProperty({property:t,record:e}){let i=this.context.getFileArrayValues({property:t,record:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.slice({valueType:l.Type.reference(this.context.getIoReaderTypeReference()),values:i.map(s=>l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(s)))})}getBodyProperty({property:t,record:e}){let i=e[t.name.wireValue];return i==null?l.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:i})}};var yt=class p extends ze{constructor({ir:e,config:i}){super({ir:e,config:i});m(this,"ir");m(this,"customConfig");m(this,"dynamicTypeMapper");m(this,"dynamicTypeInstantiationMapper");m(this,"filePropertyMapper");m(this,"rootImportPath");this.ir=e;let s=this.buildEffectiveConfig({ir:e,config:i});this.customConfig=s.customConfig!=null?s.customConfig:void 0,this.dynamicTypeMapper=new ht({context:this}),this.dynamicTypeInstantiationMapper=new ft({context:this}),this.filePropertyMapper=new mt({context:this}),this.rootImportPath=Dt({config:s,customConfig:this.customConfig})}clone(){return new p({ir:this.ir,config:this.config})}isOptional(e){switch(e.type){case"optional":case"map":return!0;case"nullable":case"list":case"set":return this.isOptional(e.value);case"named":case"literal":case"primitive":case"unknown":return!1;default:C(e)}}getMethodName(e){return e.pascalCase.unsafeName}getTestMethodName(e){return e.declaration.fernFilepath.allParts.map(i=>i.pascalCase.unsafeName).join("")+e.declaration.name.pascalCase.unsafeName}getTypeName(e){return e.pascalCase.unsafeName}getFieldName(e){return Ot(e.pascalCase.unsafeName)}getImportPath(e){let i=e.packagePath.map(s=>s.camelCase.safeName.toLowerCase());return[this.rootImportPath,...i].join("/")}getImportPathForRequest(e){return this.customConfig?.exportAllRequestsAtRoot?this.rootImportPath:this.getImportPath(e)}getContextTypeReference(){return l.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return l.invokeFunc({func:l.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return l.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return l.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return l.invokeFunc({func:l.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[l.TypeInstantiation.string(e)]})}getClientConstructorName(){return this.customConfig?.clientConstructorName!=null?this.customConfig.clientConstructorName:this.customConfig?.exportedClientName!=null?`New${this.customConfig.exportedClientName}`:`New${this.getClientName()}`}getClientName(){return this.customConfig?.clientName!=null?this.customConfig.clientName:"Client"}getClientImportPath(){return`${this.rootImportPath}/client`}getOptionImportPath(){return`${this.rootImportPath}/option`}getGoTypeReferenceFromDeclaration({declaration:e}){return l.typeReference({name:e.name.pascalCase.unsafeName,importPath:this.getImportPath(e.fernFilepath)})}getEnvironmentTypeReferenceFromID(e){let i=this.resolveEnvironmentName(e);if(i!=null)return this.getEnvironmentTypeReference(i)}getEnvironmentTypeReference(e){return l.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}buildEffectiveConfig({ir:e,config:i}){let s=e.generatorConfig;if(s==null||s.outputConfig.type!=="publish")return i;let c=s.outputConfig.value;if(c.type!=="go")return i;let o=Mt(i);return{...i,customConfig:s.customConfig??i.customConfig,output:{...i.output,mode:{type:"github",version:o??c.version,repoUrl:c.repoUrl}}}}static chainMethods(e,...i){if(i.length===0)throw new Error("Must have methods to chain");let s=e;for(let c of i)s=l.invokeMethod({on:s,method:c.method,arguments_:c.arguments_,multiline:c.multiline});return s}};y();v();g();var Sn="example",Vt="fern",cs="do",et="client",xh=l.TypeInstantiation,us="WireMockBaseURL",ps="WireMockClient",gt=class{constructor({context:t,formatter:e}){m(this,"context");m(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e,options:i}){return i?.config?.outputWiremockTests??!1?this.generateWiremockTest({endpoint:t,snippet:e}):await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({packageName:Sn,importPath:Vt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e,options:i}){return i?.config?.outputWiremockTests??!1?this.generateWiremockTest({endpoint:t,snippet:e}):this.buildCodeBlock({endpoint:t,snippet:e}).toString({packageName:Sn,importPath:Vt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}async generateSnippetAst({endpoint:t,request:e,options:i}){throw new Error("Unsupported")}generateWiremockTest({endpoint:t,snippet:e}){return this.buildWiremockTestCodeBlock({endpoint:t,snippet:e}).toString({packageName:"wiremock",importPath:Vt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return l.codeblock(i=>{i.writeNode(l.func({name:cs,parameters:[],return_:[],body:l.codeblock(s=>{s.writeNode(this.constructClient({endpoint:t,snippet:e})),s.writeLine(),s.writeNode(this.callMethod({endpoint:t,snippet:e}))})})),i.writeNewLineIfLastLineNot()})}buildWiremockTestCodeBlock({endpoint:t,snippet:e}){return l.codeblock(i=>{i.writeNode(l.func({name:"Test"+this.context.getTestMethodName(t)+"WithWireMock",parameters:[l.parameter({name:"t",type:l.Type.pointer(l.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:l.codeblock(s=>{for(let c of this.buildWiremockTestSetup({endpoint:t}))s.writeNode(c),s.writeLine();s.writeLine(),s.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),s.writeLine(),s.writeNode(this.callClientMethodAndAssert({endpoint:t,snippet:e,includeTestIdHeader:!0}))})})),i.writeNewLineIfLastLineNot()})}constructClient({endpoint:t,snippet:e}){return l.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}constructWiremockTestClient({endpoint:t,snippet:e}){return l.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:t,endpoint:e,snippet:i,includeTestIdHeader:s}){let{otherArgs:c,requestArg:o}=this.getMethodArgs({endpoint:e,snippet:i}),f=s?[l.codeblock(w=>{w.writeNode(l.invokeFunc({func:l.typeReference({name:"WithHTTPHeader",importPath:this.context.getOptionImportPath()}),arguments_:[l.codeblock('http.Header{"X-Test-Id": []string{"TEST-ID-PLACEHOLDER"}}')]}))})]:[];if(o!=null)if(o instanceof l.TypeInstantiation&&l.TypeInstantiation.isNop(o))t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,l.codeblock("nil"),...f]}));else{t.write("request := "),t.writeNode(o),t.writeLine();let w=l.codeblock("request");t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,w,...f]}))}else t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,...f]}))}callMethod({endpoint:t,snippet:e}){return l.codeblock(i=>{this.writeMethodInvocation({writer:i,endpoint:t,snippet:e})})}getConstructorArgs({endpoint:t,snippet:e}){let i=[],s=this.getConstructorBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return s!=null&&i.push(s),t.auth!=null&&(e.auth!=null?i.push(...this.getConstructorAuthArgs({auth:t.auth,values:e.auth})):this.context.errors.add({severity:L.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(ne.Headers),this.context.ir.headers!=null&&e.headers!=null&&i.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),i}getWiremockTestConstructorArgs(){return[l.codeblock(t=>{t.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[l.codeblock(us)]}))})]}getConstructorAuthArgs({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),[];switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArgs({auth:t,values:e}):[];case"bearer":return e.type==="bearer"?[this.getConstructorBearerAuthArg({auth:t,values:e})]:[];case"header":return e.type==="header"?[this.getConstructorHeaderAuthArg({auth:t,values:e})]:[];case"oauth":return e.type==="oauth"?[this.getConstructorOAuthAuthArg({values:e})]:[];case"inferred":return e.type==="inferred"?this.getConstructorInferredAuthArgs({auth:t,values:e}):[];default:C(t)}}addError(t){this.context.errors.add({severity:L.Critical,message:t})}addWarning(t){this.context.errors.add({severity:L.Warning,message:t})}getConstructorBasicAuthArgs({auth:t,values:e}){let i=t,s=!!i.usernameOmit,c=!!i.passwordOmit;if(s&&c)return[];let o=[];return s||o.push(l.TypeInstantiation.string(e.username)),c||o.push(l.TypeInstantiation.string(e.password)),[l.codeblock(f=>{f.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:o}))})]}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let i=this.getBaseUrlArg({baseUrl:t,environment:e});if(i!=null)return l.codeblock(s=>{s.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[i]}))})}getBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:L.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return l.TypeInstantiation.string(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let i=this.context.getEnvironmentTypeReferenceFromID(e);if(i==null){this.context.errors.add({severity:L.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return l.TypeInstantiation.reference(i)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:L.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 l.codeblock(i=>{i.writeNode(l.invokeFunc({func:l.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[l.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return l.codeblock(i=>{i.writeNode(l.invokeFunc({func:l.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})]}))})}getConstructorOAuthAuthArg({values:t}){return l.codeblock(e=>{e.writeNode(l.invokeFunc({func:l.typeReference({name:"WithClientCredentials",importPath:this.context.getOptionImportPath()}),arguments_:[l.TypeInstantiation.string(t.clientId),l.TypeInstantiation.string(t.clientSecret)]}))})}getConstructorInferredAuthArgs({auth:t,values:e}){let i=t.parameters;if(i==null||i.length===0)return[];let s=[];for(let c of i){if(this.isInferredAuthConstructorParamSkipped(c.typeReference))continue;let o=c.name.wireValue,f=e.values?.[o]??c.name.name.originalName,w=this.context.dynamicTypeInstantiationMapper.convert({typeReference:this.getInferredAuthConstructorTypeReference(c.typeReference),value:f});l.TypeInstantiation.isNop(w)||s.push(l.codeblock(T=>{T.writeNode(l.invokeFunc({func:l.typeReference({name:`With${c.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[w]}))}))}return s}isInferredAuthConstructorParamSkipped(t,e=new Set){switch(t.type){case"optional":case"literal":return!0;case"named":{if(e.has(t.value))return!1;e.add(t.value);let i=this.context.resolveNamedType({typeId:t.value});return i?.type==="alias"&&this.isInferredAuthConstructorParamSkipped(i.typeReference,e)}case"list":case"map":case"nullable":case"primitive":case"set":case"unknown":return!1;default:C(t)}}getInferredAuthConstructorTypeReference(t,e=new Set){switch(t.type){case"nullable":return this.getInferredAuthConstructorTypeReference(t.value,e);case"named":{if(e.has(t.value))return t;e.add(t.value);let i=this.context.resolveNamedType({typeId:t.value});return i?.type==="alias"&&i.typeReference.type==="nullable"?this.getInferredAuthConstructorTypeReference(i.typeReference,e):t}case"list":case"literal":case"map":case"optional":case"primitive":case"set":case"unknown":return t;default:C(t)}}getConstructorHeaderArgs({headers:t,values:e}){let i=[];for(let s of t){let c=e[s.name.wireValue],o=this.getConstructorHeaderArg({header:s,value:c});o!=null&&i.push(o)}return i}getConstructorHeaderArg({header:t,value:e}){let i=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!l.TypeInstantiation.isNop(i))return l.codeblock(s=>{s.writeNode(l.invokeFunc({func:l.typeReference({name:`With${t.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[i]}))})}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:C(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let i=[];this.context.errors.scope(ne.PathParameters);let s=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];s.length>0&&i.push(...this.getPathParameters({namedParameters:s,snippet:e,asPointer:!0}).map(o=>o.value)),this.context.errors.unscope(),this.context.errors.scope(ne.RequestBody);let c=t.body!=null?this.callOmitsRequestBody({request:t,snippet:e})?l.TypeInstantiation.nop():this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:i,requestArg:c}}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible({typeReference:t.value,value:e});default:C(t)}}getBytesBodyRequestArg({value:t}){let e=typeof t=="string"?t:"";return this.context.customConfig?.useReaderForBytesRequest??!0?l.TypeInstantiation.reference(l.invokeFunc({func:l.typeReference({name:"NewReader",importPath:"bytes"}),arguments_:[l.TypeInstantiation.bytes(e)]})):l.TypeInstantiation.bytes(e)}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[],{inlinePathParameters:s,inlineFileProperties:c}={inlinePathParameters:this.context.customConfig?.inlinePathParameters??!0,inlineFileProperties:this.context.customConfig?.inlineFileProperties??!0},o=this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:s});this.context.errors.scope(ne.PathParameters);let f=[],w=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];w.length>0&&f.push(...this.getPathParameters({namedParameters:w,snippet:e,asPointer:!o})),this.context.errors.unscope(),this.context.errors.scope(ne.RequestBody);let T=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),o||i.push(...f.map(x=>x.value)),c||i.push(...T.fileFields.map(x=>x.value));let b=this.context.needsRequestParameter({request:t,inlinePathParameters:s,inlineFileProperties:c})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:o?f:[],filePropertyInfo:T}):void 0;return{otherArgs:i,requestArg:b}}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:i,filePropertyInfo:s}){this.context.errors.scope(ne.QueryParameters);let o=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:e.queryParameters??{}}).map(b=>({name:b.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(b)}));this.context.errors.unscope(),this.context.errors.scope(ne.Headers);let w=this.context.associateByWireValue({parameters:t.headers??[],values:e.headers??{}}).map(b=>({name:b.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(b)}));this.context.errors.unscope(),this.context.errors.scope(ne.RequestBody);let T=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:s}):[];return this.context.errors.unscope(),l.TypeInstantiation.structPointer({typeReference:l.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPathForRequest(t.declaration.fernFilepath)}),fields:[...i,...o,...w,...T]})}getInlinedRequestBodyStructFields({body:t,value:e,filePropertyInfo:i}){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:i});default:C(t)}}callOmitsRequestBody({request:t,snippet:e}){if(this.context.customConfig?.respectOptionalRequestBody!==!0||t.bodyRequired!==!1||t.body==null||!this.bodyParameterIsNilable({body:t.body}))return!1;let i=e.requestBody;return i==null||typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length===0}bodyParameterIsNilable({body:t}){switch(t.type){case"bytes":return!0;case"typeReference":return this.context.dynamicTypeMapper.convert({typeReference:t.value}).isNilable();default:C(t)}}getFileUploadRequestBodyStructFields({filePropertyInfo:t}){return this.context.customConfig?.inlineFileProperties??!0?[...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 l.TypeInstantiation.bytes(typeof e=="string"?e:"");case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:C(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){let i=[],s=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}});for(let c of s)i.push({name:this.context.getFieldName(c.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(c)});return i}getPathParameters({namedParameters:t,snippet:e,asPointer:i}){let s=[],c=this.context.associateByWireValueOrDefault({parameters:t,values:e.pathParameters??{}});for(let o of c){let f=o.typeReference.type==="literal"?this.context.dynamicTypeInstantiationMapper.convertLiteral(o.typeReference.value):i?this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(o):this.context.dynamicTypeInstantiationMapper.convert(o);s.push({name:this.context.getTypeName(o.name.name),value:f})}return s}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 l.invokeFunc({func:l.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}buildWiremockTestSetup({endpoint:t,errorCase:e}){let i="stub";return[]}callClientMethodAndAssert({endpoint:t,snippet:e,includeTestIdHeader:i}){return l.codeblock(s=>{this.writeMethodInvocation({writer:s,endpoint:t,snippet:e,includeTestIdHeader:!0}),s.writeLine(),s.writeLine(),s.write("ok, countErr := "),s.writeNode(l.invokeMethod({on:l.codeblock(ps),method:"Verify",arguments_:[l.invokeMethod({on:l.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),l.codeblock("1")],multiline:!1})),s.writeLine(),s.writeNode(l.invokeFunc({func:l.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[l.codeblock("t"),l.codeblock("countErr"),l.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),s.writeLine(),s.writeNode(l.invokeFunc({func:l.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[l.codeblock("t"),l.codeblock("ok"),l.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),s.writeLine()})}};var vt=class extends qe{constructor({ir:e,config:i,formatter:s}){super(new yt({ir:e,config:i}));m(this,"formatter");this.formatter=s}async generate(e,i){return super.generate(e,i)}generateSync(e,i){return super.generateSync(e,i)}async generateSnippetAst(e){return super.generateSnippetAst(e)}createSnippetGenerator(e){return new gt({context:e,formatter:this.formatter})}};0&&(module.exports={DynamicSnippetsGenerator});
|
|
31
31
|
/*! Bundled license information:
|
|
32
32
|
|
|
33
33
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|