@fern-api/python-dynamic-snippets 5.27.1 → 5.29.0

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.js CHANGED
@@ -1,5 +1,5 @@
1
- var Ut=Object.defineProperty;var Bi=(p,t,e)=>t in p?Ut(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var Ie=(p,t,e)=>()=>{if(e)throw e[0];try{return p&&(t=p(p=0)),t}catch(n){throw e=[n],n}};var Mt=(p,t)=>{for(var e in t)Ut(p,e,{get:t[e],enumerable:!0})};var g=(p,t,e)=>Bi(p,typeof t!="symbol"?t+"":t,e);var f=Ie(()=>{"use strict"});var I={};Mt(I,{_debugEnd:()=>Rr,_debugProcess:()=>Er,_events:()=>$r,_eventsCount:()=>jr,_exiting:()=>or,_fatalExceptions:()=>vr,_getActiveHandles:()=>pr,_getActiveRequests:()=>ur,_kill:()=>cr,_linkedBinding:()=>nr,_maxListeners:()=>Dr,_preload_modules:()=>Or,_rawDebug:()=>tr,_startProfilerIdleNotifier:()=>Nr,_stopProfilerIdleNotifier:()=>Ar,_tickCallback:()=>br,abort:()=>Pr,addListener:()=>Wr,allowedNodeEnvironmentFlags:()=>gr,arch:()=>$t,argv:()=>qt,argv0:()=>Mr,assert:()=>xr,binding:()=>Yt,browser:()=>er,chdir:()=>Kt,config:()=>ar,cpuUsage:()=>Je,cwd:()=>Jt,debugPort:()=>Ur,default:()=>Kr,dlopen:()=>sr,domain:()=>ir,emit:()=>Qr,emitWarning:()=>Qt,env:()=>Wt,execArgv:()=>Gt,execPath:()=>Lr,exit:()=>hr,features:()=>wr,hasUncaughtExceptionCaptureCallback:()=>Tr,hrtime:()=>Ze,kill:()=>mr,listeners:()=>Jr,memoryUsage:()=>dr,moduleLoadList:()=>rr,nextTick:()=>_t,off:()=>Gr,on:()=>re,once:()=>qr,openStdin:()=>yr,pid:()=>Fr,platform:()=>jt,ppid:()=>kr,prependListener:()=>Yr,prependOnceListener:()=>Zr,reallyExit:()=>lr,release:()=>Xt,removeAllListeners:()=>Hr,removeListener:()=>zr,resourceUsage:()=>fr,setSourceMapsEnabled:()=>_r,setUncaughtExceptionCaptureCallback:()=>Ir,stderr:()=>Br,stdin:()=>Cr,stdout:()=>Sr,title:()=>Dt,umask:()=>Zt,uptime:()=>Vr,version:()=>zt,versions:()=>Ht});function mt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function Ci(){!Te||!me||(Te=!1,me.length?te=me.concat(te):Ye=-1,te.length&&Ot())}function Ot(){if(!Te){var p=setTimeout(Ci,0);Te=!0;for(var t=te.length;t;){for(me=te,te=[];++Ye<t;)me&&me[Ye].run();Ye=-1,t=te.length}me=null,Te=!1,clearTimeout(p)}}function _t(p){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];te.push(new Vt(p,t)),te.length===1&&!Te&&setTimeout(Ot,0)}function Vt(p,t){this.fun=p,this.array=t}function j(){}function nr(p){mt("_linkedBinding")}function sr(p){mt("dlopen")}function ur(){return[]}function pr(){return[]}function xr(p,t){if(!p)throw new Error(t||"assertion error")}function Tr(){return!1}function Vr(){return ae.now()/1e3}function Ze(p){var t=Math.floor((Date.now()-ae.now())*.001),e=ae.now()*.001,n=Math.floor(e)+t,o=Math.floor(e%1*1e9);return p&&(n=n-p[0],o=o-p[1],o<0&&(n--,o+=dt)),[n,o]}function re(){return Kr}function Jr(p){return[]}var te,Te,me,Ye,Dt,$t,jt,Wt,qt,Gt,zt,Ht,Qt,Yt,Zt,Jt,Kt,Xt,er,tr,rr,ir,or,ar,lr,cr,Je,fr,dr,mr,hr,yr,gr,wr,vr,Ir,br,Er,Rr,Nr,Ar,Sr,Br,Cr,Pr,Fr,kr,Lr,Ur,Mr,Or,_r,ae,ft,dt,Dr,$r,jr,Wr,qr,Gr,zr,Hr,Qr,Yr,Zr,Kr,Xr=Ie(()=>{"use strict";f();m();d();te=[],Te=!1,Ye=-1;Vt.prototype.run=function(){this.fun.apply(null,this.array)};Dt="browser",$t="x64",jt="browser",Wt={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},qt=["/usr/bin/node"],Gt=[],zt="v16.8.0",Ht={},Qt=function(p,t){console.warn((t?t+": ":"")+p)},Yt=function(p){mt("binding")},Zt=function(p){return 0},Jt=function(){return"/"},Kt=function(p){},Xt={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};er=!0,tr=j,rr=[];ir={},or=!1,ar={};lr=j,cr=j,Je=function(){return{}},fr=Je,dr=Je,mr=j,hr=j,yr=j,gr={};wr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},vr=j,Ir=j;br=j,Er=j,Rr=j,Nr=j,Ar=j,Sr=void 0,Br=void 0,Cr=void 0,Pr=j,Fr=2,kr=1,Lr="/bin/usr/node",Ur=9229,Mr="node",Or=[],_r=j,ae={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};ae.now===void 0&&(ft=Date.now(),ae.timing&&ae.timing.navigationStart&&(ft=ae.timing.navigationStart),ae.now=()=>Date.now()-ft);dt=1e9;Ze.bigint=function(p){var t=Ze(p);return typeof BigInt>"u"?t[0]*dt+t[1]:BigInt(t[0]*dt)+BigInt(t[1])};Dr=10,$r={},jr=0;Wr=re,qr=re,Gr=re,zr=re,Hr=re,Qr=j,Yr=re,Zr=re;Kr={version:zt,versions:Ht,arch:$t,platform:jt,browser:er,release:Xt,_rawDebug:tr,moduleLoadList:rr,binding:Yt,_linkedBinding:nr,_events:$r,_eventsCount:jr,_maxListeners:Dr,on:re,addListener:Wr,once:qr,off:Gr,removeListener:zr,removeAllListeners:Hr,emit:Qr,prependListener:Yr,prependOnceListener:Zr,listeners:Jr,domain:ir,_exiting:or,config:ar,dlopen:sr,uptime:Vr,_getActiveRequests:ur,_getActiveHandles:pr,reallyExit:lr,_kill:cr,cpuUsage:Je,resourceUsage:fr,memoryUsage:dr,kill:mr,exit:hr,openStdin:yr,allowedNodeEnvironmentFlags:gr,assert:xr,features:wr,_fatalExceptions:vr,setUncaughtExceptionCaptureCallback:Ir,hasUncaughtExceptionCaptureCallback:Tr,emitWarning:Qt,nextTick:_t,_tickCallback:br,_debugProcess:Er,_debugEnd:Rr,_startProfilerIdleNotifier:Nr,_stopProfilerIdleNotifier:Ar,stdout:Sr,stdin:Cr,stderr:Br,abort:Pr,umask:Zt,chdir:Kt,cwd:Jt,env:Wt,title:Dt,argv:qt,execArgv:Gt,pid:Fr,ppid:kr,execPath:Lr,debugPort:Ur,hrtime:Ze,argv0:Mr,_preload_modules:Or,setSourceMapsEnabled:_r}});var d=Ie(()=>{"use strict";Xr()});function Pi(){if(en)return Oe;en=!0,Oe.byteLength=v,Oe.toByteArray=N,Oe.fromByteArray=D;for(var p=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,l=n.length;o<l;++o)p[o]=n[o],t[n.charCodeAt(o)]=o;t[45]=62,t[95]=63;function s(R){var A=R.length;if(A%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=R.indexOf("=");k===-1&&(k=A);var M=k===A?0:4-k%4;return[k,M]}function v(R){var A=s(R),k=A[0],M=A[1];return(k+M)*3/4-M}function w(R,A,k){return(A+k)*3/4-k}function N(R){var A,k=s(R),M=k[0],q=k[1],V=new e(w(R,M,q)),G=0,H=q>0?M-4:M,W;for(W=0;W<H;W+=4)A=t[R.charCodeAt(W)]<<18|t[R.charCodeAt(W+1)]<<12|t[R.charCodeAt(W+2)]<<6|t[R.charCodeAt(W+3)],V[G++]=A>>16&255,V[G++]=A>>8&255,V[G++]=A&255;return q===2&&(A=t[R.charCodeAt(W)]<<2|t[R.charCodeAt(W+1)]>>4,V[G++]=A&255),q===1&&(A=t[R.charCodeAt(W)]<<10|t[R.charCodeAt(W+1)]<<4|t[R.charCodeAt(W+2)]>>2,V[G++]=A>>8&255,V[G++]=A&255),V}function E(R){return p[R>>18&63]+p[R>>12&63]+p[R>>6&63]+p[R&63]}function F(R,A,k){for(var M,q=[],V=A;V<k;V+=3)M=(R[V]<<16&16711680)+(R[V+1]<<8&65280)+(R[V+2]&255),q.push(E(M));return q.join("")}function D(R){for(var A,k=R.length,M=k%3,q=[],V=16383,G=0,H=k-M;G<H;G+=V)q.push(F(R,G,G+V>H?H:G+V));return M===1?(A=R[k-1],q.push(p[A>>2]+p[A<<4&63]+"==")):M===2&&(A=(R[k-2]<<8)+R[k-1],q.push(p[A>>10]+p[A>>4&63]+p[A<<2&63]+"=")),q.join("")}return Oe}function Fi(){if(tn)return Ke;tn=!0;return Ke.read=function(p,t,e,n,o){var l,s,v=o*8-n-1,w=(1<<v)-1,N=w>>1,E=-7,F=e?o-1:0,D=e?-1:1,R=p[t+F];for(F+=D,l=R&(1<<-E)-1,R>>=-E,E+=v;E>0;l=l*256+p[t+F],F+=D,E-=8);for(s=l&(1<<-E)-1,l>>=-E,E+=n;E>0;s=s*256+p[t+F],F+=D,E-=8);if(l===0)l=1-N;else{if(l===w)return s?NaN:(R?-1:1)*(1/0);s=s+Math.pow(2,n),l=l-N}return(R?-1:1)*s*Math.pow(2,l-n)},Ke.write=function(p,t,e,n,o,l){var s,v,w,N=l*8-o-1,E=(1<<N)-1,F=E>>1,D=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=n?0:l-1,A=n?1:-1,k=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(v=isNaN(t)?1:0,s=E):(s=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-s))<1&&(s--,w*=2),s+F>=1?t+=D/w:t+=D*Math.pow(2,1-F),t*w>=2&&(s++,w/=2),s+F>=E?(v=0,s=E):s+F>=1?(v=(t*w-1)*Math.pow(2,o),s=s+F):(v=t*Math.pow(2,F-1)*Math.pow(2,o),s=0));o>=8;p[e+R]=v&255,R+=A,v/=256,o-=8);for(s=s<<o|v,N+=o;N>0;p[e+R]=s&255,R+=A,s/=256,N-=8);p[e+R-A]|=k*128},Ke}function nn(){if(rn)return he;rn=!0;let p=Pi(),t=Fi(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;he.Buffer=s,he.SlowBuffer=q,he.INSPECT_MAX_BYTES=50;let n=2147483647;he.kMaxLength=n,s.TYPED_ARRAY_SUPPORT=o(),!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 o(){try{let a=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(a,r),a.foo()===42}catch{return!1}}Object.defineProperty(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 l(a){if(a>n)throw new RangeError('The value "'+a+'" is invalid for option "size"');let r=new Uint8Array(a);return Object.setPrototypeOf(r,s.prototype),r}function s(a,r,i){if(typeof a=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(a)}return v(a,r,i)}s.poolSize=8192;function v(a,r,i){if(typeof a=="string")return F(a,r);if(ArrayBuffer.isView(a))return R(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(Z(a,ArrayBuffer)||a&&Z(a.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Z(a,SharedArrayBuffer)||a&&Z(a.buffer,SharedArrayBuffer)))return A(a,r,i);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=a.valueOf&&a.valueOf();if(u!=null&&u!==a)return s.from(u,r,i);let c=k(a);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return s.from(a[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}s.from=function(a,r,i){return v(a,r,i)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function w(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function N(a,r,i){return w(a),a<=0?l(a):r!==void 0?typeof i=="string"?l(a).fill(r,i):l(a).fill(r):l(a)}s.alloc=function(a,r,i){return N(a,r,i)};function E(a){return w(a),l(a<0?0:M(a)|0)}s.allocUnsafe=function(a){return E(a)},s.allocUnsafeSlow=function(a){return E(a)};function F(a,r){if((typeof r!="string"||r==="")&&(r="utf8"),!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let i=V(a,r)|0,u=l(i),c=u.write(a,r);return c!==i&&(u=u.slice(0,c)),u}function D(a){let r=a.length<0?0:M(a.length)|0,i=l(r);for(let u=0;u<r;u+=1)i[u]=a[u]&255;return i}function R(a){if(Z(a,Uint8Array)){let r=new Uint8Array(a);return A(r.buffer,r.byteOffset,r.byteLength)}return D(a)}function A(a,r,i){if(r<0||a.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let u;return r===void 0&&i===void 0?u=new Uint8Array(a):i===void 0?u=new Uint8Array(a,r):u=new Uint8Array(a,r,i),Object.setPrototypeOf(u,s.prototype),u}function k(a){if(s.isBuffer(a)){let r=M(a.length)|0,i=l(r);return i.length===0||a.copy(i,0,0,r),i}if(a.length!==void 0)return typeof a.length!="number"||ct(a.length)?l(0):D(a);if(a.type==="Buffer"&&Array.isArray(a.data))return D(a.data)}function M(a){if(a>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return a|0}function q(a){return+a!=a&&(a=0),s.alloc(+a)}s.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==s.prototype},s.compare=function(r,i){if(Z(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),Z(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),!s.isBuffer(r)||!s.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let u=r.length,c=i.length;for(let h=0,x=Math.min(u,c);h<x;++h)if(r[h]!==i[h]){u=r[h],c=i[h];break}return u<c?-1:c<u?1:0},s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);let u;if(i===void 0)for(i=0,u=0;u<r.length;++u)i+=r[u].length;let c=s.allocUnsafe(i),h=0;for(u=0;u<r.length;++u){let x=r[u];if(Z(x,Uint8Array))h+x.length>c.length?(s.isBuffer(x)||(x=s.from(x)),x.copy(c,h)):Uint8Array.prototype.set.call(c,x,h);else if(s.isBuffer(x))x.copy(c,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=x.length}return c};function V(a,r){if(s.isBuffer(a))return a.length;if(ArrayBuffer.isView(a)||Z(a,ArrayBuffer))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);let i=a.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&i===0)return 0;let c=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return lt(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return Lt(a).length;default:if(c)return u?-1:lt(a).length;r=(""+r).toLowerCase(),c=!0}}s.byteLength=V;function G(a,r,i){let u=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(a||(a="utf8");;)switch(a){case"hex":return vi(this,r,i);case"utf8":case"utf-8":return Rt(this,r,i);case"ascii":return xi(this,r,i);case"latin1":case"binary":return wi(this,r,i);case"base64":return yi(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ii(this,r,i);default:if(u)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),u=!0}}s.prototype._isBuffer=!0;function H(a,r,i){let u=a[r];a[r]=a[i],a[i]=u}s.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)H(this,i,i+1);return this},s.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)H(this,i,i+3),H(this,i+1,i+2);return this},s.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)H(this,i,i+7),H(this,i+1,i+6),H(this,i+2,i+5),H(this,i+3,i+4);return this},s.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Rt(this,0,r):G.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(r){if(!s.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0},s.prototype.inspect=function(){let r="",i=he.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},e&&(s.prototype[e]=s.prototype.inspect),s.prototype.compare=function(r,i,u,c,h){if(Z(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),u===void 0&&(u=r?r.length:0),c===void 0&&(c=0),h===void 0&&(h=this.length),i<0||u>r.length||c<0||h>this.length)throw new RangeError("out of range index");if(c>=h&&i>=u)return 0;if(c>=h)return-1;if(i>=u)return 1;if(i>>>=0,u>>>=0,c>>>=0,h>>>=0,this===r)return 0;let x=h-c,C=u-i,O=Math.min(x,C),U=this.slice(c,h),_=r.slice(i,u);for(let L=0;L<O;++L)if(U[L]!==_[L]){x=U[L],C=_[L];break}return x<C?-1:C<x?1:0};function W(a,r,i,u,c){if(a.length===0)return-1;if(typeof i=="string"?(u=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,ct(i)&&(i=c?0:a.length-1),i<0&&(i=a.length+i),i>=a.length){if(c)return-1;i=a.length-1}else if(i<0)if(c)i=0;else return-1;if(typeof r=="string"&&(r=s.from(r,u)),s.isBuffer(r))return r.length===0?-1:Et(a,r,i,u,c);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(a,r,i):Uint8Array.prototype.lastIndexOf.call(a,r,i):Et(a,[r],i,u,c);throw new TypeError("val must be string, number or Buffer")}function Et(a,r,i,u,c){let h=1,x=a.length,C=r.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(a.length<2||r.length<2)return-1;h=2,x/=2,C/=2,i/=2}function O(_,L){return h===1?_[L]:_.readUInt16BE(L*h)}let U;if(c){let _=-1;for(U=i;U<x;U++)if(O(a,U)===O(r,_===-1?0:U-_)){if(_===-1&&(_=U),U-_+1===C)return _*h}else _!==-1&&(U-=U-_),_=-1}else for(i+C>x&&(i=x-C),U=i;U>=0;U--){let _=!0;for(let L=0;L<C;L++)if(O(a,U+L)!==O(r,L)){_=!1;break}if(_)return U}return-1}s.prototype.includes=function(r,i,u){return this.indexOf(r,i,u)!==-1},s.prototype.indexOf=function(r,i,u){return W(this,r,i,u,!0)},s.prototype.lastIndexOf=function(r,i,u){return W(this,r,i,u,!1)};function ci(a,r,i,u){i=Number(i)||0;let c=a.length-i;u?(u=Number(u),u>c&&(u=c)):u=c;let h=r.length;u>h/2&&(u=h/2);let x;for(x=0;x<u;++x){let C=parseInt(r.substr(x*2,2),16);if(ct(C))return x;a[i+x]=C}return x}function fi(a,r,i,u){return Qe(lt(r,a.length-i),a,i,u)}function di(a,r,i,u){return Qe(Ri(r),a,i,u)}function mi(a,r,i,u){return Qe(Lt(r),a,i,u)}function hi(a,r,i,u){return Qe(Ni(r,a.length-i),a,i,u)}s.prototype.write=function(r,i,u,c){if(i===void 0)c="utf8",u=this.length,i=0;else if(u===void 0&&typeof i=="string")c=i,u=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(u)?(u=u>>>0,c===void 0&&(c="utf8")):(c=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-i;if((u===void 0||u>h)&&(u=h),r.length>0&&(u<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let x=!1;for(;;)switch(c){case"hex":return ci(this,r,i,u);case"utf8":case"utf-8":return fi(this,r,i,u);case"ascii":case"latin1":case"binary":return di(this,r,i,u);case"base64":return mi(this,r,i,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hi(this,r,i,u);default:if(x)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),x=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function yi(a,r,i){return r===0&&i===a.length?p.fromByteArray(a):p.fromByteArray(a.slice(r,i))}function Rt(a,r,i){i=Math.min(a.length,i);let u=[],c=r;for(;c<i;){let h=a[c],x=null,C=h>239?4:h>223?3:h>191?2:1;if(c+C<=i){let O,U,_,L;switch(C){case 1:h<128&&(x=h);break;case 2:O=a[c+1],(O&192)===128&&(L=(h&31)<<6|O&63,L>127&&(x=L));break;case 3:O=a[c+1],U=a[c+2],(O&192)===128&&(U&192)===128&&(L=(h&15)<<12|(O&63)<<6|U&63,L>2047&&(L<55296||L>57343)&&(x=L));break;case 4:O=a[c+1],U=a[c+2],_=a[c+3],(O&192)===128&&(U&192)===128&&(_&192)===128&&(L=(h&15)<<18|(O&63)<<12|(U&63)<<6|_&63,L>65535&&L<1114112&&(x=L))}}x===null?(x=65533,C=1):x>65535&&(x-=65536,u.push(x>>>10&1023|55296),x=56320|x&1023),u.push(x),c+=C}return gi(u)}let Nt=4096;function gi(a){let r=a.length;if(r<=Nt)return String.fromCharCode.apply(String,a);let i="",u=0;for(;u<r;)i+=String.fromCharCode.apply(String,a.slice(u,u+=Nt));return i}function xi(a,r,i){let u="";i=Math.min(a.length,i);for(let c=r;c<i;++c)u+=String.fromCharCode(a[c]&127);return u}function wi(a,r,i){let u="";i=Math.min(a.length,i);for(let c=r;c<i;++c)u+=String.fromCharCode(a[c]);return u}function vi(a,r,i){let u=a.length;(!r||r<0)&&(r=0),(!i||i<0||i>u)&&(i=u);let c="";for(let h=r;h<i;++h)c+=Ai[a[h]];return c}function Ii(a,r,i){let u=a.slice(r,i),c="";for(let h=0;h<u.length-1;h+=2)c+=String.fromCharCode(u[h]+u[h+1]*256);return c}s.prototype.slice=function(r,i){let u=this.length;r=~~r,i=i===void 0?u:~~i,r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),i<0?(i+=u,i<0&&(i=0)):i>u&&(i=u),i<r&&(i=r);let c=this.subarray(r,i);return Object.setPrototypeOf(c,s.prototype),c};function $(a,r,i){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+r>i)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(r,i,u){r=r>>>0,i=i>>>0,u||$(r,i,this.length);let c=this[r],h=1,x=0;for(;++x<i&&(h*=256);)c+=this[r+x]*h;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(r,i,u){r=r>>>0,i=i>>>0,u||$(r,i,this.length);let c=this[r+--i],h=1;for(;i>0&&(h*=256);)c+=this[r+--i]*h;return c},s.prototype.readUint8=s.prototype.readUInt8=function(r,i){return r=r>>>0,i||$(r,1,this.length),this[r]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||$(r,2,this.length),this[r]|this[r+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||$(r,2,this.length),this[r]<<8|this[r+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||$(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||$(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},s.prototype.readBigUInt64LE=oe(function(r){r=r>>>0,ve(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&Me(r,this.length-8);let c=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,h=this[++r]+this[++r]*2**8+this[++r]*2**16+u*2**24;return BigInt(c)+(BigInt(h)<<BigInt(32))}),s.prototype.readBigUInt64BE=oe(function(r){r=r>>>0,ve(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&Me(r,this.length-8);let c=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],h=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u;return(BigInt(c)<<BigInt(32))+BigInt(h)}),s.prototype.readIntLE=function(r,i,u){r=r>>>0,i=i>>>0,u||$(r,i,this.length);let c=this[r],h=1,x=0;for(;++x<i&&(h*=256);)c+=this[r+x]*h;return h*=128,c>=h&&(c-=Math.pow(2,8*i)),c},s.prototype.readIntBE=function(r,i,u){r=r>>>0,i=i>>>0,u||$(r,i,this.length);let c=i,h=1,x=this[r+--c];for(;c>0&&(h*=256);)x+=this[r+--c]*h;return h*=128,x>=h&&(x-=Math.pow(2,8*i)),x},s.prototype.readInt8=function(r,i){return r=r>>>0,i||$(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},s.prototype.readInt16LE=function(r,i){r=r>>>0,i||$(r,2,this.length);let u=this[r]|this[r+1]<<8;return u&32768?u|4294901760:u},s.prototype.readInt16BE=function(r,i){r=r>>>0,i||$(r,2,this.length);let u=this[r+1]|this[r]<<8;return u&32768?u|4294901760:u},s.prototype.readInt32LE=function(r,i){return r=r>>>0,i||$(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},s.prototype.readInt32BE=function(r,i){return r=r>>>0,i||$(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},s.prototype.readBigInt64LE=oe(function(r){r=r>>>0,ve(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&Me(r,this.length-8);let c=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(u<<24);return(BigInt(c)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),s.prototype.readBigInt64BE=oe(function(r){r=r>>>0,ve(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&Me(r,this.length-8);let c=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(c)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u)}),s.prototype.readFloatLE=function(r,i){return r=r>>>0,i||$(r,4,this.length),t.read(this,r,!0,23,4)},s.prototype.readFloatBE=function(r,i){return r=r>>>0,i||$(r,4,this.length),t.read(this,r,!1,23,4)},s.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||$(r,8,this.length),t.read(this,r,!0,52,8)},s.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||$(r,8,this.length),t.read(this,r,!1,52,8)};function z(a,r,i,u,c,h){if(!s.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>c||r<h)throw new RangeError('"value" argument is out of bounds');if(i+u>a.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(r,i,u,c){if(r=+r,i=i>>>0,u=u>>>0,!c){let C=Math.pow(2,8*u)-1;z(this,r,i,u,C,0)}let h=1,x=0;for(this[i]=r&255;++x<u&&(h*=256);)this[i+x]=r/h&255;return i+u},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(r,i,u,c){if(r=+r,i=i>>>0,u=u>>>0,!c){let C=Math.pow(2,8*u)-1;z(this,r,i,u,C,0)}let h=u-1,x=1;for(this[i+h]=r&255;--h>=0&&(x*=256);)this[i+h]=r/x&255;return i+u},s.prototype.writeUint8=s.prototype.writeUInt8=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,1,255,0),this[i]=r&255,i+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function At(a,r,i,u,c){kt(r,u,c,a,i,7);let h=Number(r&BigInt(4294967295));a[i++]=h,h=h>>8,a[i++]=h,h=h>>8,a[i++]=h,h=h>>8,a[i++]=h;let x=Number(r>>BigInt(32)&BigInt(4294967295));return a[i++]=x,x=x>>8,a[i++]=x,x=x>>8,a[i++]=x,x=x>>8,a[i++]=x,i}function St(a,r,i,u,c){kt(r,u,c,a,i,7);let h=Number(r&BigInt(4294967295));a[i+7]=h,h=h>>8,a[i+6]=h,h=h>>8,a[i+5]=h,h=h>>8,a[i+4]=h;let x=Number(r>>BigInt(32)&BigInt(4294967295));return a[i+3]=x,x=x>>8,a[i+2]=x,x=x>>8,a[i+1]=x,x=x>>8,a[i]=x,i+8}s.prototype.writeBigUInt64LE=oe(function(r,i=0){return At(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=oe(function(r,i=0){return St(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(r,i,u,c){if(r=+r,i=i>>>0,!c){let O=Math.pow(2,8*u-1);z(this,r,i,u,O-1,-O)}let h=0,x=1,C=0;for(this[i]=r&255;++h<u&&(x*=256);)r<0&&C===0&&this[i+h-1]!==0&&(C=1),this[i+h]=(r/x>>0)-C&255;return i+u},s.prototype.writeIntBE=function(r,i,u,c){if(r=+r,i=i>>>0,!c){let O=Math.pow(2,8*u-1);z(this,r,i,u,O-1,-O)}let h=u-1,x=1,C=0;for(this[i+h]=r&255;--h>=0&&(x*=256);)r<0&&C===0&&this[i+h+1]!==0&&(C=1),this[i+h]=(r/x>>0)-C&255;return i+u},s.prototype.writeInt8=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},s.prototype.writeInt16LE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},s.prototype.writeInt16BE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},s.prototype.writeInt32LE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},s.prototype.writeInt32BE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},s.prototype.writeBigInt64LE=oe(function(r,i=0){return At(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=oe(function(r,i=0){return St(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Bt(a,r,i,u,c,h){if(i+u>a.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function Ct(a,r,i,u,c){return r=+r,i=i>>>0,c||Bt(a,r,i,4),t.write(a,r,i,u,23,4),i+4}s.prototype.writeFloatLE=function(r,i,u){return Ct(this,r,i,!0,u)},s.prototype.writeFloatBE=function(r,i,u){return Ct(this,r,i,!1,u)};function Pt(a,r,i,u,c){return r=+r,i=i>>>0,c||Bt(a,r,i,8),t.write(a,r,i,u,52,8),i+8}s.prototype.writeDoubleLE=function(r,i,u){return Pt(this,r,i,!0,u)},s.prototype.writeDoubleBE=function(r,i,u){return Pt(this,r,i,!1,u)},s.prototype.copy=function(r,i,u,c){if(!s.isBuffer(r))throw new TypeError("argument should be a Buffer");if(u||(u=0),!c&&c!==0&&(c=this.length),i>=r.length&&(i=r.length),i||(i=0),c>0&&c<u&&(c=u),c===u||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),r.length-i<c-u&&(c=r.length-i+u);let h=c-u;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,u,c):Uint8Array.prototype.set.call(r,this.subarray(u,c),i),h},s.prototype.fill=function(r,i,u,c){if(typeof r=="string"){if(typeof i=="string"?(c=i,i=0,u=this.length):typeof u=="string"&&(c=u,u=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(r.length===1){let x=r.charCodeAt(0);(c==="utf8"&&x<128||c==="latin1")&&(r=x)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<u)throw new RangeError("Out of range index");if(u<=i)return this;i=i>>>0,u=u===void 0?this.length:u>>>0,r||(r=0);let h;if(typeof r=="number")for(h=i;h<u;++h)this[h]=r;else{let x=s.isBuffer(r)?r:s.from(r,c),C=x.length;if(C===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(h=0;h<u-i;++h)this[h+i]=x[h%C]}return this};let we={};function pt(a,r,i){we[a]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}}}pt("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),pt("ERR_INVALID_ARG_TYPE",function(a,r){return`The "${a}" argument must be of type number. Received type ${typeof r}`},TypeError),pt("ERR_OUT_OF_RANGE",function(a,r,i){let u=`The value of "${a}" is out of range.`,c=i;return Number.isInteger(i)&&Math.abs(i)>2**32?c=Ft(String(i)):typeof i=="bigint"&&(c=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(c=Ft(c)),c+="n"),u+=` It must be ${r}. Received ${c}`,u},RangeError);function Ft(a){let r="",i=a.length,u=a[0]==="-"?1:0;for(;i>=u+4;i-=3)r=`_${a.slice(i-3,i)}${r}`;return`${a.slice(0,i)}${r}`}function Ti(a,r,i){ve(r,"offset"),(a[r]===void 0||a[r+i]===void 0)&&Me(r,a.length-(i+1))}function kt(a,r,i,u,c,h){if(a>i||a<r){let x=typeof r=="bigint"?"n":"",C;throw r===0||r===BigInt(0)?C=`>= 0${x} and < 2${x} ** ${(h+1)*8}${x}`:C=`>= -(2${x} ** ${(h+1)*8-1}${x}) and < 2 ** ${(h+1)*8-1}${x}`,new we.ERR_OUT_OF_RANGE("value",C,a)}Ti(u,c,h)}function ve(a,r){if(typeof a!="number")throw new we.ERR_INVALID_ARG_TYPE(r,"number",a)}function Me(a,r,i){throw Math.floor(a)!==a?(ve(a,i),new we.ERR_OUT_OF_RANGE("offset","an integer",a)):r<0?new we.ERR_BUFFER_OUT_OF_BOUNDS:new we.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,a)}let bi=/[^+/0-9A-Za-z-_]/g;function Ei(a){if(a=a.split("=")[0],a=a.trim().replace(bi,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}function lt(a,r){r=r||1/0;let i,u=a.length,c=null,h=[];for(let x=0;x<u;++x){if(i=a.charCodeAt(x),i>55295&&i<57344){if(!c){if(i>56319){(r-=3)>-1&&h.push(239,191,189);continue}else if(x+1===u){(r-=3)>-1&&h.push(239,191,189);continue}c=i;continue}if(i<56320){(r-=3)>-1&&h.push(239,191,189),c=i;continue}i=(c-55296<<10|i-56320)+65536}else c&&(r-=3)>-1&&h.push(239,191,189);if(c=null,i<128){if((r-=1)<0)break;h.push(i)}else if(i<2048){if((r-=2)<0)break;h.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;h.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;h.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return h}function Ri(a){let r=[];for(let i=0;i<a.length;++i)r.push(a.charCodeAt(i)&255);return r}function Ni(a,r){let i,u,c,h=[];for(let x=0;x<a.length&&!((r-=2)<0);++x)i=a.charCodeAt(x),u=i>>8,c=i%256,h.push(c),h.push(u);return h}function Lt(a){return p.toByteArray(Ei(a))}function Qe(a,r,i,u){let c;for(c=0;c<u&&!(c+i>=r.length||c>=a.length);++c)r[c+i]=a[c];return c}function Z(a,r){return a instanceof r||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===r.name}function ct(a){return a!==a}let Ai=(function(){let a="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){let u=i*16;for(let c=0;c<16;++c)r[u+c]=a[i]+a[c]}return r})();function oe(a){return typeof BigInt>"u"?Si:a}function Si(){throw new Error("BigInt not supported")}return he}var Oe,en,Ke,tn,he,rn,on=Ie(()=>{"use strict";f();m();d();Oe={},en=!1;Ke={},tn=!1;he={},rn=!1});var ye,T,as,ss,an=Ie(()=>{"use strict";f();m();d();on();ye=nn();ye.Buffer;ye.SlowBuffer;ye.INSPECT_MAX_BYTES;ye.kMaxLength;T=ye.Buffer,as=ye.INSPECT_MAX_BYTES,ss=ye.kMaxLength});var m=Ie(()=>{"use strict";an()});f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();var ki=typeof global=="object"&&global&&global.Object===Object&&global,sn=ki;var Li=typeof self=="object"&&self&&self.Object===Object&&self,Ui=sn||Li||Function("return this")(),un=Ui;var Mi=un.Symbol,ne=Mi;f();m();d();var pn=Object.prototype,Oi=pn.hasOwnProperty,_i=pn.toString,_e=ne?ne.toStringTag:void 0;function Vi(p){var t=Oi.call(p,_e),e=p[_e];try{p[_e]=void 0;var n=!0}catch{}var o=_i.call(p);return n&&(t?p[_e]=e:delete p[_e]),o}var ln=Vi;f();m();d();var Di=Object.prototype,$i=Di.toString;function ji(p){return $i.call(p)}var cn=ji;var Wi="[object Null]",qi="[object Undefined]",fn=ne?ne.toStringTag:void 0;function Gi(p){return p==null?p===void 0?qi:Wi:fn&&fn in Object(p)?ln(p):cn(p)}var dn=Gi;f();m();d();function zi(p){return p!=null&&typeof p=="object"}var mn=zi;var Hi="[object Symbol]";function Qi(p){return typeof p=="symbol"||mn(p)&&dn(p)==Hi}var hn=Qi;f();m();d();f();m();d();function Yi(p,t){for(var e=-1,n=p==null?0:p.length,o=Array(n);++e<n;)o[e]=t(p[e],e,p);return o}var yn=Yi;f();m();d();var Zi=Array.isArray,gn=Zi;var Ji=1/0,xn=ne?ne.prototype:void 0,wn=xn?xn.toString:void 0;function vn(p){if(typeof p=="string")return p;if(gn(p))return yn(p,vn)+"";if(hn(p))return wn?wn.call(p):"";var t=p+"";return t=="0"&&1/p==-Ji?"-0":t}var In=vn;f();m();d();function Ki(p){return p==null?"":In(p)}var se=Ki;f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();function Xi(p,t,e){var n=-1,o=p.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var l=Array(o);++n<o;)l[n]=p[n+t];return l}var Tn=Xi;function eo(p,t,e){var n=p.length;return e=e===void 0?n:e,!t&&e>=n?p:Tn(p,t,e)}var bn=eo;f();m();d();var to="\\ud800-\\udfff",ro="\\u0300-\\u036f",no="\\ufe20-\\ufe2f",io="\\u20d0-\\u20ff",oo=ro+no+io,ao="\\ufe0e\\ufe0f",so="\\u200d",uo=RegExp("["+so+to+oo+ao+"]");function po(p){return uo.test(p)}var Xe=po;f();m();d();f();m();d();function lo(p){return p.split("")}var En=lo;f();m();d();var Rn="\\ud800-\\udfff",co="\\u0300-\\u036f",fo="\\ufe20-\\ufe2f",mo="\\u20d0-\\u20ff",ho=co+fo+mo,yo="\\ufe0e\\ufe0f",go="["+Rn+"]",ht="["+ho+"]",yt="\\ud83c[\\udffb-\\udfff]",xo="(?:"+ht+"|"+yt+")",Nn="[^"+Rn+"]",An="(?:\\ud83c[\\udde6-\\uddff]){2}",Sn="[\\ud800-\\udbff][\\udc00-\\udfff]",wo="\\u200d",Bn=xo+"?",Cn="["+yo+"]?",vo="(?:"+wo+"(?:"+[Nn,An,Sn].join("|")+")"+Cn+Bn+")*",Io=Cn+Bn+vo,To="(?:"+[Nn+ht+"?",ht,An,Sn,go].join("|")+")",bo=RegExp(yt+"(?="+yt+")|"+To+Io,"g");function Eo(p){return p.match(bo)||[]}var Pn=Eo;function Ro(p){return Xe(p)?Pn(p):En(p)}var Fn=Ro;function No(p){return function(t){t=se(t);var e=Xe(t)?Fn(t):void 0,n=e?e[0]:t.charAt(0),o=e?bn(e,1).join(""):t.slice(1);return n[p]()+o}}var kn=No;var Ao=kn("toUpperCase"),Ln=Ao;function So(p){return Ln(se(p).toLowerCase())}var Un=So;f();m();d();f();m();d();function Bo(p,t,e,n){var o=-1,l=p==null?0:p.length;for(n&&l&&(e=p[++o]);++o<l;)e=t(e,p[o],o,p);return e}var Mn=Bo;f();m();d();f();m();d();f();m();d();function Co(p){return function(t){return p?.[t]}}var On=Co;var Po={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Fo=On(Po),_n=Fo;var ko=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Lo="\\u0300-\\u036f",Uo="\\ufe20-\\ufe2f",Mo="\\u20d0-\\u20ff",Oo=Lo+Uo+Mo,_o="["+Oo+"]",Vo=RegExp(_o,"g");function Do(p){return p=se(p),p&&p.replace(ko,_n).replace(Vo,"")}var Vn=Do;f();m();d();f();m();d();var $o=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function jo(p){return p.match($o)||[]}var Dn=jo;f();m();d();var Wo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function qo(p){return Wo.test(p)}var $n=qo;f();m();d();var zn="\\ud800-\\udfff",Go="\\u0300-\\u036f",zo="\\ufe20-\\ufe2f",Ho="\\u20d0-\\u20ff",Qo=Go+zo+Ho,Hn="\\u2700-\\u27bf",Qn="a-z\\xdf-\\xf6\\xf8-\\xff",Yo="\\xac\\xb1\\xd7\\xf7",Zo="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Jo="\\u2000-\\u206f",Ko=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Yn="A-Z\\xc0-\\xd6\\xd8-\\xde",Xo="\\ufe0e\\ufe0f",Zn=Yo+Zo+Jo+Ko,Jn="['\u2019]",jn="["+Zn+"]",ea="["+Qo+"]",Kn="\\d+",ta="["+Hn+"]",Xn="["+Qn+"]",ei="[^"+zn+Zn+Kn+Hn+Qn+Yn+"]",ra="\\ud83c[\\udffb-\\udfff]",na="(?:"+ea+"|"+ra+")",ia="[^"+zn+"]",ti="(?:\\ud83c[\\udde6-\\uddff]){2}",ri="[\\ud800-\\udbff][\\udc00-\\udfff]",be="["+Yn+"]",oa="\\u200d",Wn="(?:"+Xn+"|"+ei+")",aa="(?:"+be+"|"+ei+")",qn="(?:"+Jn+"(?:d|ll|m|re|s|t|ve))?",Gn="(?:"+Jn+"(?:D|LL|M|RE|S|T|VE))?",ni=na+"?",ii="["+Xo+"]?",sa="(?:"+oa+"(?:"+[ia,ti,ri].join("|")+")"+ii+ni+")*",ua="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",pa="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",la=ii+ni+sa,ca="(?:"+[ta,ti,ri].join("|")+")"+la,fa=RegExp([be+"?"+Xn+"+"+qn+"(?="+[jn,be,"$"].join("|")+")",aa+"+"+Gn+"(?="+[jn,be+Wn,"$"].join("|")+")",be+"?"+Wn+"+"+qn,be+"+"+Gn,pa,ua,Kn,ca].join("|"),"g");function da(p){return p.match(fa)||[]}var oi=da;function ma(p,t,e){return p=se(p),t=e?void 0:t,t===void 0?$n(p)?oi(p):Dn(p):p.match(t)||[]}var ai=ma;var ha="['\u2019]",ya=RegExp(ha,"g");function ga(p){return function(t){return Mn(ai(Vn(t).replace(ya,"")),p,"")}}var et=ga;var xa=et(function(p,t,e){return t=t.toLowerCase(),p+(e?Un(t):t)}),gt=xa;f();m();d();var wa=et(function(p,t,e){return p+(e?"_":"")+t.toLowerCase()}),xt=wa;f();m();d();function B(p){throw new Error("Unexpected value: "+JSON.stringify(p))}f();m();d();function Ve(p){return Object.keys(p)}f();m();d();f();m();d();f();m();d();var De=I.env.FERN_STACK_TRACK?.toLowerCase()??"",J=De!==""&&De!=="0"&&De!=="false",wt=["single","multiline","box"].includes(De)?De:"single";J&&(Error.stackTraceLimit=50);var va=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Ia=new Set(["stacktrace"]);function rt({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:n=[],stopOn:o=[],filterNode:l=!0,filterJs:s=!0,formatFilename:v=w=>w}={}){if(!J)return[];n=[...n,...va],e=[...e,...Ia],o=[...o,"runInteractiveTask"];let w=!1;return(new Error().stack??"").split(`
2
- `).map(N=>{let E=N.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(E&&E.length===5){let[,F,D,R,A]=E;if(!F||!D||!R||!A)return;if(w||o.some(k=>F?.includes(k))){w=!0;return}switch(F){case"Object.<anonymous>":F="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":F=`${F.substring(F.indexOf(".")+1)}()=> { ... }`;break}return{fn:F,path:v(D),position:`${R}:${A}`}}}).filter(N=>N&&!n.some(E=>N.fn.includes(E))&&!(l&&N.path?.startsWith("node:"))&&!(s&&N.path?.endsWith(".js"))&&!e.some(E=>N.path.includes(E))).slice(t,t+p)}var tt=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:n=[],filterFunctions:o=[],stopOn:l=[],filterNode:s=!0,filterJs:v=!0,multiline:w=!1,formatFilename:N=E=>E}={}){g(this,"maxFrames");g(this,"skip");g(this,"filterPaths");g(this,"filterFunctions");g(this,"stopOn");g(this,"filterNode");g(this,"filterJs");g(this,"multiline");g(this,"formatFilename");g(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=n,this.filterFunctions=o,this.stopOn=l,this.filterNode=s,this.filterJs=v,this.multiline=w,this.formatFilename=N}tag(t){let e=this.tracking.get(t)||new Set;rt({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(n=>e.add(n)),this.tracking.set(t,e)}trace(t){if(!J)return"";let e=this.tracking.get(t);return e?[...e].map(n=>`${this.multiline?`
1
+ var Ut=Object.defineProperty;var Bi=(p,t,e)=>t in p?Ut(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var Ie=(p,t,e)=>()=>{if(e)throw e[0];try{return p&&(t=p(p=0)),t}catch(n){throw e=[n],n}};var Mt=(p,t)=>{for(var e in t)Ut(p,e,{get:t[e],enumerable:!0})};var g=(p,t,e)=>Bi(p,typeof t!="symbol"?t+"":t,e);var f=Ie(()=>{"use strict"});var I={};Mt(I,{_debugEnd:()=>Rr,_debugProcess:()=>Er,_events:()=>$r,_eventsCount:()=>jr,_exiting:()=>or,_fatalExceptions:()=>vr,_getActiveHandles:()=>pr,_getActiveRequests:()=>ur,_kill:()=>cr,_linkedBinding:()=>nr,_maxListeners:()=>Dr,_preload_modules:()=>Or,_rawDebug:()=>tr,_startProfilerIdleNotifier:()=>Nr,_stopProfilerIdleNotifier:()=>Ar,_tickCallback:()=>br,abort:()=>Cr,addListener:()=>Wr,allowedNodeEnvironmentFlags:()=>gr,arch:()=>$t,argv:()=>qt,argv0:()=>Mr,assert:()=>xr,binding:()=>Yt,browser:()=>er,chdir:()=>Kt,config:()=>ar,cpuUsage:()=>Je,cwd:()=>Jt,debugPort:()=>Ur,default:()=>Kr,dlopen:()=>sr,domain:()=>ir,emit:()=>Qr,emitWarning:()=>Qt,env:()=>Wt,execArgv:()=>Gt,execPath:()=>Lr,exit:()=>hr,features:()=>wr,hasUncaughtExceptionCaptureCallback:()=>Tr,hrtime:()=>Ze,kill:()=>mr,listeners:()=>Jr,memoryUsage:()=>dr,moduleLoadList:()=>rr,nextTick:()=>_t,off:()=>Gr,on:()=>re,once:()=>qr,openStdin:()=>yr,pid:()=>Pr,platform:()=>jt,ppid:()=>kr,prependListener:()=>Yr,prependOnceListener:()=>Zr,reallyExit:()=>lr,release:()=>Xt,removeAllListeners:()=>Hr,removeListener:()=>zr,resourceUsage:()=>fr,setSourceMapsEnabled:()=>_r,setUncaughtExceptionCaptureCallback:()=>Ir,stderr:()=>Br,stdin:()=>Fr,stdout:()=>Sr,title:()=>Dt,umask:()=>Zt,uptime:()=>Vr,version:()=>zt,versions:()=>Ht});function mt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function Fi(){!Te||!me||(Te=!1,me.length?te=me.concat(te):Ye=-1,te.length&&Ot())}function Ot(){if(!Te){var p=setTimeout(Fi,0);Te=!0;for(var t=te.length;t;){for(me=te,te=[];++Ye<t;)me&&me[Ye].run();Ye=-1,t=te.length}me=null,Te=!1,clearTimeout(p)}}function _t(p){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];te.push(new Vt(p,t)),te.length===1&&!Te&&setTimeout(Ot,0)}function Vt(p,t){this.fun=p,this.array=t}function j(){}function nr(p){mt("_linkedBinding")}function sr(p){mt("dlopen")}function ur(){return[]}function pr(){return[]}function xr(p,t){if(!p)throw new Error(t||"assertion error")}function Tr(){return!1}function Vr(){return ae.now()/1e3}function Ze(p){var t=Math.floor((Date.now()-ae.now())*.001),e=ae.now()*.001,n=Math.floor(e)+t,o=Math.floor(e%1*1e9);return p&&(n=n-p[0],o=o-p[1],o<0&&(n--,o+=dt)),[n,o]}function re(){return Kr}function Jr(p){return[]}var te,Te,me,Ye,Dt,$t,jt,Wt,qt,Gt,zt,Ht,Qt,Yt,Zt,Jt,Kt,Xt,er,tr,rr,ir,or,ar,lr,cr,Je,fr,dr,mr,hr,yr,gr,wr,vr,Ir,br,Er,Rr,Nr,Ar,Sr,Br,Fr,Cr,Pr,kr,Lr,Ur,Mr,Or,_r,ae,ft,dt,Dr,$r,jr,Wr,qr,Gr,zr,Hr,Qr,Yr,Zr,Kr,Xr=Ie(()=>{"use strict";f();m();d();te=[],Te=!1,Ye=-1;Vt.prototype.run=function(){this.fun.apply(null,this.array)};Dt="browser",$t="x64",jt="browser",Wt={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},qt=["/usr/bin/node"],Gt=[],zt="v16.8.0",Ht={},Qt=function(p,t){console.warn((t?t+": ":"")+p)},Yt=function(p){mt("binding")},Zt=function(p){return 0},Jt=function(){return"/"},Kt=function(p){},Xt={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};er=!0,tr=j,rr=[];ir={},or=!1,ar={};lr=j,cr=j,Je=function(){return{}},fr=Je,dr=Je,mr=j,hr=j,yr=j,gr={};wr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},vr=j,Ir=j;br=j,Er=j,Rr=j,Nr=j,Ar=j,Sr=void 0,Br=void 0,Fr=void 0,Cr=j,Pr=2,kr=1,Lr="/bin/usr/node",Ur=9229,Mr="node",Or=[],_r=j,ae={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};ae.now===void 0&&(ft=Date.now(),ae.timing&&ae.timing.navigationStart&&(ft=ae.timing.navigationStart),ae.now=()=>Date.now()-ft);dt=1e9;Ze.bigint=function(p){var t=Ze(p);return typeof BigInt>"u"?t[0]*dt+t[1]:BigInt(t[0]*dt)+BigInt(t[1])};Dr=10,$r={},jr=0;Wr=re,qr=re,Gr=re,zr=re,Hr=re,Qr=j,Yr=re,Zr=re;Kr={version:zt,versions:Ht,arch:$t,platform:jt,browser:er,release:Xt,_rawDebug:tr,moduleLoadList:rr,binding:Yt,_linkedBinding:nr,_events:$r,_eventsCount:jr,_maxListeners:Dr,on:re,addListener:Wr,once:qr,off:Gr,removeListener:zr,removeAllListeners:Hr,emit:Qr,prependListener:Yr,prependOnceListener:Zr,listeners:Jr,domain:ir,_exiting:or,config:ar,dlopen:sr,uptime:Vr,_getActiveRequests:ur,_getActiveHandles:pr,reallyExit:lr,_kill:cr,cpuUsage:Je,resourceUsage:fr,memoryUsage:dr,kill:mr,exit:hr,openStdin:yr,allowedNodeEnvironmentFlags:gr,assert:xr,features:wr,_fatalExceptions:vr,setUncaughtExceptionCaptureCallback:Ir,hasUncaughtExceptionCaptureCallback:Tr,emitWarning:Qt,nextTick:_t,_tickCallback:br,_debugProcess:Er,_debugEnd:Rr,_startProfilerIdleNotifier:Nr,_stopProfilerIdleNotifier:Ar,stdout:Sr,stdin:Fr,stderr:Br,abort:Cr,umask:Zt,chdir:Kt,cwd:Jt,env:Wt,title:Dt,argv:qt,execArgv:Gt,pid:Pr,ppid:kr,execPath:Lr,debugPort:Ur,hrtime:Ze,argv0:Mr,_preload_modules:Or,setSourceMapsEnabled:_r}});var d=Ie(()=>{"use strict";Xr()});function Ci(){if(en)return Oe;en=!0,Oe.byteLength=v,Oe.toByteArray=N,Oe.fromByteArray=D;for(var p=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,l=n.length;o<l;++o)p[o]=n[o],t[n.charCodeAt(o)]=o;t[45]=62,t[95]=63;function s(R){var A=R.length;if(A%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=R.indexOf("=");k===-1&&(k=A);var M=k===A?0:4-k%4;return[k,M]}function v(R){var A=s(R),k=A[0],M=A[1];return(k+M)*3/4-M}function w(R,A,k){return(A+k)*3/4-k}function N(R){var A,k=s(R),M=k[0],q=k[1],V=new e(w(R,M,q)),G=0,H=q>0?M-4:M,W;for(W=0;W<H;W+=4)A=t[R.charCodeAt(W)]<<18|t[R.charCodeAt(W+1)]<<12|t[R.charCodeAt(W+2)]<<6|t[R.charCodeAt(W+3)],V[G++]=A>>16&255,V[G++]=A>>8&255,V[G++]=A&255;return q===2&&(A=t[R.charCodeAt(W)]<<2|t[R.charCodeAt(W+1)]>>4,V[G++]=A&255),q===1&&(A=t[R.charCodeAt(W)]<<10|t[R.charCodeAt(W+1)]<<4|t[R.charCodeAt(W+2)]>>2,V[G++]=A>>8&255,V[G++]=A&255),V}function E(R){return p[R>>18&63]+p[R>>12&63]+p[R>>6&63]+p[R&63]}function P(R,A,k){for(var M,q=[],V=A;V<k;V+=3)M=(R[V]<<16&16711680)+(R[V+1]<<8&65280)+(R[V+2]&255),q.push(E(M));return q.join("")}function D(R){for(var A,k=R.length,M=k%3,q=[],V=16383,G=0,H=k-M;G<H;G+=V)q.push(P(R,G,G+V>H?H:G+V));return M===1?(A=R[k-1],q.push(p[A>>2]+p[A<<4&63]+"==")):M===2&&(A=(R[k-2]<<8)+R[k-1],q.push(p[A>>10]+p[A>>4&63]+p[A<<2&63]+"=")),q.join("")}return Oe}function Pi(){if(tn)return Ke;tn=!0;return Ke.read=function(p,t,e,n,o){var l,s,v=o*8-n-1,w=(1<<v)-1,N=w>>1,E=-7,P=e?o-1:0,D=e?-1:1,R=p[t+P];for(P+=D,l=R&(1<<-E)-1,R>>=-E,E+=v;E>0;l=l*256+p[t+P],P+=D,E-=8);for(s=l&(1<<-E)-1,l>>=-E,E+=n;E>0;s=s*256+p[t+P],P+=D,E-=8);if(l===0)l=1-N;else{if(l===w)return s?NaN:(R?-1:1)*(1/0);s=s+Math.pow(2,n),l=l-N}return(R?-1:1)*s*Math.pow(2,l-n)},Ke.write=function(p,t,e,n,o,l){var s,v,w,N=l*8-o-1,E=(1<<N)-1,P=E>>1,D=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=n?0:l-1,A=n?1:-1,k=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(v=isNaN(t)?1:0,s=E):(s=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-s))<1&&(s--,w*=2),s+P>=1?t+=D/w:t+=D*Math.pow(2,1-P),t*w>=2&&(s++,w/=2),s+P>=E?(v=0,s=E):s+P>=1?(v=(t*w-1)*Math.pow(2,o),s=s+P):(v=t*Math.pow(2,P-1)*Math.pow(2,o),s=0));o>=8;p[e+R]=v&255,R+=A,v/=256,o-=8);for(s=s<<o|v,N+=o;N>0;p[e+R]=s&255,R+=A,s/=256,N-=8);p[e+R-A]|=k*128},Ke}function nn(){if(rn)return he;rn=!0;let p=Ci(),t=Pi(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;he.Buffer=s,he.SlowBuffer=q,he.INSPECT_MAX_BYTES=50;let n=2147483647;he.kMaxLength=n,s.TYPED_ARRAY_SUPPORT=o(),!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 o(){try{let a=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(a,r),a.foo()===42}catch{return!1}}Object.defineProperty(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 l(a){if(a>n)throw new RangeError('The value "'+a+'" is invalid for option "size"');let r=new Uint8Array(a);return Object.setPrototypeOf(r,s.prototype),r}function s(a,r,i){if(typeof a=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(a)}return v(a,r,i)}s.poolSize=8192;function v(a,r,i){if(typeof a=="string")return P(a,r);if(ArrayBuffer.isView(a))return R(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(Z(a,ArrayBuffer)||a&&Z(a.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Z(a,SharedArrayBuffer)||a&&Z(a.buffer,SharedArrayBuffer)))return A(a,r,i);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=a.valueOf&&a.valueOf();if(u!=null&&u!==a)return s.from(u,r,i);let c=k(a);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return s.from(a[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}s.from=function(a,r,i){return v(a,r,i)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function w(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function N(a,r,i){return w(a),a<=0?l(a):r!==void 0?typeof i=="string"?l(a).fill(r,i):l(a).fill(r):l(a)}s.alloc=function(a,r,i){return N(a,r,i)};function E(a){return w(a),l(a<0?0:M(a)|0)}s.allocUnsafe=function(a){return E(a)},s.allocUnsafeSlow=function(a){return E(a)};function P(a,r){if((typeof r!="string"||r==="")&&(r="utf8"),!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let i=V(a,r)|0,u=l(i),c=u.write(a,r);return c!==i&&(u=u.slice(0,c)),u}function D(a){let r=a.length<0?0:M(a.length)|0,i=l(r);for(let u=0;u<r;u+=1)i[u]=a[u]&255;return i}function R(a){if(Z(a,Uint8Array)){let r=new Uint8Array(a);return A(r.buffer,r.byteOffset,r.byteLength)}return D(a)}function A(a,r,i){if(r<0||a.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let u;return r===void 0&&i===void 0?u=new Uint8Array(a):i===void 0?u=new Uint8Array(a,r):u=new Uint8Array(a,r,i),Object.setPrototypeOf(u,s.prototype),u}function k(a){if(s.isBuffer(a)){let r=M(a.length)|0,i=l(r);return i.length===0||a.copy(i,0,0,r),i}if(a.length!==void 0)return typeof a.length!="number"||ct(a.length)?l(0):D(a);if(a.type==="Buffer"&&Array.isArray(a.data))return D(a.data)}function M(a){if(a>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return a|0}function q(a){return+a!=a&&(a=0),s.alloc(+a)}s.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==s.prototype},s.compare=function(r,i){if(Z(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),Z(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),!s.isBuffer(r)||!s.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let u=r.length,c=i.length;for(let h=0,x=Math.min(u,c);h<x;++h)if(r[h]!==i[h]){u=r[h],c=i[h];break}return u<c?-1:c<u?1:0},s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);let u;if(i===void 0)for(i=0,u=0;u<r.length;++u)i+=r[u].length;let c=s.allocUnsafe(i),h=0;for(u=0;u<r.length;++u){let x=r[u];if(Z(x,Uint8Array))h+x.length>c.length?(s.isBuffer(x)||(x=s.from(x)),x.copy(c,h)):Uint8Array.prototype.set.call(c,x,h);else if(s.isBuffer(x))x.copy(c,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=x.length}return c};function V(a,r){if(s.isBuffer(a))return a.length;if(ArrayBuffer.isView(a)||Z(a,ArrayBuffer))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);let i=a.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&i===0)return 0;let c=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return lt(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return Lt(a).length;default:if(c)return u?-1:lt(a).length;r=(""+r).toLowerCase(),c=!0}}s.byteLength=V;function G(a,r,i){let u=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(a||(a="utf8");;)switch(a){case"hex":return vi(this,r,i);case"utf8":case"utf-8":return Rt(this,r,i);case"ascii":return xi(this,r,i);case"latin1":case"binary":return wi(this,r,i);case"base64":return yi(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ii(this,r,i);default:if(u)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),u=!0}}s.prototype._isBuffer=!0;function H(a,r,i){let u=a[r];a[r]=a[i],a[i]=u}s.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)H(this,i,i+1);return this},s.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)H(this,i,i+3),H(this,i+1,i+2);return this},s.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)H(this,i,i+7),H(this,i+1,i+6),H(this,i+2,i+5),H(this,i+3,i+4);return this},s.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Rt(this,0,r):G.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(r){if(!s.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0},s.prototype.inspect=function(){let r="",i=he.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},e&&(s.prototype[e]=s.prototype.inspect),s.prototype.compare=function(r,i,u,c,h){if(Z(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),u===void 0&&(u=r?r.length:0),c===void 0&&(c=0),h===void 0&&(h=this.length),i<0||u>r.length||c<0||h>this.length)throw new RangeError("out of range index");if(c>=h&&i>=u)return 0;if(c>=h)return-1;if(i>=u)return 1;if(i>>>=0,u>>>=0,c>>>=0,h>>>=0,this===r)return 0;let x=h-c,F=u-i,O=Math.min(x,F),U=this.slice(c,h),_=r.slice(i,u);for(let L=0;L<O;++L)if(U[L]!==_[L]){x=U[L],F=_[L];break}return x<F?-1:F<x?1:0};function W(a,r,i,u,c){if(a.length===0)return-1;if(typeof i=="string"?(u=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,ct(i)&&(i=c?0:a.length-1),i<0&&(i=a.length+i),i>=a.length){if(c)return-1;i=a.length-1}else if(i<0)if(c)i=0;else return-1;if(typeof r=="string"&&(r=s.from(r,u)),s.isBuffer(r))return r.length===0?-1:Et(a,r,i,u,c);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(a,r,i):Uint8Array.prototype.lastIndexOf.call(a,r,i):Et(a,[r],i,u,c);throw new TypeError("val must be string, number or Buffer")}function Et(a,r,i,u,c){let h=1,x=a.length,F=r.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(a.length<2||r.length<2)return-1;h=2,x/=2,F/=2,i/=2}function O(_,L){return h===1?_[L]:_.readUInt16BE(L*h)}let U;if(c){let _=-1;for(U=i;U<x;U++)if(O(a,U)===O(r,_===-1?0:U-_)){if(_===-1&&(_=U),U-_+1===F)return _*h}else _!==-1&&(U-=U-_),_=-1}else for(i+F>x&&(i=x-F),U=i;U>=0;U--){let _=!0;for(let L=0;L<F;L++)if(O(a,U+L)!==O(r,L)){_=!1;break}if(_)return U}return-1}s.prototype.includes=function(r,i,u){return this.indexOf(r,i,u)!==-1},s.prototype.indexOf=function(r,i,u){return W(this,r,i,u,!0)},s.prototype.lastIndexOf=function(r,i,u){return W(this,r,i,u,!1)};function ci(a,r,i,u){i=Number(i)||0;let c=a.length-i;u?(u=Number(u),u>c&&(u=c)):u=c;let h=r.length;u>h/2&&(u=h/2);let x;for(x=0;x<u;++x){let F=parseInt(r.substr(x*2,2),16);if(ct(F))return x;a[i+x]=F}return x}function fi(a,r,i,u){return Qe(lt(r,a.length-i),a,i,u)}function di(a,r,i,u){return Qe(Ri(r),a,i,u)}function mi(a,r,i,u){return Qe(Lt(r),a,i,u)}function hi(a,r,i,u){return Qe(Ni(r,a.length-i),a,i,u)}s.prototype.write=function(r,i,u,c){if(i===void 0)c="utf8",u=this.length,i=0;else if(u===void 0&&typeof i=="string")c=i,u=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(u)?(u=u>>>0,c===void 0&&(c="utf8")):(c=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-i;if((u===void 0||u>h)&&(u=h),r.length>0&&(u<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let x=!1;for(;;)switch(c){case"hex":return ci(this,r,i,u);case"utf8":case"utf-8":return fi(this,r,i,u);case"ascii":case"latin1":case"binary":return di(this,r,i,u);case"base64":return mi(this,r,i,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hi(this,r,i,u);default:if(x)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),x=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function yi(a,r,i){return r===0&&i===a.length?p.fromByteArray(a):p.fromByteArray(a.slice(r,i))}function Rt(a,r,i){i=Math.min(a.length,i);let u=[],c=r;for(;c<i;){let h=a[c],x=null,F=h>239?4:h>223?3:h>191?2:1;if(c+F<=i){let O,U,_,L;switch(F){case 1:h<128&&(x=h);break;case 2:O=a[c+1],(O&192)===128&&(L=(h&31)<<6|O&63,L>127&&(x=L));break;case 3:O=a[c+1],U=a[c+2],(O&192)===128&&(U&192)===128&&(L=(h&15)<<12|(O&63)<<6|U&63,L>2047&&(L<55296||L>57343)&&(x=L));break;case 4:O=a[c+1],U=a[c+2],_=a[c+3],(O&192)===128&&(U&192)===128&&(_&192)===128&&(L=(h&15)<<18|(O&63)<<12|(U&63)<<6|_&63,L>65535&&L<1114112&&(x=L))}}x===null?(x=65533,F=1):x>65535&&(x-=65536,u.push(x>>>10&1023|55296),x=56320|x&1023),u.push(x),c+=F}return gi(u)}let Nt=4096;function gi(a){let r=a.length;if(r<=Nt)return String.fromCharCode.apply(String,a);let i="",u=0;for(;u<r;)i+=String.fromCharCode.apply(String,a.slice(u,u+=Nt));return i}function xi(a,r,i){let u="";i=Math.min(a.length,i);for(let c=r;c<i;++c)u+=String.fromCharCode(a[c]&127);return u}function wi(a,r,i){let u="";i=Math.min(a.length,i);for(let c=r;c<i;++c)u+=String.fromCharCode(a[c]);return u}function vi(a,r,i){let u=a.length;(!r||r<0)&&(r=0),(!i||i<0||i>u)&&(i=u);let c="";for(let h=r;h<i;++h)c+=Ai[a[h]];return c}function Ii(a,r,i){let u=a.slice(r,i),c="";for(let h=0;h<u.length-1;h+=2)c+=String.fromCharCode(u[h]+u[h+1]*256);return c}s.prototype.slice=function(r,i){let u=this.length;r=~~r,i=i===void 0?u:~~i,r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),i<0?(i+=u,i<0&&(i=0)):i>u&&(i=u),i<r&&(i=r);let c=this.subarray(r,i);return Object.setPrototypeOf(c,s.prototype),c};function $(a,r,i){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+r>i)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(r,i,u){r=r>>>0,i=i>>>0,u||$(r,i,this.length);let c=this[r],h=1,x=0;for(;++x<i&&(h*=256);)c+=this[r+x]*h;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(r,i,u){r=r>>>0,i=i>>>0,u||$(r,i,this.length);let c=this[r+--i],h=1;for(;i>0&&(h*=256);)c+=this[r+--i]*h;return c},s.prototype.readUint8=s.prototype.readUInt8=function(r,i){return r=r>>>0,i||$(r,1,this.length),this[r]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||$(r,2,this.length),this[r]|this[r+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||$(r,2,this.length),this[r]<<8|this[r+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||$(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||$(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},s.prototype.readBigUInt64LE=oe(function(r){r=r>>>0,ve(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&Me(r,this.length-8);let c=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,h=this[++r]+this[++r]*2**8+this[++r]*2**16+u*2**24;return BigInt(c)+(BigInt(h)<<BigInt(32))}),s.prototype.readBigUInt64BE=oe(function(r){r=r>>>0,ve(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&Me(r,this.length-8);let c=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],h=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u;return(BigInt(c)<<BigInt(32))+BigInt(h)}),s.prototype.readIntLE=function(r,i,u){r=r>>>0,i=i>>>0,u||$(r,i,this.length);let c=this[r],h=1,x=0;for(;++x<i&&(h*=256);)c+=this[r+x]*h;return h*=128,c>=h&&(c-=Math.pow(2,8*i)),c},s.prototype.readIntBE=function(r,i,u){r=r>>>0,i=i>>>0,u||$(r,i,this.length);let c=i,h=1,x=this[r+--c];for(;c>0&&(h*=256);)x+=this[r+--c]*h;return h*=128,x>=h&&(x-=Math.pow(2,8*i)),x},s.prototype.readInt8=function(r,i){return r=r>>>0,i||$(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},s.prototype.readInt16LE=function(r,i){r=r>>>0,i||$(r,2,this.length);let u=this[r]|this[r+1]<<8;return u&32768?u|4294901760:u},s.prototype.readInt16BE=function(r,i){r=r>>>0,i||$(r,2,this.length);let u=this[r+1]|this[r]<<8;return u&32768?u|4294901760:u},s.prototype.readInt32LE=function(r,i){return r=r>>>0,i||$(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},s.prototype.readInt32BE=function(r,i){return r=r>>>0,i||$(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},s.prototype.readBigInt64LE=oe(function(r){r=r>>>0,ve(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&Me(r,this.length-8);let c=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(u<<24);return(BigInt(c)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),s.prototype.readBigInt64BE=oe(function(r){r=r>>>0,ve(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&Me(r,this.length-8);let c=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(c)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u)}),s.prototype.readFloatLE=function(r,i){return r=r>>>0,i||$(r,4,this.length),t.read(this,r,!0,23,4)},s.prototype.readFloatBE=function(r,i){return r=r>>>0,i||$(r,4,this.length),t.read(this,r,!1,23,4)},s.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||$(r,8,this.length),t.read(this,r,!0,52,8)},s.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||$(r,8,this.length),t.read(this,r,!1,52,8)};function z(a,r,i,u,c,h){if(!s.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>c||r<h)throw new RangeError('"value" argument is out of bounds');if(i+u>a.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(r,i,u,c){if(r=+r,i=i>>>0,u=u>>>0,!c){let F=Math.pow(2,8*u)-1;z(this,r,i,u,F,0)}let h=1,x=0;for(this[i]=r&255;++x<u&&(h*=256);)this[i+x]=r/h&255;return i+u},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(r,i,u,c){if(r=+r,i=i>>>0,u=u>>>0,!c){let F=Math.pow(2,8*u)-1;z(this,r,i,u,F,0)}let h=u-1,x=1;for(this[i+h]=r&255;--h>=0&&(x*=256);)this[i+h]=r/x&255;return i+u},s.prototype.writeUint8=s.prototype.writeUInt8=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,1,255,0),this[i]=r&255,i+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function At(a,r,i,u,c){kt(r,u,c,a,i,7);let h=Number(r&BigInt(4294967295));a[i++]=h,h=h>>8,a[i++]=h,h=h>>8,a[i++]=h,h=h>>8,a[i++]=h;let x=Number(r>>BigInt(32)&BigInt(4294967295));return a[i++]=x,x=x>>8,a[i++]=x,x=x>>8,a[i++]=x,x=x>>8,a[i++]=x,i}function St(a,r,i,u,c){kt(r,u,c,a,i,7);let h=Number(r&BigInt(4294967295));a[i+7]=h,h=h>>8,a[i+6]=h,h=h>>8,a[i+5]=h,h=h>>8,a[i+4]=h;let x=Number(r>>BigInt(32)&BigInt(4294967295));return a[i+3]=x,x=x>>8,a[i+2]=x,x=x>>8,a[i+1]=x,x=x>>8,a[i]=x,i+8}s.prototype.writeBigUInt64LE=oe(function(r,i=0){return At(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=oe(function(r,i=0){return St(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(r,i,u,c){if(r=+r,i=i>>>0,!c){let O=Math.pow(2,8*u-1);z(this,r,i,u,O-1,-O)}let h=0,x=1,F=0;for(this[i]=r&255;++h<u&&(x*=256);)r<0&&F===0&&this[i+h-1]!==0&&(F=1),this[i+h]=(r/x>>0)-F&255;return i+u},s.prototype.writeIntBE=function(r,i,u,c){if(r=+r,i=i>>>0,!c){let O=Math.pow(2,8*u-1);z(this,r,i,u,O-1,-O)}let h=u-1,x=1,F=0;for(this[i+h]=r&255;--h>=0&&(x*=256);)r<0&&F===0&&this[i+h+1]!==0&&(F=1),this[i+h]=(r/x>>0)-F&255;return i+u},s.prototype.writeInt8=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},s.prototype.writeInt16LE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},s.prototype.writeInt16BE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},s.prototype.writeInt32LE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},s.prototype.writeInt32BE=function(r,i,u){return r=+r,i=i>>>0,u||z(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},s.prototype.writeBigInt64LE=oe(function(r,i=0){return At(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=oe(function(r,i=0){return St(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Bt(a,r,i,u,c,h){if(i+u>a.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function Ft(a,r,i,u,c){return r=+r,i=i>>>0,c||Bt(a,r,i,4),t.write(a,r,i,u,23,4),i+4}s.prototype.writeFloatLE=function(r,i,u){return Ft(this,r,i,!0,u)},s.prototype.writeFloatBE=function(r,i,u){return Ft(this,r,i,!1,u)};function Ct(a,r,i,u,c){return r=+r,i=i>>>0,c||Bt(a,r,i,8),t.write(a,r,i,u,52,8),i+8}s.prototype.writeDoubleLE=function(r,i,u){return Ct(this,r,i,!0,u)},s.prototype.writeDoubleBE=function(r,i,u){return Ct(this,r,i,!1,u)},s.prototype.copy=function(r,i,u,c){if(!s.isBuffer(r))throw new TypeError("argument should be a Buffer");if(u||(u=0),!c&&c!==0&&(c=this.length),i>=r.length&&(i=r.length),i||(i=0),c>0&&c<u&&(c=u),c===u||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),r.length-i<c-u&&(c=r.length-i+u);let h=c-u;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,u,c):Uint8Array.prototype.set.call(r,this.subarray(u,c),i),h},s.prototype.fill=function(r,i,u,c){if(typeof r=="string"){if(typeof i=="string"?(c=i,i=0,u=this.length):typeof u=="string"&&(c=u,u=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(r.length===1){let x=r.charCodeAt(0);(c==="utf8"&&x<128||c==="latin1")&&(r=x)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<u)throw new RangeError("Out of range index");if(u<=i)return this;i=i>>>0,u=u===void 0?this.length:u>>>0,r||(r=0);let h;if(typeof r=="number")for(h=i;h<u;++h)this[h]=r;else{let x=s.isBuffer(r)?r:s.from(r,c),F=x.length;if(F===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(h=0;h<u-i;++h)this[h+i]=x[h%F]}return this};let we={};function pt(a,r,i){we[a]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}}}pt("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),pt("ERR_INVALID_ARG_TYPE",function(a,r){return`The "${a}" argument must be of type number. Received type ${typeof r}`},TypeError),pt("ERR_OUT_OF_RANGE",function(a,r,i){let u=`The value of "${a}" is out of range.`,c=i;return Number.isInteger(i)&&Math.abs(i)>2**32?c=Pt(String(i)):typeof i=="bigint"&&(c=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(c=Pt(c)),c+="n"),u+=` It must be ${r}. Received ${c}`,u},RangeError);function Pt(a){let r="",i=a.length,u=a[0]==="-"?1:0;for(;i>=u+4;i-=3)r=`_${a.slice(i-3,i)}${r}`;return`${a.slice(0,i)}${r}`}function Ti(a,r,i){ve(r,"offset"),(a[r]===void 0||a[r+i]===void 0)&&Me(r,a.length-(i+1))}function kt(a,r,i,u,c,h){if(a>i||a<r){let x=typeof r=="bigint"?"n":"",F;throw r===0||r===BigInt(0)?F=`>= 0${x} and < 2${x} ** ${(h+1)*8}${x}`:F=`>= -(2${x} ** ${(h+1)*8-1}${x}) and < 2 ** ${(h+1)*8-1}${x}`,new we.ERR_OUT_OF_RANGE("value",F,a)}Ti(u,c,h)}function ve(a,r){if(typeof a!="number")throw new we.ERR_INVALID_ARG_TYPE(r,"number",a)}function Me(a,r,i){throw Math.floor(a)!==a?(ve(a,i),new we.ERR_OUT_OF_RANGE("offset","an integer",a)):r<0?new we.ERR_BUFFER_OUT_OF_BOUNDS:new we.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,a)}let bi=/[^+/0-9A-Za-z-_]/g;function Ei(a){if(a=a.split("=")[0],a=a.trim().replace(bi,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}function lt(a,r){r=r||1/0;let i,u=a.length,c=null,h=[];for(let x=0;x<u;++x){if(i=a.charCodeAt(x),i>55295&&i<57344){if(!c){if(i>56319){(r-=3)>-1&&h.push(239,191,189);continue}else if(x+1===u){(r-=3)>-1&&h.push(239,191,189);continue}c=i;continue}if(i<56320){(r-=3)>-1&&h.push(239,191,189),c=i;continue}i=(c-55296<<10|i-56320)+65536}else c&&(r-=3)>-1&&h.push(239,191,189);if(c=null,i<128){if((r-=1)<0)break;h.push(i)}else if(i<2048){if((r-=2)<0)break;h.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;h.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;h.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return h}function Ri(a){let r=[];for(let i=0;i<a.length;++i)r.push(a.charCodeAt(i)&255);return r}function Ni(a,r){let i,u,c,h=[];for(let x=0;x<a.length&&!((r-=2)<0);++x)i=a.charCodeAt(x),u=i>>8,c=i%256,h.push(c),h.push(u);return h}function Lt(a){return p.toByteArray(Ei(a))}function Qe(a,r,i,u){let c;for(c=0;c<u&&!(c+i>=r.length||c>=a.length);++c)r[c+i]=a[c];return c}function Z(a,r){return a instanceof r||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===r.name}function ct(a){return a!==a}let Ai=(function(){let a="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){let u=i*16;for(let c=0;c<16;++c)r[u+c]=a[i]+a[c]}return r})();function oe(a){return typeof BigInt>"u"?Si:a}function Si(){throw new Error("BigInt not supported")}return he}var Oe,en,Ke,tn,he,rn,on=Ie(()=>{"use strict";f();m();d();Oe={},en=!1;Ke={},tn=!1;he={},rn=!1});var ye,T,as,ss,an=Ie(()=>{"use strict";f();m();d();on();ye=nn();ye.Buffer;ye.SlowBuffer;ye.INSPECT_MAX_BYTES;ye.kMaxLength;T=ye.Buffer,as=ye.INSPECT_MAX_BYTES,ss=ye.kMaxLength});var m=Ie(()=>{"use strict";an()});f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();var ki=typeof global=="object"&&global&&global.Object===Object&&global,sn=ki;var Li=typeof self=="object"&&self&&self.Object===Object&&self,Ui=sn||Li||Function("return this")(),un=Ui;var Mi=un.Symbol,ne=Mi;f();m();d();var pn=Object.prototype,Oi=pn.hasOwnProperty,_i=pn.toString,_e=ne?ne.toStringTag:void 0;function Vi(p){var t=Oi.call(p,_e),e=p[_e];try{p[_e]=void 0;var n=!0}catch{}var o=_i.call(p);return n&&(t?p[_e]=e:delete p[_e]),o}var ln=Vi;f();m();d();var Di=Object.prototype,$i=Di.toString;function ji(p){return $i.call(p)}var cn=ji;var Wi="[object Null]",qi="[object Undefined]",fn=ne?ne.toStringTag:void 0;function Gi(p){return p==null?p===void 0?qi:Wi:fn&&fn in Object(p)?ln(p):cn(p)}var dn=Gi;f();m();d();function zi(p){return p!=null&&typeof p=="object"}var mn=zi;var Hi="[object Symbol]";function Qi(p){return typeof p=="symbol"||mn(p)&&dn(p)==Hi}var hn=Qi;f();m();d();f();m();d();function Yi(p,t){for(var e=-1,n=p==null?0:p.length,o=Array(n);++e<n;)o[e]=t(p[e],e,p);return o}var yn=Yi;f();m();d();var Zi=Array.isArray,gn=Zi;var Ji=1/0,xn=ne?ne.prototype:void 0,wn=xn?xn.toString:void 0;function vn(p){if(typeof p=="string")return p;if(gn(p))return yn(p,vn)+"";if(hn(p))return wn?wn.call(p):"";var t=p+"";return t=="0"&&1/p==-Ji?"-0":t}var In=vn;f();m();d();function Ki(p){return p==null?"":In(p)}var se=Ki;f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();function Xi(p,t,e){var n=-1,o=p.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var l=Array(o);++n<o;)l[n]=p[n+t];return l}var Tn=Xi;function eo(p,t,e){var n=p.length;return e=e===void 0?n:e,!t&&e>=n?p:Tn(p,t,e)}var bn=eo;f();m();d();var to="\\ud800-\\udfff",ro="\\u0300-\\u036f",no="\\ufe20-\\ufe2f",io="\\u20d0-\\u20ff",oo=ro+no+io,ao="\\ufe0e\\ufe0f",so="\\u200d",uo=RegExp("["+so+to+oo+ao+"]");function po(p){return uo.test(p)}var Xe=po;f();m();d();f();m();d();function lo(p){return p.split("")}var En=lo;f();m();d();var Rn="\\ud800-\\udfff",co="\\u0300-\\u036f",fo="\\ufe20-\\ufe2f",mo="\\u20d0-\\u20ff",ho=co+fo+mo,yo="\\ufe0e\\ufe0f",go="["+Rn+"]",ht="["+ho+"]",yt="\\ud83c[\\udffb-\\udfff]",xo="(?:"+ht+"|"+yt+")",Nn="[^"+Rn+"]",An="(?:\\ud83c[\\udde6-\\uddff]){2}",Sn="[\\ud800-\\udbff][\\udc00-\\udfff]",wo="\\u200d",Bn=xo+"?",Fn="["+yo+"]?",vo="(?:"+wo+"(?:"+[Nn,An,Sn].join("|")+")"+Fn+Bn+")*",Io=Fn+Bn+vo,To="(?:"+[Nn+ht+"?",ht,An,Sn,go].join("|")+")",bo=RegExp(yt+"(?="+yt+")|"+To+Io,"g");function Eo(p){return p.match(bo)||[]}var Cn=Eo;function Ro(p){return Xe(p)?Cn(p):En(p)}var Pn=Ro;function No(p){return function(t){t=se(t);var e=Xe(t)?Pn(t):void 0,n=e?e[0]:t.charAt(0),o=e?bn(e,1).join(""):t.slice(1);return n[p]()+o}}var kn=No;var Ao=kn("toUpperCase"),Ln=Ao;function So(p){return Ln(se(p).toLowerCase())}var Un=So;f();m();d();f();m();d();function Bo(p,t,e,n){var o=-1,l=p==null?0:p.length;for(n&&l&&(e=p[++o]);++o<l;)e=t(e,p[o],o,p);return e}var Mn=Bo;f();m();d();f();m();d();f();m();d();function Fo(p){return function(t){return p?.[t]}}var On=Fo;var Co={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Po=On(Co),_n=Po;var ko=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Lo="\\u0300-\\u036f",Uo="\\ufe20-\\ufe2f",Mo="\\u20d0-\\u20ff",Oo=Lo+Uo+Mo,_o="["+Oo+"]",Vo=RegExp(_o,"g");function Do(p){return p=se(p),p&&p.replace(ko,_n).replace(Vo,"")}var Vn=Do;f();m();d();f();m();d();var $o=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function jo(p){return p.match($o)||[]}var Dn=jo;f();m();d();var Wo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function qo(p){return Wo.test(p)}var $n=qo;f();m();d();var zn="\\ud800-\\udfff",Go="\\u0300-\\u036f",zo="\\ufe20-\\ufe2f",Ho="\\u20d0-\\u20ff",Qo=Go+zo+Ho,Hn="\\u2700-\\u27bf",Qn="a-z\\xdf-\\xf6\\xf8-\\xff",Yo="\\xac\\xb1\\xd7\\xf7",Zo="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Jo="\\u2000-\\u206f",Ko=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Yn="A-Z\\xc0-\\xd6\\xd8-\\xde",Xo="\\ufe0e\\ufe0f",Zn=Yo+Zo+Jo+Ko,Jn="['\u2019]",jn="["+Zn+"]",ea="["+Qo+"]",Kn="\\d+",ta="["+Hn+"]",Xn="["+Qn+"]",ei="[^"+zn+Zn+Kn+Hn+Qn+Yn+"]",ra="\\ud83c[\\udffb-\\udfff]",na="(?:"+ea+"|"+ra+")",ia="[^"+zn+"]",ti="(?:\\ud83c[\\udde6-\\uddff]){2}",ri="[\\ud800-\\udbff][\\udc00-\\udfff]",be="["+Yn+"]",oa="\\u200d",Wn="(?:"+Xn+"|"+ei+")",aa="(?:"+be+"|"+ei+")",qn="(?:"+Jn+"(?:d|ll|m|re|s|t|ve))?",Gn="(?:"+Jn+"(?:D|LL|M|RE|S|T|VE))?",ni=na+"?",ii="["+Xo+"]?",sa="(?:"+oa+"(?:"+[ia,ti,ri].join("|")+")"+ii+ni+")*",ua="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",pa="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",la=ii+ni+sa,ca="(?:"+[ta,ti,ri].join("|")+")"+la,fa=RegExp([be+"?"+Xn+"+"+qn+"(?="+[jn,be,"$"].join("|")+")",aa+"+"+Gn+"(?="+[jn,be+Wn,"$"].join("|")+")",be+"?"+Wn+"+"+qn,be+"+"+Gn,pa,ua,Kn,ca].join("|"),"g");function da(p){return p.match(fa)||[]}var oi=da;function ma(p,t,e){return p=se(p),t=e?void 0:t,t===void 0?$n(p)?oi(p):Dn(p):p.match(t)||[]}var ai=ma;var ha="['\u2019]",ya=RegExp(ha,"g");function ga(p){return function(t){return Mn(ai(Vn(t).replace(ya,"")),p,"")}}var et=ga;var xa=et(function(p,t,e){return t=t.toLowerCase(),p+(e?Un(t):t)}),gt=xa;f();m();d();var wa=et(function(p,t,e){return p+(e?"_":"")+t.toLowerCase()}),xt=wa;f();m();d();function B(p){throw new Error("Unexpected value: "+JSON.stringify(p))}f();m();d();function Ve(p){return Object.keys(p)}f();m();d();f();m();d();f();m();d();var De=I.env.FERN_STACK_TRACK?.toLowerCase()??"",J=De!==""&&De!=="0"&&De!=="false",wt=["single","multiline","box"].includes(De)?De:"single";J&&(Error.stackTraceLimit=50);var va=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Ia=new Set(["stacktrace"]);function rt({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:n=[],stopOn:o=[],filterNode:l=!0,filterJs:s=!0,formatFilename:v=w=>w}={}){if(!J)return[];n=[...n,...va],e=[...e,...Ia],o=[...o,"runInteractiveTask"];let w=!1;return(new Error().stack??"").split(`
2
+ `).map(N=>{let E=N.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(E&&E.length===5){let[,P,D,R,A]=E;if(!P||!D||!R||!A)return;if(w||o.some(k=>P?.includes(k))){w=!0;return}switch(P){case"Object.<anonymous>":P="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":P=`${P.substring(P.indexOf(".")+1)}()=> { ... }`;break}return{fn:P,path:v(D),position:`${R}:${A}`}}}).filter(N=>N&&!n.some(E=>N.fn.includes(E))&&!(l&&N.path?.startsWith("node:"))&&!(s&&N.path?.endsWith(".js"))&&!e.some(E=>N.path.includes(E))).slice(t,t+p)}var tt=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:n=[],filterFunctions:o=[],stopOn:l=[],filterNode:s=!0,filterJs:v=!0,multiline:w=!1,formatFilename:N=E=>E}={}){g(this,"maxFrames");g(this,"skip");g(this,"filterPaths");g(this,"filterFunctions");g(this,"stopOn");g(this,"filterNode");g(this,"filterJs");g(this,"multiline");g(this,"formatFilename");g(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=n,this.filterFunctions=o,this.stopOn=l,this.filterNode=s,this.filterJs=v,this.multiline=w,this.formatFilename=N}tag(t){let e=this.tracking.get(t)||new Set;rt({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(n=>e.add(n)),this.tracking.set(t,e)}trace(t){if(!J)return"";let e=this.tracking.get(t);return e?[...e].map(n=>`${this.multiline?`
3
3
  `:""}${n.fn} - ${n.path}:${n.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},vt;function si({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:n=[],stopOn:o=[],filterNode:l=!0,filterJs:s=!0,multiline:v=!1,formatFilename:w=N=>N}={}){J&&(vt??(vt=new tt({maxFrames:p,skip:t,filterPaths:e,filterFunctions:n,stopOn:o,filterNode:l,filterJs:s,multiline:v,formatFilename:w})))}function ui(p){vt?.tag(p)}function It(p){return vt?.frames(p)??[]}var ge=class{constructor(){ui(this)}};f();m();d();f();m();d();f();m();d();var Q=class extends ge{constructor(e){super();g(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 Ta=4;si({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var $e=class{constructor(){g(this,"lineBuffer",[]);g(this,"indentLevel",0);g(this,"hasWrittenAnything",!1);g(this,"lastCharacterIsSemicolon",!1);g(this,"lastCharacterIsNewline",!1);g(this,"nodeStackFrames",[])}get buffer(){return J&&this.nodeStackFrames.length>0&&this.writeInternal(`
4
4
  `),this.lineBuffer.join(`
5
5
  `)+(this.lastCharacterIsNewline?`
@@ -12,12 +12,12 @@ ${l}`);this.isAtStartOfLine()&&(s=l+s),n&&(s+=`
12
12
  `)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
13
13
  `)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:n}){if(t.length>0){let o=t[0];o!=null&&n(o);for(let l=1;l<t.length;l++){this.write(e);let s=t[l];s!=null&&n(s)}}}toString(){return this.buffer}writeInternal(t){if(t.length===0)return;let e=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
14
14
  `),this.lastCharacterIsSemicolon=t.endsWith(";");let n=t.split(`
15
- `),o=J&&!this.shouldSkipTracking(n)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${n.shift()||""}`),this.lastCharacterIsNewline&&n.pop(),this.lineBuffer.push(...n),o&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(n=>`${e?`(${e}) `:""} ${n.fn} - ${n.path} : ${n.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(rt({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,wt){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return Ta}};f();m();d();f();m();d();f();m();d();var je=class{constructor(){g(this,"reporter");g(this,"snippet");g(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:t,snippet:e}){this.shouldUpdate({snippet:e,reporter:t.errors})&&(this.reporter=t.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:t}){if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw this.err??new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}shouldUpdate({snippet:t,reporter:e}){return this.reporter==null||this.reporter.size()>0&&e.size()===0?!0:t.length>(this.snippet?.length??0)}};var We=class{constructor(t){g(this,"context");this.context=t}async generate(t,e={}){let n=this.resolveEndpoints({request:t,options:e});if(n.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let o=new je;for(let l of n){let s=this.context.clone(),v=this.createSnippetGenerator(s);try{let w=await v.generateSnippet({endpoint:l,request:t,options:e});if(s.errors.empty())return{snippet:w,errors:void 0};o.update({context:s,snippet:w})}catch(w){o.err==null&&(o.err=w)}}return o.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let n=this.resolveEndpoints({request:t,options:e});if(n.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let o;for(let l of n){let s=this.context.clone(),v=this.createSnippetGenerator(s);try{return await v.generateSnippetAst({endpoint:l,request:t,options:e})}catch(w){o=w}}throw o??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let n=this.resolveEndpoints({request:t,options:e});if(n.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let o=new je;for(let l of n){let s=this.context.clone(),v=this.createSnippetGenerator(s);try{let w=v.generateSnippetSync({endpoint:l,request:t,options:e});if(s.errors.empty())return{snippet:w,errors:void 0};o.update({context:s,snippet:w})}catch(w){o.err==null&&(o.err=w)}}return o.getResponseOrThrow({endpoint:t.endpoint})}resolveEndpoints({request:t,options:e}){if(e.endpointId!=null){let n=this.context.resolveEndpointById(e.endpointId);if(n==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[n]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}};f();m();d();f();m();d();f();m();d();var qe=class{constructor(){g(this,"REFERENCE_REGEX",/^(?:(\w+)::)?(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let n=t.match(this.REFERENCE_REGEX);if(!(n==null||n[2]==null||n[3]==null))return{namespace:n[1],method:n[2],path:n[3]}}};f();m();d();var P={Critical:"CRITICAL",Warning:"WARNING"},Ge=class p{constructor(){g(this,"errors");g(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push({...t,path:[...this.path]})}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}truncate(t){this.errors.length=t}clone(){let t=new p;return t.errors=[...this.errors],t.path=[...this.path],t}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(t=>({severity:t.severity,path:t.path!=null?this.pathToStringArray(t.path):void 0,message:t.message}))}pathToStringArray(t){let e=[];for(let n of t){if(typeof n=="string"){e.push(n);continue}e[e.length-1]+=`[${n.index}]`}return e}};var ze=class{constructor({ir:t,config:e,options:n={}}){g(this,"config");g(this,"options");g(this,"errors");g(this,"_ir");g(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=n,this.errors=new Ge,this.httpEndpointReferenceParser=new qe}associateQueryParametersByWireValue({parameters:t,values:e}){let n=[];for(let[o,l]of Object.entries(e))if(l!==void 0){this.errors.scope(o);try{let s=t.find(w=>w.name.wireValue===o);if(s==null)throw this.newParameterNotRecognizedError(o);let v=this.isListTypeReference(s.typeReference)&&!Array.isArray(l)?[l]:l;n.push({name:s.name,typeReference:s.typeReference,value:v})}finally{this.errors.unscope()}}return n}associateByWireValueOrDefault({parameters:t,values:e}){let n=[];for(let o of t){this.errors.scope(o.name.wireValue);try{let l=e[o.name.wireValue];if(l==null)if(o.typeReference.type==="primitive"&&o.typeReference.value==="STRING")l=`<${o.name.wireValue}>`;else{this.errors.add({severity:P.Critical,message:this.newParameterNotRecognizedError(o.name.wireValue).message});continue}n.push({name:o.name,typeReference:o.typeReference,value:l})}finally{this.errors.unscope()}}return n}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:n}){let o=[],l=new Set;for(let s of t){let v=s.name.wireValue,w=e[v];if(w!==void 0){l.add(v),this.errors.scope(v);try{o.push({name:s.name,typeReference:s.typeReference,value:w})}finally{this.errors.unscope()}}}if(!n){for(let[s,v]of Object.entries(e))if(!(v===void 0||l.has(s))){this.errors.scope(s);try{this.errors.add({severity:P.Critical,message:this.newParameterNotRecognizedError(s).message})}finally{this.errors.unscope()}}}return o}getExampleObjectProperties({parameters:t,snippetObject:e}){let n=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},o=[];for(let l of t){let s=n[l.name.wireValue];s==null?l.typeReference.type==="nullable"&&o.push({name:l.name,typeReference:l.typeReference,value:null}):o.push({name:l.name,typeReference:l.typeReference,value:s})}return o}getSingleFileValue({property:t,record:e}){let n=e[t.wireValue];if(n!=null){if(typeof n!="string"){this.errors.add({severity:P.Critical,message:`Expected file value to be a string, got ${typeof n}`});return}return n}}getFileArrayValues({property:t,record:e}){let n=e[t.wireValue];if(n==null)return;if(!Array.isArray(n)){this.errors.add({severity:P.Critical,message:`Expected file array value to be an array of strings, got ${typeof n}`});return}let o=[];for(let l of n){if(typeof l!="string"){this.errors.add({severity:P.Critical,message:`Expected file array value to be an array of strings, got ${typeof l}`});return}o.push(l)}return o}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:P.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t??{}}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:P.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let n=this.getRecord(e);if(n==null)return;let o=t.discriminant.wireValue,l=n[o];if(l==null){this.errors.add({severity:P.Critical,message:this.newParameterNotRecognizedError(o).message});return}if(typeof l!="string"){this.errors.add({severity:P.Critical,message:`Expected discriminant value to be a string but got: ${typeof l}`});return}let s=t.types[l];if(s==null){this.errors.add({severity:P.Critical,message:`No type found for discriminant value "${l}"`});return}let{[o]:v,...w}=n;return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:w}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocation(t){let e=[];for(let n of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:n,parsedEndpoint:t})&&e.push(n);return e}resolveEndpointLocationOrThrow(t){let e=this.resolveEndpointLocation(t);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}resolveEndpointById(t){return this._ir.endpoints[t]}resolveEndpointByIdOrThrow(t){let e=this.resolveEndpointById(t);if(e==null)throw new Error(`Failed to find endpoint with ID "${t}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:n}){return this.includePathParametersInWrappedRequest({request:t,inlinePathParameters:e})||t.queryParameters!=null&&t.queryParameters.length>0||t.headers!=null&&t.headers.length>0?!0:t.body!=null?this.includeRequestBodyInWrappedRequest({body:t.body,inlineFileProperties:n}):!t.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){return e&&(t.metadata?.includePathParameters??!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:B(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let n=e.environments.find(o=>o.id===t);return n?.name}case"multipleBaseUrls":{let n=e.environments.find(o=>o.id===t);return n?.name}default:B(e)}}isSingleEnvironmentID(t){return typeof t=="string"}isMultiEnvironmentValues(t){return typeof t=="object"}validateMultiEnvironmentUrlValues(t){if(this._ir.environments==null)return this.errors.add({severity:P.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":return this.errors.add({severity:P.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let n=e.environments[0];if(n==null)return this.errors.add({severity:P.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let o=new Set(Ve(n.urls));for(let l of Ve(t))o.has(l)&&o.delete(l);return o.size>0?(this.errors.add({severity:P.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${Ve(n.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:P.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:P.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:P.Critical,message:this.newTypeMismatchError({expected:"string",value:t}).message});return}return t}isOptional(t){switch(t.type){case"nullable":return this.isOptional(t.value);case"optional":return!0;case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}isNullable(t){switch(t.type){case"nullable":return!0;case"optional":return this.isNullable(t.value);case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}newAuthMismatchError({auth:t,values:e}){return new Error(`Expected auth type ${t.type}, got ${e.type}`)}newParameterNotRecognizedError(t){return new Error(`"${t}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:t,value:e}){return new Error(`Expected ${t}, got ${typeof e}`)}includeRequestBodyInWrappedRequest({body:t,inlineFileProperties:e}){switch(t.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e});default:B(t)}}includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e}){return this.fileUploadHasBodyProperties({fileUpload:t})||e&&this.fileUploadHasFileProperties({fileUpload:t})}fileUploadHasBodyProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:B(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:B(e)}})}isListTypeReference(t){return t.type==="optional"?this.isListTypeReference(t.value):t.type==="list"||t.type==="set"}parsedEndpointMatches({endpoint:t,parsedEndpoint:e}){return t.location.method===e.method&&t.location.path===e.path}};f();m();d();var K={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};f();m();d();f();m();d();var y={};Mt(y,{AccessAttribute:()=>Ee,AstNode:()=>S,Class:()=>ue,ClassInstantiation:()=>Ne,CodeBlock:()=>ie,Comment:()=>Ae,Decorator:()=>Se,Field:()=>pe,Lambda:()=>Be,LambdaParameter:()=>Ce,Method:()=>ce,MethodArgument:()=>Fe,MethodInvocation:()=>ke,ModuleImport:()=>Y,Operator:()=>Le,Parameter:()=>le,PythonFile:()=>Ue,Reference:()=>ee,StarImport:()=>fe,Type:()=>it,TypeInstantiation:()=>de,accessAttribute:()=>Ra,assign:()=>Na,class_:()=>Sa,codeBlock:()=>La,comment:()=>Ua,decorator:()=>Ca,field:()=>ka,file:()=>Aa,instantiateClass:()=>Ba,invokeFunction:()=>Va,invokeMethod:()=>Da,lambda:()=>Ma,lambdaParameter:()=>Oa,method:()=>_a,methodArgument:()=>ja,operator:()=>Wa,parameter:()=>$a,reference:()=>Pa,starImport:()=>Fa});f();m();d();f();m();d();f();m();d();f();m();d();var He=class extends $e{constructor(){super(...arguments);g(this,"fullyQualifiedModulePathsToImportedNames",{})}setRefNameOverrides(e){this.fullyQualifiedModulePathsToImportedNames=e}unsetRefNameOverrides(){this.fullyQualifiedModulePathsToImportedNames={}}getRefNameOverride(e){let n=this.fullyQualifiedModulePathsToImportedNames[e.getFullyQualifiedModulePath()];return n||{name:e.alias??e.name,isAlias:!!e.alias}}toString(){return this.buffer}async toStringFormatted(e){return e.format(this.buffer)}};var S=class extends ge{constructor(){super(...arguments);g(this,"references",[])}addReference(e){this.references.push(e)}inheritReferences(e){e!==void 0&&e.references.forEach(n=>{this.references.includes(n)||this.addReference(n)})}getReferences(){return this.references}toString(){let e=new He;return this.write(e),e.toString()}async toStringFormatted(e){let n=new He;return this.write(n),n.toStringFormatted(e)}};var Ee=class extends S{constructor({lhs:e,rhs:n}){super();g(this,"lhs");g(this,"rhs");this.lhs=e,this.inheritReferences(e),this.rhs=n,this.inheritReferences(n)}write(e){this.lhs.write(e),e.write("."),this.rhs.write(e)}};f();m();d();var nt=class extends S{constructor({lhs:e,rhs:n}){super();g(this,"lhs");g(this,"rhs");this.lhs=e,this.inheritReferences(e),this.rhs=n,this.inheritReferences(n)}write(e){this.lhs.write(e),e.write(" = "),this.rhs.write(e)}};f();m();d();var Re=class extends S{constructor({reference:e,arguments_:n,multiline:o}){super();g(this,"reference");g(this,"arguments");g(this,"multiline");this.reference=e,this.arguments=n,this.multiline=o??!1,this.inheritReferences(e),this.arguments.forEach(l=>{this.inheritReferences(l)})}write(e){if(this.reference.write(e),this.arguments.length===0){e.write("()");return}e.write("("),this.multiline&&(e.newLine(),e.indent()),this.arguments.forEach((n,o)=>{n.write(e),o<this.arguments.length-1?(e.write(","),this.multiline?e.newLine():e.write(" ")):this.multiline&&e.write(",")}),this.multiline&&(e.newLine(),e.dedent()),e.write(")")}};f();m();d();var ue=class extends S{constructor({docs:e,name:n,extends_:o,decorators:l}){super();g(this,"name");g(this,"extends_");g(this,"decorators");g(this,"fields",[]);g(this,"docs");g(this,"statements",[]);this.name=n,this.extends_=o??[],this.decorators=l??[],this.docs=e,this.extends_.forEach(s=>{this.inheritReferences(s)}),this.decorators.forEach(s=>{this.inheritReferences(s)})}write(e){this.decorators.forEach(n=>{n.write(e)}),e.write(`class ${this.name}`),this.extends_.length>0&&(e.write("("),this.extends_.forEach((n,o)=>{o>0&&e.write(", "),n.write(e)}),e.write(")")),e.write(":"),e.newLine(),e.indent(),this.docs!=null&&(e.write('"""'),e.write(this.docs),e.write('"""')),e.writeNewLineIfLastLineNot(),this.fields.forEach(n=>{n.write(e),e.writeNewLineIfLastLineNot()}),e.dedent(),e.indent(),this.statements.length?this.writeStatements({writer:e}):e.write("pass"),e.dedent()}add(e){this.statements.push(e),this.inheritReferences(e)}writeStatements({writer:e}){this.statements.forEach((n,o)=>{n.write(e),e.writeNewLineIfLastLineNot()})}addField(e){this.add(e)}};f();m();d();var Ne=class extends Re{constructor({classReference:t,...e}){super({reference:t,...e})}};f();m();d();var ie=class extends S{constructor(e){super();g(this,"arg");this.arg=e}write(e){return new Q(this.arg).write(e)}};f();m();d();var Ae=class extends S{constructor({docs:e}){super();g(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
16
- `).forEach(n=>{e.writeLine(`# ${n}`)})}};f();m();d();var Se=class extends S{constructor({callable:e}){super();g(this,"callable");this.callable=e,this.inheritReferences(e)}write(e){e.write("@"),this.callable.write(e),e.newLine()}};f();m();d();var pe=class extends S{constructor({name:e,type:n,initializer:o,docs:l}){super();g(this,"name");g(this,"type");g(this,"initializer");g(this,"docs");this.name=e,this.type=n,this.initializer=o,this.docs=l,this.inheritReferences(this.type),this.inheritReferences(this.initializer)}write(e){e.write(this.name),this.type!==void 0&&(e.write(": "),this.type.write(e)),this.initializer!==void 0&&(e.write(" = "),this.initializer.write(e)),this.docs!=null&&(e.newLine(),e.write('"""'),e.newLine(),e.write(this.docs),e.newLine(),e.write('"""'))}};f();m();d();var Be=class extends S{constructor({parameters:e,body:n}){super();g(this,"parameters");g(this,"body");this.parameters=e??[],this.body=n,this.inheritReferences(n)}write(e){e.write("lambda"),this.parameters&&this.parameters.length&&(e.write(" "),this.parameters.forEach((n,o)=>{n.write(e),o<this.parameters.length-1&&e.write(", ")})),e.write(": "),this.body.write(e)}};f();m();d();f();m();d();var le=class extends S{constructor({name:e,type:n,initializer:o}){super();g(this,"name");g(this,"initializer");g(this,"type");this.name=e,this.type=n,this.initializer=o}write(e){e.write(this.name),this.type&&(e.write(": "),this.type.write(e)),this.initializer!==void 0&&(e.write(" = "),this.initializer.write(e))}};var Ce=class extends le{constructor({name:t,initializer:e}){super({name:t,initializer:e,type:void 0})}};f();m();d();var Pe;(function(p){p[p.STATIC=0]="STATIC",p[p.INSTANCE=1]="INSTANCE",p[p.CLASS=2]="CLASS"})(Pe||(Pe={}));var ce=class extends S{constructor({static_:e,name:n,parameters:o,return_:l,docstring:s,type:v,decorators:w}){super();g(this,"name");g(this,"return");g(this,"docstring");g(this,"type");g(this,"parameters");g(this,"decorators");g(this,"statements",[]);g(this,"static_");this.name=n,this.parameters=o??[],this.return=l,this.docstring=s,this.type=v,this.decorators=w??[],this.static_=e??!1,this.parameters.forEach(N=>{this.inheritReferences(N)}),this.inheritReferences(this.return),this.decorators.forEach(N=>{this.inheritReferences(N)}),this.statements.forEach(N=>{this.inheritReferences(N)})}addStatement(e){this.statements.push(e),this.inheritReferences(e)}write(e){this.static_&&this.decorators.push(y.decorator({callable:y.codeBlock("staticmethod")})),this.decorators.forEach(l=>{l.write(e)}),this.type===Pe.CLASS?y.decorator({callable:new ie("classmethod")}).write(e):this.type===Pe.STATIC&&y.decorator({callable:new ie("staticmethod")}).write(e),e.write(`def ${this.name}(`);let o=this.parameters.length>3;o&&(e.newLine(),e.indent()),this.type===Pe.INSTANCE?(e.write("self"),this.parameters.length>0&&(e.write(o?",":", "),o&&e.newLine())):this.type===Pe.CLASS&&(e.write("cls"),this.parameters.length>0&&(e.write(o?",":", "),o&&e.newLine())),this.parameters.forEach((l,s)=>{l.write(e),s<this.parameters.length-1&&(e.write(o?",":", "),o&&e.newLine())}),o&&(e.write(","),e.dedent(),e.newLine()),e.write(")"),this.return&&(e.write(" -> "),this.return.write(e)),e.write(":"),e.newLine(),this.docstring&&(e.indent(),e.write('"""'),e.write(this.docstring),e.write('"""'),e.newLine(),e.dedent()),this.statements.length?(e.indent(),this.statements.forEach((l,s)=>{l.write(e),s<this.statements.length-1&&e.newLine()}),e.dedent()):(e.indent(),e.write("pass"),e.dedent()),e.newLine()}};f();m();d();var Fe=class extends S{constructor({name:e,value:n}){super();g(this,"name");g(this,"value");this.name=e,this.value=n,this.inheritReferences(this.value)}write(e){this.name!==void 0&&(e.write(this.name),e.write("=")),this.value.write(e)}};f();m();d();var ke=class extends S{constructor({on:e,method:n,arguments_:o,multiline:l}){super();g(this,"on");g(this,"method");g(this,"arguments");g(this,"multiline");this.on=e,this.method=n,this.arguments=o,this.multiline=l??!1,this.inheritReferences(e),this.arguments.forEach(s=>{this.inheritReferences(s)})}write(e){if(this.on.write(e),e.write("."),e.write(this.method),this.arguments.length===0){e.write("()");return}e.write("("),this.multiline&&(e.newLine(),e.indent()),this.arguments.forEach((n,o)=>{n.write(e),o<this.arguments.length-1?(e.write(","),this.multiline?e.newLine():e.write(" ")):this.multiline&&e.write(",")}),this.multiline&&(e.newLine(),e.dedent()),e.write(")")}};f();m();d();f();m();d();var X={Or:"or",And:"and",Add:"add",Subtract:"subtract",Multiply:"multiple",Divide:"divide",Modulo:"modulo",LeftShift:"leftShift",RightShift:"rightShift"};var Le=class extends S{constructor({operator:e,lhs:n,rhs:o}){super();g(this,"operator");g(this,"lhs");g(this,"rhs");this.operator=e,this.lhs=n,this.inheritReferences(n),this.rhs=o,this.inheritReferences(o)}getOperatorString(){switch(this.operator){case X.Or:return"or";case X.And:return"and";case X.Add:return"+";case X.Subtract:return"-";case X.Multiply:return"*";case X.Divide:return"/";case X.Modulo:return"%";case X.LeftShift:return"<<";case X.RightShift:return">>";default:B(this.operator)}}write(e){this.lhs.write(e),e.write(" "),e.write(this.getOperatorString()),e.write(" "),this.rhs.write(e)}};f();m();d();f();m();d();function pi(p){if(!p)return"Class";let t=p.replace(/[^a-zA-Z0-9\s_-]/g," ").replace(/[-_\s]+/g," ").trim();return!t||/^\d+$/.test(t)?"Class"+(t||""):(/^\d/.test(t)&&(t="Class"+t),t.split(/(?=[A-Z])|[-_\s]+/).filter(n=>n.length>0).map(n=>n.split(/(?<=\d)(?=[a-zA-Z])|(?<=[a-zA-Z])(?=\d)/).filter(o=>o.length>0)).flat().map((n,o)=>o===0&&/^\d/.test(n)?"Class"+n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():n.length>1&&n===n.toUpperCase()&&!/^\d+$/.test(n)?n:n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(""))}f();m();d();f();m();d();var ee=class extends S{constructor({name:e,modulePath:n,genericTypes:o,alias:l,attribute:s}){super();g(this,"name");g(this,"modulePath");g(this,"genericTypes");g(this,"alias");g(this,"attribute");this.name=e,this.modulePath=n??[],this.genericTypes=o??[],this.alias=l,this.attribute=s??[],this.references.push(this),this.genericTypes.forEach(v=>{this.inheritReferences(v)})}write(e){let n=e.getRefNameOverride(this);e.write(n.name),this.genericTypes.length>0&&(e.write("["),this.genericTypes.forEach((o,l)=>{l>0&&e.write(", "),o.write(e)}),e.write("]")),this.attribute.length>0&&(e.write("."),this.attribute.forEach((o,l)=>{l>0&&e.write("."),e.write(o)}))}getFullyQualifiedPath(){return this.modulePath.join(".")}getFullyQualifiedModulePath(){return`${this.getFullyQualifiedPath()}.${this.name}`}};var Y=class extends ee{constructor({module:t}){super({name:t,modulePath:[t]})}write(t){throw new Error("Not intended to be written outside the context of a PythonFile.")}};f();m();d();var fe=class extends ee{constructor({modulePath:e}){super({name:"*",modulePath:e});g(this,"docs")}write(e){throw new Error("Not intended to be written outside the context of a PythonFile.")}};var Ue=class extends S{constructor({path:e,statements:n,isInitFile:o=!1,comments:l,imports:s}){super();g(this,"path");g(this,"isInitFile");g(this,"statements",[]);g(this,"comments");this.path=e,this.isInitFile=o,n?.forEach(v=>this.addStatement(v)),this.comments=l??[],s?.forEach(v=>this.addReference(v))}addStatement(e){this.statements.push(e),this.inheritReferences(e)}write(e){let n=this.deduplicateReferences();this.updateWriterRefNameOverrides({writer:e,uniqueReferences:n}),this.writeComments(e),this.writeImports({writer:e,uniqueReferences:n}),this.statements.forEach((o,l)=>{o.write(e),e.newLine(),l<this.statements.length-1&&e.newLine()}),e.unsetRefNameOverrides()}updateWriterRefNameOverrides({writer:e,uniqueReferences:n}){let o=new Map(n),l={},s=this.getInitialUsedNames(),v=this.path.join("."),w=n.get(v);if(w){let{references:E}=w;E.forEach(F=>{let D=F.getFullyQualifiedModulePath(),R=F.name;l[D]={name:R,isAlias:!1},s.add(F.name)}),o.delete(v)}Array.from(o.values()).flatMap(({references:E})=>E).forEach(E=>{if(E instanceof fe||E instanceof Y)return;let F=E.alias??E.name,D=E.getFullyQualifiedModulePath(),R=F,A=E.modulePath.length-1,k=!!E.alias;for(;s.has(R);){k=!0;let M=E.modulePath[A];A<0||!M?R=`_${R}`:R=`${pi(M)}${R}`,A--}s.add(R),l[D]={name:R,isAlias:k}}),e.setRefNameOverrides(l)}getInitialUsedNames(){let e=new Set;return this.statements.forEach(n=>{(n instanceof ue||n instanceof ce||n instanceof pe)&&e.add(n.name)}),e}deduplicateReferences(){let e=new Map;for(let n of this.references){let o=n.name,l=n.getFullyQualifiedPath();if(l==="")continue;let s=e.get(l);s?s.referenceNames.has(o)||(s.references.push(n),s.referenceNames.add(o)):e.set(l,{modulePath:n.modulePath,references:[n],referenceNames:new Set([o])})}return e}writeComments(e){this.comments.forEach(n=>{n.write(e)}),this.comments.length>0&&e.newLine()}getImportName({writer:e,reference:n}){let o=e.getRefNameOverride(n),l=n.name,s=o.isAlias?o.name:void 0;return`${l}${s?` as ${s}`:""}`}writeImports({writer:e,uniqueReferences:n}){if(n.size!==0){for(let[o,{modulePath:l,references:s}]of n){let v=l;if(!this.isDefinedInFile(v)){if(s.some(w=>w instanceof Y)){e.write(`import ${o}`),e.newLine();continue}if(v[0]===this.path[0]){let w=0;for(;w<this.path.length&&w<v.length&&this.path[w]===v[w];)w++;let N=this.path.length-w;this.isInitFile&&N++;let E=N>0?".".repeat(N):".";E+=v.slice(w).join("."),e.write(`from ${E} import ${s.map(F=>this.getImportName({writer:e,reference:F})).join(", ")}`)}else e.write(`from ${o} import ${s.map(w=>this.getImportName({writer:e,reference:w})).join(", ")}`);e.newLine()}}e.newLine()}}isDefinedInFile(e){return e.length===this.path.length&&e.every((n,o)=>n===this.path[o])}};f();m();d();var it=class extends S{constructor(e){super();g(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"int":e.write("int");break;case"float":e.write("float");break;case"bool":e.write("bool");break;case"str":e.write("str");break;case"bytes":e.write("bytes");break;case"list":e.write("List["),this.internalType.value.write(e),e.write("]");break;case"set":e.write("Set["),this.internalType.value.write(e),e.write("]");break;case"tuple":e.write("Tuple["),this.internalType.values.forEach((n,o)=>{o>0&&e.write(", "),n.write(e)}),e.write("]");break;case"dict":e.write("Dict["),this.internalType.keyType.write(e),e.write(", "),this.internalType.valueType.write(e),e.write("]");break;case"none":e.write("None");break;case"uuid":e.write("UUID");break;case"optional":e.write("Optional["),this.internalType.value.write(e),e.write("]");break;case"union":e.write("Union["),this.internalType.values.forEach((n,o)=>{o>0&&e.write(", "),n.write(e)}),e.write("]");break;case"any":e.write("Any");break;case"reference":this.internalType.value.write(e);break;case"datetime":e.write("datetime");break;case"literal":typeof this.internalType.value=="string"?e.write(`Literal["${this.internalType.value}"]`):e.write(`Literal[${this.internalType.value}]`);break;default:B(this.internalType)}}static int(){return new this({type:"int"})}static float(){return new this({type:"float"})}static bool(){return new this({type:"bool"})}static str(){return new this({type:"str"})}static bytes(){return new this({type:"bytes"})}static list(e){let n=new this({type:"list",value:e});return n.addReference(y.reference({name:"List",modulePath:["typing"]})),n.inheritReferences(e),n}static set(e){let n=new this({type:"set",value:e});return n.addReference(y.reference({name:"Set",modulePath:["typing"]})),n.inheritReferences(e),n}static tuple(e){let n=new this({type:"tuple",values:e});return n.addReference(y.reference({name:"Tuple",modulePath:["typing"]})),e.forEach(o=>n.inheritReferences(o)),n}static dict(e,n){let o=new this({type:"dict",keyType:e,valueType:n});return o.addReference(y.reference({name:"Dict",modulePath:["typing"]})),o.inheritReferences(e),o.inheritReferences(n),o}static none(){return new this({type:"none"})}static uuid(){let e=new this({type:"uuid"});return e.addReference(y.reference({name:"UUID",modulePath:["uuid"]})),e}static optional(e){if(this.isAlreadyOptional(e))return e;let n=new this({type:"optional",value:e});return n.addReference(y.reference({name:"Optional",modulePath:["typing"]})),n.inheritReferences(e),n}static union(e){let n=new this({type:"union",values:e});return n.addReference(y.reference({name:"Union",modulePath:["typing"]})),e.forEach(o=>n.inheritReferences(o)),n}static any(){let e=new this({type:"any"});return e.addReference(y.reference({name:"Any",modulePath:["typing"]})),e}static datetime(){let e=new this({type:"datetime"});return e.addReference(y.reference({name:"datetime",modulePath:["datetime"]})),e}static reference(e){let n=new this({type:"reference",value:e});return n.addReference(e),n}static literal(e){let n=new this({type:"literal",value:e});return n.addReference(y.reference({name:"Literal",modulePath:["typing"]})),n}static isAlreadyOptional(e){return e.internalType.type==="optional"}};f();m();d();var de=class p extends S{constructor(e){super();g(this,"internalType");this.internalType=e}static int(e){return new this({type:"int",value:e})}static float(e){return new this({type:"float",value:e})}static bool(e){return new this({type:"bool",value:e})}static str(e,n={multiline:!1,startOnNewLine:!1,endWithNewLine:!1}){return new this({type:"str",value:e,config:n})}static bytes(e){return new this({type:"bytes",value:e})}static list(e,n={endWithComma:!1}){let o=new this({type:"list",values:e,config:n});return e.forEach(l=>o.inheritReferences(l)),o}static set(e,n={endWithComma:!1}){let o=new this({type:"set",values:e,config:n});return e.forEach(l=>o.inheritReferences(l)),o}static tuple(e,n={endWithComma:!1}){let o=new this({type:"tuple",values:e,config:n});return e.forEach(l=>o.inheritReferences(l)),o}static typedDict(e,n={endWithComma:!1}){let o=new this({type:"typedDict",entries:e,config:n});return e.forEach(l=>o.inheritReferences(l.value)),o}static date(e){let n=new this({type:"date",value:e});return n.addReference(new Y({module:"datetime"})),n}static datetime(e){let n=new this({type:"datetime",value:e});return n.addReference(new Y({module:"datetime"})),n}static dict(e,n={endWithComma:!1}){let o=new this({type:"dict",entries:e,config:n});return e.forEach(l=>{o.inheritReferences(l.key),o.inheritReferences(l.value)}),o}static reference(e){let n=new this({type:"reference",value:e});return n.inheritReferences(e),n}static none(){return new this({type:"none"})}static unknown(e){return new this({type:"unknown",value:e})}static uuid(e){let n=new this({type:"uuid",value:e});return n.addReference(new Y({module:"uuid"})),n}static nop(){return new this({type:"nop"})}static isNop(e){return e instanceof p&&e.internalType.type==="nop"}isTypedDict(){return this.internalType.type==="typedDict"}asTypedDictOrThrow(){if(this.isTypedDict())return this.internalType;throw new Error("Internal error; python.TypeInstantiation is not a TypedDict")}write(e){switch(this.internalType.type){case"int":e.write(this.internalType.value.toString());break;case"float":e.write(this.internalType.value.toString());break;case"bool":this.internalType.value?e.write("True"):e.write("False");break;case"str":if(this.internalType.config?.multiline){let{startOnNewLine:n,endWithNewLine:o}=this.internalType.config;this.writeStringWithTripleQuotes({writer:e,value:this.internalType.value,startOnNewLine:n,endWithNewLine:o})}else e.write(`"${this.escapeString(this.internalType.value)}"`);break;case"date":e.write(`datetime.date.fromisoformat("${this.internalType.value}")`);break;case"datetime":{let n=this.internalType.value.replace(/Z$/,"+00:00");e.write(`datetime.datetime.fromisoformat("${n}")`);break}case"bytes":e.write(`b"${this.internalType.value}"`);break;case"list":{let n=this.internalType,o=Tt({values:n.values});if(o.length===0){e.write("[]");break}e.write("["),n.config?.multiline&&(e.newLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),l.write(e),s===o.length-1&&n.config?.endWithComma&&e.write(",")}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write("]");break}case"set":{let n=this.internalType,o=Tt({values:n.values});if(o.length===0){e.write("{}");break}e.write("{"),n.config?.multiline&&(e.newLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),l.write(e),s===o.length-1&&n.config?.endWithComma&&e.write(",")}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"tuple":{let n=this.internalType,o=Tt({values:n.values});if(o.length===0){e.write("()");break}e.write("("),n.config?.multiline&&(e.newLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),l.write(e),(o.length===1||s===o.length-1&&n.config?.endWithComma)&&e.write(",")}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write(")");break}case"dict":{let n=this.internalType,o=ba({entries:n.entries});if(o.length===0){e.write("{}");break}e.write("{"),n.config?.multiline&&(e.newLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),l.key.write(e),e.write(": "),l.value.write(e),s===o.length-1&&n.config?.endWithComma&&e.write(",")}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"typedDict":{let n=this.internalType,o=Ea({entries:n.entries});if(o.length===0){e.write("{}");break}e.write("{"),n.config?.multiline&&(e.writeLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),e.write(`"${l.name}": `),l.value.write(e)}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"reference":{this.internalType.value.write(e);break}case"none":e.write("None");break;case"unknown":this.writeUnknown({writer:e,value:this.internalType.value});break;case"uuid":e.write(`uuid.UUID("${this.internalType.value}")`);break;case"nop":break;default:B(this.internalType)}}writeStringWithTripleQuotes({writer:e,value:n,startOnNewLine:o,endWithNewLine:l}){e.write('"""');let s=n.split(`
15
+ `),o=J&&!this.shouldSkipTracking(n)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${n.shift()||""}`),this.lastCharacterIsNewline&&n.pop(),this.lineBuffer.push(...n),o&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(n=>`${e?`(${e}) `:""} ${n.fn} - ${n.path} : ${n.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(rt({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,wt){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return Ta}};f();m();d();f();m();d();f();m();d();var je=class{constructor(){g(this,"reporter");g(this,"snippet");g(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:t,snippet:e}){this.shouldUpdate({snippet:e,reporter:t.errors})&&(this.reporter=t.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:t}){if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw this.err??new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}shouldUpdate({snippet:t,reporter:e}){return this.reporter==null||this.reporter.size()>0&&e.size()===0?!0:t.length>(this.snippet?.length??0)}};var We=class{constructor(t){g(this,"context");this.context=t}async generate(t,e={}){let n=this.resolveEndpoints({request:t,options:e});if(n.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let o=new je;for(let l of n){let s=this.context.clone(),v=this.createSnippetGenerator(s);try{let w=await v.generateSnippet({endpoint:l,request:t,options:e});if(s.errors.empty())return{snippet:w,errors:void 0};o.update({context:s,snippet:w})}catch(w){o.err==null&&(o.err=w)}}return o.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let n=this.resolveEndpoints({request:t,options:e});if(n.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let o;for(let l of n){let s=this.context.clone(),v=this.createSnippetGenerator(s);try{return await v.generateSnippetAst({endpoint:l,request:t,options:e})}catch(w){o=w}}throw o??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let n=this.resolveEndpoints({request:t,options:e});if(n.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let o=new je;for(let l of n){let s=this.context.clone(),v=this.createSnippetGenerator(s);try{let w=v.generateSnippetSync({endpoint:l,request:t,options:e});if(s.errors.empty())return{snippet:w,errors:void 0};o.update({context:s,snippet:w})}catch(w){o.err==null&&(o.err=w)}}return o.getResponseOrThrow({endpoint:t.endpoint})}resolveEndpoints({request:t,options:e}){if(e.endpointId!=null){let n=this.context.resolveEndpointById(e.endpointId);if(n==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[n]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}};f();m();d();f();m();d();f();m();d();var qe=class{constructor(){g(this,"REFERENCE_REGEX",/^(?:(\w+)::)?(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let n=t.match(this.REFERENCE_REGEX);if(!(n==null||n[2]==null||n[3]==null))return{namespace:n[1],method:n[2],path:n[3]}}};f();m();d();var C={Critical:"CRITICAL",Warning:"WARNING"},Ge=class p{constructor(){g(this,"errors");g(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push({...t,path:[...this.path]})}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}truncate(t){this.errors.length=t}clone(){let t=new p;return t.errors=[...this.errors],t.path=[...this.path],t}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(t=>({severity:t.severity,path:t.path!=null?this.pathToStringArray(t.path):void 0,message:t.message}))}pathToStringArray(t){let e=[];for(let n of t){if(typeof n=="string"){e.push(n);continue}e[e.length-1]+=`[${n.index}]`}return e}};var ze=class{constructor({ir:t,config:e,options:n={}}){g(this,"config");g(this,"options");g(this,"errors");g(this,"_ir");g(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=n,this.errors=new Ge,this.httpEndpointReferenceParser=new qe}associateQueryParametersByWireValue({parameters:t,values:e}){let n=[];for(let[o,l]of Object.entries(e))if(l!==void 0){this.errors.scope(o);try{let s=t.find(w=>w.name.wireValue===o);if(s==null)throw this.newParameterNotRecognizedError(o);let v=this.isListTypeReference(s.typeReference)&&!Array.isArray(l)?[l]:l;n.push({name:s.name,typeReference:s.typeReference,value:v})}finally{this.errors.unscope()}}return n}associateByWireValueOrDefault({parameters:t,values:e}){let n=[];for(let o of t){this.errors.scope(o.name.wireValue);try{let l=e[o.name.wireValue];if(l==null)if(o.typeReference.type==="primitive"&&o.typeReference.value==="STRING")l=`<${o.name.wireValue}>`;else{this.errors.add({severity:C.Critical,message:this.newParameterNotRecognizedError(o.name.wireValue).message});continue}n.push({name:o.name,typeReference:o.typeReference,value:l})}finally{this.errors.unscope()}}return n}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:n}){let o=[],l=new Set;for(let s of t){let v=s.name.wireValue,w=e[v];if(w!==void 0){l.add(v),this.errors.scope(v);try{o.push({name:s.name,typeReference:s.typeReference,value:w})}finally{this.errors.unscope()}}}if(!n){for(let[s,v]of Object.entries(e))if(!(v===void 0||l.has(s))){this.errors.scope(s);try{this.errors.add({severity:C.Critical,message:this.newParameterNotRecognizedError(s).message})}finally{this.errors.unscope()}}}return o}getExampleObjectProperties({parameters:t,snippetObject:e}){let n=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},o=[];for(let l of t){let s=n[l.name.wireValue];s==null?l.typeReference.type==="nullable"&&o.push({name:l.name,typeReference:l.typeReference,value:null}):o.push({name:l.name,typeReference:l.typeReference,value:s})}return o}getSingleFileValue({property:t,record:e}){let n=e[t.wireValue];if(n!=null){if(typeof n!="string"){this.errors.add({severity:C.Critical,message:`Expected file value to be a string, got ${typeof n}`});return}return n}}getFileArrayValues({property:t,record:e}){let n=e[t.wireValue];if(n==null)return;if(!Array.isArray(n)){this.errors.add({severity:C.Critical,message:`Expected file array value to be an array of strings, got ${typeof n}`});return}let o=[];for(let l of n){if(typeof l!="string"){this.errors.add({severity:C.Critical,message:`Expected file array value to be an array of strings, got ${typeof l}`});return}o.push(l)}return o}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:C.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t??{}}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:C.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let n=this.getRecord(e);if(n==null)return;let o=t.discriminant.wireValue,l=n[o];if(l==null){this.errors.add({severity:C.Critical,message:this.newParameterNotRecognizedError(o).message});return}if(typeof l!="string"){this.errors.add({severity:C.Critical,message:`Expected discriminant value to be a string but got: ${typeof l}`});return}let s=t.types[l];if(s==null){this.errors.add({severity:C.Critical,message:`No type found for discriminant value "${l}"`});return}let{[o]:v,...w}=n;return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:w}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocation(t){let e=[];for(let n of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:n,parsedEndpoint:t})&&e.push(n);return e}resolveEndpointLocationOrThrow(t){let e=this.resolveEndpointLocation(t);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}resolveEndpointById(t){return this._ir.endpoints[t]}resolveEndpointByIdOrThrow(t){let e=this.resolveEndpointById(t);if(e==null)throw new Error(`Failed to find endpoint with ID "${t}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:n}){return this.includePathParametersInWrappedRequest({request:t,inlinePathParameters:e})||t.queryParameters!=null&&t.queryParameters.length>0||t.headers!=null&&t.headers.length>0?!0:t.body!=null?this.includeRequestBodyInWrappedRequest({body:t.body,inlineFileProperties:n}):!t.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){return e&&(t.metadata?.includePathParameters??!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:B(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let n=e.environments.find(o=>o.id===t);return n?.name}case"multipleBaseUrls":{let n=e.environments.find(o=>o.id===t);return n?.name}default:B(e)}}isSingleEnvironmentID(t){return typeof t=="string"}isMultiEnvironmentValues(t){return typeof t=="object"}validateMultiEnvironmentUrlValues(t){if(this._ir.environments==null)return this.errors.add({severity:C.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":return this.errors.add({severity:C.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let n=e.environments[0];if(n==null)return this.errors.add({severity:C.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let o=new Set(Ve(n.urls));for(let l of Ve(t))o.has(l)&&o.delete(l);return o.size>0?(this.errors.add({severity:C.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${Ve(n.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:C.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:C.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:C.Critical,message:this.newTypeMismatchError({expected:"string",value:t}).message});return}return t}isOptional(t){switch(t.type){case"nullable":return this.isOptional(t.value);case"optional":return!0;case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}isNullable(t){switch(t.type){case"nullable":return!0;case"optional":return this.isNullable(t.value);case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}newAuthMismatchError({auth:t,values:e}){return new Error(`Expected auth type ${t.type}, got ${e.type}`)}newParameterNotRecognizedError(t){return new Error(`"${t}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:t,value:e}){return new Error(`Expected ${t}, got ${typeof e}`)}includeRequestBodyInWrappedRequest({body:t,inlineFileProperties:e}){switch(t.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e});default:B(t)}}includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e}){return this.fileUploadHasBodyProperties({fileUpload:t})||e&&this.fileUploadHasFileProperties({fileUpload:t})}fileUploadHasBodyProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:B(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:B(e)}})}isListTypeReference(t){return t.type==="optional"?this.isListTypeReference(t.value):t.type==="list"||t.type==="set"}parsedEndpointMatches({endpoint:t,parsedEndpoint:e}){return t.location.method===e.method&&t.location.path===e.path}};f();m();d();var K={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};f();m();d();f();m();d();var y={};Mt(y,{AccessAttribute:()=>Ee,AstNode:()=>S,Class:()=>ue,ClassInstantiation:()=>Ne,CodeBlock:()=>ie,Comment:()=>Ae,Decorator:()=>Se,Field:()=>pe,Lambda:()=>Be,LambdaParameter:()=>Fe,Method:()=>ce,MethodArgument:()=>Pe,MethodInvocation:()=>ke,ModuleImport:()=>Y,Operator:()=>Le,Parameter:()=>le,PythonFile:()=>Ue,Reference:()=>ee,StarImport:()=>fe,Type:()=>it,TypeInstantiation:()=>de,accessAttribute:()=>Ra,assign:()=>Na,class_:()=>Sa,codeBlock:()=>La,comment:()=>Ua,decorator:()=>Fa,field:()=>ka,file:()=>Aa,instantiateClass:()=>Ba,invokeFunction:()=>Va,invokeMethod:()=>Da,lambda:()=>Ma,lambdaParameter:()=>Oa,method:()=>_a,methodArgument:()=>ja,operator:()=>Wa,parameter:()=>$a,reference:()=>Ca,starImport:()=>Pa});f();m();d();f();m();d();f();m();d();f();m();d();var He=class extends $e{constructor(){super(...arguments);g(this,"fullyQualifiedModulePathsToImportedNames",{})}setRefNameOverrides(e){this.fullyQualifiedModulePathsToImportedNames=e}unsetRefNameOverrides(){this.fullyQualifiedModulePathsToImportedNames={}}getRefNameOverride(e){let n=this.fullyQualifiedModulePathsToImportedNames[e.getFullyQualifiedModulePath()];return n||{name:e.alias??e.name,isAlias:!!e.alias}}toString(){return this.buffer}async toStringFormatted(e){return e.format(this.buffer)}};var S=class extends ge{constructor(){super(...arguments);g(this,"references",[])}addReference(e){this.references.push(e)}inheritReferences(e){e!==void 0&&e.references.forEach(n=>{this.references.includes(n)||this.addReference(n)})}getReferences(){return this.references}toString(){let e=new He;return this.write(e),e.toString()}async toStringFormatted(e){let n=new He;return this.write(n),n.toStringFormatted(e)}};var Ee=class extends S{constructor({lhs:e,rhs:n}){super();g(this,"lhs");g(this,"rhs");this.lhs=e,this.inheritReferences(e),this.rhs=n,this.inheritReferences(n)}write(e){this.lhs.write(e),e.write("."),this.rhs.write(e)}};f();m();d();var nt=class extends S{constructor({lhs:e,rhs:n}){super();g(this,"lhs");g(this,"rhs");this.lhs=e,this.inheritReferences(e),this.rhs=n,this.inheritReferences(n)}write(e){this.lhs.write(e),e.write(" = "),this.rhs.write(e)}};f();m();d();var Re=class extends S{constructor({reference:e,arguments_:n,multiline:o}){super();g(this,"reference");g(this,"arguments");g(this,"multiline");this.reference=e,this.arguments=n,this.multiline=o??!1,this.inheritReferences(e),this.arguments.forEach(l=>{this.inheritReferences(l)})}write(e){if(this.reference.write(e),this.arguments.length===0){e.write("()");return}e.write("("),this.multiline&&(e.newLine(),e.indent()),this.arguments.forEach((n,o)=>{n.write(e),o<this.arguments.length-1?(e.write(","),this.multiline?e.newLine():e.write(" ")):this.multiline&&e.write(",")}),this.multiline&&(e.newLine(),e.dedent()),e.write(")")}};f();m();d();var ue=class extends S{constructor({docs:e,name:n,extends_:o,decorators:l}){super();g(this,"name");g(this,"extends_");g(this,"decorators");g(this,"fields",[]);g(this,"docs");g(this,"statements",[]);this.name=n,this.extends_=o??[],this.decorators=l??[],this.docs=e,this.extends_.forEach(s=>{this.inheritReferences(s)}),this.decorators.forEach(s=>{this.inheritReferences(s)})}write(e){this.decorators.forEach(n=>{n.write(e)}),e.write(`class ${this.name}`),this.extends_.length>0&&(e.write("("),this.extends_.forEach((n,o)=>{o>0&&e.write(", "),n.write(e)}),e.write(")")),e.write(":"),e.newLine(),e.indent(),this.docs!=null&&(e.write('"""'),e.write(this.docs),e.write('"""')),e.writeNewLineIfLastLineNot(),this.fields.forEach(n=>{n.write(e),e.writeNewLineIfLastLineNot()}),e.dedent(),e.indent(),this.statements.length?this.writeStatements({writer:e}):e.write("pass"),e.dedent()}add(e){this.statements.push(e),this.inheritReferences(e)}writeStatements({writer:e}){this.statements.forEach((n,o)=>{n.write(e),e.writeNewLineIfLastLineNot()})}addField(e){this.add(e)}};f();m();d();var Ne=class extends Re{constructor({classReference:t,...e}){super({reference:t,...e})}};f();m();d();var ie=class extends S{constructor(e){super();g(this,"arg");this.arg=e}write(e){return new Q(this.arg).write(e)}};f();m();d();var Ae=class extends S{constructor({docs:e}){super();g(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
16
+ `).forEach(n=>{e.writeLine(`# ${n}`)})}};f();m();d();var Se=class extends S{constructor({callable:e}){super();g(this,"callable");this.callable=e,this.inheritReferences(e)}write(e){e.write("@"),this.callable.write(e),e.newLine()}};f();m();d();var pe=class extends S{constructor({name:e,type:n,initializer:o,docs:l}){super();g(this,"name");g(this,"type");g(this,"initializer");g(this,"docs");this.name=e,this.type=n,this.initializer=o,this.docs=l,this.inheritReferences(this.type),this.inheritReferences(this.initializer)}write(e){e.write(this.name),this.type!==void 0&&(e.write(": "),this.type.write(e)),this.initializer!==void 0&&(e.write(" = "),this.initializer.write(e)),this.docs!=null&&(e.newLine(),e.write('"""'),e.newLine(),e.write(this.docs),e.newLine(),e.write('"""'))}};f();m();d();var Be=class extends S{constructor({parameters:e,body:n}){super();g(this,"parameters");g(this,"body");this.parameters=e??[],this.body=n,this.inheritReferences(n)}write(e){e.write("lambda"),this.parameters&&this.parameters.length&&(e.write(" "),this.parameters.forEach((n,o)=>{n.write(e),o<this.parameters.length-1&&e.write(", ")})),e.write(": "),this.body.write(e)}};f();m();d();f();m();d();var le=class extends S{constructor({name:e,type:n,initializer:o}){super();g(this,"name");g(this,"initializer");g(this,"type");this.name=e,this.type=n,this.initializer=o}write(e){e.write(this.name),this.type&&(e.write(": "),this.type.write(e)),this.initializer!==void 0&&(e.write(" = "),this.initializer.write(e))}};var Fe=class extends le{constructor({name:t,initializer:e}){super({name:t,initializer:e,type:void 0})}};f();m();d();var Ce;(function(p){p[p.STATIC=0]="STATIC",p[p.INSTANCE=1]="INSTANCE",p[p.CLASS=2]="CLASS"})(Ce||(Ce={}));var ce=class extends S{constructor({static_:e,name:n,parameters:o,return_:l,docstring:s,type:v,decorators:w}){super();g(this,"name");g(this,"return");g(this,"docstring");g(this,"type");g(this,"parameters");g(this,"decorators");g(this,"statements",[]);g(this,"static_");this.name=n,this.parameters=o??[],this.return=l,this.docstring=s,this.type=v,this.decorators=w??[],this.static_=e??!1,this.parameters.forEach(N=>{this.inheritReferences(N)}),this.inheritReferences(this.return),this.decorators.forEach(N=>{this.inheritReferences(N)}),this.statements.forEach(N=>{this.inheritReferences(N)})}addStatement(e){this.statements.push(e),this.inheritReferences(e)}write(e){this.static_&&this.decorators.push(y.decorator({callable:y.codeBlock("staticmethod")})),this.decorators.forEach(l=>{l.write(e)}),this.type===Ce.CLASS?y.decorator({callable:new ie("classmethod")}).write(e):this.type===Ce.STATIC&&y.decorator({callable:new ie("staticmethod")}).write(e),e.write(`def ${this.name}(`);let o=this.parameters.length>3;o&&(e.newLine(),e.indent()),this.type===Ce.INSTANCE?(e.write("self"),this.parameters.length>0&&(e.write(o?",":", "),o&&e.newLine())):this.type===Ce.CLASS&&(e.write("cls"),this.parameters.length>0&&(e.write(o?",":", "),o&&e.newLine())),this.parameters.forEach((l,s)=>{l.write(e),s<this.parameters.length-1&&(e.write(o?",":", "),o&&e.newLine())}),o&&(e.write(","),e.dedent(),e.newLine()),e.write(")"),this.return&&(e.write(" -> "),this.return.write(e)),e.write(":"),e.newLine(),this.docstring&&(e.indent(),e.write('"""'),e.write(this.docstring),e.write('"""'),e.newLine(),e.dedent()),this.statements.length?(e.indent(),this.statements.forEach((l,s)=>{l.write(e),s<this.statements.length-1&&e.newLine()}),e.dedent()):(e.indent(),e.write("pass"),e.dedent()),e.newLine()}};f();m();d();var Pe=class extends S{constructor({name:e,value:n}){super();g(this,"name");g(this,"value");this.name=e,this.value=n,this.inheritReferences(this.value)}write(e){this.name!==void 0&&(e.write(this.name),e.write("=")),this.value.write(e)}};f();m();d();var ke=class extends S{constructor({on:e,method:n,arguments_:o,multiline:l}){super();g(this,"on");g(this,"method");g(this,"arguments");g(this,"multiline");this.on=e,this.method=n,this.arguments=o,this.multiline=l??!1,this.inheritReferences(e),this.arguments.forEach(s=>{this.inheritReferences(s)})}write(e){if(this.on.write(e),e.write("."),e.write(this.method),this.arguments.length===0){e.write("()");return}e.write("("),this.multiline&&(e.newLine(),e.indent()),this.arguments.forEach((n,o)=>{n.write(e),o<this.arguments.length-1?(e.write(","),this.multiline?e.newLine():e.write(" ")):this.multiline&&e.write(",")}),this.multiline&&(e.newLine(),e.dedent()),e.write(")")}};f();m();d();f();m();d();var X={Or:"or",And:"and",Add:"add",Subtract:"subtract",Multiply:"multiple",Divide:"divide",Modulo:"modulo",LeftShift:"leftShift",RightShift:"rightShift"};var Le=class extends S{constructor({operator:e,lhs:n,rhs:o}){super();g(this,"operator");g(this,"lhs");g(this,"rhs");this.operator=e,this.lhs=n,this.inheritReferences(n),this.rhs=o,this.inheritReferences(o)}getOperatorString(){switch(this.operator){case X.Or:return"or";case X.And:return"and";case X.Add:return"+";case X.Subtract:return"-";case X.Multiply:return"*";case X.Divide:return"/";case X.Modulo:return"%";case X.LeftShift:return"<<";case X.RightShift:return">>";default:B(this.operator)}}write(e){this.lhs.write(e),e.write(" "),e.write(this.getOperatorString()),e.write(" "),this.rhs.write(e)}};f();m();d();f();m();d();function pi(p){if(!p)return"Class";let t=p.replace(/[^a-zA-Z0-9\s_-]/g," ").replace(/[-_\s]+/g," ").trim();return!t||/^\d+$/.test(t)?"Class"+(t||""):(/^\d/.test(t)&&(t="Class"+t),t.split(/(?=[A-Z])|[-_\s]+/).filter(n=>n.length>0).map(n=>n.split(/(?<=\d)(?=[a-zA-Z])|(?<=[a-zA-Z])(?=\d)/).filter(o=>o.length>0)).flat().map((n,o)=>o===0&&/^\d/.test(n)?"Class"+n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():n.length>1&&n===n.toUpperCase()&&!/^\d+$/.test(n)?n:n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(""))}f();m();d();f();m();d();var ee=class extends S{constructor({name:e,modulePath:n,genericTypes:o,alias:l,attribute:s}){super();g(this,"name");g(this,"modulePath");g(this,"genericTypes");g(this,"alias");g(this,"attribute");this.name=e,this.modulePath=n??[],this.genericTypes=o??[],this.alias=l,this.attribute=s??[],this.references.push(this),this.genericTypes.forEach(v=>{this.inheritReferences(v)})}write(e){let n=e.getRefNameOverride(this);e.write(n.name),this.genericTypes.length>0&&(e.write("["),this.genericTypes.forEach((o,l)=>{l>0&&e.write(", "),o.write(e)}),e.write("]")),this.attribute.length>0&&(e.write("."),this.attribute.forEach((o,l)=>{l>0&&e.write("."),e.write(o)}))}getFullyQualifiedPath(){return this.modulePath.join(".")}getFullyQualifiedModulePath(){return`${this.getFullyQualifiedPath()}.${this.name}`}};var Y=class extends ee{constructor({module:t}){super({name:t,modulePath:[t]})}write(t){throw new Error("Not intended to be written outside the context of a PythonFile.")}};f();m();d();var fe=class extends ee{constructor({modulePath:e}){super({name:"*",modulePath:e});g(this,"docs")}write(e){throw new Error("Not intended to be written outside the context of a PythonFile.")}};var Ue=class extends S{constructor({path:e,statements:n,isInitFile:o=!1,comments:l,imports:s}){super();g(this,"path");g(this,"isInitFile");g(this,"statements",[]);g(this,"comments");this.path=e,this.isInitFile=o,n?.forEach(v=>this.addStatement(v)),this.comments=l??[],s?.forEach(v=>this.addReference(v))}addStatement(e){this.statements.push(e),this.inheritReferences(e)}write(e){let n=this.deduplicateReferences();this.updateWriterRefNameOverrides({writer:e,uniqueReferences:n}),this.writeComments(e),this.writeImports({writer:e,uniqueReferences:n}),this.statements.forEach((o,l)=>{o.write(e),e.newLine(),l<this.statements.length-1&&e.newLine()}),e.unsetRefNameOverrides()}updateWriterRefNameOverrides({writer:e,uniqueReferences:n}){let o=new Map(n),l={},s=this.getInitialUsedNames(),v=this.path.join("."),w=n.get(v);if(w){let{references:E}=w;E.forEach(P=>{let D=P.getFullyQualifiedModulePath(),R=P.name;l[D]={name:R,isAlias:!1},s.add(P.name)}),o.delete(v)}Array.from(o.values()).flatMap(({references:E})=>E).forEach(E=>{if(E instanceof fe||E instanceof Y)return;let P=E.alias??E.name,D=E.getFullyQualifiedModulePath(),R=P,A=E.modulePath.length-1,k=!!E.alias;for(;s.has(R);){k=!0;let M=E.modulePath[A];A<0||!M?R=`_${R}`:R=`${pi(M)}${R}`,A--}s.add(R),l[D]={name:R,isAlias:k}}),e.setRefNameOverrides(l)}getInitialUsedNames(){let e=new Set;return this.statements.forEach(n=>{(n instanceof ue||n instanceof ce||n instanceof pe)&&e.add(n.name)}),e}deduplicateReferences(){let e=new Map;for(let n of this.references){let o=n.name,l=n.getFullyQualifiedPath();if(l==="")continue;let s=e.get(l);s?s.referenceNames.has(o)||(s.references.push(n),s.referenceNames.add(o)):e.set(l,{modulePath:n.modulePath,references:[n],referenceNames:new Set([o])})}return e}writeComments(e){this.comments.forEach(n=>{n.write(e)}),this.comments.length>0&&e.newLine()}getImportName({writer:e,reference:n}){let o=e.getRefNameOverride(n),l=n.name,s=o.isAlias?o.name:void 0;return`${l}${s?` as ${s}`:""}`}writeImports({writer:e,uniqueReferences:n}){if(n.size!==0){for(let[o,{modulePath:l,references:s}]of n){let v=l;if(!this.isDefinedInFile(v)){if(s.some(w=>w instanceof Y)){e.write(`import ${o}`),e.newLine();continue}if(v[0]===this.path[0]){let w=0;for(;w<this.path.length&&w<v.length&&this.path[w]===v[w];)w++;let N=this.path.length-w;this.isInitFile&&N++;let E=N>0?".".repeat(N):".";E+=v.slice(w).join("."),e.write(`from ${E} import ${s.map(P=>this.getImportName({writer:e,reference:P})).join(", ")}`)}else e.write(`from ${o} import ${s.map(w=>this.getImportName({writer:e,reference:w})).join(", ")}`);e.newLine()}}e.newLine()}}isDefinedInFile(e){return e.length===this.path.length&&e.every((n,o)=>n===this.path[o])}};f();m();d();var it=class extends S{constructor(e){super();g(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"int":e.write("int");break;case"float":e.write("float");break;case"bool":e.write("bool");break;case"str":e.write("str");break;case"bytes":e.write("bytes");break;case"list":e.write("List["),this.internalType.value.write(e),e.write("]");break;case"set":e.write("Set["),this.internalType.value.write(e),e.write("]");break;case"tuple":e.write("Tuple["),this.internalType.values.forEach((n,o)=>{o>0&&e.write(", "),n.write(e)}),e.write("]");break;case"dict":e.write("Dict["),this.internalType.keyType.write(e),e.write(", "),this.internalType.valueType.write(e),e.write("]");break;case"none":e.write("None");break;case"uuid":e.write("UUID");break;case"optional":e.write("Optional["),this.internalType.value.write(e),e.write("]");break;case"union":e.write("Union["),this.internalType.values.forEach((n,o)=>{o>0&&e.write(", "),n.write(e)}),e.write("]");break;case"any":e.write("Any");break;case"reference":this.internalType.value.write(e);break;case"datetime":e.write("datetime");break;case"literal":typeof this.internalType.value=="string"?e.write(`Literal["${this.internalType.value}"]`):e.write(`Literal[${this.internalType.value}]`);break;default:B(this.internalType)}}static int(){return new this({type:"int"})}static float(){return new this({type:"float"})}static bool(){return new this({type:"bool"})}static str(){return new this({type:"str"})}static bytes(){return new this({type:"bytes"})}static list(e){let n=new this({type:"list",value:e});return n.addReference(y.reference({name:"List",modulePath:["typing"]})),n.inheritReferences(e),n}static set(e){let n=new this({type:"set",value:e});return n.addReference(y.reference({name:"Set",modulePath:["typing"]})),n.inheritReferences(e),n}static tuple(e){let n=new this({type:"tuple",values:e});return n.addReference(y.reference({name:"Tuple",modulePath:["typing"]})),e.forEach(o=>n.inheritReferences(o)),n}static dict(e,n){let o=new this({type:"dict",keyType:e,valueType:n});return o.addReference(y.reference({name:"Dict",modulePath:["typing"]})),o.inheritReferences(e),o.inheritReferences(n),o}static none(){return new this({type:"none"})}static uuid(){let e=new this({type:"uuid"});return e.addReference(y.reference({name:"UUID",modulePath:["uuid"]})),e}static optional(e){if(this.isAlreadyOptional(e))return e;let n=new this({type:"optional",value:e});return n.addReference(y.reference({name:"Optional",modulePath:["typing"]})),n.inheritReferences(e),n}static union(e){let n=new this({type:"union",values:e});return n.addReference(y.reference({name:"Union",modulePath:["typing"]})),e.forEach(o=>n.inheritReferences(o)),n}static any(){let e=new this({type:"any"});return e.addReference(y.reference({name:"Any",modulePath:["typing"]})),e}static datetime(){let e=new this({type:"datetime"});return e.addReference(y.reference({name:"datetime",modulePath:["datetime"]})),e}static reference(e){let n=new this({type:"reference",value:e});return n.addReference(e),n}static literal(e){let n=new this({type:"literal",value:e});return n.addReference(y.reference({name:"Literal",modulePath:["typing"]})),n}static isAlreadyOptional(e){return e.internalType.type==="optional"}};f();m();d();var de=class p extends S{constructor(e){super();g(this,"internalType");this.internalType=e}static int(e){return new this({type:"int",value:e})}static float(e){return new this({type:"float",value:e})}static bool(e){return new this({type:"bool",value:e})}static str(e,n={multiline:!1,startOnNewLine:!1,endWithNewLine:!1}){return new this({type:"str",value:e,config:n})}static bytes(e){return new this({type:"bytes",value:e})}static list(e,n={endWithComma:!1}){let o=new this({type:"list",values:e,config:n});return e.forEach(l=>o.inheritReferences(l)),o}static set(e,n={endWithComma:!1}){let o=new this({type:"set",values:e,config:n});return e.forEach(l=>o.inheritReferences(l)),o}static tuple(e,n={endWithComma:!1}){let o=new this({type:"tuple",values:e,config:n});return e.forEach(l=>o.inheritReferences(l)),o}static typedDict(e,n={endWithComma:!1}){let o=new this({type:"typedDict",entries:e,config:n});return e.forEach(l=>o.inheritReferences(l.value)),o}static date(e){let n=new this({type:"date",value:e});return n.addReference(new Y({module:"datetime"})),n}static datetime(e){let n=new this({type:"datetime",value:e});return n.addReference(new Y({module:"datetime"})),n}static dict(e,n={endWithComma:!1}){let o=new this({type:"dict",entries:e,config:n});return e.forEach(l=>{o.inheritReferences(l.key),o.inheritReferences(l.value)}),o}static reference(e){let n=new this({type:"reference",value:e});return n.inheritReferences(e),n}static none(){return new this({type:"none"})}static unknown(e){return new this({type:"unknown",value:e})}static uuid(e){let n=new this({type:"uuid",value:e});return n.addReference(new Y({module:"uuid"})),n}static nop(){return new this({type:"nop"})}static isNop(e){return e instanceof p&&e.internalType.type==="nop"}isTypedDict(){return this.internalType.type==="typedDict"}asTypedDictOrThrow(){if(this.isTypedDict())return this.internalType;throw new Error("Internal error; python.TypeInstantiation is not a TypedDict")}write(e){switch(this.internalType.type){case"int":e.write(this.internalType.value.toString());break;case"float":e.write(this.internalType.value.toString());break;case"bool":this.internalType.value?e.write("True"):e.write("False");break;case"str":if(this.internalType.config?.multiline){let{startOnNewLine:n,endWithNewLine:o}=this.internalType.config;this.writeStringWithTripleQuotes({writer:e,value:this.internalType.value,startOnNewLine:n,endWithNewLine:o})}else e.write(`"${this.escapeString(this.internalType.value)}"`);break;case"date":e.write(`datetime.date.fromisoformat("${this.internalType.value}")`);break;case"datetime":{let n=this.internalType.value.replace(/Z$/,"+00:00");e.write(`datetime.datetime.fromisoformat("${n}")`);break}case"bytes":e.write(`b"${this.internalType.value}"`);break;case"list":{let n=this.internalType,o=Tt({values:n.values});if(o.length===0){e.write("[]");break}e.write("["),n.config?.multiline&&(e.newLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),l.write(e),s===o.length-1&&n.config?.endWithComma&&e.write(",")}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write("]");break}case"set":{let n=this.internalType,o=Tt({values:n.values});if(o.length===0){e.write("{}");break}e.write("{"),n.config?.multiline&&(e.newLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),l.write(e),s===o.length-1&&n.config?.endWithComma&&e.write(",")}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"tuple":{let n=this.internalType,o=Tt({values:n.values});if(o.length===0){e.write("()");break}e.write("("),n.config?.multiline&&(e.newLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),l.write(e),(o.length===1||s===o.length-1&&n.config?.endWithComma)&&e.write(",")}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write(")");break}case"dict":{let n=this.internalType,o=ba({entries:n.entries});if(o.length===0){e.write("{}");break}e.write("{"),n.config?.multiline&&(e.newLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),l.key.write(e),e.write(": "),l.value.write(e),s===o.length-1&&n.config?.endWithComma&&e.write(",")}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"typedDict":{let n=this.internalType,o=Ea({entries:n.entries});if(o.length===0){e.write("{}");break}e.write("{"),n.config?.multiline&&(e.writeLine(),e.indent()),o.forEach((l,s)=>{s>0&&(e.write(","),n.config?.multiline?e.newLine():e.write(" ")),e.write(`"${l.name}": `),l.value.write(e)}),n.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"reference":{this.internalType.value.write(e);break}case"none":e.write("None");break;case"unknown":this.writeUnknown({writer:e,value:this.internalType.value});break;case"uuid":e.write(`uuid.UUID("${this.internalType.value}")`);break;case"nop":break;default:B(this.internalType)}}writeStringWithTripleQuotes({writer:e,value:n,startOnNewLine:o,endWithNewLine:l}){e.write('"""');let s=n.split(`
17
17
  `);if(s.length<=1){e.write(this.escapeString(s[0]??"")),e.write('"""');return}o&&e.writeNoIndent(`\\
18
18
  `),s.forEach((v,w)=>{e.writeNoIndent(this.escapeString(v)),w===s.length-1?l&&e.writeNoIndent(`\\
19
19
  `):e.writeNoIndent(`
20
- `)}),e.writeNoIndent('"""')}escapeString(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/'/g,"\\'").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}writeUnknown({writer:e,value:n}){switch(typeof n){case"boolean":e.write(n?"True":"False");return;case"string":e.write(`"${this.escapeString(n)}"`);return;case"number":e.write(n.toString());return;case"object":if(n==null){e.write("None");return}if(Array.isArray(n)){this.writeUnknownArray({writer:e,value:n});return}this.writeUnknownObject({writer:e,value:n});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof n}`)}}writeUnknownArray({writer:e,value:n}){if(n.length===0){e.write("[]");return}e.write("["),n.forEach((o,l)=>{l>0&&e.write(", "),e.writeNode(p.unknown(o))}),e.write("]")}writeUnknownObject({writer:e,value:n}){let o=Object.entries(n);if(o.length===0){e.write("{}");return}e.write("{"),o.forEach(([l,s],v)=>{v>0&&e.write(", "),e.write(`"${l}": `),e.writeNode(p.unknown(s))}),e.write("}")}};function ba({entries:p}){return p.filter(t=>!de.isNop(t.key)&&!de.isNop(t.value))}function Ea({entries:p}){return p.filter(t=>!de.isNop(t.value))}function Tt({values:p}){return p.filter(t=>!de.isNop(t))}function Ra(p){return new Ee(p)}function Na(p){return new nt(p)}function Aa(p){return new Ue(p)}function Sa(p){return new ue(p)}function Ba(p){return new Ne(p)}function Ca(p){return new Se(p)}function Pa(p){return new ee(p)}function Fa(p){return new fe(p)}function ka(p){return new pe(p)}function La(p){return new ie(p)}function Ua(p){return new Ae(p)}function Ma(p){return new Be(p)}function Oa(p){return new Ce(p)}function _a(p){return new ce(p)}function Va(p){return new Re(p)}function Da(p){return new ke(p)}function $a(p){return new le(p)}function ja(p){return new Fe(p)}function Wa(p){return new Le(p)}f();m();d();var qa="value",ot=class{constructor({context:t}){g(this,"context");this.context=t}convert(t){if(t.value===null)return this.context.isNullable(t.typeReference)?y.TypeInstantiation.none():(this.context.errors.add({severity:P.Critical,message:"Expected non-null value, but got null"}),y.TypeInstantiation.nop());if(t.value===void 0)return y.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return this.convertLiteral({literalType:t.typeReference.value,value:t.value});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?y.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"optional":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"nullable":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertSet({set:t.typeReference.value,value:t.value});case"unknown":return y.TypeInstantiation.unknown(t.value);default:B(t.typeReference)}}convertLiteral({literalType:t,value:e}){switch(t.type){case"boolean":{let n=this.context.getValueAsBoolean({value:e});return n==null?y.TypeInstantiation.nop():y.TypeInstantiation.bool(n)}case"string":{let n=this.context.getValueAsString({value:e});return n==null?y.TypeInstantiation.nop():y.TypeInstantiation.str(n)}default:B(t)}}convertList({list:t,value:e}){return Array.isArray(e)?y.TypeInstantiation.list(e.map((n,o)=>{this.context.errors.scope({index:o});try{return this.convert({typeReference:t,value:n})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:P.Critical,message:`Expected array but got: ${typeof e}`}),y.TypeInstantiation.nop())}convertSet({set:t,value:e}){return Array.isArray(e)?y.TypeInstantiation.list(e.map((n,o)=>{this.context.errors.scope({index:o});try{return this.convert({typeReference:t,value:n})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:P.Critical,message:`Expected array but got: ${typeof e}`}),y.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:P.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),y.TypeInstantiation.nop()):y.TypeInstantiation.dict(Object.entries(e).map(([n,o])=>{this.context.errors.scope(n);try{return{key:this.convert({typeReference:t.key,value:n,as:"key"}),value:this.convert({typeReference:t.value,value:o})}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertNamed({named:t,value:e,as:n}){switch(t.type){case"alias":return this.convert({typeReference:t.typeReference,value:e,as:n});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:B(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let n=this.context.useTypedDictRequests(),o=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(o==null)return y.TypeInstantiation.nop();let l=o.singleDiscriminatedUnionType,s=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:o,unionVariant:l});if(s==null)return y.TypeInstantiation.nop();if(n){let w={name:this.context.getPropertyName(t.discriminant.name),value:y.TypeInstantiation.str(o.discriminantValue.wireValue)};return y.TypeInstantiation.typedDict([w,...s],{multiline:!0})}let v=this.context.getDiscriminatedUnionVariantClassReference({unionDeclaration:t.declaration,discriminantValue:l.discriminantValue});return y.TypeInstantiation.reference(y.instantiateClass({classReference:v,arguments_:s.map(w=>y.methodArgument({name:w.name,value:w.value})),multiline:!0}))}convertDiscriminatedUnionToFlatKwargs({discriminatedUnion:t,value:e}){let n=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(n==null)return;let o=n.singleDiscriminatedUnionType,l=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:n,unionVariant:o});if(l==null)return;let s={name:this.context.getPropertyName(t.discriminant.name),value:y.TypeInstantiation.str(n.discriminantValue.wireValue)};return[...l,s]}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:t,unionVariant:e}){let n=this.getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e});switch(e.type){case"samePropertiesAsObject":{let o=this.context.resolveNamedType({typeId:e.typeId});if(o==null)return;if(o.type!=="object"){this.context.errors.add({severity:P.Critical,message:"Internal error; expected union value to be an object"});return}let l=this.convertObjectEntries({object_:o,value:t.value}),s=new Set(n.map(w=>w.name)),v=l.filter(w=>!s.has(w.name));return[...n,...v]}case"singleProperty":try{this.context.errors.scope(e.discriminantValue.wireValue);let o=this.context.getRecord(t.value);return o==null?[...n,{name:qa,value:this.convert({typeReference:e.typeReference,value:t.value})}]:[...n,{name:this.context.getPropertyName(e.discriminantValue.name),value:this.convert({typeReference:e.typeReference,value:o[e.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return n;default:B(e)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getPropertyName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})}convertObjectEntries({object_:t,value:e}){let n=this.context.getRecord(e)??{},o=this.context.associateByWireValue({parameters:t.properties,values:n}),l=new Set(Object.keys(n)),s=o.map(v=>{this.context.errors.scope(v.name.wireValue);try{return{name:this.context.getPropertyName(v.name.name),value:this.convert(v)}}finally{this.context.errors.unscope()}});for(let v of t.properties){if(l.has(v.name.wireValue)||this.context.isOptional(v.typeReference)||this.context.isNullable(v.typeReference))continue;let w=this.synthesizeDefaultValue(v.typeReference);y.TypeInstantiation.isNop(w)||s.push({name:this.context.getPropertyName(v.name.name),value:w})}return s.filter(v=>!y.TypeInstantiation.isNop(v.value))}convertObject({object_:t,value:e}){let n=this.context.useTypedDictRequests(),o=this.convertObjectEntries({object_:t,value:e});if(n)return y.TypeInstantiation.typedDict(o,{multiline:!0});let l=this.context.getTypeClassReference(t.declaration);return y.TypeInstantiation.reference(y.instantiateClass({classReference:l,arguments_:o.map(s=>y.methodArgument({name:s.name,value:s.value})),multiline:!0}))}convertEnum({enum_:t,value:e}){let n=this.getEnumValue({enum_:t,value:e});if(n==null)return y.TypeInstantiation.nop();let o=this.context.customConfig.pydantic_config?.enum_type;if(o==="python_enums"||o==="forward_compatible_python_enums"){let l=this.context.getTypeClassReference(t.declaration),s=n.name.screamingSnakeCase.safeName;return y.TypeInstantiation.reference(y.accessAttribute({lhs:l,rhs:y.codeBlock(s)}))}return y.TypeInstantiation.str(n.wireValue)}getEnumValue({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:P.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let n=t.values.find(o=>o.wireValue===e);if(n==null){this.context.errors.add({severity:P.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return n}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let n=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});return n??y.TypeInstantiation.nop()}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let n of t.types){let o=this.context.errors.size();try{let l=this.convert({typeReference:n,value:e});if(y.TypeInstantiation.isNop(l)||this.context.errors.size()>o){this.context.errors.truncate(o);continue}return l}catch{this.context.errors.truncate(o);continue}}this.context.errors.add({severity:P.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}synthesizeDefaultValue(t,e=new Set){switch(t.type){case"optional":case"nullable":return y.TypeInstantiation.nop();case"primitive":return this.synthesizeDefaultPrimitive(t.value);case"literal":return this.synthesizeDefaultLiteral(t.value);case"list":return y.TypeInstantiation.list([]);case"set":return y.TypeInstantiation.list([]);case"map":return y.TypeInstantiation.dict([]);case"named":{if(e.has(t.value))return y.TypeInstantiation.nop();let n=this.context.resolveNamedType({typeId:t.value});return n==null?y.TypeInstantiation.nop():this.synthesizeDefaultNamed({named:n,typeId:t.value,seen:e})}case"unknown":return y.TypeInstantiation.nop();default:B(t)}}synthesizeDefaultPrimitive(t){switch(t){case"STRING":case"BASE_64":case"BIG_INTEGER":return y.TypeInstantiation.str("string");case"INTEGER":case"LONG":case"UINT":case"UINT_64":return y.TypeInstantiation.int(1);case"FLOAT":case"DOUBLE":return y.TypeInstantiation.float(1.1);case"BOOLEAN":return y.TypeInstantiation.bool(!0);case"DATE":return y.TypeInstantiation.date("2024-01-15");case"DATE_TIME":case"DATE_TIME_RFC_2822":return y.TypeInstantiation.datetime("2024-01-15T09:30:00Z");case"UUID":return y.TypeInstantiation.uuid("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32");default:B(t)}}synthesizeDefaultLiteral(t){switch(t.type){case"boolean":return y.TypeInstantiation.bool(t.value);case"string":return y.TypeInstantiation.str(t.value);default:B(t)}}synthesizeDefaultNamed({named:t,typeId:e,seen:n}){let o=this.context.useTypedDictRequests(),l=new Set(n);switch(l.add(e),t.type){case"alias":return this.synthesizeDefaultValue(t.typeReference,l);case"enum":{let s=t.values[0];if(s==null)return y.TypeInstantiation.nop();let v=this.context.customConfig.pydantic_config?.enum_type;if(v==="python_enums"||v==="forward_compatible_python_enums"){let w=this.context.getTypeClassReference(t.declaration),N=s.name.screamingSnakeCase.safeName;return y.TypeInstantiation.reference(y.accessAttribute({lhs:w,rhs:y.codeBlock(N)}))}return y.TypeInstantiation.str(s.wireValue)}case"object":{let s=[];for(let w of t.properties){if(this.context.isOptional(w.typeReference)||this.context.isNullable(w.typeReference))continue;let N=this.synthesizeDefaultValue(w.typeReference,l);y.TypeInstantiation.isNop(N)||s.push({name:this.context.getPropertyName(w.name.name),value:N})}if(o)return y.TypeInstantiation.typedDict(s,{multiline:!0});let v=this.context.getTypeClassReference(t.declaration);return y.TypeInstantiation.reference(y.instantiateClass({classReference:v,arguments_:s.map(w=>y.methodArgument({name:w.name,value:w.value})),multiline:!0}))}case"discriminatedUnion":case"undiscriminatedUnion":return y.TypeInstantiation.nop();default:B(t)}}convertPrimitive({primitive:t,value:e,as:n}){switch(t){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let o=this.getValueAsNumber({value:e,as:n});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.int(o)}case"FLOAT":case"DOUBLE":{let o=this.getValueAsNumber({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.float(o)}case"BOOLEAN":{let o=this.getValueAsBoolean({value:e,as:n});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.bool(o)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let o=this.context.getValueAsString({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.str(o)}case"UUID":{let o=this.context.getValueAsString({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.uuid(o)}case"DATE":{let o=this.context.getValueAsString({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.date(o)}case"DATE_TIME":case"DATE_TIME_RFC_2822":{let o=this.context.getValueAsString({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.datetime(o)}default:B(t)}}getValueAsNumber({value:t,as:e}){let n=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:n})}getValueAsBoolean({value:t,as:e}){let n=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:n})}};f();m();d();var at=class{constructor({context:t}){g(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){let n={fileFields:[],bodyPropertyFields:[]},o=this.context.getRecord(e)??{};for(let l of t.properties)switch(l.type){case"file":{let s=this.getSingleFileProperty({property:l,record:o});if(y.TypeInstantiation.isNop(s))break;n.fileFields.push({name:this.context.getPropertyName(l.name),value:s});break}case"fileArray":{let s=this.getArrayFileProperty({property:l,record:o});if(y.TypeInstantiation.isNop(s))break;n.fileFields.push({name:this.context.getPropertyName(l.name),value:s});break}case"bodyProperty":{let s=this.getBodyProperty({property:l,record:o});if(y.TypeInstantiation.isNop(s))break;n.bodyPropertyFields.push({name:this.context.getPropertyName(l.name.name),value:s});break}default:B(l)}return n}getSingleFileProperty({property:t,record:e}){let n=this.context.getSingleFileValue({property:t,record:e});return n==null&&(n=`example_${t.wireValue??"file"}`),this.context.getFileFromString(n)}getArrayFileProperty({property:t,record:e}){let n=this.context.getFileArrayValues({property:t,record:e});if(n==null){let o=`example_${t.wireValue??"files"}`;return y.TypeInstantiation.list([this.context.getFileFromString(o)])}return y.TypeInstantiation.list(n.map(o=>this.context.getFileFromString(o)))}getBodyProperty({property:t,record:e}){let n=e[t.name.wireValue];return n==null?y.TypeInstantiation.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:n})}};var Ga=["list","set"],st=class p extends ze{constructor({ir:e,config:n}){super({ir:e,config:n});g(this,"ir");g(this,"customConfig");g(this,"dynamicTypeLiteralMapper");g(this,"filePropertyMapper");this.ir=e,this.customConfig=n.customConfig??{},this.dynamicTypeLiteralMapper=new ot({context:this}),this.filePropertyMapper=new at({context:this})}clone(){return new p({ir:this.ir,config:this.config})}getClassName(e){let n=e.pascalCase.safeName,o=this.getRootClientClassName();return n===o?`${o}Model`:n}getTypedDictClassName(e){return`${this.getClassName(e)}Params`}getPropertyName(e){let n=e.snakeCase.safeName;return n.startsWith("_")?"f_"+n.substring(n.lastIndexOf("_")+1):n}getMethodName(e){return Ga.includes(e.snakeCase.unsafeName)?e.snakeCase.unsafeName:e.snakeCase.safeName}getModuleName(e){let n=e.originalName.match(/^(_+)/)?.[1]??"",l=e.originalName.slice(n.length).match(/(_+)$/)?.[1]??"";return`${n}${e.snakeCase.safeName}${l}`}getRootClientClassReference(){return y.reference({name:this.getRootClientClassName(),modulePath:this.getRootModulePath()})}getTypeClassReference(e){let n=this.getClassName(e.name),o=[...this.getRootModulePath(),...e.fernFilepath.allParts.map(l=>this.getModuleName(l))];return y.reference({name:n,modulePath:o})}getDiscriminatedUnionVariantClassReference({unionDeclaration:e,discriminantValue:n}){let o=this.getClassName(e.name),l=n.name.pascalCase.safeName,s=[...this.getRootModulePath(),...e.fernFilepath.allParts.map(w=>this.getModuleName(w))],v=this.customConfig.pydantic_config?.union_naming==="v1"?`${l}${o}`:`${o}_${l}`;return y.reference({name:v,modulePath:s})}useTypedDictRequests(){return this.customConfig.use_typeddict_requests===!0}getRootClientClassName(){return this.customConfig.client?.exported_class_name!=null?this.customConfig.client.exported_class_name:this.customConfig.client_class_name!=null?this.customConfig.client_class_name:this.customConfig.client?.class_name!=null?this.customConfig.client.class_name:this.pascalCase(this.config.organization)+this.pascalCase(this.config.workspaceName)}getEnvironmentClassName(){return`${this.getRootClientClassName()}Environment`}getEnvironmentTypeReferenceFromID(e){let n=this.resolveEnvironmentName(e);if(n!=null)return y.accessAttribute({lhs:this.getEnvironmentClassReference(),rhs:y.codeBlock(this.getEnvironmentEnumName(n))})}getEnvironmentClassReference(){return y.reference({name:this.getEnvironmentClassName(),modulePath:this.getEnvironmentModulePath()})}getEnvironmentEnumName(e){return e.screamingSnakeCase.safeName}isPrimitive(e){switch(e.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(e.value);case"named":{let n=this.resolveNamedType({typeId:e.value});if(n==null)return!1;switch(n.type){case"alias":return this.isPrimitive(n.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:B(n)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:B(e)}}getFileFromString(e){return y.TypeInstantiation.str(e)}getRootModulePath(){if(this.customConfig.package_name!=null)return[this.customConfig.package_name];let e=this.cleanOrganizationName();if(this.customConfig.use_api_name_in_package)return[e,this.getApiName()];if(this.customConfig.package_path!=null){let n=this.customConfig.package_path.replace(/\//g,".").split(".");return[e,...n]}return[e]}getCoreModulePath(){return this.getRootModulePath().concat("core")}getEnvironmentModulePath(){return this.getRootModulePath().concat("environment")}shouldInlinePathParameters(){return!0}cleanOrganizationName(){return this.config.organization.replace(/[^a-zA-Z0-9]/g,"_")}getApiName(){return xt(this.config.workspaceName)}pascalCase(e){let n=gt(e);return n.charAt(0).toUpperCase()+n.slice(1)}};f();m();d();var za={type:"primitive",value:"STRING"},Ha=["example"],li="client",xe="request",ut=class{constructor({context:t}){g(this,"context");this.context=t}async generateSnippet({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e}).toString()}generateSnippetSync({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e}).toString()}async generateSnippetAst({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e})}generateMethodCallSnippetAst({endpoint:t,request:e}){return this.callMethod({endpoint:t,snippet:e})}buildPythonFile({endpoint:t,snippet:e}){return y.file({path:Ha,statements:[this.constructClient({endpoint:t,snippet:e}),this.callMethod({endpoint:t,snippet:e})]})}constructClient({endpoint:t,snippet:e}){return y.assign({lhs:y.reference({name:li}),rhs:y.instantiateClass({classReference:this.context.getRootClientClassReference(),arguments_:this.getConstructorArgs({endpoint:t,snippet:e}).map(n=>y.methodArgument({name:n.name,value:n.value})),multiline:!0})})}getConstructorArgs({endpoint:t,snippet:e}){let n=[],o=this.getConstructorEnvironmentArgs({baseUrl:e.baseURL,environment:e.environment});return o.length>0&&n.push(...o),t.auth!=null&&(e.auth!=null?n.push(...this.getConstructorAuthArgs({auth:t.auth,values:e.auth})):this.context.errors.add({severity:P.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(K.Headers),this.context.ir.headers!=null&&e.headers!=null&&n.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),n}getConstructorEnvironmentArgs({baseUrl:t,environment:e}){let n=this.getEnvironmentValue({baseUrl:t,environment:e});return n==null?[]:e!=null&&this.context.isMultiEnvironmentValues(e)?[{name:"environment",value:n}]:[{name:this.getEnvironmentOptionName({environment:e}),value:n}]}getEnvironmentValue({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:P.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return y.TypeInstantiation.str(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let n=this.context.getEnvironmentTypeReferenceFromID(e);if(n==null){this.context.errors.add({severity:P.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return y.TypeInstantiation.reference(n)}if(this.context.isMultiEnvironmentValues(e))return this.context.validateMultiEnvironmentUrlValues(e)?y.TypeInstantiation.reference(y.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.entries(e).map(([n,o])=>({name:n,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:za,value:o})})).map(n=>y.methodArgument({name:n.name,value:n.value})),multiline:!0})):void 0}}getConstructorAuthArgs({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.addAuthMismatchError(t,e),[]):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.addAuthMismatchError(t,e),[]):this.getConstructorBearerAuthArgs({auth:t,values:e});case"header":return e.type!=="header"?(this.addAuthMismatchError(t,e),[]):this.getConstructorHeaderAuthArgs({auth:t,values:e});case"oauth":return e.type!=="oauth"?(this.addAuthMismatchError(t,e),[]):this.getConstructorOAuthArgs({auth:t,values:e});case"inferred":return e.type!=="inferred"?(this.addAuthMismatchError(t,e),[]):this.getConstructorInferredAuthArgs({auth:t,values:e});default:B(t)}}addAuthMismatchError(t,e){this.context.errors.add({severity:P.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message})}addWarning(t){this.context.errors.add({severity:P.Warning,message:t})}getConstructorBasicAuthArg({auth:t,values:e}){let n="usernameOmit"in t&&t.usernameOmit===!0,o="passwordOmit"in t&&t.passwordOmit===!0,l=[];return n||l.push({name:this.context.getPropertyName(t.username),value:y.TypeInstantiation.str(e.username)}),o||l.push({name:this.context.getPropertyName(t.password),value:y.TypeInstantiation.str(e.password)}),l}getConstructorBearerAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.token),value:y.TypeInstantiation.str(e.token)}]}getConstructorHeaderAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t.header.typeReference,value:e.value})}]}getConstructorOAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.clientId),value:y.TypeInstantiation.str(e.clientId)},{name:this.context.getPropertyName(t.clientSecret),value:y.TypeInstantiation.str(e.clientSecret)}]}getConstructorInferredAuthArgs({auth:t,values:e}){let n=t.parameters??[];if(n.length===0)return this.addWarning("Inferred auth scheme is missing parameters; cannot generate constructor arguments."),[];let o=e.values;if(o==null)return this.addWarning("Inferred auth values were not provided; cannot generate constructor arguments."),[];let l=[];for(let s of n){let v=s.name.wireValue;if(!Object.hasOwn(o,v)){this.addWarning(`Missing inferred auth value for ${v}`);continue}let w=o[v],N=this.context.dynamicTypeLiteralMapper.convert({typeReference:s.typeReference,value:w});y.TypeInstantiation.isNop(N)||l.push({name:this.context.getPropertyName(s.name.name),value:N})}return l}getConstructorHeaderArgs({headers:t,values:e}){let n=[];for(let o of t){let l=e[o.name.wireValue],s=this.getConstructorHeaderArg({header:o,value:l});s!=null&&n.push(s)}return n}getConstructorHeaderArg({header:t,value:e}){let n=this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:e});if(!y.TypeInstantiation.isNop(n))return{name:this.context.getPropertyName(t.name.name),value:n}}callMethod({endpoint:t,snippet:e}){return y.invokeMethod({on:y.reference({name:li}),method:this.getMethod({endpoint:t}),arguments_:this.getMethodArgs({endpoint:t,snippet:e}).filter(n=>!y.TypeInstantiation.isNop(n.value)).map(n=>y.methodArgument({name:n.name,value:n.value})),multiline:!0})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e});default:B(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let n=[];this.context.errors.scope(K.PathParameters);let o=[...this.context.ir.pathParameters??[],...t.pathParameters??[]],l=new Set;if(t.body!=null){let s=this.getBodyRequestArgs({body:t.body,value:e.requestBody});if(l=new Set(s.map(v=>v.name)),t.body.type==="typeReference"){let v=t.body.value;if(v.type==="named"){let w=this.context.resolveNamedType({typeId:v.value});if(w!=null&&w.type==="object")for(let N of w.properties)this.resolvesToLiteralType(N.typeReference)||l.add(this.context.getPropertyName(N.name.name))}}}if(o.length>0){let v=this.getPathParameters({namedParameters:o,snippet:e}).map(w=>l.has(w.name)?{...w,name:w.name+"_"}:w);n.push(...v)}return this.context.errors.unscope(),this.context.errors.scope(K.RequestBody),t.body!=null&&n.push(...this.getBodyRequestArgs({body:t.body,value:e.requestBody})),this.context.errors.unscope(),n}getBodyRequestArgs({body:t,value:e}){switch(t.type){case"bytes":return[{name:xe,value:this.getBytesBodyRequestTypeInstantiation({value:e})}];case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:t.value,value:e});default:B(t)}}getBodyRequestArgsForTypeReference({typeReference:t,value:e}){switch(t.type){case"named":{let n=this.context.resolveNamedType({typeId:t.value});return n==null?[]:this.getBodyRequestArgsForNamedTypeReference({typeReference:t,named:n,value:e})}case"nullable":case"optional":{let n=t.value;return n.type==="named"&&this.context.resolveNamedType({typeId:n.value})?.type==="object"?[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:n,value:e})}]:this.getBodyRequestArgsForTypeReference({typeReference:t.value,value:e})}case"list":case"map":case"set":case"literal":case"primitive":case"unknown":return[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:e})}];default:B(t)}}getBodyRequestArgsForNamedTypeReference({typeReference:t,named:e,value:n}){switch(e.type){case"alias":return this.getBodyRequestArgsForTypeReference({typeReference:e.typeReference,value:n});case"discriminatedUnion":if(this.context.customConfig.flatten_union_request_bodies===!0){let o=this.context.dynamicTypeLiteralMapper.convertDiscriminatedUnionToFlatKwargs({discriminatedUnion:e,value:n});if(o!=null)return o}return[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:n})}];case"enum":case"undiscriminatedUnion":return[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:n})}];case"object":return this.context.customConfig.inline_request_params===!1?[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:n})}]:this.context.associateByWireValue({parameters:e.properties,values:this.context.getRecord(n)??{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference)).map(s=>({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)}));default:B(e)}}resolvesToLiteralType(t){switch(t.type){case"literal":return!0;case"optional":case"nullable":return this.resolvesToLiteralType(t.value);case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.resolvesToLiteralType(e.typeReference):!1}case"list":case"map":case"set":case"primitive":case"unknown":return!1;default:B(t)}}resolvesToNonOptionalLiteralType(t){switch(t.type){case"literal":return!0;case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.resolvesToNonOptionalLiteralType(e.typeReference):!1}case"optional":case"nullable":case"list":case"map":case"set":case"primitive":case"unknown":return!1;default:B(t)}}getBodyRequestArgsForBytes({body:t,value:e}){let n=this.getBytesBodyRequestTypeInstantiation({value:e});return y.TypeInstantiation.isNop(n)?[]:[{name:xe,value:n}]}getBytesBodyRequestTypeInstantiation({value:t}){return typeof t!="string"?(this.context.errors.add({severity:P.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),y.TypeInstantiation.nop()):y.TypeInstantiation.bytes(t)}getBodyPropertyNamesForInlinedRequest(t){if(t.body==null)return new Set;switch(t.body.type){case"referenced":{let e=t.body.bodyType;if(e.type!=="typeReference")return new Set;let n=e.value;if(n.type!=="named")return new Set;let o=this.context.resolveNamedType({typeId:n.value});if(o==null||o.type!=="object")return new Set;let l=new Set;for(let s of o.properties)this.resolvesToLiteralType(s.typeReference)||l.add(this.context.getPropertyName(s.name.name));return l}case"properties":return new Set(t.body.value.filter(e=>!this.resolvesToLiteralType(e.typeReference)).map(e=>this.context.getPropertyName(e.name.name)));case"fileUpload":return new Set(t.body.properties.filter(e=>e.type==="bodyProperty").map(e=>this.context.getPropertyName(e.name.name)));default:B(t.body)}}getMethodArgsForInlinedRequest({request:t,snippet:e}){let n=[],o=this.context.shouldInlinePathParameters();this.context.errors.scope(K.PathParameters);let l=[...this.context.ir.pathParameters??[],...t.pathParameters??[]],s=[];l.length>0&&s.push(...this.getPathParameters({namedParameters:l,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(K.RequestBody);let v=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope();let w=this.getBodyPropertyNamesForInlinedRequest(t),N=s.map(E=>w.has(E.name)?{...E,name:`${E.name}_`}:E);return this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:o})||n.push(...N),this.context.needsRequestParameter({request:t,inlinePathParameters:o,inlineFileProperties:!0})&&n.push(...this.getInlinedRequestArgs({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:o})?N:[],filePropertyInfo:v})),n}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArgs({request:t,snippet:e,pathParameterFields:n,filePropertyInfo:o}){this.context.errors.scope(K.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:e.queryParameters??{}}).filter(E=>!this.resolvesToNonOptionalLiteralType(E.typeReference)).map(E=>({name:this.context.getPropertyName(E.name.name),value:this.context.dynamicTypeLiteralMapper.convert(E)}));this.context.errors.unscope(),this.context.errors.scope(K.Headers);let w=this.context.associateByWireValue({parameters:t.headers??[],values:e.headers??{}}).filter(E=>!this.resolvesToNonOptionalLiteralType(E.typeReference)).map(E=>({name:this.context.getPropertyName(E.name.name),value:this.context.dynamicTypeLiteralMapper.convert(E)}));this.context.errors.unscope(),this.context.errors.scope(K.RequestBody);let N=t.body!=null?this.getInlinedRequestBodyObjectFields({body:t.body,value:e.requestBody,filePropertyInfo:o}):[];return this.context.errors.unscope(),[...n,...s,...w,...N]}getInlinedRequestBodyObjectFields({body:t,value:e,filePropertyInfo:n}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:t.value,value:e});case"referenced":return this.getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e});case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:n});default:B(t)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:t}){return[...t.fileFields,...t.bodyPropertyFields]}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){let n=t.bodyType;switch(n.type){case"bytes":return this.getBodyRequestArgsForBytes({body:t,value:e});case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:n.value,value:e});default:B(n)}}getInlinedRequestBodyPropertyObjectFields({parameters:t,value:e}){let n=[],l=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference));for(let s of l)n.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return n}getPathParameters({namedParameters:t,snippet:e}){let n=[],o=t.filter(s=>!this.resolvesToLiteralType(s.typeReference)),l=this.context.associateByWireValue({parameters:o,values:e.pathParameters??{},ignoreMissingParameters:!0});for(let s of l)n.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return n}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getModuleName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}getEnvironmentOptionName({environment:t}){return t!=null?"environment":"base_url"}};var bt=class extends We{constructor({ir:t,config:e}){super(new st({ir:t,config:e}))}async generate(t,e={}){return super.generate(t,e)}generateSync(t,e={}){return super.generateSync(t,e)}async generateSnippetAst(t,e={}){return super.generateSnippetAst(t,e)}generateMethodCallSnippetAst({request:t,options:e={}}){let n=this.resolveEndpointsForMethodCall({request:t,options:e});if(n.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let o;for(let l of n){let s=this.context.clone(),v=this.createSnippetGenerator(s);try{return v.generateMethodCallSnippetAst({endpoint:l,request:t})}catch(w){o=w}}throw o??new Error(`Failed to generate method call snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}resolveEndpointsForMethodCall({request:t,options:e}){if(e.endpointId!=null){let n=this.context.resolveEndpointById(e.endpointId);if(n==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[n]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}createSnippetGenerator(t){return new ut({context:t})}};export{bt as DynamicSnippetsGenerator};
20
+ `)}),e.writeNoIndent('"""')}escapeString(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/'/g,"\\'").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}writeUnknown({writer:e,value:n}){switch(typeof n){case"boolean":e.write(n?"True":"False");return;case"string":e.write(`"${this.escapeString(n)}"`);return;case"number":e.write(n.toString());return;case"object":if(n==null){e.write("None");return}if(Array.isArray(n)){this.writeUnknownArray({writer:e,value:n});return}this.writeUnknownObject({writer:e,value:n});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof n}`)}}writeUnknownArray({writer:e,value:n}){if(n.length===0){e.write("[]");return}e.write("["),n.forEach((o,l)=>{l>0&&e.write(", "),e.writeNode(p.unknown(o))}),e.write("]")}writeUnknownObject({writer:e,value:n}){let o=Object.entries(n);if(o.length===0){e.write("{}");return}e.write("{"),o.forEach(([l,s],v)=>{v>0&&e.write(", "),e.write(`"${l}": `),e.writeNode(p.unknown(s))}),e.write("}")}};function ba({entries:p}){return p.filter(t=>!de.isNop(t.key)&&!de.isNop(t.value))}function Ea({entries:p}){return p.filter(t=>!de.isNop(t.value))}function Tt({values:p}){return p.filter(t=>!de.isNop(t))}function Ra(p){return new Ee(p)}function Na(p){return new nt(p)}function Aa(p){return new Ue(p)}function Sa(p){return new ue(p)}function Ba(p){return new Ne(p)}function Fa(p){return new Se(p)}function Ca(p){return new ee(p)}function Pa(p){return new fe(p)}function ka(p){return new pe(p)}function La(p){return new ie(p)}function Ua(p){return new Ae(p)}function Ma(p){return new Be(p)}function Oa(p){return new Fe(p)}function _a(p){return new ce(p)}function Va(p){return new Re(p)}function Da(p){return new ke(p)}function $a(p){return new le(p)}function ja(p){return new Pe(p)}function Wa(p){return new Le(p)}f();m();d();var qa="value",ot=class{constructor({context:t}){g(this,"context");this.context=t}convert(t){if(t.value===null)return this.context.isNullable(t.typeReference)?y.TypeInstantiation.none():(this.context.errors.add({severity:C.Critical,message:"Expected non-null value, but got null"}),y.TypeInstantiation.nop());if(t.value===void 0)return y.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return this.convertLiteral({literalType:t.typeReference.value,value:t.value});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?y.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"optional":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"nullable":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertSet({set:t.typeReference.value,value:t.value});case"unknown":return y.TypeInstantiation.unknown(t.value);default:B(t.typeReference)}}convertLiteral({literalType:t,value:e}){switch(t.type){case"boolean":{let n=this.context.getValueAsBoolean({value:e});return n==null?y.TypeInstantiation.nop():y.TypeInstantiation.bool(n)}case"string":{let n=this.context.getValueAsString({value:e});return n==null?y.TypeInstantiation.nop():y.TypeInstantiation.str(n)}default:B(t)}}convertList({list:t,value:e}){return Array.isArray(e)?y.TypeInstantiation.list(e.map((n,o)=>{this.context.errors.scope({index:o});try{return this.convert({typeReference:t,value:n})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:C.Critical,message:`Expected array but got: ${typeof e}`}),y.TypeInstantiation.nop())}convertSet({set:t,value:e}){return Array.isArray(e)?y.TypeInstantiation.list(e.map((n,o)=>{this.context.errors.scope({index:o});try{return this.convert({typeReference:t,value:n})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:C.Critical,message:`Expected array but got: ${typeof e}`}),y.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:C.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),y.TypeInstantiation.nop()):y.TypeInstantiation.dict(Object.entries(e).map(([n,o])=>{this.context.errors.scope(n);try{return{key:this.convert({typeReference:t.key,value:n,as:"key"}),value:this.convert({typeReference:t.value,value:o})}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertNamed({named:t,value:e,as:n}){switch(t.type){case"alias":return this.convert({typeReference:t.typeReference,value:e,as:n});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:B(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let n=this.context.useTypedDictRequests(),o=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(o==null)return y.TypeInstantiation.nop();let l=o.singleDiscriminatedUnionType,s=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:o,unionVariant:l});if(s==null)return y.TypeInstantiation.nop();if(n){let w={name:this.context.getPropertyName(t.discriminant.name),value:y.TypeInstantiation.str(o.discriminantValue.wireValue)};return y.TypeInstantiation.typedDict([w,...s],{multiline:!0})}let v=this.context.getDiscriminatedUnionVariantClassReference({unionDeclaration:t.declaration,discriminantValue:l.discriminantValue});return y.TypeInstantiation.reference(y.instantiateClass({classReference:v,arguments_:s.map(w=>y.methodArgument({name:w.name,value:w.value})),multiline:!0}))}convertDiscriminatedUnionToFlatKwargs({discriminatedUnion:t,value:e}){let n=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(n==null)return;let o=n.singleDiscriminatedUnionType,l=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:n,unionVariant:o});if(l==null)return;let s={name:this.context.getPropertyName(t.discriminant.name),value:y.TypeInstantiation.str(n.discriminantValue.wireValue)};return[...l,s]}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:t,unionVariant:e}){let n=this.getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e});switch(e.type){case"samePropertiesAsObject":{let o=this.context.resolveNamedType({typeId:e.typeId});if(o==null)return;if(o.type!=="object"){this.context.errors.add({severity:C.Critical,message:"Internal error; expected union value to be an object"});return}let l=this.convertObjectEntries({object_:o,value:t.value}),s=new Set(n.map(w=>w.name)),v=l.filter(w=>!s.has(w.name));return[...n,...v]}case"singleProperty":try{this.context.errors.scope(e.discriminantValue.wireValue);let o=this.context.getRecord(t.value);return o==null?[...n,{name:qa,value:this.convert({typeReference:e.typeReference,value:t.value})}]:[...n,{name:this.context.getPropertyName(e.discriminantValue.name),value:this.convert({typeReference:e.typeReference,value:o[e.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return n;default:B(e)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getPropertyName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})}convertObjectEntries({object_:t,value:e}){let n=this.context.getRecord(e)??{},o=this.context.associateByWireValue({parameters:t.properties,values:n}),l=new Set(Object.keys(n)),s=o.map(v=>{this.context.errors.scope(v.name.wireValue);try{return{name:this.context.getPropertyName(v.name.name),value:this.convert(v)}}finally{this.context.errors.unscope()}});for(let v of t.properties){if(l.has(v.name.wireValue)||this.context.isOptional(v.typeReference)||this.context.isNullable(v.typeReference))continue;let w=this.synthesizeDefaultValue(v.typeReference);y.TypeInstantiation.isNop(w)||s.push({name:this.context.getPropertyName(v.name.name),value:w})}return s.filter(v=>!y.TypeInstantiation.isNop(v.value))}convertObject({object_:t,value:e}){let n=this.context.useTypedDictRequests(),o=this.convertObjectEntries({object_:t,value:e});if(n)return y.TypeInstantiation.typedDict(o,{multiline:!0});let l=this.context.getTypeClassReference(t.declaration);return y.TypeInstantiation.reference(y.instantiateClass({classReference:l,arguments_:o.map(s=>y.methodArgument({name:s.name,value:s.value})),multiline:!0}))}convertEnum({enum_:t,value:e}){let n=this.getEnumValue({enum_:t,value:e});if(n==null)return y.TypeInstantiation.nop();let o=this.context.customConfig.pydantic_config?.enum_type;if(o==="python_enums"||o==="forward_compatible_python_enums"){let l=this.context.getTypeClassReference(t.declaration),s=n.name.screamingSnakeCase.safeName;return y.TypeInstantiation.reference(y.accessAttribute({lhs:l,rhs:y.codeBlock(s)}))}return y.TypeInstantiation.str(n.wireValue)}getEnumValue({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:C.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let n=t.values.find(o=>o.wireValue===e);if(n==null){this.context.errors.add({severity:C.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return n}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let n=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});return n??y.TypeInstantiation.nop()}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let n of t.types){let o=this.context.errors.size();try{let l=this.convert({typeReference:n,value:e});if(y.TypeInstantiation.isNop(l)||this.context.errors.size()>o){this.context.errors.truncate(o);continue}return l}catch{this.context.errors.truncate(o);continue}}this.context.errors.add({severity:C.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}synthesizeDefaultValue(t,e=new Set){switch(t.type){case"optional":case"nullable":return y.TypeInstantiation.nop();case"primitive":return this.synthesizeDefaultPrimitive(t.value);case"literal":return this.synthesizeDefaultLiteral(t.value);case"list":return y.TypeInstantiation.list([]);case"set":return y.TypeInstantiation.list([]);case"map":return y.TypeInstantiation.dict([]);case"named":{if(e.has(t.value))return y.TypeInstantiation.nop();let n=this.context.resolveNamedType({typeId:t.value});return n==null?y.TypeInstantiation.nop():this.synthesizeDefaultNamed({named:n,typeId:t.value,seen:e})}case"unknown":return y.TypeInstantiation.nop();default:B(t)}}synthesizeDefaultPrimitive(t){switch(t){case"STRING":case"BASE_64":case"BIG_INTEGER":return y.TypeInstantiation.str("string");case"INTEGER":case"LONG":case"UINT":case"UINT_64":return y.TypeInstantiation.int(1);case"FLOAT":case"DOUBLE":return y.TypeInstantiation.float(1.1);case"BOOLEAN":return y.TypeInstantiation.bool(!0);case"DATE":return y.TypeInstantiation.date("2024-01-15");case"DATE_TIME":case"DATE_TIME_RFC_2822":return y.TypeInstantiation.datetime("2024-01-15T09:30:00Z");case"UUID":return y.TypeInstantiation.uuid("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32");default:B(t)}}synthesizeDefaultLiteral(t){switch(t.type){case"boolean":return y.TypeInstantiation.bool(t.value);case"string":return y.TypeInstantiation.str(t.value);default:B(t)}}synthesizeDefaultNamed({named:t,typeId:e,seen:n}){let o=this.context.useTypedDictRequests(),l=new Set(n);switch(l.add(e),t.type){case"alias":return this.synthesizeDefaultValue(t.typeReference,l);case"enum":{let s=t.values[0];if(s==null)return y.TypeInstantiation.nop();let v=this.context.customConfig.pydantic_config?.enum_type;if(v==="python_enums"||v==="forward_compatible_python_enums"){let w=this.context.getTypeClassReference(t.declaration),N=s.name.screamingSnakeCase.safeName;return y.TypeInstantiation.reference(y.accessAttribute({lhs:w,rhs:y.codeBlock(N)}))}return y.TypeInstantiation.str(s.wireValue)}case"object":{let s=[];for(let w of t.properties){if(this.context.isOptional(w.typeReference)||this.context.isNullable(w.typeReference))continue;let N=this.synthesizeDefaultValue(w.typeReference,l);y.TypeInstantiation.isNop(N)||s.push({name:this.context.getPropertyName(w.name.name),value:N})}if(o)return y.TypeInstantiation.typedDict(s,{multiline:!0});let v=this.context.getTypeClassReference(t.declaration);return y.TypeInstantiation.reference(y.instantiateClass({classReference:v,arguments_:s.map(w=>y.methodArgument({name:w.name,value:w.value})),multiline:!0}))}case"discriminatedUnion":case"undiscriminatedUnion":return y.TypeInstantiation.nop();default:B(t)}}convertPrimitive({primitive:t,value:e,as:n}){switch(t){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let o=this.getValueAsNumber({value:e,as:n});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.int(o)}case"FLOAT":case"DOUBLE":{let o=this.getValueAsNumber({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.float(o)}case"BOOLEAN":{let o=this.getValueAsBoolean({value:e,as:n});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.bool(o)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let o=this.context.getValueAsString({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.str(o)}case"UUID":{let o=this.context.getValueAsString({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.uuid(o)}case"DATE":{let o=this.context.getValueAsString({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.date(o)}case"DATE_TIME":case"DATE_TIME_RFC_2822":{let o=this.context.getValueAsString({value:e});return o==null?y.TypeInstantiation.nop():y.TypeInstantiation.datetime(o)}default:B(t)}}getValueAsNumber({value:t,as:e}){let n=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:n})}getValueAsBoolean({value:t,as:e}){let n=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:n})}};f();m();d();var at=class{constructor({context:t}){g(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){let n={fileFields:[],bodyPropertyFields:[]},o=this.context.getRecord(e)??{};for(let l of t.properties)switch(l.type){case"file":{let s=this.getSingleFileProperty({property:l,record:o});if(y.TypeInstantiation.isNop(s))break;n.fileFields.push({name:this.context.getPropertyName(l.name),value:s});break}case"fileArray":{let s=this.getArrayFileProperty({property:l,record:o});if(y.TypeInstantiation.isNop(s))break;n.fileFields.push({name:this.context.getPropertyName(l.name),value:s});break}case"bodyProperty":{let s=this.getBodyProperty({property:l,record:o});if(y.TypeInstantiation.isNop(s))break;n.bodyPropertyFields.push({name:this.context.getPropertyName(l.name.name),value:s});break}default:B(l)}return n}getSingleFileProperty({property:t,record:e}){let n=this.context.getSingleFileValue({property:t,record:e});return n==null&&(n=`example_${t.wireValue??"file"}`),this.context.getFileFromString(n)}getArrayFileProperty({property:t,record:e}){let n=this.context.getFileArrayValues({property:t,record:e});if(n==null){let o=`example_${t.wireValue??"files"}`;return y.TypeInstantiation.list([this.context.getFileFromString(o)])}return y.TypeInstantiation.list(n.map(o=>this.context.getFileFromString(o)))}getBodyProperty({property:t,record:e}){let n=e[t.name.wireValue];return n==null?y.TypeInstantiation.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:n})}};var Ga=["list","set"],st=class p extends ze{constructor({ir:e,config:n}){super({ir:e,config:n});g(this,"ir");g(this,"customConfig");g(this,"dynamicTypeLiteralMapper");g(this,"filePropertyMapper");this.ir=e,this.customConfig=n.customConfig??{},this.dynamicTypeLiteralMapper=new ot({context:this}),this.filePropertyMapper=new at({context:this})}clone(){return new p({ir:this.ir,config:this.config})}getClassName(e){let n=e.pascalCase.safeName,o=this.getRootClientClassName();return n===o?`${o}Model`:n}getTypedDictClassName(e){return`${this.getClassName(e)}Params`}getPropertyName(e){let n=e.snakeCase.safeName;return n.startsWith("_")?"f_"+n.substring(n.lastIndexOf("_")+1):n}getMethodName(e){return Ga.includes(e.snakeCase.unsafeName)?e.snakeCase.unsafeName:e.snakeCase.safeName}getModuleName(e){let n=e.originalName.match(/^(_+)/)?.[1]??"",l=e.originalName.slice(n.length).match(/(_+)$/)?.[1]??"";return`${n}${e.snakeCase.safeName}${l}`}getRootClientClassReference(){return y.reference({name:this.getRootClientClassName(),modulePath:this.getRootModulePath()})}getTypeClassReference(e){let n=this.getClassName(e.name),o=[...this.getRootModulePath(),...e.fernFilepath.allParts.map(l=>this.getModuleName(l))];return y.reference({name:n,modulePath:o})}getDiscriminatedUnionVariantClassReference({unionDeclaration:e,discriminantValue:n}){let o=this.getClassName(e.name),l=n.name.pascalCase.safeName,s=[...this.getRootModulePath(),...e.fernFilepath.allParts.map(w=>this.getModuleName(w))],v=this.customConfig.pydantic_config?.union_naming==="v1"?`${l}${o}`:`${o}_${l}`;return y.reference({name:v,modulePath:s})}useTypedDictRequests(){return this.customConfig.use_typeddict_requests===!0}getRootClientClassName(){return this.customConfig.client?.exported_class_name!=null?this.customConfig.client.exported_class_name:this.customConfig.client_class_name!=null?this.customConfig.client_class_name:this.customConfig.client?.class_name!=null?this.customConfig.client.class_name:this.pascalCase(this.config.organization)+this.pascalCase(this.config.workspaceName)}getEnvironmentClassName(){return`${this.getRootClientClassName()}Environment`}getEnvironmentTypeReferenceFromID(e){let n=this.resolveEnvironmentName(e);if(n!=null)return y.accessAttribute({lhs:this.getEnvironmentClassReference(),rhs:y.codeBlock(this.getEnvironmentEnumName(n))})}getEnvironmentClassReference(){return y.reference({name:this.getEnvironmentClassName(),modulePath:this.getEnvironmentModulePath()})}getEnvironmentEnumName(e){return e.screamingSnakeCase.safeName}isPrimitive(e){switch(e.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(e.value);case"named":{let n=this.resolveNamedType({typeId:e.value});if(n==null)return!1;switch(n.type){case"alias":return this.isPrimitive(n.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:B(n)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:B(e)}}getFileFromString(e){return y.TypeInstantiation.str(e)}getRootModulePath(){if(this.customConfig.package_name!=null)return[this.customConfig.package_name];let e=this.cleanOrganizationName();if(this.customConfig.use_api_name_in_package)return[e,this.getApiName()];if(this.customConfig.package_path!=null){let n=this.customConfig.package_path.replace(/\//g,".").split(".");return[e,...n]}return[e]}getCoreModulePath(){return this.getRootModulePath().concat("core")}getEnvironmentModulePath(){return this.getRootModulePath().concat("environment")}shouldInlinePathParameters(){return!0}cleanOrganizationName(){return this.config.organization.replace(/[^a-zA-Z0-9]/g,"_")}getApiName(){return xt(this.config.workspaceName)}pascalCase(e){let n=gt(e);return n.charAt(0).toUpperCase()+n.slice(1)}};f();m();d();var za={type:"primitive",value:"STRING"},Ha=["example"],li="client",xe="request",ut=class{constructor({context:t}){g(this,"context");this.context=t}async generateSnippet({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e}).toString()}generateSnippetSync({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e}).toString()}async generateSnippetAst({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e})}generateMethodCallSnippetAst({endpoint:t,request:e}){return this.callMethod({endpoint:t,snippet:e})}buildPythonFile({endpoint:t,snippet:e}){return y.file({path:Ha,statements:[this.constructClient({endpoint:t,snippet:e}),this.callMethod({endpoint:t,snippet:e})]})}constructClient({endpoint:t,snippet:e}){return y.assign({lhs:y.reference({name:li}),rhs:y.instantiateClass({classReference:this.context.getRootClientClassReference(),arguments_:this.getConstructorArgs({endpoint:t,snippet:e}).map(n=>y.methodArgument({name:n.name,value:n.value})),multiline:!0})})}getConstructorArgs({endpoint:t,snippet:e}){let n=[],o=this.getConstructorEnvironmentArgs({baseUrl:e.baseURL,environment:e.environment});return o.length>0&&n.push(...o),t.auth!=null&&(e.auth!=null?n.push(...this.getConstructorAuthArgs({auth:t.auth,values:e.auth})):this.context.errors.add({severity:C.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(K.Headers),this.context.ir.headers!=null&&e.headers!=null&&n.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),n}getConstructorEnvironmentArgs({baseUrl:t,environment:e}){let n=this.getEnvironmentValue({baseUrl:t,environment:e});return n==null?[]:e!=null&&this.context.isMultiEnvironmentValues(e)?[{name:"environment",value:n}]:[{name:this.getEnvironmentOptionName({environment:e}),value:n}]}getEnvironmentValue({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:C.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return y.TypeInstantiation.str(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let n=this.context.getEnvironmentTypeReferenceFromID(e);if(n==null){this.context.errors.add({severity:C.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return y.TypeInstantiation.reference(n)}if(this.context.isMultiEnvironmentValues(e))return this.context.validateMultiEnvironmentUrlValues(e)?y.TypeInstantiation.reference(y.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.entries(e).map(([n,o])=>({name:n,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:za,value:o})})).map(n=>y.methodArgument({name:n.name,value:n.value})),multiline:!0})):void 0}}getConstructorAuthArgs({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.addAuthMismatchError(t,e),[]):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.addAuthMismatchError(t,e),[]):this.getConstructorBearerAuthArgs({auth:t,values:e});case"header":return e.type!=="header"?(this.addAuthMismatchError(t,e),[]):this.getConstructorHeaderAuthArgs({auth:t,values:e});case"oauth":return e.type!=="oauth"?(this.addAuthMismatchError(t,e),[]):this.getConstructorOAuthArgs({auth:t,values:e});case"inferred":return e.type!=="inferred"?(this.addAuthMismatchError(t,e),[]):this.getConstructorInferredAuthArgs({auth:t,values:e});default:B(t)}}addAuthMismatchError(t,e){this.context.errors.add({severity:C.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message})}addWarning(t){this.context.errors.add({severity:C.Warning,message:t})}getConstructorBasicAuthArg({auth:t,values:e}){let n=t.usernameOmit===!0,o=t.passwordOmit===!0,l=[];return n||l.push({name:this.context.getPropertyName(t.username),value:y.TypeInstantiation.str(e.username)}),o||l.push({name:this.context.getPropertyName(t.password),value:y.TypeInstantiation.str(e.password)}),l}getConstructorBearerAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.token),value:y.TypeInstantiation.str(e.token)}]}getConstructorHeaderAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t.header.typeReference,value:e.value})}]}getConstructorOAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.clientId),value:y.TypeInstantiation.str(e.clientId)},{name:this.context.getPropertyName(t.clientSecret),value:y.TypeInstantiation.str(e.clientSecret)}]}getConstructorInferredAuthArgs({auth:t,values:e}){let n=t.parameters??[];if(n.length===0)return this.addWarning("Inferred auth scheme is missing parameters; cannot generate constructor arguments."),[];let o=e.values;if(o==null)return this.addWarning("Inferred auth values were not provided; cannot generate constructor arguments."),[];let l=[];for(let s of n){let v=s.name.wireValue;if(!Object.hasOwn(o,v)){this.addWarning(`Missing inferred auth value for ${v}`);continue}let w=o[v],N=this.context.dynamicTypeLiteralMapper.convert({typeReference:s.typeReference,value:w});y.TypeInstantiation.isNop(N)||l.push({name:this.context.getPropertyName(s.name.name),value:N})}return l}getConstructorHeaderArgs({headers:t,values:e}){let n=[];for(let o of t){let l=e[o.name.wireValue],s=this.getConstructorHeaderArg({header:o,value:l});s!=null&&n.push(s)}return n}getConstructorHeaderArg({header:t,value:e}){let n=this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:e});if(!y.TypeInstantiation.isNop(n))return{name:this.context.getPropertyName(t.name.name),value:n}}callMethod({endpoint:t,snippet:e}){return y.invokeMethod({on:y.reference({name:li}),method:this.getMethod({endpoint:t}),arguments_:this.getMethodArgs({endpoint:t,snippet:e}).filter(n=>!y.TypeInstantiation.isNop(n.value)).map(n=>y.methodArgument({name:n.name,value:n.value})),multiline:!0})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e});default:B(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let n=[];this.context.errors.scope(K.PathParameters);let o=[...this.context.ir.pathParameters??[],...t.pathParameters??[]],l=this.callOmitsRequestBody({request:t,snippet:e}),s=new Set;if(t.body!=null&&!l){let v=this.getBodyRequestArgs({body:t.body,value:e.requestBody});if(s=new Set(v.map(w=>w.name)),t.body.type==="typeReference"){let w=t.body.value;if(w.type==="named"){let N=this.context.resolveNamedType({typeId:w.value});if(N!=null&&N.type==="object")for(let E of N.properties)this.resolvesToLiteralType(E.typeReference)||s.add(this.context.getPropertyName(E.name.name))}}}if(o.length>0){let w=this.getPathParameters({namedParameters:o,snippet:e}).map(N=>s.has(N.name)?{...N,name:N.name+"_"}:N);n.push(...w)}return this.context.errors.unscope(),this.context.errors.scope(K.RequestBody),t.body!=null&&!l&&n.push(...this.getBodyRequestArgs({body:t.body,value:e.requestBody})),this.context.errors.unscope(),n}callOmitsRequestBody({request:t,snippet:e}){if(this.context.customConfig.respect_optional_request_body!==!0||t.bodyRequired!==!1)return!1;let n=e.requestBody;return n==null||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0}getBodyRequestArgs({body:t,value:e}){switch(t.type){case"bytes":return[{name:xe,value:this.getBytesBodyRequestTypeInstantiation({value:e})}];case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:t.value,value:e});default:B(t)}}getBodyRequestArgsForTypeReference({typeReference:t,value:e}){switch(t.type){case"named":{let n=this.context.resolveNamedType({typeId:t.value});return n==null?[]:this.getBodyRequestArgsForNamedTypeReference({typeReference:t,named:n,value:e})}case"nullable":case"optional":{let n=t.value;return n.type==="named"&&this.context.resolveNamedType({typeId:n.value})?.type==="object"?[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:n,value:e})}]:this.getBodyRequestArgsForTypeReference({typeReference:t.value,value:e})}case"list":case"map":case"set":case"literal":case"primitive":case"unknown":return[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:e})}];default:B(t)}}getBodyRequestArgsForNamedTypeReference({typeReference:t,named:e,value:n}){switch(e.type){case"alias":return this.getBodyRequestArgsForTypeReference({typeReference:e.typeReference,value:n});case"discriminatedUnion":if(this.context.customConfig.flatten_union_request_bodies===!0){let o=this.context.dynamicTypeLiteralMapper.convertDiscriminatedUnionToFlatKwargs({discriminatedUnion:e,value:n});if(o!=null)return o}return[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:n})}];case"enum":case"undiscriminatedUnion":return[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:n})}];case"object":return this.context.customConfig.inline_request_params===!1?[{name:xe,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:n})}]:this.context.associateByWireValue({parameters:e.properties,values:this.context.getRecord(n)??{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference)).map(s=>({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)}));default:B(e)}}resolvesToLiteralType(t){switch(t.type){case"literal":return!0;case"optional":case"nullable":return this.resolvesToLiteralType(t.value);case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.resolvesToLiteralType(e.typeReference):!1}case"list":case"map":case"set":case"primitive":case"unknown":return!1;default:B(t)}}resolvesToNonOptionalLiteralType(t){switch(t.type){case"literal":return!0;case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.resolvesToNonOptionalLiteralType(e.typeReference):!1}case"optional":case"nullable":case"list":case"map":case"set":case"primitive":case"unknown":return!1;default:B(t)}}getBodyRequestArgsForBytes({body:t,value:e}){let n=this.getBytesBodyRequestTypeInstantiation({value:e});return y.TypeInstantiation.isNop(n)?[]:[{name:xe,value:n}]}getBytesBodyRequestTypeInstantiation({value:t}){return typeof t!="string"?(this.context.errors.add({severity:C.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),y.TypeInstantiation.nop()):y.TypeInstantiation.bytes(t)}getBodyPropertyNamesForInlinedRequest(t){if(t.body==null)return new Set;switch(t.body.type){case"referenced":{let e=t.body.bodyType;if(e.type!=="typeReference")return new Set;let n=e.value;if(n.type!=="named")return new Set;let o=this.context.resolveNamedType({typeId:n.value});if(o==null||o.type!=="object")return new Set;let l=new Set;for(let s of o.properties)this.resolvesToLiteralType(s.typeReference)||l.add(this.context.getPropertyName(s.name.name));return l}case"properties":return new Set(t.body.value.filter(e=>!this.resolvesToLiteralType(e.typeReference)).map(e=>this.context.getPropertyName(e.name.name)));case"fileUpload":return new Set(t.body.properties.filter(e=>e.type==="bodyProperty").map(e=>this.context.getPropertyName(e.name.name)));default:B(t.body)}}getMethodArgsForInlinedRequest({request:t,snippet:e}){let n=[],o=this.context.shouldInlinePathParameters();this.context.errors.scope(K.PathParameters);let l=[...this.context.ir.pathParameters??[],...t.pathParameters??[]],s=[];l.length>0&&s.push(...this.getPathParameters({namedParameters:l,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(K.RequestBody);let v=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope();let w=this.getBodyPropertyNamesForInlinedRequest(t),N=s.map(E=>w.has(E.name)?{...E,name:`${E.name}_`}:E);return this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:o})||n.push(...N),this.context.needsRequestParameter({request:t,inlinePathParameters:o,inlineFileProperties:!0})&&n.push(...this.getInlinedRequestArgs({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:o})?N:[],filePropertyInfo:v})),n}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArgs({request:t,snippet:e,pathParameterFields:n,filePropertyInfo:o}){this.context.errors.scope(K.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:e.queryParameters??{}}).filter(E=>!this.resolvesToNonOptionalLiteralType(E.typeReference)).map(E=>({name:this.context.getPropertyName(E.name.name),value:this.context.dynamicTypeLiteralMapper.convert(E)}));this.context.errors.unscope(),this.context.errors.scope(K.Headers);let w=this.context.associateByWireValue({parameters:t.headers??[],values:e.headers??{}}).filter(E=>!this.resolvesToNonOptionalLiteralType(E.typeReference)).map(E=>({name:this.context.getPropertyName(E.name.name),value:this.context.dynamicTypeLiteralMapper.convert(E)}));this.context.errors.unscope(),this.context.errors.scope(K.RequestBody);let N=t.body!=null?this.getInlinedRequestBodyObjectFields({body:t.body,value:e.requestBody,filePropertyInfo:o}):[];return this.context.errors.unscope(),[...n,...s,...w,...N]}getInlinedRequestBodyObjectFields({body:t,value:e,filePropertyInfo:n}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:t.value,value:e});case"referenced":return this.getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e});case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:n});default:B(t)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:t}){return[...t.fileFields,...t.bodyPropertyFields]}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){let n=t.bodyType;switch(n.type){case"bytes":return this.getBodyRequestArgsForBytes({body:t,value:e});case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:n.value,value:e});default:B(n)}}getInlinedRequestBodyPropertyObjectFields({parameters:t,value:e}){let n=[],l=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference));for(let s of l)n.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return n}getPathParameters({namedParameters:t,snippet:e}){let n=[],o=t.filter(s=>!this.resolvesToLiteralType(s.typeReference)),l=this.context.associateByWireValue({parameters:o,values:e.pathParameters??{},ignoreMissingParameters:!0});for(let s of l)n.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return n}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getModuleName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}getEnvironmentOptionName({environment:t}){return t!=null?"environment":"base_url"}};var bt=class extends We{constructor({ir:t,config:e}){super(new st({ir:t,config:e}))}async generate(t,e={}){return super.generate(t,e)}generateSync(t,e={}){return super.generateSync(t,e)}async generateSnippetAst(t,e={}){return super.generateSnippetAst(t,e)}generateMethodCallSnippetAst({request:t,options:e={}}){let n=this.resolveEndpointsForMethodCall({request:t,options:e});if(n.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let o;for(let l of n){let s=this.context.clone(),v=this.createSnippetGenerator(s);try{return v.generateMethodCallSnippetAst({endpoint:l,request:t})}catch(w){o=w}}throw o??new Error(`Failed to generate method call snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}resolveEndpointsForMethodCall({request:t,options:e}){if(e.endpointId!=null){let n=this.context.resolveEndpointById(e.endpointId);if(n==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[n]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}createSnippetGenerator(t){return new ut({context:t})}};export{bt as DynamicSnippetsGenerator};
21
21
  /*! Bundled license information:
22
22
 
23
23
  @jspm/core/nodelibs/browser/chunk-DtuTasat.js: