fern-api 0.45.0-rc39 → 0.45.0-rc40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +3 -3
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1785,7 +1785,7 @@ ${l.indent}`:""}${oVc(o)}:${f.indent?" ":""}`;return u=!1,c=!0,f.objectItem=void
1785
1785
  `}),r.replaceAll(/\n$/g,"")}function zfj(e){return e?qc.green(jNr.radioOn):jNr.radioOff}var lha=Jo(lwe(),1);function Rsf(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var wpi=class extends p8{_run(t){this.done=t;let r=oW(this.rl),n=r.line.pipe((0,lha.map)(this.filterInput.bind(this))),i=this.handleSubmitEvents(n);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,lha.takeUntil)(i.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),n="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(n=`
1786
1786
  `+qc.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?qc.cyan(Rsf(t,this.opt.mask)):qc.italic.dim("[hidden]"):this.opt.mask?Rsf(t,this.opt.mask):qc.italic.dim("[input is hidden] ")}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var flf=Jo(llf(),1),dlf=Jo(lwe(),1);var Bpi=class extends p8{_run(t){this.done=t,this.editorResult=new dlf.Subject;let r=oW(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?qc.dim("Received"):qc.dim("Press <enter> to launch your preferred editor."),t&&(r=qc.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),(0,flf.editAsync)(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(t,r){this.rl.resume(),t?this.editorResult.error(t):this.editorResult.next(r)}onEnd(t){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=t.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(t){this.render(t.isValid)}};var mlf=Jo(hlf(),1);var blf=Jo(require("readline"),1),glf=Jo(vlf(),1),ckr=class{constructor(t){this.rl||=blf.default.createInterface(Sdj(t)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&typeof this.activePrompt.close=="function"&&this.activePrompt.close(),this.rl.output.end(),this.rl.pause(),this.rl.close()}};function Sdj(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new glf.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Ipi=class extends ckr{constructor(t={}){super(t),this.log=(0,mlf.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return ypi(this.rl,this.bottomBar.split(`
1787
1787
  `).length),this}updateBottomBar(t){return ypi(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=t,this.render(),this.rl.output.mute(),this}writeLog(t){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(t.toString())),this.render(),this.rl.output.mute(),this}enforceLF(t){return/[\n\r]$/.test(t)?t:t+`
1788
- `}write(t){let r=t.split(/\n/);this.height=r.length,this.rl.setPrompt(r.at(-1)),this.rl.output.rows===0&&this.rl.output.columns===0&&oha(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Tlf=Jo(jlf(),1),xlf=Jo(cuu(),1),qlf=Jo(Alf(),1),Qx=Jo(lwe(),1),Clf=Jo(wdi(),1);var Tha=Jo(lwe(),1),Mlf=Jo(wdi(),1),xha=function(e,t,r){return typeof e[t]!="function"?(0,Tha.of)(e):(0,Tha.from)((0,Mlf.default)(e[t])(r).then(n=>(e[t]=n,e)))};var zpi={isPlainObject:Tlf.default,set:qlf.default,get:xlf.default},wBn=class extends ckr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=zpi.isPlainObject(r)?{...r}:{},zpi.isPlainObject(t)&&(t=Object.values(t).every(i=>zpi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,Qx.from)(t):t;return this.process=n.pipe((0,Qx.concatMap)(this.processQuestion.bind(this)),(0,Qx.publish)()),this.process.connect(),this.process.pipe((0,Qx.reduce)((i,a)=>(zpi.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,Qx.defer)(()=>(0,Qx.of)(t).pipe((0,Qx.concatMap)(this.setDefaultType.bind(this)),(0,Qx.concatMap)(this.filterIfRunnable.bind(this)),(0,Qx.concatMap)(()=>xha(t,"message",this.answers)),(0,Qx.concatMap)(()=>xha(t,"default",this.answers)),(0,Qx.concatMap)(()=>xha(t,"choices",this.answers)),(0,Qx.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,Qx.defer)(()=>(0,Qx.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,Qx.defer)(()=>(0,Qx.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&zpi.get(this.answers,t.name)!==void 0)return(0,Qx.empty)();if(t.when===!1)return(0,Qx.empty)();if(typeof t.when!="function")return(0,Qx.of)(t);let{answers:r}=this;return(0,Qx.defer)(()=>(0,Qx.from)((0,Clf.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,Qx.filter)(n=>n!=null)))}};function Blf(e){let t=function(r,n){let i;try{i=new wBn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",bpi),this.registerPrompt("input",tkr),this.registerPrompt("number",gpi),this.registerPrompt("confirm",mpi),this.registerPrompt("rawlist",Opi),this.registerPrompt("expand",Ppi),this.registerPrompt("checkbox",jpi),this.registerPrompt("password",wpi),this.registerPrompt("editor",Bpi)},t.restoreDefaultPrompts(),t}var ocu=Blf();function Hdj(e,t){ocu.registerPrompt(e,t)}function Jdj(){ocu.restoreDefaultPrompts()}var Qdj={prompt:ocu,ui:{BottomBar:Ipi,Prompt:wBn},createPromptModule:Blf,registerPrompt:Hdj,restoreDefaultPrompts:Jdj,Separator:pne},qha=Qdj;var Hff=Jo(Ilf()),yhj="4.2.1",kCt;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(kCt||(kCt={}));function vhj(e,t){if(!e)throw new Error(t)}function bhj(e){return e?.replace(/\/+$/,"")}async function ghj(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function mhj(){return new Date().getTime()}function zff(){return new Date().toISOString()}function Jff(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Gpi=String.fromCharCode,Nff="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Jha={};function Ohj(e,t){if(!Jha[e]){Jha[e]={};for(let r=0;r<e.length;r++)Jha[e][e.charAt(r)]=r}return Jha[e][t]}var $pi={compressToBase64:function(e){if(e==null)return"";let t=$pi._compress(e,6,function(r){return Nff.charAt(r)});switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return e==null?"":e==""?null:$pi._decompress(e.length,32,function(t){return Ohj(Nff,e.charAt(t))})},compress:function(e){return $pi._compress(e,16,function(t){return Gpi(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],u,f,d="",c="",o="",l=2,m=3,O=2,j=0,A=0,T;for(T=0;T<e.length;T+=1)if(d=e.charAt(T),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=m++,i[d]=!0),c=o+d,Object.prototype.hasOwnProperty.call(n,c))o=c;else{if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[c]=m++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(f=2,u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;for(;;)if(j=j<<1,A==t-1){a.push(r(j));break}else A++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:$pi._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},u=4,f=4,d=3,c="",o,l,m,O,j,A,T;for(o=0;o<3;o+=1)n[o]=o;for(m=0,j=Math.pow(2,2),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=Gpi(m);break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=Gpi(m);break;case 2:return""}for(n[3]=T,l=T,i.push(T);;){if(a.index>e)return"";for(m=0,j=Math.pow(2,d),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(T=m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;n[f++]=Gpi(m),T=f-1,u--;break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;n[f++]=Gpi(m),T=f-1,u--;break;case 2:return i.join("")}if(u==0&&(u=Math.pow(2,d),d++),n[T])c=n[T];else if(T===f)c=l+l.charAt(0);else return null;i.push(c),n[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,d),d++)}}},Gcu=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}};var Qha="0123456789abcdef",Gha=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=Qha.charAt(this.bytes[r]>>>4),t+=Qha.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=Qha.charAt(this.bytes[r]>>>4),t+=Qha.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},$cu=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??Phj()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return Gha.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,Gha.ofInner(t)}},Phj=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Fff,Rff=()=>jhj().toString(),jhj=()=>(Fff||(Fff=new $cu)).generate(),$ha=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Kpi=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Lff(e){return typeof e=="object"&&(e instanceof $ha||e instanceof Kpi)}var Kcu=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new Gcu,this._isInitialized=!1,vhj(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=bhj(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:Lff},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(kCt.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(kCt.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(kCt.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Rff();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}captureStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}groupIdentifyStateless(t,r,n,i,a,u){this.wrap(()=>{let f=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...u||{}}});this.enqueue("capture",f,i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.fetchWithRetry(u,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,n={},i={},a={},u){await this._initPromise;let f=await this.getFeatureFlagsStateless(r,n,i,a,u);if(!f)return;let d=f[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},u){await this._initPromise;let f=await this.getFeatureFlagPayloadsStateless(r,n,i,a,u);if(!f)return;let d=f[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},n={},i={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let f=await this.getDecide(t,r,n,i,u),d=f?.featureFlags,c=f?.featureFlagPayloads,o=c;return c&&(o=Object.fromEntries(Object.entries(c).map(([l,m])=>[l,this._parsePayload(m)]))),{flags:d,payloads:o}}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:zff(),uuid:n?.uuid?n.uuid:Rff()};(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId);let u=this.getPersistedProperty(kCt.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:i}),this.setPersistedProperty(kCt.Queue,u),this._events.emit(t,i),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Jff(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(kCt.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),n=r.map(c=>c.message),i=()=>{let c=this.getPersistedProperty(kCt.Queue)||[];this.setPersistedProperty(kCt.Queue,c.slice(r.length))},a={api_key:this.apiKey,batch:n,sent_at:zff()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),f=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${mhj()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent($pi.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(f,d)}catch(c){throw c instanceof Kpi||i(),this._events.emit("error",c),c}return i(),this._events.emit("flush",n),n}async fetchWithRetry(t,r,n,i){var a;return(a=AbortSignal).timeout??(a.timeout=function(f){let d=new AbortController;return setTimeout(()=>d.abort(),f),d.signal}),await ghj(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(d){throw new Kpi(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new $ha(u);return u},{...this._retryOptions,...n})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(kCt.Queue)||[]).length!==0;){await this.flush();let i=Date.now();if(r<i)break}}catch(r){if(!Lff(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},Ycu=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},Xcu=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!Xcu){let e=Iff();Xcu=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var Qff=Xcu,whj=1152921504606847e3,Dhj=["is_not"],Kha=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},_8=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Zcu=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:u,...f}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=f.fetch||Qff,this.onError=f.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let u,f;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){f=d;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof _8?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},u={},f=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let c=this.computeFlagLocally(d,t,r,n,i);a[d.key]=c;let o=await this.computeFeatureFlagPayloadLocally(d.key,c);o&&(u[d.key]=o)}catch(c){c instanceof _8||c instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${c}`)),f=!0}}),{response:a,payloads:u,fallbackToDecide:f}}computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new _8("Flag has experience continuity enabled");if(!t.active)return!1;let f=(t.filters||{}).aggregation_group_type_index;if(f!=null){let d=this.groupTypeMapping[String(f)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${f} for feature flag ${t.key}`)),new _8("Flag has unknown group type index");if(!(d in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let c=a[d];return this.matchFeatureFlagProperties(t,n[d],c)}else return this.matchFeatureFlagProperties(t,r,i)}matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],u=!1,f,d=[...a].sort((c,o)=>{let l=!!c.variant,m=!!o.variant;return l&&m?0:l?-1:m?1:0});for(let c of d)try{if(this.isConditionMatch(t,r,c,n)){let o=c.variant,l=i.multivariate?.variants||[];o&&l.some(m=>m.key===o)?f=o:f=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof _8)u=!0;else throw o}if(f!==void 0)return f;if(u)throw new _8("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,n,i){let a=n.rollout_percentage,u=f=>{this.logMsgIfDebug(()=>console.warn(f))};if((n.properties||[]).length>0){for(let f of n.properties){let d=f.type,c=!1;if(d==="cohort"?c=$ff(f,i,this.cohorts,this.debugMode):c=Gff(f,i,u),!c)return!1}if(a==null)return!0}return!(a!=null&&Uff(t.key,r)>a/100)}getMatchingVariant(t,r){let n=Uff(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(f=>{i=n+f.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:f.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new Kha("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof Kha&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=Jff(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}};function Uff(e,t,r=""){let n=(0,Hff.createHash)();return n.update(`${e}.${t}${r}`),parseInt(n.digest("hex").slice(0,15),16)/whj}function Gff(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new _8("Operator is_not_set is not supported")}else throw new _8(`Property ${n} not found in propertyValues`);let u=t[n];if(u==null&&!Dhj.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function f(c,o){return Array.isArray(c)?c.map(l=>String(l).toLowerCase()).includes(String(o).toLowerCase()):String(c).toLowerCase()===String(o).toLowerCase()}function d(c,o,l){if(l==="gt")return c>o;if(l==="gte")return c>=o;if(l==="lt")return c<o;if(l==="lte")return c<=o;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return f(i,u);case"is_not":return!f(i,u);case"is_set":return n in t;case"icontains":return String(u).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(i).toLowerCase());case"regex":return Vff(String(i))&&String(u).match(String(i))!==null;case"not_regex":return Vff(String(i))&&String(u).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let c=typeof i=="number"?i:null;if(typeof i=="string")try{c=parseFloat(i)}catch{}return c!=null&&u!=null?typeof u=="string"?d(u,String(i),a):d(u,c,a):d(String(u),String(i),a)}case"is_date_after":case"is_date_before":{let c=Shj(String(i));if(c==null&&(c=Wff(i)),c==null)throw new _8(`Invalid date: ${i}`);let o=Wff(u);return["is_date_before"].includes(a)?o<c:o>c}default:throw new _8(`Unknown operator: ${a}`)}}function $ff(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new _8("can't match cohort without a given cohort property value");let a=r[i];return Kff(a,t,r,n)}function Kff(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let f of a)try{let d=Kff(f,t,r,n);if(i==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof _8)n&&console.debug(`Failed to compute property ${f} locally: ${d}`),u=!0;else throw d}if(u)throw new _8("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let f of a)try{let d;f.type==="cohort"?d=$ff(f,t,r,n):d=Gff(f,t);let c=f.negation||!1;if(i==="AND"){if(!d&&!c||d&&c)return!1}else if(d&&!c||!d&&c)return!0}catch(d){if(d instanceof _8)n&&console.debug(`Failed to compute property ${f} locally: ${d}`),u=!0;else throw d}if(u)throw new _8("can't match cohort without a given cohort property value");return i==="AND"}}function Vff(e){try{return new RegExp(e),!0}catch{return!1}}function Wff(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new _8(`${e} is in an invalid date format`)}else throw new _8(`The date provided ${e} must be a string, number, or date object`)}function Shj(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var Ehj=30*1e3,Ahj=50*1e3,xBn=class extends Kcu{constructor(t,r={}){super(t,r),this._memoryStorage=new Ycu,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new Zcu({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:Ehj,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||Ahj}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):Qff(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return yhj}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:n,groups:i,sendFeatureFlags:a,timestamp:u,disableGeoip:f,uuid:d}){let c=m=>{super.captureStateless(t,r,m,{timestamp:u,disableGeoip:f,uuid:d})},o=(m,O,j)=>super.getFeatureFlagsStateless(m,O,void 0,void 0,j),l=Promise.resolve().then(async()=>{if(a)return await o(t,i,f);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let m={};for(let[O,j]of Object.entries(i||{}))m[O]=String(j);return await this.getAllFlags(t,{groups:m,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(m=>{let O={};if(m)for(let[A,T]of Object.entries(m))O[`$feature/${A}`]=T;let j=Object.keys(m||{}).filter(A=>m?.[A]!==!1);return j.length>0&&(O.$active_feature_flags=j),O}).catch(()=>({})).then(m=>{c({...m,...n,$groups:i})});this.addPendingPromise(l)}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set||r;super.identifyStateless(t,{$set:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:f,personProperties:d,groupProperties:c}=n||{},o=this.addLocalPersonAndGroupProperties(r,i,d,c);d=o.allPersonProperties,c=o.allGroupProperties,u==null&&(u=!1),f==null&&(f=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,d,c),m=l!==void 0;!m&&!u&&(l=await super.getFeatureFlagStateless(t,r,i,d,c,a));let O=`${t}_${l}`;return f&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(O))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(O):this.distinctIdHasSentFlagCalls[r]=[O],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,locally_evaluated:m,[`$feature/${t}`]:l},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:u}=i||{},{onlyEvaluateLocally:f,sendFeatureFlagEvents:d,personProperties:c,groupProperties:o}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,c,o);c=l.allPersonProperties,o=l.allGroupProperties;let m;return n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n)),f==null&&(f=!1),d==null&&(d=!0),f==null&&(f=!1),!(m!==void 0)&&!f&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,c,o,u)),m}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:f}=r||{},d=this.addLocalPersonAndGroupProperties(t,n,u,f);u=d.allPersonProperties,f=d.allGroupProperties,a==null&&(a=!1);let c=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,u,f),o={},l={},m=!0;if(c&&(o=c.response,l=c.payloads,m=c.fallbackToDecide),m&&!a){let O=await super.getFeatureFlagsAndPayloadsStateless(t,n,u,f,i);o={...o,...O.flags||{}},l={...l,...O.payloads||{}}}return{featureFlags:o,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},u={};if(r)for(let f of Object.keys(r))u[f]={$group_key:r[f],...i?.[f]||{}};return{allPersonProperties:a,allGroupProperties:u}}},kcu=class e{constructor(t,r,n,i){this.posthog=t,this.posthogHost=r,this.organization=n,this.prefix=i,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(n=>{if(n.exception?.values===void 0||n.exception.values.length===0)return n;n.tags||(n.tags={});let i=r(),a=n.tags[e.POSTHOG_ID_TAG];if(a===void 0)return n;n.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:n.exception.values[0]?.value,$exception_type:n.exception.values[0]?.type,$exception_personURL:n.tags["PostHog Person URL"],$sentry_event_id:n.event_id,$sentry_exception:n.exception,$sentry_exception_message:n.exception.values[0]?.value,$sentry_exception_type:n.exception.values[0]?.type,$sentry_tags:n.tags},f=i.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&f!==void 0&&n.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${f}&query=${n.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),n})}};kcu.POSTHOG_ID_TAG="posthog_distinct_id";var Yha=class{posthog;constructor({posthogApiKey:t}){this.posthog=new xBn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.45.0-rc39",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Ypi=class{async sendEvent(){}async identify(){}async flush(){}};var qBn=require("fs/promises"),kff=require("os"),edf=require("path");var Yff=Jo(require("crypto")),Zha=new Uint8Array(256),Xha=Zha.length;function elu(){return Xha>Zha.length-16&&(Yff.default.randomFillSync(Zha),Xha=0),Zha.slice(Xha,Xha+=16)}var cW=[];for(let e=0;e<256;++e)cW.push((e+256).toString(16).slice(1));function Xff(e,t=0){return cW[e[t+0]]+cW[e[t+1]]+cW[e[t+2]]+cW[e[t+3]]+"-"+cW[e[t+4]]+cW[e[t+5]]+"-"+cW[e[t+6]]+cW[e[t+7]]+"-"+cW[e[t+8]]+cW[e[t+9]]+"-"+cW[e[t+10]]+cW[e[t+11]]+cW[e[t+12]]+cW[e[t+13]]+cW[e[t+14]]+cW[e[t+15]]}var Zff=Jo(require("crypto")),tlu={randomUUID:Zff.default.randomUUID};function Mhj(e,t,r){if(tlu.randomUUID&&!t&&!e)return tlu.randomUUID();e=e||{};let n=e.random||(e.rng||elu)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Xff(n)}var c6r=Mhj;var Thj="id",xhj=".fern",Xpi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new xBn(r),this.userId=t==null?void 0:vru(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.45.0-rc39",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Wl(Hp.of((0,kff.homedir)()),ls.of(xhj),ls.of(Thj));await _h(t)||(await(0,qBn.mkdir)((0,edf.dirname)(t),{recursive:!0}),await(0,qBn.writeFile)(t,c6r())),this.persistedDistinctId=(await(0,qBn.readFile)(t)).toString()}return this.persistedDistinctId}};var rlu;async function CBn(){return rlu==null&&(rlu=await qhj()),rlu}async function qhj(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Ypi;let r=await oca();return r!=null?new Xpi({token:r,posthogApiKey:e}):await aca()!=null?new Yha({posthogApiKey:e}):new Xpi({token:void 0,posthogApiKey:e})}catch{return new Ypi}}function Zpi(e,t){return function(){return e.apply(t,arguments)}}var{toString:Chj}=Object.prototype,{getPrototypeOf:alu}=Object,eya=(e=>t=>{let r=Chj.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),e2t=e=>(e=e.toLowerCase(),t=>eya(t)===e),tya=e=>t=>typeof t===e,{isArray:BBn}=Array,kpi=tya("undefined");function Bhj(e){return e!==null&&!kpi(e)&&e.constructor!==null&&!kpi(e.constructor)&&dwe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var ndf=e2t("ArrayBuffer");function Ihj(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ndf(e.buffer),t}var zhj=tya("string"),dwe=tya("function"),idf=tya("number"),rya=e=>e!==null&&typeof e=="object",Nhj=e=>e===!0||e===!1,kha=e=>{if(eya(e)!=="object")return!1;let t=alu(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Fhj=e2t("Date"),Rhj=e2t("File"),Lhj=e2t("Blob"),Uhj=e2t("FileList"),Vhj=e=>rya(e)&&dwe(e.pipe),Whj=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||dwe(e.append)&&((t=eya(e))==="formdata"||t==="object"&&dwe(e.toString)&&e.toString()==="[object FormData]"))},Hhj=e2t("URLSearchParams"),[Jhj,Qhj,Ghj,$hj]=["ReadableStream","Request","Response","Headers"].map(e2t),Khj=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function e_i(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),BBn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,f;for(n=0;n<u;n++)f=a[n],t.call(null,e[f],f,e)}}function adf(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var pkr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,odf=e=>!kpi(e)&&e!==pkr;function ilu(){let{caseless:e}=odf(this)&&this||{},t={},r=(n,i)=>{let a=e&&adf(t,i)||i;kha(t[a])&&kha(n)?t[a]=ilu(t[a],n):kha(n)?t[a]=ilu({},n):BBn(n)?t[a]=n.slice():t[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&e_i(arguments[n],r);return t}var Yhj=(e,t,r,{allOwnKeys:n}={})=>(e_i(t,(i,a)=>{r&&dwe(i)?e[a]=Zpi(i,r):e[a]=i},{allOwnKeys:n}),e),Xhj=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Zhj=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},khj=(e,t,r,n)=>{let i,a,u,f={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)u=i[a],(!n||n(u,e,t))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&alu(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},eyj=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},tyj=e=>{if(!e)return null;if(BBn(e))return e;let t=e.length;if(!idf(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},ryj=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&alu(Uint8Array)),nyj=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},iyj=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},ayj=e2t("HTMLFormElement"),oyj=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),tdf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),uyj=e2t("RegExp"),udf=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};e_i(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},syj=e=>{udf(e,(t,r)=>{if(dwe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(dwe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},cyj=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return BBn(e)?n(e):n(String(e).split(t)),r},lyj=()=>{},fyj=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,nlu="abcdefghijklmnopqrstuvwxyz",rdf="0123456789",sdf={DIGIT:rdf,ALPHA:nlu,ALPHA_DIGIT:nlu+nlu.toUpperCase()+rdf},dyj=(e=16,t=sdf.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function pyj(e){return!!(e&&dwe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var _yj=e=>{let t=new Array(10),r=(n,i)=>{if(rya(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;let a=BBn(n)?[]:{};return e_i(n,(u,f)=>{let d=r(u,i+1);!kpi(d)&&(a[f]=d)}),t[i]=void 0,a}}return n};return r(e,0)},hyj=e2t("AsyncFunction"),yyj=e=>e&&(rya(e)||dwe(e))&&dwe(e.then)&&dwe(e.catch),cdf=((e,t)=>e?setImmediate:t?((r,n)=>(pkr.addEventListener("message",({source:i,data:a})=>{i===pkr&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),pkr.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",dwe(pkr.postMessage)),vyj=typeof queueMicrotask<"u"?queueMicrotask.bind(pkr):typeof process<"u"&&process.nextTick||cdf,Ol={isArray:BBn,isArrayBuffer:ndf,isBuffer:Bhj,isFormData:Whj,isArrayBufferView:Ihj,isString:zhj,isNumber:idf,isBoolean:Nhj,isObject:rya,isPlainObject:kha,isReadableStream:Jhj,isRequest:Qhj,isResponse:Ghj,isHeaders:$hj,isUndefined:kpi,isDate:Fhj,isFile:Rhj,isBlob:Lhj,isRegExp:uyj,isFunction:dwe,isStream:Vhj,isURLSearchParams:Hhj,isTypedArray:ryj,isFileList:Uhj,forEach:e_i,merge:ilu,extend:Yhj,trim:Khj,stripBOM:Xhj,inherits:Zhj,toFlatObject:khj,kindOf:eya,kindOfTest:e2t,endsWith:eyj,toArray:tyj,forEachEntry:nyj,matchAll:iyj,isHTMLForm:ayj,hasOwnProperty:tdf,hasOwnProp:tdf,reduceDescriptors:udf,freezeMethods:syj,toObjectSet:cyj,toCamelCase:oyj,noop:lyj,toFiniteNumber:fyj,findKey:adf,global:pkr,isContextDefined:odf,ALPHABET:sdf,generateString:dyj,isSpecCompliantForm:pyj,toJSONObject:_yj,isAsyncFn:hyj,isThenable:yyj,setImmediate:cdf,asap:vyj};function IBn(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Ol.inherits(IBn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ol.toJSONObject(this.config),code:this.code,status:this.status}}});var ldf=IBn.prototype,fdf={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{fdf[e]={value:e}});Object.defineProperties(IBn,fdf);Object.defineProperty(ldf,"isAxiosError",{value:!0});IBn.from=(e,t,r,n,i,a)=>{let u=Object.create(ldf);return Ol.toFlatObject(e,u,function(d){return d!==Error.prototype},f=>f!=="isAxiosError"),IBn.call(u,e.message,t,r,n,i),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var sy=IBn;var ddf=Jo(azr(),1),nya=ddf.default;function olu(e){return Ol.isPlainObject(e)||Ol.isArray(e)}function _df(e){return Ol.endsWith(e,"[]")?e.slice(0,-2):e}function pdf(e,t,r){return e?e.concat(t).map(function(i,a){return i=_df(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function byj(e){return Ol.isArray(e)&&!e.some(olu)}var gyj=Ol.toFlatObject(Ol,{},null,function(t){return/^is[A-Z]/.test(t)});function myj(e,t,r){if(!Ol.isObject(e))throw new TypeError("target must be an object");t=t||new(nya||FormData),r=Ol.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,T){return!Ol.isUndefined(T[A])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Ol.isSpecCompliantForm(t);if(!Ol.isFunction(i))throw new TypeError("visitor must be a function");function c(j){if(j===null)return"";if(Ol.isDate(j))return j.toISOString();if(!d&&Ol.isBlob(j))throw new sy("Blob is not supported. Use a Buffer instead.");return Ol.isArrayBuffer(j)||Ol.isTypedArray(j)?d&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}function o(j,A,T){let B=j;if(j&&!T&&typeof j=="object"){if(Ol.endsWith(A,"{}"))A=n?A:A.slice(0,-2),j=JSON.stringify(j);else if(Ol.isArray(j)&&byj(j)||(Ol.isFileList(j)||Ol.endsWith(A,"[]"))&&(B=Ol.toArray(j)))return A=_df(A),B.forEach(function(C,N){!(Ol.isUndefined(C)||C===null)&&t.append(u===!0?pdf([A],N,a):u===null?A:A+"[]",c(C))}),!1}return olu(j)?!0:(t.append(pdf(T,A,a),c(j)),!1)}let l=[],m=Object.assign(gyj,{defaultVisitor:o,convertValue:c,isVisitable:olu});function O(j,A){if(!Ol.isUndefined(j)){if(l.indexOf(j)!==-1)throw Error("Circular reference detected in "+A.join("."));l.push(j),Ol.forEach(j,function(B,F){(!(Ol.isUndefined(B)||B===null)&&i.call(t,B,Ol.isString(F)?F.trim():F,A,m))===!0&&O(B,A?A.concat(F):[F])}),l.pop()}}if(!Ol.isObject(e))throw new TypeError("data must be an object");return O(e),t}var l6r=myj;function hdf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function ydf(e,t){this._pairs=[],e&&l6r(e,this,t)}var vdf=ydf.prototype;vdf.append=function(t,r){this._pairs.push([t,r])};vdf.toString=function(t){let r=t?function(n){return t.call(this,n,hdf)}:hdf;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var bdf=ydf;function Oyj(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function _kr(e,t,r){if(!t)return e;let n=r&&r.encode||Oyj,i=r&&r.serialize,a;if(i?a=i(t,r):a=Ol.isURLSearchParams(t)?t.toString():new bdf(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var ulu=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Ol.forEach(this.handlers,function(n){n!==null&&t(n)})}},slu=ulu;var zBn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var gdf=Jo(require("url"),1),mdf=gdf.default.URLSearchParams;var Odf={isNode:!0,classes:{URLSearchParams:mdf,FormData:nya,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var flu={};Dc(flu,{hasBrowserEnv:()=>llu,hasStandardBrowserEnv:()=>Pyj,hasStandardBrowserWebWorkerEnv:()=>jyj,navigator:()=>clu,origin:()=>wyj});var llu=typeof window<"u"&&typeof document<"u",clu=typeof navigator=="object"&&navigator||void 0,Pyj=llu&&(!clu||["ReactNative","NativeScript","NS"].indexOf(clu.product)<0),jyj=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wyj=llu&&window.location.href||"http://localhost";var _2={...flu,...Odf};function dlu(e,t){return l6r(e,new _2.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return _2.isNode&&Ol.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function Dyj(e){return Ol.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Syj(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function Eyj(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),d=a>=r.length;return u=!u&&Ol.isArray(i)?i.length:u,d?(Ol.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!f):((!i[u]||!Ol.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Ol.isArray(i[u])&&(i[u]=Syj(i[u])),!f)}if(Ol.isFormData(e)&&Ol.isFunction(e.entries)){let r={};return Ol.forEachEntry(e,(n,i)=>{t(Dyj(n),i,r,0)}),r}return null}var iya=Eyj;function Ayj(e,t,r){if(Ol.isString(e))try{return(t||JSON.parse)(e),Ol.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var plu={transitional:zBn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Ol.isObject(t);if(a&&Ol.isHTMLForm(t)&&(t=new FormData(t)),Ol.isFormData(t))return i?JSON.stringify(iya(t)):t;if(Ol.isArrayBuffer(t)||Ol.isBuffer(t)||Ol.isStream(t)||Ol.isFile(t)||Ol.isBlob(t)||Ol.isReadableStream(t))return t;if(Ol.isArrayBufferView(t))return t.buffer;if(Ol.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return dlu(t,this.formSerializer).toString();if((f=Ol.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return l6r(f?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),Ayj(t)):t}],transformResponse:[function(t){let r=this.transitional||plu.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Ol.isResponse(t)||Ol.isReadableStream(t))return t;if(t&&Ol.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?sy.from(f,sy.ERR_BAD_RESPONSE,this,null,this.response):f}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_2.classes.FormData,Blob:_2.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ol.forEach(["delete","get","head","post","put","patch"],e=>{plu.headers[e]={}});var NBn=plu;var Myj=Ol.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Pdf=e=>{let t={},r,n,i;return e&&e.split(`
1788
+ `}write(t){let r=t.split(/\n/);this.height=r.length,this.rl.setPrompt(r.at(-1)),this.rl.output.rows===0&&this.rl.output.columns===0&&oha(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Tlf=Jo(jlf(),1),xlf=Jo(cuu(),1),qlf=Jo(Alf(),1),Qx=Jo(lwe(),1),Clf=Jo(wdi(),1);var Tha=Jo(lwe(),1),Mlf=Jo(wdi(),1),xha=function(e,t,r){return typeof e[t]!="function"?(0,Tha.of)(e):(0,Tha.from)((0,Mlf.default)(e[t])(r).then(n=>(e[t]=n,e)))};var zpi={isPlainObject:Tlf.default,set:qlf.default,get:xlf.default},wBn=class extends ckr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=zpi.isPlainObject(r)?{...r}:{},zpi.isPlainObject(t)&&(t=Object.values(t).every(i=>zpi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,Qx.from)(t):t;return this.process=n.pipe((0,Qx.concatMap)(this.processQuestion.bind(this)),(0,Qx.publish)()),this.process.connect(),this.process.pipe((0,Qx.reduce)((i,a)=>(zpi.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,Qx.defer)(()=>(0,Qx.of)(t).pipe((0,Qx.concatMap)(this.setDefaultType.bind(this)),(0,Qx.concatMap)(this.filterIfRunnable.bind(this)),(0,Qx.concatMap)(()=>xha(t,"message",this.answers)),(0,Qx.concatMap)(()=>xha(t,"default",this.answers)),(0,Qx.concatMap)(()=>xha(t,"choices",this.answers)),(0,Qx.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,Qx.defer)(()=>(0,Qx.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,Qx.defer)(()=>(0,Qx.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&zpi.get(this.answers,t.name)!==void 0)return(0,Qx.empty)();if(t.when===!1)return(0,Qx.empty)();if(typeof t.when!="function")return(0,Qx.of)(t);let{answers:r}=this;return(0,Qx.defer)(()=>(0,Qx.from)((0,Clf.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,Qx.filter)(n=>n!=null)))}};function Blf(e){let t=function(r,n){let i;try{i=new wBn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",bpi),this.registerPrompt("input",tkr),this.registerPrompt("number",gpi),this.registerPrompt("confirm",mpi),this.registerPrompt("rawlist",Opi),this.registerPrompt("expand",Ppi),this.registerPrompt("checkbox",jpi),this.registerPrompt("password",wpi),this.registerPrompt("editor",Bpi)},t.restoreDefaultPrompts(),t}var ocu=Blf();function Hdj(e,t){ocu.registerPrompt(e,t)}function Jdj(){ocu.restoreDefaultPrompts()}var Qdj={prompt:ocu,ui:{BottomBar:Ipi,Prompt:wBn},createPromptModule:Blf,registerPrompt:Hdj,restoreDefaultPrompts:Jdj,Separator:pne},qha=Qdj;var Hff=Jo(Ilf()),yhj="4.2.1",kCt;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(kCt||(kCt={}));function vhj(e,t){if(!e)throw new Error(t)}function bhj(e){return e?.replace(/\/+$/,"")}async function ghj(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function mhj(){return new Date().getTime()}function zff(){return new Date().toISOString()}function Jff(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Gpi=String.fromCharCode,Nff="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Jha={};function Ohj(e,t){if(!Jha[e]){Jha[e]={};for(let r=0;r<e.length;r++)Jha[e][e.charAt(r)]=r}return Jha[e][t]}var $pi={compressToBase64:function(e){if(e==null)return"";let t=$pi._compress(e,6,function(r){return Nff.charAt(r)});switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return e==null?"":e==""?null:$pi._decompress(e.length,32,function(t){return Ohj(Nff,e.charAt(t))})},compress:function(e){return $pi._compress(e,16,function(t){return Gpi(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],u,f,d="",c="",o="",l=2,m=3,O=2,j=0,A=0,T;for(T=0;T<e.length;T+=1)if(d=e.charAt(T),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=m++,i[d]=!0),c=o+d,Object.prototype.hasOwnProperty.call(n,c))o=c;else{if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[c]=m++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(f=2,u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;for(;;)if(j=j<<1,A==t-1){a.push(r(j));break}else A++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:$pi._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},u=4,f=4,d=3,c="",o,l,m,O,j,A,T;for(o=0;o<3;o+=1)n[o]=o;for(m=0,j=Math.pow(2,2),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=Gpi(m);break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=Gpi(m);break;case 2:return""}for(n[3]=T,l=T,i.push(T);;){if(a.index>e)return"";for(m=0,j=Math.pow(2,d),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(T=m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;n[f++]=Gpi(m),T=f-1,u--;break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;n[f++]=Gpi(m),T=f-1,u--;break;case 2:return i.join("")}if(u==0&&(u=Math.pow(2,d),d++),n[T])c=n[T];else if(T===f)c=l+l.charAt(0);else return null;i.push(c),n[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,d),d++)}}},Gcu=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}};var Qha="0123456789abcdef",Gha=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=Qha.charAt(this.bytes[r]>>>4),t+=Qha.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=Qha.charAt(this.bytes[r]>>>4),t+=Qha.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},$cu=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??Phj()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return Gha.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,Gha.ofInner(t)}},Phj=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Fff,Rff=()=>jhj().toString(),jhj=()=>(Fff||(Fff=new $cu)).generate(),$ha=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Kpi=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Lff(e){return typeof e=="object"&&(e instanceof $ha||e instanceof Kpi)}var Kcu=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new Gcu,this._isInitialized=!1,vhj(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=bhj(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:Lff},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(kCt.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(kCt.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(kCt.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Rff();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}captureStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}groupIdentifyStateless(t,r,n,i,a,u){this.wrap(()=>{let f=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...u||{}}});this.enqueue("capture",f,i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.fetchWithRetry(u,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,n={},i={},a={},u){await this._initPromise;let f=await this.getFeatureFlagsStateless(r,n,i,a,u);if(!f)return;let d=f[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},u){await this._initPromise;let f=await this.getFeatureFlagPayloadsStateless(r,n,i,a,u);if(!f)return;let d=f[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},n={},i={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let f=await this.getDecide(t,r,n,i,u),d=f?.featureFlags,c=f?.featureFlagPayloads,o=c;return c&&(o=Object.fromEntries(Object.entries(c).map(([l,m])=>[l,this._parsePayload(m)]))),{flags:d,payloads:o}}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:zff(),uuid:n?.uuid?n.uuid:Rff()};(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId);let u=this.getPersistedProperty(kCt.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:i}),this.setPersistedProperty(kCt.Queue,u),this._events.emit(t,i),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Jff(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(kCt.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),n=r.map(c=>c.message),i=()=>{let c=this.getPersistedProperty(kCt.Queue)||[];this.setPersistedProperty(kCt.Queue,c.slice(r.length))},a={api_key:this.apiKey,batch:n,sent_at:zff()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),f=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${mhj()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent($pi.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(f,d)}catch(c){throw c instanceof Kpi||i(),this._events.emit("error",c),c}return i(),this._events.emit("flush",n),n}async fetchWithRetry(t,r,n,i){var a;return(a=AbortSignal).timeout??(a.timeout=function(f){let d=new AbortController;return setTimeout(()=>d.abort(),f),d.signal}),await ghj(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(d){throw new Kpi(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new $ha(u);return u},{...this._retryOptions,...n})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(kCt.Queue)||[]).length!==0;){await this.flush();let i=Date.now();if(r<i)break}}catch(r){if(!Lff(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},Ycu=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},Xcu=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!Xcu){let e=Iff();Xcu=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var Qff=Xcu,whj=1152921504606847e3,Dhj=["is_not"],Kha=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},_8=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Zcu=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:u,...f}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=f.fetch||Qff,this.onError=f.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let u,f;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){f=d;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof _8?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},u={},f=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let c=this.computeFlagLocally(d,t,r,n,i);a[d.key]=c;let o=await this.computeFeatureFlagPayloadLocally(d.key,c);o&&(u[d.key]=o)}catch(c){c instanceof _8||c instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${c}`)),f=!0}}),{response:a,payloads:u,fallbackToDecide:f}}computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new _8("Flag has experience continuity enabled");if(!t.active)return!1;let f=(t.filters||{}).aggregation_group_type_index;if(f!=null){let d=this.groupTypeMapping[String(f)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${f} for feature flag ${t.key}`)),new _8("Flag has unknown group type index");if(!(d in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let c=a[d];return this.matchFeatureFlagProperties(t,n[d],c)}else return this.matchFeatureFlagProperties(t,r,i)}matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],u=!1,f,d=[...a].sort((c,o)=>{let l=!!c.variant,m=!!o.variant;return l&&m?0:l?-1:m?1:0});for(let c of d)try{if(this.isConditionMatch(t,r,c,n)){let o=c.variant,l=i.multivariate?.variants||[];o&&l.some(m=>m.key===o)?f=o:f=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof _8)u=!0;else throw o}if(f!==void 0)return f;if(u)throw new _8("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,n,i){let a=n.rollout_percentage,u=f=>{this.logMsgIfDebug(()=>console.warn(f))};if((n.properties||[]).length>0){for(let f of n.properties){let d=f.type,c=!1;if(d==="cohort"?c=$ff(f,i,this.cohorts,this.debugMode):c=Gff(f,i,u),!c)return!1}if(a==null)return!0}return!(a!=null&&Uff(t.key,r)>a/100)}getMatchingVariant(t,r){let n=Uff(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(f=>{i=n+f.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:f.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new Kha("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof Kha&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=Jff(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}};function Uff(e,t,r=""){let n=(0,Hff.createHash)();return n.update(`${e}.${t}${r}`),parseInt(n.digest("hex").slice(0,15),16)/whj}function Gff(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new _8("Operator is_not_set is not supported")}else throw new _8(`Property ${n} not found in propertyValues`);let u=t[n];if(u==null&&!Dhj.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function f(c,o){return Array.isArray(c)?c.map(l=>String(l).toLowerCase()).includes(String(o).toLowerCase()):String(c).toLowerCase()===String(o).toLowerCase()}function d(c,o,l){if(l==="gt")return c>o;if(l==="gte")return c>=o;if(l==="lt")return c<o;if(l==="lte")return c<=o;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return f(i,u);case"is_not":return!f(i,u);case"is_set":return n in t;case"icontains":return String(u).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(i).toLowerCase());case"regex":return Vff(String(i))&&String(u).match(String(i))!==null;case"not_regex":return Vff(String(i))&&String(u).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let c=typeof i=="number"?i:null;if(typeof i=="string")try{c=parseFloat(i)}catch{}return c!=null&&u!=null?typeof u=="string"?d(u,String(i),a):d(u,c,a):d(String(u),String(i),a)}case"is_date_after":case"is_date_before":{let c=Shj(String(i));if(c==null&&(c=Wff(i)),c==null)throw new _8(`Invalid date: ${i}`);let o=Wff(u);return["is_date_before"].includes(a)?o<c:o>c}default:throw new _8(`Unknown operator: ${a}`)}}function $ff(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new _8("can't match cohort without a given cohort property value");let a=r[i];return Kff(a,t,r,n)}function Kff(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let f of a)try{let d=Kff(f,t,r,n);if(i==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof _8)n&&console.debug(`Failed to compute property ${f} locally: ${d}`),u=!0;else throw d}if(u)throw new _8("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let f of a)try{let d;f.type==="cohort"?d=$ff(f,t,r,n):d=Gff(f,t);let c=f.negation||!1;if(i==="AND"){if(!d&&!c||d&&c)return!1}else if(d&&!c||!d&&c)return!0}catch(d){if(d instanceof _8)n&&console.debug(`Failed to compute property ${f} locally: ${d}`),u=!0;else throw d}if(u)throw new _8("can't match cohort without a given cohort property value");return i==="AND"}}function Vff(e){try{return new RegExp(e),!0}catch{return!1}}function Wff(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new _8(`${e} is in an invalid date format`)}else throw new _8(`The date provided ${e} must be a string, number, or date object`)}function Shj(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var Ehj=30*1e3,Ahj=50*1e3,xBn=class extends Kcu{constructor(t,r={}){super(t,r),this._memoryStorage=new Ycu,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new Zcu({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:Ehj,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||Ahj}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):Qff(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return yhj}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:n,groups:i,sendFeatureFlags:a,timestamp:u,disableGeoip:f,uuid:d}){let c=m=>{super.captureStateless(t,r,m,{timestamp:u,disableGeoip:f,uuid:d})},o=(m,O,j)=>super.getFeatureFlagsStateless(m,O,void 0,void 0,j),l=Promise.resolve().then(async()=>{if(a)return await o(t,i,f);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let m={};for(let[O,j]of Object.entries(i||{}))m[O]=String(j);return await this.getAllFlags(t,{groups:m,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(m=>{let O={};if(m)for(let[A,T]of Object.entries(m))O[`$feature/${A}`]=T;let j=Object.keys(m||{}).filter(A=>m?.[A]!==!1);return j.length>0&&(O.$active_feature_flags=j),O}).catch(()=>({})).then(m=>{c({...m,...n,$groups:i})});this.addPendingPromise(l)}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set||r;super.identifyStateless(t,{$set:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:f,personProperties:d,groupProperties:c}=n||{},o=this.addLocalPersonAndGroupProperties(r,i,d,c);d=o.allPersonProperties,c=o.allGroupProperties,u==null&&(u=!1),f==null&&(f=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,d,c),m=l!==void 0;!m&&!u&&(l=await super.getFeatureFlagStateless(t,r,i,d,c,a));let O=`${t}_${l}`;return f&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(O))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(O):this.distinctIdHasSentFlagCalls[r]=[O],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,locally_evaluated:m,[`$feature/${t}`]:l},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:u}=i||{},{onlyEvaluateLocally:f,sendFeatureFlagEvents:d,personProperties:c,groupProperties:o}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,c,o);c=l.allPersonProperties,o=l.allGroupProperties;let m;return n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n)),f==null&&(f=!1),d==null&&(d=!0),f==null&&(f=!1),!(m!==void 0)&&!f&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,c,o,u)),m}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:f}=r||{},d=this.addLocalPersonAndGroupProperties(t,n,u,f);u=d.allPersonProperties,f=d.allGroupProperties,a==null&&(a=!1);let c=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,u,f),o={},l={},m=!0;if(c&&(o=c.response,l=c.payloads,m=c.fallbackToDecide),m&&!a){let O=await super.getFeatureFlagsAndPayloadsStateless(t,n,u,f,i);o={...o,...O.flags||{}},l={...l,...O.payloads||{}}}return{featureFlags:o,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},u={};if(r)for(let f of Object.keys(r))u[f]={$group_key:r[f],...i?.[f]||{}};return{allPersonProperties:a,allGroupProperties:u}}},kcu=class e{constructor(t,r,n,i){this.posthog=t,this.posthogHost=r,this.organization=n,this.prefix=i,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(n=>{if(n.exception?.values===void 0||n.exception.values.length===0)return n;n.tags||(n.tags={});let i=r(),a=n.tags[e.POSTHOG_ID_TAG];if(a===void 0)return n;n.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:n.exception.values[0]?.value,$exception_type:n.exception.values[0]?.type,$exception_personURL:n.tags["PostHog Person URL"],$sentry_event_id:n.event_id,$sentry_exception:n.exception,$sentry_exception_message:n.exception.values[0]?.value,$sentry_exception_type:n.exception.values[0]?.type,$sentry_tags:n.tags},f=i.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&f!==void 0&&n.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${f}&query=${n.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),n})}};kcu.POSTHOG_ID_TAG="posthog_distinct_id";var Yha=class{posthog;constructor({posthogApiKey:t}){this.posthog=new xBn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.45.0-rc40",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Ypi=class{async sendEvent(){}async identify(){}async flush(){}};var qBn=require("fs/promises"),kff=require("os"),edf=require("path");var Yff=Jo(require("crypto")),Zha=new Uint8Array(256),Xha=Zha.length;function elu(){return Xha>Zha.length-16&&(Yff.default.randomFillSync(Zha),Xha=0),Zha.slice(Xha,Xha+=16)}var cW=[];for(let e=0;e<256;++e)cW.push((e+256).toString(16).slice(1));function Xff(e,t=0){return cW[e[t+0]]+cW[e[t+1]]+cW[e[t+2]]+cW[e[t+3]]+"-"+cW[e[t+4]]+cW[e[t+5]]+"-"+cW[e[t+6]]+cW[e[t+7]]+"-"+cW[e[t+8]]+cW[e[t+9]]+"-"+cW[e[t+10]]+cW[e[t+11]]+cW[e[t+12]]+cW[e[t+13]]+cW[e[t+14]]+cW[e[t+15]]}var Zff=Jo(require("crypto")),tlu={randomUUID:Zff.default.randomUUID};function Mhj(e,t,r){if(tlu.randomUUID&&!t&&!e)return tlu.randomUUID();e=e||{};let n=e.random||(e.rng||elu)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Xff(n)}var c6r=Mhj;var Thj="id",xhj=".fern",Xpi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new xBn(r),this.userId=t==null?void 0:vru(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.45.0-rc40",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Wl(Hp.of((0,kff.homedir)()),ls.of(xhj),ls.of(Thj));await _h(t)||(await(0,qBn.mkdir)((0,edf.dirname)(t),{recursive:!0}),await(0,qBn.writeFile)(t,c6r())),this.persistedDistinctId=(await(0,qBn.readFile)(t)).toString()}return this.persistedDistinctId}};var rlu;async function CBn(){return rlu==null&&(rlu=await qhj()),rlu}async function qhj(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Ypi;let r=await oca();return r!=null?new Xpi({token:r,posthogApiKey:e}):await aca()!=null?new Yha({posthogApiKey:e}):new Xpi({token:void 0,posthogApiKey:e})}catch{return new Ypi}}function Zpi(e,t){return function(){return e.apply(t,arguments)}}var{toString:Chj}=Object.prototype,{getPrototypeOf:alu}=Object,eya=(e=>t=>{let r=Chj.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),e2t=e=>(e=e.toLowerCase(),t=>eya(t)===e),tya=e=>t=>typeof t===e,{isArray:BBn}=Array,kpi=tya("undefined");function Bhj(e){return e!==null&&!kpi(e)&&e.constructor!==null&&!kpi(e.constructor)&&dwe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var ndf=e2t("ArrayBuffer");function Ihj(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ndf(e.buffer),t}var zhj=tya("string"),dwe=tya("function"),idf=tya("number"),rya=e=>e!==null&&typeof e=="object",Nhj=e=>e===!0||e===!1,kha=e=>{if(eya(e)!=="object")return!1;let t=alu(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Fhj=e2t("Date"),Rhj=e2t("File"),Lhj=e2t("Blob"),Uhj=e2t("FileList"),Vhj=e=>rya(e)&&dwe(e.pipe),Whj=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||dwe(e.append)&&((t=eya(e))==="formdata"||t==="object"&&dwe(e.toString)&&e.toString()==="[object FormData]"))},Hhj=e2t("URLSearchParams"),[Jhj,Qhj,Ghj,$hj]=["ReadableStream","Request","Response","Headers"].map(e2t),Khj=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function e_i(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),BBn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,f;for(n=0;n<u;n++)f=a[n],t.call(null,e[f],f,e)}}function adf(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var pkr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,odf=e=>!kpi(e)&&e!==pkr;function ilu(){let{caseless:e}=odf(this)&&this||{},t={},r=(n,i)=>{let a=e&&adf(t,i)||i;kha(t[a])&&kha(n)?t[a]=ilu(t[a],n):kha(n)?t[a]=ilu({},n):BBn(n)?t[a]=n.slice():t[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&e_i(arguments[n],r);return t}var Yhj=(e,t,r,{allOwnKeys:n}={})=>(e_i(t,(i,a)=>{r&&dwe(i)?e[a]=Zpi(i,r):e[a]=i},{allOwnKeys:n}),e),Xhj=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Zhj=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},khj=(e,t,r,n)=>{let i,a,u,f={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)u=i[a],(!n||n(u,e,t))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&alu(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},eyj=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},tyj=e=>{if(!e)return null;if(BBn(e))return e;let t=e.length;if(!idf(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},ryj=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&alu(Uint8Array)),nyj=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},iyj=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},ayj=e2t("HTMLFormElement"),oyj=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),tdf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),uyj=e2t("RegExp"),udf=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};e_i(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},syj=e=>{udf(e,(t,r)=>{if(dwe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(dwe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},cyj=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return BBn(e)?n(e):n(String(e).split(t)),r},lyj=()=>{},fyj=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,nlu="abcdefghijklmnopqrstuvwxyz",rdf="0123456789",sdf={DIGIT:rdf,ALPHA:nlu,ALPHA_DIGIT:nlu+nlu.toUpperCase()+rdf},dyj=(e=16,t=sdf.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function pyj(e){return!!(e&&dwe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var _yj=e=>{let t=new Array(10),r=(n,i)=>{if(rya(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;let a=BBn(n)?[]:{};return e_i(n,(u,f)=>{let d=r(u,i+1);!kpi(d)&&(a[f]=d)}),t[i]=void 0,a}}return n};return r(e,0)},hyj=e2t("AsyncFunction"),yyj=e=>e&&(rya(e)||dwe(e))&&dwe(e.then)&&dwe(e.catch),cdf=((e,t)=>e?setImmediate:t?((r,n)=>(pkr.addEventListener("message",({source:i,data:a})=>{i===pkr&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),pkr.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",dwe(pkr.postMessage)),vyj=typeof queueMicrotask<"u"?queueMicrotask.bind(pkr):typeof process<"u"&&process.nextTick||cdf,Ol={isArray:BBn,isArrayBuffer:ndf,isBuffer:Bhj,isFormData:Whj,isArrayBufferView:Ihj,isString:zhj,isNumber:idf,isBoolean:Nhj,isObject:rya,isPlainObject:kha,isReadableStream:Jhj,isRequest:Qhj,isResponse:Ghj,isHeaders:$hj,isUndefined:kpi,isDate:Fhj,isFile:Rhj,isBlob:Lhj,isRegExp:uyj,isFunction:dwe,isStream:Vhj,isURLSearchParams:Hhj,isTypedArray:ryj,isFileList:Uhj,forEach:e_i,merge:ilu,extend:Yhj,trim:Khj,stripBOM:Xhj,inherits:Zhj,toFlatObject:khj,kindOf:eya,kindOfTest:e2t,endsWith:eyj,toArray:tyj,forEachEntry:nyj,matchAll:iyj,isHTMLForm:ayj,hasOwnProperty:tdf,hasOwnProp:tdf,reduceDescriptors:udf,freezeMethods:syj,toObjectSet:cyj,toCamelCase:oyj,noop:lyj,toFiniteNumber:fyj,findKey:adf,global:pkr,isContextDefined:odf,ALPHABET:sdf,generateString:dyj,isSpecCompliantForm:pyj,toJSONObject:_yj,isAsyncFn:hyj,isThenable:yyj,setImmediate:cdf,asap:vyj};function IBn(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Ol.inherits(IBn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ol.toJSONObject(this.config),code:this.code,status:this.status}}});var ldf=IBn.prototype,fdf={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{fdf[e]={value:e}});Object.defineProperties(IBn,fdf);Object.defineProperty(ldf,"isAxiosError",{value:!0});IBn.from=(e,t,r,n,i,a)=>{let u=Object.create(ldf);return Ol.toFlatObject(e,u,function(d){return d!==Error.prototype},f=>f!=="isAxiosError"),IBn.call(u,e.message,t,r,n,i),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var sy=IBn;var ddf=Jo(azr(),1),nya=ddf.default;function olu(e){return Ol.isPlainObject(e)||Ol.isArray(e)}function _df(e){return Ol.endsWith(e,"[]")?e.slice(0,-2):e}function pdf(e,t,r){return e?e.concat(t).map(function(i,a){return i=_df(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function byj(e){return Ol.isArray(e)&&!e.some(olu)}var gyj=Ol.toFlatObject(Ol,{},null,function(t){return/^is[A-Z]/.test(t)});function myj(e,t,r){if(!Ol.isObject(e))throw new TypeError("target must be an object");t=t||new(nya||FormData),r=Ol.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,T){return!Ol.isUndefined(T[A])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Ol.isSpecCompliantForm(t);if(!Ol.isFunction(i))throw new TypeError("visitor must be a function");function c(j){if(j===null)return"";if(Ol.isDate(j))return j.toISOString();if(!d&&Ol.isBlob(j))throw new sy("Blob is not supported. Use a Buffer instead.");return Ol.isArrayBuffer(j)||Ol.isTypedArray(j)?d&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}function o(j,A,T){let B=j;if(j&&!T&&typeof j=="object"){if(Ol.endsWith(A,"{}"))A=n?A:A.slice(0,-2),j=JSON.stringify(j);else if(Ol.isArray(j)&&byj(j)||(Ol.isFileList(j)||Ol.endsWith(A,"[]"))&&(B=Ol.toArray(j)))return A=_df(A),B.forEach(function(C,N){!(Ol.isUndefined(C)||C===null)&&t.append(u===!0?pdf([A],N,a):u===null?A:A+"[]",c(C))}),!1}return olu(j)?!0:(t.append(pdf(T,A,a),c(j)),!1)}let l=[],m=Object.assign(gyj,{defaultVisitor:o,convertValue:c,isVisitable:olu});function O(j,A){if(!Ol.isUndefined(j)){if(l.indexOf(j)!==-1)throw Error("Circular reference detected in "+A.join("."));l.push(j),Ol.forEach(j,function(B,F){(!(Ol.isUndefined(B)||B===null)&&i.call(t,B,Ol.isString(F)?F.trim():F,A,m))===!0&&O(B,A?A.concat(F):[F])}),l.pop()}}if(!Ol.isObject(e))throw new TypeError("data must be an object");return O(e),t}var l6r=myj;function hdf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function ydf(e,t){this._pairs=[],e&&l6r(e,this,t)}var vdf=ydf.prototype;vdf.append=function(t,r){this._pairs.push([t,r])};vdf.toString=function(t){let r=t?function(n){return t.call(this,n,hdf)}:hdf;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var bdf=ydf;function Oyj(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function _kr(e,t,r){if(!t)return e;let n=r&&r.encode||Oyj,i=r&&r.serialize,a;if(i?a=i(t,r):a=Ol.isURLSearchParams(t)?t.toString():new bdf(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var ulu=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Ol.forEach(this.handlers,function(n){n!==null&&t(n)})}},slu=ulu;var zBn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var gdf=Jo(require("url"),1),mdf=gdf.default.URLSearchParams;var Odf={isNode:!0,classes:{URLSearchParams:mdf,FormData:nya,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var flu={};Dc(flu,{hasBrowserEnv:()=>llu,hasStandardBrowserEnv:()=>Pyj,hasStandardBrowserWebWorkerEnv:()=>jyj,navigator:()=>clu,origin:()=>wyj});var llu=typeof window<"u"&&typeof document<"u",clu=typeof navigator=="object"&&navigator||void 0,Pyj=llu&&(!clu||["ReactNative","NativeScript","NS"].indexOf(clu.product)<0),jyj=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wyj=llu&&window.location.href||"http://localhost";var _2={...flu,...Odf};function dlu(e,t){return l6r(e,new _2.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return _2.isNode&&Ol.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function Dyj(e){return Ol.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Syj(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function Eyj(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),d=a>=r.length;return u=!u&&Ol.isArray(i)?i.length:u,d?(Ol.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!f):((!i[u]||!Ol.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Ol.isArray(i[u])&&(i[u]=Syj(i[u])),!f)}if(Ol.isFormData(e)&&Ol.isFunction(e.entries)){let r={};return Ol.forEachEntry(e,(n,i)=>{t(Dyj(n),i,r,0)}),r}return null}var iya=Eyj;function Ayj(e,t,r){if(Ol.isString(e))try{return(t||JSON.parse)(e),Ol.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var plu={transitional:zBn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Ol.isObject(t);if(a&&Ol.isHTMLForm(t)&&(t=new FormData(t)),Ol.isFormData(t))return i?JSON.stringify(iya(t)):t;if(Ol.isArrayBuffer(t)||Ol.isBuffer(t)||Ol.isStream(t)||Ol.isFile(t)||Ol.isBlob(t)||Ol.isReadableStream(t))return t;if(Ol.isArrayBufferView(t))return t.buffer;if(Ol.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return dlu(t,this.formSerializer).toString();if((f=Ol.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return l6r(f?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),Ayj(t)):t}],transformResponse:[function(t){let r=this.transitional||plu.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Ol.isResponse(t)||Ol.isReadableStream(t))return t;if(t&&Ol.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?sy.from(f,sy.ERR_BAD_RESPONSE,this,null,this.response):f}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_2.classes.FormData,Blob:_2.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ol.forEach(["delete","get","head","post","put","patch"],e=>{plu.headers[e]={}});var NBn=plu;var Myj=Ol.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Pdf=e=>{let t={},r,n,i;return e&&e.split(`
1789
1789
  `).forEach(function(u){i=u.indexOf(":"),r=u.substring(0,i).trim().toLowerCase(),n=u.substring(i+1).trim(),!(!r||t[r]&&Myj[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var jdf=Symbol("internals");function t_i(e){return e&&String(e).trim().toLowerCase()}function aya(e){return e===!1||e==null?e:Ol.isArray(e)?e.map(aya):String(e)}function Tyj(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var xyj=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function _lu(e,t,r,n,i){if(Ol.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Ol.isString(t)){if(Ol.isString(n))return t.indexOf(n)!==-1;if(Ol.isRegExp(n))return n.test(t)}}function qyj(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function Cyj(e,t){let r=Ol.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,a,u){return this[n].call(this,t,i,a,u)},configurable:!0})})}var FBn=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(f,d,c){let o=t_i(d);if(!o)throw new Error("header name must be a non-empty string");let l=Ol.findKey(i,o);(!l||i[l]===void 0||c===!0||c===void 0&&i[l]!==!1)&&(i[l||d]=aya(f))}let u=(f,d)=>Ol.forEach(f,(c,o)=>a(c,o,d));if(Ol.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(Ol.isString(t)&&(t=t.trim())&&!xyj(t))u(Pdf(t),r);else if(Ol.isHeaders(t))for(let[f,d]of t.entries())a(d,f,n);else t!=null&&a(r,t,n);return this}get(t,r){if(t=t_i(t),t){let n=Ol.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return Tyj(i);if(Ol.isFunction(r))return r.call(this,i,n);if(Ol.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=t_i(t),t){let n=Ol.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||_lu(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(u){if(u=t_i(u),u){let f=Ol.findKey(n,u);f&&(!r||_lu(n,n[f],f,r))&&(delete n[f],i=!0)}}return Ol.isArray(t)?t.forEach(a):a(t),i}clear(t){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!t||_lu(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Ol.forEach(this,(i,a)=>{let u=Ol.findKey(n,a);if(u){r[u]=aya(i),delete r[a];return}let f=t?qyj(a):String(a).trim();f!==a&&delete r[a],r[f]=aya(i),n[f]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Ol.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Ol.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
1790
1790
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[jdf]=this[jdf]={accessors:{}}).accessors,i=this.prototype;function a(u){let f=t_i(u);n[f]||(Cyj(i,u),n[f]=!0)}return Ol.isArray(t)?t.forEach(a):a(t),this}};FBn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Ol.reduceDescriptors(FBn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Ol.freezeMethods(FBn);var vz=FBn;function r_i(e,t){let r=this||NBn,n=t||r,i=vz.from(n.headers),a=n.data;return Ol.forEach(e,function(f){a=f.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function n_i(e){return!!(e&&e.__CANCEL__)}function wdf(e,t,r){sy.call(this,e??"canceled",sy.ERR_CANCELED,t,r),this.name="CanceledError"}Ol.inherits(wdf,sy,{__CANCEL__:!0});var pwe=wdf;function ZRt(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new sy("Request failed with status code "+r.status,[sy.ERR_BAD_REQUEST,sy.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function hlu(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ylu(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function hkr(e,t){return e&&!hlu(t)?ylu(e,t):t}var Ldf=Jo(scu(),1),Udf=Jo(require("http"),1),Vdf=Jo(require("https"),1),Wdf=Jo(require("util"),1),Hdf=Jo(Ocu(),1),FDr=Jo(require("zlib"),1);var ykr="1.7.7";function i_i(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var Byj=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function vlu(e,t,r){let n=r&&r.Blob||_2.classes.Blob,i=i_i(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=Byj.exec(e);if(!a)throw new sy("Invalid URL",sy.ERR_INVALID_URL);let u=a[1],f=a[2],d=a[3],c=Buffer.from(decodeURIComponent(d),f?"base64":"utf8");if(t){if(!n)throw new sy("Blob is not supported",sy.ERR_NOT_SUPPORT);return new n([c],{type:u})}return c}throw new sy("Unsupported protocol "+i,sy.ERR_NOT_SUPPORT)}var vkr=Jo(require("stream"),1);var Ddf=Jo(require("stream"),1);var blu=Symbol("internals"),glu=class extends Ddf.default.Transform{constructor(t){t=Ol.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Ol.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[blu]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[blu];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[blu],a=i.maxRate,u=this.readableHighWaterMark,f=i.timeWindow,d=1e3/f,c=a/d,o=i.minChunkSize!==!1?Math.max(i.minChunkSize,c*.01):0,l=(O,j)=>{let A=Buffer.byteLength(O);i.bytesSeen+=A,i.bytes+=A,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(O)?process.nextTick(j):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(j)}},m=(O,j)=>{let A=Buffer.byteLength(O),T=null,B=u,F,C=0;if(a){let N=Date.now();(!i.ts||(C=N-i.ts)>=f)&&(i.ts=N,F=c-i.bytes,i.bytes=F<0?-F:0,C=0),F=c-i.bytes}if(a){if(F<=0)return setTimeout(()=>{j(null,O)},f-C);F<B&&(B=F)}B&&A>B&&A-B>o&&(T=O.subarray(B),O=O.subarray(0,B)),l(O,T?()=>{process.nextTick(j,null,T)}:j)};m(t,function O(j,A){if(j)return n(j);A?m(A,O):n(null)})}},mlu=glu;var Jdf=require("events");var Edf=require("util"),Adf=require("stream");var{asyncIterator:Sdf}=Symbol,Iyj=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Sdf]?yield*e[Sdf]():yield e},oya=Iyj;var zyj=Ol.ALPHABET.ALPHA_DIGIT+"-_",a_i=new Edf.TextEncoder,f6r=`\r
1791
1791
  `,Nyj=a_i.encode(f6r),Fyj=2,Olu=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Ol.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${f6r}`;i?r=a_i.encode(String(r).replace(/\r?\n|\r\n?/g,f6r)):a+=`Content-Type: ${r.type||"application/octet-stream"}${f6r}`,this.headers=a_i.encode(a+f6r),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+Fyj,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Ol.isTypedArray(t)?yield t:yield*oya(t),yield Nyj}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},Ryj=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+Ol.generateString(i,zyj)}=r||{};if(!Ol.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let u=a_i.encode("--"+a+f6r),f=a_i.encode("--"+a+"--"+f6r+f6r),d=f.byteLength,c=Array.from(e.entries()).map(([l,m])=>{let O=new Olu(l,m);return d+=O.size,O});d+=u.byteLength*c.length,d=Ol.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),Adf.Readable.from(async function*(){for(let l of c)yield u,yield*l.encode();yield f}())},Mdf=Ryj;var Tdf=Jo(require("stream"),1),Plu=class extends Tdf.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},xdf=Plu;var Lyj=(e,t)=>Ol.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(a){n(a)}},n)}:e,qdf=Lyj;function Uyj(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let c=Date.now(),o=n[a];u||(u=c),r[i]=d,n[i]=c;let l=a,m=0;for(;l!==i;)m+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-u<t)return;let O=o&&c-o;return O?Math.round(m*1e3/O):void 0}}var Cdf=Uyj;function Vyj(e,t){let r=0,n=1e3/t,i,a,u=(c,o=Date.now())=>{r=o,i=null,a&&(clearTimeout(a),a=null),e.apply(null,c)};return[(...c)=>{let o=Date.now(),l=o-r;l>=n?u(c,o):(i=c,a||(a=setTimeout(()=>{a=null,u(i)},n-l)))},()=>i&&u(i)]}var Bdf=Vyj;var NDr=(e,t,r=3)=>{let n=0,i=Cdf(50,250);return Bdf(a=>{let u=a.loaded,f=a.lengthComputable?a.total:void 0,d=u-n,c=i(d),o=u<=f;n=u;let l={loaded:u,total:f,progress:f?u/f:void 0,bytes:d,rate:c||void 0,estimated:c&&f&&o?(f-u)/c:void 0,event:a,lengthComputable:f!=null,[t?"download":"upload"]:!0};e(l)},r)},RBn=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},LBn=e=>(...t)=>Ol.asap(()=>e(...t));var Idf={flush:FDr.default.constants.Z_SYNC_FLUSH,finishFlush:FDr.default.constants.Z_SYNC_FLUSH},Wyj={flush:FDr.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:FDr.default.constants.BROTLI_OPERATION_FLUSH},zdf=Ol.isFunction(FDr.default.createBrotliDecompress),{http:Hyj,https:Jyj}=Hdf.default,Qyj=/https:?/,Ndf=_2.protocols.map(e=>e+":"),Fdf=(e,[t,r])=>(e.on("end",r).on("error",r),t);function Gyj(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function Qdf(e,t,r){let n=t;if(!n&&n!==!1){let i=(0,Ldf.getProxyForUrl)(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(a){Qdf(a,t,a.href)}}var $yj=typeof process<"u"&&Ol.kindOf(process)==="process",Kyj=e=>new Promise((t,r)=>{let n,i,a=(d,c)=>{i||(i=!0,n&&n(d,c))},u=d=>{a(d),t(d)},f=d=>{a(d,!0),r(d)};e(u,f,d=>n=d).catch(f)}),Yyj=({address:e,family:t})=>{if(!Ol.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},Rdf=(e,t)=>Yyj(Ol.isObject(e)?e:{address:e,family:t}),Gdf=$yj&&function(t){return Kyj(async function(n,i,a){let{data:u,lookup:f,family:d}=t,{responseType:c,responseEncoding:o}=t,l=t.method.toUpperCase(),m,O=!1,j;if(f){let cr=qdf(f,Wr=>Ol.isArray(Wr)?Wr:[Wr]);f=(Wr,gn,Kt)=>{cr(Wr,gn,(Mr,Mn,ar)=>{if(Mr)return Kt(Mr);let mn=Ol.isArray(Mn)?Mn.map(On=>Rdf(On)):[Rdf(Mn,ar)];gn.all?Kt(Mr,mn):Kt(Mr,mn[0].address,mn[0].family)})}}let A=new Jdf.EventEmitter,T=()=>{t.cancelToken&&t.cancelToken.unsubscribe(B),t.signal&&t.signal.removeEventListener("abort",B),A.removeAllListeners()};a((cr,Wr)=>{m=!0,Wr&&(O=!0,T())});function B(cr){A.emit("abort",!cr||cr.type?new pwe(null,t,j):cr)}A.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(B),t.signal&&(t.signal.aborted?B():t.signal.addEventListener("abort",B)));let F=hkr(t.baseURL,t.url),C=new URL(F,_2.hasBrowserEnv?_2.origin:void 0),N=C.protocol||Ndf[0];if(N==="data:"){let cr;if(l!=="GET")return ZRt(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{cr=vlu(t.url,c==="blob",{Blob:t.env&&t.env.Blob})}catch(Wr){throw sy.from(Wr,sy.ERR_BAD_REQUEST,t)}return c==="text"?(cr=cr.toString(o),(!o||o==="utf8")&&(cr=Ol.stripBOM(cr))):c==="stream"&&(cr=vkr.default.Readable.from(cr)),ZRt(n,i,{data:cr,status:200,statusText:"OK",headers:new vz,config:t})}if(Ndf.indexOf(N)===-1)return i(new sy("Unsupported protocol "+N,sy.ERR_BAD_REQUEST,t));let U=vz.from(t.headers).normalize();U.set("User-Agent","axios/"+ykr,!1);let{onUploadProgress:ne,onDownloadProgress:ge}=t,X=t.maxRate,k,xe;if(Ol.isSpecCompliantForm(u)){let cr=U.getContentType(/boundary=([-_\w\d]{10,70})/i);u=Mdf(u,Wr=>{U.set(Wr)},{tag:`axios-${ykr}-boundary`,boundary:cr&&cr[1]||void 0})}else if(Ol.isFormData(u)&&Ol.isFunction(u.getHeaders)){if(U.set(u.getHeaders()),!U.hasContentLength())try{let cr=await Wdf.default.promisify(u.getLength).call(u);Number.isFinite(cr)&&cr>=0&&U.setContentLength(cr)}catch{}}else if(Ol.isBlob(u))u.size&&U.setContentType(u.type||"application/octet-stream"),U.setContentLength(u.size||0),u=vkr.default.Readable.from(oya(u));else if(u&&!Ol.isStream(u)){if(!Buffer.isBuffer(u))if(Ol.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(Ol.isString(u))u=Buffer.from(u,"utf-8");else return i(new sy("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",sy.ERR_BAD_REQUEST,t));if(U.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return i(new sy("Request body larger than maxBodyLength limit",sy.ERR_BAD_REQUEST,t))}let vt=Ol.toFiniteNumber(U.getContentLength());Ol.isArray(X)?(k=X[0],xe=X[1]):k=xe=X,u&&(ne||k)&&(Ol.isStream(u)||(u=vkr.default.Readable.from(u,{objectMode:!1})),u=vkr.default.pipeline([u,new mlu({maxRate:Ol.toFiniteNumber(k)})],Ol.noop),ne&&u.on("progress",Fdf(u,RBn(vt,NDr(LBn(ne),!1,3)))));let yt;if(t.auth){let cr=t.auth.username||"",Wr=t.auth.password||"";yt=cr+":"+Wr}if(!yt&&C.username){let cr=C.username,Wr=C.password;yt=cr+":"+Wr}yt&&U.delete("authorization");let St;try{St=_kr(C.pathname+C.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(cr){let Wr=new Error(cr.message);return Wr.config=t,Wr.url=t.url,Wr.exists=!0,i(Wr)}U.set("Accept-Encoding","gzip, compress, deflate"+(zdf?", br":""),!1);let Ft={path:St,method:l,headers:U.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:yt,protocol:N,family:d,beforeRedirect:Gyj,beforeRedirects:{}};!Ol.isUndefined(f)&&(Ft.lookup=f),t.socketPath?Ft.socketPath=t.socketPath:(Ft.hostname=C.hostname.startsWith("[")?C.hostname.slice(1,-1):C.hostname,Ft.port=C.port,Qdf(Ft,t.proxy,N+"//"+C.hostname+(C.port?":"+C.port:"")+Ft.path));let Zt,Vt=Qyj.test(Ft.protocol);if(Ft.agent=Vt?t.httpsAgent:t.httpAgent,t.transport?Zt=t.transport:t.maxRedirects===0?Zt=Vt?Vdf.default:Udf.default:(t.maxRedirects&&(Ft.maxRedirects=t.maxRedirects),t.beforeRedirect&&(Ft.beforeRedirects.config=t.beforeRedirect),Zt=Vt?Jyj:Hyj),t.maxBodyLength>-1?Ft.maxBodyLength=t.maxBodyLength:Ft.maxBodyLength=1/0,t.insecureHTTPParser&&(Ft.insecureHTTPParser=t.insecureHTTPParser),j=Zt.request(Ft,function(Wr){if(j.destroyed)return;let gn=[Wr],Kt=+Wr.headers["content-length"];if(ge||xe){let On=new mlu({maxRate:Ol.toFiniteNumber(xe)});ge&&On.on("progress",Fdf(On,RBn(Kt,NDr(LBn(ge),!0,3)))),gn.push(On)}let Mr=Wr,Mn=Wr.req||j;if(t.decompress!==!1&&Wr.headers["content-encoding"])switch((l==="HEAD"||Wr.statusCode===204)&&delete Wr.headers["content-encoding"],(Wr.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":gn.push(FDr.default.createUnzip(Idf)),delete Wr.headers["content-encoding"];break;case"deflate":gn.push(new xdf),gn.push(FDr.default.createUnzip(Idf)),delete Wr.headers["content-encoding"];break;case"br":zdf&&(gn.push(FDr.default.createBrotliDecompress(Wyj)),delete Wr.headers["content-encoding"])}Mr=gn.length>1?vkr.default.pipeline(gn,Ol.noop):gn[0];let ar=vkr.default.finished(Mr,()=>{ar(),T()}),mn={status:Wr.statusCode,statusText:Wr.statusMessage,headers:new vz(Wr.headers),config:t,request:Mn};if(c==="stream")mn.data=Mr,ZRt(n,i,mn);else{let On=[],Ut=0;Mr.on("data",function(Yr){On.push(Yr),Ut+=Yr.length,t.maxContentLength>-1&&Ut>t.maxContentLength&&(O=!0,Mr.destroy(),i(new sy("maxContentLength size of "+t.maxContentLength+" exceeded",sy.ERR_BAD_RESPONSE,t,Mn)))}),Mr.on("aborted",function(){if(O)return;let Yr=new sy("maxContentLength size of "+t.maxContentLength+" exceeded",sy.ERR_BAD_RESPONSE,t,Mn);Mr.destroy(Yr),i(Yr)}),Mr.on("error",function(Yr){j.destroyed||i(sy.from(Yr,null,t,Mn))}),Mr.on("end",function(){try{let Yr=On.length===1?On[0]:Buffer.concat(On);c!=="arraybuffer"&&(Yr=Yr.toString(o),(!o||o==="utf8")&&(Yr=Ol.stripBOM(Yr))),mn.data=Yr}catch(Yr){return i(sy.from(Yr,null,t,mn.request,mn))}ZRt(n,i,mn)})}A.once("abort",On=>{Mr.destroyed||(Mr.emit("error",On),Mr.destroy())})}),A.once("abort",cr=>{i(cr),j.destroy(cr)}),j.on("error",function(Wr){i(sy.from(Wr,null,t,j))}),j.on("socket",function(Wr){Wr.setKeepAlive(!0,1e3*60)}),t.timeout){let cr=parseInt(t.timeout,10);if(Number.isNaN(cr)){i(new sy("error trying to parse `config.timeout` to int",sy.ERR_BAD_OPTION_VALUE,t,j));return}j.setTimeout(cr,function(){if(m)return;let gn=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Kt=t.transitional||zBn;t.timeoutErrorMessage&&(gn=t.timeoutErrorMessage),i(new sy(gn,Kt.clarifyTimeoutError?sy.ETIMEDOUT:sy.ECONNABORTED,t,j)),B()})}if(Ol.isStream(u)){let cr=!1,Wr=!1;u.on("end",()=>{cr=!0}),u.once("error",gn=>{Wr=!0,j.destroy(gn)}),u.on("close",()=>{!cr&&!Wr&&B(new pwe("Request stream has been aborted",t,j))}),u.pipe(j)}else j.end(u)})};var $df=_2.hasStandardBrowserEnv?function(){let t=_2.navigator&&/(msie|trident)/i.test(_2.navigator.userAgent),r=document.createElement("a"),n;function i(a){let u=a;return t&&(r.setAttribute("href",u),u=r.href),r.setAttribute("href",u),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(u){let f=Ol.isString(u)?i(u):u;return f.protocol===n.protocol&&f.host===n.host}}():function(){return function(){return!0}}();var Kdf=_2.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let u=[e+"="+encodeURIComponent(t)];Ol.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),Ol.isString(n)&&u.push("path="+n),Ol.isString(i)&&u.push("domain="+i),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var Ydf=e=>e instanceof vz?{...e}:e;function t2t(e,t){t=t||{};let r={};function n(c,o,l){return Ol.isPlainObject(c)&&Ol.isPlainObject(o)?Ol.merge.call({caseless:l},c,o):Ol.isPlainObject(o)?Ol.merge({},o):Ol.isArray(o)?o.slice():o}function i(c,o,l){if(Ol.isUndefined(o)){if(!Ol.isUndefined(c))return n(void 0,c,l)}else return n(c,o,l)}function a(c,o){if(!Ol.isUndefined(o))return n(void 0,o)}function u(c,o){if(Ol.isUndefined(o)){if(!Ol.isUndefined(c))return n(void 0,c)}else return n(void 0,o)}function f(c,o,l){if(l in t)return n(c,o);if(l in e)return n(void 0,c)}let d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:f,headers:(c,o)=>i(Ydf(c),Ydf(o),!0)};return Ol.forEach(Object.keys(Object.assign({},e,t)),function(o){let l=d[o]||i,m=l(e[o],t[o],o);Ol.isUndefined(m)&&l!==f||(r[o]=m)}),r}var uya=e=>{let t=t2t({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:u,auth:f}=t;t.headers=u=vz.from(u),t.url=_kr(hkr(t.baseURL,t.url),e.params,e.paramsSerializer),f&&u.set("Authorization","Basic "+btoa((f.username||"")+":"+(f.password?unescape(encodeURIComponent(f.password)):"")));let d;if(Ol.isFormData(r)){if(_2.hasStandardBrowserEnv||_2.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[c,...o]=d?d.split(";").map(l=>l.trim()).filter(Boolean):[];u.setContentType([c||"multipart/form-data",...o].join("; "))}}if(_2.hasStandardBrowserEnv&&(n&&Ol.isFunction(n)&&(n=n(t)),n||n!==!1&&$df(t.url))){let c=i&&a&&Kdf.read(a);c&&u.set(i,c)}return t};var Xyj=typeof XMLHttpRequest<"u",Xdf=Xyj&&function(e){return new Promise(function(r,n){let i=uya(e),a=i.data,u=vz.from(i.headers).normalize(),{responseType:f,onUploadProgress:d,onDownloadProgress:c}=i,o,l,m,O,j;function A(){O&&O(),j&&j(),i.cancelToken&&i.cancelToken.unsubscribe(o),i.signal&&i.signal.removeEventListener("abort",o)}let T=new XMLHttpRequest;T.open(i.method.toUpperCase(),i.url,!0),T.timeout=i.timeout;function B(){if(!T)return;let C=vz.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),U={data:!f||f==="text"||f==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:C,config:e,request:T};ZRt(function(ge){r(ge),A()},function(ge){n(ge),A()},U),T=null}"onloadend"in T?T.onloadend=B:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(B)},T.onabort=function(){T&&(n(new sy("Request aborted",sy.ECONNABORTED,e,T)),T=null)},T.onerror=function(){n(new sy("Network Error",sy.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let N=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",U=i.transitional||zBn;i.timeoutErrorMessage&&(N=i.timeoutErrorMessage),n(new sy(N,U.clarifyTimeoutError?sy.ETIMEDOUT:sy.ECONNABORTED,e,T)),T=null},a===void 0&&u.setContentType(null),"setRequestHeader"in T&&Ol.forEach(u.toJSON(),function(N,U){T.setRequestHeader(U,N)}),Ol.isUndefined(i.withCredentials)||(T.withCredentials=!!i.withCredentials),f&&f!=="json"&&(T.responseType=i.responseType),c&&([m,j]=NDr(c,!0),T.addEventListener("progress",m)),d&&T.upload&&([l,O]=NDr(d),T.upload.addEventListener("progress",l),T.upload.addEventListener("loadend",O)),(i.cancelToken||i.signal)&&(o=C=>{T&&(n(!C||C.type?new pwe(null,e,T):C),T.abort(),T=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));let F=i_i(i.url);if(F&&_2.protocols.indexOf(F)===-1){n(new sy("Unsupported protocol "+F+":",sy.ERR_BAD_REQUEST,e));return}T.send(a||null)})};var Zyj=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(c){if(!i){i=!0,f();let o=c instanceof Error?c:this.reason;n.abort(o instanceof sy?o:new pwe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new sy(`timeout ${t} of ms exceeded`,sy.ETIMEDOUT))},t),f=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(a):c.removeEventListener("abort",a)}),e=null)};e.forEach(c=>c.addEventListener("abort",a));let{signal:d}=n;return d.unsubscribe=()=>Ol.asap(f),d}},Zdf=Zyj;var kyj=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},evj=async function*(e,t){for await(let r of tvj(e))yield*kyj(r,t)},tvj=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},jlu=(e,t,r,n)=>{let i=evj(e,t),a=0,u,f=d=>{u||(u=!0,n&&n(d))};return new ReadableStream({async pull(d){try{let{done:c,value:o}=await i.next();if(c){f(),d.close();return}let l=o.byteLength;if(r){let m=a+=l;r(m)}d.enqueue(new Uint8Array(o))}catch(c){throw f(c),c}},cancel(d){return f(d),i.return()}},{highWaterMark:2})};var cya=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",epf=cya&&typeof ReadableStream=="function",rvj=cya&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),tpf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},nvj=epf&&tpf(()=>{let e=!1,t=new Request(_2.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),kdf=64*1024,wlu=epf&&tpf(()=>Ol.isReadableStream(new Response("").body)),sya={stream:wlu&&(e=>e.body)};cya&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!sya[t]&&(sya[t]=Ol.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new sy(`Response type '${t}' is not supported`,sy.ERR_NOT_SUPPORT,n)})})})(new Response);var ivj=async e=>{if(e==null)return 0;if(Ol.isBlob(e))return e.size;if(Ol.isSpecCompliantForm(e))return(await new Request(_2.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(Ol.isArrayBufferView(e)||Ol.isArrayBuffer(e))return e.byteLength;if(Ol.isURLSearchParams(e)&&(e=e+""),Ol.isString(e))return(await rvj(e)).byteLength},avj=async(e,t)=>{let r=Ol.toFiniteNumber(e.getContentLength());return r??ivj(t)},rpf=cya&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:a,timeout:u,onDownloadProgress:f,onUploadProgress:d,responseType:c,headers:o,withCredentials:l="same-origin",fetchOptions:m}=uya(e);c=c?(c+"").toLowerCase():"text";let O=Zdf([i,a&&a.toAbortSignal()],u),j,A=O&&O.unsubscribe&&(()=>{O.unsubscribe()}),T;try{if(d&&nvj&&r!=="get"&&r!=="head"&&(T=await avj(o,n))!==0){let U=new Request(t,{method:"POST",body:n,duplex:"half"}),ne;if(Ol.isFormData(n)&&(ne=U.headers.get("content-type"))&&o.setContentType(ne),U.body){let[ge,X]=RBn(T,NDr(LBn(d)));n=jlu(U.body,kdf,ge,X)}}Ol.isString(l)||(l=l?"include":"omit");let B="credentials"in Request.prototype;j=new Request(t,{...m,signal:O,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:n,duplex:"half",credentials:B?l:void 0});let F=await fetch(j),C=wlu&&(c==="stream"||c==="response");if(wlu&&(f||C&&A)){let U={};["status","statusText","headers"].forEach(k=>{U[k]=F[k]});let ne=Ol.toFiniteNumber(F.headers.get("content-length")),[ge,X]=f&&RBn(ne,NDr(LBn(f),!0))||[];F=new Response(jlu(F.body,kdf,ge,()=>{X&&X(),A&&A()}),U)}c=c||"text";let N=await sya[Ol.findKey(sya,c)||"text"](F,e);return!C&&A&&A(),await new Promise((U,ne)=>{ZRt(U,ne,{data:N,headers:vz.from(F.headers),status:F.status,statusText:F.statusText,config:e,request:j})})}catch(B){throw A&&A(),B&&B.name==="TypeError"&&/fetch/i.test(B.message)?Object.assign(new sy("Network Error",sy.ERR_NETWORK,e,j),{cause:B.cause||B}):sy.from(B,B&&B.code,e,j)}});var Dlu={http:Gdf,xhr:Xdf,fetch:rpf};Ol.forEach(Dlu,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var npf=e=>`- ${e}`,ovj=e=>Ol.isFunction(e)||e===null||e===!1,lya={getAdapter:e=>{e=Ol.isArray(e)?e:[e];let{length:t}=e,r,n,i={};for(let a=0;a<t;a++){r=e[a];let u;if(n=r,!ovj(r)&&(n=Dlu[(u=String(r)).toLowerCase()],n===void 0))throw new sy(`Unknown adapter '${u}'`);if(n)break;i[u||"#"+a]=n}if(!n){let a=Object.entries(i).map(([f,d])=>`adapter ${f} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
@@ -1908,7 +1908,7 @@ errors:
1908
1908
  Run ${qc.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
1909
1909
  Run ${qc.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),VBn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function wpu({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!V0f(e))return;let i=t??"",a=e.filter(f=>f.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((f,d)=>f.generatorName.localeCompare(d.generatorName)||f.currentVersion.localeCompare(d.currentVersion));for(let f of u)i+=`
1910
1910
  ${await DDj(f.generatorName)} (${f.apiName!=null?"API: "+f.apiName+", ":""}Group: ${f.generatorGroup}) `+qc.dim(f.currentVersion)+qc.reset(" \u2192 ")+qc.green(f.latestVersion);return i+=`
1911
- `,n?VBn(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function DDj(e){let r=await new U0f.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function SDj({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await H0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let m=yO.getGeneratorNameOrThrow(o.name,l),O=await yO.getLatestGeneratorVersion({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await H0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=yO.getGeneratorNameOrThrow(c.name,o),m=await yO.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});m!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),u}async function H0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await yO.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function J0f(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=bne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function mva({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await SDj({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...J0f(c,d,t.logger));else u.push(...J0f(f.versions,void 0,t.logger))}return u}var H_i=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var yIn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var vIn=e=>e!==null&&typeof e=="object";var J_i=(...e)=>{for(let t of e)if((!vIn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Epu({},...e)},Dpu=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Ova(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Epu(e[r]??[],t[r]??[])}var Spu=(e={},t={})=>({beforeRequest:Ova(e,t,"beforeRequest"),beforeRetry:Ova(e,t,"beforeRetry"),afterResponse:Ova(e,t,"afterResponse"),beforeError:Ova(e,t,"beforeError")}),Epu=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(vIn(i)){for(let[a,u]of Object.entries(i))vIn(u)&&a in t&&(u=Epu(t[a],u)),t={...t,[a]:u};vIn(i.hooks)&&(n=Spu(n,i.hooks),t.hooks=n),vIn(i.headers)&&(r=Dpu(r,i.headers),t.headers=r)}return t};var Q0f=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),G0f=typeof globalThis.AbortController=="function",$0f=typeof globalThis.ReadableStream=="function",K0f=typeof globalThis.FormData=="function",Pva=["get","post","put","patch","head","delete"],EDj=()=>{};EDj();var Y0f={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},jva=2147483647,wva=Symbol("stop"),X0f={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},Z0f={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var ebf=e=>Pva.includes(e)?e.toUpperCase():e,ADj=["get","put","head","delete","options","trace"],MDj=[408,413,429,500,502,503,504],TDj=[413,429,503],k0f={limit:2,methods:ADj,statusCodes:MDj,afterStatusCodes:TDj,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},tbf=(e={})=>{if(typeof e=="number")return{...k0f,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...k0f,...e}};async function Apu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new yIn(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Mpu(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var rbf=(e,t)=>{let r={};for(let n in t)!(n in Z0f)&&!(n in X0f)&&!(n in e)&&(r[n]=t[n]);return r};var Q_i=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>jva)throw new RangeError(`The \`timeout\` option cannot be greater than ${jva}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new H_i(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!$0f)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(Y0f))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Dpu(this._input.headers,r.headers),hooks:Spu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:ebf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:tbf(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(G0f){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(Q0f&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(K0f&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof yIn)throw t;if(t instanceof H_i){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),jva);if(this._retryCount<1)throw r;await Mpu(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===wva)return;return this._retry(t)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=rbf(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Apu(r,t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Tpu=e=>{let t=(r,n)=>Q_i.create(r,J_i(e,n));for(let r of Pva)t[r]=(n,i)=>Q_i.create(n,J_i(e,i,{method:r}));return t.create=r=>Tpu(J_i(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Tpu(J_i(e,r))),t.stop=wva,t},xDj=Tpu(),nbf=xDj;var Sbf=Jo(Dbf(),1);function Ipu(e){let t=(0,Sbf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var fOf=Jo(ggf(),1),dOf=Jo(lOf(),1),p_u=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},__u=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function h_u(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??Ipu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,fOf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await nbf(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new p_u(e):l}if(t.allVersions)return c;let o=new __u(e,r);if(c["dist-tags"][r]){let{time:l}=c;c=c.versions[c["dist-tags"][r]],c.time=l}else if(r){let l=!!c.versions[r];if(n&&!l)for(let[O,j]of Object.entries(c.versions))j.deprecated&&delete c.versions[O];if(!l){let O=Object.keys(c.versions);if(r=dOf.default.maxSatisfying(O,r),!r)throw o}let{time:m}=c;if(c=c.versions[r],c.time=m,!c)throw o}return c}async function ahi(e,t){let{version:r}=await h_u(e.toLowerCase(),t);return r}async function SIn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:ahi(e.packageName,{version:t?"prerelease":"latest"})}var pOf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Qva=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=tA.Info;constructor(t){this.ttyAwareLogger=new gva(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.45.0-rc39"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${qc.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new XAe}failWithoutThrowing(t,r){this.didSucceed=!1,hva({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),await(await CBn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await W0f({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1911
+ `,n?VBn(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function DDj(e){let r=await new U0f.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function SDj({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await H0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let m=yO.getGeneratorNameOrThrow(o.name,l),O=await yO.getLatestGeneratorVersion({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await H0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=yO.getGeneratorNameOrThrow(c.name,o),m=await yO.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});m!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),u}async function H0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await yO.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function J0f(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=bne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function mva({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await SDj({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...J0f(c,d,t.logger));else u.push(...J0f(f.versions,void 0,t.logger))}return u}var H_i=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var yIn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var vIn=e=>e!==null&&typeof e=="object";var J_i=(...e)=>{for(let t of e)if((!vIn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Epu({},...e)},Dpu=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Ova(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Epu(e[r]??[],t[r]??[])}var Spu=(e={},t={})=>({beforeRequest:Ova(e,t,"beforeRequest"),beforeRetry:Ova(e,t,"beforeRetry"),afterResponse:Ova(e,t,"afterResponse"),beforeError:Ova(e,t,"beforeError")}),Epu=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(vIn(i)){for(let[a,u]of Object.entries(i))vIn(u)&&a in t&&(u=Epu(t[a],u)),t={...t,[a]:u};vIn(i.hooks)&&(n=Spu(n,i.hooks),t.hooks=n),vIn(i.headers)&&(r=Dpu(r,i.headers),t.headers=r)}return t};var Q0f=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),G0f=typeof globalThis.AbortController=="function",$0f=typeof globalThis.ReadableStream=="function",K0f=typeof globalThis.FormData=="function",Pva=["get","post","put","patch","head","delete"],EDj=()=>{};EDj();var Y0f={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},jva=2147483647,wva=Symbol("stop"),X0f={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},Z0f={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var ebf=e=>Pva.includes(e)?e.toUpperCase():e,ADj=["get","put","head","delete","options","trace"],MDj=[408,413,429,500,502,503,504],TDj=[413,429,503],k0f={limit:2,methods:ADj,statusCodes:MDj,afterStatusCodes:TDj,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},tbf=(e={})=>{if(typeof e=="number")return{...k0f,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...k0f,...e}};async function Apu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new yIn(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Mpu(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var rbf=(e,t)=>{let r={};for(let n in t)!(n in Z0f)&&!(n in X0f)&&!(n in e)&&(r[n]=t[n]);return r};var Q_i=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>jva)throw new RangeError(`The \`timeout\` option cannot be greater than ${jva}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new H_i(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!$0f)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(Y0f))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Dpu(this._input.headers,r.headers),hooks:Spu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:ebf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:tbf(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(G0f){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(Q0f&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(K0f&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof yIn)throw t;if(t instanceof H_i){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),jva);if(this._retryCount<1)throw r;await Mpu(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===wva)return;return this._retry(t)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=rbf(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Apu(r,t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Tpu=e=>{let t=(r,n)=>Q_i.create(r,J_i(e,n));for(let r of Pva)t[r]=(n,i)=>Q_i.create(n,J_i(e,i,{method:r}));return t.create=r=>Tpu(J_i(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Tpu(J_i(e,r))),t.stop=wva,t},xDj=Tpu(),nbf=xDj;var Sbf=Jo(Dbf(),1);function Ipu(e){let t=(0,Sbf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var fOf=Jo(ggf(),1),dOf=Jo(lOf(),1),p_u=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},__u=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function h_u(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??Ipu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,fOf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await nbf(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new p_u(e):l}if(t.allVersions)return c;let o=new __u(e,r);if(c["dist-tags"][r]){let{time:l}=c;c=c.versions[c["dist-tags"][r]],c.time=l}else if(r){let l=!!c.versions[r];if(n&&!l)for(let[O,j]of Object.entries(c.versions))j.deprecated&&delete c.versions[O];if(!l){let O=Object.keys(c.versions);if(r=dOf.default.maxSatisfying(O,r),!r)throw o}let{time:m}=c;if(c=c.versions[r],c.time=m,!c)throw o}return c}async function ahi(e,t){let{version:r}=await h_u(e.toLowerCase(),t);return r}async function SIn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:ahi(e.packageName,{version:t?"prerelease":"latest"})}var pOf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Qva=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=tA.Info;constructor(t){this.ttyAwareLogger=new gva(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.45.0-rc40"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${qc.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new XAe}failWithoutThrowing(t,r){this.didSucceed=!1,hva({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),await(await CBn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await W0f({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1912
1912
  `)||(r+=`
1913
1913
  `),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=aUo(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new N_i(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw a.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,a),new XAe}finally{n.finish()}return i}async instrumentPostHogEvent(t){(await CBn()).sendEvent(t)}logger=aci(this.log.bind(this));constructTaskInitForWorkspace(t){let r=_Of(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?_Of(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=pOf[this.numTasks++%pOf.length],u=qc.hex(a)(i);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===_7.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logImmediately(t){let r=t.filter(n=>TIr.indexOf(n.level)>=TIr.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===tA.Debug})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await SIn({cliEnvironment:this.environment,includePreReleases:t}),n=bne(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await mva({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}};function _Of(e){return`[${e}]:`}var VPf=Jo(UPf(),1);async function XQ(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...u}={}){let f=i.reduce((o,l)=>({...o,[l]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[o,l]of Object.entries(f))d=d.replaceAll(o,l);e?.debug(`+ ${d}`);let c=(0,VPf.default)(t,r,u);return n||(c.stdout?.pipe(process.stdout),c.stderr?.pipe(process.stderr)),c}function e0a(e,{logger:t,...r}={}){return(n,i)=>XQ(t,e,n,{...r,...i})}var r0a=require("fs/promises"),WPf=Jo(Hte(),1),Pxj="buf.gen.yaml",HPf="output",jxj=`${HPf}/openapi.yaml`,wxj=`
1914
1914
  version: v1
@@ -1921,7 +1921,7 @@ plugins:
1921
1921
  - default_response=false
1922
1922
  `,t0a=class{context;constructor({context:t}){this.context=t}async generate({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,local:n}){return n?this.generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}):this.generateRemote()}async generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}){let n=await this.setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}),i=mC(t,r);return this.doGenerateLocal({cwd:n,target:i})}async setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}){let r=Hp.of((await WPf.default.dir()).path);return await(0,r0a.cp)(t,r,{recursive:!0}),await(0,r0a.writeFile)(Wl(r,ls.of(Pxj)),wxj),r}async doGenerateLocal({cwd:t,target:r}){let n=e0a("which",{cwd:t,logger:this.context.logger});try{await n(["buf"])}catch{this.context.failAndThrow("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').")}try{await n(["protoc-gen-openapi"])}catch{this.context.failAndThrow("Missing required dependency; please install 'protoc-gen-openapi' to continue (e.g. 'brew install go && go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest').")}let i=e0a("buf",{cwd:t,logger:this.context.logger});return await i(["config","init"]),await i(["generate",r]),Wl(t,ls.of(jxj))}async generateRemote(){this.context.failAndThrow("Remote Protobuf generation is unimplemented.")}};async function Jkr({context:e,specs:t,relativePathToDependency:r}){let n=new t0a({context:e}),i=t.filter(f=>f.type==="openapi").map(f=>({...f,relativePathToDependency:r})),a=t.filter(f=>f.type==="protobuf"),u=await Promise.all(a.map(async f=>Dxj({generator:n,protobufSpec:f,relativePathToDependency:r})));return[...i,...u]}async function Dxj({generator:e,protobufSpec:t,relativePathToDependency:r}){return{type:"openapi",absoluteFilepath:await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,local:t.generateLocally}),absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var gyu=Jo(kXr(),1);var V1f=require("fs"),t7n=require("fs/promises");var W1f=require("os"),H1f=Jo(require("path"),1),J1f=require("stream/promises"),Q1f=Jo(cba(),1),G1f=Jo(Hte(),1);var Iw;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_VALIDATION",e.JSONSCHEMA_VALIDATION="JSONSCHEMA_VALIDATION",e.DEPENDENCY_NOT_LISTED="DEPENDENCY_NOT_LISTED",e.FAILED_TO_LOAD_DEPENDENCY="FAILED_TO_LOAD_DEPENDENCY",e.EXPORTING_PACKAGE_MARKER_OTHER_KEYS="EXPORTING_PACKAGE_MARKER_OTHER_KEYS",e.EXPORT_PACKAGE_HAS_DEFINITIONS="EXPORT_PACKAGE_HAS_DEFINITIONS",e.MISCONFIGURED_DIRECTORY="MISCONFIGURED_DIRECTORY"})(Iw||(Iw={}));var t2j=fDr();async function $1f({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:n,cliVersion:i,settings:a,loadAPIWorkspace:u}){let f,d={type:Iw.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},c=t.dependencies[e];return c==null?d={type:Iw.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${s2j(c)}`},async o=>{switch(c.type){case"version":f=await o2j({context:o,dependency:c,cliVersion:i,settings:a,loadAPIWorkspace:u});return;case"local":f=await a2j({context:o,dependency:c,cliVersion:i,settings:a,loadAPIWorkspace:u});return;default:hc(c)}}),f!=null?{didSucceed:!0,definition:f}:{didSucceed:!1,failure:d}}var K1f="dependencies";var r2j="metadata.json",n2j=".fern";function i2j(e){return Wl(Hp.of((0,W1f.homedir)()),ls.of(n2j),ls.of(K1f),ls.of(e.organization),ls.of(e.apiName),ls.of(e.version))}async function a2j({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){if(i==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await i({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let u=await a.workspace.getDefinition({context:t,relativePathToDependency:ls.of(e.path)},n);return t.logger.info("Loaded..."),u}async function o2j({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){let a=i2j(e),u=Wl(a,ls.of(K1f)),f=Wl(a,ls.of(r2j)),d;if(!await _h(u)||!await _h(f)){t.logger.info("Downloading manifest...");let l=await t2j.definitionRegistry.get(gyu.FernFiddle.OrganizationId(e.organization),gyu.FernFiddle.ApiId(e.apiName),e.version);if(!l.ok){l.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:A=>{t.failWithoutThrowing("Failed to download API manifest",A)}});return}let m=l.body.yamlSchemaVersion!=null?parseInt(l.body.yamlSchemaVersion):void 0,O=Ikr(r),j=Ikr(l.body.cliVersion);if(m!=null){if(m>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${l.body.cliVersion}`);return}else if(m<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(O.major!==j.major||O.minor!==j.minor){t.failWithoutThrowing(`CLI version is ${l.body.cliVersion}. Expected ${O.major}.${O.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+l.body.definitionS3DownloadUrl),await(0,t7n.mkdir)(u,{recursive:!0});try{await u2j({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(A){t.failWithoutThrowing("Failed to download API",A);return}d=l.body,await(0,t7n.writeFile)(f,JSON.stringify(d))}else d=JSON.parse((await(0,t7n.readFile)(f)).toString());if(t.logger.info("Parsing..."),i==null){t.failWithoutThrowing("Failed to load API");return}let c=await i({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!c.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",c.failures);return}if(c.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await c.workspace.getDefinition({context:t},n)}async function u2j({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await YN.get(e,{responseType:"stream"}),n=await G1f.default.dir(),i=H1f.default.join(n.path,"api.tgz");await(0,J1f.pipeline)(r.data,(0,V1f.createWriteStream)(i)),await(0,Q1f.extract)({file:i,cwd:t})}function s2j(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:hc(e)}}var sDf=Jo(Pyu(),1);function lba(e,t){for(let[r,n]of X6(e))l2j({relativeFilepath:r,failure:n,logger:t})}function l2j({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Iw.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case Iw.FILE_READ:r.error("Failed to open file: "+e);break;case Iw.FILE_MISSING:r.error("Missing file: "+e);break;case Iw.FILE_PARSE:t.error instanceof pci?r.error($qt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Iw.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of f2j(n))r.error($qt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case Iw.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Iw.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${nQi}: `+t.dependencyName);break;case Iw.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Iw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Iw.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error($qt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));break;default:hc(t)}}function f2j(e){switch(e.code){case Tp.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${qc.underline(e.expected)} but received ${qc.underline(e.received)}`}];case Tp.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${qc.underline(t)}`}));case Tp.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>qc.underline(t)).join(", ")}`}];case Tp.invalid_union:case Tp.invalid_arguments:case Tp.invalid_return_type:case Tp.invalid_date:case Tp.invalid_string:case Tp.too_small:case Tp.too_big:case Tp.invalid_intersection_types:case Tp.not_multiple_of:case Tp.custom:default:return[{title:e.message}]}}var tDf=require("fs/promises");async function rDf(e,t){let r=[];for(let n of await KAe(e,t))r.push(await d2j({relativeFilepath:mC(e,n),absoluteFilepath:n}));return r}async function d2j({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,tDf.readFile)(t)).toString()}}async function nDf(e){let t={},r={};function n(i){try{t[i.relativeFilepath]={defaultUrl:void 0,contents:Fy.load(i.fileContents,{schema:Fy.CORE_SCHEMA}),rawContents:i.fileContents}}catch(a){r[i.relativeFilepath]={type:Iw.FILE_PARSE,error:a}}}return await Promise.all(e.map(n)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function iDf({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:n,settings:i,loadAPIWorkspace:a}){let u={},f={},d={};return await Promise.all(X6(t.packageMarkers).map(async([c,o])=>{if(o.contents.export==null)u[c]=o;else{let{export:l,...m}=o.contents;if(O6t(m)>0)d[c]={type:Iw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:c};else{let O=B0(c);if(_6t(t.namedDefinitionFiles).some(A=>A!==c&&A.startsWith(O)))d[c]={type:Iw.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:O};else{let A=await $1f({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:n,settings:i,loadAPIWorkspace:a});A.didSucceed?f[B0(c)]={definition:A.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[c]=A.failure}}}})),O6t(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:f}}var aDf=Jo(require("path"),1);var jyu={};Dc(jyu,{additionalProperties:()=>h2j,default:()=>v2j,definitions:()=>y2j,properties:()=>_2j,type:()=>p2j});var p2j="object",_2j={docs:{oneOf:[{type:"string"},{type:"null"}]},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]}},h2j=!1,y2j={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.TypeReferenceDeclarationWithName":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceDeclarationWithNameSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDeclarationWithName"}]},"types.ObjectPropertySchema":{$ref:"#/definitions/types.TypeReferenceDeclarationWithNameSchema"},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithContentTypeSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithContentTypeSchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1}},v2j={type:p2j,properties:_2j,additionalProperties:h2j,definitions:y2j};var wyu={};Dc(wyu,{additionalProperties:()=>O2j,default:()=>j2j,definitions:()=>P2j,properties:()=>g2j,required:()=>m2j,type:()=>b2j});var b2j="object",g2j={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},m2j=["name"],O2j=!1,P2j={"environments.SingleBaseUrlEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"}},required:["url"],additionalProperties:!1},"environments.MultipleBaseUrlsEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},urls:{type:"object",additionalProperties:{type:"string"}}},required:["urls"],additionalProperties:!1},"environments.EnvironmentSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/environments.SingleBaseUrlEnvironmentSchema"},{$ref:"#/definitions/environments.MultipleBaseUrlsEnvironmentSchema"}]},"auth.AuthSchemeReferenceSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{type:"string"}},required:["scheme"],additionalProperties:!1},"auth.AnyAuthItem":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"}]},"auth.AnyAuthSchemesSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},any:{type:"array",items:{$ref:"#/definitions/auth.AnyAuthItem"}}},required:["any"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"}]},"auth.OAuthAccessTokenRequestPropertiesSchema":{type:"object",properties:{"client-id":{oneOf:[{type:"string"},{type:"null"}]},"client-secret":{oneOf:[{type:"string"},{type:"null"}]},scopes:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthAccessTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthGetTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthRefreshTokenRequestPropertiesSchema":{type:"object",properties:{"refresh-token":{type:"string"}},required:["refresh-token"],additionalProperties:!1},"auth.OAuthRefreshTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthRefreshTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"oauth"},type:{const:"client-credentials"},scopes:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"client-id-env":{oneOf:[{type:"string"},{type:"null"}]},"client-secret-env":{oneOf:[{type:"string"},{type:"null"}]},"token-prefix":{oneOf:[{type:"string"},{type:"null"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"}]},"versioning.VersionValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionValue":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionValueDetailed"}]},"versioning.VersionDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionDeclarationHeaderObjectSchema"}]},"versioning.VersionDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/versioning.VersionValue"}},header:{$ref:"#/definitions/versioning.VersionDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1}},j2j={type:b2j,properties:g2j,required:m2j,additionalProperties:O2j,definitions:P2j};var Dyu={};Dc(Dyu,{additionalProperties:()=>S2j,default:()=>A2j,definitions:()=>E2j,properties:()=>D2j,type:()=>w2j});var w2j="object",D2j={imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/file.Navigation"},{type:"null"}]},export:{oneOf:[{$ref:"#/definitions/file.Export"},{type:"null"}]}},S2j=!1,E2j={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.TypeReferenceDeclarationWithName":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceDeclarationWithNameSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDeclarationWithName"}]},"types.ObjectPropertySchema":{$ref:"#/definitions/types.TypeReferenceDeclarationWithNameSchema"},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithContentTypeSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithContentTypeSchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1},"file.Navigation":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"file.ExportDetailed":{type:"object",properties:{dependency:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]}},required:["dependency"],additionalProperties:!1},"file.Export":{anyOf:[{type:"string"},{$ref:"#/definitions/file.ExportDetailed"}]}},A2j={type:w2j,properties:D2j,additionalProperties:S2j,definitions:E2j};function oDf({files:e,absolutePathToDefinition:t}){let r,n={},i={},a={};for(let[u,f]of X6(e)){let d=f.contents,c=o=>{a[u]={type:Iw.JSONSCHEMA_VALIDATION,error:o}};if(u===eF){let o=Csi(d,wyu);if(o.success){let l=Hre.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:f.rawContents}}else c(o)}else if(aDf.default.basename(u)===mD){let o=Csi(d,Dyu);if(o.success){let l=Hre.serialization.PackageMarkerFileSchema.parseOrThrow(d);i[u]={defaultUrl:typeof l.export=="object"?l.export.url:void 0,contents:l,rawContents:f.rawContents}}else c(o)}else{let o=Csi(d,jyu);if(o.success){let l=Hre.serialization.DefinitionFileSchema.parseOrThrow(d);n[u]={defaultUrl:void 0,contents:l,rawContents:f.rawContents,absoluteFilePath:Wl(t,u)}}else c(o)}}return r==null?{didSucceed:!1,failures:{[ls.of(eF)]:{type:Iw.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:n,rootApiFile:r,packageMarkers:i}}var d2t=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;type="api";constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};var p2t=class extends d2t{definition;sources;constructor({definition:t,sources:r,...n}){super(n),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};function R6r(e,t={}){return{...Object.fromEntries(X6(e.namedDefinitionFiles).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...X6(e.importedDefinitions).reduce((r,[n,i])=>({...r,...nsi(R6r(i.definition,{defaultURL:i.url}),(a,u)=>Wl(n,ls.of(u)))}),{})}}function Chi(e,t={}){return{...Object.fromEntries(X6(e.packageMarkers).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...X6(e.importedDefinitions).reduce((r,[n,i])=>({...r,...nsi(Chi(i.definition,{defaultURL:i.url}),(a,u)=>Wl(n,ls.of(u)))}),{})}}function iSr(e){return{...Chi(e),...R6r(e)}}function jne(e,t){return iSr(e.definition)[t]?.contents}var uDf=Jo(require("path"),1);async function D3(e,t){for(let[r,n]of X6(iSr(e.definition)))await t(r,n.contents,{isPackageMarker:uDf.default.basename(r)===mD,defaultUrl:n.defaultUrl})}async function ien(e,t){for(let[r,n]of X6(Chi(e.definition)))await t(r,n.contents)}var i7n=class extends d2t{context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...n}){super(n),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let n=(0,sDf.default)(r??{}),i=this.fernWorkspaces[n];if(i==null){let a=t||this.context,u=Wl(this.absoluteFilePath,ls.of(v9)),f=await iGi.loadDependenciesConfiguration({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await rDf(u,"{yml,yaml}"),c=await nDf(d);if(!c.didSucceed)return lba(c.failures,a.logger),a.failAndThrow();let o=oDf({files:c.files,absolutePathToDefinition:u});if(!o.didSucceed)return lba(o.failures,a.logger),a.failAndThrow();let l=await iDf({dependenciesConfiguration:f,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return lba(l.failures,a.logger),a.failAndThrow();i=new p2t({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:f,workspaceName:this.workspaceName,definition:{absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions},cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[n]=i}return i}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var aSr={openapi:e=>({...e,type:"openapi",_visit:function(t){return aSr._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return aSr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"openapi":return t.openapi(e);case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var a7n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return a7n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var $9={basic:e=>({...e,type:"basic",_visit:function(t){return $9._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return $9._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return $9._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return $9._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return $9._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var OP={primitive:e=>({value:e,type:"primitive",_visit:function(t){return OP._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return OP._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return OP._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return OP._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return OP._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return OP._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return OP._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return OP._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var Uy={int:e=>({value:e,type:"int",_visit:function(t){return Uy._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return Uy._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return Uy._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return Uy._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return Uy._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return Uy._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Uy._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return Uy._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return Uy._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return Uy._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return Uy._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var o7n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return o7n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return o7n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var L6r={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return L6r._visit(this,t)}}),undisciminated:e=>({value:e,type:"undisciminated",_visit:function(t){return L6r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undisciminated":return t.undisciminated(e.value);default:return t._other(e)}}};var pW={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case pW.GenerallyAvailable:return t.generallyAvailable();case pW.Beta:return t.beta();case pW.Deprecated:return t.deprecated();default:return t._other()}}};var oSr={cursor:e=>({...e,type:"cursor",_visit:function(t){return oSr._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return oSr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);default:return t._other(e)}}};var uSr={language:e=>({...e,type:"language",_visit:function(t){return uSr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return uSr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var _W={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",_visit:(e,t)=>{switch(e){case _W.Curl:return t.curl();case _W.Python:return t.python();case _W.Javascript:return t.javascript();case _W.Typescript:return t.typescript();case _W.Go:return t.go();case _W.Ruby:return t.ruby();case _W.Csharp:return t.csharp();case _W.Java:return t.java();case _W.Js:return t.js();case _W.Node:return t.node();case _W.Ts:return t.ts();case _W.Nodets:return t.nodets();case _W.Golang:return t.golang();case _W.Dotnet:return t.dotnet();case _W.Jvm:return t.jvm();default:return t._other()}}};var _2t={unknown:e=>({value:e,type:"unknown",_visit:function(t){return _2t._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return _2t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"unknown":return t.unknown(e.value);case"full":return t.full(e);default:return t._other(e)}}};var h2t={withStreaming:e=>({value:e,type:"withStreaming",_visit:function(t){return h2t._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return h2t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e.value);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var tG={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case tG.Get:return t.get();case tG.Post:return t.post();case tG.Put:return t.put();case tG.Patch:return t.patch();case tG.Delete:return t.delete();case tG.Head:return t.head();case tG.Options:return t.options();case tG.Trace:return t.trace();default:return t._other()}}};var U6r={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return U6r._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return U6r._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return U6r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var Oxe={file:e=>({...e,type:"file",_visit:function(t){return Oxe._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return Oxe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e.value);default:return t._other(e)}}};var wne={file:e=>({...e,type:"file",_visit:function(t){return wne._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return wne._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return wne._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return wne._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return wne._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return wne._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var J0={primitive:e=>({...e,type:"primitive",_visit:function(t){return J0._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return J0._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return J0._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return J0._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return J0._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return J0._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return J0._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return J0._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return J0._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return J0._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return J0._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var q1={int:e=>({...e,type:"int",_visit:function(t){return q1._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return q1._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return q1._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return q1._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return q1._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return q1._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return q1._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return q1._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return q1._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return q1._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return q1._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var _I={boolean:e=>({value:e,type:"boolean",_visit:function(t){return _I._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return _I._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var sSr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return sSr._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return sSr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var Dwe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return Dwe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return Dwe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Dwe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var hI={file:e=>({...e,type:"file",_visit:function(t){return hI._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return hI._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return hI._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return hI._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return hI._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return hI._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Op={primitive:e=>({...e,type:"primitive",_visit:function(t){return Op._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Op._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Op._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Op._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Op._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Op._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Op._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Op._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Op._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Op._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Op._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var wX={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return wX._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return wX._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var ty={int:e=>({...e,type:"int",_visit:function(t){return ty._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return ty._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return ty._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return ty._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return ty._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return ty._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return ty._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return ty._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return ty._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return ty._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return ty._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var Kb={};Dc(Kb,{AllOfPropertyConflict:()=>A7n,ArraySchema:()=>Oga,ArraySchemaWithExample:()=>Kga,Availability:()=>mba,Base64WithExample:()=>Hga,BasicSecurityScheme:()=>jba,BearerSecurityScheme:()=>wba,BooleanSchema:()=>hga,BooleanWithExample:()=>Jga,CasingOverrides:()=>Eba,CommonProperty:()=>Mga,CommonPropertyWithExample:()=>ima,CursorPagination:()=>rga,CustomCodeSample:()=>ega,CustomCodeSampleLanguage:()=>Xba,CustomCodeSampleSdk:()=>kba,DateWithExample:()=>Wga,DatetimeWithExample:()=>Vga,DiscriminatedOneOfSchema:()=>Ega,DiscriminatedOneOfSchemaWithExample:()=>rma,DoubleSchema:()=>pga,DoubleWithExample:()=>Lga,Encoding:()=>gba,Endpoint:()=>iga,EndpointExample:()=>j7n,EndpointResponseExample:()=>Yba,EndpointSdkName:()=>_8t,EndpointWithExample:()=>NDf,EnumSchema:()=>f7n,EnumSchemaWithExample:()=>Gga,EnumValue:()=>H6r,ErrorExample:()=>Qba,FernExample:()=>$ba,FileResponse:()=>g7n,FileSchema:()=>Lba,FloatWithExample:()=>Rga,FullEndpointExample:()=>tga,FullExample:()=>$q,FullObjectExample:()=>Iba,FullOneOfExample:()=>Nba,GlobalHeader:()=>vga,Header:()=>G6r,HeaderExample:()=>P7n,HeaderSecurityScheme:()=>Dba,HeaderWithExample:()=>X6r,HttpEndpointServer:()=>m7n,HttpError:()=>Gba,HttpErrorWithExample:()=>Bga,HttpMethod:()=>_7n,IdempotencyHeader:()=>bga,Int64WithExample:()=>zga,IntSchema:()=>fga,IntWithExample:()=>Iga,JsonRequest:()=>Wba,JsonRequestWithExample:()=>xga,JsonResponse:()=>$6r,JsonResponseWithExample:()=>Nhi,KeyValuePair:()=>zba,LiteralExample:()=>Bba,LiteralSchema:()=>E7n,LiteralSchemaValue:()=>gga,LongSchema:()=>dga,MapSchema:()=>Pga,MapSchemaWithExample:()=>Yga,MultipartRequest:()=>b7n,MultipartRequestProperty:()=>Vba,MultipartSchema:()=>Uba,NamedFullExample:()=>y8t,Namespace:()=>Aba,NamespaceId:()=>Cba,NullableSchema:()=>wga,NullableSchemaWithExample:()=>Zga,OauthSecurityScheme:()=>Tba,ObjectProperty:()=>Sga,ObjectPropertyConflictInfo:()=>M7n,ObjectPropertyWithExample:()=>tma,ObjectSchema:()=>mga,ObjectSchemaWithExample:()=>kga,OctetStreamRequest:()=>v7n,OffsetPagination:()=>nga,OneOfSchema:()=>Dga,OneOfSchemaWithExample:()=>ema,OpenApiIntermediateRepresentation:()=>IDf,OpenApiSource:()=>hba,OptionalSchema:()=>jga,OptionalSchemaWithExample:()=>Xga,Pagination:()=>w7n,PathParameter:()=>h7n,PathParameterExample:()=>Kba,PathParameterWithExample:()=>Tga,PrimitiveExample:()=>p7n,PrimitiveSchema:()=>Y6r,PrimitiveSchemaValue:()=>yga,PrimitiveSchemaValueWithExample:()=>Qga,PrimitiveSchemaWithExample:()=>x7n,PropertyKey:()=>d7n,ProtobufEncoding:()=>bba,ProtobufSource:()=>yba,QueryParameter:()=>y7n,QueryParameterExample:()=>O7n,QueryParameterWithExample:()=>T7n,QuerySecurityScheme:()=>Sba,ReferencedSchema:()=>h8t,Request:()=>Hba,RequestWithExample:()=>qga,Response:()=>Jba,ResponseWithExample:()=>Cga,Schema:()=>fj,SchemaId:()=>DX,SchemaWithExample:()=>VT,Schemas:()=>lga,SdkGroup:()=>Mba,SdkGroupInfo:()=>Fba,SdkGroupName:()=>J6r,SecurityScheme:()=>xba,SecuritySchemeId:()=>Pba,Server:()=>qba,Source:()=>vba,StatusCode:()=>Q6r,StringSchema:()=>_ga,StringSchemaWithExample:()=>Uga,SupportedSdkLanguage:()=>Zba,Tag:()=>Oba,TagId:()=>SX,Tags:()=>Rba,TextResponse:()=>K6r,Uint64WithExample:()=>Fga,UintWithExample:()=>Nga,UnDiscriminatedOneOfSchema:()=>Aga,UnDiscriminatedOneOfSchemaWithExample:()=>nma,UnknownSchemaWithExample:()=>$ga,Webhook:()=>aga,WebhookExampleCall:()=>S7n,WebhookHttpMethod:()=>D7n,WebhookWithExample:()=>FDf,WebsocketChannel:()=>cga,WebsocketHandshake:()=>oga,WebsocketHandshakeWithExample:()=>zDf,WebsocketMessageExample:()=>uga,WebsocketSessionExample:()=>sga,WithAvailability:()=>Uv,WithDescription:()=>kp,WithEncoding:()=>Dne,WithName:()=>Am,WithNamespace:()=>p8t,WithSdkGroupName:()=>lj,WithSource:()=>z0,WithTitle:()=>cj,commons:()=>Tyu,example:()=>xyu,finalIr:()=>qyu,parseIr:()=>Cyu});var Tyu={};Dc(Tyu,{BasicSecurityScheme:()=>jba,BearerSecurityScheme:()=>wba,Encoding:()=>gba,HeaderSecurityScheme:()=>Dba,Namespace:()=>Aba,NamespaceId:()=>Cba,OauthSecurityScheme:()=>Tba,OpenApiSource:()=>hba,ProtobufEncoding:()=>bba,ProtobufSource:()=>yba,QuerySecurityScheme:()=>Sba,SchemaId:()=>DX,SdkGroup:()=>Mba,SdkGroupName:()=>J6r,SecurityScheme:()=>xba,SecuritySchemeId:()=>Pba,Server:()=>qba,Source:()=>vba,StatusCode:()=>Q6r,Tag:()=>Oba,TagId:()=>SX,WithAvailability:()=>Uv,WithDescription:()=>kp,WithEncoding:()=>Dne,WithName:()=>Am,WithNamespace:()=>p8t,WithSdkGroupName:()=>lj,WithSource:()=>z0,WithTitle:()=>cj});var jn={};Dc(jn,{JsonError:()=>u7n,ParseError:()=>s7n,any:()=>PDf,boolean:()=>jDf,booleanLiteral:()=>ODf,date:()=>lDf,discriminant:()=>qDf,enum_:()=>dba,getObjectLikeUtils:()=>d8t,getObjectUtils:()=>l7n,getSchemaUtils:()=>h2,isProperty:()=>W6r,lazy:()=>fDf,lazyObject:()=>bDf,list:()=>_ba,number:()=>wDf,object:()=>pba,objectWithoutOptionalProperties:()=>vDf,optional:()=>Syu,property:()=>pDf,record:()=>ADf,set:()=>MDf,string:()=>DDf,stringLiteral:()=>mDf,transform:()=>Eyu,undiscriminatedUnion:()=>xDf,union:()=>BDf,unknown:()=>SDf,withParsedProperties:()=>Myu});var DS={DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function Gq(e,t){return`Expected ${t}. Received ${M2j(e)}.`}function M2j(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function rG(e){return{...e,json:cDf(e.json),parse:cDf(e.parse)}}function cDf(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1923
1923
  `)),{ok:!0,value:t}):n}}function fba(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var u7n=class e extends Error{errors;constructor(t){super(t.map(fba).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var s7n=class e extends Error{errors;constructor(t){super(t.map(fba).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function h2(e){return{optional:()=>Syu(e),transform:t=>Eyu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new s7n(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new u7n(n.errors)}}}function Syu(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>DS.OPTIONAL};return{...t,...h2(t)}}function Eyu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...h2(r)}}var T2j=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function lDf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Gq(t,"string")}]}:T2j.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:Gq(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:Gq(t,"Date object")}]},getType:()=>DS.DATE};return{...rG(e),...h2(e)}}function nG(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...rG(r),...h2(r)}}}function dba(e){let t=new Set(e);return nG(DS.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:Gq(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:Gq(n,"enum")}]}:{ok:!0,value:n})()}function fDf(e){let t=Ayu(e);return{...t,...h2(t)}}function Ayu(e){return{parse:(t,r)=>c7n(e).parse(t,r),json:(t,r)=>c7n(e).json(t,r),getType:()=>c7n(e).getType()}}function c7n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Bhi(e){return Object.entries(e)}function Ihi(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function V6r(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function zhi(e){return Object.keys(e)}function dDf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function d8t(e){return{withParsedProperties:t=>Myu(e,t)}}function Myu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!V6r(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Gq(n,"object")}]};let a=new Set(Object.keys(t)),u=Ihi(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...h2(r),...d8t(r)}}function pDf(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function W6r(e){return e.isProperty}function pba(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>W6r(n)?n.rawKey:r),_getParsedProperties:()=>zhi(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of Bhi(e)){let d=W6r(f)?f.rawKey:u,c=W6r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,yDf(c)&&a.push(d)}return _Df({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of Bhi(e)){let f=W6r(u)?u.valueSchema:u;yDf(f)&&i.push(a)}return _Df({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return W6r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>DS.OBJECT};return{...rG(t),...h2(t),...d8t(t),...l7n(t)}}function _Df({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!V6r(e))return{ok:!1,errors:[{path:a,message:Gq(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let m=l.transform(o);m.ok?d[l.transformedKey]=m.value:(d[c]=o,f.push(...m.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function l7n(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>hDf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>hDf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>DS.OBJECT};return{...r,...h2(r),...d8t(r),...l7n(r)}}}}function hDf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=dDf(zhi(t),c=>i.has(c)),f=r(Ihi(t,u)),d=n(Ihi(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function yDf(e){return!x2j(e)}function x2j(e){switch(e.getType()){case DS.ANY:case DS.UNKNOWN:case DS.OPTIONAL:return!0;default:return!1}}function vDf(e){return pba(e)}function bDf(e){let t={...Ayu(e),_getRawProperties:()=>c7n(e)._getRawProperties(),_getParsedProperties:()=>c7n(e)._getParsedProperties()};return{...t,...h2(t),...d8t(t),...l7n(t)}}function _ba(e){let t={parse:(r,n)=>gDf(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>gDf(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>DS.LIST};return{...rG(t),...h2(t)}}function gDf(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:Gq(e,"list"),path:[]}]}}function mDf(e){return nG(DS.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Gq(r,`"${e}"`)}]})()}function ODf(e){return nG(DS.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Gq(r,`${e.toString()}`)}]})()}var PDf=nG(DS.ANY,e=>({ok:!0,value:e}));var jDf=nG(DS.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Gq(e,"boolean")}]});var wDf=nG(DS.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Gq(e,"number")}]});var DDf=nG(DS.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Gq(e,"string")}]});var SDf=nG(DS.UNKNOWN,e=>({ok:!0,value:e}));function ADf(e,t){let r={parse:(n,i)=>EDf({value:n,isKeyNumeric:e.getType()===DS.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>EDf({value:n,isKeyNumeric:e.getType()===DS.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>DS.RECORD};return{...rG(r),...h2(r)}}function EDf({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return V6r(e)?Bhi(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),o.ok||m.push(...o.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:Gq(e,"object")}]}}function MDf(e){let t=_ba(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Gq(n,"Set")}]},getType:()=>DS.SET};return{...rG(r),...h2(r)}}function xDf(e){let t={parse:(r,n)=>TDf((i,a)=>i.parse(r,a),e,n),json:(r,n)=>TDf((i,a)=>i.json(r,a),e,n),getType:()=>DS.UNDISCRIMINATED_UNION};return{...rG(t),...h2(t)}}function TDf(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function qDf(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function BDf(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=dba(zhi(t)),a={parse:(u,f)=>CDf({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),json:(u,f)=>CDf({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),getType:()=>DS.UNION};return{...rG(a),...h2(a),...d8t(a)}}function CDf({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!V6r(e))return{ok:!1,errors:[{path:f,message:Gq(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let m=u(c,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var cj=jn.objectWithoutOptionalProperties({title:jn.string().optional()});var hba=jn.objectWithoutOptionalProperties({file:jn.string()});var yba=jn.objectWithoutOptionalProperties({file:jn.string()});var vba=jn.union("type",{openapi:hba,protobuf:yba}).transform({transform:e=>{switch(e.type){case"openapi":return aSr.openapi(e);case"protobuf":return aSr.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var z0=jn.objectWithoutOptionalProperties({source:vba.optional()});var bba=jn.objectWithoutOptionalProperties({typeName:jn.string()});var gba=jn.union("type",{protobuf:bba}).transform({transform:e=>{switch(e.type){case"protobuf":return a7n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Dne=jn.objectWithoutOptionalProperties({encoding:gba.optional()});var kp=jn.objectWithoutOptionalProperties({description:jn.string().optional()});var mba=jn.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Uv=jn.objectWithoutOptionalProperties({availability:mba.optional()});var Am=jn.objectWithoutOptionalProperties({nameOverride:jn.string().optional(),generatedName:jn.string()});var DX=jn.string();var SX=jn.string();var Oba=jn.objectWithoutOptionalProperties({id:SX}).extend(kp);var Pba=jn.string();var jba=jn.objectWithoutOptionalProperties({usernameVariableName:jn.string().optional(),usernameEnvVar:jn.string().optional(),passwordVariableName:jn.string().optional(),passwordEnvVar:jn.string().optional()});var wba=jn.objectWithoutOptionalProperties({tokenVariableName:jn.string().optional(),tokenEnvVar:jn.string().optional()});var Dba=jn.objectWithoutOptionalProperties({headerName:jn.string(),prefix:jn.string().optional(),headerVariableName:jn.string().optional(),headerEnvVar:jn.string().optional()});var Sba=jn.objectWithoutOptionalProperties({queryParameterName:jn.string()});var Eba=jn.objectWithoutOptionalProperties({snake:jn.string().optional(),camel:jn.string().optional(),screamingSnake:jn.string().optional(),pascal:jn.string().optional()});var H6r=jn.objectWithoutOptionalProperties({nameOverride:jn.string().optional(),generatedName:jn.string(),value:jn.string(),casing:Eba.optional()}).extend(kp).extend(Uv);var Aba=jn.objectWithoutOptionalProperties({type:jn.stringLiteral("namespace"),name:jn.string()});var Mba=jn.undiscriminatedUnion([jn.string(),Aba]);var J6r=jn.list(Mba);var lj=jn.objectWithoutOptionalProperties({groupName:J6r.optional()});var f7n=jn.objectWithoutOptionalProperties({default:H6r.optional(),values:jn.list(H6r)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var Tba=jn.objectWithoutOptionalProperties({scopesEnum:f7n.optional()});var xba=jn.union("type",{basic:jba,bearer:wba,header:Dba,query:Sba,oauth:Tba}).transform({transform:e=>{switch(e.type){case"basic":return $9.basic(e);case"bearer":return $9.bearer(e);case"header":return $9.header(e);case"query":return $9.query(e);case"oauth":return $9.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var Q6r=jn.number();var qba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),url:jn.string(),audiences:jn.list(jn.string()).optional()}).extend(kp);var Cba=jn.string();var p8t=jn.objectWithoutOptionalProperties({namespace:jn.string().optional()});var xyu={};Dc(xyu,{FullExample:()=>$q,FullObjectExample:()=>Iba,FullOneOfExample:()=>Nba,KeyValuePair:()=>zba,LiteralExample:()=>Bba,PrimitiveExample:()=>p7n,PropertyKey:()=>d7n});var d7n=jn.string();var p7n=jn.union("type",{int:jn.object({value:jn.number()}),int64:jn.object({value:jn.number()}),uint:jn.object({value:jn.number()}),uint64:jn.object({value:jn.number()}),float:jn.object({value:jn.number()}),double:jn.object({value:jn.number()}),string:jn.object({value:jn.string()}),datetime:jn.object({value:jn.string()}),date:jn.object({value:jn.string()}),base64:jn.object({value:jn.string()}),boolean:jn.object({value:jn.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Uy.int(e.value);case"int64":return Uy.int64(e.value);case"uint":return Uy.uint(e.value);case"uint64":return Uy.uint64(e.value);case"float":return Uy.float(e.value);case"double":return Uy.double(e.value);case"string":return Uy.string(e.value);case"datetime":return Uy.datetime(e.value);case"date":return Uy.date(e.value);case"base64":return Uy.base64(e.value);case"boolean":return Uy.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Bba=jn.union("type",{boolean:jn.object({value:jn.boolean()}),string:jn.object({value:jn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return o7n.boolean(e.value);case"string":return o7n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var $q=jn.union("type",{primitive:jn.object({value:p7n}),object:jn.lazyObject(()=>Iba),array:jn.object({value:jn.list(jn.lazy(()=>$q))}),map:jn.object({value:jn.list(jn.lazyObject(()=>zba))}),enum:jn.object({value:jn.string()}),literal:jn.object({value:Bba}),oneOf:jn.object({value:jn.lazy(()=>Nba)}),unknown:jn.object({value:jn.lazy(()=>$q)})}).transform({transform:e=>{switch(e.type){case"primitive":return OP.primitive(e.value);case"object":return OP.object(e);case"array":return OP.array(e.value);case"map":return OP.map(e.value);case"enum":return OP.enum(e.value);case"literal":return OP.literal(e.value);case"oneOf":return OP.oneOf(e.value);case"unknown":return OP.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Iba=jn.objectWithoutOptionalProperties({properties:jn.record(d7n,jn.lazy(()=>$q))});var zba=jn.objectWithoutOptionalProperties({key:p7n,value:jn.lazy(()=>$q)});var Nba=jn.union("type",{discriminated:jn.object({value:jn.record(d7n,jn.lazy(()=>$q))}),undisciminated:jn.object({value:jn.lazy(()=>$q)})}).transform({transform:e=>{switch(e.type){case"discriminated":return L6r.discriminated(e.value);case"undisciminated":return L6r.undisciminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var qyu={};Dc(qyu,{AllOfPropertyConflict:()=>A7n,ArraySchema:()=>Oga,Availability:()=>mba,BooleanSchema:()=>hga,CasingOverrides:()=>Eba,CommonProperty:()=>Mga,CursorPagination:()=>rga,CustomCodeSample:()=>ega,CustomCodeSampleLanguage:()=>Xba,CustomCodeSampleSdk:()=>kba,DiscriminatedOneOfSchema:()=>Ega,DoubleSchema:()=>pga,Endpoint:()=>iga,EndpointExample:()=>j7n,EndpointResponseExample:()=>Yba,EndpointSdkName:()=>_8t,EnumSchema:()=>f7n,EnumValue:()=>H6r,ErrorExample:()=>Qba,FernExample:()=>$ba,FileResponse:()=>g7n,FileSchema:()=>Lba,FullEndpointExample:()=>tga,GlobalHeader:()=>vga,Header:()=>G6r,HeaderExample:()=>P7n,HttpEndpointServer:()=>m7n,HttpError:()=>Gba,HttpMethod:()=>_7n,IdempotencyHeader:()=>bga,IntSchema:()=>fga,JsonRequest:()=>Wba,JsonResponse:()=>$6r,LiteralSchema:()=>E7n,LiteralSchemaValue:()=>gga,LongSchema:()=>dga,MapSchema:()=>Pga,MultipartRequest:()=>b7n,MultipartRequestProperty:()=>Vba,MultipartSchema:()=>Uba,NullableSchema:()=>wga,ObjectProperty:()=>Sga,ObjectPropertyConflictInfo:()=>M7n,ObjectSchema:()=>mga,OctetStreamRequest:()=>v7n,OffsetPagination:()=>nga,OneOfSchema:()=>Dga,OpenApiIntermediateRepresentation:()=>IDf,OptionalSchema:()=>jga,Pagination:()=>w7n,PathParameter:()=>h7n,PathParameterExample:()=>Kba,PrimitiveSchema:()=>Y6r,PrimitiveSchemaValue:()=>yga,QueryParameter:()=>y7n,QueryParameterExample:()=>O7n,ReferencedSchema:()=>h8t,Request:()=>Hba,Response:()=>Jba,Schema:()=>fj,Schemas:()=>lga,SdkGroupInfo:()=>Fba,StringSchema:()=>_ga,SupportedSdkLanguage:()=>Zba,Tags:()=>Rba,TextResponse:()=>K6r,UnDiscriminatedOneOfSchema:()=>Aga,Webhook:()=>aga,WebhookExampleCall:()=>S7n,WebhookHttpMethod:()=>D7n,WebsocketChannel:()=>cga,WebsocketHandshake:()=>oga,WebsocketMessageExample:()=>uga,WebsocketSessionExample:()=>sga});var Fba=jn.objectWithoutOptionalProperties({summary:jn.string().optional(),description:jn.string().optional()});var Rba=jn.objectWithoutOptionalProperties({tagsById:jn.record(SX,Oba),orderedTagIds:jn.list(SX).optional()});var _7n=jn.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var h7n=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>fj),variableReference:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var y7n=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>fj),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var G6r=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>fj),env:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var _8t=jn.objectWithoutOptionalProperties({groupName:J6r,methodName:jn.string()});var v7n=jn.objectWithoutOptionalProperties({}).extend(kp).extend(z0);var Lba=jn.objectWithoutOptionalProperties({isOptional:jn.boolean(),isArray:jn.boolean()});var Uba=jn.union("type",{file:Lba,json:jn.object({value:jn.lazy(()=>fj)})}).transform({transform:e=>{switch(e.type){case"file":return Oxe.file(e);case"json":return Oxe.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Vba=jn.objectWithoutOptionalProperties({key:jn.string(),schema:Uba,contentType:jn.string().optional()}).extend(kp);var b7n=jn.objectWithoutOptionalProperties({name:jn.string().optional(),properties:jn.list(Vba)}).extend(kp).extend(z0);var Wba=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>fj),contentType:jn.string().optional(),additionalProperties:jn.boolean()}).extend(kp).extend(z0);var Hba=jn.union("type",{octetStream:v7n,multipart:b7n,json:Wba}).transform({transform:e=>{switch(e.type){case"octetStream":return U6r.octetStream(e);case"multipart":return U6r.multipart(e);case"json":return U6r.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var g7n=jn.objectWithoutOptionalProperties({}).extend(kp).extend(z0);var $6r=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>fj),responseProperty:jn.string().optional()}).extend(kp).extend(z0);var K6r=jn.objectWithoutOptionalProperties({}).extend(kp).extend(z0);var Jba=jn.union("type",{file:g7n,json:$6r,text:K6r,streamingSse:$6r,streamingText:K6r,streamingJson:$6r}).transform({transform:e=>{switch(e.type){case"file":return wne.file(e);case"json":return wne.json(e);case"text":return wne.text(e);case"streamingSse":return wne.streamingSse(e);case"streamingText":return wne.streamingText(e);case"streamingJson":return wne.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Qba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),description:jn.string().optional(),example:jn.lazy(()=>$q)});var Gba=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>fj).optional(),examples:jn.list(Qba).optional()}).extend(kp).extend(Am).extend(z0);var m7n=jn.objectWithoutOptionalProperties({name:jn.string().optional(),url:jn.string().optional(),audiences:jn.list(jn.string()).optional()});var $ba=jn.unknown();var Kba=jn.objectWithoutOptionalProperties({name:jn.string(),parameterNameOverride:jn.string().optional(),value:jn.lazy(()=>$q)});var O7n=jn.objectWithoutOptionalProperties({name:jn.string(),value:jn.lazy(()=>$q)});var P7n=jn.objectWithoutOptionalProperties({name:jn.string(),value:jn.lazy(()=>$q)});var Yba=jn.union("type",{withStreaming:jn.object({value:jn.list(jn.lazy(()=>$q))}),withoutStreaming:jn.object({value:jn.lazy(()=>$q)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return h2t.withStreaming(e.value);case"withoutStreaming":return h2t.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Xba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),language:jn.string(),code:jn.string(),install:jn.string().optional()}).extend(kp);var Zba=jn.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var kba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),sdk:Zba,code:jn.string()}).extend(kp);var ega=jn.union("type",{language:Xba,sdk:kba}).transform({transform:e=>{switch(e.type){case"language":return uSr.language(e);case"sdk":return uSr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var tga=jn.objectWithoutOptionalProperties({name:jn.string().optional(),pathParameters:jn.list(Kba).optional(),queryParameters:jn.list(O7n).optional(),headers:jn.list(P7n).optional(),request:jn.lazy(()=>$q).optional(),response:Yba.optional(),codeSamples:jn.list(ega)}).extend(kp);var j7n=jn.union("type",{unknown:jn.object({value:$ba}),full:tga}).transform({transform:e=>{switch(e.type){case"unknown":return _2t.unknown(e.value);case"full":return _2t.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var rga=jn.objectWithoutOptionalProperties({cursor:jn.string(),nextCursor:jn.property("next_cursor",jn.string()),results:jn.string()});var nga=jn.objectWithoutOptionalProperties({offset:jn.string(),results:jn.string(),step:jn.string().optional(),hasNextPage:jn.string().optional()});var w7n=jn.union("type",{cursor:rga,offset:nga}).transform({transform:e=>{switch(e.type){case"cursor":return oSr.cursor(e);case"offset":return oSr.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var iga=jn.objectWithoutOptionalProperties({authed:jn.boolean(),internal:jn.boolean().optional(),idempotent:jn.boolean().optional(),method:_7n,audiences:jn.list(jn.string()),path:jn.string(),summary:jn.string().optional(),operationId:jn.string().optional(),tags:jn.list(SX),pathParameters:jn.list(h7n),queryParameters:jn.list(y7n),headers:jn.list(G6r),sdkName:_8t.optional(),generatedRequestName:jn.string(),requestNameOverride:jn.string().optional(),request:Hba.optional(),response:Jba.optional(),errors:jn.record(Q6r,Gba),server:jn.list(m7n),examples:jn.list(j7n),pagination:w7n.optional()}).extend(kp).extend(Uv).extend(z0).extend(p8t);var D7n=jn.enum_(["GET","POST"]);var S7n=jn.objectWithoutOptionalProperties({name:jn.string().optional(),payload:jn.lazy(()=>$q)}).extend(kp);var aga=jn.objectWithoutOptionalProperties({sdkName:_8t.optional(),method:D7n,summary:jn.string().optional(),operationId:jn.string(),tags:jn.list(SX),headers:jn.list(G6r),generatedPayloadName:jn.string(),payload:jn.lazy(()=>fj),examples:jn.list(S7n)}).extend(kp).extend(z0).extend(p8t);var oga=jn.objectWithoutOptionalProperties({queryParameters:jn.list(y7n),headers:jn.list(G6r),pathParameters:jn.list(h7n)});var uga=jn.objectWithoutOptionalProperties({messageType:jn.string(),payload:jn.lazy(()=>$q)}).extend(kp);var sga=jn.objectWithoutOptionalProperties({name:jn.string().optional(),queryParameters:jn.list(O7n).optional(),headers:jn.list(P7n).optional(),messages:jn.list(uga)}).extend(kp);var cga=jn.objectWithoutOptionalProperties({path:jn.string(),groupName:J6r,summary:jn.string().optional(),handshake:oga,publish:jn.lazy(()=>fj).optional(),subscribe:jn.lazy(()=>fj).optional(),examples:jn.list(sga)}).extend(kp).extend(z0);var lga=jn.objectWithoutOptionalProperties({rootSchemas:jn.record(DX,jn.lazy(()=>fj)),namespacedSchemas:jn.record(Cba,jn.record(DX,jn.lazy(()=>fj)))});var fga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional()});var dga=jn.objectWithoutOptionalProperties({default:jn.number().optional()});var pga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional()});var _ga=jn.objectWithoutOptionalProperties({default:jn.string().optional(),pattern:jn.string().optional(),format:jn.string().optional(),minLength:jn.number().optional(),maxLength:jn.number().optional()});var hga=jn.objectWithoutOptionalProperties({default:jn.boolean().optional()});var yga=jn.union("type",{int:fga,int64:dga,uint:jn.object({}),uint64:jn.object({}),float:jn.object({}),double:pga,string:_ga,datetime:jn.object({}),date:jn.object({}),base64:jn.object({}),boolean:hga}).transform({transform:e=>{switch(e.type){case"int":return q1.int(e);case"int64":return q1.int64(e);case"uint":return q1.uint();case"uint64":return q1.uint64();case"float":return q1.float();case"double":return q1.double(e);case"string":return q1.string(e);case"datetime":return q1.datetime();case"date":return q1.date();case"base64":return q1.base64();case"boolean":return q1.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var Y6r=jn.objectWithoutOptionalProperties({schema:yga}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var vga=jn.objectWithoutOptionalProperties({header:jn.string(),name:jn.string().optional(),optional:jn.boolean().optional(),env:jn.string().optional(),schema:jn.lazy(()=>fj).optional()});var bga=jn.objectWithoutOptionalProperties({header:jn.string(),name:jn.string().optional(),env:jn.string().optional(),schema:jn.lazy(()=>fj).optional()});var IDf=jn.objectWithoutOptionalProperties({apiVersion:jn.unknown().optional(),title:jn.string().optional(),description:jn.string().optional(),basePath:jn.string().optional(),servers:jn.list(qba),groups:jn.record(jn.string(),Fba),tags:Rba,hasEndpointsMarkedInternal:jn.boolean(),endpoints:jn.list(iga),webhooks:jn.list(aga),channel:jn.list(cga),groupedSchemas:lga,variables:jn.record(jn.string(),Y6r),nonRequestReferencedSchemas:jn.set(DX),securitySchemes:jn.record(Pba,xba),globalHeaders:jn.list(vga).optional(),idempotencyHeaders:jn.list(bga).optional()});var h8t=jn.objectWithoutOptionalProperties({schema:DX}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var gga=jn.union("type",{boolean:jn.object({value:jn.boolean()}),string:jn.object({value:jn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return _I.boolean(e.value);case"string":return _I.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var E7n=jn.objectWithoutOptionalProperties({value:gga}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var fj=jn.union("type",{primitive:Y6r,object:jn.lazyObject(()=>mga),array:jn.lazyObject(()=>Oga),map:jn.lazyObject(()=>Pga),optional:jn.lazyObject(()=>jga),enum:f7n,reference:h8t,literal:E7n,oneOf:jn.object({value:jn.lazy(()=>Dga)}),nullable:jn.lazyObject(()=>wga),unknown:Am}).transform({transform:e=>{switch(e.type){case"primitive":return J0.primitive(e);case"object":return J0.object(e);case"array":return J0.array(e);case"map":return J0.map(e);case"optional":return J0.optional(e);case"enum":return J0.enum(e);case"reference":return J0.reference(e);case"literal":return J0.literal(e);case"oneOf":return J0.oneOf(e.value);case"nullable":return J0.nullable(e);case"unknown":return J0.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var A7n=jn.objectWithoutOptionalProperties({propertyKey:jn.string(),allOfSchemaIds:jn.list(DX),conflictingTypeSignatures:jn.boolean()});var mga=jn.objectWithoutOptionalProperties({allOf:jn.list(h8t),properties:jn.list(jn.lazyObject(()=>Sga)),allOfPropertyConflicts:jn.list(A7n),additionalProperties:jn.boolean()}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var M7n=jn.objectWithoutOptionalProperties({differentSchema:jn.boolean()});var Sga=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>fj),readonly:jn.boolean().optional(),conflict:jn.record(DX,M7n),generatedName:jn.string(),nameOverride:jn.string().optional(),audiences:jn.list(jn.string())}).extend(Uv);var Oga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var Pga=jn.objectWithoutOptionalProperties({key:Y6r,value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Dne).extend(cj);var jga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var wga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var Dga=jn.union("type",{discriminated:jn.lazyObject(()=>Ega),undisciminated:jn.lazyObject(()=>Aga)}).transform({transform:e=>{switch(e.type){case"discriminated":return sSr.discriminated(e);case"undisciminated":return sSr.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ega=jn.objectWithoutOptionalProperties({discriminantProperty:jn.string(),commonProperties:jn.list(jn.lazyObject(()=>Mga)),schemas:jn.record(jn.string(),jn.lazy(()=>fj))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Dne).extend(z0).extend(cj);var Mga=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>fj)});var Aga=jn.objectWithoutOptionalProperties({schemas:jn.list(jn.lazy(()=>fj))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Dne).extend(z0).extend(cj);var Cyu={};Dc(Cyu,{ArraySchemaWithExample:()=>Kga,Base64WithExample:()=>Hga,BooleanWithExample:()=>Jga,CommonPropertyWithExample:()=>ima,DateWithExample:()=>Wga,DatetimeWithExample:()=>Vga,DiscriminatedOneOfSchemaWithExample:()=>rma,DoubleWithExample:()=>Lga,EndpointWithExample:()=>NDf,EnumSchemaWithExample:()=>Gga,FloatWithExample:()=>Rga,HeaderWithExample:()=>X6r,HttpErrorWithExample:()=>Bga,Int64WithExample:()=>zga,IntWithExample:()=>Iga,JsonRequestWithExample:()=>xga,JsonResponseWithExample:()=>Nhi,MapSchemaWithExample:()=>Yga,NamedFullExample:()=>y8t,NullableSchemaWithExample:()=>Zga,ObjectPropertyWithExample:()=>tma,ObjectSchemaWithExample:()=>kga,OneOfSchemaWithExample:()=>ema,OptionalSchemaWithExample:()=>Xga,PathParameterWithExample:()=>Tga,PrimitiveSchemaValueWithExample:()=>Qga,PrimitiveSchemaWithExample:()=>x7n,QueryParameterWithExample:()=>T7n,RequestWithExample:()=>qga,ResponseWithExample:()=>Cga,SchemaWithExample:()=>VT,StringSchemaWithExample:()=>Uga,Uint64WithExample:()=>Fga,UintWithExample:()=>Nga,UnDiscriminatedOneOfSchemaWithExample:()=>nma,UnknownSchemaWithExample:()=>$ga,WebhookWithExample:()=>FDf,WebsocketHandshakeWithExample:()=>zDf});var y8t=jn.objectWithoutOptionalProperties({name:jn.string().optional(),value:jn.unknown()}).extend(kp);var T7n=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>VT),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var X6r=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>VT),env:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var zDf=jn.objectWithoutOptionalProperties({queryParameters:jn.list(T7n),headers:jn.list(X6r)});var Tga=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>VT),variableReference:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var xga=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>VT),contentType:jn.string().optional(),fullExamples:jn.list(y8t).optional(),additionalProperties:jn.boolean()}).extend(kp).extend(z0);var qga=jn.union("type",{octetStream:v7n,multipart:b7n,json:xga}).transform({transform:e=>{switch(e.type){case"octetStream":return Dwe.octetStream(e);case"multipart":return Dwe.multipart(e);case"json":return Dwe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var Nhi=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>VT),responseProperty:jn.string().optional(),fullExamples:jn.list(y8t).optional()}).extend(kp).extend(z0);var Cga=jn.union("type",{file:g7n,json:Nhi,text:K6r,streamingSse:$6r,streamingText:K6r,streamingJson:Nhi}).transform({transform:e=>{switch(e.type){case"file":return hI.file(e);case"json":return hI.json(e);case"text":return hI.text(e);case"streamingSse":return hI.streamingSse(e);case"streamingText":return hI.streamingText(e);case"streamingJson":return hI.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Bga=jn.objectWithoutOptionalProperties({statusCode:Q6r,schema:jn.lazy(()=>VT),fullExamples:jn.list(y8t).optional()}).extend(kp).extend(Am).extend(z0);var NDf=jn.objectWithoutOptionalProperties({authed:jn.boolean(),internal:jn.boolean().optional(),idempotent:jn.boolean().optional(),method:_7n,audiences:jn.list(jn.string()),path:jn.string(),summary:jn.string().optional(),operationId:jn.string().optional(),tags:jn.list(SX),pathParameters:jn.list(Tga),queryParameters:jn.list(T7n),headers:jn.list(X6r),sdkName:_8t.optional(),generatedRequestName:jn.string(),requestNameOverride:jn.string().optional(),request:qga.optional(),response:Cga.optional(),errors:jn.record(Q6r,Bga),server:jn.list(m7n),examples:jn.list(j7n),pagination:w7n.optional()}).extend(kp).extend(Uv).extend(z0).extend(p8t);var FDf=jn.objectWithoutOptionalProperties({sdkName:_8t.optional(),method:D7n,summary:jn.string().optional(),operationId:jn.string(),tags:jn.list(SX),headers:jn.list(X6r),generatedPayloadName:jn.string(),payload:jn.lazy(()=>VT),examples:jn.list(S7n)}).extend(kp).extend(z0).extend(p8t);var Iga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional(),example:jn.number().optional()});var zga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),example:jn.number().optional()});var Nga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),example:jn.number().optional()});var Fga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),example:jn.number().optional()});var Rga=jn.objectWithoutOptionalProperties({example:jn.number().optional()});var Lga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional(),example:jn.number().optional()});var Uga=jn.objectWithoutOptionalProperties({default:jn.string().optional(),pattern:jn.string().optional(),format:jn.string().optional(),minLength:jn.number().optional(),maxLength:jn.number().optional(),example:jn.string().optional()});var Vga=jn.objectWithoutOptionalProperties({example:jn.string().optional()});var Wga=jn.objectWithoutOptionalProperties({example:jn.string().optional()});var Hga=jn.objectWithoutOptionalProperties({example:jn.string().optional()});var Jga=jn.objectWithoutOptionalProperties({default:jn.boolean().optional(),example:jn.boolean().optional()});var Qga=jn.union("type",{int:Iga,int64:zga,uint:Nga,uint64:Fga,float:Rga,double:Lga,string:Uga,datetime:Vga,date:Wga,base64:Hga,boolean:Jga}).transform({transform:e=>{switch(e.type){case"int":return ty.int(e);case"int64":return ty.int64(e);case"uint":return ty.uint(e);case"uint64":return ty.uint64(e);case"float":return ty.float(e);case"double":return ty.double(e);case"string":return ty.string(e);case"datetime":return ty.datetime(e);case"date":return ty.date(e);case"base64":return ty.base64(e);case"boolean":return ty.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var x7n=jn.objectWithoutOptionalProperties({schema:Qga}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var Gga=jn.objectWithoutOptionalProperties({default:H6r.optional(),values:jn.list(H6r),example:jn.string().optional()}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var $ga=jn.objectWithoutOptionalProperties({example:jn.unknown()}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var VT=jn.union("type",{primitive:x7n,object:jn.lazyObject(()=>kga),array:jn.lazyObject(()=>Kga),map:jn.lazyObject(()=>Yga),optional:jn.lazyObject(()=>Xga),enum:Gga,reference:h8t,literal:E7n,oneOf:jn.object({value:jn.lazy(()=>ema)}),nullable:jn.lazyObject(()=>Zga),unknown:$ga}).transform({transform:e=>{switch(e.type){case"primitive":return Op.primitive(e);case"object":return Op.object(e);case"array":return Op.array(e);case"map":return Op.map(e);case"optional":return Op.optional(e);case"enum":return Op.enum(e);case"reference":return Op.reference(e);case"literal":return Op.literal(e);case"oneOf":return Op.oneOf(e.value);case"nullable":return Op.nullable(e);case"unknown":return Op.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Kga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>VT),example:jn.list(jn.unknown()).optional()}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var Yga=jn.objectWithoutOptionalProperties({key:x7n,value:jn.lazy(()=>VT),example:jn.unknown().optional()}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(Dne).extend(cj);var Xga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>VT)}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var Zga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>VT)}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var kga=jn.objectWithoutOptionalProperties({allOf:jn.list(h8t),properties:jn.list(jn.lazyObject(()=>tma)),allOfPropertyConflicts:jn.list(A7n),fullExamples:jn.list(y8t).optional(),additionalProperties:jn.boolean()}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var tma=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>VT),readonly:jn.boolean().optional(),audiences:jn.list(jn.string()),conflict:jn.record(DX,M7n),nameOverride:jn.string().optional(),generatedName:jn.string()}).extend(Uv);var ema=jn.union("type",{discriminated:jn.lazyObject(()=>rma),undisciminated:jn.lazyObject(()=>nma)}).transform({transform:e=>{switch(e.type){case"discriminated":return wX.discriminated(e);case"undisciminated":return wX.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var rma=jn.objectWithoutOptionalProperties({discriminantProperty:jn.string(),commonProperties:jn.list(jn.lazyObject(()=>ima)),schemas:jn.record(jn.string(),jn.lazy(()=>VT))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Dne).extend(z0).extend(cj);var ima=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>VT)});var nma=jn.objectWithoutOptionalProperties({schemas:jn.list(jn.lazy(()=>VT))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Dne).extend(z0).extend(cj);function ama(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:hc(e.type)}}function q7n(e){switch(e.type){case"object":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"primitive":return e.groupName??void 0;case"oneOf":return e.value.groupName??void 0;case"unknown":return;default:hc(e)}}function gx(e){return typeof e=="string"?e:e.type}function Fhi(e){if(typeof e!="string")return e.docs}function RDf(e){if(typeof e!="string")return e.default}function LDf(e){if(typeof e!="string")return e.validation}function q2j(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function UDf(e){let t=e?q2j(e):void 0;if(t==null||t.length===0)return Bsi;let r=[];for(let[n,i]of t.entries())if(typeof i=="string")r.push(mE(i));else if(typeof i=="object")switch(i.type){case"namespace":{n<t.length-1?r.push(mE(i.name)):r.push(i.name,Bsi);break}default:hc(i.type)}else hc(i);return r.join("/")}function C7n(e){return ls.of(`${UDf(e)}.yml`)}function Byu({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Bsi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,UDf(r))}function VDf({sdkName:e,namespaceOverride:t}){return ls.of(`${Byu({sdkName:e,namespaceOverride:t})}.yml`)}function WDf({location:e,namespaceOverride:t}){return t!=null?Wl(ls.of(t),e):e}function gz(e){switch(e){case pW.Deprecated:return"deprecated";case pW.Beta:return"pre-release";case pW.GenerallyAvailable:return"generally-available";default:return}}var C2j=-2147483648,B2j=2147483647,I2j=-17976931348623157e292,z2j=17976931348623157e292;function qO({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i}){switch(e.type){case"primitive":return oma(e);case"array":return Nyu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"map":return Fyu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"reference":return zyu({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return Lyu();case"optional":case"nullable":return Ryu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"enum":return J2j({schema:e,fileContainingReference:t,context:n,declarationFile:r});case"literal":return e.value,Uyu(e);case"object":return Q2j({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"oneOf":return G2j({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i});default:hc(e)}}function oma(e){switch(e.schema.type){case"string":return R2j({description:e.description,schema:e.schema});case"int":return L2j({description:e.description,schema:e.schema});case"float":return U2j({description:e.description,schema:e.schema});case"double":return V2j({description:e.description,schema:e.schema});case"boolean":return N2j({description:e.description,schema:e.schema});case"int64":return F2j({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function N2j({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function F2j({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function R2j({description:e,schema:t}){let r="string",n=W2j(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function L2j({description:e,schema:t}){let r="integer",n=HDf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function U2j({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function V2j({description:e,schema:t}){let r="double",n=HDf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function W2j(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=H2j(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function H2j(e){switch(e){case"date":case"date-time":case"password":case"byte":case"bytes":case"binary":case"email":case"uuid":case"uri":case"hostname":case"ipv4":case"ipv6":return e;default:return}}function HDf(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=Iyu(r,t),n=Iyu(n,t),i=Iyu(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function Iyu(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[C2j,B2j]:[I2j,z2j];return e<r||e>n?void 0:e}function zyu({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=$2j(i)??e.schema,u=q7n(i),f=K2j(i),d=uma({context:r,fileContainingReference:t,declarationFile:C7n(u),type:a}),c=i.type==="nullable"?`optional<${d}>`:d;return e.description==null&&f==null?c:{type:i.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function Nyu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=qO({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=`list<${gx(a)}>`;return e.description==null&&e.title==null?u:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{},type:u}}function Fyu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=oma(e.key),u=qO({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),f=e.encoding!=null?ama(e.encoding):void 0,d=`map<${gx(a)}, ${gx(u)}>`;if(e.description==null&&f==null&&e.title==null)return d;let c={type:d};return e.description!=null&&(c.docs=e.description),e.encoding!=null&&(c.encoding=f),e.availability!=null&&(c.availability=gz(e.availability)),c}function Ryu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=qO({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=gx(a),f=Fhi(a),d=RDf(a),c=LDf(a),o=u.startsWith("optional<")?u:`optional<${u}>`;if(e.availability==null&&e.description==null&&f==null&&d==null&&c==null&&e.title==null)return o;let l={type:o};return(e.description!=null||f!=null)&&(l.docs=e.description??f),d!=null&&(l.default=d),c!=null&&(l.validation=c),e.availability!=null&&(l.availability=gz(e.availability)),l}function Lyu(){return"unknown"}function Uyu(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:hc(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function J2j({schema:e,fileContainingReference:t,declarationFile:r,context:n}){let i=Rhi(e),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:i.schema});let u=uma({type:a,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return u;let f={type:u};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=gz(e.availability)),f}function Q2j({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Vyu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=uma({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function G2j({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Wyu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=uma({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function uma({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function $2j(e){return J0._visit(e,{primitive:t=>t.nameOverride??t.generatedName,object:t=>t.nameOverride??t.generatedName,array:t=>t.nameOverride??t.generatedName,map:t=>t.nameOverride??t.generatedName,enum:t=>t.nameOverride??t.generatedName,reference:t=>t.nameOverride??t.generatedName,literal:t=>t.nameOverride??t.generatedName,oneOf:t=>t.nameOverride??t.generatedName,optional:t=>t.nameOverride??t.generatedName,nullable:t=>t.nameOverride??t.generatedName,unknown:t=>t.nameOverride??t.generatedName,_other:()=>{}})}function K2j(e){return J0._visit(e,{primitive:t=>t.title,object:t=>t.title,array:t=>t.title,map:t=>t.title,enum:t=>t.title,reference:t=>t.title,literal:t=>t.title,oneOf:t=>t.title,optional:t=>t.title,nullable:t=>t.title,unknown:t=>{},_other:()=>{}})}function cSr(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:hc(e)}}function QDf({schema:e,context:t,declarationFile:r,namespace:n}){switch(e.type){case"primitive":return Z2j(e);case"array":return Y2j({schema:e,context:t,declarationFile:r,namespace:n});case"map":return X2j({schema:e,context:t,declarationFile:r,namespace:n});case"reference":return k2j({schema:e,context:t,declarationFile:r,namespace:n});case"unknown":return tBj(e.nameOverride,e.generatedName);case"optional":case"nullable":return eBj({schema:e,context:t,declarationFile:r,namespace:n});case"enum":return Rhi(e);case"literal":return rBj(e,e.nameOverride,e.generatedName);case"object":return Vyu({schema:e,context:t,declarationFile:r,namespace:n});case"oneOf":return Wyu({schema:e.value,context:t,declarationFile:r,namespace:n});default:hc(e)}}function Vyu({schema:e,context:t,declarationFile:r,namespace:n}){let i=t.isInRequest()&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),a=!1,u={},f=new Set;for(let m of e.properties){if(m.readonly&&(a=!0),i&&m.readonly)continue;if(Object.keys(m.conflict).length>0){if(Object.entries(m.conflict).every(([F,C])=>!C.differentSchema))continue;Object.entries(m.conflict).forEach(([F])=>{Hyu({property:m.key,schemaId:F,context:t,namespace:n}).forEach(N=>{f.add(N)})})}let O=qO({schema:m.schema,context:t,fileContainingReference:r,namespace:n}),j=m.audiences,A=m.nameOverride,T=gz(m.availability);u[m.key]=aBj(O,j,A,T)}let d=new Set;for(let m of e.allOfPropertyConflicts)m.allOfSchemaIds.forEach(O=>f.add(O)),m.conflictingTypeSignatures&&d.add(m.propertyKey);let c=[];for(let m of e.allOf){let O=GDf({schema:m.schema,context:t,namespace:n});if(O==null||f.has(m.schema)||f.has(O))continue;let j=qO({schema:J0.reference(m),context:t,fileContainingReference:r,namespace:n});c.push(gx(j))}for(let m of f){let O=Jyu(t,m,n);for(let j of O.properties)u[j.key]==null&&(d.has(j.key)&&(u[j.key]="unknown"),u[j.key]=qO({schema:j.schema,context:t,fileContainingReference:r,namespace:n}));for(let j of O.allOf){if(f.has(j.schema))continue;let A=qO({schema:J0.reference(j),context:t,fileContainingReference:r,namespace:n});c.push(gx(A))}}let o={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(u).map(([m,O])=>iBj(m)?[m,typeof O=="string"?{type:O,name:`_${m}`}:{...O,name:`_${m}`}]:[m,O]))};c.length>0&&(o.extends=c),e.additionalProperties&&(o["extra-properties"]=!0),e.availability!=null&&(o.availability=gz(e.availability)),e.source!=null&&(o.source=cSr(e.source));let l=e.nameOverride??e.generatedName;return{name:a&&t.respectReadonlySchemas&&!i?`${l}Read`:l,schema:o}}function Hyu({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return Hyu({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=Jyu(r,t,n),f=a.some(c=>c.key===e),d=[...u.flatMap(c=>Hyu({property:e,context:r,schemaId:c.schema,namespace:n}))];if(f||d.length>0)return[t,...d]}return[]}function Jyu(e,t,r){let n=e.getSchema(t,r);if(n==null)return{properties:[],allOf:[]};if(n.type==="object")return{properties:n.properties,allOf:n.allOf};if(n.type==="reference")return Jyu(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function Y2j({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Nyu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function X2j({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Fyu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function Z2j(e){let t=oma(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function JDf(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function Rhi(e){let t={enum:e.values.map(i=>{let a=i.nameOverride??i.generatedName,u=i.value;if(a===u&&i.description==null&&(i.casing==null||JDf(i.casing)))return a;let f={value:i.value};if(a!==u&&(f.name=a),i.description!=null&&(f.docs=i.description),i.casing!=null&&!JDf(i.casing)){let d={},c=!1;i.casing.camel!=null&&(d.camel=i.casing.camel,c=!0),i.casing.screamingSnake!=null&&(d["screaming-snake"]=i.casing.screamingSnake,c=!0),i.casing.snake!=null&&(d.snake=i.casing.snake,c=!0),i.casing.pascal!=null&&(d.pascal=i.casing.pascal,c=!0),c&&(f.casing=d)}return f})};e.description!=null&&(t.docs=e.description),e.default!=null&&(t.default=e.default.value);let r=new Set,n={...t,enum:[],source:e.source!=null?cSr(e.source):void 0};for(let i of t.enum){let a=typeof i=="string"?i:i.name??i.value;r.has(a.toLowerCase())||(n.enum.push(i),r.add(a.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function k2j({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:zyu({schema:e,context:t,fileContainingReference:r,namespace:n})}}function eBj({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Ryu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n})}}function tBj(e,t){return{name:e??t,schema:Lyu()}}function rBj(e,t,r){return{name:t??r,schema:Uyu(e)}}function Wyu({schema:e,context:t,declarationFile:r,namespace:n}){let i=e.encoding!=null?ama(e.encoding):void 0;if(e.type==="discriminated"){let u={};for(let d of e.commonProperties)u[d.key]=qO({schema:d.schema,fileContainingReference:r,context:t,namespace:n});let f={};for(let[d,c]of Object.entries(e.schemas))f[d]=qO({schema:c,context:t,fileContainingReference:r,namespace:n});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":u,docs:e.description??void 0,availability:e.availability!=null?gz(e.availability):void 0,union:f,encoding:i,source:e.source!=null?cSr(e.source):void 0}}}let a=[];for(let u of e.schemas)a.push(qO({schema:u,fileContainingReference:r,context:t,namespace:n}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:a,encoding:i,source:e.source!=null?cSr(e.source):void 0}}}var nBj=/^[0-9]/;function iBj(e){return nBj.test(e)}function GDf({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?GDf({context:t,schema:n.schema,namespace:r}):e}function aBj(e,t,r,n){return t.length===0&&r==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{}}}function $Df(e){let t=e.replace(/^x-|^X-/,"");return mE(t)}var KDf="BasicAuthScheme",sma="BearerAuthScheme";function YDf(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:KDf,schema:i}),t||(e.builder.setAuth(KDf),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:sma,schema:i}),t||(e.builder.setAuth(sma),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??$Df(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:sma,schema:i}),t||(e.builder.setAuth(sma),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(ls.of("__package__.yml"),{name:"OauthScope",schema:Rhi(n.scopesEnum).schema})}}function v8t({header:e,context:t,fileContainingReference:r,namespace:n}){let i=qO({schema:e.schema,context:t,fileContainingReference:r,namespace:n}),a=gx(i),u=e.name.replace(/^x-|^X-/,""),f=e.parameterNameOverride!=null?e.parameterNameOverride:mE(u);if(e.description==null&&e.name===f&&e.env==null&&e.availability==null)return a;let d={type:a};return f!==e.name&&(d.name=f),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=gz(e.availability)),d}function cma({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=qO({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(e.variableReference==null&&e.description==null&&e.availability==null)return gx(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:gx(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=gz(e.availability)),a}var Iju=require("fs/promises");var XDf={naming:"v1"};function B_(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function Lhi(e,t,r,n,i=[]){try{let a=B_(e,t);if(a!=null)return r.parse(a)}catch{let u=g6t(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var lma={of(e){return e}};var wh={SDK_METHOD_NAME:lma.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:lma.of("x-fern-sdk-group-name"),REQUEST_NAME_V1:"x-request-name",REQUEST_NAME_V2:"x-fern-request-name",TYPE_NAME:"x-fern-type-name",BOOLEAN_LITERAL:"x-fern-boolean-literal",SERVER_NAME_V1:"x-name",SERVER_NAME_V2:"x-fern-server-name",BASE_PATH:"x-fern-base-path",GROUPS:lma.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport"};function Kh(e){return e.$ref!=null}function Pxe(e){switch(B_(e,wh.AVAILABILITY)){case"deprecated":return pW.Deprecated;case"beta":return pW.Beta;case"generally-available":return pW.GenerallyAvailable;default:break}if(!Kh(e)&&e.deprecated)return pW.Deprecated}var Swe={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};function aen(e){let t=B_(e,"examples");return t!=null&&Array.isArray(t)?t:[]}function ZDf({schema:e,logger:t}){return B_(e,wh.ENCODING)??void 0}function kDf(e){return B_(e,wh.FERN_ENUM)}function eSf({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let u=B_(n,wh.SDK_GROUP_NAME),f=B_(n,wh.TYPE_DEFINITION);if(f!=null)return Uhi({fernType:f,nameOverride:e,generatedName:t,title:r,description:i,availability:a,groupName:typeof u=="string"?[u]:u})}function Uhi({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u}){return HQ({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.base64({example:void 0})});case"BOOLEAN":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.boolean({default:void 0,example:void 0})});case"DATE":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.date({example:void 0})});case"DATE_TIME":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.datetime({example:void 0})});case"FLOAT":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.float({example:void 0})});case"DOUBLE":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.double({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.uint({default:void 0,example:void 0})});case"INTEGER":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.int({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT_64":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.uint64({default:void 0,example:void 0})});case"LONG":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:hc(f.v1)}},unknown:()=>Op.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,groupName:u}),map:({keyType:f,valueType:d})=>f?.type==="primitive"&&d!=null?Op.map({nameOverride:t,generatedName:r,title:n,key:f,value:d,description:i,availability:a,groupName:u,encoding:void 0,example:void 0}):void 0,list:f=>f!=null?Op.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,optional:f=>f!=null?Op.optional({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u}):void 0,set:f=>f!=null?Op.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,literal:f=>Op.literal({nameOverride:t,generatedName:r,title:n,value:f._visit({string:d=>_I.string(d),boolean:d=>_I.boolean(d),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,groupName:u}),named:()=>{}}})}function oen(e){if(e!=null&&typeof e=="boolean")return e}function tSf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,encoding:l,source:m,namespace:O}){return typeof i=="boolean"||B7n(i)?fma({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Op.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:c,example:o,encoding:l}):fma({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:aP(i,d.options.optionalAdditionalProperties?f:!1,d,[...n,"Value"],m,O),groupName:c,example:o,encoding:l})}function fma({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsNullable:a,description:u,availability:f,groupName:d,example:c,encoding:o}){return a?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.map({nameOverride:e,generatedName:t,title:r,description:u,availability:n.availability,key:n,value:i,groupName:d,encoding:o,example:c}),description:u,availability:f,groupName:d}):Op.map({nameOverride:e,generatedName:t,title:r,description:u,availability:f,key:n,value:i,groupName:d,encoding:o,example:c})}function B7n(e){return e==null?!1:typeof e=="boolean"?e:!Kh(e)&&Object.keys(e).length===0}function rSf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,source:l,namespace:m}){let O=i==null?Op.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:c}):aP(i,!1,d,[...n,"Item"],l,m);return oBj({nameOverride:e,generatedName:t,title:r,groupName:c,itemSchema:O,wrapAsNullable:f,description:a,availability:u,example:o})}function oBj({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsNullable:i,description:a,availability:u,groupName:f,example:d}){return i?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d}),description:a,availability:u,groupName:f}):Op.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d})}function Qyu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminator:c,context:o,groupName:l,encoding:m,source:O,namespace:j}){let A=c.propertyName,T=Object.fromEntries(Object.entries(c.mapping??{}).map(([F,C])=>{let N=I7n({$ref:C},!1,o,[C],m,O,j);return o.markReferencedByDiscriminatedUnion({$ref:C},A,1),[F,N]})),B=Object.entries(i).filter(([F])=>F!==A).map(([F,C])=>{let N=f!=null&&f.includes(F),U=aP(C,!N,o,[...n,F],O,j);return{key:F,schema:U}});return nSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:B,description:a,availability:u,discriminant:A,subtypes:T,groupName:l,source:O})}function Gyu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminant:c,variants:o,context:l,groupName:m,encoding:O,source:j,namespace:A}){let T=Object.fromEntries(Object.entries(o).map(([F,C])=>{if(Kh(C)){let N=I7n(C,!1,l,[C.$ref],O,j,A);return l.markReferencedByDiscriminatedUnion(C,c,1),[F,N]}else{let N=Z6r(C,!1,l,[...n,F],O,j,A,new Set([c]));return[F,N]}})),B=Object.entries(i).filter(([F])=>F!==c).map(([F,C])=>{let N=f!=null&&f.includes(F),U=aP(C,!N,l,[...n,F],j,A);return{key:F,schema:U}});return nSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:B,description:a,availability:u,discriminant:c,subtypes:T,groupName:m,source:j})}function nSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,availability:u,discriminant:f,subtypes:d,groupName:c,source:o}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.oneOf(wX.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o})),groupName:c,description:a,availability:u}):Op.oneOf(wX.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o}))}function iSf(e){if(e.proto!=null)return a7n.protobuf({typeName:e.proto.type})}var uBj=/^(\d+)/;function dma(e){let t=e.match(uBj);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=z7n(i);return n.length>0?`${a}_${n}`:a}}}function z7n(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),f=e%10;return f===0?n[u]:`${n[u]}_${t[f]}`}if(e<1e3){let u=Math.floor(e/100),f=e%100;return f===0?`${t[u]}_hundred`:`${t[u]}_hundred_${z7n(f)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${z7n(a)}`}var N7n=/^[a-zA-Z][a-zA-Z0-9_]*$/;function k6r({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:u,description:f,availability:d,wrapAsNullable:c,groupName:o,context:l,source:m}){let O=lBj(i??[]),j=new Set(a),A=Array.from(j).map((B,F)=>{let C=n?.[B],N=O[F],U=N7n.test(B),ne=C?.name??N,ge=U?B:Vhi(B);return ne!=null&&!N7n.test(ne)&&(l?.logger.warn(`Enum name override ${ne} is not a valid name. Falling back on ${ge}.`),ne=void 0),{nameOverride:ne,generatedName:ge,value:B,description:C?.description,availability:d,casing:{snake:C?.casing?.snake??void 0,pascal:C?.casing?.pascal??void 0,screamingSnake:C?.casing?.screamingSnake??void 0,camel:C?.casing?.camel??void 0}}}),T=u!=null?A.find(B=>B.value===u):void 0;return sBj({wrapAsNullable:c,nameOverride:e,generatedName:t,title:r,values:A,_default:T,description:f,availability:d,groupName:o,source:m})}function sBj({wrapAsNullable:e,nameOverride:t,generatedName:r,title:n,values:i,_default:a,description:u,availability:f,groupName:d,source:c}){return e?Op.nullable({nameOverride:t,generatedName:r,title:n,value:Op.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,default:a,availability:f,example:void 0,groupName:d,source:c}),description:u,availability:f,groupName:d}):Op.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,availability:f,default:a,example:void 0,groupName:d,source:c})}var cBj={"<":"LESS_THAN",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL_TO","<=":"LESS_THAN_OR_EQUAL_TO","!=":"NOT_EQUALS","=":"EQUAL_TO","==":"EQUAL_TO","*":"ALL","":"EMPTY",'""':"EMPTY_STRING","-":"HYPHEN","|":"PIPE",".":"DOT","/":"SLASH"};function Vhi(e){let t=dma(e),r=cBj[e];return t!=null?PV(mE(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":PV(mE(e)))}function lBj(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function aSf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:m,example:O,groupName:j}){return n==="int64"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.int64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint32"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint64"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):K9({nameOverride:e,generatedName:t,title:r,primitive:ty.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j})}function oSf(e){return typeof e=="string"?_I.string(e):typeof e=="boolean"?_I.boolean(e):_I.string(`${e}`)}function uSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,value:i,description:a,availability:u,groupName:f}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.literal({nameOverride:e,generatedName:t,title:r,value:oSf(i),description:a,availability:u,groupName:f}),description:a,availability:u,groupName:f}):Op.literal({nameOverride:e,generatedName:t,title:r,value:oSf(i),description:a,availability:u,groupName:f})}function $yu({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:m,example:O,groupName:j}){return n==null||n==="double"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.double({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="float"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.float({example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="int32"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="int64"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.int64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint32"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint64"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="time-delta"?K9({nameOverride:e,generatedName:t,title:r,primitive:ty.float({example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):K9({nameOverride:e,generatedName:t,title:r,primitive:ty.float({example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j})}var fBj={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},dBj={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="responses",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},pBj={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="parameters",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),e[0]==="schema"&&(e=e.slice(1)),{refUnderProcessing:e,newBreadcrumbs:t}}},_Bj={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},hBj={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},yBj={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},vBj={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},bBj={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function pma(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[fBj,dBj,pBj,_Bj,hBj,yBj,vBj,bBj],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:f}=a.applyStrategy(t);t=u,r=[...r,...f]}}while(t.join("")!==i.join(""));return r}function v8(e){let t=e.join("_"),r=PV(mE(t));return/^\d/.test(r)?dma(r)??r:r}function Kyu(e){let t=e.join("_");return mE(t)}function mx(e){switch(e.type){case"object":return J0.object({allOf:e.allOf,properties:e.properties.map(t=>mBj(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return J0.array({description:e.description,availability:e.availability,value:mx(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"enum":return J0.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,groupName:e.groupName,source:e.source});case"literal":return J0.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"nullable":return J0.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:mx(e.value),groupName:e.groupName});case"optional":return J0.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:mx(e.value),groupName:e.groupName});case"primitive":return J0.primitive({description:e.description,availability:e.availability,schema:sSf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return J0.map({description:e.description,availability:e.availability,key:J0.primitive({description:e.key.description,availability:e.key.availability,schema:sSf(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:mx(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding});case"reference":return J0.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return J0.oneOf(gBj(e.value));case"unknown":return J0.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:hc(e)}}function gBj(e){switch(e.type){case"discriminated":return sSr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:mx(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,mx(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return sSr.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>mx(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:hc(e)}}function sSf(e){switch(e.type){case"string":return q1.string(e);case"base64":return q1.base64();case"boolean":return q1.boolean(e);case"date":return q1.date();case"datetime":return q1.datetime();case"double":return q1.double(e);case"float":return q1.float();case"int":return q1.int(e);case"int64":return q1.int64(e);case"uint":return q1.uint();case"uint64":return q1.uint64();default:hc(e)}}function mBj(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:mx(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function _ma(e,t){return Ewe(mx(e),mx(t))}function Ewe(e,t){return e.type==="primitive"&&t.type==="primitive"?cSf(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?OBj(e.values,t.values):e.type==="array"&&t.type==="array"?Ewe(e.value,t.value):e.type==="unknown"&&t.type==="unknown"?!0:e.type==="reference"&&t.type==="reference"?e.schema===t.schema:e.type==="optional"&&t.type==="optional"?Ewe(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?PBj(e.value,t.value):e.type==="object"&&t.type==="object"?jBj(e,t):e.type==="map"&&t.type==="map"?cSf(e.key.schema,t.key.schema)&&Ewe(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function cSf(e,t){return e.type===t.type}function OBj(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return Iqt(r,n)}function PBj(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:Ewe(n,i)}):e.type==="undisciminated"&&t.type==="undisciminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:Ewe(r,i)}):!1}function jBj(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let a=r[n];return a==null?!1:Ewe(a,i.schema)})}function lSf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:u,wrapAsNullable:f,allOf:d,context:c,propertiesToExclude:o,groupName:l,fullExamples:m,additionalProperties:O,availability:j,encoding:A,source:T,namespace:B}){let F=[...u??[]],C={...i},N=[],U=[];for(let k of d)if(Kh(k)){let xe=c.resolveSchemaReference(k);if(xe.discriminator!=null&&xe.discriminator.mapping!=null)continue;if(xe.oneOf!=null){for(let yt of xe.oneOf){let St=Kh(yt)?c.resolveSchemaReference(yt):yt,Ft=aP(St,!1,c.DUMMY,n,T,B);Ft.type==="object"&&N.push(...Ft.properties.map(Zt=>Zt.schema.type!=="optional"&&Zt.schema.type!=="nullable"?{...Zt,schema:Op.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Zt.schema,description:void 0,availability:Zt.availability,groupName:void 0})}:Zt))}continue}let vt=e3r(k);if(vt==null)continue;U.push({schemaId:vt,convertedSchema:Yyu(k,[vt],T),properties:fSf({schema:k,context:c,breadcrumbs:n,source:T,namespace:B})}),c.markSchemaAsReferencedByNonRequest(vt)}else{let xe=aP(k,!1,c,n,T,B);xe.type==="object"&&N.push(...xe.properties)}let ne={};for(let k of U)for(let[xe,vt]of Object.entries(k.properties)){let yt=ne[xe];yt!=null?(yt.schemaIds.push(k.schemaId),yt.schemas.some(Ft=>_ma(Ft,vt))||yt.schemas.push(vt)):ne[xe]={schemaIds:[k.schemaId],schemas:[vt]}}let ge=[];for(let[k,xe]of Object.entries(ne))xe.schemaIds.length>1&&ge.push({propertyKey:k,allOfSchemaIds:xe.schemaIds,conflictingTypeSignatures:xe.schemas.length>1});let X=Object.entries(C).map(([k,xe])=>{let vt=F.includes(k),yt=B_(xe,wh.AUDIENCES)??[],St=Pxe(xe),Ft=Kh(xe)?!1:xe.readOnly,Zt=B_(xe,wh.FERN_PROPERTY_NAME),Vt=[...n,k],cr=Kyu(Vt),Wr=vt?aP(xe,!1,c,Vt,T,B):Op.optional({nameOverride:e,generatedName:cr,title:r,description:void 0,availability:St,value:aP(xe,!1,c,Vt,T,B),groupName:l}),gn={};for(let Kt of U){let Mr=Kt.properties[k];Mr!=null&&!_ma(Wr,Mr)?gn[Kt.schemaId]={differentSchema:!0}:Mr!=null&&(gn[Kt.schemaId]={differentSchema:!1})}return{key:k,schema:Wr,nameOverride:Zt,audiences:yt,conflict:gn,generatedName:Kyu([...n,k]),availability:St,readonly:Ft}});return X.push(...N.map(k=>{let xe=k.conflict;for(let vt of U){let yt=vt.properties[k.key];yt!=null&&!_ma(k.schema,yt)?xe[vt.schemaId]={differentSchema:!0}:yt!=null&&(xe[vt.schemaId]={differentSchema:!1})}return{...k,conflict:xe}})),wBj({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:X.filter(k=>!o.has(k.key)),description:a,allOf:U.map(k=>k.convertedSchema),allOfPropertyConflicts:ge,groupName:l,fullExamples:m,additionalProperties:O,availability:j,source:T})}function wBj({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:o,availability:l,source:m}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:B7n(o),availability:void 0,source:m}),description:a,availability:l,groupName:d}):Op.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:B7n(o),availability:l,source:m})}function fSf({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,f]=Kh(e)?[t.resolveSchemaReference(e),pma(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...fSf({schema:d,context:t,breadcrumbs:f,source:n,namespace:i})};for(let[d,c]of Object.entries(u.properties??{})){let o=aP(c,!1,t,[...f,d],n,i);a[d]=o}return a}function F7n({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsNullable:u,context:f,subtypes:d,groupName:c,encoding:o,source:l,subtypePrefixOverrides:m,namespace:O}){let j=DBj({schemas:d}),A=d.flatMap((F,C)=>{if(!Kh(F)&&F.enum!=null&&f.options.cooerceEnumsToLiterals)return F.enum.map(U=>Op.literal({nameOverride:void 0,generatedName:v8([t,U]),title:void 0,value:_I.string(U),groupName:void 0,description:void 0,availability:U.availability}));let N=j[C];if(m!=null){let U=m[C];U!=null&&"name"in U&&(N=U.name)}return[aP(F,!1,f,[...n,N??`${C}`],l,O)]}),T=[];for(let F=0;F<A.length;++F){let C=A[F],N=!1;for(let U=F+1;U<A.length;++U){let ne=A[U];if(C!=null&&ne!=null&&Ewe(C,ne)){N=!0;break}}C!=null&&!N&&T.push(C)}if(Object.entries(T).every(([F,C])=>C.type==="literal")){let F={},C=[];return Object.entries(T).forEach(([N,U])=>{U.type==="literal"&&U.value.type==="string"&&(C.push(U.value.value),U.description!=null&&(F[U.value.value]={description:U.description}))}),k6r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,fernEnum:F,enumVarNames:void 0,enumValues:C,_default:void 0,groupName:c,context:f,source:l})}return T.length===1&&T[0]!=null?T[0]:dSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,subtypes:T,groupName:c,encoding:o,source:l})}function Xyu({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsNullable:a,context:u,groupName:f,discriminator:d,encoding:c,source:o,namespace:l}){let m=Object.entries(d.mapping??{}).map(([A,T],B)=>{let F={$ref:T},C=I7n(F,!1,u,[T],c,o,l);return u.markSchemaWithDiscriminantValue(F,d.propertyName,A),C.type==="object"&&(C.properties={[d.propertyName]:Op.literal({nameOverride:void 0,generatedName:v8([t,A]),title:void 0,value:_I.string(A),groupName:void 0,description:void 0,availability:void 0}),...C.properties.filter(N=>N.key!==d.propertyName)}),C}),O=[];for(let A=0;A<m.length;++A){let T=m[A],B=!1;for(let F=A+1;F<m.length;++F){let C=m[F];if(T!=null&&C!=null&&Ewe(T,C)){B=!0;break}}T!=null&&!B&&O.push(T)}if(Object.entries(O).every(([A,T])=>T.type==="literal")){let A={},T=[];return Object.entries(O).forEach(([B,F])=>{F.type==="literal"&&F.value.type==="string"&&(T.push(F.value.value),F.description!=null&&(A[F.value.value]={description:F.description}))}),k6r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,fernEnum:A,enumVarNames:void 0,enumValues:T,_default:void 0,groupName:f,context:u,source:o})}return O.length===1&&O[0]!=null?O[0]:dSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:O,groupName:f,encoding:c,source:o})}function DBj({schemas:e}){let t={},r=0;for(let a of e){if(!Kh(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),f={},d=u;for(let[c,o]of Object.entries(t)){let l=bJi(o,u);d=bJi(d,o),f[c]=l}f[r]=d,t=f}}r++}let n=[],i=0;for(let a of e){let u=t[i];if(u!=null&&u.length>0){let f=u.sort();if(f[0]!=null){n.push(f[0]),++i;continue}}Kh(a)?n.push(z7n(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(z7n(i)??`${i}`),++i}return n}function dSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,description:i,availability:a,subtypes:u,groupName:f,encoding:d,source:c}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.oneOf(wX.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c})),description:i,availability:a,groupName:f}):Op.oneOf(wX.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c}))}function R7n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function hma({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let n=aen(e);for(let i of n??[])if(typeof i=="number")return i;if(r&&typeof r=="number")return r}function pSf({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let n=aen(e);for(let i of n??[])if(typeof i=="boolean")return i;if(r&&typeof r=="boolean")return r}function lSr({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let n=aen(e);for(let i of n??[])if(typeof i=="string")return i;if(r&&typeof r=="string")return r}function _Sf({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let n=aen(e);for(let i of n??[])if(Array.isArray(i))return i;if(r&&Array.isArray(r))return r}var uen="#/components/schemas/";function aP(e,t,r,n,i,a,u=!1,f=new Set,d){let c=qBj({schema:e,logger:r.logger});if(Kh(e)){let o=e3r(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),I7n(e,t,r,n,c,i,a)):Z6r(r.resolveSchemaReference(e),t,r,pma(e.$ref),c,i,a,f,u,d)}return Z6r(e,t,r,n,c,i,a,f,u,d)}function I7n(e,t,r,n,i,a,u){let f=e.$ref.includes("properties")?Z6r(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Op.reference(Yyu(e,n,a));return t?Op.nullable({title:void 0,nameOverride:void 0,generatedName:v8(n),value:f,description:void 0,availability:void 0,groupName:void 0}):f}function SBj(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function Z6r(e,t,r,n,i,a,u,f=new Set,d=!1,c){let o=B_(e,wh.TYPE_NAME)??(r.options.useTitlesAsName?SBj(e.title):void 0),l=B_(e,wh.SDK_GROUP_NAME)??B_(e,Swe.TAGS)?.[0],m=(typeof l=="string"?[l]:l)??[];m=r.resolveGroupName(m);let O=v8(n),j=e.title,A=e.description,T=Pxe(e),B=[];e.example!=null&&B.push({name:void 0,value:e.example,description:void 0});let F=B_(e,Swe.EXAMPLES);F!=null&&Object.keys(F).length>0&&B.push(...Object.entries(F).map(([U,ne])=>({name:ne?.summary??U,value:ne.value,description:ne.description})));let C=aen(e);C!=null&&Object.keys(C).length>0&&B.push(...C.map(U=>({name:void 0,value:U,description:void 0})));let N=eSf({schema:e,description:A,title:j,nameOverride:o,generatedName:O,availability:T});if(N!=null)return N;if(!t&&e.nullable===!0)return Z6r(e,!0,r,n,i,a,u,f,d,c);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!Whi(e.enum))return K9({nameOverride:o,generatedName:O,title:j,primitive:ty.string({default:R7n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:lSr({schema:e,logger:r.logger,fallback:c})}),groupName:m,wrapAsNullable:t,description:A,availability:T});let U=kDf(e);return e.enum.length===1&&e.enum[0]!=null&&U==null?uSf({nameOverride:o,generatedName:O,title:j,wrapAsNullable:t,value:e.enum[0],description:A,availability:T,groupName:m}):k6r({nameOverride:o,generatedName:O,title:j,fernEnum:U,enumVarNames:B_(e,[Swe.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:A,availability:T,wrapAsNullable:t,groupName:m,context:r,source:a})}if(Whi(e.type)&&e.type[1]!=null&&e.type[0]!=null){let U=e.type[0],ne=e.type[1];if(U==="null")return Op.nullable({nameOverride:o,generatedName:O,title:j,value:Z6r({...e,type:ne},t,r,n,i,a,u,f,d,c),groupName:m,description:e.description,availability:T});if(ne==="null")return Op.nullable({nameOverride:o,generatedName:O,title:j,value:Z6r({...e,type:U},t,r,n,i,a,u,f,d,c),groupName:m,description:e.description,availability:T})}if(Whi(e.type)&&e.type.length>1){let U=e.type.includes("null"),ne=e.type.filter(ge=>ge!=="null").map(ge=>({type:ge,nullable:U}));return F7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,wrapAsNullable:t,context:r,subtypes:ne,groupName:m,encoding:i,source:a,namespace:u})}if(e==="boolean"||e.type==="boolean"){let U=B_(e,wh.BOOLEAN_LITERAL);return U!=null?ySf({nameOverride:o,generatedName:O,title:j,literal:_I.boolean(U),wrapAsNullable:t,description:A,availability:T,groupName:m}):K9({nameOverride:o,generatedName:O,title:j,primitive:ty.boolean({default:e.default,example:pSf({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:A,availability:T,groupName:m})}if(e==="number"||e.type==="number")return $yu({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:oen(e.exclusiveMinimum),exclusiveMaximum:oen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:T,wrapAsNullable:t,example:hma({schema:e,logger:r.logger,fallback:c}),groupName:m});if(e==="integer"||e.type==="integer")return aSf({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:oen(e.exclusiveMinimum),exclusiveMaximum:oen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:T,wrapAsNullable:t,example:hma({schema:e,logger:r.logger,fallback:c}),groupName:m});if(e==="float")return $yu({nameOverride:o,generatedName:O,title:j,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:oen(e.exclusiveMinimum),exclusiveMaximum:oen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:T,wrapAsNullable:t,example:hma({schema:e,logger:r.logger,fallback:c}),groupName:m});if(e==="string"||e.type==="string"){if(e.format==="date-time")return K9({nameOverride:o,generatedName:O,title:j,primitive:ty.datetime({example:lSr({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:A,availability:T,groupName:m});if(e.format==="json-string")return Op.unknown({nameOverride:o,generatedName:O,title:j,description:A,availability:T,groupName:m,example:void 0});let U=gSf(e,"const");return U!=null?ySf({nameOverride:o,generatedName:O,title:j,literal:_I.string(U),wrapAsNullable:t,description:A,availability:T,groupName:m}):K9({nameOverride:o,generatedName:O,title:j,primitive:ty.string({default:R7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:lSr({schema:e,logger:r.logger,fallback:c})}),groupName:m,wrapAsNullable:t,description:A,availability:T})}if(e.type==="array")return rSf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,item:e.items,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,example:_Sf({schema:e,logger:r.logger,fallback:c}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&hSf(e))return tSf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,additionalProperties:e.additionalProperties,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,encoding:i,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?Xyu({nameOverride:o,generatedName:O,title:j,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):Qyu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:m,encoding:i,source:a,namespace:u});if(Array.isArray(e.type)&&(e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type)),e.oneOf!=null&&e.oneOf.length>0){let U=B_(e,wh.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||U?Xyu({nameOverride:o,generatedName:O,title:j,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):Qyu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:m,encoding:i,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let ne=aP(e.oneOf[0],t,r,n,a,u,d);return L7n(ne,A,m)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let k=e.oneOf[0],xe=e.oneOf[1];if(!Kh(k)&&k.type==="null")return aP(xe,!0,r,n,a,u);if(!Kh(xe)&&xe.type==="null")return aP(k,!0,r,n,a,u)}let ne=MBj({schemas:e.oneOf});if(ne!=null)return k6r({nameOverride:o,generatedName:O,title:j,fernEnum:void 0,enumVarNames:void 0,enumValues:ne,_default:e.default,description:A,availability:T,wrapAsNullable:t,groupName:m,context:r,source:a});let ge=vSf({schemas:e.oneOf,context:r});if(ge!=null&&!r.options.discriminatedUnionV2&&!U)return Gyu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:A,availability:T,wrapAsNullable:t,discriminant:ge.discriminant,variants:ge.schemas,context:r,groupName:m,encoding:i,source:a,namespace:u});let X=e.oneOf.filter(k=>!Kh(k)&&k.type==="null").length>0;return F7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,wrapAsNullable:t||X,context:r,subtypes:e.oneOf.filter(k=>Kh(k)||k.type!=="null"),encoding:i,groupName:m,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let ge=aP(e.anyOf[0],t,r,n,a,u,d);return L7n(ge,A,m)}if(e.anyOf.length===2){let[ge,X]=e.anyOf;if(ge!=null&&X!=null){if(!Kh(ge)&&ge.type==="null"){let k=aP(X,!0,r,n,a,u);return L7n(k,A,m)}else if(!Kh(X)&&X.type==="null"){let k=aP(ge,!0,r,n,a,u);return L7n(k,A,m)}}}let U=vSf({schemas:e.anyOf,context:r});if(U!=null&&!r.options.discriminatedUnionV2)return Gyu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:A,availability:T,wrapAsNullable:t,discriminant:U.discriminant,variants:U.schemas,context:r,groupName:m,encoding:i,source:a,namespace:u});let ne=e.anyOf.filter(ge=>!Kh(ge)&&ge.type==="null").length>0;return F7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,wrapAsNullable:t||ne,context:r,subtypes:e.anyOf.filter(ge=>Kh(ge)||ge.type!=="null"),encoding:i,groupName:m,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let U=[];for(let ge of e.allOf??[])(Kh(ge)||Object.keys(ge).length>0)&&U.push(ge);if((e.properties==null||e.properties.length===0)&&U.length===1&&U[0]!=null){let ge=aP(U[0],t,r,n,a,u,d);return L7n(ge,A,m)}let ne=U.filter(ge=>{let X=yma(ge);return X||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(ge)}`),X});if((e.properties==null||e.properties.length===0)&&ne.length===1&&ne[0]!=null){let ge=aP(ne[0],t,r,n,a,u,d);return L7n(ge,A,m)}return lSf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},description:A,required:e.required,wrapAsNullable:t,allOf:ne,context:r,propertiesToExclude:f,groupName:m,fullExamples:B,additionalProperties:e.additionalProperties,availability:T,encoding:i,source:a,namespace:u})}if(e.type==="object"&&EBj(e)&&ABj(e)&&hSf(e))return fma({nameOverride:o,generatedName:O,title:j,description:A,availability:T,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${O}Key`,title:void 0,description:void 0,availability:void 0,schema:ty.string({default:R7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:lSr({schema:e,logger:r.logger,fallback:c})}),groupName:m},valueSchema:Op.unknown({nameOverride:void 0,generatedName:`${O}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:m}),groupName:m,encoding:i,example:e.example});if(e.type==null){let U=e.example??e.default;return Op.unknown({nameOverride:o,generatedName:O,title:j,description:A,availability:T,groupName:m,example:U})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(n)} value=${JSON.stringify(e)}`)}function e3r(e){if(e.$ref.startsWith(uen))return e.$ref.replace(uen,"")}function Yyu(e,t,r){let n=B_(e,wh.TYPE_NAME),i=v8(t),a=e.description,u=Pxe(e),f=e3r(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return J0.reference({generatedName:i,nameOverride:n,title:void 0,schema:f,description:a??void 0,availability:u,groupName:void 0,source:r})}function EBj(e){return e.oneOf==null||e.oneOf.length===0}function ABj(e){return e.allOf==null||e.allOf.length===0}function hSf(e){return e.properties==null||Object.keys(e.properties).length===0}function Whi(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function L7n(e,t,r){return e.type==="reference"?Op.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?Op.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e.type==="nullable"?Op.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e}function yma(e){return Kh(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>yma(t)):e.oneOf!=null?e.oneOf.every(t=>yma(t)):e.anyOf!=null?e.anyOf.every(t=>yma(t)):!1}function ySf({literal:e,wrapAsNullable:t,groupName:r,description:n,availability:i,nameOverride:a,generatedName:u,title:f}){return t?Op.nullable({nameOverride:a,generatedName:u,title:f,value:Op.literal({nameOverride:a,generatedName:u,title:f,value:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Op.literal({nameOverride:a,generatedName:u,title:f,value:e,groupName:r,description:n,availability:i})}function K9({primitive:e,wrapAsNullable:t,groupName:r,description:n,availability:i,generatedName:a,nameOverride:u,title:f}){return r=typeof r=="string"?[r]:r,t?Op.nullable({nameOverride:u,generatedName:a,title:f,value:Op.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Op.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r})}function MBj({schemas:e}){let t=new Set;for(let r of e){if(Kh(r))return;if(r.enum!=null&&Whi(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function vSf({schemas:e,context:t}){let r={};for(let n of e){let i=bSf({schema:n,context:t});for(let[a,u]of Object.entries(i)){let f=r[a];f!=null?f[u]=n:r[a]={[u]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function bSf({schema:e,context:t}){let r=Kh(e)?t.resolveSchemaReference(e):e;return TBj({schema:r,context:t})}function TBj({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=bSf({schema:n,context:t});for(let[a,u]of Object.entries(i??{}))r[a]=u}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=Kh(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&Whi(a.enum)&&xBj(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let u=gSf(a,"const");a.type==="string"&&u!=null&&(r[n]=u),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function xBj(e){if(!e)return[];let t=new Set;return e.forEach(r=>{typeof r=="string"?t.add(r.toLowerCase()):t.add(r)}),Array.from(t)}function gSf(e,t){let r=e[t];if(r!=null)return r}function qBj({schema:e,logger:t}){let r=ZDf({schema:e,logger:t});if(r!=null)return iSf(r)}function vma(e,t){let r={},n={};return e==null?r=t:n={[e]:t},{rootSchemas:r,namespacedSchemas:n}}var mSf="#/components/messages/",Zyu=class{logger;document;taskContext;DUMMY;options;namespace;constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){if(this.document.components==null||this.document.components.schemas==null||!t.$ref.startsWith(uen))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(uen.length).split("/");if(n[0]==null)throw new Error(`${t.$ref} is undefined`);let i=this.document.components.schemas[n[0]];if(i==null)throw new Error(`${n[0]} is undefined`);if(Kh(i)&&(i=this.resolveSchemaReference(i)),n[1]==="properties"&&n[2]!=null){let a=i.properties?.[n[2]];if(a==null)throw new Error(`${t.$ref} is undefiened. Property does not exist on object.`);Kh(a)?i=this.resolveSchemaReference(a):i=a}return i}resolveMessageReference(t){if(this.document.components==null||this.document.components.messages==null||!t.$ref.startsWith(mSf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(mSf.length),n=this.document.components.messages[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}},bma=class extends Zyu{constructor({document:t,taskContext:r,options:n,namespace:i}){super({document:t,taskContext:r,options:n,namespace:i})}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}};function t3r(e){if(typeof e=="string")return OP.primitive(Uy.string(e));if(typeof e=="number")return Number.isInteger(e)?OP.primitive(Uy.int(e)):OP.primitive(Uy.double(e));if(typeof e=="boolean")return OP.primitive(Uy.boolean(e));if(Array.isArray(e)){let t=e.map(r=>t3r(r));return t.length===0?void 0:OP.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=t3r(n);i!=null&&t.push({key:Uy.string(r),value:i})}return OP.map(t)}}function Hhi(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function OSf(e){if(e!=null&&Array.isArray(e))return e}var r3r=class{schemas;context;constructor(t,r){this.schemas=t,this.context=r}buildExample({schema:t,exampleId:r,example:n,options:i,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:u,skipReadonly:f}){switch(n.type){case"enum":return typeof r=="string"&&PSf({schema:n,value:r})?OP.enum(r):n.values[0]!=null?OP.enum(n.values[0]?.value):void 0;case"literal":return OP.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"optional":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:n.schema,example:r,options:u});return OP.primitive(d)}case"reference":{let d=this.schemas[n.schema];if(d!=null&&!a.has(n.schema)){a.add(n.schema);let c=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});return a.delete(n.schema),c}return}case"oneOf":switch(n.value.type){case"discriminated":{let d={},c={},o={},l=Hhi(r),m=l?.[n.value.discriminantProperty],O=n.value.schemas[m],j=[],A=this.getDiscriminatedUnionVariantSchema(n.value,l);A!=null&&j.push(A),j.push(...Object.entries(n.value.schemas));for(let T of j)if(m!=null&&O!=null&&O.type==="object"){c=this.getAllProperties(O),o=this.getAllRequiredProperties(O),d[n.value.discriminantProperty]=OP.primitive(Uy.string(m));break}else{let B=this.getObjectSchema(T[1]);if(B==null)continue;c=this.getAllProperties(B),o=this.getAllRequiredProperties(B),d[n.value.discriminantProperty]=OP.primitive(Uy.string(T[0]))}for(let T of n.value.commonProperties){c[T.key]={schema:T.schema,readonly:!1};let B=this.getResolvedSchema(T.schema);B.type!=="optional"&&B.type!=="nullable"&&(o[T.key]=T.schema)}for(let[T,B]of Object.entries(c)){let F=T in o;if(F&&l?.[T]!=null){let C=this.buildExampleHelper({schema:B.schema,exampleId:t,example:l[T],visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});if(C!=null)d[T]=C;else return}else{let C=this.buildExampleHelper({exampleId:t,schema:B.schema,example:l?.[T],visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});if(C!=null)d[T]=C;else if(F)return}}return OP.oneOf(L6r.discriminated(d))}case"undisciminated":{let d=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});break}}return;case"unknown":if(r!=null){let d=t3r(r);if(d!=null)return OP.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(i,u)?void 0:u.isParameter?OP.primitive(Uy.string(u.name??"string")):OP.map([{key:Uy.string("key"),value:OP.primitive(Uy.string("value"))}]);case"array":{let d=OSf(r),c=[];if(d!=null&&d.length>0)for(let o of d){let l=this.buildExampleHelper({exampleId:t,example:o,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});l!=null&&c.push(l)}else if(n.example!=null&&n.example.length>0)for(let o of n.example){let l=this.buildExampleHelper({exampleId:t,example:o,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});l!=null&&c.push(l)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});o!=null&&c.push(o)}return OP.array(c)}case"map":{let d=Hhi(r??n.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[m,O]of Object.entries(d)){let j=this.buildExampleFromPrimitive({schema:n.key.schema,example:m,options:u}),A=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});A!=null&&l.push({key:j,value:A})}return OP.map(l)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return OP.map([{key:Uy.string("key"),value:OP.unknown(OP.primitive(Uy.string("value")))}]);let c=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...u,name:"value"},skipReadonly:f&&this.context.options.respectReadonlySchemas});return o!=null?OP.map([{key:c,value:o}]):OP.map([])}case"object":{let d={},c=n.fullExamples?.find(O=>O.name===t)??n.fullExamples?.find(O=>O.name==null)??n.fullExamples?.[0],o=Hhi(r)??(c!=null?Hhi(c.value):{})??{},l=this.getAllProperties(n),m=this.getAllRequiredProperties(n);for(let[O,j]of Object.entries(l)){if(f&&j.readonly)continue;let A=O in m,T=Object.keys(o).includes(O),B=this.buildExampleHelper({schema:j.schema,exampleId:t,example:o[O],visitedSchemaIds:a,depth:i+1,options:{...u,name:O},skipReadonly:f&&this.context.options.respectReadonlySchemas});if(A&&B!=null)d[O]=B;else{if(A)return;(T&&B!=null||!u.ignoreOptionals&&B!=null)&&(d[O]=B)}}return OP.object({properties:d})}default:hc(n)}}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r?.[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,u)=>u.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return PSf({schema:t,value:r})?5:0;case"object":{if(!bD(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,u]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(u.schema,r[a])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!bD(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,a)=>a-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let u=this.hasExample(a,r,n,i);return n.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let n of t.properties)r[n.key]={schema:n.schema,readonly:n.readonly??!1};for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?Uy.string(t):r.example!=null?Uy.string(r.example):Uy.string(n.name??_1.STRING);case"base64":return t!=null&&typeof t=="string"?Uy.base64(t):r.example!=null?Uy.base64(r.example):Uy.base64(_1.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?Uy.boolean(t):r.example!=null?Uy.boolean(r.example):Uy.boolean(_1.BOOLEAN);case"date":return t!=null&&typeof t=="string"?Uy.date(t):r.example!=null?Uy.date(r.example):Uy.date(_1.DATE);case"datetime":return t!=null&&typeof t=="string"?Uy.datetime(t):r.example!=null?Uy.datetime(r.example):Uy.datetime(_1.DATE_TIME);case"double":return t!=null&&typeof t=="number"?Uy.double(t):r.example!=null?Uy.double(r.example):Uy.double(_1.DOUBLE);case"float":return t!=null&&typeof t=="number"?Uy.float(t):r.example!=null?Uy.float(r.example):Uy.float(_1.FLOAT);case"int":return t!=null&&typeof t=="number"?Uy.int(t):r.example!=null?Uy.int(r.example):Uy.int(_1.INT);case"int64":return t!=null&&typeof t=="number"?Uy.int64(t):r.example!=null?Uy.int64(r.example):Uy.int64(_1.INT64);case"uint":return t!=null&&typeof t=="number"?Uy.uint(t):r.example!=null?Uy.uint(r.example):Uy.uint(_1.UINT);case"uint64":return t!=null&&typeof t=="number"?Uy.uint64(t):r.example!=null?Uy.uint64(r.example):Uy.uint64(_1.UINT64);default:hc(r)}}};function PSf({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function b8t(e){switch(e.type){case"object":return Op.object({allOf:e.allOf,properties:e.properties.map(t=>BBj(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return Op.array({description:e.description,availability:e.availability,value:b8t(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0});case"enum":return Op.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,groupName:e.groupName,example:void 0,source:e.source});case"literal":return Op.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName});case"nullable":return Op.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:b8t(e.value),groupName:e.groupName});case"optional":return Op.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:b8t(e.value),groupName:e.groupName});case"primitive":return Op.primitive({description:e.description,availability:e.availability,schema:jSf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return Op.map({description:e.description,availability:e.availability,key:Op.primitive({description:e.key.description,availability:e.key.availability,schema:jSf(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:b8t(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0});case"reference":return Op.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return Op.oneOf(CBj(e.value));case"unknown":return Op.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:hc(e)}}function CBj(e){switch(e.type){case"discriminated":return wX.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:b8t(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,b8t(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return wX.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>b8t(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:hc(e)}}function jSf(e){switch(e.type){case"string":return ty.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return ty.base64({example:void 0});case"boolean":return ty.boolean({default:e.default,example:void 0});case"date":return ty.date({example:void 0});case"datetime":return ty.datetime({example:void 0});case"double":return ty.double({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"float":return ty.float({example:void 0});case"int":return ty.int({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"int64":return ty.int64({default:e.default,example:void 0});case"uint":return ty.uint({default:void 0,example:void 0});case"uint64":return ty.uint64({default:void 0,example:void 0});default:hc(e)}}function BBj(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:b8t(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function gma(e){return e.type!=="optional"&&e.type!=="nullable"}function Jhi(e){if(e.type==="full")return e.request==null&&e.response==null&&e.queryParameters==null&&e.pathParameters==null&&e.headers==null;{let t=e.value;return t.request==null&&t.response==null&&t["query-parameters"]==null&&t["path-parameters"]==null&&t.headers==null}}var mma=class{exampleTypeFactory;logger;schemas;constructor(t,r){this.schemas=t,this.exampleTypeFactory=new r3r(t,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=zBj(t.request),n=NBj(t.response);if(r?.type==="unsupported"||n?.type==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:t.method==="POST"||t.method==="PUT",schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&i.push([void 0,m])}else for(let{name:m,value:O}of r.examples){let j=this.exampleTypeFactory.buildExample({skipReadonly:t.method==="POST"||t.method==="PUT",schema:r.schema,exampleId:m,example:O,options:{isParameter:!1,ignoreOptionals:!0}});j!=null&&i.push([m,j])}if(l&&i.length===0)return this.logger.warn(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});m!=null&&(t.response?.type==="json"?a.push([void 0,h2t.withoutStreaming(m)]):t.response?.type==="streamingJson"&&a.push([void 0,h2t.withStreaming([m])]))}else for(let{name:m,value:O}of n.examples){let j=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:m,example:O,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});j!=null&&(t.response?.type==="json"?a.push([m,h2t.withoutStreaming(j)]):t.response?.type==="streamingJson"&&a.push([m,h2t.withStreaming([j])]))}if(l&&a.length===0)return this.logger.warn(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let m=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!g8t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),m&&O==null)return[];O!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:O})}let f=[];for(let l of t.queryParameters){let m=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!g8t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),m&&O==null)return[];O!=null&&f.push({name:l.name,value:O})}let d=[];for(let l of t.headers){let m=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!g8t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),m&&O==null)return[];O!=null&&d.push({name:l.name,value:O})}let c=[];t.request!=null&&t.response!=null?c=IBj(i,a):t.request!=null?c=i.map(([l,m])=>({id:l,request:m,response:void 0})):t.response!=null&&(c=a.map(([l,m])=>({id:l,request:void 0,response:m})));let o=t.examples.filter(l=>Jhi(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let m=l.value["code-samples"];if(m!=null)return this.convertCodeSamples(m)}return}else return l.codeSamples}).filter(l=>YA(l));return c.length===0?[_2t.full({name:void 0,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:void 0,response:void 0,codeSamples:o})]:c.map(({id:l,request:m,response:O})=>_2t.full({name:l,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:m,response:O,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?uSr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):uSr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?_W.Csharp:r.sdk,code:r.code})).filter(YA)}isSchemaRequired(t){return gma(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function IBj(e,t){let r=[];if(e.length<=1){let[i,a]=e[0]??[];if(t.length===0)return r.push({id:i,request:a,response:void 0}),r;for(let[u,f]of t)r.push({id:u??i,request:a,response:f});return r}if(t.length<=1){let[i,a]=t[0]??[];if(t.length===0)return r.push({id:i,request:void 0,response:a}),r;for(let[u,f]of e)r.push({id:u??i,request:f,response:a});return r}let n=new Set;for(let[i,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(i==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let f=!1;for(let d=0;d<t.length;d++){let[c,o]=t[d];c==null||n.has(d)||i===c&&(r.push({id:i,request:a,response:o}),c!=null&&n.add(d),f=!0)}!f&&u!=null&&r.push({id:i,request:a,response:u})}for(let i=0;i<t.length;i++){if(n.has(i))continue;let[a,u]=t[i],f=e.find(([d])=>d==null)?.[1]??e[0]?.[1];f!=null&&r.push({id:a,request:f,response:u})}return r}function zBj(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:FBj(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function NBj(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function g8t(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return g8t(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undisciminated":return g8t(e.value.value);default:return!1}default:hc(e)}}function FBj(e){return Op.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:b8t(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0}).filter(YA),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source})}var Oma=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new r3r(t,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:n,subscribe:i,handshake:a,source:u,namespace:f}){let d=[];for(let c of r){let o=[];for(let O of a.queryParameters){let j=this.isSchemaRequired(O.schema),A=this.exampleTypeFactory.buildExample({schema:O.schema,exampleId:void 0,example:c.queryParameters?.[O.name],options:{name:O.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!g8t(A)&&(A=void 0),!(j&&A==null)&&A!=null&&o.push({name:O.name,value:A})}let l=[];for(let O of a.headers){let j=this.isSchemaRequired(O.schema),A=this.exampleTypeFactory.buildExample({schema:O.schema,exampleId:void 0,example:c.headers?.[O.name],options:{name:O.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!g8t(A)&&(A=void 0),!(j&&A==null)&&A!=null&&l.push({name:O.name,value:A})}let m=[];for(let O of c.messages){let j=t.resolveMessageReference({$ref:`#/components/messages/${O.messageId}`}),A=Kh(j.payload)?t.resolveSchemaReference(j.payload):j.payload,T=this.exampleTypeFactory.buildExample({schema:aP(A,!1,t,[O.messageId],u,f),exampleId:void 0,example:O.value,options:{isParameter:!1,ignoreOptionals:!0}});T!=null&&m.push({messageType:O.type,payload:T,description:void 0})}d.push({name:c.summary,queryParameters:o,headers:l,description:c.description,messages:m})}return d}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:n}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let f of n.queryParameters){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!g8t(c)&&(c=void 0),d&&c==null)return;c!=null&&a.push({name:f.name,value:c})}let u=[];for(let f of n.headers){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!g8t(c)&&(c=void 0),d&&c==null)return;c!=null&&u.push({name:f.name,value:c})}if(t!=null){let f=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"publish",payload:f,description:void 0})}if(r!=null){let f=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"subscribe",payload:f,description:void 0})}return i}isSchemaRequired(t){return gma(this.getResolvedSchema(t))}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}};var Qhi={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path"};function wSf(e){return B_(e,Qhi.FERN_EXAMPLES)??[]}function SSf({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){let u=[];a!=null&&u.push(a),e.tags?.[0]!=null?u.push(e.tags[0].name):i.naming!=="v2"&&u.push("websocket");let f=new bma({document:e,taskContext:t,options:r,namespace:a}),d={},c;for(let[l,m]of Object.entries(e.components?.schemas??{})){let O=aP(m,!1,f,[l],n,a);d[l]=O}let o=new Oma(d,f);for(let[l,m]of Object.entries(e.channels??{})){if(m.bindings?.ws==null){f.logger.error(`Channel ${l} does not have websocket bindings. Skipping.`);continue}let O=[];if(m.parameters!=null)for(let[F,C]of Object.entries(m.parameters??{}))O.push({name:F,description:C.description,parameterNameOverride:void 0,schema:C.schema!=null?aP(C.schema,!1,f,u,n,a):Op.primitive({schema:ty.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:Pxe(C),source:n});let j=[];if(m.bindings.ws.headers!=null){let F=m.bindings.ws.headers.required??[];for(let[C,N]of Object.entries(m.bindings.ws.headers.properties??{})){let U=Kh(N)?f.resolveSchemaReference(N):N;j.push({name:C,schema:aP(U,!F.includes(C),f,u,n,a),description:U.description,parameterNameOverride:void 0,env:void 0,availability:Pxe(U),source:n})}}let A=[];if(m.bindings.ws.query!=null){let F=m.bindings.ws.query.required??[];for(let[C,N]of Object.entries(m.bindings.ws.query.properties??{})){let U=Kh(N)?f.resolveSchemaReference(N):N;A.push({name:C,schema:aP(U,!F.includes(C),f,u,n,a),description:U.description,parameterNameOverride:void 0,availability:Pxe(U),source:n})}}let T;m.publish!=null&&(T=DSf({generatedName:m.publish.operationId??"PublishEvent",event:m.publish,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i}));let B;if(m.subscribe!=null&&(B=DSf({generatedName:m.subscribe.operationId??"SubscribeEvent",event:m.subscribe,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i})),j.length>0||A.length>0||T!=null||B!=null){let F=wSf(m),C=[];if(F.length>0)C=o.buildWebsocketSessionExamplesForExtension({context:f,extensionExamples:F,handshake:{headers:j,queryParameters:A},publish:T,subscribe:B,source:n,namespace:a});else{let U=o.buildWebsocketSessionExample({handshake:{headers:j,queryParameters:A},publish:T,subscribe:B});U!=null&&C.push(U)}let N=e.tags?.[0]?.name!=null?[e.tags?.[0].name]:void 0;c={handshake:{headers:j.map(U=>({...U,schema:mx(U.schema),env:U.env})),queryParameters:A.map(U=>({...U,schema:mx(U.schema)})),pathParameters:O.map(U=>({...U,parameterNameOverride:void 0,schema:mx(U.schema)}))},groupName:f.resolveTags(N,"Websocket"),publish:T!=null?mx(T):T,subscribe:B!=null?mx(B):B,summary:B_(m,Qhi.FERN_DISPLAY_NAME),path:l,description:void 0,examples:C,source:n};break}}return{groupedSchemas:vma(a,d),channel:c,basePath:B_(e,Qhi.BASE_PATH)}}function DSf({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:u}){if(t.message.oneOf!=null){let f=[],d=[];for(let c of t.message.oneOf){let o,l={type:"notFound"};if(Kh(c)){let m=r.resolveMessageReference(c);!Kh(m.payload)&&u.naming==="v2"?(l=m.name?{type:"name",name:m.name}:l,o={...m.payload,title:m.name??m.payload.title,description:m.name??m.payload.description}):o=m.payload}else o=c;d.push(l),f.push(o)}return F7n({description:t.description??t.message.description,availability:Pxe(t.message),subtypes:f,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}var Uen=Jo(dIf(),1);var pIf=require("fs/promises");async function Tja({absoluteFilepathToOverrides:e,data:t,context:r}){let n=null;try{let i=(await(0,pIf.readFile)(e,"utf8")).toString();try{n=JSON.parse(i)}catch{n=Fy.load(i,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return lUo({data:t,overrides:n})}var KXj={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},YXj={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:KXj,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}};async function hIf({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,context:r}){let n=await _If({absolutePathToOpenAPI:e}),i;if(t!=null?i=t:typeof n=="object"&&n[wh.OPENAPI_OVERIDES_FILEPATH]!=null&&(i=Wl(B0(e),ls.of(n[wh.OPENAPI_OVERIDES_FILEPATH]))),i!=null){let a=await Tja({absoluteFilepathToOverrides:i,context:r,data:n});return await _If({absolutePathToOpenAPI:e,parsed:a})}return n}async function _If({absolutePathToOpenAPI:e,parsed:t}){let r={config:new Uen.Config({apis:{},styleguide:{plugins:[YXj],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};return(t!=null?await(0,Uen.bundle)({...r,doc:{source:new Uen.Source(e,"<openapi>"),parsed:t}}):await(0,Uen.bundle)({...r,ref:e})).bundle.parsed}var E3f=Jo(j6f(),1);function w6f(e){return B_(e,wh.ASYNC_CONFIG)}var D6f="$request.";function S6f(e){let t=B_(e,wh.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamDescription:t["stream-description"],streamConditionProperty:ciw(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function ciw(e){return e.startsWith(D6f)?e.slice(D6f.length):e}function E6f(e){let t=e;if(t.cursor!=null)return oSr.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return oSr.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function A6f(e,t){let r=B_(t,wh.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=B_(e,wh.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:E6f(n)}return E6f(r)}}function M6f(e){let t=liw(e),r={};return Pju({obj:t,occurrences:r,breadcrumbs:[]}),r}function Pju({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)Pju({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)Pju({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function liw(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?Jvi(r.get):void 0,put:r?.put!=null?Jvi(r.put):void 0,post:r?.post!=null?Jvi(r.post):void 0,patch:r?.patch!=null?Jvi(r.patch):void 0,delete:r?.delete!=null?Jvi(r.delete):void 0}]))}}function Jvi(e){return{...e,requestBody:e.requestBody!=null?Kh(e.requestBody)?e.requestBody:fiw(e.requestBody):void 0}}function fiw(e){let t,r;for(let n in e.content){let i=eI.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[eI.MULTIPART_FORM_DATA]:r}}:e}var T6f="#/components/parameters/",x6f="#/components/responses/",q6f="#/components/examples/",C6f="#/components/requestBodies/",tNn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=M6f(t),this.options=i,this.source=a,this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown",additionalProperties:!0};n=n[i]}return n==null?{"x-fern-type":"unknown",additionalProperties:!0}:(Kh(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(T6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(T6f.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(C6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(C6f.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(x6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(x6f.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(q6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(q6f.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveExampleReference(n):n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}};var rNn=class extends tNn{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var MM;(function(e){e.assertEqual=i=>i;function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let a={};for(let u of i)a[u]=u;return a},e.getValidEnumValues=i=>{let a=e.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),u={};for(let f of a)u[f]=i[f];return e.objectValues(u)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let u in i)Object.prototype.hasOwnProperty.call(i,u)&&a.push(u);return a},e.find=(i,a)=>{for(let u of i)if(a(u))return u},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(u=>typeof u=="string"?`'${u}'`:u).join(a)}e.joinValues=n,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(MM||(MM={}));var wju;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(wju||(wju={}));var av=MM.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Q3r=e=>{switch(typeof e){case"undefined":return av.undefined;case"string":return av.string;case"number":return isNaN(e)?av.nan:av.number;case"boolean":return av.boolean;case"function":return av.function;case"bigint":return av.bigint;case"symbol":return av.symbol;case"object":return Array.isArray(e)?av.array:e===null?av.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?av.promise:typeof Map<"u"&&e instanceof Map?av.map:typeof Set<"u"&&e instanceof Set?av.set:typeof Date<"u"&&e instanceof Date?av.date:av.object;default:return av.unknown}},W_=MM.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),diw=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Bwe=class e extends Error{constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){let r=t||function(a){return a.message},n={_errors:[]},i=a=>{for(let u of a.issues)if(u.code==="invalid_union")u.unionErrors.map(i);else if(u.code==="invalid_return_type")i(u.returnTypeError);else if(u.code==="invalid_arguments")i(u.argumentsError);else if(u.path.length===0)n._errors.push(r(u));else{let f=n,d=0;for(;d<u.path.length;){let c=u.path[d];d===u.path.length-1?(f[c]=f[c]||{_errors:[]},f[c]._errors.push(r(u))):f[c]=f[c]||{_errors:[]},f=f[c],d++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,MM.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Bwe.create=e=>new Bwe(e);var aNn=(e,t)=>{let r;switch(e.code){case W_.invalid_type:e.received===av.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case W_.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,MM.jsonStringifyReplacer)}`;break;case W_.unrecognized_keys:r=`Unrecognized key(s) in object: ${MM.joinValues(e.keys,", ")}`;break;case W_.invalid_union:r="Invalid input";break;case W_.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${MM.joinValues(e.options)}`;break;case W_.invalid_enum_value:r=`Invalid enum value. Expected ${MM.joinValues(e.options)}, received '${e.received}'`;break;case W_.invalid_arguments:r="Invalid function arguments";break;case W_.invalid_return_type:r="Invalid function return type";break;case W_.invalid_date:r="Invalid date";break;case W_.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:MM.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case W_.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case W_.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case W_.custom:r="Invalid input";break;case W_.invalid_intersection_types:r="Intersection results could not be merged";break;case W_.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case W_.not_finite:r="Number must be finite";break;default:r=t.defaultError,MM.assertNever(e)}return{message:r}},z6f=aNn;function piw(e){z6f=e}function Fwa(){return z6f}var Rwa=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],u={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let f="",d=n.filter(c=>!!c).slice().reverse();for(let c of d)f=c(u,{data:t,defaultError:f}).message;return{...i,path:a,message:f}},_iw=[];function qy(e,t){let r=Fwa(),n=Rwa({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===aNn?void 0:aNn].filter(i=>!!i)});e.common.issues.push(n)}var pG=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return bO;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let a=await i.key,u=await i.value;n.push({key:a,value:u})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:a,value:u}=i;if(a.status==="aborted"||u.status==="aborted")return bO;a.status==="dirty"&&t.dirty(),u.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof u.value<"u"||i.alwaysSet)&&(n[a.value]=u.value)}return{status:t.value,value:n}}},bO=Object.freeze({status:"aborted"}),iNn=e=>({status:"dirty",value:e}),LX=e=>({status:"valid",value:e}),Dju=e=>e.status==="aborted",Sju=e=>e.status==="dirty",$vi=e=>e.status==="valid",Kvi=e=>typeof Promise<"u"&&e instanceof Promise;function Lwa(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}function N6f(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r}var Yb;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Yb||(Yb={}));var Qvi,Gvi,zxe=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},B6f=(e,t)=>{if($vi(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Bwe(e.common.issues);return this._error=r,this._error}}};function Nw(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(u,f)=>{var d,c;let{message:o}=e;return u.code==="invalid_enum_value"?{message:o??f.defaultError}:typeof f.data>"u"?{message:(d=o??n)!==null&&d!==void 0?d:f.defaultError}:u.code!=="invalid_type"?{message:f.defaultError}:{message:(c=o??r)!==null&&c!==void 0?c:f.defaultError}},description:i}}var Fw=class{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return Q3r(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Q3r(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new pG,ctx:{common:t.parent.common,data:t.data,parsedType:Q3r(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Kvi(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){var n;let i={common:{issues:[],async:(n=r?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Q3r(t)},a=this._parseSync({data:t,path:i.path,parent:i});return B6f(i,a)}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Q3r(t)},i=this._parse({data:t,path:n.path,parent:n}),a=await(Kvi(i)?i:Promise.resolve(i));return B6f(n,a)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{let u=t(i),f=()=>a.addIssue({code:W_.custom,...n(i)});return typeof Promise<"u"&&u instanceof Promise?u.then(d=>d?!0:(f(),!1)):u?!0:(f(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new Iwe({schema:this,typeName:Gm.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return Ixe.create(this,this._def)}nullable(){return N8t.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return MSr.create(this,this._def)}promise(){return K3r.create(this,this._def)}or(t){return atn.create([this,t],this._def)}and(t){return otn.create(this,t,this._def)}transform(t){return new Iwe({...Nw(this._def),schema:this,typeName:Gm.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new ftn({...Nw(this._def),innerType:this,defaultValue:r,typeName:Gm.ZodDefault})}brand(){return new Yvi({typeName:Gm.ZodBranded,type:this,...Nw(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new dtn({...Nw(this._def),innerType:this,catchValue:r,typeName:Gm.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Xvi.create(this,t)}readonly(){return ptn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},hiw=/^c[^\s-]{8,}$/i,yiw=/^[0-9a-z]+$/,viw=/^[0-9A-HJKMNP-TV-Z]{26}$/,biw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,giw=/^[a-z0-9_-]{21}$/i,miw=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Oiw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Piw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",jju,jiw=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,wiw=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Diw=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,F6f="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Siw=new RegExp(`^${F6f}$`);function R6f(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Eiw(e){return new RegExp(`^${R6f(e)}$`)}function L6f(e){let t=`${F6f}T${R6f(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Aiw(e,t){return!!((t==="v4"||!t)&&jiw.test(e)||(t==="v6"||!t)&&wiw.test(e))}var G3r=class e extends Fw{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==av.string){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.string,received:a.parsedType}),bO}let n=new pG,i;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let u=t.data.length>a.value,f=t.data.length<a.value;(u||f)&&(i=this._getOrReturnCtx(t,i),u?qy(i,{code:W_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):f&&qy(i,{code:W_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Oiw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"email",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")jju||(jju=new RegExp(Piw,"u")),jju.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"emoji",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")biw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"uuid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")giw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"nanoid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")hiw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"cuid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")yiw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"cuid2",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")viw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"ulid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),qy(i,{validation:"url",code:W_.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"regex",code:W_.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?L6f(a).test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Siw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Eiw(a).test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?miw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"duration",code:W_.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Aiw(t.data,a.version)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"ip",code:W_.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Diw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"base64",code:W_.invalid_string,message:a.message}),n.dirty()):MM.assertNever(a);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:W_.invalid_string,...Yb.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Yb.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Yb.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Yb.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Yb.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Yb.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Yb.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Yb.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Yb.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Yb.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Yb.errToObj(t)})}datetime(t){var r,n;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(r=t?.offset)!==null&&r!==void 0?r:!1,local:(n=t?.local)!==null&&n!==void 0?n:!1,...Yb.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Yb.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Yb.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Yb.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Yb.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Yb.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Yb.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Yb.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Yb.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Yb.errToObj(r)})}nonempty(t){return this.min(1,Yb.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};G3r.create=e=>{var t;return new G3r({checks:[],typeName:Gm.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Nw(e)})};function Miw(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(e.toFixed(i).replace(".","")),u=parseInt(t.toFixed(i).replace(".",""));return a%u/Math.pow(10,i)}var ken=class e extends Fw{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==av.number){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.number,received:a.parsedType}),bO}let n,i=new pG;for(let a of this._def.checks)a.kind==="int"?MM.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?Miw(t.data,a.value)!==0&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.not_finite,message:a.message}),i.dirty()):MM.assertNever(a);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Yb.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Yb.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Yb.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Yb.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Yb.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Yb.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Yb.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Yb.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Yb.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Yb.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Yb.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Yb.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Yb.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Yb.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&MM.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};ken.create=e=>new ken({checks:[],typeName:Gm.ZodNumber,coerce:e?.coerce||!1,...Nw(e)});var etn=class e extends Fw{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==av.bigint){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.bigint,received:a.parsedType}),bO}let n,i=new pG;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):MM.assertNever(a);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Yb.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Yb.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Yb.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Yb.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Yb.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Yb.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Yb.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Yb.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Yb.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Yb.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};etn.create=e=>{var t;return new etn({checks:[],typeName:Gm.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Nw(e)})};var ttn=class extends Fw{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==av.boolean){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.boolean,received:n.parsedType}),bO}return LX(t.data)}};ttn.create=e=>new ttn({typeName:Gm.ZodBoolean,coerce:e?.coerce||!1,...Nw(e)});var rtn=class e extends Fw{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==av.date){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.date,received:a.parsedType}),bO}if(isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_date}),bO}let n=new pG,i;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):MM.assertNever(a);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Yb.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Yb.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};rtn.create=e=>new rtn({checks:[],coerce:e?.coerce||!1,typeName:Gm.ZodDate,...Nw(e)});var oNn=class extends Fw{_parse(t){if(this._getType(t)!==av.symbol){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.symbol,received:n.parsedType}),bO}return LX(t.data)}};oNn.create=e=>new oNn({typeName:Gm.ZodSymbol,...Nw(e)});var ntn=class extends Fw{_parse(t){if(this._getType(t)!==av.undefined){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.undefined,received:n.parsedType}),bO}return LX(t.data)}};ntn.create=e=>new ntn({typeName:Gm.ZodUndefined,...Nw(e)});var itn=class extends Fw{_parse(t){if(this._getType(t)!==av.null){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.null,received:n.parsedType}),bO}return LX(t.data)}};itn.create=e=>new itn({typeName:Gm.ZodNull,...Nw(e)});var $3r=class extends Fw{constructor(){super(...arguments),this._any=!0}_parse(t){return LX(t.data)}};$3r.create=e=>new $3r({typeName:Gm.ZodAny,...Nw(e)});var ASr=class extends Fw{constructor(){super(...arguments),this._unknown=!0}_parse(t){return LX(t.data)}};ASr.create=e=>new ASr({typeName:Gm.ZodUnknown,...Nw(e)});var A2t=class extends Fw{_parse(t){let r=this._getOrReturnCtx(t);return qy(r,{code:W_.invalid_type,expected:av.never,received:r.parsedType}),bO}};A2t.create=e=>new A2t({typeName:Gm.ZodNever,...Nw(e)});var uNn=class extends Fw{_parse(t){if(this._getType(t)!==av.undefined){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.void,received:n.parsedType}),bO}return LX(t.data)}};uNn.create=e=>new uNn({typeName:Gm.ZodVoid,...Nw(e)});var MSr=class e extends Fw{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==av.array)return qy(r,{code:W_.invalid_type,expected:av.array,received:r.parsedType}),bO;if(i.exactLength!==null){let u=r.data.length>i.exactLength.value,f=r.data.length<i.exactLength.value;(u||f)&&(qy(r,{code:u?W_.too_big:W_.too_small,minimum:f?i.exactLength.value:void 0,maximum:u?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(qy(r,{code:W_.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(qy(r,{code:W_.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((u,f)=>i.type._parseAsync(new zxe(r,u,r.path,f)))).then(u=>pG.mergeArray(n,u));let a=[...r.data].map((u,f)=>i.type._parseSync(new zxe(r,u,r.path,f)));return pG.mergeArray(n,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:Yb.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:Yb.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:Yb.toString(r)}})}nonempty(t){return this.min(1,t)}};MSr.create=(e,t)=>new MSr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Gm.ZodArray,...Nw(t)});function nNn(e){if(e instanceof Ine){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Ixe.create(nNn(n))}return new Ine({...e._def,shape:()=>t})}else return e instanceof MSr?new MSr({...e._def,type:nNn(e.element)}):e instanceof Ixe?Ixe.create(nNn(e.unwrap())):e instanceof N8t?N8t.create(nNn(e.unwrap())):e instanceof z8t?z8t.create(e.items.map(t=>nNn(t))):e}var Ine=class e extends Fw{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=MM.objectKeys(t);return this._cached={shape:t,keys:r}}_parse(t){if(this._getType(t)!==av.object){let c=this._getOrReturnCtx(t);return qy(c,{code:W_.invalid_type,expected:av.object,received:c.parsedType}),bO}let{status:n,ctx:i}=this._processInputParams(t),{shape:a,keys:u}=this._getCached(),f=[];if(!(this._def.catchall instanceof A2t&&this._def.unknownKeys==="strip"))for(let c in i.data)u.includes(c)||f.push(c);let d=[];for(let c of u){let o=a[c],l=i.data[c];d.push({key:{status:"valid",value:c},value:o._parse(new zxe(i,l,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof A2t){let c=this._def.unknownKeys;if(c==="passthrough")for(let o of f)d.push({key:{status:"valid",value:o},value:{status:"valid",value:i.data[o]}});else if(c==="strict")f.length>0&&(qy(i,{code:W_.unrecognized_keys,keys:f}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let o of f){let l=i.data[o];d.push({key:{status:"valid",value:o},value:c._parse(new zxe(i,l,i.path,o)),alwaysSet:o in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let o of d){let l=await o.key,m=await o.value;c.push({key:l,value:m,alwaysSet:o.alwaysSet})}return c}).then(c=>pG.mergeObjectSync(n,c)):pG.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(t){return Yb.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{var i,a,u,f;let d=(u=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&u!==void 0?u:n.defaultError;return r.code==="unrecognized_keys"?{message:(f=Yb.errToObj(t).message)!==null&&f!==void 0?f:d}:{message:d}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Gm.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};return MM.objectKeys(t).forEach(n=>{t[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new e({...this._def,shape:()=>r})}omit(t){let r={};return MM.objectKeys(this.shape).forEach(n=>{t[n]||(r[n]=this.shape[n])}),new e({...this._def,shape:()=>r})}deepPartial(){return nNn(this)}partial(t){let r={};return MM.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}),new e({...this._def,shape:()=>r})}required(t){let r={};return MM.objectKeys(this.shape).forEach(n=>{if(t&&!t[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Ixe;)a=a._def.innerType;r[n]=a}}),new e({...this._def,shape:()=>r})}keyof(){return U6f(MM.objectKeys(this.shape))}};Ine.create=(e,t)=>new Ine({shape:()=>e,unknownKeys:"strip",catchall:A2t.create(),typeName:Gm.ZodObject,...Nw(t)});Ine.strictCreate=(e,t)=>new Ine({shape:()=>e,unknownKeys:"strict",catchall:A2t.create(),typeName:Gm.ZodObject,...Nw(t)});Ine.lazycreate=(e,t)=>new Ine({shape:e,unknownKeys:"strip",catchall:A2t.create(),typeName:Gm.ZodObject,...Nw(t)});var atn=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(a){for(let f of a)if(f.result.status==="valid")return f.result;for(let f of a)if(f.result.status==="dirty")return r.common.issues.push(...f.ctx.common.issues),f.result;let u=a.map(f=>new Bwe(f.ctx.common.issues));return qy(r,{code:W_.invalid_union,unionErrors:u}),bO}if(r.common.async)return Promise.all(n.map(async a=>{let u={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:u}),ctx:u}})).then(i);{let a,u=[];for(let d of n){let c={...r,common:{...r.common,issues:[]},parent:null},o=d._parseSync({data:r.data,path:r.path,parent:c});if(o.status==="valid")return o;o.status==="dirty"&&!a&&(a={result:o,ctx:c}),c.common.issues.length&&u.push(c.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let f=u.map(d=>new Bwe(d));return qy(r,{code:W_.invalid_union,unionErrors:f}),bO}}get options(){return this._def.options}};atn.create=(e,t)=>new atn({options:e,typeName:Gm.ZodUnion,...Nw(t)});var ESr=e=>e instanceof utn?ESr(e.schema):e instanceof Iwe?ESr(e.innerType()):e instanceof stn?[e.value]:e instanceof ctn?e.options:e instanceof ltn?MM.objectValues(e.enum):e instanceof ftn?ESr(e._def.innerType):e instanceof ntn?[void 0]:e instanceof itn?[null]:e instanceof Ixe?[void 0,...ESr(e.unwrap())]:e instanceof N8t?[null,...ESr(e.unwrap())]:e instanceof Yvi||e instanceof ptn?ESr(e.unwrap()):e instanceof dtn?ESr(e._def.innerType):[],Uwa=class e extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==av.object)return qy(r,{code:W_.invalid_type,expected:av.object,received:r.parsedType}),bO;let n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(qy(r,{code:W_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),bO)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let a of r){let u=ESr(a.shape[t]);if(!u.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let f of u){if(i.has(f))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(f)}`);i.set(f,a)}}return new e({typeName:Gm.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Nw(n)})}};function Eju(e,t){let r=Q3r(e),n=Q3r(t);if(e===t)return{valid:!0,data:e};if(r===av.object&&n===av.object){let i=MM.objectKeys(t),a=MM.objectKeys(e).filter(f=>i.indexOf(f)!==-1),u={...e,...t};for(let f of a){let d=Eju(e[f],t[f]);if(!d.valid)return{valid:!1};u[f]=d.data}return{valid:!0,data:u}}else if(r===av.array&&n===av.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let a=0;a<e.length;a++){let u=e[a],f=t[a],d=Eju(u,f);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return r===av.date&&n===av.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var otn=class extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(a,u)=>{if(Dju(a)||Dju(u))return bO;let f=Eju(a.value,u.value);return f.valid?((Sju(a)||Sju(u))&&r.dirty(),{status:r.value,value:f.data}):(qy(n,{code:W_.invalid_intersection_types}),bO)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,u])=>i(a,u)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};otn.create=(e,t,r)=>new otn({left:e,right:t,typeName:Gm.ZodIntersection,...Nw(r)});var z8t=class e extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.array)return qy(n,{code:W_.invalid_type,expected:av.array,received:n.parsedType}),bO;if(n.data.length<this._def.items.length)return qy(n,{code:W_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),bO;!this._def.rest&&n.data.length>this._def.items.length&&(qy(n,{code:W_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((u,f)=>{let d=this._def.items[f]||this._def.rest;return d?d._parse(new zxe(n,u,n.path,f)):null}).filter(u=>!!u);return n.common.async?Promise.all(a).then(u=>pG.mergeArray(r,u)):pG.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};z8t.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z8t({items:e,typeName:Gm.ZodTuple,rest:null,...Nw(t)})};var Vwa=class e extends Fw{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.object)return qy(n,{code:W_.invalid_type,expected:av.object,received:n.parsedType}),bO;let i=[],a=this._def.keyType,u=this._def.valueType;for(let f in n.data)i.push({key:a._parse(new zxe(n,f,n.path,f)),value:u._parse(new zxe(n,n.data[f],n.path,f)),alwaysSet:f in n.data});return n.common.async?pG.mergeObjectAsync(r,i):pG.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof Fw?new e({keyType:t,valueType:r,typeName:Gm.ZodRecord,...Nw(n)}):new e({keyType:G3r.create(),valueType:t,typeName:Gm.ZodRecord,...Nw(r)})}},sNn=class extends Fw{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.map)return qy(n,{code:W_.invalid_type,expected:av.map,received:n.parsedType}),bO;let i=this._def.keyType,a=this._def.valueType,u=[...n.data.entries()].map(([f,d],c)=>({key:i._parse(new zxe(n,f,n.path,[c,"key"])),value:a._parse(new zxe(n,d,n.path,[c,"value"]))}));if(n.common.async){let f=new Map;return Promise.resolve().then(async()=>{for(let d of u){let c=await d.key,o=await d.value;if(c.status==="aborted"||o.status==="aborted")return bO;(c.status==="dirty"||o.status==="dirty")&&r.dirty(),f.set(c.value,o.value)}return{status:r.value,value:f}})}else{let f=new Map;for(let d of u){let c=d.key,o=d.value;if(c.status==="aborted"||o.status==="aborted")return bO;(c.status==="dirty"||o.status==="dirty")&&r.dirty(),f.set(c.value,o.value)}return{status:r.value,value:f}}}};sNn.create=(e,t,r)=>new sNn({valueType:t,keyType:e,typeName:Gm.ZodMap,...Nw(r)});var cNn=class e extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.set)return qy(n,{code:W_.invalid_type,expected:av.set,received:n.parsedType}),bO;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(qy(n,{code:W_.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(qy(n,{code:W_.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let a=this._def.valueType;function u(d){let c=new Set;for(let o of d){if(o.status==="aborted")return bO;o.status==="dirty"&&r.dirty(),c.add(o.value)}return{status:r.value,value:c}}let f=[...n.data.values()].map((d,c)=>a._parse(new zxe(n,d,n.path,c)));return n.common.async?Promise.all(f).then(d=>u(d)):u(f)}min(t,r){return new e({...this._def,minSize:{value:t,message:Yb.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:Yb.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};cNn.create=(e,t)=>new cNn({valueType:e,minSize:null,maxSize:null,typeName:Gm.ZodSet,...Nw(t)});var Wwa=class e extends Fw{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==av.function)return qy(r,{code:W_.invalid_type,expected:av.function,received:r.parsedType}),bO;function n(f,d){return Rwa({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Fwa(),aNn].filter(c=>!!c),issueData:{code:W_.invalid_arguments,argumentsError:d}})}function i(f,d){return Rwa({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Fwa(),aNn].filter(c=>!!c),issueData:{code:W_.invalid_return_type,returnTypeError:d}})}let a={errorMap:r.common.contextualErrorMap},u=r.data;if(this._def.returns instanceof K3r){let f=this;return LX(async function(...d){let c=new Bwe([]),o=await f._def.args.parseAsync(d,a).catch(O=>{throw c.addIssue(n(d,O)),c}),l=await Reflect.apply(u,this,o);return await f._def.returns._def.type.parseAsync(l,a).catch(O=>{throw c.addIssue(i(l,O)),c})})}else{let f=this;return LX(function(...d){let c=f._def.args.safeParse(d,a);if(!c.success)throw new Bwe([n(d,c.error)]);let o=Reflect.apply(u,this,c.data),l=f._def.returns.safeParse(o,a);if(!l.success)throw new Bwe([i(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:z8t.create(t).rest(ASr.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||z8t.create([]).rest(ASr.create()),returns:r||ASr.create(),typeName:Gm.ZodFunction,...Nw(n)})}},utn=class extends Fw{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};utn.create=(e,t)=>new utn({getter:e,typeName:Gm.ZodLazy,...Nw(t)});var stn=class extends Fw{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return qy(r,{received:r.data,code:W_.invalid_literal,expected:this._def.value}),bO}return{status:"valid",value:t.data}}get value(){return this._def.value}};stn.create=(e,t)=>new stn({value:e,typeName:Gm.ZodLiteral,...Nw(t)});function U6f(e,t){return new ctn({values:e,typeName:Gm.ZodEnum,...Nw(t)})}var ctn=class e extends Fw{constructor(){super(...arguments),Qvi.set(this,void 0)}_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return qy(r,{expected:MM.joinValues(n),received:r.parsedType,code:W_.invalid_type}),bO}if(Lwa(this,Qvi,"f")||N6f(this,Qvi,new Set(this._def.values),"f"),!Lwa(this,Qvi,"f").has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return qy(r,{received:r.data,code:W_.invalid_enum_value,options:n}),bO}return LX(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Qvi=new WeakMap;ctn.create=U6f;var ltn=class extends Fw{constructor(){super(...arguments),Gvi.set(this,void 0)}_parse(t){let r=MM.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==av.string&&n.parsedType!==av.number){let i=MM.objectValues(r);return qy(n,{expected:MM.joinValues(i),received:n.parsedType,code:W_.invalid_type}),bO}if(Lwa(this,Gvi,"f")||N6f(this,Gvi,new Set(MM.getValidEnumValues(this._def.values)),"f"),!Lwa(this,Gvi,"f").has(t.data)){let i=MM.objectValues(r);return qy(n,{received:n.data,code:W_.invalid_enum_value,options:i}),bO}return LX(t.data)}get enum(){return this._def.values}};Gvi=new WeakMap;ltn.create=(e,t)=>new ltn({values:e,typeName:Gm.ZodNativeEnum,...Nw(t)});var K3r=class extends Fw{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==av.promise&&r.common.async===!1)return qy(r,{code:W_.invalid_type,expected:av.promise,received:r.parsedType}),bO;let n=r.parsedType===av.promise?r.data:Promise.resolve(r.data);return LX(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};K3r.create=(e,t)=>new K3r({type:e,typeName:Gm.ZodPromise,...Nw(t)});var Iwe=class extends Fw{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Gm.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:u=>{qy(n,u),u.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let u=i.transform(n.data,a);if(n.common.async)return Promise.resolve(u).then(async f=>{if(r.value==="aborted")return bO;let d=await this._def.schema._parseAsync({data:f,path:n.path,parent:n});return d.status==="aborted"?bO:d.status==="dirty"||r.value==="dirty"?iNn(d.value):d});{if(r.value==="aborted")return bO;let f=this._def.schema._parseSync({data:u,path:n.path,parent:n});return f.status==="aborted"?bO:f.status==="dirty"||r.value==="dirty"?iNn(f.value):f}}if(i.type==="refinement"){let u=f=>{let d=i.refinement(f,a);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(n.common.async===!1){let f=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return f.status==="aborted"?bO:(f.status==="dirty"&&r.dirty(),u(f.value),{status:r.value,value:f.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(f=>f.status==="aborted"?bO:(f.status==="dirty"&&r.dirty(),u(f.value).then(()=>({status:r.value,value:f.value}))))}if(i.type==="transform")if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!$vi(u))return u;let f=i.transform(u.value,a);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:f}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>$vi(u)?Promise.resolve(i.transform(u.value,a)).then(f=>({status:r.value,value:f})):u);MM.assertNever(i)}};Iwe.create=(e,t,r)=>new Iwe({schema:e,typeName:Gm.ZodEffects,effect:t,...Nw(r)});Iwe.createWithPreprocess=(e,t,r)=>new Iwe({schema:t,effect:{type:"preprocess",transform:e},typeName:Gm.ZodEffects,...Nw(r)});var Ixe=class extends Fw{_parse(t){return this._getType(t)===av.undefined?LX(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Ixe.create=(e,t)=>new Ixe({innerType:e,typeName:Gm.ZodOptional,...Nw(t)});var N8t=class extends Fw{_parse(t){return this._getType(t)===av.null?LX(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};N8t.create=(e,t)=>new N8t({innerType:e,typeName:Gm.ZodNullable,...Nw(t)});var ftn=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===av.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ftn.create=(e,t)=>new ftn({innerType:e,typeName:Gm.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Nw(t)});var dtn=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Kvi(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Bwe(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Bwe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};dtn.create=(e,t)=>new dtn({innerType:e,typeName:Gm.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Nw(t)});var lNn=class extends Fw{_parse(t){if(this._getType(t)!==av.nan){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.nan,received:n.parsedType}),bO}return{status:"valid",value:t.data}}};lNn.create=e=>new lNn({typeName:Gm.ZodNaN,...Nw(e)});var Tiw=Symbol("zod_brand"),Yvi=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Xvi=class e extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?bO:a.status==="dirty"?(r.dirty(),iNn(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?bO:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:Gm.ZodPipeline})}},ptn=class extends Fw{_parse(t){let r=this._def.innerType._parse(t),n=i=>($vi(i)&&(i.value=Object.freeze(i.value)),i);return Kvi(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};ptn.create=(e,t)=>new ptn({innerType:e,typeName:Gm.ZodReadonly,...Nw(t)});function V6f(e,t={},r){return e?$3r.create().superRefine((n,i)=>{var a,u;if(!e(n)){let f=typeof t=="function"?t(n):typeof t=="string"?{message:t}:t,d=(u=(a=f.fatal)!==null&&a!==void 0?a:r)!==null&&u!==void 0?u:!0,c=typeof f=="string"?{message:f}:f;i.addIssue({code:"custom",...c,fatal:d})}}):$3r.create()}var xiw={object:Ine.lazycreate},Gm;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Gm||(Gm={}));var qiw=(e,t={message:`Input not instance of ${e.name}`})=>V6f(r=>r instanceof e,t),W6f=G3r.create,H6f=ken.create,Ciw=lNn.create,Biw=etn.create,J6f=ttn.create,Iiw=rtn.create,ziw=oNn.create,Niw=ntn.create,Fiw=itn.create,Riw=$3r.create,Liw=ASr.create,Uiw=A2t.create,Viw=uNn.create,Wiw=MSr.create,Hiw=Ine.create,Jiw=Ine.strictCreate,Qiw=atn.create,Giw=Uwa.create,$iw=otn.create,Kiw=z8t.create,Yiw=Vwa.create,Xiw=sNn.create,Ziw=cNn.create,kiw=Wwa.create,eaw=utn.create,taw=stn.create,raw=ctn.create,naw=ltn.create,iaw=K3r.create,I6f=Iwe.create,aaw=Ixe.create,oaw=N8t.create,uaw=Iwe.createWithPreprocess,saw=Xvi.create,caw=()=>W6f().optional(),law=()=>H6f().optional(),faw=()=>J6f().optional(),daw={string:e=>G3r.create({...e,coerce:!0}),number:e=>ken.create({...e,coerce:!0}),boolean:e=>ttn.create({...e,coerce:!0}),bigint:e=>etn.create({...e,coerce:!0}),date:e=>rtn.create({...e,coerce:!0})},paw=bO,zwe=Object.freeze({__proto__:null,defaultErrorMap:aNn,setErrorMap:piw,getErrorMap:Fwa,makeIssue:Rwa,EMPTY_PATH:_iw,addIssueToContext:qy,ParseStatus:pG,INVALID:bO,DIRTY:iNn,OK:LX,isAborted:Dju,isDirty:Sju,isValid:$vi,isAsync:Kvi,get util(){return MM},get objectUtil(){return wju},ZodParsedType:av,getParsedType:Q3r,ZodType:Fw,datetimeRegex:L6f,ZodString:G3r,ZodNumber:ken,ZodBigInt:etn,ZodBoolean:ttn,ZodDate:rtn,ZodSymbol:oNn,ZodUndefined:ntn,ZodNull:itn,ZodAny:$3r,ZodUnknown:ASr,ZodNever:A2t,ZodVoid:uNn,ZodArray:MSr,ZodObject:Ine,ZodUnion:atn,ZodDiscriminatedUnion:Uwa,ZodIntersection:otn,ZodTuple:z8t,ZodRecord:Vwa,ZodMap:sNn,ZodSet:cNn,ZodFunction:Wwa,ZodLazy:utn,ZodLiteral:stn,ZodEnum:ctn,ZodNativeEnum:ltn,ZodPromise:K3r,ZodEffects:Iwe,ZodTransformer:Iwe,ZodOptional:Ixe,ZodNullable:N8t,ZodDefault:ftn,ZodCatch:dtn,ZodNaN:lNn,BRAND:Tiw,ZodBranded:Yvi,ZodPipeline:Xvi,ZodReadonly:ptn,custom:V6f,Schema:Fw,ZodSchema:Fw,late:xiw,get ZodFirstPartyTypeKind(){return Gm},coerce:daw,any:Riw,array:Wiw,bigint:Biw,boolean:J6f,date:Iiw,discriminatedUnion:Giw,effect:I6f,enum:raw,function:kiw,instanceof:qiw,intersection:$iw,lazy:eaw,literal:taw,map:Xiw,nan:Ciw,nativeEnum:naw,never:Uiw,null:Fiw,nullable:oaw,number:H6f,object:Hiw,oboolean:faw,onumber:law,optional:aaw,ostring:caw,pipeline:saw,preprocess:uaw,promise:iaw,record:Yiw,set:Ziw,strictObject:Jiw,string:W6f,symbol:ziw,transformer:I6f,tuple:Kiw,undefined:Niw,union:Qiw,unknown:Liw,void:Viw,NEVER:paw,ZodIssueCode:W_,quotelessJson:diw,ZodError:Bwe});var _aw=zwe.object({lang:zwe.string(),label:zwe.optional(zwe.string()),source:zwe.string()}),Aju=zwe.array(_aw);var Q6f={README_EXT:"x-readme"};function haw(e){if(!Array.isArray(e))return!1;for(let t of e)if(!bD(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function G6f(e){let t=B_(e,Q6f.README_EXT);if(!bD(t))return[];let r=t["code-samples"];if(!haw(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function $6f(e,t,r){let n=B_(t,wh.EXAMPLES)??[],i=Lhi(t,Swe.REDOCLY_CODE_SAMPLES_KEBAB,Aju,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],u=[...Lhi(t,Swe.REDOCLY_CODE_SAMPLES_CAMEL,Aju,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...i];u.length>0&&n.push({"code-samples":u.map(d=>({name:d.label??d.lang,language:d.lang,code:d.source,install:void 0,docs:void 0}))});let f=G6f(t);return f.length>0&&n.push({"code-samples":f}),n.map(_2t.unknown)}function K6f(e){let t=B_(e,wh.AVAILABILITY);if(t==="ga"||t==="generally-available")return pW.GenerallyAvailable;if(t==="beta"||t==="pre-release")return pW.Beta;if(t==="deprecated")return pW.Deprecated;if(e.deprecated)return pW.Deprecated}function Hwa(e){return{url:yaw({url:e.url,variables:e.variables??{}}),description:e.description,name:vaw(e),audiences:B_(e,wh.AUDIENCES)}}function yaw({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,i);return e}function vaw(e){let t=B_(e,[wh.SERVER_NAME_V1,wh.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function Y6f(e){return B_(e,wh.PARAMETER_NAME)}function X6f(e){return B_(e,wh.SDK_VARIABLE)}function Jwa({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let f of r){let d=B_(f,wh.IGNORE);if(d!=null&&d){n.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let c=Kh(f)?n.resolveParameterReference(f):f,o=c.required??!1,l=Pxe(c),m=[...i,c.name],O=v8(m),j=c.schema!=null?aP(c.schema,!o,n,m,a,n.namespace,!1,new Set,lSr({schema:c,logger:n.logger})):o?Op.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:lSr({schema:c,logger:n.logger})}),description:void 0,availability:l,groupName:void 0}):Op.optional({nameOverride:void 0,generatedName:O,title:void 0,value:Op.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:lSr({schema:c,logger:n.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:l,groupName:void 0});if(c.in==="header"&&c.schema!=null&&!Kh(c.schema)&&c.schema.default!=null){let T=c.schema.default;typeof T=="string"&&T.length>0&&(j=Op.literal({nameOverride:void 0,generatedName:O,title:void 0,value:_I.string(T),description:void 0,availability:l,groupName:void 0}))}let A={name:c.name,schema:j,description:c.description,parameterNameOverride:Y6f(c),availability:l,source:a};c.in==="query"?u.queryParameters.push(A):c.in==="path"?u.pathParameters.push({...A,variableReference:X6f(c)}):c.in==="header"?!baw.has(c.name.toLowerCase())&&!n.authHeaders.has(c.name)?u.headers.push({...A,env:void 0}):n.logger.debug(`Ignoring ${c.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${c.in} parameter, ${c.name}, in ${t.toUpperCase()} ${e}`)}return u}var baw=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function Z6f(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r,schema:i??{},examples:Zvi(n,t)}}}function fNn(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r.includes("*")?void 0:r,schema:i??{},examples:Zvi(n,t)}}}function k6f(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:Zvi(n,t)}}}function Zvi(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=B_(e,Swe.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let u=Kh(a)?t.resolveExampleReference(a):a;return{name:u.summary??i,value:u.value,description:u.description}})),r}function gaw(e,t){for(let[r,n]of Object.entries(e.content))if(eI.parse(r)?.isURLEncoded())return{schema:n.schema,contentType:r,examples:Zvi(n,t)}}function maw(e){for(let[t,r]of Object.entries(e.content))if(eI.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function Oaw(e){for(let t in e.content)if(eI.parse(t)?.isOctetStream())return!0;return!1}function Paw(e,t){let r=Kh(e)?Mju(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!Kh(i)&&i.type==="string"&&i.format==="binary")!=null}function dNn({requestBody:e,document:t,context:r,requestBreadcrumbs:n,source:i,namespace:a}){let u=Kh(e)?r.resolveRequestBodyReference(e):e,f=maw(u),d=f?.schema,c=f?.encoding,o=gaw(u,r),l=fNn(u.content,r);if(o!=null&&o.schema!=null){let O=aP(o.schema,!1,r,n,i,a);return Dwe.json({schema:O,description:u.description,contentType:o.contentType,source:i,fullExamples:o.examples,additionalProperties:!1})}if(Oaw(u))return Dwe.octetStream({description:u.description,source:i});if(d!=null&&l==null||d!=null&&Paw(d,t)){let O=Kh(d)?Mju(d,t):{id:void 0,schema:d},j=aP(O.schema,!1,r,n,i,a),A=[];if(j.type==="object")for(let T of j.properties){if(T.schema.type==="primitive"&&T.schema.schema.type==="string"&&T.schema.schema.format==="binary"){A.push({key:T.key,schema:Oxe.file({isOptional:!1,isArray:!1}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}if(T.schema.type==="optional"&&T.schema.value.type==="primitive"&&T.schema.value.schema.type==="string"&&T.schema.value.schema.format==="binary"){A.push({key:T.key,schema:Oxe.file({isOptional:!0,isArray:!1}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}if(T.schema.type==="array"&&T.schema.value.type==="primitive"&&T.schema.value.schema.type==="string"&&T.schema.value.schema.format==="binary"){A.push({key:T.key,schema:Oxe.file({isOptional:!1,isArray:!0}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}if(T.schema.type==="optional"&&T.schema.value.type==="array"&&T.schema.value.value.type==="primitive"&&T.schema.value.value.schema.type==="string"&&T.schema.value.value.schema.format==="binary"){A.push({key:T.key,schema:Oxe.file({isOptional:!0,isArray:!0}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}A.push({key:T.key,schema:Oxe.json(T.schema),description:void 0,contentType:c?.[T.key]?.contentType})}return Dwe.multipart({name:Kh(d)&&r.getNumberOfOccurrencesForRef(d)===1?O.id:void 0,description:O.schema.description,properties:A,source:i})}if(l==null)return;let m=aP(l.schema,!1,r,n,i,a,!0);return Dwe.json({description:void 0,schema:m,contentType:l.contentType,fullExamples:l.examples,additionalProperties:!Kh(l.schema)&&B7n(l.schema.additionalProperties),source:i})}function Mju(e,t){if(!e.$ref.startsWith(uen))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=e3r(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=t.components?.schemas?.[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return Kh(n)?Mju(n,t):{id:r,schema:n}}var Tju={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},e3f=new Set(Object.values(Tju));var jaw=["200","201","202","204"];function r3f({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let f=waw({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,c;for(let o of i!=null?[i]:jaw){let l=t[o];l!=null&&(d=!0,c==null&&(c=t3f({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})))}if(c==null&&!d&&t.default!=null&&(c=t3f({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})),c!=null)switch(c.type){case"json":return{value:c,errors:f};case"streamingJson":case"streamingSse":return{value:c,errors:f};case"file":case"text":case"streamingText":return{value:c,errors:f};default:hc(c)}return{value:void 0,errors:f}}function t3f({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:u}){let f=Kh(r)?n.resolveResponseReference(r):r;if(f.content!=null&&Object.entries(f.content).find(([l,m])=>{if(m.schema==null)return!1;let O=Kh(m.schema)?n.resolveSchemaReference(m.schema):m.schema;return O.type==="string"&&O.format==="binary"}))return hI.file({description:f.description,source:a});let d=Z6f(f.content??{},n);if(d!=null&&t!=null)switch(t){case"json":return hI.streamingJson({description:f.description,responseProperty:B_(e.operation,wh.RESPONSE_PROPERTY),fullExamples:d.examples,schema:aP(d.schema,!1,n,i,a,u),source:a});case"sse":return hI.streamingSse({description:f.description,responseProperty:void 0,schema:mx(aP(d.schema,!1,n,i,a,u)),source:a})}let c=fNn(f.content??{},n);if(c!=null){if(t!=null)switch(t){case"json":return hI.streamingJson({description:f.description,responseProperty:void 0,fullExamples:c.examples,schema:aP(c.schema,!1,n,i,a,u),source:a});case"sse":return hI.streamingSse({description:f.description,responseProperty:void 0,schema:mx(aP(c.schema,!1,n,i,a,u)),source:a})}return hI.json({description:f.description,schema:aP(c.schema,!1,n,i,a,u),responseProperty:B_(e.operation,wh.RESPONSE_PROPERTY),fullExamples:c.examples,source:a})}for(let[o,l]of Object.entries(f.content??{})){let m=eI.parse(o);if(m!=null){if(m.isOctetStream()||m.isPDF()||m.isAudio()||m.isImage()||m.isVideo())return hI.file({description:f.description,source:a});if(m.isPlainText()){let O=l.schema;if(O==null)return hI.text({description:f.description,source:a});let j=Kh(O)?n.resolveSchemaReference(O):O;return j.type==="string"&&j.format==="byte"?hI.file({description:f.description,source:a}):hI.text({description:f.description,source:a})}}}}function waw({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let f=parseInt(a);if(f<400||f>600)continue;let d=Kh(u)?t.resolveResponseReference(u):u,c=k6f(d.content??{},t),o=Tju[f];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[f]={statusCode:f,nameOverride:void 0,generatedName:o,description:d.description,schema:aP(c?.schema??{},!1,t,[o,"Body"],r,n),fullExamples:c?.examples,source:r}}return i}function TSr({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:u,operation:f,path:d,method:c,baseBreadcrumbs:o,sdkMethodName:l}=e,m=B_(f,wh.IDEMPOTENT),O=B_(f,[wh.REQUEST_NAME_V1,wh.REQUEST_NAME_V2]),j=[...o,"Request"],A=Jwa({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:j,path:d,httpMethod:c,source:a}),T=f.requestBody!=null?dNn({requestBody:f.requestBody,document:u,context:new rNn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:j,source:a,namespace:t.namespace}):void 0;(A.queryParameters.length>0||A.headers.length>0)&&T!=null&&T.type==="json"&&T.schema.type!=="object"&&f.requestBody!=null?T=dNn({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j,"Body"],source:a,namespace:t.namespace}):f.requestBody!=null&&(T=dNn({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j],source:a,namespace:t.namespace}));let B=[...o,"Response"],F=r3f({operationContext:e,streamFormat:i,responses:f.responses,context:t,responseBreadcrumbs:B,responseStatusCode:r,source:a}),C=K6f(f),N=$6f(e,f,t),U=B_(f,wh.SERVER_NAME_V2);return{summary:f.summary,internal:B_(f,Swe.INTERNAL),idempotent:m,audiences:B_(f,wh.AUDIENCES)??[],operationId:f.operationId!=null&&n!=null?f.operationId+"_"+n:f.operationId,tags:t.resolveTagsToTagIds(f.tags),namespace:t.namespace,sdkName:l,pathParameters:A.pathParameters,queryParameters:A.queryParameters,headers:A.headers,requestNameOverride:O??void 0,generatedRequestName:v8(j),request:T,response:F.value,errors:F.errors,server:U!=null?[{name:U,url:void 0,audiences:void 0}]:(f.servers??[]).map(ne=>Hwa(ne)),description:f.description,authed:Daw(f,u),availability:C,method:c,path:d,examples:N,pagination:e.pagination,source:a}}function Daw(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function i3f({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:u}=e,f=r.discriminant.name,d=r.discriminant.value,c=r["response-status-code"],o=n3f({context:t,headerToIgnore:f,parameters:a}),l=n3f({context:t,headerToIgnore:f,parameters:u}),m=TSr({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([j])=>parseInt(j)!==c))}},context:t,streamFormat:void 0,source:n}),O=TSr({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:c,streamFormat:void 0,source:n});return O.headers.push({name:f,schema:Op.literal({nameOverride:void 0,generatedName:v8([f]),title:void 0,description:void 0,availability:void 0,value:_I.string(d),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n}),{sync:m,async:O}}function n3f({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=Kh(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var xju="stream";function s3f({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:TSr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let n=a3f({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(n?.schemaReference!=null){let c=e3r(n.schemaReference);c!=null&&t.excludeSchema(c)}let i=o3f({operation:e.operation,response:r.responseStream}),a=TSr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+xju}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:n?.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,xju]},context:t,streamFormat:r.format,suffix:xju,source:t.source});a.examples=a.examples.filter(c=>u3f(c,t)!==!1);let u=a3f({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),f=o3f({operation:e.operation,response:r.response}),d=TSr({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:f}},context:t,source:t.source});return d.examples=d.examples.filter(c=>u3f(c,t)!==!0),{streaming:a,nonStreaming:d}}default:hc(r)}}function a3f({context:e,operation:t,streamingExtension:r,isStreaming:n}){if(t.requestBody==null)return;let i=Kh(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=fNn(i.content,e);if(a==null)return;let u=Kh(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let f=u.properties?.[r.streamConditionProperty];f!=null&&Kh(f)&&(f=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...f??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[eI.APPLICATION_JSON]:{schema:d}}},schemaReference:Kh(a.schema)?a.schema:void 0}}function o3f({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[eI.APPLICATION_JSON]:{schema:t}}}}}function u3f(e,t){return e._visit({unknown:r=>{let n=Hre.serialization.ExampleEndpointCallSchema.parse(r);if(!n.ok){t.logger.error("Failed to parse example",n.errors.toString());return}if(n.value.response!=null)return n.value.response.stream!=null},full:()=>{},_other:()=>{}})}function c3f({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:u,baseBreadcrumbs:f,sdkMethodName:d}=t,c=[...f,"Payload"],o=Jwa({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:c,path:a,httpMethod:u,source:r});if(i.requestBody==null){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`);return}if(u!=="POST"&&u!=="GET"){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`);return}let l=dNn({requestBody:i.requestBody,document:n,context:e,requestBreadcrumbs:[...f,"Payload"],source:r,namespace:e.namespace});if(l==null||l.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(i.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:i.summary,sdkName:d,namespace:e.namespace,method:u,operationId:i.operationId,tags:e.resolveTagsToTagIds(i.tags),headers:o.headers,generatedPayloadName:v8(c),payload:l.schema,description:i.description,examples:Saw(l.fullExamples),source:r}}function Saw(e){if(e==null)return[];let t=[];for(let r of e){let n=t3r(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function qju({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=B_(r,wh.IGNORE);if(i!=null&&i){e.logger.info(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=Eaw(r,e),u=A6f(e.document,r),f={...t,sdkMethodName:a,baseBreadcrumbs:Aaw({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(n){let l=c3f({context:e,operationContext:f,source:e.source});return l!=null?{type:"webhook",value:l}:void 0}let d=S6f(r);if(d!=null){let l=s3f({context:e,operationContext:f,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let c=w6f(r);if(c!=null){let l=i3f({context:e,operationContext:f,asyncExtension:c,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:TSr({context:e,operationContext:f,streamFormat:void 0,source:e.source})}}function Eaw(e,t){let r=B_(e,wh.SDK_METHOD_NAME),n=B_(e,wh.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function Aaw({sdkMethodName:e,operation:t,httpMethod:r,path:n}){let i=[];if(e!=null){if(e.groupName.length>0){let a=e.groupName[e.groupName.length-1];a!=null&&i.push(typeof a=="string"?a:a.name)}i.push(e.methodName)}else t.operationId!=null?i.push(t.operationId):i.push(mE(`${r}_${n.split("/").join("_")}`));return i}function l3f(e,t,r,n){let i=[],a=d3f(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=Maw({operation:f.operation}),c=qju({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:d});c!=null&&i.push(c)}return i}function f3f(e,t,r,n){let i=[],a=d3f(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=qju({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:!0});d!=null&&i.push(d)}return i}function d3f(e){let t=[];return e.get!=null&&t.push({method:tG.Get,operation:e.get}),e.post!=null&&t.push({method:tG.Post,operation:e.post}),e.put!=null&&t.push({method:tG.Put,operation:e.put}),e.delete!=null&&t.push({method:tG.Delete,operation:e.delete}),e.patch!=null&&t.push({method:tG.Patch,operation:e.patch}),t}function Maw({operation:e}){return B_(e,[wh.WEBHOOK])??!1}function p3f(e){let t=B_(e,wh.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=B_(e,wh.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function _3f(e){return B_(e,wh.FERN_BASIC_AUTH)}function Cju(e,t){if(Kh(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return Taw(e,t)}function Taw(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=B_(e,Swe.BEARER_FORMAT),n=B_(e,wh.FERN_HEADER_AUTH);return $9.header({headerName:e.name,prefix:r!=null?"Bearer":n?.prefix,headerVariableName:n?.name??B_(e,wh.HEADER_VARIABLE_NAME),headerEnvVar:n?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=B_(e,wh.FERN_BEARER_TOKEN);return $9.bearer({tokenVariableName:r?.name??B_(e,wh.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=_3f(e),n=p3f(e);return $9.basic({usernameVariableName:r?.username?.name??n.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??n.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return $9.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return $9.oauth({scopesEnum:xaw(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function xaw(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let n=k6r({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,u])=>[a,{description:u}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,groupName:void 0,context:void 0,source:t}),i=mx(n);if(i.type==="enum")return i}}function h3f(e){return B_(e,wh.BASE_PATH)}var qaw=zwe.record(zwe.string(),zwe.object({summary:zwe.string().optional(),description:zwe.string().optional()}));function y3f({document:e,context:t}){return Lhi(e,wh.GROUPS,qaw,t.logger)}function v3f({context:e,document:t}){return B_(t,wh.FERN_VERSION)??void 0}function b3f(e){let t=B_(e,wh.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?Uhi({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function g3f(e){let t=B_(e,wh.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?Uhi({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function m3f(e){let t=B_(e,wh.SDK_VARIABLES);return t==null?{}:Object.fromEntries(Object.entries(t).map(([r,n])=>{if(n.type==="string")return[r,{nameOverride:void 0,generatedName:v8([r]),title:n.title,schema:q1.string({default:R7n(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,groupName:void 0}];throw new Error(`Variable ${r} has unsupported schema ${JSON.stringify(n)}`)}))}var Caw="webhooks";function O3f(e){return B_(e,Caw)??{}}var Qwa=class extends tNn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discrminatedUnionReferences={};discrminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u})}getDummy(){return new rNn({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discrminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discrminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discrminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discrminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discrminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discrminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function P3f(e){return B_(e,wh.RESOLUTIONS)}function j3f({openapi:e}){let t=P3f(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=Baw({openapi:e,schemaReference:a,schemaName:n.name}),e=w3f({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(u=>[i,u]))}}return e}function Baw({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replace("~1","/")),i=e;for(let a of n){let u=i[a];if(u==null)return e;i=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function w3f({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,c)=>c.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let c=r.replace(i,d);return w3f({openapi:e,replaceReference:t,schemaReference:c,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replace("~1","/")),u=e;for(let d of a.slice(0,-1)){let c=u[d];if(c==null)return e;u=c}let f=a[a.length-1];return f==null||(u[f]={$ref:r}),e}function Gwa({openApi:e,taskContext:t,options:r,source:n,namespace:i}){e=j3f({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([X,k])=>Cju(k,n)==null?[]:[X,Cju(k,n)])),u=new Set(...Object.entries(a).map(([X,k])=>k.type==="basic"||k.type==="bearer"?"Authorization":k.type==="header"?k.headerName:null)),f=new Qwa({document:e,taskContext:t,authHeaders:u,options:r,source:n,namespace:i}),d=m3f(e),c=b3f(e),o=g3f(e),l=r.audiences??[],m=[],O=[];Object.entries(e.paths??{}).forEach(([X,k])=>{if(k==null)return;t.logger.debug(`Converting path ${X}`);let xe=l3f(X,k,e,f);for(let vt of xe){let yt=D3f({operation:vt});if(!(l.length>0&&!l.some(St=>yt.includes(St))))switch(vt.type){case"async":m.push(vt.sync),m.push(vt.async);break;case"http":m.push(vt.value);break;case"streaming":m.push(vt.streaming),vt.nonStreaming&&m.push(vt.nonStreaming);break;case"webhook":O.push(vt.value);break;default:hc(vt)}}}),Object.entries(O3f(e)).forEach(([X,k])=>{if(k==null)return;t.logger.debug(`Converting path ${X}`);let xe=f3f(X,k,e,f);for(let vt of xe){let yt=D3f({operation:vt});l.length>0&&!l.some(St=>yt.includes(St))||O.push(vt.value)}});let j=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([X,k])=>{if(!Kh(k)){let xe=B_(k,wh.IGNORE);if(xe!=null&&xe)return[];if(e3f.has(X))return[X,aP({...k,"x-fern-type-name":`${X}Body`},!1,f,[X],n,i)]}return[X,aP(k,!1,f,[X],n,i)]}).filter(X=>X.length>0)),A=Iaw(j,f,n),T=zaw(A,f),B={};for(let[X,k]of Object.entries(T)){let xe=mx(k);f.isSchemaExcluded(X)||(B[X]=xe,t.logger.debug(`Converted schema ${X}`))}let F=new r3r(T,f),C=O.map(X=>{let xe=X.examples;if(!r.disableExamples&&xe.length===0){let vt=F.buildExample({schema:X.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});vt!=null&&(xe=[{name:void 0,description:void 0,payload:vt}])}return{...X,payload:mx(X.payload),examples:xe}}),N=new mma(T,f),U=m.map(X=>{let k=X.examples,xe=k;if(!r.disableExamples&&(k.length===0||k.every(Jhi))){let St=N.buildEndpointExample(X);St.length>0&&(xe=[...St,...k.filter(Ft=>!Jhi(Ft))])}let vt=X.request,yt=X.response;return{...X,request:vt?.type==="json"?{...vt,schema:mx(vt.schema)}:vt,response:yt?.type==="json"?{...yt,schema:mx(yt.schema)}:yt,queryParameters:X.queryParameters.map(St=>({description:St.description,name:St.name,schema:mx(St.schema),parameterNameOverride:St.parameterNameOverride,availability:St.availability,source:St.source})),pathParameters:X.pathParameters.map(St=>({description:St.description,name:St.name,schema:mx(St.schema),parameterNameOverride:St.parameterNameOverride,variableReference:St.variableReference,availability:St.availability,source:St.source})),headers:X.headers.map(St=>({description:St.description,name:St.name,schema:mx(St.schema),parameterNameOverride:St.parameterNameOverride,env:St.env,availability:St.availability,source:St.source})),examples:xe,errors:Vh(X.errors,St=>{let Ft=St.fullExamples?.map(Zt=>{let Vt=t3r(Zt.value);if(Vt!=null)return{name:Zt.name,description:Zt.description,example:Vt}}).filter(YA);if(Ft?.length===0){let Zt=F.buildExample({schema:St.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Zt!=null&&Ft.push({name:void 0,description:void 0,example:Zt})}return{generatedName:St.generatedName,nameOverride:St.nameOverride,schema:mx(St.schema),description:St.description,source:St.source,examples:Ft}})}}),ne=y3f({document:e,context:f});return{apiVersion:v3f({context:f,document:e}),basePath:h3f(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(ne??{}).map(([X,k])=>[X,{summary:k.summary??void 0,description:k.description??void 0}])),servers:(e.servers??[]).map(X=>Hwa(X)),tags:{tagsById:Object.fromEntries((e.tags??[]).map(X=>[X.name,{id:X.name,description:X.description}])),orderedTagIds:e.tags?.map(X=>X.name)},endpoints:U,webhooks:C,channel:[],groupedSchemas:vma(i,B),securitySchemes:a,hasEndpointsMarkedInternal:U.some(X=>X.internal),nonRequestReferencedSchemas:f.getReferencedSchemas(),variables:d,globalHeaders:c,idempotencyHeaders:o}}function Iaw(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let u={$ref:`#/components/schemas/${i}`},f=t.getReferencesFromDiscriminatedUnion(u);if(f==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!f.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!f.discriminants.has(o.propertyKey)),source:r};n[i]=d;let c=S3f({schema:a,schemas:e});for(let o of[...new Set(c)]){let l=n[o]??e[o];l==null||l.type!=="object"||(n[o]={...l,type:"object",properties:l.properties.filter(m=>!f.discriminants.has(m.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(m=>!f.discriminants.has(m.propertyKey))})}}return n}function zaw(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[n]=i;continue}let f=[];for(let c of i.properties)if(u.discriminants.has(c.key)){let o=u.discriminants.get(c.key);o!=null&&f.push({...c,schema:Op.literal({nameOverride:void 0,generatedName:v8([i.generatedName,o]),title:void 0,value:_I.string(o),groupName:void 0,description:void 0,availability:i.availability})})}else f.push(c);let d={...i,type:"object",properties:f};r[n]=d}return r}function S3f({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...S3f({schema:i,schemas:t}))}return r}function D3f({operation:e}){let t=[];switch(e.type){case"async":t=e.async.audiences;break;case"http":t=e.value.audiences;break;case"streaming":t=e.streaming.audiences;break;case"webhook":break;default:hc(e)}return t}async function A3f({openApi:e,taskContext:t,options:r,source:n,namespace:i}){let a=await(0,E3f.convertObj)(e,{});return Gwa({openApi:a.openapi,taskContext:t,options:r,source:n,namespace:i})}var Y3r={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,cooerceEnumsToLiterals:!0,respectReadonlySchemas:!1};async function _tn({absoluteFilePathToWorkspace:e,specs:t,taskContext:r,optionOverrides:n}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channel:[],groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let a of t){let u=(await(0,Iju.readFile)(a.absoluteFilepath)).toString(),f=mC(e,a.source.file);a.source.relativePathToDependency!=null&&(f=Wl(a.source.relativePathToDependency,f));let d=a.source.type==="protobuf"?aSr.protobuf({file:f}):aSr.openapi({file:f});if(u.includes("openapi")||u.includes("swagger")){let c=await hIf({absolutePathToOpenAPI:a.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides});if(Raw(c)){let o=Gwa({openApi:c,taskContext:r,options:Bju({specSettings:a.settings,overrides:n}),source:d,namespace:a.namespace});i=M3f(i,o)}else if(Law(c)){let o=await A3f({openApi:c,taskContext:r,options:Bju({specSettings:a.settings}),source:d,namespace:a.namespace});i=M3f(i,o)}}else if(u.includes("asyncapi")){let c=await Faw({absoluteFilePathToAsyncAPI:a.absoluteFilepath,context:r,absoluteFilePathToAsyncAPIOverrides:a.absoluteFilepathToOverrides}),o=SSf({document:c,taskContext:r,options:Bju({specSettings:a.settings}),source:d,asyncApiOptions:Naw({specSettings:a.settings}),namespace:a.namespace});o.channel!=null&&i.channel.push(o.channel),o.groupedSchemas!=null&&(i.groupedSchemas=T3f(i.groupedSchemas,o.groupedSchemas)),o.basePath!=null&&(i.basePath=o.basePath)}else r.failAndThrow(`${a.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}function Bju({specSettings:e,overrides:t}){return{disableExamples:t?.disableExamples??Y3r.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.shouldUseUndiscriminatedUnionsWithLiterals??Y3r.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.shouldUseTitleAsName??Y3r.useTitlesAsName,audiences:t?.audiences??e?.audiences??Y3r.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??Y3r.optionalAdditionalProperties,cooerceEnumsToLiterals:t?.cooerceEnumsToLiterals??e?.cooerceEnumsToLiterals??Y3r.cooerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??Y3r.respectReadonlySchemas}}function Naw({specSettings:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??XDf.naming}}function M3f(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channel:[...e.channel,...t.channel],groupedSchemas:T3f(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}function T3f(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}async function Faw({absoluteFilePathToAsyncAPI:e,absoluteFilePathToAsyncAPIOverrides:t,context:r}){let n=(await(0,Iju.readFile)(e)).toString(),i=await Fy.load(n);return t!=null?await Tja({absoluteFilepathToOverrides:t,context:r,data:i}):i}function Raw(e){return e.openapi!=null}function Law(e){return e.swagger!=null}function Kwa({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=zju({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=gx(i.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!i.allowMultiple&&e.parameterNameOverride==null&&e.availability==null)return a;let u={type:a};return i.allowMultiple&&(u["allow-multiple"]=!0),e.description!=null&&(u.docs=e.description),e.parameterNameOverride!=null&&(u.name=e.parameterNameOverride),e.availability!=null&&(u.availability=gz(e.availability)),u}function zju({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,declarationFile:ls.of(mD),fileContainingReference:r,namespace:n}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undisciminated"){let a=[];for(let[u,f]of Object.entries(i.value.schemas))f.type==="literal"&&f.value.type==="string"&&(N7n.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:Vhi(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[u,f]=i.value.schemas;if(u!=null&&f!=null&&$wa({array:u,primitive:f}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(u!=null&&f!=null&&$wa({array:u,primitive:f}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[u,f]of Object.entries(i.value.schemas))return zju({schema:f,context:t,fileContainingReference:r,namespace:n})}else if(t.objectQueryParameters)return{value:qO({schema:e,context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let i=t.getSchema(e.value.schema,n);if(i==null)return;if(i.type==="array")return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!0};if(t.objectQueryParameters)return{value:qO({schema:e,context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!1}}if(e.value.type==="array")return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undisciminated"){let i=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(N7n.test(u.value.value)?i.push(u.value.value):i.push({value:u.value.value,name:Vhi(u.value.value)}));if(i.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:i}}),{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[a,u]=e.value.value.schemas;if(a!=null&&u!=null&&$wa({array:a,primitive:u}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(a!=null&&u!=null&&$wa({array:u,primitive:a}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return zju({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.objectQueryParameters?{value:qO({schema:e,context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!1}:void 0;return{value:qO({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}return e.type==="array"?{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}:{value:qO({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}function $wa({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function x3f({websocketExample:e,context:t}){let r={messages:[]};e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=Uaw(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=Vaw({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=X3r(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function Uaw(e){let t={};return e.forEach(r=>{let n=X3r(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function Vaw({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=X3r(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function X3r(e){switch(e.type){case"primitive":return q3f(e.value);case"object":return C3f(e.properties);case"array":return Waw(e.value);case"map":return Haw(e.value);case"oneOf":return Jaw(e.value);case"enum":return e.value;case"literal":return Qaw(e.value);case"unknown":return X3r(e.value);default:hc(e)}}function q3f(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:hc(e)}}function C3f(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,X3r(r)]))}function Waw(e){return e.map(t=>X3r(t))}function Haw(e){return Object.fromEntries(e.map(t=>[q3f(t.key),X3r(t.value)]))}function Jaw(e){return e.type==="discriminated"?C3f(e.value):X3r(e.value)}function Qaw(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:hc(e)}}function xSr(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function Ywa(e,t){return t??(e?.groupName!=null?xSr(e.groupName):void 0)}function B3f({channel:e,context:t,declarationFile:r}){let n={path:e.path,auth:!1};e.summary!=null&&(n["display-name"]=e.summary);let i=xSr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=cma({pathParameter:d,context:t,fileContainingReference:r,namespace:i});Object.keys(a).length>0&&(n["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let c=Kwa({queryParameter:d,context:t,fileContainingReference:r,namespace:i});c!=null&&(u[d.name]=c)}Object.keys(u).length>0&&(n["query-parameters"]=u);let f={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let c=v8t({header:d,context:t,fileContainingReference:r,namespace:i});f[d.name]=c}Object.keys(f).length>0&&(n.headers=f),t.builder.addChannel(r,{channel:n}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:qO({schema:e.subscribe,context:t,fileContainingReference:r,namespace:i})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:qO({schema:e.publish,context:t,fileContainingReference:r,namespace:i})}});for(let d of e.examples){let c=x3f({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:c})}}var I3f="Production",z3f="Default";function N3f(e){return Object.entries(e).reduce((t,[r,n])=>(Gqn(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function F3f(e){if(e.environmentOverrides!=null){for(let[f,d]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:f,schema:d});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[];for(let f of e.ir.servers){let d=f.audiences?{url:f.url,audiences:f.audiences}:f.url;if(f.name==null){r.push(d);continue}t[f.name]=d}let n={},i=[];for(let f of e.ir.endpoints)for(let d of f.server){if(d.url==null)continue;let c=d.audiences?{url:d.url,audiences:d.audiences}:d.url;if(d.name==null){i.push(c);continue}n[d.name]=c}let a=Object.keys(t).length,u=Object.keys(n).length;if(a===0&&u===0){let f=e.ir.servers[0]?.url,d=e.ir.servers[0]?.audiences;f!=null&&(e.builder.addEnvironment({name:z3f,schema:d?{url:f,audiences:d}:f}),e.builder.setDefaultEnvironment(z3f))}else if(a>0&&u===0){let f=0;r.length>0&&e.logger.error(`Skipping servers ${r.map(d=>typeof d=="string"?d:d.url).join(", ")} because x-fern-server-name was not provided.`);for(let[d,c]of Object.entries(t))f===0&&e.builder.setDefaultEnvironment(d),e.builder.addEnvironment({name:d,schema:c}),f+=1}else if(u>0){(r.length>0||i.length>0)&&e.logger.error(`Skipping servers ${[...r,...i].map(d=>typeof d=="string"?d:d.url).join(", ")} because x-fern-server-name was not provided.`);let f=Object.entries(t)[0];if(f!=null){let[d,c]=f;e.setDefaultServerName(d)}e.builder.addEnvironment({name:I3f,schema:{urls:{...N3f(t),...N3f(n)}}}),e.builder.setDefaultEnvironment(I3f)}}function Xwa(e){return gx(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var Nju=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},Gaw=.75,$aw=new Set("authorization");function R3f(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let i="optional<string>";if(n.name==null&&n.env==null&&typeof n.schema=="string")i=n.schema;else if(n!=null){let a=n.schema?q7n(n.schema):void 0,u=a!=null?xSr(a):void 0,f=ls.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?gx(qO({schema:n.schema,context:e,fileContainingReference:u?Wl(ls.of(mE(u)),f):f,namespace:u}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if($aw.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let f=t[a.name],d=v8t({header:{...a,schema:f?.schema??a.schema,name:f?.name??a.name},fileContainingReference:ls.of(eF),context:e,namespace:void 0});u=new Nju(d),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*Gaw;for(let[i,a]of Object.entries(r)){let u=t[i],f=a.count===e.ir.endpoints.length,d=a.count>=n;u==null&&(f?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:Xwa(a.schema)}))}}}function L3f(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?q7n(t.schema):void 0,n=r!=null?xSr(r):void 0,i=v8t({header:{...t,schema:t.schema??J0.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:q1.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0})}),name:t.name??t.header,parameterNameOverride:void 0,description:void 0,availability:void 0,source:void 0},fileContainingReference:ls.of(eF),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:Xwa(i)})}}function UX(e){switch(e.type){case"primitive":return V3f(e.value);case"object":return W3f(e.properties);case"array":return H3f(e.value);case"map":return Kaw(e.value);case"oneOf":return Yaw(e.value);case"enum":return e.value;case"literal":return Xaw(e.value);case"unknown":return UX(e.value);default:hc(e)}}function U3f(e){switch(e.type){case"withStreaming":return{stream:H3f(e.value)};case"withoutStreaming":return{body:UX(e.value)};default:hc(e)}}function V3f(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:hc(e)}}function W3f(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,UX(r)]))}function H3f(e){return e.map(t=>UX(t))}function Kaw(e){return Object.fromEntries(e.map(t=>[V3f(t.key),UX(t.value)]))}function Yaw(e){return e.type==="discriminated"?W3f(e.value):UX(e.value)}function Xaw(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:hc(e)}}function J3f({endpointExample:e,context:t}){let r={};return e.type!=="full"?e.value:(e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=Zaw(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=kaw(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=eow({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=UX(e.request)),e.response!=null&&(r.response=U3f(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(n=>n.type==="language"?{name:n.name??void 0,docs:n.description??void 0,language:n.language,code:n.code,install:n.install??void 0}:{name:n.name??void 0,docs:n.description??void 0,sdk:n.sdk,code:n.code}).filter(YA)),r)}function Zaw(e){let t={};return e.forEach(r=>{let n=UX(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function kaw(e){let t={};return e.forEach(r=>{let n=UX(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function eow({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=UX(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function Q3f(e){return tG._visit(e,{get:()=>Hre.HttpMethodSchema.Get,post:()=>Hre.HttpMethodSchema.Post,put:()=>Hre.HttpMethodSchema.Put,patch:()=>Hre.HttpMethodSchema.Patch,delete:()=>Hre.HttpMethodSchema.Delete,head:()=>{throw new Error("HEAD is unsupported")},options:()=>{throw new Error("HEAD is unsupported")},trace:()=>{throw new Error("HEAD is unsupported")},_other:()=>{throw new Error("Unkown http method is unsupported")}})}function G3f({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,f=Ywa(e.sdkName,e.namespace),d={};for(let A of e.pathParameters)A.parameterNameOverride&&(u=u.replace(A.name,A.parameterNameOverride)),d[A.parameterNameOverride??A.name]=cma({pathParameter:A,context:r,fileContainingReference:t,namespace:f}),a.add(A.name);let c={};for(let A of e.queryParameters){let T=Kwa({queryParameter:A,context:r,fileContainingReference:t,namespace:f});T!=null&&(c[A.name]=T,a.add(A.name))}let o;e.pagination!=null&&(e.pagination.type==="cursor"?o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results}:o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage});let l={path:u,method:Q3f(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?cSr(e.source):void 0};Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let m={},O=r.builder.getGlobalHeaderNames(),j=e.headers.filter(A=>!O.has(A.name));for(let A of j){let T=v8t({header:A,context:r,fileContainingReference:t,namespace:f});m[A.name]=T,a.add(typeof T=="string"?A.name:T.name??A.name)}if(e.request!=null){r.setInRequest();let A=row({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,queryParameters:Object.keys(c).length>0?c:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(m).length>0?m:void 0,usedNames:a,namespace:f});l.request=A.value,i=[...i,...A.schemaIdsToExclude??[]],r.unsetInRequest()}else{let A=Object.keys(c).length>0,T=Object.keys(m).length>0,B={};(A||T)&&(B.name=e.requestNameOverride??e.generatedRequestName),A&&(B["query-parameters"]=c),T&&(B.headers=m),Object.keys(B).length>0&&(l.request=B)}if(e.response!=null&&e.response._visit({json:A=>{let T=qO({schema:A.schema,context:r,fileContainingReference:t,namespace:f});l.response={docs:A.description??void 0,type:gx(T)},A.responseProperty!=null&&(l.response.property=A.responseProperty)},streamingJson:A=>{let T=qO({schema:A.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:A.description??void 0,type:gx(T),format:"json"}},streamingSse:A=>{let T=qO({schema:A.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:A.description??void 0,type:gx(T),format:"sse"}},file:A=>{l.response={docs:A.description??void 0,type:"file"}},streamingText:A=>{l["response-stream"]={docs:A.description??void 0,type:"text"}},text:A=>{l.response={docs:A.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let A=r.getDefaultServerName(),T=e.server[0];T==null?A!=null&&(l.url=A):l.url=T.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=gz(e.availability)),Object.entries(e.errors).forEach(([A,T])=>{let B=T.generatedName,F=ls.of(mD);r.builder.enableUniqueErrorsPerEndpoint&&(B=`${e.generatedRequestName}${T.generatedName}`,T.schema!=null&&(T.schema.type!=="reference"&&T.schema.type!=="oneOf"?T.schema.generatedName=`${e.generatedRequestName}${T.schema.generatedName}`:T.schema.type==="oneOf"&&(T.schema.value.generatedName=`${e.generatedRequestName}${T.schema.value.generatedName}`)));let C={"status-code":parseInt(A)},N=WDf({location:$3f,namespaceOverride:f});if(T.schema!=null){let ge=qO({schema:T.schema,context:r,fileContainingReference:N,declarationFile:N,namespace:f});C.type=gx(ge),C.docs=T.description}r.builder.addError(N,{name:B,schema:r.isErrorUnknownSchema(parseInt(A))?{...C,type:"unknown"}:C}),l.errors==null&&(l.errors=[]);let U=r.builder.addImport({file:t,fileToImport:N});l.errors.push(U!=null?`${U}.${B}`:B),C.type!=null&&T.examples?.forEach(ge=>{let X={value:UX(ge.example),name:ge.name,docs:ge.description};r.builder.addErrorExample(N,{name:B,example:X})})}),e.examples.length>0&&(l.examples=tow({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[Fju,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function tow({endpointExamples:e,context:t}){return e.map(r=>{try{return J3f({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function row({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:a,queryParameters:u,nonRequestReferencedSchemas:f,headers:d,usedNames:c,namespace:o}){if(n.type==="json"){let l=n.schema.type==="reference"?n.schema.schema:void 0,m=n.schema.type==="reference"?r.getSchema(n.schema.schema,o):n.schema;if(m?.type!=="object"||l!=null&&f.includes(l)){let B=qO({schema:n.schema,fileContainingReference:t,context:r,namespace:o}),F={schemaIdsToExclude:[],value:{body:B}},C=Object.keys(u??{}).length>0,N=Object.keys(d??{}).length>0;return C&&(F.value["query-parameters"]=u),N&&(F.value.headers=d),(C||N)&&(F.value.name=i??a),n.contentType!=null&&(F.value["content-type"]=n.contentType),n.description!=null&&(F.value.docs=n.description),F}let O=Object.fromEntries(m.properties.filter(B=>B.readonly==null?!0:!((e.method==="POST"||e.method==="PUT")&&B.readonly)).map(B=>{let F=qO({schema:B.schema,fileContainingReference:t,context:r,namespace:o}),C=B.nameOverride??B.key,N=gz(B.availability);if(!c.has(C)&&B.audiences.length<=0)return c.add(C),B.nameOverride!=null?[B.key,{type:gx(F),docs:Fhi(F),name:B.nameOverride,availability:N}]:[B.key,N?{...typeof F=="string"?{type:F}:F,availability:N}:F];let U={type:gx(F),docs:Fhi(F)};return c.has(C)&&(U.name=B.generatedName),B.audiences.length>0&&(U.audiences=B.audiences),N!=null&&(U.availability=N),c.add(C),[B.key,U]})),j=m.allOf.map(B=>{let F=qO({schema:J0.reference(B),fileContainingReference:t,context:r,namespace:o});return gx(F)}),A={properties:O};j.length>0&&(A.extends=j),n.additionalProperties&&(A["extra-properties"]=!0);let T={name:i??m.nameOverride??m.generatedName,"query-parameters":u,headers:d,body:A};return n.contentType!=null&&(T["content-type"]=n.contentType),n.description!=null&&(T.docs=n.description),{schemaIdsToExclude:l!=null?[l]:[],value:T}}else{if(n.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":eI.APPLICATION_OCTET_STREAM,...n.description?{docs:n.description}:{}}};if(n.type==="multipart"){let l=Object.fromEntries(n.properties.map(m=>{if(m.schema.type==="file"){let O=m.schema.isArray?"list<file>":"file";if(O=m.schema.isOptional?`optional<${O}>`:O,m.description!=null||m.contentType!=null){let j={type:O};return m.description!=null&&(j.docs=m.description),m.contentType!=null&&(j["content-type"]=m.contentType),[m.key,j]}return[m.key,O]}else{let O=qO({schema:m.schema.value,fileContainingReference:t,context:r,namespace:o});return m.contentType!=null&&(typeof O=="string"?O={type:O,"content-type":m.contentType}:O["content-type"]=m.contentType),[m.key,O]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??a,"query-parameters":u,headers:d,body:{properties:l},"content-type":eI.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else hc(n)}}function now({location:e,namespaceOverride:t}){return t!=null?{...e,file:Wl(ls.of(t),e.file)}:e}function iow(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:ls.of(`${mE(r)}.yml`),endpointId:e.summary!=null?mE(e.summary):mE(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:ls.of(mD),endpointId:mE(e.summary)}:{file:ls.of(mD),endpointId:mE(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:ls.of(mD),endpointId:n};let i=kvi(r),a=kvi(n);if(Iqt(i,a))return{file:ls.of("__package__.yml"),endpointId:r};let u=uow({operationId:n,tag:r,path:e.path,method:e.method});if(u!=null)return u;let f=[];for(let d=0;d<i.length;++d){let c=i[d];if(c!=null&&c===a[d])f.push(c);else{let o=mE(r);return{file:ls.of(`${o}.yml`),endpointId:n,tag:r}}}if(f.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:ls.of(mE(f.join("_"))+".yml"),endpointId:mE(a.slice(f.length).join("_")),tag:r}}function e0i(e){let t=e.tags[0];if(e.sdkName!=null){let r=Byu({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:ls.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return now({namespaceOverride:e.namespace,location:iow(e)})}function kvi(e){let t;return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)?t=e.split(/(?=[A-Z])/):t=e.split(/[^a-zA-Z0-9]+/),t=t.map(r=>r.toLowerCase()),t=g6t(t),t}var aow=new RegExp("[^a-zA-Z0-9{}]+"),oow=new RegExp("[{}]","g");function uow({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(aow).join("_").replaceAll(oow,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:ls.of(mE(t)+".yml"),endpointId:mE(e.slice(0,-1*a.length)),tag:t}}function K3f(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:f,tag:d}=e0i(a),c=f.split(".")[0];c!=null&&t.add(c);let o;if(a.sdkName!=null){let O=e.ir.groups;for(let j of a.sdkName.groupName){let A=typeof j=="string"?j:j.name,T=O[A];if(T==null)break;if(T.summary!=null||T.description!=null){o=O[A];break}}}let l=d==null?void 0:n.tagsById[d];e.setEndpointMethod(a.method);let m=G3f({context:e,endpoint:a,declarationFile:f});e.unsetEndpointMethod(),i=[...i,...m.schemaIdsToExclude],e.builder.addEndpoint(f,{name:u,schema:m.value,source:a.source!=null?cSr(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(f,{"display-name":o?.summary??l?.id,docs:o?.description??l?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function Y3f(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?xSr(r.groupName):void 0,i=qO({schema:J0.primitive(r),context:e,fileContainingReference:ls.of(mD),namespace:n});e.builder.addVariable({name:t,schema:{type:gx(i),docs:r.description??void 0}})}}function X3f(e){for(let t of e.ir.webhooks){let r=low({webhook:t,context:e});if(r==null)continue;let n=Ywa(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=v8t({header:u,context:e,fileContainingReference:r.file,namespace:n});let a={method:t.method,"display-name":t.summary??void 0,headers:i,payload:qO({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:UX(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function sow({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:Wl(ls.of(t),e.file)}:e}function cow({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:ls.of(mD),endpointId:n};let i=kvi(r),a=kvi(n);if(Iqt(i,a))return{file:ls.of("__package__.yml"),endpointId:r};let u=[];for(let f=0;f<i.length;++f){let d=i[f];if(d!=null&&d===a[f])u.push(d);else{let c=mE(r);return{file:ls.of(`${c}.yml`),endpointId:n,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:ls.of(mE(u.join("_"))+".yml"),endpointId:mE(a.slice(u.length).join("_")),tag:r}}function low({webhook:e,context:t}){return e.sdkName!=null?{file:VDf({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:sow({namespaceOverride:e.namespace,location:cow({webhook:e,context:t})})}var fow=ls.of(mD);function Z3f(e){switch(e.type){case"object":return F8t(e.groupName);case"enum":return F8t(e.groupName);case"oneOf":return F8t(e.value.groupName);case"array":return F8t(e.groupName);case"map":return F8t(e.groupName);case"reference":return F8t(e.groupName);case"literal":return F8t(e.groupName);case"optional":return F8t(e.groupName);case"nullable":return F8t(e.groupName);case"primitive":return F8t(e.groupName);case"unknown":return fow;default:hc(e)}}function F8t(e){return C7n(e)}var Fju="external",$3f=ls.of(mD);function k3f({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=Z3f(a),f=QDf({schema:a,context:n,declarationFile:u,namespace:r});if(Kqn(f.schema)){let d=gx(f.schema);if(d===(f.name??i)||d===`optional<${f.name??i}>`)continue}n.builder.addType(u,{name:f.name??i,schema:f.schema})}}function e4f(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),F3f(e),R3f(e),L3f(e),YDf(e),Y3f(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(Fju);let{schemaIdsToExclude:t,sdkGroups:r}=K3f(e);X3f(e);for(let n of e.ir.channel){let i=C7n(n.groupName);B3f({channel:n,context:e,declarationFile:i})}k3f({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:t,namespace:void 0,context:e});for(let[n,i]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))k3f({schemas:i,schemaIdsToExclude:t,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(i=>r.has(i))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}var t0i=class{context;constructor(t){this.context=t}};var Z3r=Jo(require("path"),1);var Zwa=Jo(require("path"),1),kwa=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[u,f]of Object.entries(n.files)){let d=i!=null?ls.of(`${i}${Zwa.default.sep}${u}`):ls.of(u);t[d]=f}let a=Object.keys(n.directories).sort();for(let u of a){let f=i!=null?`${i}${Zwa.default.sep}${u}`:u,d=n.directories[u];r(d,f)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(Zwa.default.sep))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[ls.of(t[0])]??={};let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(n)}};var htn=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new kwa,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":n,"display-name":i,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),n!=null&&(u.service["base-path"]=n),i!=null&&(u.service["display-name"]=i),a!=null&&(u.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return nDr(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{}),r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:n}){if(t===r)return;let i=n??mE((B0(r)+"/"+(0,Z3r.basename)(r,(0,Z3r.extname)(r))).replaceAll("__package__","root"));if(t===ls.of(eF))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=mC(B0(Hp.of(`/${t}`)),Hp.of(`/${r}`)),i;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[i]=mC(B0(Hp.of(`/${t}`)),Hp.of(`/${r}`)),i}addType(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.examples.push(n)))}addError(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:i.errors[r]?.type!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){let i=this.getOrCreateFile(t);if(i.errors==null)return;let a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(f=>Iqt(f,n))??!1)||a.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=i),a.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=Z3r.default.join(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([i,a])=>[i,{...a,path:Z3r.default.join(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,u])=>[a,{...u,path:Z3r.default.join(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===mD?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};var e1a=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;endpointMethod;inRequest=!1;constructor({taskContext:t,ir:r,enableUniqueErrorsPerEndpoint:n,detectGlobalHeaders:i,environmentOverrides:a,globalHeaderOverrides:u,authOverrides:f,objectQueryParameters:d,respectReadonlySchemas:c}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.enableUniqueErrorsPerEndpoint=n,this.builder=new htn(n),r.title!=null&&this.builder.setDisplayName({displayName:r.title}),this.detectGlobalHeaders=i,this.environmentOverrides=a,this.authOverrides=f,this.globalHeaderOverrides=u,this.objectQueryParameters=d,this.respectReadonlySchemas=c;let o={};if(!this.enableUniqueErrorsPerEndpoint)for(let l of r.endpoints)for(let[m,O]of Object.entries(l.errors)){let j=parseInt(m),A=o[j];A==null&&O.schema!=null?o[j]=O.schema:A!=null&&O.schema!=null&&Ewe(A,O.schema)||this.unknownSchema.add(j)}}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInRequest(){return this.inRequest}setInRequest(){this.inRequest=!0}unsetInRequest(){this.inRequest=!1}};function Rju(e){let t=new e1a(e);return e4f(t)}function t1a(e,t){return Vh(e,t)}var Nxe=class extends d2t{specs;sources;respectReadonlySchemas;constructor({specs:t,...r}){super(r),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t),this.respectReadonlySchemas=this.specs.every(n=>n.settings?.respectReadonlySchemas??!1)}async getOpenAPIIr({context:t,relativePathToDependency:r},n){let i=await Jkr({context:t,specs:this.specs,relativePathToDependency:r}),a=dow(n);return await _tn({absoluteFilePathToWorkspace:this.absoluteFilePath,specs:i,taskContext:t,optionOverrides:{...a,respectReadonlySchemas:this.respectReadonlySchemas}})}async getDefinition({context:t,relativePathToDependency:r},n){let i=await this.getOpenAPIIr({context:t,relativePathToDependency:r},n),a=this.specs.every(f=>f.settings?.objectQueryParameters),u=Rju({authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0,taskContext:t,ir:i,enableUniqueErrorsPerEndpoint:n?.enableUniqueErrorsPerEndpoint??!1,detectGlobalHeaders:n?.detectGlobalHeaders??!0,objectQueryParameters:a,respectReadonlySchemas:this.respectReadonlySchemas});return{absoluteFilePath:Hp.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:u.rootApiFile["default-url"],contents:u.rootApiFile,rawContents:Fy.dump(u.rootApiFile)},namedDefinitionFiles:{...t1a(u.definitionFiles,f=>({absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(f),contents:f})),[ls.of(mD)]:{absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(u.packageMarkerFile),contents:u.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new p2t({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(YA)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,n=[];return t.reduce((i,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),i.push({type:a.type,id:c6r(),absoluteFilePath:u})),i},n)}};function r0i(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.enableDiscriminatedUnionV2=!0),t}function dow(e){if(e==null)return;let t={};return e.enableDiscriminatedUnionV2&&(t.discriminatedUnionV2=!0),e.optionalAdditionalProperties&&(t.optionalAdditionalProperties=!0),e.cooerceEnumsToLiterals&&(t.cooerceEnumsToLiterals=!0),t}function t4f(e,t){if(pow(e))return t.alias(e);if(_ow(e))return t.enum(e);if(how(e))return t.object(e);if(yow(e))return t.union(e);hc(e)}function pow(e){return e?.alias!=null}function _ow(e){return e?.values!=null}function how(e){return e?.fields!=null}function yow(e){return e?.union!=null}var j1a={};Dc(j1a,{ConjureAliasDeclaration:()=>s1a,ConjureArgument:()=>m1a,ConjureArgumentWithParamType:()=>g1a,ConjureDefinitions:()=>y1a,ConjureEndpoint:()=>O1a,ConjureEnumDeclaration:()=>_1a,ConjureEnumVariant:()=>p1a,ConjureEnumWithDocs:()=>d1a,ConjureObjectDeclaration:()=>f1a,ConjureParamType:()=>b1a,ConjurePrimitive:()=>u1a,ConjureService:()=>P1a,ConjureServiceName:()=>o1a,ConjureType:()=>t4r,ConjureTypeDeclaration:()=>h1a,ConjureTypeReference:()=>r4r,ConjureTypeWithDocs:()=>c1a,ConjureTypes:()=>v1a,ConjureUnionDeclaration:()=>l1a,DefinitionFile:()=>A4f,WithDocs:()=>L8t,commons:()=>Hju,conjure:()=>Jju,services:()=>Qju,types:()=>Gju});var Hju={};Dc(Hju,{WithDocs:()=>L8t});var _y={};Dc(_y,{JsonError:()=>pNn,ParseError:()=>_Nn,any:()=>h4f,boolean:()=>y4f,booleanLiteral:()=>_4f,date:()=>n4f,discriminant:()=>D4f,enum_:()=>n1a,getObjectLikeUtils:()=>R8t,getObjectUtils:()=>yNn,getSchemaUtils:()=>v2,isProperty:()=>e4r,lazy:()=>i4f,lazyObject:()=>f4f,list:()=>a1a,number:()=>v4f,object:()=>i1a,objectWithoutOptionalProperties:()=>l4f,optional:()=>Lju,property:()=>o4f,record:()=>O4f,set:()=>P4f,string:()=>b4f,stringLiteral:()=>p4f,transform:()=>Uju,undiscriminatedUnion:()=>w4f,union:()=>E4f,unknown:()=>g4f,withParsedProperties:()=>Wju});var ES={DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function Yq(e,t){return`Expected ${t}. Received ${vow(e)}.`}function vow(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function _G(e){return{...e,json:r4f(e.json),parse:r4f(e.parse)}}function r4f(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1924
- `)),{ok:!0,value:t}):n}}function r1a(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var pNn=class e extends Error{errors;constructor(t){super(t.map(r1a).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var _Nn=class e extends Error{errors;constructor(t){super(t.map(r1a).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function v2(e){return{optional:()=>Lju(e),transform:t=>Uju(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new _Nn(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new pNn(n.errors)}}}function Lju(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>ES.OPTIONAL};return{...t,...v2(t)}}function Uju(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...v2(r)}}var bow=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function n4f(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Yq(t,"string")}]}:bow.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:Yq(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:Yq(t,"Date object")}]},getType:()=>ES.DATE};return{..._G(e),...v2(e)}}function hG(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{..._G(r),...v2(r)}}}function n1a(e){let t=new Set(e);return hG(ES.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:Yq(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:Yq(n,"enum")}]}:{ok:!0,value:n})()}function i4f(e){let t=Vju(e);return{...t,...v2(t)}}function Vju(e){return{parse:(t,r)=>hNn(e).parse(t,r),json:(t,r)=>hNn(e).json(t,r),getType:()=>hNn(e).getType()}}function hNn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function n0i(e){return Object.entries(e)}function i0i(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function k3r(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function a0i(e){return Object.keys(e)}function a4f(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function R8t(e){return{withParsedProperties:t=>Wju(e,t)}}function Wju(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!k3r(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Yq(n,"object")}]};let a=new Set(Object.keys(t)),u=i0i(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...v2(r),...R8t(r)}}function o4f(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function e4r(e){return e.isProperty}function i1a(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>e4r(n)?n.rawKey:r),_getParsedProperties:()=>a0i(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of n0i(e)){let d=e4r(f)?f.rawKey:u,c=e4r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,c4f(c)&&a.push(d)}return u4f({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of n0i(e)){let f=e4r(u)?u.valueSchema:u;c4f(f)&&i.push(a)}return u4f({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return e4r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>ES.OBJECT};return{..._G(t),...v2(t),...R8t(t),...yNn(t)}}function u4f({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!k3r(e))return{ok:!1,errors:[{path:a,message:Yq(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let m=l.transform(o);m.ok?d[l.transformedKey]=m.value:(d[c]=o,f.push(...m.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function yNn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>s4f({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>s4f({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>ES.OBJECT};return{...r,...v2(r),...R8t(r),...yNn(r)}}}}function s4f({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=a4f(a0i(t),c=>i.has(c)),f=r(i0i(t,u)),d=n(i0i(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function c4f(e){return!gow(e)}function gow(e){switch(e.getType()){case ES.ANY:case ES.UNKNOWN:case ES.OPTIONAL:return!0;default:return!1}}function l4f(e){return i1a(e)}function f4f(e){let t={...Vju(e),_getRawProperties:()=>hNn(e)._getRawProperties(),_getParsedProperties:()=>hNn(e)._getParsedProperties()};return{...t,...v2(t),...R8t(t),...yNn(t)}}function a1a(e){let t={parse:(r,n)=>d4f(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>d4f(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>ES.LIST};return{..._G(t),...v2(t)}}function d4f(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:Yq(e,"list"),path:[]}]}}function p4f(e){return hG(ES.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Yq(r,`"${e}"`)}]})()}function _4f(e){return hG(ES.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Yq(r,`${e.toString()}`)}]})()}var h4f=hG(ES.ANY,e=>({ok:!0,value:e}));var y4f=hG(ES.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Yq(e,"boolean")}]});var v4f=hG(ES.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Yq(e,"number")}]});var b4f=hG(ES.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Yq(e,"string")}]});var g4f=hG(ES.UNKNOWN,e=>({ok:!0,value:e}));function O4f(e,t){let r={parse:(n,i)=>m4f({value:n,isKeyNumeric:e.getType()===ES.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>m4f({value:n,isKeyNumeric:e.getType()===ES.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>ES.RECORD};return{..._G(r),...v2(r)}}function m4f({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return k3r(e)?n0i(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),o.ok||m.push(...o.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:Yq(e,"object")}]}}function P4f(e){let t=a1a(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Yq(n,"Set")}]},getType:()=>ES.SET};return{..._G(r),...v2(r)}}function w4f(e){let t={parse:(r,n)=>j4f((i,a)=>i.parse(r,a),e,n),json:(r,n)=>j4f((i,a)=>i.json(r,a),e,n),getType:()=>ES.UNDISCRIMINATED_UNION};return{..._G(t),...v2(t)}}function j4f(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function D4f(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function E4f(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=n1a(a0i(t)),a={parse:(u,f)=>S4f({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),json:(u,f)=>S4f({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),getType:()=>ES.UNION};return{..._G(a),...v2(a),...R8t(a)}}function S4f({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!k3r(e))return{ok:!1,errors:[{path:f,message:Yq(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let m=u(c,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var L8t=_y.objectWithoutOptionalProperties({docs:_y.string().optional()});var Jju={};Dc(Jju,{ConjureServiceName:()=>o1a,DefinitionFile:()=>A4f});var o1a=_y.string();var u1a=_y.enum_(["rid","string","safelong","integer","double","boolean"]);var t4r=_y.undiscriminatedUnion([u1a,_y.string()]);var s1a=_y.objectWithoutOptionalProperties({alias:t4r,docs:_y.string().optional()});var c1a=_y.objectWithoutOptionalProperties({type:t4r,docs:_y.string().optional()});var r4r=_y.undiscriminatedUnion([t4r,c1a]);var l1a=_y.objectWithoutOptionalProperties({union:_y.record(_y.string(),r4r)});var f1a=_y.objectWithoutOptionalProperties({fields:_y.record(_y.string(),r4r)});var d1a=_y.objectWithoutOptionalProperties({value:_y.string()}).extend(L8t);var p1a=_y.undiscriminatedUnion([_y.string(),d1a]);var _1a=_y.objectWithoutOptionalProperties({values:_y.list(p1a)});var h1a=_y.undiscriminatedUnion([s1a,l1a,f1a,_1a]);var y1a=_y.objectWithoutOptionalProperties({objects:_y.record(_y.string(),h1a).optional()});var v1a=_y.objectWithoutOptionalProperties({conjureImports:_y.property("conjure-imports",_y.record(_y.string(),_y.string()).optional()),definitions:y1a.optional()});var b1a=_y.enum_(["path","query","body"]);var g1a=_y.objectWithoutOptionalProperties({paramType:_y.property("param-type",b1a),type:_y.string()}).extend(L8t);var m1a=_y.undiscriminatedUnion([_y.string(),g1a]);var O1a=_y.objectWithoutOptionalProperties({http:_y.string(),args:_y.record(_y.string(),m1a).optional(),returns:r4r.optional()}).extend(L8t);var P1a=_y.objectWithoutOptionalProperties({name:_y.string().optional(),package:_y.string().optional(),basePath:_y.property("base-path",_y.string().optional()),endpoints:_y.record(_y.string(),O1a).optional()}).extend(L8t);var A4f=_y.objectWithoutOptionalProperties({types:v1a.optional(),services:_y.record(o1a,P1a).optional()});var Qju={};Dc(Qju,{ConjureArgument:()=>m1a,ConjureArgumentWithParamType:()=>g1a,ConjureEndpoint:()=>O1a,ConjureParamType:()=>b1a,ConjureService:()=>P1a});var Gju={};Dc(Gju,{ConjureAliasDeclaration:()=>s1a,ConjureDefinitions:()=>y1a,ConjureEnumDeclaration:()=>_1a,ConjureEnumVariant:()=>p1a,ConjureEnumWithDocs:()=>d1a,ConjureObjectDeclaration:()=>f1a,ConjurePrimitive:()=>u1a,ConjureType:()=>t4r,ConjureTypeDeclaration:()=>h1a,ConjureTypeReference:()=>r4r,ConjureTypeWithDocs:()=>c1a,ConjureTypes:()=>v1a,ConjureUnionDeclaration:()=>l1a});var M4f=require("fs/promises");async function T4f(e,t){let r=[];for(let n of await KAe(e,t))r.push(await mow({relativeFilepath:mC(e,n),absoluteFilepath:n}));return r}async function mow({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,M4f.readFile)(t)).toString().replaceAll(": rid",": string").replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:j1a.DefinitionFile.parseOrThrow(Fy.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}var o0i=class extends t0i{fernDefinitionBuilder=new htn(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:n,globalHeaderOverrides:i}){if(r!=null){for(let[a,u]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:u});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(n!=null){for(let[a,u]of Object.entries(n.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});n["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(n["default-environment"]),n["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(n["default-url"])}return await x4f(t,(a,u,f)=>{for(let[o,l]of Object.entries(f.services??{})){let m=OJi({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=ls.of(`${m}/__package__.yml`);return}let c=oHo(u)?.split(".")[0];c!=null&&(this.conjureFilepathToFernFilepath[u]=ls.of(`${c}/__package__.yml`))}),await x4f(t,(a,u,f)=>{if(f.services==null||Object.keys(f.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[u];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${u}`);for(let[c,o]of Object.entries(f.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ls.of(o)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:ls.of(l),alias:c})}this.importAllTypes({conjureFile:f,fernFilePath:d});return}for(let[d,c]of Object.entries(f.services)){let o=OJi({value:d,suffix:"Service"}),l=ls.of(`${o}/__package__.yml`),m={};c.basePath!=null&&(m["base-path"]=c.basePath),c.docs!=null&&(m.docs=c.docs),this.fernDefinitionBuilder.setServiceInfo(l,m),this.importAllTypes({conjureFile:f,fernFilePath:l});for(let[O,j]of Object.entries(f.types?.conjureImports??{})){let A=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ls.of(j)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:ls.of(A),alias:O})}for(let[O,j]of Object.entries(c.endpoints??{})){let A=fUo(j.http);if(A.type==="failure"){this.context?.logger.error(`Failed to parse ${j.http}. Skipping.`);continue}let T={auth:!0,path:A.path,method:A.method,response:j.returns==="binary"?"file":j.returns};j.docs!=null&&(T.docs=j.docs);let B={};if(j.args!=null)for(let F of A.pathParameters){let C=j.args[F];if(C==null)throw new Error(`Failed to find path parameter ${F} in ${j.http}`);B[F]=typeof C=="string"?C:{type:C.type}}Object.entries(B).length>0&&(T["path-parameters"]=B);for(let[F,C]of Object.entries(j.args??{}))if(B[F]==null)if(typeof C=="string")T.request={body:C==="binary"?"bytes":C};else switch(C.paramType){case"body":T.request={body:C.type==="binary"?"bytes":C.type};break;case"query":T.request==null?T.request={"query-parameters":{[F]:C.type}}:typeof T.request!="string"&&T.request?.["query-parameters"]==null?T.request["query-parameters"]={[F]:C.type}:typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request["query-parameters"][F]=C.type)}T.request!=null&&typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request.name=`${O}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:O,schema:T,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[n,i]of Object.entries(t.types?.definitions?.objects??{}))t4f(i,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{union:Object.fromEntries(Object.entries(a.union).map(([u,f])=>[u,{type:typeof f=="string"?f:f.type,docs:typeof f=="string"?void 0:f.docs,key:u}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:n}){let i=Wl(B0(t),ls.of(r)),a=jIr(n,i),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function x4f(e,t){for(let r of await T4f(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}var w1a=class extends d2t{absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Wl(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new p2t({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let i=await new o0i(t).import({absolutePathToConjureFolder:this.absolutePathToConjureFolder,authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:Hp.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:i.rootApiFile["default-url"],contents:i.rootApiFile,rawContents:Fy.dump(i.rootApiFile)},namedDefinitionFiles:{...t1a(i.definitionFiles,a=>({absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(a),contents:a})),[ls.of(mD)]:{absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(i.packageMarkerFile),contents:i.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function $ju(e,t){for(let[r,n]of X6(e.failures))Oow({relativeFilepath:r,failure:n,logger:t})}function Oow({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Iw.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case Iw.FILE_READ:r.error("Failed to open file: "+e);break;case Iw.FILE_MISSING:r.error("Missing file: "+e);break;case Iw.FILE_PARSE:t.error instanceof pci?r.error($qt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Iw.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of Pow(n))r.error($qt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case Iw.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Iw.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${nQi}: `+t.dependencyName);break;case Iw.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Iw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Iw.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error($qt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));break;default:hc(t)}}function Pow(e){switch(e.code){case Tp.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${qc.underline(e.expected)} but received ${qc.underline(e.received)}`}];case Tp.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${qc.underline(t)}`}));case Tp.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>qc.underline(t)).join(", ")}`}];case Tp.invalid_union:case Tp.invalid_arguments:case Tp.invalid_return_type:case Tp.invalid_date:case Tp.invalid_string:case Tp.too_small:case Tp.too_big:case Tp.invalid_intersection_types:case Tp.not_multiple_of:case Tp.custom:default:return[{title:e.message}]}}var q4f=require("fs/promises");async function C4f(e,t){let r=[];for(let n of await KAe(e,t))r.push(await jow({relativeFilepath:mC(e,n),absoluteFilepath:n}));return r}async function jow({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,q4f.readFile)(t)).toString()}}async function B4f({absolutePathToWorkspace:e}){let t=Wl(e,ls.of(KLc));if(!await _h(t))return;let n=await C4f(t,"{md,mdx}");return{files:await Promise.all(n.map(i=>({absoluteFilepath:i.absoluteFilepath,contents:i.fileContents})))}}async function Kju({absolutePathToWorkspace:e,namespace:t,definitions:r}){let n=[];for(let i of r){let a=i.overrides!=null?Wl(e,ls.of(i.overrides)):void 0;if(i.schema.type==="protobuf"){let f=Wl(e,ls.of(i.schema.root));if(!await _h(f))return{didSucceed:!1,failures:{[ls.of(i.schema.root)]:{type:Iw.FILE_MISSING}}};let d=Wl(e,ls.of(i.schema.target));if(!await _h(d))return{didSucceed:!1,failures:{[ls.of(i.schema.target)]:{type:Iw.FILE_MISSING}}};n.push({type:"protobuf",absoluteFilepathToProtobufRoot:f,absoluteFilepathToProtobufTarget:d,absoluteFilepathToOverrides:a,generateLocally:i.schema.localGeneration,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:i.settings?.objectQueryParameters??!1,respectReadonlySchemas:i.settings?.respectReadonlySchemas??!1}});continue}let u=Wl(e,ls.of(i.schema.path));if(!await _h(u))return{didSucceed:!1,failures:{[ls.of(i.schema.path)]:{type:Iw.FILE_MISSING}}};if(i.overrides!=null&&a!=null&&!await _h(a))return{didSucceed:!1,failures:{[ls.of(i.overrides)]:{type:Iw.FILE_MISSING}}};n.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,asyncApiNaming:i.settings?.asyncApiMessageNaming,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:i.settings?.objectQueryParameters??!1,respectReadonlySchemas:i.settings?.respectReadonlySchemas??!1},source:{type:"openapi",file:u},namespace:t})}return n}async function u0i({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:n}){let i=await yO.loadGeneratorsConfiguration({absolutePathToWorkspace:e,context:t}),a;try{a=await B4f({absolutePathToWorkspace:e})}catch{}if(i?.api!=null&&i?.api.type==="conjure")return{didSucceed:!0,workspace:new w1a({workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:ls.of(i.api.pathToConjureDefinition)})};if(i?.api!=null&&(i.api.type==="singleNamespace"&&i.api.definitions.length>0||i.api.type==="multiNamespace")){let u=[];if(i.api.type==="singleNamespace"){let f=await Kju({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.definitions});if(!Array.isArray(f))return f;u.push(...f)}else{for(let[f,d]of Object.entries(i.api.definitions)){let c=await Kju({absolutePathToWorkspace:e,namespace:f,definitions:d});if(!Array.isArray(c))return c;u.push(...c)}if(i.api.rootDefinitions!=null){let f=await Kju({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.rootDefinitions});if(!Array.isArray(f))return f;u.push(...f)}}return{didSucceed:!0,workspace:new Nxe({specs:u,workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r})}}return await _h(Wl(e,ls.of(v9)))?{didSucceed:!0,workspace:new i7n({absoluteFilePath:e,generatorsConfiguration:i,workspaceName:n,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:u0i})}:{didSucceed:!1,failures:{[ls.of(lYr)]:{type:Iw.MISCONFIGURED_DIRECTORY}}}}var I4f=require("fs/promises");var z4f=Jo(require("path"),1);async function Yju({fernDirectory:e,context:t}){let r=Wl(e,ls.of(u1r));if(!await _h(r))return;let n=await wow({absolutePathToDocsDefinition:e,context:t});if(n!=null)return{type:"docs",absoluteFilePath:e,config:n,workspaceName:void 0,absoluteFilepathToDocsConfig:Wl(e,ls.of(u1r))}}async function wow({absolutePathToDocsDefinition:e,context:t}){if(!await _h(e))return;let r=Wl(e,ls.of(u1r));return await Dow({absolutePathOfConfiguration:r,context:t})}async function Dow({absolutePathOfConfiguration:e,context:t}){let r=await(0,I4f.readFile)(e),n=Fy.load(r.toString());return await Sow({value:n,context:t,filepathBeingParsed:e})}async function Sow({value:e,context:t,filepathBeingParsed:r}){let n=await pMe.RawSchemas.Serializer.DocsConfiguration.parse(e);if(n.ok)return n.value;let i=n.errors.map(u=>{let f=u.path.length>0?`${u.message} at "${u.path.join(" -> ")}"`:u.message;return VY({content:f,prefix:" - "})}),a=[`Failed to parse file: ${z4f.default.relative(process.cwd(),r)}`,...i].join(`
1924
+ `)),{ok:!0,value:t}):n}}function r1a(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var pNn=class e extends Error{errors;constructor(t){super(t.map(r1a).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var _Nn=class e extends Error{errors;constructor(t){super(t.map(r1a).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function v2(e){return{optional:()=>Lju(e),transform:t=>Uju(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new _Nn(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new pNn(n.errors)}}}function Lju(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>ES.OPTIONAL};return{...t,...v2(t)}}function Uju(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...v2(r)}}var bow=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function n4f(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Yq(t,"string")}]}:bow.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:Yq(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:Yq(t,"Date object")}]},getType:()=>ES.DATE};return{..._G(e),...v2(e)}}function hG(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{..._G(r),...v2(r)}}}function n1a(e){let t=new Set(e);return hG(ES.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:Yq(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:Yq(n,"enum")}]}:{ok:!0,value:n})()}function i4f(e){let t=Vju(e);return{...t,...v2(t)}}function Vju(e){return{parse:(t,r)=>hNn(e).parse(t,r),json:(t,r)=>hNn(e).json(t,r),getType:()=>hNn(e).getType()}}function hNn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function n0i(e){return Object.entries(e)}function i0i(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function k3r(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function a0i(e){return Object.keys(e)}function a4f(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function R8t(e){return{withParsedProperties:t=>Wju(e,t)}}function Wju(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!k3r(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Yq(n,"object")}]};let a=new Set(Object.keys(t)),u=i0i(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...v2(r),...R8t(r)}}function o4f(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function e4r(e){return e.isProperty}function i1a(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>e4r(n)?n.rawKey:r),_getParsedProperties:()=>a0i(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of n0i(e)){let d=e4r(f)?f.rawKey:u,c=e4r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,c4f(c)&&a.push(d)}return u4f({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of n0i(e)){let f=e4r(u)?u.valueSchema:u;c4f(f)&&i.push(a)}return u4f({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return e4r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>ES.OBJECT};return{..._G(t),...v2(t),...R8t(t),...yNn(t)}}function u4f({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!k3r(e))return{ok:!1,errors:[{path:a,message:Yq(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let m=l.transform(o);m.ok?d[l.transformedKey]=m.value:(d[c]=o,f.push(...m.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function yNn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>s4f({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>s4f({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>ES.OBJECT};return{...r,...v2(r),...R8t(r),...yNn(r)}}}}function s4f({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=a4f(a0i(t),c=>i.has(c)),f=r(i0i(t,u)),d=n(i0i(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function c4f(e){return!gow(e)}function gow(e){switch(e.getType()){case ES.ANY:case ES.UNKNOWN:case ES.OPTIONAL:return!0;default:return!1}}function l4f(e){return i1a(e)}function f4f(e){let t={...Vju(e),_getRawProperties:()=>hNn(e)._getRawProperties(),_getParsedProperties:()=>hNn(e)._getParsedProperties()};return{...t,...v2(t),...R8t(t),...yNn(t)}}function a1a(e){let t={parse:(r,n)=>d4f(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>d4f(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>ES.LIST};return{..._G(t),...v2(t)}}function d4f(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:Yq(e,"list"),path:[]}]}}function p4f(e){return hG(ES.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Yq(r,`"${e}"`)}]})()}function _4f(e){return hG(ES.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Yq(r,`${e.toString()}`)}]})()}var h4f=hG(ES.ANY,e=>({ok:!0,value:e}));var y4f=hG(ES.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Yq(e,"boolean")}]});var v4f=hG(ES.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Yq(e,"number")}]});var b4f=hG(ES.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Yq(e,"string")}]});var g4f=hG(ES.UNKNOWN,e=>({ok:!0,value:e}));function O4f(e,t){let r={parse:(n,i)=>m4f({value:n,isKeyNumeric:e.getType()===ES.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>m4f({value:n,isKeyNumeric:e.getType()===ES.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>ES.RECORD};return{..._G(r),...v2(r)}}function m4f({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return k3r(e)?n0i(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),o.ok||m.push(...o.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:Yq(e,"object")}]}}function P4f(e){let t=a1a(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Yq(n,"Set")}]},getType:()=>ES.SET};return{..._G(r),...v2(r)}}function w4f(e){let t={parse:(r,n)=>j4f((i,a)=>i.parse(r,a),e,n),json:(r,n)=>j4f((i,a)=>i.json(r,a),e,n),getType:()=>ES.UNDISCRIMINATED_UNION};return{..._G(t),...v2(t)}}function j4f(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function D4f(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function E4f(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=n1a(a0i(t)),a={parse:(u,f)=>S4f({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),json:(u,f)=>S4f({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),getType:()=>ES.UNION};return{..._G(a),...v2(a),...R8t(a)}}function S4f({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!k3r(e))return{ok:!1,errors:[{path:f,message:Yq(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let m=u(c,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var L8t=_y.objectWithoutOptionalProperties({docs:_y.string().optional()});var Jju={};Dc(Jju,{ConjureServiceName:()=>o1a,DefinitionFile:()=>A4f});var o1a=_y.string();var u1a=_y.enum_(["rid","string","safelong","integer","double","boolean"]);var t4r=_y.undiscriminatedUnion([u1a,_y.string()]);var s1a=_y.objectWithoutOptionalProperties({alias:t4r,docs:_y.string().optional()});var c1a=_y.objectWithoutOptionalProperties({type:t4r,docs:_y.string().optional()});var r4r=_y.undiscriminatedUnion([t4r,c1a]);var l1a=_y.objectWithoutOptionalProperties({union:_y.record(_y.string(),r4r)});var f1a=_y.objectWithoutOptionalProperties({fields:_y.record(_y.string(),r4r)});var d1a=_y.objectWithoutOptionalProperties({value:_y.string()}).extend(L8t);var p1a=_y.undiscriminatedUnion([_y.string(),d1a]);var _1a=_y.objectWithoutOptionalProperties({values:_y.list(p1a)});var h1a=_y.undiscriminatedUnion([s1a,l1a,f1a,_1a]);var y1a=_y.objectWithoutOptionalProperties({objects:_y.record(_y.string(),h1a).optional()});var v1a=_y.objectWithoutOptionalProperties({conjureImports:_y.property("conjure-imports",_y.record(_y.string(),_y.string()).optional()),definitions:y1a.optional()});var b1a=_y.enum_(["path","query","body"]);var g1a=_y.objectWithoutOptionalProperties({paramType:_y.property("param-type",b1a),type:_y.string()}).extend(L8t);var m1a=_y.undiscriminatedUnion([_y.string(),g1a]);var O1a=_y.objectWithoutOptionalProperties({http:_y.string(),args:_y.record(_y.string(),m1a).optional(),returns:r4r.optional()}).extend(L8t);var P1a=_y.objectWithoutOptionalProperties({name:_y.string().optional(),package:_y.string().optional(),basePath:_y.property("base-path",_y.string().optional()),endpoints:_y.record(_y.string(),O1a).optional()}).extend(L8t);var A4f=_y.objectWithoutOptionalProperties({types:v1a.optional(),services:_y.record(o1a,P1a).optional()});var Qju={};Dc(Qju,{ConjureArgument:()=>m1a,ConjureArgumentWithParamType:()=>g1a,ConjureEndpoint:()=>O1a,ConjureParamType:()=>b1a,ConjureService:()=>P1a});var Gju={};Dc(Gju,{ConjureAliasDeclaration:()=>s1a,ConjureDefinitions:()=>y1a,ConjureEnumDeclaration:()=>_1a,ConjureEnumVariant:()=>p1a,ConjureEnumWithDocs:()=>d1a,ConjureObjectDeclaration:()=>f1a,ConjurePrimitive:()=>u1a,ConjureType:()=>t4r,ConjureTypeDeclaration:()=>h1a,ConjureTypeReference:()=>r4r,ConjureTypeWithDocs:()=>c1a,ConjureTypes:()=>v1a,ConjureUnionDeclaration:()=>l1a});var M4f=require("fs/promises");async function T4f(e,t){let r=[];for(let n of await KAe(e,t))r.push(await mow({relativeFilepath:mC(e,n),absoluteFilepath:n}));return r}async function mow({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,M4f.readFile)(t)).toString().replaceAll(": rid",": string").replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:j1a.DefinitionFile.parseOrThrow(Fy.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}var o0i=class extends t0i{fernDefinitionBuilder=new htn(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:n,globalHeaderOverrides:i}){if(r!=null){for(let[a,u]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:u});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(n!=null){for(let[a,u]of Object.entries(n.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});n["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(n["default-environment"]),n["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(n["default-url"])}return await x4f(t,(a,u,f)=>{for(let[o,l]of Object.entries(f.services??{})){let m=OJi({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=ls.of(`${m}/__package__.yml`);return}let c=oHo(u)?.split(".")[0];c!=null&&(this.conjureFilepathToFernFilepath[u]=ls.of(`${c}/__package__.yml`))}),await x4f(t,(a,u,f)=>{if(f.services==null||Object.keys(f.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[u];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${u}`);for(let[c,o]of Object.entries(f.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ls.of(o)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:ls.of(l),alias:c})}this.importAllTypes({conjureFile:f,fernFilePath:d});return}for(let[d,c]of Object.entries(f.services)){let o=OJi({value:d,suffix:"Service"}),l=ls.of(`${o}/__package__.yml`),m={};c.basePath!=null&&(m["base-path"]=c.basePath),c.docs!=null&&(m.docs=c.docs),this.fernDefinitionBuilder.setServiceInfo(l,m),this.importAllTypes({conjureFile:f,fernFilePath:l});for(let[O,j]of Object.entries(f.types?.conjureImports??{})){let A=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ls.of(j)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:ls.of(A),alias:O})}for(let[O,j]of Object.entries(c.endpoints??{})){let A=fUo(j.http);if(A.type==="failure"){this.context?.logger.error(`Failed to parse ${j.http}. Skipping.`);continue}let T={auth:!0,path:A.path,method:A.method,response:j.returns==="binary"?"file":j.returns};j.docs!=null&&(T.docs=j.docs);let B={};if(j.args!=null)for(let F of A.pathParameters){let C=j.args[F];if(C==null)throw new Error(`Failed to find path parameter ${F} in ${j.http}`);B[F]=typeof C=="string"?C:{type:C.type}}Object.entries(B).length>0&&(T["path-parameters"]=B);for(let[F,C]of Object.entries(j.args??{}))if(B[F]==null)if(typeof C=="string")T.request?typeof T.request=="string"&&(T.request={body:T.request}):T.request={},T.request.body=C==="binary"?"bytes":C;else switch(C.paramType){case"body":T.request={body:C.type==="binary"?"bytes":C.type};break;case"query":T.request==null?T.request={"query-parameters":{[F]:C.type}}:typeof T.request!="string"&&T.request?.["query-parameters"]==null?T.request["query-parameters"]={[F]:C.type}:typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request["query-parameters"][F]=C.type)}T.request!=null&&typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request.name=`${O}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:O,schema:T,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[n,i]of Object.entries(t.types?.definitions?.objects??{}))t4f(i,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{union:Object.fromEntries(Object.entries(a.union).map(([u,f])=>[u,{type:typeof f=="string"?f:f.type,docs:typeof f=="string"?void 0:f.docs,key:u}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:n}){let i=Wl(B0(t),ls.of(r)),a=jIr(n,i),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function x4f(e,t){for(let r of await T4f(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}var w1a=class extends d2t{absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Wl(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new p2t({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let i=await new o0i(t).import({absolutePathToConjureFolder:this.absolutePathToConjureFolder,authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:Hp.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:i.rootApiFile["default-url"],contents:i.rootApiFile,rawContents:Fy.dump(i.rootApiFile)},namedDefinitionFiles:{...t1a(i.definitionFiles,a=>({absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(a),contents:a})),[ls.of(mD)]:{absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(i.packageMarkerFile),contents:i.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function $ju(e,t){for(let[r,n]of X6(e.failures))Oow({relativeFilepath:r,failure:n,logger:t})}function Oow({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Iw.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case Iw.FILE_READ:r.error("Failed to open file: "+e);break;case Iw.FILE_MISSING:r.error("Missing file: "+e);break;case Iw.FILE_PARSE:t.error instanceof pci?r.error($qt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Iw.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of Pow(n))r.error($qt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case Iw.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Iw.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${nQi}: `+t.dependencyName);break;case Iw.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Iw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Iw.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error($qt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));break;default:hc(t)}}function Pow(e){switch(e.code){case Tp.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${qc.underline(e.expected)} but received ${qc.underline(e.received)}`}];case Tp.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${qc.underline(t)}`}));case Tp.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>qc.underline(t)).join(", ")}`}];case Tp.invalid_union:case Tp.invalid_arguments:case Tp.invalid_return_type:case Tp.invalid_date:case Tp.invalid_string:case Tp.too_small:case Tp.too_big:case Tp.invalid_intersection_types:case Tp.not_multiple_of:case Tp.custom:default:return[{title:e.message}]}}var q4f=require("fs/promises");async function C4f(e,t){let r=[];for(let n of await KAe(e,t))r.push(await jow({relativeFilepath:mC(e,n),absoluteFilepath:n}));return r}async function jow({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,q4f.readFile)(t)).toString()}}async function B4f({absolutePathToWorkspace:e}){let t=Wl(e,ls.of(KLc));if(!await _h(t))return;let n=await C4f(t,"{md,mdx}");return{files:await Promise.all(n.map(i=>({absoluteFilepath:i.absoluteFilepath,contents:i.fileContents})))}}async function Kju({absolutePathToWorkspace:e,namespace:t,definitions:r}){let n=[];for(let i of r){let a=i.overrides!=null?Wl(e,ls.of(i.overrides)):void 0;if(i.schema.type==="protobuf"){let f=Wl(e,ls.of(i.schema.root));if(!await _h(f))return{didSucceed:!1,failures:{[ls.of(i.schema.root)]:{type:Iw.FILE_MISSING}}};let d=Wl(e,ls.of(i.schema.target));if(!await _h(d))return{didSucceed:!1,failures:{[ls.of(i.schema.target)]:{type:Iw.FILE_MISSING}}};n.push({type:"protobuf",absoluteFilepathToProtobufRoot:f,absoluteFilepathToProtobufTarget:d,absoluteFilepathToOverrides:a,generateLocally:i.schema.localGeneration,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:i.settings?.objectQueryParameters??!1,respectReadonlySchemas:i.settings?.respectReadonlySchemas??!1}});continue}let u=Wl(e,ls.of(i.schema.path));if(!await _h(u))return{didSucceed:!1,failures:{[ls.of(i.schema.path)]:{type:Iw.FILE_MISSING}}};if(i.overrides!=null&&a!=null&&!await _h(a))return{didSucceed:!1,failures:{[ls.of(i.overrides)]:{type:Iw.FILE_MISSING}}};n.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,asyncApiNaming:i.settings?.asyncApiMessageNaming,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:i.settings?.objectQueryParameters??!1,respectReadonlySchemas:i.settings?.respectReadonlySchemas??!1},source:{type:"openapi",file:u},namespace:t})}return n}async function u0i({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:n}){let i=await yO.loadGeneratorsConfiguration({absolutePathToWorkspace:e,context:t}),a;try{a=await B4f({absolutePathToWorkspace:e})}catch{}if(i?.api!=null&&i?.api.type==="conjure")return{didSucceed:!0,workspace:new w1a({workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:ls.of(i.api.pathToConjureDefinition)})};if(i?.api!=null&&(i.api.type==="singleNamespace"&&i.api.definitions.length>0||i.api.type==="multiNamespace")){let u=[];if(i.api.type==="singleNamespace"){let f=await Kju({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.definitions});if(!Array.isArray(f))return f;u.push(...f)}else{for(let[f,d]of Object.entries(i.api.definitions)){let c=await Kju({absolutePathToWorkspace:e,namespace:f,definitions:d});if(!Array.isArray(c))return c;u.push(...c)}if(i.api.rootDefinitions!=null){let f=await Kju({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.rootDefinitions});if(!Array.isArray(f))return f;u.push(...f)}}return{didSucceed:!0,workspace:new Nxe({specs:u,workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r})}}return await _h(Wl(e,ls.of(v9)))?{didSucceed:!0,workspace:new i7n({absoluteFilePath:e,generatorsConfiguration:i,workspaceName:n,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:u0i})}:{didSucceed:!1,failures:{[ls.of(lYr)]:{type:Iw.MISCONFIGURED_DIRECTORY}}}}var I4f=require("fs/promises");var z4f=Jo(require("path"),1);async function Yju({fernDirectory:e,context:t}){let r=Wl(e,ls.of(u1r));if(!await _h(r))return;let n=await wow({absolutePathToDocsDefinition:e,context:t});if(n!=null)return{type:"docs",absoluteFilePath:e,config:n,workspaceName:void 0,absoluteFilepathToDocsConfig:Wl(e,ls.of(u1r))}}async function wow({absolutePathToDocsDefinition:e,context:t}){if(!await _h(e))return;let r=Wl(e,ls.of(u1r));return await Dow({absolutePathOfConfiguration:r,context:t})}async function Dow({absolutePathOfConfiguration:e,context:t}){let r=await(0,I4f.readFile)(e),n=Fy.load(r.toString());return await Sow({value:n,context:t,filepathBeingParsed:e})}async function Sow({value:e,context:t,filepathBeingParsed:r}){let n=await pMe.RawSchemas.Serializer.DocsConfiguration.parse(e);if(n.ok)return n.value;let i=n.errors.map(u=>{let f=u.path.length>0?`${u.message} at "${u.path.join(" -> ")}"`:u.message;return VY({content:f,prefix:" - "})}),a=[`Failed to parse file: ${z4f.default.relative(process.cwd(),r)}`,...i].join(`
1925
1925
  `);return t.failAndThrow(a)}var N4f=require("fs/promises");async function Xju({context:e,nameOverride:t,...r}){let n=await Vzr(t);return n==null?e.failAndThrow(`Directory "${t??Lqt}" not found.`):await F4f({absolutePathToFernDirectory:n,context:e,nameOverride:t,...r})}async function F4f({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:i,context:a}){let u=[];return(await _h(Wl(e,ls.of(vIr)))||await _h(Wl(e,ls.of(v9)))||await _h(Wl(e,ls.of(k6)))||await _h(Wl(e,ls.of(lYr)))||await _h(Wl(e,ls.of(YLc))))&&(u=await R4f({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:i})),{config:await V6t.loadProjectConfig({directory:e,context:a}),apiWorkspaces:u,docsWorkspaces:await Yju({fernDirectory:e,context:a}),loadAPIWorkspace:f=>f==null?u[0]:u.find(d=>d.workspaceName===f)}}async function R4f({cliName:e,fernDirectory:t,context:r,cliVersion:n,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:a}){let u=Wl(t,ls.of(vIr));if(await _h(u)){let o=(await(0,N4f.readdir)(u,{withFileTypes:!0})).reduce((O,j)=>(j.isDirectory()&&O.push(j.name),O),[]);if(i!=null){if(!o.includes(i))return r.failAndThrow("API does not exist: "+i)}else{if(o.length===0)return r.failAndThrow("No APIs found.");if(o.length>1&&!a){let O=`There are multiple workspaces. You must specify one with --api:
1926
1926
  `,j=Math.max(...o.map(A=>A.length));return O+=o.map(A=>{let T=`${e} ${process.argv.slice(2).join(" ")} --api ${A}`;return` \u203A ${qc.bold(A.padEnd(j))} ${qc.dim(T)}`}).join(`
1927
1927
  `),r.failAndThrow(O)}}let l=[],m=i!=null?o.filter(O=>O===i):o;return await Promise.all(m.map(async O=>{let j=await u0i({absolutePathToWorkspace:Wl(u,ls.of(O)),context:r,cliVersion:n,workspaceName:O});j.didSucceed?l.push(j.workspace):($ju(j,r.logger),r.failAndThrow())})),l}let d=await u0i({absolutePathToWorkspace:t,context:r,cliVersion:n,workspaceName:void 0});return d.didSucceed?[d.workspace]:($ju(d,r.logger),[])}async function EC(e,t,r=!1){let n=e.addTask().start(),i=await Xju({...t,cliName:e.environment.cliName,cliVersion:e.environment.packageVersion,context:n});return n.finish(),r&&i.docsWorkspaces!=null?e.registerWorkspaces([...i.apiWorkspaces,i.docsWorkspaces]):e.registerWorkspaces(i.apiWorkspaces),e.registerProject(i),i}var G4f=Jo(Tli(),1);var U4f=require("fs/promises");var vNn={GitHub:"github",Local:"local-file-system",PackageRegistry:"publish"};async function V4f({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:n,apiKeyFallback:i="FERN_DEFAULT",project:{apiWorkspaces:a},outputLocation:u,excludedModes:f,includedModes:d}){let c={};await Promise.all(a.map(async l=>{await e.runTaskForWorkspace(l,async m=>{if(n!=null&&(l.workspaceName==null||!n.has(l.workspaceName)))return;let O=await yO.loadGeneratorsConfiguration({absolutePathToWorkspace:l.absoluteFilePath,context:m});if(O==null||O.groups==null)return;let j=l.workspaceName??i;c[j]={};for(let A of O.groups)r!=null&&!r.has(A.groupName)||(c[j][A.groupName]=A.generators.filter(T=>{let B=!0;return d!=null&&(B=L4f(T,d)),f!=null&&(B=!L4f(T,f)),B}).filter(T=>t==null||t.has(T.name)).map(T=>T.name))})}));let o=Fy.dump(c);if(u==null){process.stdout.write(o);return}try{await(0,U4f.writeFile)(u,o)}catch(l){e.failAndThrow(`Could not write file to the specified location: ${u}`,l)}}function L4f(e,t){let r,n=e.outputMode.type;switch(n){case"downloadFiles":r=vNn.Local;break;case"github":case"githubV2":r=vNn.GitHub;break;case"publish":case"publishV2":r=vNn.PackageRegistry;break;default:hc(n)}return t.has(r)}async function W4f({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:n,project:{apiWorkspaces:i}}){let a;return await Promise.all(i.map(async u=>{await e.runTaskForWorkspace(u,async f=>{if(n!=null&&(u.workspaceName==null||n!==u.workspaceName))return;let d=await yO.loadGeneratorsConfiguration({absolutePathToWorkspace:u.absoluteFilePath,context:f});if(!(d==null||d.groups==null)){for(let c of d.groups)if(r===c.groupName)for(let o of c.generators)t===o.name&&(a=o)}})})),a}var H4f=require("fs/promises");async function J4f({project:e,outputLocation:t,context:r}){let n=e.config.organization;if(t==null){process.stdout.write(n);return}try{await(0,H4f.writeFile)(t,n)}catch(i){r.failAndThrow(`Could not write file to the specified location: ${t}`,i)}}var D1a=require("fs/promises"),s0i=Jo(require("path"),1),bNn=Jo(Bne(),1);async function Eow({absolutePathToWorkspace:e,context:t,generatorFilter:r,groupFilter:n,includeMajor:i,channel:a,cliVersion:u}){let f=yO.getPathToGeneratorsConfiguration({absolutePathToWorkspace:e});if(!await _h(f)){t.logger.debug("Generators configuration file was not found, no generators to upgrade.");return}let d=await(0,D1a.readFile)(f);t.logger.debug(`Found generators: ${d.toString()}`);let c=bNn.default.parseDocument(d.toString()),o=c.get("groups");if(o==null){t.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}if(!bNn.default.isMap(o)){t.failAndThrow(`Expected 'groups' to be a map in ${s0i.default.relative(process.cwd(),f)}`);return}t.logger.debug(`Groups found: ${o.toString()}`);for(let l of o.items){let m=l.key.value,O=l.value;if(!bNn.default.isMap(O)){t.failAndThrow(`Expected group ${m} to be a map in ${s0i.default.relative(process.cwd(),f)}`);continue}if(n!=null&&n!==m){t.logger.debug(`Skipping group ${m} as it does not match the filter: ${n}`);continue}let j=O.get("generators");if(!bNn.default.isSeq(j)){t.failAndThrow(`Expected group ${m} to have a 'generators' key in ${s0i.default.relative(process.cwd(),f)}`);continue}t.logger.debug(`Generators found: ${j.toString()}`);for(let A of j.items){bNn.default.isMap(A)||t.failAndThrow(`Expected generator in group ${m} to be a map in ${s0i.default.relative(process.cwd(),f)}`);let T=A.get("name");if(r!=null&&T!==r){t.logger.debug(`Skipping generator ${T} as it does not match the filter: ${r}`);continue}let B=yO.getGeneratorNameOrThrow(T,t),F=A.get("version"),C=await yO.getLatestGeneratorVersion({generatorName:B,cliVersion:u,currentGeneratorVersion:F,channel:a,includeMajor:i,context:t});C!=null&&(t.logger.debug(qc.green(`Upgrading ${T} from ${F} to ${C}`)),A.set("version",C))}}return c.toString()}async function Q4f({cliContext:e,generator:t,group:r,project:{apiWorkspaces:n},includeMajor:i,channel:a}){await Promise.all(n.map(async u=>{await e.runTaskForWorkspace(u,async f=>{let d=await yO.loadRawGeneratorsConfiguration({absolutePathToWorkspace:u.absoluteFilePath,context:f})??{};if(d==null||d.groups==null){f.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}u.workspaceName==null?f.logger.info("Upgrading generators."):f.logger.info(`Upgrading generators in workspace: ${u.workspaceName}.`);let c=await Eow({absolutePathToWorkspace:u.absoluteFilePath,context:f,generatorFilter:t,groupFilter:r,includeMajor:i,channel:a,cliVersion:e.environment.packageVersion});c!=null&&await(0,D1a.writeFile)(u.generatorsConfiguration?.absolutePathToConfiguration??yO.getPathToGeneratorsConfiguration({absolutePathToWorkspace:u.absoluteFilePath}),c)})}))}var $4f=require("fs/promises");function K4f(e,t){e.command("organization",!1,r=>r.option("output",{string:!0,alias:"o",description:"The location to output the organization name as a text file, defaults to standard out."}),async r=>{await t.instrumentPostHogEvent({command:"fern organization",properties:{outputLocation:r.output}}),await J4f({project:await EC(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),context:t,outputLocation:r.output})})}function Y4f(e,t){e.command("generator","Operate on the generators within your Fern configuration",r=>{r.command("list",!1,n=>n.option("output",{string:!0,alias:"o",description:"The location to output the list as a text file, defaults to standard out."}).option("generators",{string:!0,type:"array",description:"The type of generator to include in the list, ex: `fern-typescript-node-sdk`. If omitted, all generators will be listed."}).option("groups",{type:"array",string:!0,description:"The groups to include generators from, if group is not specified, the all generators of the specified type will be listed."}).option("apis",{type:"array",string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("api-fallback",{string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("include-mode",{choices:Object.values(vNn),type:"array",description:"The generator output modes to include within the outputted list."}).option("exclude-mode",{choices:Object.values(vNn),type:"array",description:"The generator output modes to exclude within the outputted list."}),async n=>{await t.instrumentPostHogEvent({command:"fern generator list",properties:{outputLocation:n.output}}),await V4f({project:await EC(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),generatorFilter:n.generators?new Set(n.generators):void 0,groupFilter:n.groups?new Set(n.groups):void 0,apiFilter:n.apis?new Set(n.apis):void 0,apiKeyFallback:n.apiFallback,cliContext:t,outputLocation:n.output,includedModes:n["include-mode"]?new Set(n["include-mode"]):void 0,excludedModes:n["exclude-mode"]?new Set(n["exclude-mode"]):void 0})}).command("upgrade",`Upgrades the specified generator in ${k6} to the latest stable version.`,n=>n.option("generator",{string:!0,description:"The type of generator to upgrade, ex: `fern-typescript-node-sdk`."}).option("group",{string:!0,description:"The group in which the generator is located, if group is not specified, the all generators of the specified type will be upgraded."}).option("api",{string:!0,description:"The API to upgrade the generator for. If not specified, the generator will be upgraded for all APIs."}).option("include-major",{boolean:!0,default:!1,description:"Whether or not to include major versions within the upgrade. Defaults to false, meaning major versions will be skipped."}).option("channel",{demandOption:!1,choices:Object.values(G4f.FernRegistry.generators.ReleaseType)}).option("list",{demandOption:!1,boolean:!0,default:!1,description:"When specified, a list of available upgrades will be displayed, but no upgrade will be taken."}),async n=>{await t.instrumentPostHogEvent({command:"fern generator upgrade",properties:{generator:n.generator,version:n.version,api:n.api,group:n.group,includeMajor:n.includeMajor,rc:n.rc}});let i=await EC(t,{commandLineApiWorkspace:n.api,defaultToAllApiWorkspaces:!0});if(n.list){t.suppressUpgradeMessage();let a=await mva({cliContext:t,project:i,generatorFilter:n.generator,groupFilter:n.group,includeMajor:n.includeMajor,channel:n.channel}),u=await wpu({generatorUpgradeInfo:a,header:`Generator Upgrades