@fern-api/go-dynamic-snippets 1.21.6 → 1.21.8
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 +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Jt=Object.defineProperty;var Jr=(u,t,e)=>t in u?Jt(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var oe=(u,t)=>()=>(u&&(t=u(u=0)),t);var Xt=(u,t)=>{for(var e in t)Jt(u,e,{get:t[e],enumerable:!0})};var m=(u,t,e)=>Jr(u,typeof t!="symbol"?t+"":t,e);var y=oe(()=>{"use strict"});var b={};Xt(b,{_debugEnd:()=>Vn,_debugProcess:()=>On,_events:()=>rr,_eventsCount:()=>ir,_exiting:()=>Tn,_fatalExceptions:()=>_n,_getActiveHandles:()=>bn,_getActiveRequests:()=>Nn,_kill:()=>Rn,_linkedBinding:()=>vn,_maxListeners:()=>nr,_preload_modules:()=>Zn,_rawDebug:()=>gn,_startProfilerIdleNotifier:()=>Wn,_stopProfilerIdleNotifier:()=>qn,_tickCallback:()=>Dn,abort:()=>zn,addListener:()=>or,allowedNodeEnvironmentFlags:()=>Cn,arch:()=>nn,argv:()=>sn,argv0:()=>Qn,assert:()=>Un,binding:()=>ln,browser:()=>yn,chdir:()=>hn,config:()=>xn,cpuUsage:()=>it,cwd:()=>fn,debugPort:()=>Xn,default:()=>hr,dlopen:()=>En,domain:()=>In,emit:()=>pr,emitWarning:()=>pn,env:()=>on,execArgv:()=>an,execPath:()=>Jn,exit:()=>Pn,features:()=>Ln,hasUncaughtExceptionCaptureCallback:()=>$n,hrtime:()=>rt,kill:()=>Bn,listeners:()=>fr,memoryUsage:()=>kn,moduleLoadList:()=>wn,nextTick:()=>Zt,off:()=>ar,on:()=>ae,once:()=>sr,openStdin:()=>Sn,pid:()=>Yn,platform:()=>rn,ppid:()=>Kn,prependListener:()=>lr,prependOnceListener:()=>dr,reallyExit:()=>An,release:()=>mn,removeAllListeners:()=>ur,removeListener:()=>cr,resourceUsage:()=>Fn,setSourceMapsEnabled:()=>er,setUncaughtExceptionCaptureCallback:()=>Mn,stderr:()=>jn,stdin:()=>Hn,stdout:()=>Gn,title:()=>tn,umask:()=>dn,uptime:()=>tr,version:()=>cn,versions:()=>un});function xt(u){throw new Error("Node.js process "+u+" is not supported by JSPM core outside of Node.js")}function Xr(){!Ue||!ye||(Ue=!1,ye.length?se=ye.concat(se):nt=-1,se.length&&Qt())}function Qt(){if(!Ue){var u=setTimeout(Xr,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(u)}}function Zt(u){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 en(u,t)),se.length===1&&!Ue&&setTimeout(Qt,0)}function en(u,t){this.fun=u,this.array=t}function H(){}function vn(u){xt("_linkedBinding")}function En(u){xt("dlopen")}function Nn(){return[]}function bn(){return[]}function Un(u,t){if(!u)throw new Error(t||"assertion error")}function $n(){return!1}function tr(){return fe.now()/1e3}function rt(u){var t=Math.floor((Date.now()-fe.now())*.001),e=fe.now()*.001,i=Math.floor(e)+t,a=Math.floor(e%1*1e9);return u&&(i=i-u[0],a=a-u[1],a<0&&(i--,a+=Tt)),[i,a]}function ae(){return hr}function fr(u){return[]}var se,Ue,ye,nt,tn,nn,rn,on,sn,an,cn,un,pn,ln,dn,fn,hn,mn,yn,gn,wn,In,Tn,xn,An,Rn,it,Fn,kn,Bn,Pn,Sn,Cn,Ln,_n,Mn,Dn,On,Vn,Wn,qn,Gn,jn,Hn,zn,Yn,Kn,Jn,Xn,Qn,Zn,er,fe,It,Tt,nr,rr,ir,or,sr,ar,cr,ur,pr,lr,dr,hr,mr=oe(()=>{"use strict";y();w();g();se=[],Ue=!1,nt=-1;en.prototype.run=function(){this.fun.apply(null,this.array)};tn="browser",nn="x64",rn="browser",on={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},sn=["/usr/bin/node"],an=[],cn="v16.8.0",un={},pn=function(u,t){console.warn((t?t+": ":"")+u)},ln=function(u){xt("binding")},dn=function(u){return 0},fn=function(){return"/"},hn=function(u){},mn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};yn=!0,gn=H,wn=[];In={},Tn=!1,xn={};An=H,Rn=H,it=function(){return{}},Fn=it,kn=it,Bn=H,Pn=H,Sn=H,Cn={};Ln={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},_n=H,Mn=H;Dn=H,On=H,Vn=H,Wn=H,qn=H,Gn=void 0,jn=void 0,Hn=void 0,zn=H,Yn=2,Kn=1,Jn="/bin/usr/node",Xn=9229,Qn="node",Zn=[],er=H,fe={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};fe.now===void 0&&(It=Date.now(),fe.timing&&fe.timing.navigationStart&&(It=fe.timing.navigationStart),fe.now=()=>Date.now()-It);Tt=1e9;rt.bigint=function(u){var t=rt(u);return typeof BigInt>"u"?t[0]*Tt+t[1]:BigInt(t[0]*Tt)+BigInt(t[1])};nr=10,rr={},ir=0;or=ae,sr=ae,ar=ae,cr=ae,ur=ae,pr=H,lr=ae,dr=ae;hr={version:cn,versions:un,arch:nn,platform:rn,browser:yn,release:mn,_rawDebug:gn,moduleLoadList:wn,binding:ln,_linkedBinding:vn,_events:rr,_eventsCount:ir,_maxListeners:nr,on:ae,addListener:or,once:sr,off:ar,removeListener:cr,removeAllListeners:ur,emit:pr,prependListener:lr,prependOnceListener:dr,listeners:fr,domain:In,_exiting:Tn,config:xn,dlopen:En,uptime:tr,_getActiveRequests:Nn,_getActiveHandles:bn,reallyExit:An,_kill:Rn,cpuUsage:it,resourceUsage:Fn,memoryUsage:kn,kill:Bn,exit:Pn,openStdin:Sn,allowedNodeEnvironmentFlags:Cn,assert:Un,features:Ln,_fatalExceptions:_n,setUncaughtExceptionCaptureCallback:Mn,hasUncaughtExceptionCaptureCallback:$n,emitWarning:pn,nextTick:Zt,_tickCallback:Dn,_debugProcess:On,_debugEnd:Vn,_startProfilerIdleNotifier:Wn,_stopProfilerIdleNotifier:qn,stdout:Gn,stdin:Hn,stderr:jn,abort:zn,umask:dn,chdir:hn,cwd:fn,env:on,title:tn,argv:sn,execArgv:an,pid:Yn,ppid:Kn,execPath:Jn,debugPort:Xn,hrtime:rt,argv0:Qn,_preload_modules:Zn,setSourceMapsEnabled:er}});var g=oe(()=>{"use strict";mr()});function Qr(){if(yr)return De;yr=!0,De.byteLength=f,De.toByteArray=x,De.fromByteArray=F;for(var u=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,p=i.length;a<p;++a)u[a]=i[a],t[i.charCodeAt(a)]=a;t[45]=62,t[95]=63;function s(N){var k=N.length;if(k%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var S=N.indexOf("=");S===-1&&(S=k);var P=S===k?0:4-S%4;return[S,P]}function f(N){var k=s(N),S=k[0],P=k[1];return(S+P)*3/4-P}function I(N,k,S){return(k+S)*3/4-S}function x(N){var k,S=s(N),P=S[0],G=S[1],$=new e(I(N,P,G)),V=0,Q=G>0?P-4:P,Y;for(Y=0;Y<Q;Y+=4)k=t[N.charCodeAt(Y)]<<18|t[N.charCodeAt(Y+1)]<<12|t[N.charCodeAt(Y+2)]<<6|t[N.charCodeAt(Y+3)],$[V++]=k>>16&255,$[V++]=k>>8&255,$[V++]=k&255;return G===2&&(k=t[N.charCodeAt(Y)]<<2|t[N.charCodeAt(Y+1)]>>4,$[V++]=k&255),G===1&&(k=t[N.charCodeAt(Y)]<<10|t[N.charCodeAt(Y+1)]<<4|t[N.charCodeAt(Y+2)]>>2,$[V++]=k>>8&255,$[V++]=k&255),$}function E(N){return u[N>>18&63]+u[N>>12&63]+u[N>>6&63]+u[N&63]}function T(N,k,S){for(var P,G=[],$=k;$<S;$+=3)P=(N[$]<<16&16711680)+(N[$+1]<<8&65280)+(N[$+2]&255),G.push(E(P));return G.join("")}function F(N){for(var k,S=N.length,P=S%3,G=[],$=16383,V=0,Q=S-P;V<Q;V+=$)G.push(T(N,V,V+$>Q?Q:V+$));return P===1?(k=N[S-1],G.push(u[k>>2]+u[k<<4&63]+"==")):P===2&&(k=(N[S-2]<<8)+N[S-1],G.push(u[k>>10]+u[k>>4&63]+u[k<<2&63]+"=")),G.join("")}return De}function Zr(){if(gr)return ot;gr=!0;return ot.read=function(u,t,e,i,a){var p,s,f=a*8-i-1,I=(1<<f)-1,x=I>>1,E=-7,T=e?a-1:0,F=e?-1:1,N=u[t+T];for(T+=F,p=N&(1<<-E)-1,N>>=-E,E+=f;E>0;p=p*256+u[t+T],T+=F,E-=8);for(s=p&(1<<-E)-1,p>>=-E,E+=i;E>0;s=s*256+u[t+T],T+=F,E-=8);if(p===0)p=1-x;else{if(p===I)return s?NaN:(N?-1:1)*(1/0);s=s+Math.pow(2,i),p=p-x}return(N?-1:1)*s*Math.pow(2,p-i)},ot.write=function(u,t,e,i,a,p){var s,f,I,x=p*8-a-1,E=(1<<x)-1,T=E>>1,F=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=i?0:p-1,k=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,s=E):(s=Math.floor(Math.log(t)/Math.LN2),t*(I=Math.pow(2,-s))<1&&(s--,I*=2),s+T>=1?t+=F/I:t+=F*Math.pow(2,1-T),t*I>=2&&(s++,I/=2),s+T>=E?(f=0,s=E):s+T>=1?(f=(t*I-1)*Math.pow(2,a),s=s+T):(f=t*Math.pow(2,T-1)*Math.pow(2,a),s=0));a>=8;u[e+N]=f&255,N+=k,f/=256,a-=8);for(s=s<<a|f,x+=a;x>0;u[e+N]=s&255,N+=k,s/=256,x-=8);u[e+N-k]|=S*128},ot}function vr(){if(wr)return ge;wr=!0;let u=Qr(),t=Zr(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ge.Buffer=s,ge.SlowBuffer=G,ge.INSPECT_MAX_BYTES=50;let i=2147483647;ge.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.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 a(){try{let o=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(o,n),o.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function p(o){if(o>i)throw new RangeError('The value "'+o+'" is invalid for option "size"');let n=new Uint8Array(o);return Object.setPrototypeOf(n,s.prototype),n}function s(o,n,r){if(typeof o=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(o)}return f(o,n,r)}s.poolSize=8192;function f(o,n,r){if(typeof o=="string")return T(o,n);if(ArrayBuffer.isView(o))return N(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(te(o,ArrayBuffer)||o&&te(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(te(o,SharedArrayBuffer)||o&&te(o.buffer,SharedArrayBuffer)))return k(o,n,r);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let c=o.valueOf&&o.valueOf();if(c!=null&&c!==o)return s.from(c,n,r);let l=S(o);if(l)return l;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return s.from(o[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 o)}s.from=function(o,n,r){return f(o,n,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function I(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function x(o,n,r){return I(o),o<=0?p(o):n!==void 0?typeof r=="string"?p(o).fill(n,r):p(o).fill(n):p(o)}s.alloc=function(o,n,r){return x(o,n,r)};function E(o){return I(o),p(o<0?0:P(o)|0)}s.allocUnsafe=function(o){return E(o)},s.allocUnsafeSlow=function(o){return E(o)};function T(o,n){if((typeof n!="string"||n==="")&&(n="utf8"),!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);let r=$(o,n)|0,c=p(r),l=c.write(o,n);return l!==r&&(c=c.slice(0,l)),c}function F(o){let n=o.length<0?0:P(o.length)|0,r=p(n);for(let c=0;c<n;c+=1)r[c]=o[c]&255;return r}function N(o){if(te(o,Uint8Array)){let n=new Uint8Array(o);return k(n.buffer,n.byteOffset,n.byteLength)}return F(o)}function k(o,n,r){if(n<0||o.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<n+(r||0))throw new RangeError('"length" is outside of buffer bounds');let c;return n===void 0&&r===void 0?c=new Uint8Array(o):r===void 0?c=new Uint8Array(o,n):c=new Uint8Array(o,n,r),Object.setPrototypeOf(c,s.prototype),c}function S(o){if(s.isBuffer(o)){let n=P(o.length)|0,r=p(n);return r.length===0||o.copy(r,0,0,n),r}if(o.length!==void 0)return typeof o.length!="number"||vt(o.length)?p(0):F(o);if(o.type==="Buffer"&&Array.isArray(o.data))return F(o.data)}function P(o){if(o>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return o|0}function G(o){return+o!=o&&(o=0),s.alloc(+o)}s.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==s.prototype},s.compare=function(n,r){if(te(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),te(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(n)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===r)return 0;let c=n.length,l=r.length;for(let h=0,v=Math.min(c,l);h<v;++h)if(n[h]!==r[h]){c=n[h],l=r[h];break}return c<l?-1:l<c?1:0},s.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}},s.concat=function(n,r){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return s.alloc(0);let c;if(r===void 0)for(r=0,c=0;c<n.length;++c)r+=n[c].length;let l=s.allocUnsafe(r),h=0;for(c=0;c<n.length;++c){let v=n[c];if(te(v,Uint8Array))h+v.length>l.length?(s.isBuffer(v)||(v=s.from(v)),v.copy(l,h)):Uint8Array.prototype.set.call(l,v,h);else if(s.isBuffer(v))v.copy(l,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=v.length}return l};function $(o,n){if(s.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||te(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);let r=o.length,c=arguments.length>2&&arguments[2]===!0;if(!c&&r===0)return 0;let l=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return wt(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Kt(o).length;default:if(l)return c?-1:wt(o).length;n=(""+n).toLowerCase(),l=!0}}s.byteLength=$;function V(o,n,r){let c=!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(o||(o="utf8");;)switch(o){case"hex":return Vr(this,n,r);case"utf8":case"utf-8":return Ot(this,n,r);case"ascii":return Dr(this,n,r);case"latin1":case"binary":return Or(this,n,r);case"base64":return Mr(this,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wr(this,n,r);default:if(c)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),c=!0}}s.prototype._isBuffer=!0;function Q(o,n,r){let c=o[n];o[n]=o[r],o[r]=c}s.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},s.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},s.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},s.prototype.toString=function(){let n=this.length;return n===0?"":arguments.length===0?Ot(this,0,n):V.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(n){if(!s.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:s.compare(this,n)===0},s.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&&(s.prototype[e]=s.prototype.inspect),s.prototype.compare=function(n,r,c,l,h){if(te(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),!s.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),c===void 0&&(c=n?n.length:0),l===void 0&&(l=0),h===void 0&&(h=this.length),r<0||c>n.length||l<0||h>this.length)throw new RangeError("out of range index");if(l>=h&&r>=c)return 0;if(l>=h)return-1;if(r>=c)return 1;if(r>>>=0,c>>>=0,l>>>=0,h>>>=0,this===n)return 0;let v=h-l,C=c-r,D=Math.min(v,C),M=this.slice(l,h),O=n.slice(r,c);for(let _=0;_<D;++_)if(M[_]!==O[_]){v=M[_],C=O[_];break}return v<C?-1:C<v?1:0};function Y(o,n,r,c,l){if(o.length===0)return-1;if(typeof r=="string"?(c=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,vt(r)&&(r=l?0:o.length-1),r<0&&(r=o.length+r),r>=o.length){if(l)return-1;r=o.length-1}else if(r<0)if(l)r=0;else return-1;if(typeof n=="string"&&(n=s.from(n,c)),s.isBuffer(n))return n.length===0?-1:Dt(o,n,r,c,l);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?l?Uint8Array.prototype.indexOf.call(o,n,r):Uint8Array.prototype.lastIndexOf.call(o,n,r):Dt(o,[n],r,c,l);throw new TypeError("val must be string, number or Buffer")}function Dt(o,n,r,c,l){let h=1,v=o.length,C=n.length;if(c!==void 0&&(c=String(c).toLowerCase(),c==="ucs2"||c==="ucs-2"||c==="utf16le"||c==="utf-16le")){if(o.length<2||n.length<2)return-1;h=2,v/=2,C/=2,r/=2}function D(O,_){return h===1?O[_]:O.readUInt16BE(_*h)}let M;if(l){let O=-1;for(M=r;M<v;M++)if(D(o,M)===D(n,O===-1?0:M-O)){if(O===-1&&(O=M),M-O+1===C)return O*h}else O!==-1&&(M-=M-O),O=-1}else for(r+C>v&&(r=v-C),M=r;M>=0;M--){let O=!0;for(let _=0;_<C;_++)if(D(o,M+_)!==D(n,_)){O=!1;break}if(O)return M}return-1}s.prototype.includes=function(n,r,c){return this.indexOf(n,r,c)!==-1},s.prototype.indexOf=function(n,r,c){return Y(this,n,r,c,!0)},s.prototype.lastIndexOf=function(n,r,c){return Y(this,n,r,c,!1)};function Sr(o,n,r,c){r=Number(r)||0;let l=o.length-r;c?(c=Number(c),c>l&&(c=l)):c=l;let h=n.length;c>h/2&&(c=h/2);let v;for(v=0;v<c;++v){let C=parseInt(n.substr(v*2,2),16);if(vt(C))return v;o[r+v]=C}return v}function Cr(o,n,r,c){return tt(wt(n,o.length-r),o,r,c)}function Ur(o,n,r,c){return tt(Hr(n),o,r,c)}function Lr(o,n,r,c){return tt(Kt(n),o,r,c)}function _r(o,n,r,c){return tt(zr(n,o.length-r),o,r,c)}s.prototype.write=function(n,r,c,l){if(r===void 0)l="utf8",c=this.length,r=0;else if(c===void 0&&typeof r=="string")l=r,c=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(c)?(c=c>>>0,l===void 0&&(l="utf8")):(l=c,c=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-r;if((c===void 0||c>h)&&(c=h),n.length>0&&(c<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");l||(l="utf8");let v=!1;for(;;)switch(l){case"hex":return Sr(this,n,r,c);case"utf8":case"utf-8":return Cr(this,n,r,c);case"ascii":case"latin1":case"binary":return Ur(this,n,r,c);case"base64":return Lr(this,n,r,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _r(this,n,r,c);default:if(v)throw new TypeError("Unknown encoding: "+l);l=(""+l).toLowerCase(),v=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Mr(o,n,r){return n===0&&r===o.length?u.fromByteArray(o):u.fromByteArray(o.slice(n,r))}function Ot(o,n,r){r=Math.min(o.length,r);let c=[],l=n;for(;l<r;){let h=o[l],v=null,C=h>239?4:h>223?3:h>191?2:1;if(l+C<=r){let D,M,O,_;switch(C){case 1:h<128&&(v=h);break;case 2:D=o[l+1],(D&192)===128&&(_=(h&31)<<6|D&63,_>127&&(v=_));break;case 3:D=o[l+1],M=o[l+2],(D&192)===128&&(M&192)===128&&(_=(h&15)<<12|(D&63)<<6|M&63,_>2047&&(_<55296||_>57343)&&(v=_));break;case 4:D=o[l+1],M=o[l+2],O=o[l+3],(D&192)===128&&(M&192)===128&&(O&192)===128&&(_=(h&15)<<18|(D&63)<<12|(M&63)<<6|O&63,_>65535&&_<1114112&&(v=_))}}v===null?(v=65533,C=1):v>65535&&(v-=65536,c.push(v>>>10&1023|55296),v=56320|v&1023),c.push(v),l+=C}return $r(c)}let Vt=4096;function $r(o){let n=o.length;if(n<=Vt)return String.fromCharCode.apply(String,o);let r="",c=0;for(;c<n;)r+=String.fromCharCode.apply(String,o.slice(c,c+=Vt));return r}function Dr(o,n,r){let c="";r=Math.min(o.length,r);for(let l=n;l<r;++l)c+=String.fromCharCode(o[l]&127);return c}function Or(o,n,r){let c="";r=Math.min(o.length,r);for(let l=n;l<r;++l)c+=String.fromCharCode(o[l]);return c}function Vr(o,n,r){let c=o.length;(!n||n<0)&&(n=0),(!r||r<0||r>c)&&(r=c);let l="";for(let h=n;h<r;++h)l+=Yr[o[h]];return l}function Wr(o,n,r){let c=o.slice(n,r),l="";for(let h=0;h<c.length-1;h+=2)l+=String.fromCharCode(c[h]+c[h+1]*256);return l}s.prototype.slice=function(n,r){let c=this.length;n=~~n,r=r===void 0?c:~~r,n<0?(n+=c,n<0&&(n=0)):n>c&&(n=c),r<0?(r+=c,r<0&&(r=0)):r>c&&(r=c),r<n&&(r=n);let l=this.subarray(n,r);return Object.setPrototypeOf(l,s.prototype),l};function W(o,n,r){if(o%1!==0||o<0)throw new RangeError("offset is not uint");if(o+n>r)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let l=this[n],h=1,v=0;for(;++v<r&&(h*=256);)l+=this[n+v]*h;return l},s.prototype.readUintBE=s.prototype.readUIntBE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let l=this[n+--r],h=1;for(;r>0&&(h*=256);)l+=this[n+--r]*h;return l},s.prototype.readUint8=s.prototype.readUInt8=function(n,r){return n=n>>>0,r||W(n,1,this.length),this[n]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(n,r){return n=n>>>0,r||W(n,2,this.length),this[n]|this[n+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(n,r){return n=n>>>0,r||W(n,2,this.length),this[n]<<8|this[n+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(n,r){return n=n>>>0,r||W(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(n,r){return n=n>>>0,r||W(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},s.prototype.readBigUInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(n,this.length-8);let l=r+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,h=this[++n]+this[++n]*2**8+this[++n]*2**16+c*2**24;return BigInt(l)+(BigInt(h)<<BigInt(32))}),s.prototype.readBigUInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(n,this.length-8);let l=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+c;return(BigInt(l)<<BigInt(32))+BigInt(h)}),s.prototype.readIntLE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let l=this[n],h=1,v=0;for(;++v<r&&(h*=256);)l+=this[n+v]*h;return h*=128,l>=h&&(l-=Math.pow(2,8*r)),l},s.prototype.readIntBE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let l=r,h=1,v=this[n+--l];for(;l>0&&(h*=256);)v+=this[n+--l]*h;return h*=128,v>=h&&(v-=Math.pow(2,8*r)),v},s.prototype.readInt8=function(n,r){return n=n>>>0,r||W(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},s.prototype.readInt16LE=function(n,r){n=n>>>0,r||W(n,2,this.length);let c=this[n]|this[n+1]<<8;return c&32768?c|4294901760:c},s.prototype.readInt16BE=function(n,r){n=n>>>0,r||W(n,2,this.length);let c=this[n+1]|this[n]<<8;return c&32768?c|4294901760:c},s.prototype.readInt32LE=function(n,r){return n=n>>>0,r||W(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},s.prototype.readInt32BE=function(n,r){return n=n>>>0,r||W(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},s.prototype.readBigInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(n,this.length-8);let l=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(c<<24);return(BigInt(l)<<BigInt(32))+BigInt(r+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),s.prototype.readBigInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(n,this.length-8);let l=(r<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(l)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+c)}),s.prototype.readFloatLE=function(n,r){return n=n>>>0,r||W(n,4,this.length),t.read(this,n,!0,23,4)},s.prototype.readFloatBE=function(n,r){return n=n>>>0,r||W(n,4,this.length),t.read(this,n,!1,23,4)},s.prototype.readDoubleLE=function(n,r){return n=n>>>0,r||W(n,8,this.length),t.read(this,n,!0,52,8)},s.prototype.readDoubleBE=function(n,r){return n=n>>>0,r||W(n,8,this.length),t.read(this,n,!1,52,8)};function X(o,n,r,c,l,h){if(!s.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>l||n<h)throw new RangeError('"value" argument is out of bounds');if(r+c>o.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(n,r,c,l){if(n=+n,r=r>>>0,c=c>>>0,!l){let C=Math.pow(2,8*c)-1;X(this,n,r,c,C,0)}let h=1,v=0;for(this[r]=n&255;++v<c&&(h*=256);)this[r+v]=n/h&255;return r+c},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(n,r,c,l){if(n=+n,r=r>>>0,c=c>>>0,!l){let C=Math.pow(2,8*c)-1;X(this,n,r,c,C,0)}let h=c-1,v=1;for(this[r+h]=n&255;--h>=0&&(v*=256);)this[r+h]=n/v&255;return r+c},s.prototype.writeUint8=s.prototype.writeUInt8=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,1,255,0),this[r]=n&255,r+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,65535,0),this[r]=n&255,this[r+1]=n>>>8,r+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,65535,0),this[r]=n>>>8,this[r+1]=n&255,r+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(n,r,c){return n=+n,r=r>>>0,c||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},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(n,r,c){return n=+n,r=r>>>0,c||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 Wt(o,n,r,c,l){Yt(n,c,l,o,r,7);let h=Number(n&BigInt(4294967295));o[r++]=h,h=h>>8,o[r++]=h,h=h>>8,o[r++]=h,h=h>>8,o[r++]=h;let v=Number(n>>BigInt(32)&BigInt(4294967295));return o[r++]=v,v=v>>8,o[r++]=v,v=v>>8,o[r++]=v,v=v>>8,o[r++]=v,r}function qt(o,n,r,c,l){Yt(n,c,l,o,r,7);let h=Number(n&BigInt(4294967295));o[r+7]=h,h=h>>8,o[r+6]=h,h=h>>8,o[r+5]=h,h=h>>8,o[r+4]=h;let v=Number(n>>BigInt(32)&BigInt(4294967295));return o[r+3]=v,v=v>>8,o[r+2]=v,v=v>>8,o[r+1]=v,v=v>>8,o[r]=v,r+8}s.prototype.writeBigUInt64LE=de(function(n,r=0){return Wt(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=de(function(n,r=0){return qt(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(n,r,c,l){if(n=+n,r=r>>>0,!l){let D=Math.pow(2,8*c-1);X(this,n,r,c,D-1,-D)}let h=0,v=1,C=0;for(this[r]=n&255;++h<c&&(v*=256);)n<0&&C===0&&this[r+h-1]!==0&&(C=1),this[r+h]=(n/v>>0)-C&255;return r+c},s.prototype.writeIntBE=function(n,r,c,l){if(n=+n,r=r>>>0,!l){let D=Math.pow(2,8*c-1);X(this,n,r,c,D-1,-D)}let h=c-1,v=1,C=0;for(this[r+h]=n&255;--h>=0&&(v*=256);)n<0&&C===0&&this[r+h+1]!==0&&(C=1),this[r+h]=(n/v>>0)-C&255;return r+c},s.prototype.writeInt8=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,1,127,-128),n<0&&(n=255+n+1),this[r]=n&255,r+1},s.prototype.writeInt16LE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,32767,-32768),this[r]=n&255,this[r+1]=n>>>8,r+2},s.prototype.writeInt16BE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,32767,-32768),this[r]=n>>>8,this[r+1]=n&255,r+2},s.prototype.writeInt32LE=function(n,r,c){return n=+n,r=r>>>0,c||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},s.prototype.writeInt32BE=function(n,r,c){return n=+n,r=r>>>0,c||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},s.prototype.writeBigInt64LE=de(function(n,r=0){return Wt(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=de(function(n,r=0){return qt(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Gt(o,n,r,c,l,h){if(r+c>o.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function jt(o,n,r,c,l){return n=+n,r=r>>>0,l||Gt(o,n,r,4),t.write(o,n,r,c,23,4),r+4}s.prototype.writeFloatLE=function(n,r,c){return jt(this,n,r,!0,c)},s.prototype.writeFloatBE=function(n,r,c){return jt(this,n,r,!1,c)};function Ht(o,n,r,c,l){return n=+n,r=r>>>0,l||Gt(o,n,r,8),t.write(o,n,r,c,52,8),r+8}s.prototype.writeDoubleLE=function(n,r,c){return Ht(this,n,r,!0,c)},s.prototype.writeDoubleBE=function(n,r,c){return Ht(this,n,r,!1,c)},s.prototype.copy=function(n,r,c,l){if(!s.isBuffer(n))throw new TypeError("argument should be a Buffer");if(c||(c=0),!l&&l!==0&&(l=this.length),r>=n.length&&(r=n.length),r||(r=0),l>0&&l<c&&(l=c),l===c||n.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("sourceEnd out of bounds");l>this.length&&(l=this.length),n.length-r<l-c&&(l=n.length-r+c);let h=l-c;return this===n&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,c,l):Uint8Array.prototype.set.call(n,this.subarray(c,l),r),h},s.prototype.fill=function(n,r,c,l){if(typeof n=="string"){if(typeof r=="string"?(l=r,r=0,c=this.length):typeof c=="string"&&(l=c,c=this.length),l!==void 0&&typeof l!="string")throw new TypeError("encoding must be a string");if(typeof l=="string"&&!s.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(n.length===1){let v=n.charCodeAt(0);(l==="utf8"&&v<128||l==="latin1")&&(n=v)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(r<0||this.length<r||this.length<c)throw new RangeError("Out of range index");if(c<=r)return this;r=r>>>0,c=c===void 0?this.length:c>>>0,n||(n=0);let h;if(typeof n=="number")for(h=r;h<c;++h)this[h]=n;else{let v=s.isBuffer(n)?n:s.from(n,l),C=v.length;if(C===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(h=0;h<c-r;++h)this[h+r]=v[h%C]}return this};let Se={};function gt(o,n,r){Se[o]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${o}]`,this.stack,delete this.name}get code(){return o}set code(l){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:l,writable:!0})}toString(){return`${this.name} [${o}]: ${this.message}`}}}gt("ERR_BUFFER_OUT_OF_BOUNDS",function(o){return o?`${o} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),gt("ERR_INVALID_ARG_TYPE",function(o,n){return`The "${o}" argument must be of type number. Received type ${typeof n}`},TypeError),gt("ERR_OUT_OF_RANGE",function(o,n,r){let c=`The value of "${o}" is out of range.`,l=r;return Number.isInteger(r)&&Math.abs(r)>2**32?l=zt(String(r)):typeof r=="bigint"&&(l=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(l=zt(l)),l+="n"),c+=` It must be ${n}. Received ${l}`,c},RangeError);function zt(o){let n="",r=o.length,c=o[0]==="-"?1:0;for(;r>=c+4;r-=3)n=`_${o.slice(r-3,r)}${n}`;return`${o.slice(0,r)}${n}`}function qr(o,n,r){Ce(n,"offset"),(o[n]===void 0||o[n+r]===void 0)&&$e(n,o.length-(r+1))}function Yt(o,n,r,c,l,h){if(o>r||o<n){let v=typeof n=="bigint"?"n":"",C;throw n===0||n===BigInt(0)?C=`>= 0${v} and < 2${v} ** ${(h+1)*8}${v}`:C=`>= -(2${v} ** ${(h+1)*8-1}${v}) and < 2 ** ${(h+1)*8-1}${v}`,new Se.ERR_OUT_OF_RANGE("value",C,o)}qr(c,l,h)}function Ce(o,n){if(typeof o!="number")throw new Se.ERR_INVALID_ARG_TYPE(n,"number",o)}function $e(o,n,r){throw Math.floor(o)!==o?(Ce(o,r),new Se.ERR_OUT_OF_RANGE("offset","an integer",o)):n<0?new Se.ERR_BUFFER_OUT_OF_BOUNDS:new Se.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,o)}let Gr=/[^+/0-9A-Za-z-_]/g;function jr(o){if(o=o.split("=")[0],o=o.trim().replace(Gr,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function wt(o,n){n=n||1/0;let r,c=o.length,l=null,h=[];for(let v=0;v<c;++v){if(r=o.charCodeAt(v),r>55295&&r<57344){if(!l){if(r>56319){(n-=3)>-1&&h.push(239,191,189);continue}else if(v+1===c){(n-=3)>-1&&h.push(239,191,189);continue}l=r;continue}if(r<56320){(n-=3)>-1&&h.push(239,191,189),l=r;continue}r=(l-55296<<10|r-56320)+65536}else l&&(n-=3)>-1&&h.push(239,191,189);if(l=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 Hr(o){let n=[];for(let r=0;r<o.length;++r)n.push(o.charCodeAt(r)&255);return n}function zr(o,n){let r,c,l,h=[];for(let v=0;v<o.length&&!((n-=2)<0);++v)r=o.charCodeAt(v),c=r>>8,l=r%256,h.push(l),h.push(c);return h}function Kt(o){return u.toByteArray(jr(o))}function tt(o,n,r,c){let l;for(l=0;l<c&&!(l+r>=n.length||l>=o.length);++l)n[l+r]=o[l];return l}function te(o,n){return o instanceof n||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===n.name}function vt(o){return o!==o}let Yr=(function(){let o="0123456789abcdef",n=new Array(256);for(let r=0;r<16;++r){let c=r*16;for(let l=0;l<16;++l)n[c+l]=o[r]+o[l]}return n})();function de(o){return typeof BigInt>"u"?Kr:o}function Kr(){throw new Error("BigInt not supported")}return ge}var De,yr,ot,gr,ge,wr,Ir=oe(()=>{"use strict";y();w();g();De={},yr=!1;ot={},gr=!1;ge={},wr=!1});var we,A,gs,ws,Tr=oe(()=>{"use strict";y();w();g();Ir();we=vr();we.Buffer;we.SlowBuffer;we.INSPECT_MAX_BYTES;we.kMaxLength;A=we.Buffer,gs=we.INSPECT_MAX_BYTES,ws=we.kMaxLength});var w=oe(()=>{"use strict";Tr()});function kt(u){throw new Error("Node.js process "+u+" is not supported by JSPM core outside of Node.js")}function oi(){!Le||!Te||(Le=!1,Te.length?ce=Te.concat(ce):ut=-1,ce.length&&Nr())}function Nr(){if(!Le){var u=setTimeout(oi,0);Le=!0;for(var t=ce.length;t;){for(Te=ce,ce=[];++ut<t;)Te&&Te[ut].run();ut=-1,t=ce.length}Te=null,Le=!1,clearTimeout(u)}}function si(u){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 br(u,t)),ce.length===1&&!Le&&setTimeout(Nr,0)}function br(u,t){this.fun=u,this.array=t}function z(){}function Ei(u){kt("_linkedBinding")}function Ri(u){kt("dlopen")}function Fi(){return[]}function ki(){return[]}function $i(u,t){if(!u)throw new Error(t||"assertion error")}function Wi(){return!1}function oo(){return he.now()/1e3}function Ft(u){var t=Math.floor((Date.now()-he.now())*.001),e=he.now()*.001,i=Math.floor(e)+t,a=Math.floor(e%1*1e9);return u&&(i=i-u[0],a=a-u[1],a<0&&(i--,a+=Rt)),[i,a]}function me(){return Pt}function wo(u){return[]}var ce,Le,Te,ut,ai,ci,ui,pi,li,di,fi,hi,mi,yi,gi,wi,vi,Ii,Ti,xi,Ni,bi,Ai,Bi,Pi,Bt,Si,Ci,Ui,Li,_i,Mi,Di,Oi,Vi,qi,Gi,ji,Hi,zi,Yi,Ki,Ji,Xi,Qi,Zi,eo,to,no,ro,io,he,At,Rt,so,ao,co,uo,po,lo,fo,ho,mo,yo,go,Pt,St=oe(()=>{"use strict";y();w();g();ce=[],Le=!1,ut=-1;br.prototype.run=function(){this.fun.apply(null,this.array)};ai="browser",ci="x64",ui="browser",pi={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},li=["/usr/bin/node"],di=[],fi="v16.8.0",hi={},mi=function(u,t){console.warn((t?t+": ":"")+u)},yi=function(u){kt("binding")},gi=function(u){return 0},wi=function(){return"/"},vi=function(u){},Ii={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};Ti=z,xi=[];Ni={},bi=!1,Ai={};Bi=z,Pi=z,Bt=function(){return{}},Si=Bt,Ci=Bt,Ui=z,Li=z,_i=z,Mi={};Di={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Oi=z,Vi=z;qi=z,Gi=z,ji=z,Hi=z,zi=z,Yi=void 0,Ki=void 0,Ji=void 0,Xi=z,Qi=2,Zi=1,eo="/bin/usr/node",to=9229,no="node",ro=[],io=z,he={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};he.now===void 0&&(At=Date.now(),he.timing&&he.timing.navigationStart&&(At=he.timing.navigationStart),he.now=()=>Date.now()-At);Rt=1e9;Ft.bigint=function(u){var t=Ft(u);return typeof BigInt>"u"?t[0]*Rt+t[1]:BigInt(t[0]*Rt)+BigInt(t[1])};so=10,ao={},co=0;uo=me,po=me,lo=me,fo=me,ho=me,mo=z,yo=me,go=me;Pt={version:fi,versions:hi,arch:ci,platform:ui,release:Ii,_rawDebug:Ti,moduleLoadList:xi,binding:yi,_linkedBinding:Ei,_events:ao,_eventsCount:co,_maxListeners:so,on:me,addListener:uo,once:po,off:lo,removeListener:fo,removeAllListeners:ho,emit:mo,prependListener:yo,prependOnceListener:go,listeners:wo,domain:Ni,_exiting:bi,config:Ai,dlopen:Ri,uptime:oo,_getActiveRequests:Fi,_getActiveHandles:ki,reallyExit:Bi,_kill:Pi,cpuUsage:Bt,resourceUsage:Si,memoryUsage:Ci,kill:Ui,exit:Li,openStdin:_i,allowedNodeEnvironmentFlags:Mi,assert:$i,features:Di,_fatalExceptions:Oi,setUncaughtExceptionCaptureCallback:Vi,hasUncaughtExceptionCaptureCallback:Wi,emitWarning:mi,nextTick:si,_tickCallback:qi,_debugProcess:Gi,_debugEnd:ji,_startProfilerIdleNotifier:Hi,_stopProfilerIdleNotifier:zi,stdout:Yi,stdin:Ji,stderr:Ki,abort:Xi,umask:gi,chdir:vi,cwd:wi,env:pi,title:ai,argv:li,execArgv:di,pid:Qi,ppid:Zi,execPath:eo,debugPort:to,hrtime:Ft,argv0:no,_preload_modules:ro,setSourceMapsEnabled:io}});function vo(){if(Ar)return Ct;Ar=!0;var u=Pt;function t(p){if(typeof p!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(p))}function e(p,s){for(var f="",I=0,x=-1,E=0,T,F=0;F<=p.length;++F){if(F<p.length)T=p.charCodeAt(F);else{if(T===47)break;T=47}if(T===47){if(!(x===F-1||E===1))if(x!==F-1&&E===2){if(f.length<2||I!==2||f.charCodeAt(f.length-1)!==46||f.charCodeAt(f.length-2)!==46){if(f.length>2){var N=f.lastIndexOf("/");if(N!==f.length-1){N===-1?(f="",I=0):(f=f.slice(0,N),I=f.length-1-f.lastIndexOf("/")),x=F,E=0;continue}}else if(f.length===2||f.length===1){f="",I=0,x=F,E=0;continue}}s&&(f.length>0?f+="/..":f="..",I=2)}else f.length>0?f+="/"+p.slice(x+1,F):f=p.slice(x+1,F),I=F-x-1;x=F,E=0}else T===46&&E!==-1?++E:E=-1}return f}function i(p,s){var f=s.dir||s.root,I=s.base||(s.name||"")+(s.ext||"");return f?f===s.root?f+I:f+p+I:I}var a={resolve:function(){for(var s="",f=!1,I,x=arguments.length-1;x>=-1&&!f;x--){var E;x>=0?E=arguments[x]:(I===void 0&&(I=u.cwd()),E=I),t(E),E.length!==0&&(s=E+"/"+s,f=E.charCodeAt(0)===47)}return s=e(s,!f),f?s.length>0?"/"+s:"/":s.length>0?s:"."},normalize:function(s){if(t(s),s.length===0)return".";var f=s.charCodeAt(0)===47,I=s.charCodeAt(s.length-1)===47;return s=e(s,!f),s.length===0&&!f&&(s="."),s.length>0&&I&&(s+="/"),f?"/"+s:s},isAbsolute:function(s){return t(s),s.length>0&&s.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var s,f=0;f<arguments.length;++f){var I=arguments[f];t(I),I.length>0&&(s===void 0?s=I:s+="/"+I)}return s===void 0?".":a.normalize(s)},relative:function(s,f){if(t(s),t(f),s===f||(s=a.resolve(s),f=a.resolve(f),s===f))return"";for(var I=1;I<s.length&&s.charCodeAt(I)===47;++I);for(var x=s.length,E=x-I,T=1;T<f.length&&f.charCodeAt(T)===47;++T);for(var F=f.length,N=F-T,k=E<N?E:N,S=-1,P=0;P<=k;++P){if(P===k){if(N>k){if(f.charCodeAt(T+P)===47)return f.slice(T+P+1);if(P===0)return f.slice(T+P)}else E>k&&(s.charCodeAt(I+P)===47?S=P:P===0&&(S=0));break}var G=s.charCodeAt(I+P),$=f.charCodeAt(T+P);if(G!==$)break;G===47&&(S=P)}var V="";for(P=I+S+1;P<=x;++P)(P===x||s.charCodeAt(P)===47)&&(V.length===0?V+="..":V+="/..");return V.length>0?V+f.slice(T+S):(T+=S,f.charCodeAt(T)===47&&++T,f.slice(T))},_makeLong:function(s){return s},dirname:function(s){if(t(s),s.length===0)return".";for(var f=s.charCodeAt(0),I=f===47,x=-1,E=!0,T=s.length-1;T>=1;--T)if(f=s.charCodeAt(T),f===47){if(!E){x=T;break}}else E=!1;return x===-1?I?"/":".":I&&x===1?"//":s.slice(0,x)},basename:function(s,f){if(f!==void 0&&typeof f!="string")throw new TypeError('"ext" argument must be a string');t(s);var I=0,x=-1,E=!0,T;if(f!==void 0&&f.length>0&&f.length<=s.length){if(f.length===s.length&&f===s)return"";var F=f.length-1,N=-1;for(T=s.length-1;T>=0;--T){var k=s.charCodeAt(T);if(k===47){if(!E){I=T+1;break}}else N===-1&&(E=!1,N=T+1),F>=0&&(k===f.charCodeAt(F)?--F===-1&&(x=T):(F=-1,x=N))}return I===x?x=N:x===-1&&(x=s.length),s.slice(I,x)}else{for(T=s.length-1;T>=0;--T)if(s.charCodeAt(T)===47){if(!E){I=T+1;break}}else x===-1&&(E=!1,x=T+1);return x===-1?"":s.slice(I,x)}},extname:function(s){t(s);for(var f=-1,I=0,x=-1,E=!0,T=0,F=s.length-1;F>=0;--F){var N=s.charCodeAt(F);if(N===47){if(!E){I=F+1;break}continue}x===-1&&(E=!1,x=F+1),N===46?f===-1?f=F:T!==1&&(T=1):f!==-1&&(T=-1)}return f===-1||x===-1||T===0||T===1&&f===x-1&&f===I+1?"":s.slice(f,x)},format:function(s){if(s===null||typeof s!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof s);return i("/",s)},parse:function(s){t(s);var f={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return f;var I=s.charCodeAt(0),x=I===47,E;x?(f.root="/",E=1):E=0;for(var T=-1,F=0,N=-1,k=!0,S=s.length-1,P=0;S>=E;--S){if(I=s.charCodeAt(S),I===47){if(!k){F=S+1;break}continue}N===-1&&(k=!1,N=S+1),I===46?T===-1?T=S:P!==1&&(P=1):T!==-1&&(P=-1)}return T===-1||N===-1||P===0||P===1&&T===N-1&&T===F+1?N!==-1&&(F===0&&x?f.base=f.name=s.slice(1,N):f.base=f.name=s.slice(F,N)):(F===0&&x?(f.name=s.slice(1,T),f.base=s.slice(1,N)):(f.name=s.slice(F,T),f.base=s.slice(F,N)),f.ext=s.slice(T,N)),F>0?f.dir=s.slice(0,F-1):x&&(f.dir="/"),f},sep:"/",delimiter:":",win32:null,posix:null};return a.posix=a,Ct=a,Ct}var Ct,Ar,q,Rr=oe(()=>{"use strict";y();w();g();St();Ct={},Ar=!1;q=vo()});var uu,pu,lu,du,fu,hu,mu,yu,gu,wu,vu,Iu,Tu,xu,Eu,Fr=oe(()=>{"use strict";y();w();g();Rr();St();uu=q._makeLong,pu=q.basename,lu=q.delimiter,du=q.dirname,fu=q.extname,hu=q.format,mu=q.isAbsolute,yu=q.join,gu=q.normalize,wu=q.parse,vu=q.posix,Iu=q.relative,Tu=q.resolve,xu=q.sep,Eu=q.win32});y();w();g();y();w();g();y();w();g();y();w();g();function U(u){throw new Error("Unexpected value: "+JSON.stringify(u))}y();w();g();function Oe(u){return Object.keys(u)}y();w();g();y();w();g();y();w();g();var Ve=b.env.FERN_STACK_TRACK?.toLowerCase()??"",ne=Ve!==""&&Ve!=="0"&&Ve!=="false",Et=["single","multiline","box"].includes(Ve)?Ve:"single";ne&&(Error.stackTraceLimit=50);var ei=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),ti=new Set(["stacktrace"]);function at({maxFrames:u=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:p=!0,filterJs:s=!0,formatFilename:f=I=>I}={}){if(!ne)return[];i=[...i,...ei],e=[...e,...ti],a=[...a,"runInteractiveTask"];let I=!1;return(new Error().stack??"").split(`
|
|
1
|
+
var Jt=Object.defineProperty;var Jr=(u,t,e)=>t in u?Jt(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var oe=(u,t)=>()=>(u&&(t=u(u=0)),t);var Xt=(u,t)=>{for(var e in t)Jt(u,e,{get:t[e],enumerable:!0})};var m=(u,t,e)=>Jr(u,typeof t!="symbol"?t+"":t,e);var y=oe(()=>{"use strict"});var b={};Xt(b,{_debugEnd:()=>Vn,_debugProcess:()=>On,_events:()=>rr,_eventsCount:()=>ir,_exiting:()=>Tn,_fatalExceptions:()=>_n,_getActiveHandles:()=>bn,_getActiveRequests:()=>Nn,_kill:()=>Rn,_linkedBinding:()=>vn,_maxListeners:()=>nr,_preload_modules:()=>Zn,_rawDebug:()=>gn,_startProfilerIdleNotifier:()=>Wn,_stopProfilerIdleNotifier:()=>qn,_tickCallback:()=>Dn,abort:()=>zn,addListener:()=>or,allowedNodeEnvironmentFlags:()=>Cn,arch:()=>nn,argv:()=>sn,argv0:()=>Qn,assert:()=>Un,binding:()=>ln,browser:()=>yn,chdir:()=>hn,config:()=>xn,cpuUsage:()=>it,cwd:()=>fn,debugPort:()=>Xn,default:()=>hr,dlopen:()=>En,domain:()=>In,emit:()=>pr,emitWarning:()=>pn,env:()=>on,execArgv:()=>an,execPath:()=>Jn,exit:()=>Pn,features:()=>Ln,hasUncaughtExceptionCaptureCallback:()=>$n,hrtime:()=>rt,kill:()=>Bn,listeners:()=>fr,memoryUsage:()=>kn,moduleLoadList:()=>wn,nextTick:()=>Zt,off:()=>ar,on:()=>ae,once:()=>sr,openStdin:()=>Sn,pid:()=>Yn,platform:()=>rn,ppid:()=>Kn,prependListener:()=>lr,prependOnceListener:()=>dr,reallyExit:()=>An,release:()=>mn,removeAllListeners:()=>ur,removeListener:()=>cr,resourceUsage:()=>Fn,setSourceMapsEnabled:()=>er,setUncaughtExceptionCaptureCallback:()=>Mn,stderr:()=>jn,stdin:()=>Hn,stdout:()=>Gn,title:()=>tn,umask:()=>dn,uptime:()=>tr,version:()=>cn,versions:()=>un});function xt(u){throw new Error("Node.js process "+u+" is not supported by JSPM core outside of Node.js")}function Xr(){!Ue||!ye||(Ue=!1,ye.length?se=ye.concat(se):nt=-1,se.length&&Qt())}function Qt(){if(!Ue){var u=setTimeout(Xr,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(u)}}function Zt(u){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 en(u,t)),se.length===1&&!Ue&&setTimeout(Qt,0)}function en(u,t){this.fun=u,this.array=t}function H(){}function vn(u){xt("_linkedBinding")}function En(u){xt("dlopen")}function Nn(){return[]}function bn(){return[]}function Un(u,t){if(!u)throw new Error(t||"assertion error")}function $n(){return!1}function tr(){return fe.now()/1e3}function rt(u){var t=Math.floor((Date.now()-fe.now())*.001),e=fe.now()*.001,i=Math.floor(e)+t,a=Math.floor(e%1*1e9);return u&&(i=i-u[0],a=a-u[1],a<0&&(i--,a+=Tt)),[i,a]}function ae(){return hr}function fr(u){return[]}var se,Ue,ye,nt,tn,nn,rn,on,sn,an,cn,un,pn,ln,dn,fn,hn,mn,yn,gn,wn,In,Tn,xn,An,Rn,it,Fn,kn,Bn,Pn,Sn,Cn,Ln,_n,Mn,Dn,On,Vn,Wn,qn,Gn,jn,Hn,zn,Yn,Kn,Jn,Xn,Qn,Zn,er,fe,It,Tt,nr,rr,ir,or,sr,ar,cr,ur,pr,lr,dr,hr,mr=oe(()=>{"use strict";y();w();g();se=[],Ue=!1,nt=-1;en.prototype.run=function(){this.fun.apply(null,this.array)};tn="browser",nn="x64",rn="browser",on={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},sn=["/usr/bin/node"],an=[],cn="v16.8.0",un={},pn=function(u,t){console.warn((t?t+": ":"")+u)},ln=function(u){xt("binding")},dn=function(u){return 0},fn=function(){return"/"},hn=function(u){},mn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};yn=!0,gn=H,wn=[];In={},Tn=!1,xn={};An=H,Rn=H,it=function(){return{}},Fn=it,kn=it,Bn=H,Pn=H,Sn=H,Cn={};Ln={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},_n=H,Mn=H;Dn=H,On=H,Vn=H,Wn=H,qn=H,Gn=void 0,jn=void 0,Hn=void 0,zn=H,Yn=2,Kn=1,Jn="/bin/usr/node",Xn=9229,Qn="node",Zn=[],er=H,fe={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};fe.now===void 0&&(It=Date.now(),fe.timing&&fe.timing.navigationStart&&(It=fe.timing.navigationStart),fe.now=()=>Date.now()-It);Tt=1e9;rt.bigint=function(u){var t=rt(u);return typeof BigInt>"u"?t[0]*Tt+t[1]:BigInt(t[0]*Tt)+BigInt(t[1])};nr=10,rr={},ir=0;or=ae,sr=ae,ar=ae,cr=ae,ur=ae,pr=H,lr=ae,dr=ae;hr={version:cn,versions:un,arch:nn,platform:rn,browser:yn,release:mn,_rawDebug:gn,moduleLoadList:wn,binding:ln,_linkedBinding:vn,_events:rr,_eventsCount:ir,_maxListeners:nr,on:ae,addListener:or,once:sr,off:ar,removeListener:cr,removeAllListeners:ur,emit:pr,prependListener:lr,prependOnceListener:dr,listeners:fr,domain:In,_exiting:Tn,config:xn,dlopen:En,uptime:tr,_getActiveRequests:Nn,_getActiveHandles:bn,reallyExit:An,_kill:Rn,cpuUsage:it,resourceUsage:Fn,memoryUsage:kn,kill:Bn,exit:Pn,openStdin:Sn,allowedNodeEnvironmentFlags:Cn,assert:Un,features:Ln,_fatalExceptions:_n,setUncaughtExceptionCaptureCallback:Mn,hasUncaughtExceptionCaptureCallback:$n,emitWarning:pn,nextTick:Zt,_tickCallback:Dn,_debugProcess:On,_debugEnd:Vn,_startProfilerIdleNotifier:Wn,_stopProfilerIdleNotifier:qn,stdout:Gn,stdin:Hn,stderr:jn,abort:zn,umask:dn,chdir:hn,cwd:fn,env:on,title:tn,argv:sn,execArgv:an,pid:Yn,ppid:Kn,execPath:Jn,debugPort:Xn,hrtime:rt,argv0:Qn,_preload_modules:Zn,setSourceMapsEnabled:er}});var g=oe(()=>{"use strict";mr()});function Qr(){if(yr)return De;yr=!0,De.byteLength=f,De.toByteArray=x,De.fromByteArray=F;for(var u=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,p=i.length;a<p;++a)u[a]=i[a],t[i.charCodeAt(a)]=a;t[45]=62,t[95]=63;function s(N){var k=N.length;if(k%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var S=N.indexOf("=");S===-1&&(S=k);var P=S===k?0:4-S%4;return[S,P]}function f(N){var k=s(N),S=k[0],P=k[1];return(S+P)*3/4-P}function I(N,k,S){return(k+S)*3/4-S}function x(N){var k,S=s(N),P=S[0],G=S[1],$=new e(I(N,P,G)),V=0,Q=G>0?P-4:P,Y;for(Y=0;Y<Q;Y+=4)k=t[N.charCodeAt(Y)]<<18|t[N.charCodeAt(Y+1)]<<12|t[N.charCodeAt(Y+2)]<<6|t[N.charCodeAt(Y+3)],$[V++]=k>>16&255,$[V++]=k>>8&255,$[V++]=k&255;return G===2&&(k=t[N.charCodeAt(Y)]<<2|t[N.charCodeAt(Y+1)]>>4,$[V++]=k&255),G===1&&(k=t[N.charCodeAt(Y)]<<10|t[N.charCodeAt(Y+1)]<<4|t[N.charCodeAt(Y+2)]>>2,$[V++]=k>>8&255,$[V++]=k&255),$}function E(N){return u[N>>18&63]+u[N>>12&63]+u[N>>6&63]+u[N&63]}function T(N,k,S){for(var P,G=[],$=k;$<S;$+=3)P=(N[$]<<16&16711680)+(N[$+1]<<8&65280)+(N[$+2]&255),G.push(E(P));return G.join("")}function F(N){for(var k,S=N.length,P=S%3,G=[],$=16383,V=0,Q=S-P;V<Q;V+=$)G.push(T(N,V,V+$>Q?Q:V+$));return P===1?(k=N[S-1],G.push(u[k>>2]+u[k<<4&63]+"==")):P===2&&(k=(N[S-2]<<8)+N[S-1],G.push(u[k>>10]+u[k>>4&63]+u[k<<2&63]+"=")),G.join("")}return De}function Zr(){if(gr)return ot;gr=!0;return ot.read=function(u,t,e,i,a){var p,s,f=a*8-i-1,I=(1<<f)-1,x=I>>1,E=-7,T=e?a-1:0,F=e?-1:1,N=u[t+T];for(T+=F,p=N&(1<<-E)-1,N>>=-E,E+=f;E>0;p=p*256+u[t+T],T+=F,E-=8);for(s=p&(1<<-E)-1,p>>=-E,E+=i;E>0;s=s*256+u[t+T],T+=F,E-=8);if(p===0)p=1-x;else{if(p===I)return s?NaN:(N?-1:1)*(1/0);s=s+Math.pow(2,i),p=p-x}return(N?-1:1)*s*Math.pow(2,p-i)},ot.write=function(u,t,e,i,a,p){var s,f,I,x=p*8-a-1,E=(1<<x)-1,T=E>>1,F=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=i?0:p-1,k=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,s=E):(s=Math.floor(Math.log(t)/Math.LN2),t*(I=Math.pow(2,-s))<1&&(s--,I*=2),s+T>=1?t+=F/I:t+=F*Math.pow(2,1-T),t*I>=2&&(s++,I/=2),s+T>=E?(f=0,s=E):s+T>=1?(f=(t*I-1)*Math.pow(2,a),s=s+T):(f=t*Math.pow(2,T-1)*Math.pow(2,a),s=0));a>=8;u[e+N]=f&255,N+=k,f/=256,a-=8);for(s=s<<a|f,x+=a;x>0;u[e+N]=s&255,N+=k,s/=256,x-=8);u[e+N-k]|=S*128},ot}function vr(){if(wr)return ge;wr=!0;let u=Qr(),t=Zr(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ge.Buffer=s,ge.SlowBuffer=G,ge.INSPECT_MAX_BYTES=50;let i=2147483647;ge.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.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 a(){try{let o=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(o,n),o.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function p(o){if(o>i)throw new RangeError('The value "'+o+'" is invalid for option "size"');let n=new Uint8Array(o);return Object.setPrototypeOf(n,s.prototype),n}function s(o,n,r){if(typeof o=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(o)}return f(o,n,r)}s.poolSize=8192;function f(o,n,r){if(typeof o=="string")return T(o,n);if(ArrayBuffer.isView(o))return N(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(te(o,ArrayBuffer)||o&&te(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(te(o,SharedArrayBuffer)||o&&te(o.buffer,SharedArrayBuffer)))return k(o,n,r);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let c=o.valueOf&&o.valueOf();if(c!=null&&c!==o)return s.from(c,n,r);let d=S(o);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return s.from(o[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 o)}s.from=function(o,n,r){return f(o,n,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function I(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function x(o,n,r){return I(o),o<=0?p(o):n!==void 0?typeof r=="string"?p(o).fill(n,r):p(o).fill(n):p(o)}s.alloc=function(o,n,r){return x(o,n,r)};function E(o){return I(o),p(o<0?0:P(o)|0)}s.allocUnsafe=function(o){return E(o)},s.allocUnsafeSlow=function(o){return E(o)};function T(o,n){if((typeof n!="string"||n==="")&&(n="utf8"),!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);let r=$(o,n)|0,c=p(r),d=c.write(o,n);return d!==r&&(c=c.slice(0,d)),c}function F(o){let n=o.length<0?0:P(o.length)|0,r=p(n);for(let c=0;c<n;c+=1)r[c]=o[c]&255;return r}function N(o){if(te(o,Uint8Array)){let n=new Uint8Array(o);return k(n.buffer,n.byteOffset,n.byteLength)}return F(o)}function k(o,n,r){if(n<0||o.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<n+(r||0))throw new RangeError('"length" is outside of buffer bounds');let c;return n===void 0&&r===void 0?c=new Uint8Array(o):r===void 0?c=new Uint8Array(o,n):c=new Uint8Array(o,n,r),Object.setPrototypeOf(c,s.prototype),c}function S(o){if(s.isBuffer(o)){let n=P(o.length)|0,r=p(n);return r.length===0||o.copy(r,0,0,n),r}if(o.length!==void 0)return typeof o.length!="number"||vt(o.length)?p(0):F(o);if(o.type==="Buffer"&&Array.isArray(o.data))return F(o.data)}function P(o){if(o>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return o|0}function G(o){return+o!=o&&(o=0),s.alloc(+o)}s.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==s.prototype},s.compare=function(n,r){if(te(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),te(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(n)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===r)return 0;let c=n.length,d=r.length;for(let h=0,v=Math.min(c,d);h<v;++h)if(n[h]!==r[h]){c=n[h],d=r[h];break}return c<d?-1:d<c?1:0},s.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}},s.concat=function(n,r){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return s.alloc(0);let c;if(r===void 0)for(r=0,c=0;c<n.length;++c)r+=n[c].length;let d=s.allocUnsafe(r),h=0;for(c=0;c<n.length;++c){let v=n[c];if(te(v,Uint8Array))h+v.length>d.length?(s.isBuffer(v)||(v=s.from(v)),v.copy(d,h)):Uint8Array.prototype.set.call(d,v,h);else if(s.isBuffer(v))v.copy(d,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=v.length}return d};function $(o,n){if(s.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||te(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);let r=o.length,c=arguments.length>2&&arguments[2]===!0;if(!c&&r===0)return 0;let d=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return wt(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Kt(o).length;default:if(d)return c?-1:wt(o).length;n=(""+n).toLowerCase(),d=!0}}s.byteLength=$;function V(o,n,r){let c=!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(o||(o="utf8");;)switch(o){case"hex":return Vr(this,n,r);case"utf8":case"utf-8":return Ot(this,n,r);case"ascii":return Dr(this,n,r);case"latin1":case"binary":return Or(this,n,r);case"base64":return Mr(this,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wr(this,n,r);default:if(c)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),c=!0}}s.prototype._isBuffer=!0;function Q(o,n,r){let c=o[n];o[n]=o[r],o[r]=c}s.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},s.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},s.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},s.prototype.toString=function(){let n=this.length;return n===0?"":arguments.length===0?Ot(this,0,n):V.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(n){if(!s.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:s.compare(this,n)===0},s.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&&(s.prototype[e]=s.prototype.inspect),s.prototype.compare=function(n,r,c,d,h){if(te(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),!s.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),c===void 0&&(c=n?n.length:0),d===void 0&&(d=0),h===void 0&&(h=this.length),r<0||c>n.length||d<0||h>this.length)throw new RangeError("out of range index");if(d>=h&&r>=c)return 0;if(d>=h)return-1;if(r>=c)return 1;if(r>>>=0,c>>>=0,d>>>=0,h>>>=0,this===n)return 0;let v=h-d,C=c-r,D=Math.min(v,C),M=this.slice(d,h),O=n.slice(r,c);for(let _=0;_<D;++_)if(M[_]!==O[_]){v=M[_],C=O[_];break}return v<C?-1:C<v?1:0};function Y(o,n,r,c,d){if(o.length===0)return-1;if(typeof r=="string"?(c=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,vt(r)&&(r=d?0:o.length-1),r<0&&(r=o.length+r),r>=o.length){if(d)return-1;r=o.length-1}else if(r<0)if(d)r=0;else return-1;if(typeof n=="string"&&(n=s.from(n,c)),s.isBuffer(n))return n.length===0?-1:Dt(o,n,r,c,d);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(o,n,r):Uint8Array.prototype.lastIndexOf.call(o,n,r):Dt(o,[n],r,c,d);throw new TypeError("val must be string, number or Buffer")}function Dt(o,n,r,c,d){let h=1,v=o.length,C=n.length;if(c!==void 0&&(c=String(c).toLowerCase(),c==="ucs2"||c==="ucs-2"||c==="utf16le"||c==="utf-16le")){if(o.length<2||n.length<2)return-1;h=2,v/=2,C/=2,r/=2}function D(O,_){return h===1?O[_]:O.readUInt16BE(_*h)}let M;if(d){let O=-1;for(M=r;M<v;M++)if(D(o,M)===D(n,O===-1?0:M-O)){if(O===-1&&(O=M),M-O+1===C)return O*h}else O!==-1&&(M-=M-O),O=-1}else for(r+C>v&&(r=v-C),M=r;M>=0;M--){let O=!0;for(let _=0;_<C;_++)if(D(o,M+_)!==D(n,_)){O=!1;break}if(O)return M}return-1}s.prototype.includes=function(n,r,c){return this.indexOf(n,r,c)!==-1},s.prototype.indexOf=function(n,r,c){return Y(this,n,r,c,!0)},s.prototype.lastIndexOf=function(n,r,c){return Y(this,n,r,c,!1)};function Sr(o,n,r,c){r=Number(r)||0;let d=o.length-r;c?(c=Number(c),c>d&&(c=d)):c=d;let h=n.length;c>h/2&&(c=h/2);let v;for(v=0;v<c;++v){let C=parseInt(n.substr(v*2,2),16);if(vt(C))return v;o[r+v]=C}return v}function Cr(o,n,r,c){return tt(wt(n,o.length-r),o,r,c)}function Ur(o,n,r,c){return tt(Hr(n),o,r,c)}function Lr(o,n,r,c){return tt(Kt(n),o,r,c)}function _r(o,n,r,c){return tt(zr(n,o.length-r),o,r,c)}s.prototype.write=function(n,r,c,d){if(r===void 0)d="utf8",c=this.length,r=0;else if(c===void 0&&typeof r=="string")d=r,c=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(c)?(c=c>>>0,d===void 0&&(d="utf8")):(d=c,c=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-r;if((c===void 0||c>h)&&(c=h),n.length>0&&(c<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let v=!1;for(;;)switch(d){case"hex":return Sr(this,n,r,c);case"utf8":case"utf-8":return Cr(this,n,r,c);case"ascii":case"latin1":case"binary":return Ur(this,n,r,c);case"base64":return Lr(this,n,r,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _r(this,n,r,c);default:if(v)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),v=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Mr(o,n,r){return n===0&&r===o.length?u.fromByteArray(o):u.fromByteArray(o.slice(n,r))}function Ot(o,n,r){r=Math.min(o.length,r);let c=[],d=n;for(;d<r;){let h=o[d],v=null,C=h>239?4:h>223?3:h>191?2:1;if(d+C<=r){let D,M,O,_;switch(C){case 1:h<128&&(v=h);break;case 2:D=o[d+1],(D&192)===128&&(_=(h&31)<<6|D&63,_>127&&(v=_));break;case 3:D=o[d+1],M=o[d+2],(D&192)===128&&(M&192)===128&&(_=(h&15)<<12|(D&63)<<6|M&63,_>2047&&(_<55296||_>57343)&&(v=_));break;case 4:D=o[d+1],M=o[d+2],O=o[d+3],(D&192)===128&&(M&192)===128&&(O&192)===128&&(_=(h&15)<<18|(D&63)<<12|(M&63)<<6|O&63,_>65535&&_<1114112&&(v=_))}}v===null?(v=65533,C=1):v>65535&&(v-=65536,c.push(v>>>10&1023|55296),v=56320|v&1023),c.push(v),d+=C}return $r(c)}let Vt=4096;function $r(o){let n=o.length;if(n<=Vt)return String.fromCharCode.apply(String,o);let r="",c=0;for(;c<n;)r+=String.fromCharCode.apply(String,o.slice(c,c+=Vt));return r}function Dr(o,n,r){let c="";r=Math.min(o.length,r);for(let d=n;d<r;++d)c+=String.fromCharCode(o[d]&127);return c}function Or(o,n,r){let c="";r=Math.min(o.length,r);for(let d=n;d<r;++d)c+=String.fromCharCode(o[d]);return c}function Vr(o,n,r){let c=o.length;(!n||n<0)&&(n=0),(!r||r<0||r>c)&&(r=c);let d="";for(let h=n;h<r;++h)d+=Yr[o[h]];return d}function Wr(o,n,r){let c=o.slice(n,r),d="";for(let h=0;h<c.length-1;h+=2)d+=String.fromCharCode(c[h]+c[h+1]*256);return d}s.prototype.slice=function(n,r){let c=this.length;n=~~n,r=r===void 0?c:~~r,n<0?(n+=c,n<0&&(n=0)):n>c&&(n=c),r<0?(r+=c,r<0&&(r=0)):r>c&&(r=c),r<n&&(r=n);let d=this.subarray(n,r);return Object.setPrototypeOf(d,s.prototype),d};function W(o,n,r){if(o%1!==0||o<0)throw new RangeError("offset is not uint");if(o+n>r)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let d=this[n],h=1,v=0;for(;++v<r&&(h*=256);)d+=this[n+v]*h;return d},s.prototype.readUintBE=s.prototype.readUIntBE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let d=this[n+--r],h=1;for(;r>0&&(h*=256);)d+=this[n+--r]*h;return d},s.prototype.readUint8=s.prototype.readUInt8=function(n,r){return n=n>>>0,r||W(n,1,this.length),this[n]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(n,r){return n=n>>>0,r||W(n,2,this.length),this[n]|this[n+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(n,r){return n=n>>>0,r||W(n,2,this.length),this[n]<<8|this[n+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(n,r){return n=n>>>0,r||W(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(n,r){return n=n>>>0,r||W(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},s.prototype.readBigUInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(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+c*2**24;return BigInt(d)+(BigInt(h)<<BigInt(32))}),s.prototype.readBigUInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(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+c;return(BigInt(d)<<BigInt(32))+BigInt(h)}),s.prototype.readIntLE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let d=this[n],h=1,v=0;for(;++v<r&&(h*=256);)d+=this[n+v]*h;return h*=128,d>=h&&(d-=Math.pow(2,8*r)),d},s.prototype.readIntBE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let d=r,h=1,v=this[n+--d];for(;d>0&&(h*=256);)v+=this[n+--d]*h;return h*=128,v>=h&&(v-=Math.pow(2,8*r)),v},s.prototype.readInt8=function(n,r){return n=n>>>0,r||W(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},s.prototype.readInt16LE=function(n,r){n=n>>>0,r||W(n,2,this.length);let c=this[n]|this[n+1]<<8;return c&32768?c|4294901760:c},s.prototype.readInt16BE=function(n,r){n=n>>>0,r||W(n,2,this.length);let c=this[n+1]|this[n]<<8;return c&32768?c|4294901760:c},s.prototype.readInt32LE=function(n,r){return n=n>>>0,r||W(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},s.prototype.readInt32BE=function(n,r){return n=n>>>0,r||W(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},s.prototype.readBigInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(n,this.length-8);let d=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(c<<24);return(BigInt(d)<<BigInt(32))+BigInt(r+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),s.prototype.readBigInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(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+c)}),s.prototype.readFloatLE=function(n,r){return n=n>>>0,r||W(n,4,this.length),t.read(this,n,!0,23,4)},s.prototype.readFloatBE=function(n,r){return n=n>>>0,r||W(n,4,this.length),t.read(this,n,!1,23,4)},s.prototype.readDoubleLE=function(n,r){return n=n>>>0,r||W(n,8,this.length),t.read(this,n,!0,52,8)},s.prototype.readDoubleBE=function(n,r){return n=n>>>0,r||W(n,8,this.length),t.read(this,n,!1,52,8)};function X(o,n,r,c,d,h){if(!s.isBuffer(o))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+c>o.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(n,r,c,d){if(n=+n,r=r>>>0,c=c>>>0,!d){let C=Math.pow(2,8*c)-1;X(this,n,r,c,C,0)}let h=1,v=0;for(this[r]=n&255;++v<c&&(h*=256);)this[r+v]=n/h&255;return r+c},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(n,r,c,d){if(n=+n,r=r>>>0,c=c>>>0,!d){let C=Math.pow(2,8*c)-1;X(this,n,r,c,C,0)}let h=c-1,v=1;for(this[r+h]=n&255;--h>=0&&(v*=256);)this[r+h]=n/v&255;return r+c},s.prototype.writeUint8=s.prototype.writeUInt8=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,1,255,0),this[r]=n&255,r+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,65535,0),this[r]=n&255,this[r+1]=n>>>8,r+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,65535,0),this[r]=n>>>8,this[r+1]=n&255,r+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(n,r,c){return n=+n,r=r>>>0,c||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},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(n,r,c){return n=+n,r=r>>>0,c||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 Wt(o,n,r,c,d){Yt(n,c,d,o,r,7);let h=Number(n&BigInt(4294967295));o[r++]=h,h=h>>8,o[r++]=h,h=h>>8,o[r++]=h,h=h>>8,o[r++]=h;let v=Number(n>>BigInt(32)&BigInt(4294967295));return o[r++]=v,v=v>>8,o[r++]=v,v=v>>8,o[r++]=v,v=v>>8,o[r++]=v,r}function qt(o,n,r,c,d){Yt(n,c,d,o,r,7);let h=Number(n&BigInt(4294967295));o[r+7]=h,h=h>>8,o[r+6]=h,h=h>>8,o[r+5]=h,h=h>>8,o[r+4]=h;let v=Number(n>>BigInt(32)&BigInt(4294967295));return o[r+3]=v,v=v>>8,o[r+2]=v,v=v>>8,o[r+1]=v,v=v>>8,o[r]=v,r+8}s.prototype.writeBigUInt64LE=de(function(n,r=0){return Wt(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=de(function(n,r=0){return qt(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(n,r,c,d){if(n=+n,r=r>>>0,!d){let D=Math.pow(2,8*c-1);X(this,n,r,c,D-1,-D)}let h=0,v=1,C=0;for(this[r]=n&255;++h<c&&(v*=256);)n<0&&C===0&&this[r+h-1]!==0&&(C=1),this[r+h]=(n/v>>0)-C&255;return r+c},s.prototype.writeIntBE=function(n,r,c,d){if(n=+n,r=r>>>0,!d){let D=Math.pow(2,8*c-1);X(this,n,r,c,D-1,-D)}let h=c-1,v=1,C=0;for(this[r+h]=n&255;--h>=0&&(v*=256);)n<0&&C===0&&this[r+h+1]!==0&&(C=1),this[r+h]=(n/v>>0)-C&255;return r+c},s.prototype.writeInt8=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,1,127,-128),n<0&&(n=255+n+1),this[r]=n&255,r+1},s.prototype.writeInt16LE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,32767,-32768),this[r]=n&255,this[r+1]=n>>>8,r+2},s.prototype.writeInt16BE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,32767,-32768),this[r]=n>>>8,this[r+1]=n&255,r+2},s.prototype.writeInt32LE=function(n,r,c){return n=+n,r=r>>>0,c||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},s.prototype.writeInt32BE=function(n,r,c){return n=+n,r=r>>>0,c||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},s.prototype.writeBigInt64LE=de(function(n,r=0){return Wt(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=de(function(n,r=0){return qt(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Gt(o,n,r,c,d,h){if(r+c>o.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function jt(o,n,r,c,d){return n=+n,r=r>>>0,d||Gt(o,n,r,4),t.write(o,n,r,c,23,4),r+4}s.prototype.writeFloatLE=function(n,r,c){return jt(this,n,r,!0,c)},s.prototype.writeFloatBE=function(n,r,c){return jt(this,n,r,!1,c)};function Ht(o,n,r,c,d){return n=+n,r=r>>>0,d||Gt(o,n,r,8),t.write(o,n,r,c,52,8),r+8}s.prototype.writeDoubleLE=function(n,r,c){return Ht(this,n,r,!0,c)},s.prototype.writeDoubleBE=function(n,r,c){return Ht(this,n,r,!1,c)},s.prototype.copy=function(n,r,c,d){if(!s.isBuffer(n))throw new TypeError("argument should be a Buffer");if(c||(c=0),!d&&d!==0&&(d=this.length),r>=n.length&&(r=n.length),r||(r=0),d>0&&d<c&&(d=c),d===c||n.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=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-c&&(d=n.length-r+c);let h=d-c;return this===n&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,c,d):Uint8Array.prototype.set.call(n,this.subarray(c,d),r),h},s.prototype.fill=function(n,r,c,d){if(typeof n=="string"){if(typeof r=="string"?(d=r,r=0,c=this.length):typeof c=="string"&&(d=c,c=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!s.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(n.length===1){let v=n.charCodeAt(0);(d==="utf8"&&v<128||d==="latin1")&&(n=v)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(r<0||this.length<r||this.length<c)throw new RangeError("Out of range index");if(c<=r)return this;r=r>>>0,c=c===void 0?this.length:c>>>0,n||(n=0);let h;if(typeof n=="number")for(h=r;h<c;++h)this[h]=n;else{let v=s.isBuffer(n)?n:s.from(n,d),C=v.length;if(C===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(h=0;h<c-r;++h)this[h+r]=v[h%C]}return this};let Se={};function gt(o,n,r){Se[o]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${o}]`,this.stack,delete this.name}get code(){return o}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${o}]: ${this.message}`}}}gt("ERR_BUFFER_OUT_OF_BOUNDS",function(o){return o?`${o} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),gt("ERR_INVALID_ARG_TYPE",function(o,n){return`The "${o}" argument must be of type number. Received type ${typeof n}`},TypeError),gt("ERR_OUT_OF_RANGE",function(o,n,r){let c=`The value of "${o}" is out of range.`,d=r;return Number.isInteger(r)&&Math.abs(r)>2**32?d=zt(String(r)):typeof r=="bigint"&&(d=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(d=zt(d)),d+="n"),c+=` It must be ${n}. Received ${d}`,c},RangeError);function zt(o){let n="",r=o.length,c=o[0]==="-"?1:0;for(;r>=c+4;r-=3)n=`_${o.slice(r-3,r)}${n}`;return`${o.slice(0,r)}${n}`}function qr(o,n,r){Ce(n,"offset"),(o[n]===void 0||o[n+r]===void 0)&&$e(n,o.length-(r+1))}function Yt(o,n,r,c,d,h){if(o>r||o<n){let v=typeof n=="bigint"?"n":"",C;throw n===0||n===BigInt(0)?C=`>= 0${v} and < 2${v} ** ${(h+1)*8}${v}`:C=`>= -(2${v} ** ${(h+1)*8-1}${v}) and < 2 ** ${(h+1)*8-1}${v}`,new Se.ERR_OUT_OF_RANGE("value",C,o)}qr(c,d,h)}function Ce(o,n){if(typeof o!="number")throw new Se.ERR_INVALID_ARG_TYPE(n,"number",o)}function $e(o,n,r){throw Math.floor(o)!==o?(Ce(o,r),new Se.ERR_OUT_OF_RANGE("offset","an integer",o)):n<0?new Se.ERR_BUFFER_OUT_OF_BOUNDS:new Se.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,o)}let Gr=/[^+/0-9A-Za-z-_]/g;function jr(o){if(o=o.split("=")[0],o=o.trim().replace(Gr,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function wt(o,n){n=n||1/0;let r,c=o.length,d=null,h=[];for(let v=0;v<c;++v){if(r=o.charCodeAt(v),r>55295&&r<57344){if(!d){if(r>56319){(n-=3)>-1&&h.push(239,191,189);continue}else if(v+1===c){(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 Hr(o){let n=[];for(let r=0;r<o.length;++r)n.push(o.charCodeAt(r)&255);return n}function zr(o,n){let r,c,d,h=[];for(let v=0;v<o.length&&!((n-=2)<0);++v)r=o.charCodeAt(v),c=r>>8,d=r%256,h.push(d),h.push(c);return h}function Kt(o){return u.toByteArray(jr(o))}function tt(o,n,r,c){let d;for(d=0;d<c&&!(d+r>=n.length||d>=o.length);++d)n[d+r]=o[d];return d}function te(o,n){return o instanceof n||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===n.name}function vt(o){return o!==o}let Yr=(function(){let o="0123456789abcdef",n=new Array(256);for(let r=0;r<16;++r){let c=r*16;for(let d=0;d<16;++d)n[c+d]=o[r]+o[d]}return n})();function de(o){return typeof BigInt>"u"?Kr:o}function Kr(){throw new Error("BigInt not supported")}return ge}var De,yr,ot,gr,ge,wr,Ir=oe(()=>{"use strict";y();w();g();De={},yr=!1;ot={},gr=!1;ge={},wr=!1});var we,A,gs,ws,Tr=oe(()=>{"use strict";y();w();g();Ir();we=vr();we.Buffer;we.SlowBuffer;we.INSPECT_MAX_BYTES;we.kMaxLength;A=we.Buffer,gs=we.INSPECT_MAX_BYTES,ws=we.kMaxLength});var w=oe(()=>{"use strict";Tr()});function kt(u){throw new Error("Node.js process "+u+" is not supported by JSPM core outside of Node.js")}function oi(){!Le||!Te||(Le=!1,Te.length?ce=Te.concat(ce):ut=-1,ce.length&&Nr())}function Nr(){if(!Le){var u=setTimeout(oi,0);Le=!0;for(var t=ce.length;t;){for(Te=ce,ce=[];++ut<t;)Te&&Te[ut].run();ut=-1,t=ce.length}Te=null,Le=!1,clearTimeout(u)}}function si(u){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 br(u,t)),ce.length===1&&!Le&&setTimeout(Nr,0)}function br(u,t){this.fun=u,this.array=t}function z(){}function Ei(u){kt("_linkedBinding")}function Ri(u){kt("dlopen")}function Fi(){return[]}function ki(){return[]}function $i(u,t){if(!u)throw new Error(t||"assertion error")}function Wi(){return!1}function oo(){return he.now()/1e3}function Ft(u){var t=Math.floor((Date.now()-he.now())*.001),e=he.now()*.001,i=Math.floor(e)+t,a=Math.floor(e%1*1e9);return u&&(i=i-u[0],a=a-u[1],a<0&&(i--,a+=Rt)),[i,a]}function me(){return Pt}function wo(u){return[]}var ce,Le,Te,ut,ai,ci,ui,pi,li,di,fi,hi,mi,yi,gi,wi,vi,Ii,Ti,xi,Ni,bi,Ai,Bi,Pi,Bt,Si,Ci,Ui,Li,_i,Mi,Di,Oi,Vi,qi,Gi,ji,Hi,zi,Yi,Ki,Ji,Xi,Qi,Zi,eo,to,no,ro,io,he,At,Rt,so,ao,co,uo,po,lo,fo,ho,mo,yo,go,Pt,St=oe(()=>{"use strict";y();w();g();ce=[],Le=!1,ut=-1;br.prototype.run=function(){this.fun.apply(null,this.array)};ai="browser",ci="x64",ui="browser",pi={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},li=["/usr/bin/node"],di=[],fi="v16.8.0",hi={},mi=function(u,t){console.warn((t?t+": ":"")+u)},yi=function(u){kt("binding")},gi=function(u){return 0},wi=function(){return"/"},vi=function(u){},Ii={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};Ti=z,xi=[];Ni={},bi=!1,Ai={};Bi=z,Pi=z,Bt=function(){return{}},Si=Bt,Ci=Bt,Ui=z,Li=z,_i=z,Mi={};Di={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Oi=z,Vi=z;qi=z,Gi=z,ji=z,Hi=z,zi=z,Yi=void 0,Ki=void 0,Ji=void 0,Xi=z,Qi=2,Zi=1,eo="/bin/usr/node",to=9229,no="node",ro=[],io=z,he={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};he.now===void 0&&(At=Date.now(),he.timing&&he.timing.navigationStart&&(At=he.timing.navigationStart),he.now=()=>Date.now()-At);Rt=1e9;Ft.bigint=function(u){var t=Ft(u);return typeof BigInt>"u"?t[0]*Rt+t[1]:BigInt(t[0]*Rt)+BigInt(t[1])};so=10,ao={},co=0;uo=me,po=me,lo=me,fo=me,ho=me,mo=z,yo=me,go=me;Pt={version:fi,versions:hi,arch:ci,platform:ui,release:Ii,_rawDebug:Ti,moduleLoadList:xi,binding:yi,_linkedBinding:Ei,_events:ao,_eventsCount:co,_maxListeners:so,on:me,addListener:uo,once:po,off:lo,removeListener:fo,removeAllListeners:ho,emit:mo,prependListener:yo,prependOnceListener:go,listeners:wo,domain:Ni,_exiting:bi,config:Ai,dlopen:Ri,uptime:oo,_getActiveRequests:Fi,_getActiveHandles:ki,reallyExit:Bi,_kill:Pi,cpuUsage:Bt,resourceUsage:Si,memoryUsage:Ci,kill:Ui,exit:Li,openStdin:_i,allowedNodeEnvironmentFlags:Mi,assert:$i,features:Di,_fatalExceptions:Oi,setUncaughtExceptionCaptureCallback:Vi,hasUncaughtExceptionCaptureCallback:Wi,emitWarning:mi,nextTick:si,_tickCallback:qi,_debugProcess:Gi,_debugEnd:ji,_startProfilerIdleNotifier:Hi,_stopProfilerIdleNotifier:zi,stdout:Yi,stdin:Ji,stderr:Ki,abort:Xi,umask:gi,chdir:vi,cwd:wi,env:pi,title:ai,argv:li,execArgv:di,pid:Qi,ppid:Zi,execPath:eo,debugPort:to,hrtime:Ft,argv0:no,_preload_modules:ro,setSourceMapsEnabled:io}});function vo(){if(Ar)return Ct;Ar=!0;var u=Pt;function t(p){if(typeof p!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(p))}function e(p,s){for(var f="",I=0,x=-1,E=0,T,F=0;F<=p.length;++F){if(F<p.length)T=p.charCodeAt(F);else{if(T===47)break;T=47}if(T===47){if(!(x===F-1||E===1))if(x!==F-1&&E===2){if(f.length<2||I!==2||f.charCodeAt(f.length-1)!==46||f.charCodeAt(f.length-2)!==46){if(f.length>2){var N=f.lastIndexOf("/");if(N!==f.length-1){N===-1?(f="",I=0):(f=f.slice(0,N),I=f.length-1-f.lastIndexOf("/")),x=F,E=0;continue}}else if(f.length===2||f.length===1){f="",I=0,x=F,E=0;continue}}s&&(f.length>0?f+="/..":f="..",I=2)}else f.length>0?f+="/"+p.slice(x+1,F):f=p.slice(x+1,F),I=F-x-1;x=F,E=0}else T===46&&E!==-1?++E:E=-1}return f}function i(p,s){var f=s.dir||s.root,I=s.base||(s.name||"")+(s.ext||"");return f?f===s.root?f+I:f+p+I:I}var a={resolve:function(){for(var s="",f=!1,I,x=arguments.length-1;x>=-1&&!f;x--){var E;x>=0?E=arguments[x]:(I===void 0&&(I=u.cwd()),E=I),t(E),E.length!==0&&(s=E+"/"+s,f=E.charCodeAt(0)===47)}return s=e(s,!f),f?s.length>0?"/"+s:"/":s.length>0?s:"."},normalize:function(s){if(t(s),s.length===0)return".";var f=s.charCodeAt(0)===47,I=s.charCodeAt(s.length-1)===47;return s=e(s,!f),s.length===0&&!f&&(s="."),s.length>0&&I&&(s+="/"),f?"/"+s:s},isAbsolute:function(s){return t(s),s.length>0&&s.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var s,f=0;f<arguments.length;++f){var I=arguments[f];t(I),I.length>0&&(s===void 0?s=I:s+="/"+I)}return s===void 0?".":a.normalize(s)},relative:function(s,f){if(t(s),t(f),s===f||(s=a.resolve(s),f=a.resolve(f),s===f))return"";for(var I=1;I<s.length&&s.charCodeAt(I)===47;++I);for(var x=s.length,E=x-I,T=1;T<f.length&&f.charCodeAt(T)===47;++T);for(var F=f.length,N=F-T,k=E<N?E:N,S=-1,P=0;P<=k;++P){if(P===k){if(N>k){if(f.charCodeAt(T+P)===47)return f.slice(T+P+1);if(P===0)return f.slice(T+P)}else E>k&&(s.charCodeAt(I+P)===47?S=P:P===0&&(S=0));break}var G=s.charCodeAt(I+P),$=f.charCodeAt(T+P);if(G!==$)break;G===47&&(S=P)}var V="";for(P=I+S+1;P<=x;++P)(P===x||s.charCodeAt(P)===47)&&(V.length===0?V+="..":V+="/..");return V.length>0?V+f.slice(T+S):(T+=S,f.charCodeAt(T)===47&&++T,f.slice(T))},_makeLong:function(s){return s},dirname:function(s){if(t(s),s.length===0)return".";for(var f=s.charCodeAt(0),I=f===47,x=-1,E=!0,T=s.length-1;T>=1;--T)if(f=s.charCodeAt(T),f===47){if(!E){x=T;break}}else E=!1;return x===-1?I?"/":".":I&&x===1?"//":s.slice(0,x)},basename:function(s,f){if(f!==void 0&&typeof f!="string")throw new TypeError('"ext" argument must be a string');t(s);var I=0,x=-1,E=!0,T;if(f!==void 0&&f.length>0&&f.length<=s.length){if(f.length===s.length&&f===s)return"";var F=f.length-1,N=-1;for(T=s.length-1;T>=0;--T){var k=s.charCodeAt(T);if(k===47){if(!E){I=T+1;break}}else N===-1&&(E=!1,N=T+1),F>=0&&(k===f.charCodeAt(F)?--F===-1&&(x=T):(F=-1,x=N))}return I===x?x=N:x===-1&&(x=s.length),s.slice(I,x)}else{for(T=s.length-1;T>=0;--T)if(s.charCodeAt(T)===47){if(!E){I=T+1;break}}else x===-1&&(E=!1,x=T+1);return x===-1?"":s.slice(I,x)}},extname:function(s){t(s);for(var f=-1,I=0,x=-1,E=!0,T=0,F=s.length-1;F>=0;--F){var N=s.charCodeAt(F);if(N===47){if(!E){I=F+1;break}continue}x===-1&&(E=!1,x=F+1),N===46?f===-1?f=F:T!==1&&(T=1):f!==-1&&(T=-1)}return f===-1||x===-1||T===0||T===1&&f===x-1&&f===I+1?"":s.slice(f,x)},format:function(s){if(s===null||typeof s!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof s);return i("/",s)},parse:function(s){t(s);var f={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return f;var I=s.charCodeAt(0),x=I===47,E;x?(f.root="/",E=1):E=0;for(var T=-1,F=0,N=-1,k=!0,S=s.length-1,P=0;S>=E;--S){if(I=s.charCodeAt(S),I===47){if(!k){F=S+1;break}continue}N===-1&&(k=!1,N=S+1),I===46?T===-1?T=S:P!==1&&(P=1):T!==-1&&(P=-1)}return T===-1||N===-1||P===0||P===1&&T===N-1&&T===F+1?N!==-1&&(F===0&&x?f.base=f.name=s.slice(1,N):f.base=f.name=s.slice(F,N)):(F===0&&x?(f.name=s.slice(1,T),f.base=s.slice(1,N)):(f.name=s.slice(F,T),f.base=s.slice(F,N)),f.ext=s.slice(T,N)),F>0?f.dir=s.slice(0,F-1):x&&(f.dir="/"),f},sep:"/",delimiter:":",win32:null,posix:null};return a.posix=a,Ct=a,Ct}var Ct,Ar,q,Rr=oe(()=>{"use strict";y();w();g();St();Ct={},Ar=!1;q=vo()});var uu,pu,lu,du,fu,hu,mu,yu,gu,wu,vu,Iu,Tu,xu,Eu,Fr=oe(()=>{"use strict";y();w();g();Rr();St();uu=q._makeLong,pu=q.basename,lu=q.delimiter,du=q.dirname,fu=q.extname,hu=q.format,mu=q.isAbsolute,yu=q.join,gu=q.normalize,wu=q.parse,vu=q.posix,Iu=q.relative,Tu=q.resolve,xu=q.sep,Eu=q.win32});y();w();g();y();w();g();y();w();g();y();w();g();function U(u){throw new Error("Unexpected value: "+JSON.stringify(u))}y();w();g();function Oe(u){return Object.keys(u)}y();w();g();y();w();g();y();w();g();var Ve=b.env.FERN_STACK_TRACK?.toLowerCase()??"",ne=Ve!==""&&Ve!=="0"&&Ve!=="false",Et=["single","multiline","box"].includes(Ve)?Ve:"single";ne&&(Error.stackTraceLimit=50);var ei=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),ti=new Set(["stacktrace"]);function at({maxFrames:u=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:p=!0,filterJs:s=!0,formatFilename:f=I=>I}={}){if(!ne)return[];i=[...i,...ei],e=[...e,...ti],a=[...a,"runInteractiveTask"];let I=!1;return(new Error().stack??"").split(`
|
|
2
2
|
`).map(x=>{let E=x.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(E&&E.length===5){let[,T,F,N,k]=E;if(!T||!F||!N||!k)return;if(I||a.some(S=>T?.includes(S))){I=!0;return}switch(T){case"Object.<anonymous>":T="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":T=`${T.substring(T.indexOf(".")+1)}()=> { ... }`;break}return{fn:T,path:f(F),position:`${N}:${k}`}}}).filter(x=>x&&!i.some(E=>x.fn.includes(E))&&!(p&&x.path?.startsWith("node:"))&&!(s&&x.path?.endsWith(".js"))&&!e.some(E=>x.path.includes(E))).slice(t,t+u)}var st=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:i=[],filterFunctions:a=[],stopOn:p=[],filterNode:s=!0,filterJs:f=!0,multiline:I=!1,formatFilename:x=E=>E}={}){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=a,this.stopOn=p,this.filterNode=s,this.filterJs=f,this.multiline=I,this.formatFilename=x}tag(t){let e=this.tracking.get(t)||new Set;at({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(!ne)return"";let e=this.tracking.get(t);return e?[...e].map(i=>`${this.multiline?`
|
|
3
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}},Nt;function xr({maxFrames:u=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:p=!0,filterJs:s=!0,multiline:f=!1,formatFilename:I=x=>x}={}){ne&&(Nt??(Nt=new st({maxFrames:u,skip:t,filterPaths:e,filterFunctions:i,stopOn:a,filterNode:p,filterJs:s,multiline:f,formatFilename:I})))}function Er(u){Nt?.tag(u)}function bt(u){return Nt?.frames(u)??[]}var ve=class{constructor(){Er(this)}};y();w();g();var ct=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},We=class extends ct{async format(t){return t}formatSync(t){return t}};y();w();g();y();w();g();y();w();g();var Z=class extends ve{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 ni=4;xr({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var qe=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 ne&&this.nodeStackFrames.length>0&&this.writeInternal(`
|
|
4
4
|
`),this.lineBuffer.join(`
|
|
@@ -21,9 +21,9 @@ ${t}`)}return t}getContent(){let t=`package ${this.packageName}
|
|
|
21
21
|
${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.imports).filter(([e,i])=>e!==this.importPath).map(([e,i])=>` ${i} "${e}"`).join(`
|
|
22
22
|
`);return t?`import (
|
|
23
23
|
${t}
|
|
24
|
-
)`:""}};var
|
|
24
|
+
)`:""}};var l={};Xt(l,{Alias:()=>xe,AstNode:()=>B,CodeBlock:()=>ie,Enum:()=>Ee,Field:()=>Ne,File:()=>be,Func:()=>Ae,FuncInvocation:()=>ee,IoReaderTypeReference:()=>Ut,Method:()=>le,MethodInvocation:()=>pe,MultiNode:()=>Xe,Parameter:()=>Re,Pointer:()=>Fe,Selector:()=>ke,Struct:()=>Be,TimeTypeReference:()=>pt,Type:()=>Ze,TypeDeclaration:()=>Pe,TypeInstantiation:()=>K,TypeReference:()=>J,UuidTypeReference:()=>lt,Writer:()=>Ie,alias:()=>Po,codeblock:()=>So,enum_:()=>Co,field:()=>Uo,file:()=>Lo,func:()=>_o,identifier:()=>Mo,invokeFunc:()=>$o,invokeMethod:()=>Do,method:()=>Oo,parameter:()=>Vo,pointer:()=>Wo,selector:()=>qo,struct:()=>Go,switch_:()=>jo,typeDeclaration:()=>Ho,typeReference:()=>zo});y();w();g();y();w();g();y();w();g();y();w();g();y();w();g();var B=class extends ve{async toStringAsync({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p}){let s=new Je({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p});return this.write(s),s.toStringAsync()}toString({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p}){let s=new Je({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p});return this.write(s),s.toString()}};var j=class extends B{constructor({docs:e}={}){super();m(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
25
25
|
`).forEach(i=>{e.writeLine(`// ${i}`)})}};var xe=class extends B{constructor({name:e,type:i,docs:a}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=a}write(e){e.writeNode(new j({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};y();w();g();var ie=class extends B{constructor(e){super();m(this,"arg");this.arg=e}write(e){return new Z(this.arg).write(e)}};y();w();g();y();w();g();var ue=class extends B{constructor(e){super();m(this,"name");this.name=e}write(e){e.write(this.name)}};y();w();g();y();w();g();y();w();g();function _e({writer:u,arguments_:t,multiline:e=!0}){let i=t.map(a=>a instanceof K&&K.isNop(a)?K.nil():a);if(i.length===0){u.write("()");return}if(e){Io({writer:u,arguments_:i});return}To({writer:u,arguments_:i})}function Io({writer:u,arguments_:t}){u.writeLine("("),u.indent();for(let e of t)e.write(u),u.writeLine(",");u.dedent(),u.write(")")}function To({writer:u,arguments_:t}){u.write("("),t.forEach((e,i)=>{i>0&&u.write(", "),e.write(u)}),u.write(")")}var ee=class extends B{constructor({func:e,arguments_:i,multiline:a=!0}){super();m(this,"func");m(this,"arguments_");m(this,"multiline");this.func=e,this.arguments_=i,this.multiline=a}write(e){e.writeNode(this.func),_e({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};y();w();g();y();w();g();function kr({writer:u,generics:t}){t.length!==0&&(u.write("["),t.forEach((e,i)=>{i>0&&u.write(", "),e!=null&&u.writeNode(e)}),u.write("]"))}var J=class extends B{constructor({name:e,importPath:i,generics:a}){super();m(this,"name");m(this,"importPath");m(this,"generics");this.name=e,this.importPath=i,this.generics=a}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&&kr({writer:e,generics:this.generics})}};y();w();g();var pe=class extends B{constructor({method:e,arguments_:i,on:a,multiline:p}){super();m(this,"on");m(this,"method");m(this,"arguments_");m(this,"multiline");this.on=a,this.method=e,this.arguments_=i,this.multiline=p}write(e){this.on.write(e),e.write("."),e.write(this.method),_e({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};var xo=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),Br=new Set(["any","bytes","map","slice"]),K=class u extends B{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":case"int64":e.write(this.internalType.value.toString());break;case"map":this.writeMap({writer:e,map:this.internalType});break;case"nil":e.write("nil");break;case"nop":break;case"optional":this.writeOptional({writer:e,type:this.internalType.value});break;case"reference":e.writeNode(this.internalType.value);break;case"slice":this.writeSlice({writer:e,slice:this.internalType});break;case"string":e.write(this.internalType.value.includes('"')||this.internalType.value.includes(`
|
|
26
|
-
`)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(Ao({value:this.internalType.value}));break;default:U(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:a}){return new this({type:"map",keyType:e,valueType:i,entries:a})}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:a}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:i,generics:a})})}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('"')?`\`${i}\``:`"${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 a of i)e.writeNode(u.any(a)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:i}){e.write("map[string]any");let a=Object.entries(i);if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[p,s]of a)e.write(`"${p}": `),e.writeNode(u.any(s)),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 a=Ro({entries:i.entries});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let p of a)p.key.write(e),e.write(": "),p.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:i}){if(xo.has(i.internalType.type)){e.writeNode(Eo({writer:e,type:i}));return}if(Br.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"||Br.has(e.internalType.type)}writeSlice({writer:e,slice:i}){e.write("[]"),e.writeNode(i.valueType);let a=ko({values:i.values});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let p of a)p.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((p,s)=>{s>0&&e.write(", "),e.writeNode(p)}),e.write("]"));let a=Fo({fields:i.fields});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let p of a)e.write(`${p.name}: `),p.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Eo({writer:u,type:t}){return new ee({func:new J({name:No({type:t}),importPath:u.rootImportPath}),arguments_:[t]})}function No({type:u}){switch(u.internalType.type){case"bool":return"Bool";case"date":case"dateTime":return"Time";case"float64":return"Float64";case"int":return"Int";case"int64":return"Int64";case"string":return"String";case"uuid":return"UUID";default:return""}}function bo({writer:u,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new ee({func:new J({name:e,importPath:u.rootImportPath}),arguments_:[new ie(`"${t.value}"`)]})}function Ao({value:u}){return new ee({func:new J({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new ie(`"${u}"`)]})}function Ro({entries:u}){return u.filter(t=>!K.isNop(t.key)&&!K.isNop(t.value))}function Fo({fields:u}){return u.filter(t=>!K.isNop(t.value))}function ko({values:u}){return u.filter(t=>!K.isNop(t))}var Ee=class u extends B{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(u.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();w();g();var Ne=class extends B{constructor({name:e,type:i,docs:a,tags:p}){super();m(this,"name");m(this,"type");m(this,"docs");m(this,"tags",[]);this.name=e,this.type=i,this.docs=a,this.tags=p??[]}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,a)=>{a>0&&e.write(" "),e.write(`${i.name}:"${i.value}"`)}),e.write("`"))}};y();w();g();var be=class extends B{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();w();g();y();w();g();var le=class extends B{constructor({name:e,parameters:i,return_:a,body:p,docs:s,typeReference:f,multiline:I,receiver:x,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_=a,this.body=p,this.docs=s,this.typeReference=f,this.multiline=I,this.receiver=x,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,a)=>{a>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:a}){e.write(` (${this.getReceiverName({typeReference:i,receiver:a})} `),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 B{constructor({name:e,parameters:i,return_:a,body:p,docs:s,multiline:f}){super();m(this,"func");this.func=new le({name:e,parameters:i,return_:a,body:p,docs:s,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();w();g();var Xe=class extends B{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();w();g();var Re=class extends B{constructor({name:e,type:i,docs:a}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=a}write(e){e.writeNode(new j({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};y();w();g();var Fe=class extends B{constructor({node:e}){super();m(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};y();w();g();var ke=class extends B{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();w();g();var Be=class extends B{constructor({name:e,embeds:i,fields:a,docs:p}){super();m(this,"name");m(this,"embeds",[]);m(this,"fields",[]);m(this,"docs");m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=p,this.embeds=i??[],this.fields=a??[]}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 p of this.embeds)e.writeNode(p),e.newLine();let i=this.fields.filter(p=>this.isExported(p));for(let p of i)e.writeNode(p),e.newLine();let a=this.fields.filter(p=>!this.isExported(p));i.length>0&&a.length>0&&e.newLine();for(let p of a)e.writeNode(p),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((a,p)=>{p>0&&e.write(", "),e.writeNode(a)}),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();w();g();var Qe=class extends B{constructor({on:e,cases:i,default:a}){super();m(this,"on");m(this,"cases");m(this,"default");this.on=e,this.cases=i,this.default=a}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 a of i)e.write("case "),e.writeNode(a.on),e.writeLine(":"),e.indent(),e.writeNode(a.body),e.dedent(),e.writeNewLineIfLastLineNot();e.dedent(),e.write("}")}};y();w();g();var Bo=new Set(["any","bytes","map","slice"]),Ze=class u extends B{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(pt);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(lt);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 u.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"||Bo.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},pt=new J({importPath:"time",name:"Time"}),lt=new J({importPath:"github.com/google/uuid",name:"UUID"}),Ut=new J({importPath:"io",name:"Reader"});y();w();g();var Pe=class extends B{constructor({name:e,type:i,docs:a}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=a}write(e){e.writeNode(new j({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function Po(u){return new xe(u)}function So(u){return new ie(u)}function Co(u){return new Ee(u)}function Uo(u){return new Ne(u)}function Lo(u={}){return new be(u)}function _o(u){return new Ae(u)}function Mo(u){return new ue(u)}function $o(u){return new ee(u)}function Do(u){return new pe(u)}function Oo(u){return new le(u)}function Vo(u){return new Re(u)}function Wo(u){return new Fe(u)}function qo(u){return new ke(u)}function Go(u={}){return new Be(u)}function jo(u){return new Qe(u)}function Ho(u){return new Pe(u)}function zo(u){return new J(u)}y();w();g();var Yo=new Set(["string"]);function Lt(u){if(u==="")return"Underscore";let t=u;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)),Yo.has(e.toLowerCase())?"Field"+e:e}y();w();g();Fr();var Ko="sdk";function _t({config:u,customConfig:t}){let e=Xo({config:u}),i=Jo({config:u,customConfig:t});return e!=null?Zo({importPath:i,majorVersion:e}):i}function Jo({config:u,customConfig:t,isModulePath:e=!1}){let i=t?.importPath??t?.module?.path??(u.output.mode.type==="github"?es(u.output.mode.repoUrl,"https://"):Ko);return e?i:q.join(i,t?.packagePath??"")}function Xo({config:u}){let t=Qo({config:u});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Qo({config:u}){let t=ts(u);if(t==null)return;let e=t.split(".");if(e[0]==null)return;let i=e[0];return i.startsWith("v")?i:`v${i}`}function Zo({importPath:u,majorVersion:t}){return Ke(u)===t?u:`${u}/${t}`}function es(u,t){return u.startsWith(t)?u.slice(t.length):u}function ts(u){let t=u?.output?.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}y();w();g();var dt=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 d.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return d.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?d.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 a=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),p=this.context.getTypeName(i.declaration.name),s=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:p,aliasImportPath:s})}}return d.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 a=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),p=this.context.getTypeName(i.declaration.name),s=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:p,aliasImportPath:s})}}return d.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);switch(t.typeReference.type){case"named":return this.context.resolveNamedType({typeId:t.typeReference.value})?.type==="enum"?d.TypeInstantiation.reference(d.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e;default:return e}}convertList({list:t,value:e}){return Array.isArray(e)?d.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:t}),values:e.map((i,a)=>{this.context.errors.scope({index:a});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}`}),d.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}`}),d.TypeInstantiation.nop()):d.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries:Object.entries(e).map(([i,a])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:t.key,value:i,as:"key"}),value:this.convert({typeReference:t.value,value:a})}}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}){switch(t.typeReference.type){case"literal":return d.TypeInstantiation.reference(d.invokeFunc({func:d.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(t.typeReference.value)]}));default:return this.convert({typeReference:t.typeReference,value:e,as:i})}}reconstructAliasCollectionLiteral({collectionLiteral:t,aliasName:e,aliasImportPath:i}){let a=t.internalType;return a.type==="slice"?d.TypeInstantiation.reference(d.codeblock(p=>{p.write("&"),p.writeNode(d.typeReference({name:e,importPath:i}));let s=a.values;if(s.length===0){p.write("{}");return}p.writeLine("{"),p.indent();for(let f of s)p.writeNode(f),p.writeLine(",");p.dedent(),p.write("}")})):a.type==="map"?d.TypeInstantiation.reference(d.codeblock(p=>{p.write("&"),p.writeNode(d.typeReference({name:e,importPath:i}));let s=a.entries;if(s.length===0){p.write("{}");return}p.writeLine("{"),p.indent();for(let f of s)p.writeNode(f.key),p.write(": "),p.writeNode(f.value),p.writeLine(",");p.dedent(),p.write("}")})):d.TypeInstantiation.reference(d.codeblock(p=>{p.write("&"),p.writeNode(t)}))}convertLiteralValue(t){switch(t.type){case"boolean":return d.TypeInstantiation.bool(t.value);case"string":return d.TypeInstantiation.string(t.value);default:U(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let i=this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),a=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(a==null)return d.TypeInstantiation.nop();let p=a.singleDiscriminatedUnionType,s=this.getBaseFields({discriminatedUnionTypeInstance:a,singleDiscriminatedUnionType:p});switch(p.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:p.typeId});return f==null?d.TypeInstantiation.nop():d.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(p.discriminantValue.name),value:this.convertNamed({named:f,value:a.value})},...s]})}case"singleProperty":{let f=this.context.getRecord(a.value);if(f==null)return d.TypeInstantiation.nop();try{return this.context.errors.scope(p.discriminantValue.wireValue),d.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(p.discriminantValue.name),value:this.convert({typeReference:p.typeReference,value:f[p.discriminantValue.wireValue]})},...s]})}finally{this.context.errors.unscope()}}case"noProperties":return d.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(a.discriminantValue.name),value:d.TypeInstantiation.string(p.discriminantValue.wireValue)},...s]});default:U(p)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getFieldName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}})}convertObject({object_:t,value:e}){let i=this.context.associateByWireValue({parameters:t.properties,values:this.context.getRecord(e)??{}});return d.TypeInstantiation.structPointer({typeReference:d.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:i.map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getFieldName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:t,value:e}){let i=this.getEnumValueName({enum_:t,value:e});return i==null?d.TypeInstantiation.nop():d.TypeInstantiation.enum(d.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(a=>a.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 d.TypeInstantiation.nop();let a=this.getUndiscriminatedUnionFieldName({typeReference:i.valueTypeReference});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),fields:[{name:a,value:i.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let i of t.types)try{let a=this.convert({typeReference:i,value:e});return{valueTypeReference:i,typeInstantiation:a}}catch{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});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});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Set`}getUndiscriminatedUnionFieldNameForLiteral({literal:t}){switch(t.type){case"boolean":return t.value?"TrueLiteral":"FalseLiteral";case"string":return`${t.value}StringLiteral`;default: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":return"DateTime";case"BASE_64":return"Base64";default:U(t)}}convertUnknown({value:t}){return d.TypeInstantiation.any(t)}convertPrimitive({primitive:t,value:e,as:i}){switch(t){case"INTEGER":case"UINT":{let a=this.getValueAsNumber({value:e,as:i});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.int(a)}case"LONG":case"UINT_64":{let a=this.getValueAsNumber({value:e,as:i});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.int64(a)}case"FLOAT":case"DOUBLE":{let a=this.getValueAsNumber({value:e,as:i});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.float64(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:e,as:i});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.bool(a)}case"STRING":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.string(a)}case"DATE":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.date(a)}case"DATE_TIME":{let a=this.context.getValueAsString({value:e});if(a==null)return d.TypeInstantiation.nop();let p=this.normalizeDateTimeString(a);return d.TypeInstantiation.dateTime(p)}case"UUID":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.uuid(a)}case"BASE_64":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.bytes(a)}case"BIG_INTEGER":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.string(a)}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();w();g();var ft=class{constructor({context:t}){m(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return d.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return d.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 d.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return d.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return d.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:U(t.typeReference)}}convertLiteral({literal:t}){switch(t.type){case"boolean":return d.Type.bool();case"string":return d.Type.string()}}convertNamed({named:t}){let e=d.Type.reference(d.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 d.Type.pointer(e);default:U(t)}}convertUnknown(){return d.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return d.Type.int();case"UINT":return d.Type.int();case"LONG":return d.Type.int64();case"UINT_64":return d.Type.int64();case"FLOAT":return d.Type.float64();case"DOUBLE":return d.Type.float64();case"BOOLEAN":return d.Type.bool();case"STRING":return d.Type.string();case"DATE":return d.Type.date();case"DATE_TIME":return d.Type.dateTime();case"UUID":return d.Type.uuid();case"BASE_64":return d.Type.bytes();case"BIG_INTEGER":return d.Type.string();default:U(t)}}};y();w();g();var ht=class{constructor({context:t}){m(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){let i={fileFields:[],bodyPropertyFields:[]},a=this.context.getRecord(e)??{};for(let p of t.properties)switch(p.type){case"file":i.fileFields.push({name:this.context.getFieldName(p.name),value:this.getSingleFileProperty({property:p,record:a})});break;case"fileArray":i.fileFields.push({name:this.context.getFieldName(p.name),value:this.getArrayFileProperty({property:p,record:a})});break;case"bodyProperty":i.bodyPropertyFields.push({name:this.context.getFieldName(p.name.name),value:this.getBodyProperty({property:p,record:a})});break;default:U(p)}return i}getSingleFileProperty({property:t,record:e}){let i=this.context.getSingleFileValue({property:t,record:e})||"";return d.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i))}getArrayFileProperty({property:t,record:e}){let i=this.context.getFileArrayValues({property:t,record:e});return i==null?d.TypeInstantiation.nop():d.TypeInstantiation.slice({valueType:d.Type.reference(this.context.getIoReaderTypeReference()),values:i.map(a=>d.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(a)))})}getBodyProperty({property:t,record:e}){let i=e[t.name.wireValue];return i==null?d.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:i})}};var mt=class u extends Ye{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,this.customConfig=i.customConfig!=null?i.customConfig:void 0,this.dynamicTypeMapper=new ft({context:this}),this.dynamicTypeInstantiationMapper=new dt({context:this}),this.filePropertyMapper=new ht({context:this}),this.rootImportPath=_t({config:i,customConfig:this.customConfig})}clone(){return new u({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 Lt(e.pascalCase.unsafeName)}getImportPath(e){let i=e.packagePath.map(a=>a.pascalCase.unsafeName.toLowerCase());return[this.rootImportPath,...i].join("/")}getImportPathForRequest(e){return this.customConfig?.exportAllRequestsAtRoot?this.rootImportPath:this.getImportPath(e)}getContextTypeReference(){return d.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return d.invokeFunc({func:d.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return d.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return d.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return d.invokeFunc({func:d.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[d.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 d.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 d.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}static chainMethods(e,...i){if(i.length===0)throw new Error("Must have methods to chain");let a=e;for(let p of i)a=d.invokeMethod({on:a,method:p.method,arguments_:p.arguments_,multiline:p.multiline});return a}};y();w();g();var Pr="example",Mt="fern",ns="do",et="client",Me=d.TypeInstantiation,rs="WireMockBaseURL",is="WireMockClient",yt=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:Pr,importPath:Mt,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:Pr,importPath:Mt,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:Mt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return d.codeblock(i=>{i.writeNode(d.func({name:ns,parameters:[],return_:[],body:d.codeblock(a=>{a.writeNode(this.constructClient({endpoint:t,snippet:e})),a.writeLine(),a.writeNode(this.callMethod({endpoint:t,snippet:e}))})})),i.writeNewLineIfLastLineNot()})}buildWiremockTestCodeBlock({endpoint:t,snippet:e}){return d.codeblock(i=>{i.writeNode(d.func({name:"Test"+this.context.getTestMethodName(t)+"WithWireMock",parameters:[d.parameter({name:"t",type:d.Type.pointer(d.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:d.codeblock(a=>{for(let p of this.buildWiremockTestSetup({endpoint:t}))a.writeNode(p),a.writeLine();a.writeLine(),a.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),a.writeLine(),a.writeNode(this.callClientMethodAndAssert({endpoint:t,snippet:e}))})})),i.writeNewLineIfLastLineNot()})}constructClient({endpoint:t,snippet:e}){return d.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}constructWiremockTestClient({endpoint:t,snippet:e}){return d.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:t,endpoint:e,snippet:i}){let{otherArgs:a,requestArg:p}=this.getMethodArgs({endpoint:e,snippet:i});if(p!=null)if(p instanceof d.TypeInstantiation&&d.TypeInstantiation.isNop(p))t.writeNode(d.invokeMethod({on:d.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...a,d.codeblock("nil")]}));else{t.write("request := "),t.writeNode(p),t.writeLine();let s=d.codeblock("request");t.writeNode(d.invokeMethod({on:d.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...a,s]}))}else t.writeNode(d.invokeMethod({on:d.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...a]}))}callMethod({endpoint:t,snippet:e}){return d.codeblock(i=>{this.writeMethodInvocation({writer:i,endpoint:t,snippet:e})})}getConstructorArgs({endpoint:t,snippet:e}){let i=[],a=this.getConstructorBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return a!=null&&i.push(a),t.auth!=null&&(e.auth!=null?i.push(this.getConstructorAuthArg({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[d.codeblock(t=>{t.writeNode(d.invokeFunc({func:d.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[d.codeblock(rs)]}))})]}getConstructorAuthArg({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),Me.nop();switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArg({auth:t,values:e}):Me.nop();case"bearer":return e.type==="bearer"?this.getConstructorBearerAuthArg({auth:t,values:e}):Me.nop();case"header":return e.type==="header"?this.getConstructorHeaderAuthArg({auth:t,values:e}):Me.nop();case"oauth":return e.type==="oauth"?this.getConstructorOAuthAuthArg({values:e}):Me.nop();case"inferred":return this.addWarning("The Go SDK Generator does not support Inferred auth scheme yet"),Me.nop();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})}getConstructorBasicAuthArg({auth:t,values:e}){return d.codeblock(i=>{i.writeNode(d.invokeFunc({func:d.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[d.TypeInstantiation.string(e.username),d.TypeInstantiation.string(e.password)]}))})}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let i=this.getBaseUrlArg({baseUrl:t,environment:e});if(i!=null)return d.codeblock(a=>{a.writeNode(d.invokeFunc({func:d.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 d.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 d.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 d.codeblock(i=>{i.writeNode(d.invokeFunc({func:d.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[d.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return d.codeblock(i=>{i.writeNode(d.invokeFunc({func:d.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 d.codeblock(e=>{e.writeNode(d.invokeFunc({func:d.typeReference({name:"WithClientCredentials",importPath:this.context.getOptionImportPath()}),arguments_:[d.TypeInstantiation.string(t.clientId),d.TypeInstantiation.string(t.clientSecret)]}))})}getConstructorHeaderArgs({headers:t,values:e}){let i=[];for(let a of t){let p=this.getConstructorHeaderArg({header:a,value:e.value});p!=null&&i.push(p)}return i}getConstructorHeaderArg({header:t,value:e}){let i=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!d.TypeInstantiation.isNop(i))return d.codeblock(a=>{a.writeNode(d.invokeFunc({func:d.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 a=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];a.length>0&&i.push(...this.getPathParameters({namedParameters:a,snippet:e}).map(s=>s.value)),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let p=t.body!=null?this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:i,requestArg:p}}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:U(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:L.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),d.TypeInstantiation.nop()):d.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[],{inlinePathParameters:a,inlineFileProperties:p}={inlinePathParameters:this.context.customConfig?.inlinePathParameters??!0,inlineFileProperties:this.context.customConfig?.inlineFileProperties??!0};this.context.errors.scope(re.PathParameters);let s=[],f=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];f.length>0&&s.push(...this.getPathParameters({namedParameters:f,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let I=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})||i.push(...s.map(E=>E.value)),p||i.push(...I.fileFields.map(E=>E.value));let x=this.context.needsRequestParameter({request:t,inlinePathParameters:a,inlineFileProperties:p})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})?s:[],filePropertyInfo:I}):void 0;return{otherArgs:i,requestArg:x}}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:a}){this.context.errors.scope(re.QueryParameters);let s=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 I=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 x=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),d.TypeInstantiation.structPointer({typeReference:d.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPathForRequest(t.declaration.fernFilepath)}),fields:[...i,...s,...I,...x]})}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?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyStructField({body:t,value:e}){return{name:this.context.getTypeName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeInstantiation({body:t.bodyType,value:e})}}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:U(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){let i=[],a=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}});for(let p of a)i.push({name:this.context.getTypeName(p.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(p)});return i}getPathParameters({namedParameters:t,snippet:e}){let i=[],a=this.context.associateByWireValue({parameters:t,values:e.pathParameters??{}});for(let p of a)i.push({name:this.context.getTypeName(p.name.name),value:this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(p)});return i}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 d.invokeFunc({func:d.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}){return d.codeblock(i=>{this.writeMethodInvocation({writer:i,endpoint:t,snippet:e}),i.writeLine(),i.writeLine(),i.write("ok, countErr := "),i.writeNode(d.invokeMethod({on:d.codeblock(is),method:"Verify",arguments_:[d.invokeMethod({on:d.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),d.codeblock("1")],multiline:!1})),i.writeLine(),i.writeNode(d.invokeFunc({func:d.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[d.codeblock("t"),d.codeblock("countErr"),d.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),i.writeLine(),i.writeNode(d.invokeFunc({func:d.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[d.codeblock("t"),d.codeblock("ok"),d.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),i.writeLine()})}};var $t=class extends je{constructor({ir:e,config:i,formatter:a}){super(new mt({ir:e,config:i}));m(this,"formatter");this.formatter=a}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 yt({context:e,formatter:this.formatter})}};export{$t as DynamicSnippetsGenerator};
|
|
26
|
+
`)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(Ao({value:this.internalType.value}));break;default:U(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:a}){return new this({type:"map",keyType:e,valueType:i,entries:a})}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:a}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:i,generics:a})})}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('"')?`\`${i}\``:`"${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 a of i)e.writeNode(u.any(a)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:i}){e.write("map[string]any");let a=Object.entries(i);if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[p,s]of a)e.write(`"${p}": `),e.writeNode(u.any(s)),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 a=Ro({entries:i.entries});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let p of a)p.key.write(e),e.write(": "),p.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:i}){if(xo.has(i.internalType.type)){e.writeNode(Eo({writer:e,type:i}));return}if(Br.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"||Br.has(e.internalType.type)}writeSlice({writer:e,slice:i}){e.write("[]"),e.writeNode(i.valueType);let a=ko({values:i.values});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let p of a)p.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((p,s)=>{s>0&&e.write(", "),e.writeNode(p)}),e.write("]"));let a=Fo({fields:i.fields});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let p of a)e.write(`${p.name}: `),p.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Eo({writer:u,type:t}){return new ee({func:new J({name:No({type:t}),importPath:u.rootImportPath}),arguments_:[t]})}function No({type:u}){switch(u.internalType.type){case"bool":return"Bool";case"date":case"dateTime":return"Time";case"float64":return"Float64";case"int":return"Int";case"int64":return"Int64";case"string":return"String";case"uuid":return"UUID";default:return""}}function bo({writer:u,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new ee({func:new J({name:e,importPath:u.rootImportPath}),arguments_:[new ie(`"${t.value}"`)]})}function Ao({value:u}){return new ee({func:new J({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new ie(`"${u}"`)]})}function Ro({entries:u}){return u.filter(t=>!K.isNop(t.key)&&!K.isNop(t.value))}function Fo({fields:u}){return u.filter(t=>!K.isNop(t.value))}function ko({values:u}){return u.filter(t=>!K.isNop(t))}var Ee=class u extends B{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(u.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();w();g();var Ne=class extends B{constructor({name:e,type:i,docs:a,tags:p}){super();m(this,"name");m(this,"type");m(this,"docs");m(this,"tags",[]);this.name=e,this.type=i,this.docs=a,this.tags=p??[]}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,a)=>{a>0&&e.write(" "),e.write(`${i.name}:"${i.value}"`)}),e.write("`"))}};y();w();g();var be=class extends B{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();w();g();y();w();g();var le=class extends B{constructor({name:e,parameters:i,return_:a,body:p,docs:s,typeReference:f,multiline:I,receiver:x,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_=a,this.body=p,this.docs=s,this.typeReference=f,this.multiline=I,this.receiver=x,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,a)=>{a>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:a}){e.write(` (${this.getReceiverName({typeReference:i,receiver:a})} `),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 B{constructor({name:e,parameters:i,return_:a,body:p,docs:s,multiline:f}){super();m(this,"func");this.func=new le({name:e,parameters:i,return_:a,body:p,docs:s,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();w();g();var Xe=class extends B{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();w();g();var Re=class extends B{constructor({name:e,type:i,docs:a}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=a}write(e){e.writeNode(new j({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};y();w();g();var Fe=class extends B{constructor({node:e}){super();m(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};y();w();g();var ke=class extends B{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();w();g();var Be=class extends B{constructor({name:e,embeds:i,fields:a,docs:p}){super();m(this,"name");m(this,"embeds",[]);m(this,"fields",[]);m(this,"docs");m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=p,this.embeds=i??[],this.fields=a??[]}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 p of this.embeds)e.writeNode(p),e.newLine();let i=this.fields.filter(p=>this.isExported(p));for(let p of i)e.writeNode(p),e.newLine();let a=this.fields.filter(p=>!this.isExported(p));i.length>0&&a.length>0&&e.newLine();for(let p of a)e.writeNode(p),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((a,p)=>{p>0&&e.write(", "),e.writeNode(a)}),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();w();g();var Qe=class extends B{constructor({on:e,cases:i,default:a}){super();m(this,"on");m(this,"cases");m(this,"default");this.on=e,this.cases=i,this.default=a}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 a of i)e.write("case "),e.writeNode(a.on),e.writeLine(":"),e.indent(),e.writeNode(a.body),e.dedent(),e.writeNewLineIfLastLineNot();e.dedent(),e.write("}")}};y();w();g();var Bo=new Set(["any","bytes","map","slice"]),Ze=class u extends B{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(pt);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(lt);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 u.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"||Bo.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},pt=new J({importPath:"time",name:"Time"}),lt=new J({importPath:"github.com/google/uuid",name:"UUID"}),Ut=new J({importPath:"io",name:"Reader"});y();w();g();var Pe=class extends B{constructor({name:e,type:i,docs:a}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=a}write(e){e.writeNode(new j({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function Po(u){return new xe(u)}function So(u){return new ie(u)}function Co(u){return new Ee(u)}function Uo(u){return new Ne(u)}function Lo(u={}){return new be(u)}function _o(u){return new Ae(u)}function Mo(u){return new ue(u)}function $o(u){return new ee(u)}function Do(u){return new pe(u)}function Oo(u){return new le(u)}function Vo(u){return new Re(u)}function Wo(u){return new Fe(u)}function qo(u){return new ke(u)}function Go(u={}){return new Be(u)}function jo(u){return new Qe(u)}function Ho(u){return new Pe(u)}function zo(u){return new J(u)}y();w();g();var Yo=new Set(["string"]);function Lt(u){if(u==="")return"Underscore";let t=u;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)),Yo.has(e.toLowerCase())?"Field"+e:e}y();w();g();Fr();var Ko="sdk";function _t({config:u,customConfig:t}){let e=Xo({config:u}),i=Jo({config:u,customConfig:t});return e!=null?Zo({importPath:i,majorVersion:e}):i}function Jo({config:u,customConfig:t,isModulePath:e=!1}){let i=t?.importPath??t?.module?.path??(u.output.mode.type==="github"?es(u.output.mode.repoUrl,"https://"):Ko);return e?i:q.join(i,t?.packagePath??"")}function Xo({config:u}){let t=Qo({config:u});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Qo({config:u}){let t=ts(u);if(t==null)return;let e=t.split(".");if(e[0]==null)return;let i=e[0];return i.startsWith("v")?i:`v${i}`}function Zo({importPath:u,majorVersion:t}){return Ke(u)===t?u:`${u}/${t}`}function es(u,t){return u.startsWith(t)?u.slice(t.length):u}function ts(u){let t=u?.output?.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}y();w();g();var dt=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 a=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),p=this.context.getTypeName(i.declaration.name),s=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:p,aliasImportPath:s})}}return 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 a=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),p=this.context.getTypeName(i.declaration.name),s=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:p,aliasImportPath:s})}}return 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);switch(t.typeReference.type){case"named":return this.context.resolveNamedType({typeId:t.typeReference.value})?.type==="enum"?l.TypeInstantiation.reference(l.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e;default:return e}}convertList({list:t,value:e}){return Array.isArray(e)?l.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:t}),values:e.map((i,a)=>{this.context.errors.scope({index:a});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).map(([i,a])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:t.key,value:i,as:"key"}),value:this.convert({typeReference:t.value,value:a})}}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}){switch(t.typeReference.type){case"literal":return 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)]}));default:return this.convert({typeReference:t.typeReference,value:e,as:i})}}reconstructAliasCollectionLiteral({collectionLiteral:t,aliasName:e,aliasImportPath:i}){let a=t.internalType;return a.type==="slice"?l.TypeInstantiation.reference(l.codeblock(p=>{p.write("&"),p.writeNode(l.typeReference({name:e,importPath:i}));let s=a.values;if(s.length===0){p.write("{}");return}p.writeLine("{"),p.indent();for(let f of s)p.writeNode(f),p.writeLine(",");p.dedent(),p.write("}")})):a.type==="map"?l.TypeInstantiation.reference(l.codeblock(p=>{p.write("&"),p.writeNode(l.typeReference({name:e,importPath:i}));let s=a.entries;if(s.length===0){p.write("{}");return}p.writeLine("{"),p.indent();for(let f of s)p.writeNode(f.key),p.write(": "),p.writeNode(f.value),p.writeLine(",");p.dedent(),p.write("}")})):l.TypeInstantiation.reference(l.codeblock(p=>{p.write("&"),p.writeNode(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)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let i=this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),a=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(a==null)return l.TypeInstantiation.nop();let p=a.singleDiscriminatedUnionType,s=this.getBaseFields({discriminatedUnionTypeInstance:a,singleDiscriminatedUnionType:p});switch(p.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:p.typeId});return f==null?l.TypeInstantiation.nop():l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(p.discriminantValue.name),value:this.convertNamed({named:f,value:a.value})},...s]})}case"singleProperty":{let f=this.context.getRecord(a.value);if(f==null)return l.TypeInstantiation.nop();try{return this.context.errors.scope(p.discriminantValue.wireValue),l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(p.discriminantValue.name),value:this.convert({typeReference:p.typeReference,value:f[p.discriminantValue.wireValue]})},...s]})}finally{this.context.errors.unscope()}}case"noProperties":return l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(a.discriminantValue.name),value:l.TypeInstantiation.string(p.discriminantValue.wireValue)},...s]});default:U(p)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getFieldName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}})}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(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getFieldName(a.name.name),value:this.convert(a)}}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(a=>a.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 a=this.getUndiscriminatedUnionFieldName({typeReference:i.valueTypeReference});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),fields:[{name:a,value:i.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let i of t.types)try{let a=this.convert({typeReference:i,value:e});return{valueTypeReference:i,typeInstantiation:a}}catch{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});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});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Set`}getUndiscriminatedUnionFieldNameForLiteral({literal:t}){switch(t.type){case"boolean":return t.value?"TrueLiteral":"FalseLiteral";case"string":return`${t.value}StringLiteral`;default: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":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 a=this.getValueAsNumber({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.int(a)}case"LONG":case"UINT_64":{let a=this.getValueAsNumber({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.int64(a)}case"FLOAT":case"DOUBLE":{let a=this.getValueAsNumber({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.float64(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.bool(a)}case"STRING":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(a)}case"DATE":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.date(a)}case"DATE_TIME":{let a=this.context.getValueAsString({value:e});if(a==null)return l.TypeInstantiation.nop();let p=this.normalizeDateTimeString(a);return l.TypeInstantiation.dateTime(p)}case"UUID":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.uuid(a)}case"BASE_64":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.bytes(a)}case"BIG_INTEGER":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(a)}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();w();g();var ft=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 l.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return l.Type.optional(this.convert({typeReference: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)}}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":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();w();g();var ht=class{constructor({context:t}){m(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){let i={fileFields:[],bodyPropertyFields:[]},a=this.context.getRecord(e)??{};for(let p of t.properties)switch(p.type){case"file":i.fileFields.push({name:this.context.getFieldName(p.name),value:this.getSingleFileProperty({property:p,record:a})});break;case"fileArray":i.fileFields.push({name:this.context.getFieldName(p.name),value:this.getArrayFileProperty({property:p,record:a})});break;case"bodyProperty":i.bodyPropertyFields.push({name:this.context.getFieldName(p.name.name),value:this.getBodyProperty({property:p,record:a})});break;default:U(p)}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(a=>l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(a)))})}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 mt=class u extends Ye{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,this.customConfig=i.customConfig!=null?i.customConfig:void 0,this.dynamicTypeMapper=new ft({context:this}),this.dynamicTypeInstantiationMapper=new dt({context:this}),this.filePropertyMapper=new ht({context:this}),this.rootImportPath=_t({config:i,customConfig:this.customConfig})}clone(){return new u({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 Lt(e.pascalCase.unsafeName)}getImportPath(e){let i=e.packagePath.map(a=>a.pascalCase.unsafeName.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})}static chainMethods(e,...i){if(i.length===0)throw new Error("Must have methods to chain");let a=e;for(let p of i)a=l.invokeMethod({on:a,method:p.method,arguments_:p.arguments_,multiline:p.multiline});return a}};y();w();g();var Pr="example",Mt="fern",ns="do",et="client",Me=l.TypeInstantiation,rs="WireMockBaseURL",is="WireMockClient",yt=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:Pr,importPath:Mt,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:Pr,importPath:Mt,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:Mt,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:ns,parameters:[],return_:[],body:l.codeblock(a=>{a.writeNode(this.constructClient({endpoint:t,snippet:e})),a.writeLine(),a.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(a=>{for(let p of this.buildWiremockTestSetup({endpoint:t}))a.writeNode(p),a.writeLine();a.writeLine(),a.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),a.writeLine(),a.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:a}){let{otherArgs:p,requestArg:s}=this.getMethodArgs({endpoint:e,snippet:i}),f=a?[l.codeblock(I=>{I.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(s!=null)if(s instanceof l.TypeInstantiation&&l.TypeInstantiation.isNop(s))t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...p,l.codeblock("nil")]}));else{t.write("request := "),t.writeNode(s),t.writeLine();let I=l.codeblock("request");t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...p,I,...f]}))}else t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...p,...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=[],a=this.getConstructorBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return a!=null&&i.push(a),t.auth!=null&&(e.auth!=null?i.push(this.getConstructorAuthArg({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(rs)]}))})]}getConstructorAuthArg({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),Me.nop();switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArg({auth:t,values:e}):Me.nop();case"bearer":return e.type==="bearer"?this.getConstructorBearerAuthArg({auth:t,values:e}):Me.nop();case"header":return e.type==="header"?this.getConstructorHeaderAuthArg({auth:t,values:e}):Me.nop();case"oauth":return e.type==="oauth"?this.getConstructorOAuthAuthArg({values:e}):Me.nop();case"inferred":return this.addWarning("The Go SDK Generator does not support Inferred auth scheme yet"),Me.nop();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})}getConstructorBasicAuthArg({auth:t,values:e}){return l.codeblock(i=>{i.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[l.TypeInstantiation.string(e.username),l.TypeInstantiation.string(e.password)]}))})}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let i=this.getBaseUrlArg({baseUrl:t,environment:e});if(i!=null)return l.codeblock(a=>{a.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)]}))})}getConstructorHeaderArgs({headers:t,values:e}){let i=[];for(let a of t){let p=this.getConstructorHeaderArg({header:a,value:e.value});p!=null&&i.push(p)}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(a=>{a.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 a=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];a.length>0&&i.push(...this.getPathParameters({namedParameters:a,snippet:e}).map(s=>s.value)),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let p=t.body!=null?this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:i,requestArg:p}}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:U(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:L.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),l.TypeInstantiation.nop()):l.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[],{inlinePathParameters:a,inlineFileProperties:p}={inlinePathParameters:this.context.customConfig?.inlinePathParameters??!0,inlineFileProperties:this.context.customConfig?.inlineFileProperties??!0};this.context.errors.scope(re.PathParameters);let s=[],f=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];f.length>0&&s.push(...this.getPathParameters({namedParameters:f,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let I=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})||i.push(...s.map(E=>E.value)),p||i.push(...I.fileFields.map(E=>E.value));let x=this.context.needsRequestParameter({request:t,inlinePathParameters:a,inlineFileProperties:p})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})?s:[],filePropertyInfo:I}):void 0;return{otherArgs:i,requestArg:x}}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:a}){this.context.errors.scope(re.QueryParameters);let s=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 I=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 x=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:a}):[];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,...s,...I,...x]})}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?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyStructField({body:t,value:e}){return{name:this.context.getTypeName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeInstantiation({body:t.bodyType,value:e})}}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:U(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){let i=[],a=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}});for(let p of a)i.push({name:this.context.getTypeName(p.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(p)});return i}getPathParameters({namedParameters:t,snippet:e}){let i=[],a=this.context.associateByWireValue({parameters:t,values:e.pathParameters??{}});for(let p of a)i.push({name:this.context.getTypeName(p.name.name),value:this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(p)});return i}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(a=>{this.writeMethodInvocation({writer:a,endpoint:t,snippet:e,includeTestIdHeader:!0}),a.writeLine(),a.writeLine(),a.write("ok, countErr := "),a.writeNode(l.invokeMethod({on:l.codeblock(is),method:"Verify",arguments_:[l.invokeMethod({on:l.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),l.codeblock("1")],multiline:!1})),a.writeLine(),a.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})),a.writeLine(),a.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})),a.writeLine()})}};var $t=class extends je{constructor({ir:e,config:i,formatter:a}){super(new mt({ir:e,config:i}));m(this,"formatter");this.formatter=a}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 yt({context:e,formatter:this.formatter})}};export{$t as DynamicSnippetsGenerator};
|
|
27
27
|
/*! Bundled license information:
|
|
28
28
|
|
|
29
29
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|